CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TOBRod.cc
Go to the documentation of this file.
2 
4 
9 
13 
14 
15 using namespace std;
16 
18 
19 class DetZLess {
20 public:
21  bool operator()(const GeomDet* a,const GeomDet* b)
22  {
23  return (a->position().z() < b->position().z());
24  }
25 };
26 
27 
28 TOBRod::TOBRod(vector<const GeomDet*>& innerDets,
29  vector<const GeomDet*>& outerDets):
30  theInnerDets(innerDets),theOuterDets(outerDets)
31 {
32  theDets.assign(theInnerDets.begin(),theInnerDets.end());
33  theDets.insert(theDets.end(),theOuterDets.begin(),theOuterDets.end());
34 
35 
36  RodPlaneBuilderFromDet planeBuilder;
37  setPlane( planeBuilder( theDets));
38  theInnerPlane = planeBuilder( theInnerDets);
39  theOuterPlane = planeBuilder( theOuterDets);
40 
41 
42  sort(theDets.begin(),theDets.end(),DetZLess());
43  sort(theInnerDets.begin(),theInnerDets.end(),DetZLess());
44  sort(theOuterDets.begin(),theOuterDets.end(),DetZLess());
47 
48 
49 
50  LogDebug("TkDetLayers") << "==== DEBUG TOBRod =====" ;
51  for (vector<const GeomDet*>::const_iterator i=theInnerDets.begin();
52  i != theInnerDets.end(); i++){
53  LogDebug("TkDetLayers") << "inner TOBRod's Det pos z,perp,eta,phi: "
54  << (**i).position().z() << " , "
55  << (**i).position().perp() << " , "
56  << (**i).position().eta() << " , "
57  << (**i).position().phi() ;
58  }
59 
60  for (vector<const GeomDet*>::const_iterator i=theOuterDets.begin();
61  i != theOuterDets.end(); i++){
62  LogDebug("TkDetLayers") << "outer TOBRod's Det pos z,perp,eta,phi: "
63  << (**i).position().z() << " , "
64  << (**i).position().perp() << " , "
65  << (**i).position().eta() << " , "
66  << (**i).position().phi() ;
67  }
68  LogDebug("TkDetLayers") << "==== end DEBUG TOBRod =====" ;
69 
70 
71 
72 }
73 
75 
76 }
77 
78 
79 const vector<const GeometricSearchDet*>&
81  throw DetLayerException("TOBRod doesn't have GeometricSearchDet components");
82 }
83 
84 pair<bool, TrajectoryStateOnSurface>
86  const MeasurementEstimator&) const{
87  edm::LogError("TkDetLayers") << "temporary dummy implementation of TOBRod::compatible()!!" ;
88  return pair<bool,TrajectoryStateOnSurface>();
89 }
90 
91 
92 
93 
94 
95 void
97  const Propagator& prop,
98  const MeasurementEstimator& est,
99  std::vector<DetGroup> & result) const{
100 
101  SubLayerCrossings crossings;
102  crossings = computeCrossings( tsos, prop.propagationDirection());
103  if(! crossings.isValid()) return;
104 
105  vector<DetGroup> closestResult;
106  addClosest( tsos, prop, est, crossings.closest(), closestResult);
107  if (closestResult.empty()){
108  vector<DetGroup> nextResult;
109  addClosest( tsos, prop, est, crossings.other(), nextResult);
110  if(nextResult.empty()) return;
111 
112  DetGroupElement nextGel( nextResult.front().front());
113  int crossingSide = LayerCrossingSide().barrelSide( nextGel.trajectoryState(), prop);
114  DetGroupMerger::orderAndMergeTwoLevels( closestResult, nextResult, result,
115  crossings.closestIndex(), crossingSide);
116  } else {
117 
118  DetGroupElement closestGel( closestResult.front().front());
119  float window = computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
120 
121  searchNeighbors( tsos, prop, est, crossings.closest(), window,
122  closestResult, false);
123 
124  vector<DetGroup> nextResult;
125  searchNeighbors( tsos, prop, est, crossings.other(), window,
126  nextResult, true);
127 
128  int crossingSide = LayerCrossingSide().barrelSide( closestGel.trajectoryState(), prop);
129  DetGroupMerger::orderAndMergeTwoLevels( closestResult, nextResult, result,
130  crossings.closestIndex(), crossingSide);
131  }
132 }
133 
134 
137  PropagationDirection propDir) const
138 {
139  GlobalPoint startPos( startingState.globalPosition());
140  GlobalVector startDir( startingState.globalMomentum());
141  double rho( startingState.transverseCurvature());
142 
143  HelixBarrelPlaneCrossingByCircle crossing( startPos, startDir, rho, propDir);
144 
145  pair<bool,double> innerPath = crossing.pathLength( *theInnerPlane);
146  if (!innerPath.first) return SubLayerCrossings();
147 
148  GlobalPoint gInnerPoint( crossing.position(innerPath.second));
149  int innerIndex = theInnerBinFinder.binIndex(gInnerPoint.z());
150  float innerDist = fabs( theInnerBinFinder.binPosition(innerIndex) - gInnerPoint.z());
151  SubLayerCrossing innerSLC( 0, innerIndex, gInnerPoint);
152 
153  pair<bool,double> outerPath = crossing.pathLength( *theOuterPlane);
154  if (!outerPath.first) return SubLayerCrossings();
155 
156  GlobalPoint gOuterPoint( crossing.position(outerPath.second));
157  int outerIndex = theOuterBinFinder.binIndex(gOuterPoint.z());
158  float outerDist = fabs( theOuterBinFinder.binPosition(outerIndex) - gOuterPoint.z());
159  SubLayerCrossing outerSLC( 1, outerIndex, gOuterPoint);
160 
161  if (innerDist < outerDist) {
162  return SubLayerCrossings( innerSLC, outerSLC, 0);
163  }
164  else {
165  return SubLayerCrossings( outerSLC, innerSLC, 1);
166  }
167 }
168 
169 
170 
171 
172 bool
174  const Propagator& prop,
175  const MeasurementEstimator& est,
176  const SubLayerCrossing& crossing,
177  vector<DetGroup>& result) const
178 {
179 
180  const vector<const GeomDet*>& sRod( subRod( crossing.subLayerIndex()));
181  return CompatibleDetToGroupAdder::add( *sRod[crossing.closestDetIndex()],
182  tsos, prop, est, result);
183 }
184 
185 
187  const TrajectoryStateOnSurface& tsos,
188  const MeasurementEstimator& est) const
189 {
190  return
191  est.maximalLocalDisplacement(tsos, det->surface()).y();
192 }
193 
194 
195 
196 
198  const Propagator& prop,
199  const MeasurementEstimator& est,
200  const SubLayerCrossing& crossing,
201  float window,
202  vector<DetGroup>& result,
203  bool checkClosest) const
204 {
205  GlobalPoint gCrossingPos = crossing.position();
206 
207  const vector<const GeomDet*>& sRod( subRod( crossing.subLayerIndex()));
208 
209  int closestIndex = crossing.closestDetIndex();
210  int negStartIndex = closestIndex-1;
211  int posStartIndex = closestIndex+1;
212 
213  if (checkClosest) { // must decide if the closest is on the neg or pos side
214  if (gCrossingPos.z() < sRod[closestIndex]->surface().position().z()) {
215  posStartIndex = closestIndex;
216  }
217  else {
218  negStartIndex = closestIndex;
219  }
220  }
221 
222  typedef CompatibleDetToGroupAdder Adder;
223  for (int idet=negStartIndex; idet >= 0; idet--) {
224  if (!overlap( gCrossingPos, *sRod[idet], window)) break;
225  if (!Adder::add( *sRod[idet], tsos, prop, est, result)) break;
226  }
227  for (int idet=posStartIndex; idet < static_cast<int>(sRod.size()); idet++) {
228  if (!overlap( gCrossingPos, *sRod[idet], window)) break;
229  if (!Adder::add( *sRod[idet], tsos, prop, est, result)) break;
230  }
231 }
232 
233 
234 
235 bool TOBRod::overlap( const GlobalPoint& crossPoint, const GeomDet& det, float window) const
236 {
237  // check if the z window around TSOS overlaps with the detector theDet (with a 1% margin added)
238 
239  // const float tolerance = 0.1;
240  const float relativeMargin = 1.01;
241 
242  LocalPoint localCrossPoint( det.surface().toLocal(crossPoint));
243  // if (fabs(localCrossPoint.z()) > tolerance) {
244  // edm::LogInfo(TkDetLayers) << "TOBRod::overlap calculation assumes point on surface, but it is off by "
245  // << localCrossPoint.z() ;
246  // }
247 
248  float localY = localCrossPoint.y();
249  float detHalfLength = det.surface().bounds().length()/2.;
250 
251  // edm::LogInfo(TkDetLayers) << "TOBRod::overlap: Det at " << det.position() << " hit at " << localY
252  // << " Window " << window << " halflength " << detHalfLength ;
253 
254  if ( ( fabs(localY)-window) < relativeMargin*detHalfLength ) { // FIXME: margin hard-wired!
255  return true;
256  } else {
257  return false;
258  }
259 }
260 
#define LogDebug(id)
Common base class.
int i
Definition: DBlmapReader.cc:9
static void orderAndMergeTwoLevels(const std::vector< DetGroup > &one, const std::vector< DetGroup > &two, std::vector< DetGroup > &result, int firstIndex, int firstCrossed)
def window
Definition: svgfig.py:642
BinFinderType theOuterBinFinder
Definition: TOBRod.h:81
virtual float length() const =0
std::vector< const GeomDet * > theInnerDets
Definition: TOBRod.h:74
virtual PropagationDirection propagationDirection() const
Definition: Propagator.h:143
bool operator()(const GeomDet *a, const GeomDet *b)
Definition: TOBRod.cc:21
int closestIndex() const
int closestDetIndex() const
SubLayerCrossings computeCrossings(const TrajectoryStateOnSurface &tsos, PropagationDirection propDir) const
Definition: TOBRod.cc:136
PeriodicBinFinderInZ< float > BinFinderType
Definition: TOBRod.h:17
Definition: DDAxes.h:10
std::vector< const GeomDet * > theDets
Definition: TOBRod.h:73
T y() const
Definition: PV3DBase.h:57
GlobalPoint globalPosition() const
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
std::vector< const GeomDet * > theOuterDets
Definition: TOBRod.h:75
virtual T binPosition(int ind) const
the middle of the bin
PropagationDirection
bool addClosest(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, std::vector< DetGroup > &result) const
Definition: TOBRod.cc:173
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const BoundPlane &plane) const
virtual int binIndex(T z) const
returns an index in the valid range for the bin that contains Z
const GlobalPoint & position() const
const std::vector< const GeomDet * > & subRod(int ind) const
Definition: TOBRod.h:67
void setPlane(BoundPlane *plane)
Set the rod&#39;s plane.
Definition: DetRod.h:30
~TOBRod()
Definition: TOBRod.cc:74
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
ReferenceCountingPointer< BoundPlane > theInnerPlane
Definition: TOBRod.h:77
LocalPoint toLocal(const GlobalPoint &gp) const
int subLayerIndex() const
T z() const
Definition: PV3DBase.h:58
tuple result
Definition: query.py:137
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const
Definition: TOBRod.cc:186
void searchNeighbors(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, float window, std::vector< DetGroup > &result, bool checkClosest) const
Definition: TOBRod.cc:197
BinFinderType theInnerBinFinder
Definition: TOBRod.h:80
const SubLayerCrossing & other() const
const Bounds & bounds() const
Definition: BoundSurface.h:89
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const
Definition: TOBRod.cc:96
virtual const std::vector< const GeometricSearchDet * > & components() const
Returns basic components, if any.
Definition: TOBRod.cc:80
double b
Definition: hdecay.h:120
static bool add(const GeometricSearchDet &det, const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result)
int barrelSide(const TrajectoryStateOnSurface &startingState, const Propagator &prop) const
returns 0 if barrel layer crossed from inside, 1 if from outside
const SubLayerCrossing & closest() const
GlobalVector globalMomentum() const
double a
Definition: hdecay.h:121
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
ReferenceCountingPointer< BoundPlane > theOuterPlane
Definition: TOBRod.h:78
virtual std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &ts, const Propagator &, const MeasurementEstimator &) const
Definition: TOBRod.cc:85
TOBRod(std::vector< const GeomDet * > &innerDets, std::vector< const GeomDet * > &outerDets)
Definition: TOBRod.cc:28
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
bool overlap(const GlobalPoint &gpos, const GeomDet &rod, float phiWin) const
Definition: TOBRod.cc:235