CMS 3D CMS Logo

MuRingForwardDoubleLayer.cc
Go to the documentation of this file.
1 
12 
14 
15 #include <algorithm>
16 #include <iostream>
17 #include <vector>
18 
19 using namespace std;
20 
21 MuRingForwardDoubleLayer::MuRingForwardDoubleLayer(const vector<const ForwardDetRing*>& frontRings,
22  const vector<const ForwardDetRing*>& backRings) :
24  theFrontLayer(frontRings),
25  theBackLayer(backRings),
26  theRings(frontRings), // add back later
27  theComponents(),
28  theBasicComponents()
29 {
30 
31  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuRingForwardDoubleLayer";
32 
33  theRings.insert(theRings.end(), backRings.begin(), backRings.end());
34  theComponents = std::vector <const GeometricSearchDet*>(theRings.begin(), theRings.end());
35 
36  // Cache chamber pointers (the basic components_)
37  // and find extension in R and Z
38  for (vector<const ForwardDetRing*>::const_iterator it=theRings.begin();
39  it!=theRings.end(); it++) {
40  vector<const GeomDet*> tmp2 = (*it)->basicComponents();
41  theBasicComponents.insert(theBasicComponents.end(),tmp2.begin(),tmp2.end());
42  }
43 
44  setSurface(computeSurface());
45 
46  LogTrace(metname) << "Constructing MuRingForwardDoubleLayer: "
47  << basicComponents().size() << " Dets "
48  << theRings.size() << " Rings "
49  << " Z: " << specificSurface().position().z()
50  << " R1: " << specificSurface().innerRadius()
51  << " R2: " << specificSurface().outerRadius();
52 
53  selfTest();
54 }
55 
56 
58 {
59  const BoundDisk & frontDisk = theFrontLayer.specificSurface();
60  const BoundDisk & backDisk = theBackLayer.specificSurface();
61 
62  float rmin = min( frontDisk.innerRadius(), backDisk.innerRadius() );
63  float rmax = max( frontDisk.outerRadius(), backDisk.outerRadius() );
64  float zmin = frontDisk.position().z();
65  float halfThickness = frontDisk.bounds().thickness()/2.;
66  zmin = (zmin > 0) ? zmin-halfThickness : zmin+halfThickness;
67  float zmax = backDisk.position().z();
68  halfThickness = backDisk.bounds().thickness()/2.;
69  zmax = (zmax > 0) ? zmax+halfThickness : zmax-halfThickness;
70  float zPos = (zmax+zmin)/2.;
71  PositionType pos(0.,0.,zPos);
73 
74  return new BoundDisk( pos, rot,
75  new SimpleDiskBounds( rmin, rmax,
76  zmin-zPos, zmax-zPos));
77 }
78 
79 
81 {
82  return tsos.globalPosition().basicVector().dot(tsos.globalMomentum().basicVector()) > 0;
83 }
84 
85 
86 
87 std::pair<bool, TrajectoryStateOnSurface>
89  const MeasurementEstimator& est) const
90 {
91  // mostly copied from ForwardDetLayer, except propagates to closest surface,
92  // not to center
93  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuRingForwardDoubleLayer";
94 
95  bool insideOut = isInsideOut(startingState);
96  const MuRingForwardLayer & closerLayer = (insideOut) ? theFrontLayer : theBackLayer;
97  LogTrace("Muon|RecoMuon|RecoMuonDetLayers|MuRingForwardDoubleLayer")
98  << "MuRingForwardDoubleLayer::compatible is assuming inside-out direction: "<< insideOut;
99 
100 
101  //std::pair<bool, TrajectoryStateOnSurface> result
102  // = closerLayer.compatible(startingState, prop, est);
103  //if(!result.first)
104  // {
105  // result = furtherLayer.compatible(startingState, prop, est);
106  //}
107 
108 
109  TrajectoryStateOnSurface myState = prop.propagate( startingState, closerLayer.specificSurface());
110  if ( !myState.isValid()) return make_pair( false, myState);
111 
112  // take into account the thickness of the layer
113  float deltaR = surface().bounds().thickness()/2. *
114  fabs( tan( myState.localDirection().theta()));
115 
116  // take into account the error on the predicted state
117  const float nSigma = 3.;
118  if (myState.hasError()) {
119  LocalError err = myState.localError().positionError();
120  // ignore correlation for the moment...
121  deltaR += nSigma * sqrt(err.xx() + err.yy());
122  }
123 
124  float zPos = (zmax()+zmin())/2.;
125  SimpleDiskBounds tmp( rmin()-deltaR, rmax()+deltaR,
126  zmin()-zPos, zmax()-zPos);
127 
128  return make_pair( tmp.inside(myState.localPosition()), myState);
129 }
130 
131 
132 vector<GeometricSearchDet::DetWithState>
134  const Propagator& prop,
135  const MeasurementEstimator& est) const {
136  vector<DetWithState> result;
137  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuRingForwardDoubleLayer";
138  pair<bool, TrajectoryStateOnSurface> compat =
139  compatible(startingState, prop, est);
140 
141  if (!compat.first) {
142 
143  LogTrace(metname) << " MuRingForwardDoubleLayer::compatibleDets: not compatible"
144  << " (should not have been selected!)";
145  return result;
146  }
147 
148 
149  TrajectoryStateOnSurface& tsos = compat.second;
150 
151  // standard implementation of compatibleDets() for class which have
152  // groupedCompatibleDets implemented.
153  // This code should be moved in a common place intead of being
154  // copied many times.
155  vector<DetGroup> vectorGroups = groupedCompatibleDets(tsos,prop,est);
156  for(vector<DetGroup>::const_iterator itDG=vectorGroups.begin();
157  itDG!=vectorGroups.end();itDG++){
158  for(vector<DetGroupElement>::const_iterator itDGE=itDG->begin();
159  itDGE!=itDG->end();itDGE++){
160  result.push_back(DetWithState(itDGE->det(),itDGE->trajectoryState()));
161  }
162  }
163  return result;
164 }
165 
166 
167 vector<DetGroup>
169  const Propagator& prop,
170  const MeasurementEstimator& est) const {
171 
172  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuRingForwardDoubleLayer";
173  vector<GeometricSearchDet::DetWithState> detWithStates1, detWithStates2;
174 
175  LogTrace(metname) << "groupedCompatibleDets are currently given always in inside-out order";
176  // this should be fixed either in RecoMuon/MeasurementDet/MuonDetLayerMeasurements or
177  // RecoMuon/DetLayers/MuRingForwardDoubleLayer
178  // and removed the reverse operation in StandAloneMuonFilter::findBestMeasurements
179 
180  detWithStates1 = theFrontLayer.compatibleDets(startingState, prop, est);
181  detWithStates2 = theBackLayer.compatibleDets(startingState, prop, est);
182 
183  vector<DetGroup> result;
184  if(!detWithStates1.empty()) result.push_back( DetGroup(detWithStates1) );
185  if(!detWithStates2.empty()) result.push_back( DetGroup(detWithStates2) );
186  LogTrace(metname) << "DoubleLayer Compatible dets: " << result.size();
187  return result;
188 }
189 
190 
192 {
193  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuRingForwardDoubleLayer";
194  // approximate
195  bool result = false;
196  double r = gp.perp();
197  const std::vector<const ForwardDetRing*>& backRings = theBackLayer.rings();
198  if(backRings.size() > 1)
199  {
200  const MuDetRing * innerRing = dynamic_cast<const MuDetRing *>(backRings[0]);
201  const MuDetRing * outerRing = dynamic_cast<const MuDetRing *>(backRings[1]);
202  assert(innerRing && outerRing);
203  float crackInner = innerRing->specificSurface().outerRadius();
204  float crackOuter = outerRing->specificSurface().innerRadius();
205  LogTrace(metname) << "In a crack:" << crackInner << " " << r << " " << crackOuter;
206  if(r > crackInner && r < crackOuter) return true;
207  }
208  // non-overlapping rings
209  //double phi = gp.phi().degrees();
210  return result;
211 }
212 
213 
215 {
216  const std::vector<const GeomDet*>& frontDets = theFrontLayer.basicComponents();
217  const std::vector<const GeomDet*>& backDets = theBackLayer.basicComponents();
218 
219  std::vector<const GeomDet*>::const_iterator frontItr = frontDets.begin(),
220  lastFront = frontDets.end(),
221  backItr = backDets.begin(),
222  lastBack = backDets.end();
223 
224  // test that each front z is less than each back z
225  for( ; frontItr != lastFront; ++frontItr)
226  {
227  float frontz = fabs( (**frontItr).surface().position().z() );
228  for( ; backItr != lastBack; ++backItr)
229  {
230  float backz = fabs( (**backItr).surface().position().z() );
231  assert(frontz < backz);
232  }
233  }
234 }
235 
236 
TkRotation< Scalar > RotationType
Definition: Definitions.h:29
float xx() const
Definition: LocalError.h:24
T perp() const
Definition: PV3DBase.h:72
const std::string metname
LocalVector localDirection() const
std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &, const Propagator &, const MeasurementEstimator &) const override
std::vector< const GeomDet * > theBasicComponents
GlobalPoint globalPosition() const
const std::vector< const GeomDet * > & basicComponents() const override
std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
std::vector< const ForwardDetRing * > theRings
LocalError positionError() const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
Point3DBase< Scalar, GlobalTag > PositionType
Definition: Definitions.h:30
virtual const std::vector< const ForwardDetRing * > & rings() const
Return the vector of rings.
float yy() const
Definition: LocalError.h:26
std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
T sqrt(T t)
Definition: SSEVec.h:18
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
T min(T a, T b)
Definition: MathUtil.h:58
const LocalTrajectoryError & localError() const
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
#define LogTrace(id)
bool isCrack(const GlobalPoint &gp) const
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
BoundDisk * computeSurface() override
Disk BoundDisk
Definition: BoundDisk.h:62
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::vector< const GeometricSearchDet * > theComponents
bool isInsideOut(const TrajectoryStateOnSurface &tsos) const
GlobalVector globalMomentum() const
MuRingForwardDoubleLayer(const std::vector< const ForwardDetRing * > &frontRings, const std::vector< const ForwardDetRing * > &backRings)
Constructor, takes ownership of pointers.
bool inside(const Local3DPoint &p) const override
Determine if the point is inside the bounds.
const std::vector< const GeomDet * > & basicComponents() const override
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
const BoundDisk & specificSurface() const
Return the ring surface as a BoundDisk.
T dot(const Basic3DVector &rh) const
Scalar product, or "dot" product, with a vector of same type.