CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuRingForwardLayer.cc
Go to the documentation of this file.
1 
12 
14 
15 #include "RBorderFinder.h"
16 #include "GeneralBinFinderInR.h"
17 
18 #include <algorithm>
19 #include <iostream>
20 #include <vector>
21 
22 using namespace std;
23 
24 MuRingForwardLayer::MuRingForwardLayer(const vector<const ForwardDetRing*>& rings) :
26  theRings(rings),
27  theComponents(theRings.begin(),theRings.end()),
28  theBinFinder(0),
29  isOverlapping(false)
30 {
31 
32  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuRingForwardLayer";
33 
34  // Initial values for R and Z bounds
35  float theRmin = rings.front()->basicComponents().front()->position().perp();
36  float theRmax = theRmin;
37  float theZmin = rings.front()->position().z();
38  float theZmax = theZmin;
39 
40  // Cache chamber pointers (the basic components_)
41  // and find extension in R and Z
42  for (vector<const ForwardDetRing*>::const_iterator it=rings.begin();
43  it!=rings.end(); it++) {
44  vector<const GeomDet*> tmp2 = (*it)->basicComponents();
45  theBasicComps.insert(theBasicComps.end(),tmp2.begin(),tmp2.end());
46 
47  theRmin = min( theRmin, (*it)->specificSurface().innerRadius());
48  theRmax = max( theRmax, (*it)->specificSurface().outerRadius());
49  float halfThick = (*it)->surface().bounds().thickness()/2.;
50  float zCenter = (*it)->surface().position().z();
51  theZmin = min( theZmin, zCenter-halfThick);
52  theZmax = max( theZmax, zCenter+halfThick);
53  }
54 
58 
59  // Build surface
60 
61  float zPos = (theZmax+theZmin)/2.;
62  PositionType pos(0.,0.,zPos);
64 
65  setSurface(new BoundDisk( pos, rot,
66  new SimpleDiskBounds( theRmin, theRmax,
67  theZmin-zPos, theZmax-zPos)));
68 
69 
70 
71  LogTrace(metname) << "Constructing MuRingForwardLayer: "
72  << basicComponents().size() << " Dets "
73  << theRings.size() << " Rings "
74  << " Z: " << specificSurface().position().z()
75  << " R1: " << specificSurface().innerRadius()
76  << " R2: " << specificSurface().outerRadius()
77  << " Per.: " << bf.isRPeriodic()
78  << " Overl.: " << bf.isROverlapping();
79 }
80 
81 
83  delete theBinFinder;
84  for (vector <const ForwardDetRing*>::iterator i = theRings.begin();
85  i<theRings.end(); i++) {delete *i;}
86 }
87 
88 
89 vector<GeometricSearchDet::DetWithState>
91  const Propagator& prop,
92  const MeasurementEstimator& est) const {
93 
94  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuRingForwardLayer";
95  vector<DetWithState> result;
96 
97 
98  LogTrace(metname) << "MuRingForwardLayer::compatibleDets,"
99  << " R1 " << specificSurface().innerRadius()
100  << " R2: " << specificSurface().outerRadius()
101  << " FTS at R: " << startingState.globalPosition().perp();
102 
103  pair<bool, TrajectoryStateOnSurface> compat =
104  compatible(startingState, prop, est);
105 
106  if (!compat.first) {
107 
108  LogTrace(metname) << " MuRingForwardLayer::compatibleDets: not compatible"
109  << " (should not have been selected!)";
110  return result;
111  }
112 
113 
114  TrajectoryStateOnSurface& tsos = compat.second;
115 
116  int closest = theBinFinder->binIndex(tsos.globalPosition().perp());
117  const ForwardDetRing* closestRing = theRings[closest];
118 
119  // Check the closest ring
120 
121  LogTrace(metname) << " MuRingForwardLayer::fastCompatibleDets, closestRing: "
122  << closest
123  << " R1 " << closestRing->specificSurface().innerRadius()
124  << " R2: " << closestRing->specificSurface().outerRadius()
125  << " FTS R: " << tsos.globalPosition().perp();
126  if (tsos.hasError()) {
127  LogTrace(metname) << " sR: " << sqrt(tsos.localError().positionError().yy())
128  << " sX: " << sqrt(tsos.localError().positionError().xx());
129  }
130  LogTrace(metname) << endl;
131 
132 
133  result = closestRing->compatibleDets(tsos, prop, est);
134 
135  int nclosest = result.size(); int nnextdet=0; // MDEBUG counters
136 
137  //FIXME: if closest is not compatible next cannot be either?
138 
139  // Use state on layer surface. Note that local coordinates and errors
140  // are the same on the layer and on all rings surfaces, since
141  // all BoundDisks are centered in 0,0 and have the same rotation.
142  // CAVEAT: if the rings are not at the same Z, the local position and error
143  // will be "Z-projected" to the rings. This is a fairly good approximation.
144  // However in this case additional propagation will be done when calling
145  // compatibleDets.
146  GlobalPoint startPos = tsos.globalPosition();
147  LocalPoint nextPos(surface().toLocal(startPos));
148 
149  for (unsigned int idet=closest+1; idet < theRings.size(); idet++) {
150  bool inside = false;
151  if (tsos.hasError()) {
152  inside=theRings[idet]->specificSurface().bounds().inside(nextPos,tsos.localError().positionError());
153  } else {
154  inside=theRings[idet]->specificSurface().bounds().inside(nextPos);
155  }
156  if (inside){
157  LogTrace(metname) << " MuRingForwardLayer::fastCompatibleDets:NextRing" << idet
158  << " R1 " << theRings[idet]->specificSurface().innerRadius()
159  << " R2: " << theRings[idet]->specificSurface().outerRadius()
160  << " FTS R " << nextPos.perp();
161  nnextdet++;
162  vector<DetWithState> nextRodDets =
163  theRings[idet]->compatibleDets(tsos, prop, est);
164  if (nextRodDets.size()!=0) {
165  result.insert( result.end(),
166  nextRodDets.begin(), nextRodDets.end());
167  } else {
168  break;
169  }
170  }
171  }
172 
173  for (int idet=closest-1; idet >= 0; idet--) {
174  bool inside = false;
175  if (tsos.hasError()) {
176  inside=theRings[idet]->specificSurface().bounds().inside(nextPos,tsos.localError().positionError());
177  } else {
178  inside=theRings[idet]->specificSurface().bounds().inside(nextPos);
179  }
180  if (inside){
181  LogTrace(metname) << " MuRingForwardLayer::fastCompatibleDets:PreviousRing:" << idet
182  << " R1 " << theRings[idet]->specificSurface().innerRadius()
183  << " R2: " << theRings[idet]->specificSurface().outerRadius()
184  << " FTS R " << nextPos.perp();
185  nnextdet++;
186  vector<DetWithState> nextRodDets =
187  theRings[idet]->compatibleDets(tsos, prop, est);
188  if (nextRodDets.size()!=0) {
189  result.insert( result.end(),
190  nextRodDets.begin(), nextRodDets.end());
191  } else {
192  break;
193  }
194  }
195  }
196 
197  LogTrace(metname) << " MuRingForwardLayer::fastCompatibleDets: found: "
198  << result.size()
199  << " on closest: " << nclosest
200  << " # checked rings: " << 1 + nnextdet;
201 
202  return result;
203 }
204 
205 
206 vector<DetGroup>
208  const Propagator& prop,
209  const MeasurementEstimator& est) const {
210  // FIXME should return only 1 group
211  cout << "dummy implementation of MuRingForwardLayer::groupedCompatibleDets()" << endl;
212  return vector<DetGroup>();
213 }
214 
215 
216 
218  return theBasicComps.front()->subDetector();
219 }
220 
221 const vector<const GeometricSearchDet*> &
223  return theComponents;
224 }
TkRotation< Scalar > RotationType
Definition: Definitions.h:29
int i
Definition: DBlmapReader.cc:9
float xx() const
Definition: LocalError.h:24
T perp() const
Definition: PV3DBase.h:72
const std::string metname
double zPos
virtual std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
MuRingForwardLayer(const std::vector< const ForwardDetRing * > &rings)
Constructor, takes ownership of pointers.
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
virtual int binIndex(T pos) const =0
Return the index of bin at given position.
GlobalPoint globalPosition() const
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
std::vector< const ForwardDetRing * > theRings
LocalError positionError() const
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Point3DBase< Scalar, GlobalTag > PositionType
Definition: Definitions.h:30
float yy() const
Definition: LocalError.h:26
const T & max(const T &a, const T &b)
T sqrt(T t)
Definition: SSEVec.h:48
tuple result
Definition: query.py:137
#define end
Definition: vmac.h:37
const LocalTrajectoryError & localError() const
#define LogTrace(id)
std::vector< const GeometricSearchDet * > theComponents
virtual const std::vector< const GeomDet * > & basicComponents() const
virtual SubDetector subDetector() const
BaseBinFinder< double > * theBinFinder
Disk BoundDisk
Definition: BoundDisk.h:62
#define begin
Definition: vmac.h:30
virtual const std::vector< const GeometricSearchDet * > & components() const
tuple cout
Definition: gather_cfg.py:121
bool isRPeriodic() const
Returns true if the Dets are periodic in R.
volatile std::atomic< bool > shutdown_flag false
const BoundDisk & specificSurface() const
Return the ring surface as a BoundDisk.
bool isROverlapping() const
Returns true if any 2 of the Det overlap in R.
std::vector< const GeomDet * > theBasicComps