CMS 3D CMS Logo

MTDRingForwardLayer.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 MTDRingForwardLayer::MTDRingForwardLayer(const vector<const ForwardDetRing*>& rings) :
26  theRings(rings),
27  theComponents(theRings.begin(),theRings.end()),
28  theBinFinder(nullptr),
29  isOverlapping(false)
30 {
31 
32  const std::string metname = "MTD|RecoMTD|RecoMTDDetLayers|MTDRingForwardLayer";
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 MTDRingForwardLayer: "
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 = "MTD|RecoMTD|RecoMTDDetLayers|MTDRingForwardLayer";
95  vector<DetWithState> result;
96 
97 
98  LogTrace(metname) << "MTDRingForwardLayer::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) << " MTDRingForwardLayer::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) << " MTDRingForwardLayer::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 #ifdef EDM_ML_DEBUG
136  int nclosest = result.size(); int nnextdet=0; // MDEBUG counters
137 #endif
138 
139  //FIXME: if closest is not compatible next cannot be either?
140 
141  // Use state on layer surface. Note that local coordinates and errors
142  // are the same on the layer and on all rings surfaces, since
143  // all BoundDisks are centered in 0,0 and have the same rotation.
144  // CAVEAT: if the rings are not at the same Z, the local position and error
145  // will be "Z-projected" to the rings. This is a fairly good approximation.
146  // However in this case additional propagation will be done when calling
147  // compatibleDets.
148  GlobalPoint startPos = tsos.globalPosition();
149  LocalPoint nextPos(surface().toLocal(startPos));
150 
151  for (unsigned int idet=closest+1; idet < theRings.size(); idet++) {
152  bool inside = false;
153  if (tsos.hasError()) {
154  inside=theRings[idet]->specificSurface().bounds().inside(nextPos,tsos.localError().positionError());
155  } else {
156  inside=theRings[idet]->specificSurface().bounds().inside(nextPos);
157  }
158  if (inside){
159  LogTrace(metname) << " MTDRingForwardLayer::fastCompatibleDets:NextRing" << idet
160  << " R1 " << theRings[idet]->specificSurface().innerRadius()
161  << " R2: " << theRings[idet]->specificSurface().outerRadius()
162  << " FTS R " << nextPos.perp();
163 #ifdef EDM_ML_DEBUG
164  nnextdet++;
165 #endif
166  vector<DetWithState> nextRodDets =
167  theRings[idet]->compatibleDets(tsos, prop, est);
168  if (!nextRodDets.empty()) {
169  result.insert( result.end(),
170  nextRodDets.begin(), nextRodDets.end());
171  } else {
172  break;
173  }
174  }
175  }
176 
177  for (int idet=closest-1; idet >= 0; idet--) {
178  bool inside = false;
179  if (tsos.hasError()) {
180  inside=theRings[idet]->specificSurface().bounds().inside(nextPos,tsos.localError().positionError());
181  } else {
182  inside=theRings[idet]->specificSurface().bounds().inside(nextPos);
183  }
184  if (inside){
185  LogTrace(metname) << " MTDRingForwardLayer::fastCompatibleDets:PreviousRing:" << idet
186  << " R1 " << theRings[idet]->specificSurface().innerRadius()
187  << " R2: " << theRings[idet]->specificSurface().outerRadius()
188  << " FTS R " << nextPos.perp();
189 #ifdef EDM_ML_DEBUG
190  nnextdet++;
191 #endif
192  vector<DetWithState> nextRodDets =
193  theRings[idet]->compatibleDets(tsos, prop, est);
194  if (!nextRodDets.empty()) {
195  result.insert( result.end(),
196  nextRodDets.begin(), nextRodDets.end());
197  } else {
198  break;
199  }
200  }
201  }
202 
203 #ifdef EDM_ML_DEBUG
204  LogTrace(metname) << " MTDRingForwardLayer::fastCompatibleDets: found: "
205  << result.size()
206  << " on closest: " << nclosest
207  << " # checked rings: " << 1 + nnextdet;
208 #endif
209 
210  return result;
211 }
212 
213 
214 vector<DetGroup>
216  const Propagator& prop,
217  const MeasurementEstimator& est) const {
218  // FIXME should return only 1 group
219  cout << "dummy implementation of MTDRingForwardLayer::groupedCompatibleDets()" << endl;
220  return vector<DetGroup>();
221 }
222 
223 
224 
226  return theBasicComps.front()->subDetector();
227 }
228 
229 const vector<const GeometricSearchDet*> &
231  return theComponents;
232 }
TkRotation< Scalar > RotationType
Definition: Definitions.h:29
float xx() const
Definition: LocalError.h:24
const std::vector< const GeomDet * > & basicComponents() const override
T perp() const
Definition: PV3DBase.h:72
virtual int binIndex(T pos) const =0
Return the index of bin at given position.
std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
const std::string metname
std::vector< const ForwardDetRing * > theRings
GlobalPoint globalPosition() const
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
#define nullptr
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
std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
T sqrt(T t)
Definition: SSEVec.h:18
BaseBinFinder< double > * theBinFinder
#define end
Definition: vmac.h:39
T min(T a, T b)
Definition: MathUtil.h:58
const LocalTrajectoryError & localError() const
SubDetector subDetector() const override
#define LogTrace(id)
MTDRingForwardLayer(const std::vector< const ForwardDetRing * > &rings)
Constructor, takes ownership of pointers.
std::vector< const GeometricSearchDet * > theComponents
Disk BoundDisk
Definition: BoundDisk.h:62
#define begin
Definition: vmac.h:32
const std::vector< const GeometricSearchDet * > & components() const override
bool isRPeriodic() const
Returns true if the Dets are periodic in R.
Definition: RBorderFinder.h:33
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.
Definition: RBorderFinder.h:36
std::vector< const GeomDet * > theBasicComps