CMS 3D CMS Logo

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