CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SimpleForwardNavigableLayer.cc
Go to the documentation of this file.
2 
6 
9 
12 
13 
14 using namespace std;
15 
18  const BDLC& outerBL,
19  const FDLC& outerFL,
20  const MagneticField* field,
21  float epsilon,
22  bool checkCrossingSide) :
23  SimpleNavigableLayer(field,epsilon,checkCrossingSide),
24  areAllReachableLayersSet(false),
25  theDetLayer(detLayer),
26  theOuterBarrelLayers(outerBL),
27  theInnerBarrelLayers(0),
28  theOuterForwardLayers(outerFL),
29  theInnerForwardLayers(0),
30  theOuterLayers(0),
31  theInnerLayers(0)
32 {
33 
34  // put barrel and forward layers together
35  theOuterLayers.reserve(outerBL.size() + outerFL.size());
36  for ( ConstBDLI bl = outerBL.begin(); bl != outerBL.end(); bl++ )
37  theOuterLayers.push_back(*bl);
38  for ( ConstFDLI fl = outerFL.begin(); fl != outerFL.end(); fl++ )
39  theOuterLayers.push_back(*fl);
40 
41  // sort the outer layers
42  sort(theOuterLayers.begin(), theOuterLayers.end(), TkLayerLess());
45 
46 }
47 
50  const BDLC& outerBL,
51  const BDLC& allOuterBL,
52  const BDLC& innerBL,
53  const BDLC& allInnerBL,
54  const FDLC& outerFL,
55  const FDLC& allOuterFL,
56  const FDLC& innerFL,
57  const FDLC& allInnerFL,
58  const MagneticField* field,
59  float epsilon,
60  bool checkCrossingSide) :
61  SimpleNavigableLayer(field,epsilon,checkCrossingSide),
62  areAllReachableLayersSet(true),
63  theDetLayer(detLayer),
64  theOuterBarrelLayers(outerBL),
65  theAllOuterBarrelLayers(allOuterBL),
66  theInnerBarrelLayers(innerBL),
67  theAllInnerBarrelLayers(allInnerBL),
68  theOuterForwardLayers(outerFL),
69  theAllOuterForwardLayers(allOuterFL),
70  theInnerForwardLayers(innerFL),
71  theAllInnerForwardLayers(allInnerFL),
72  theOuterLayers(0),
73  theInnerLayers(0),
74  theAllOuterLayers(0),
75  theAllInnerLayers(0)
76 {
77 
78  // put barrel and forward layers together
79  theOuterLayers.reserve(outerBL.size() + outerFL.size());
80  for ( ConstBDLI bl = outerBL.begin(); bl != outerBL.end(); bl++ )
81  theOuterLayers.push_back(*bl);
82  for ( ConstFDLI fl = outerFL.begin(); fl != outerFL.end(); fl++ )
83  theOuterLayers.push_back(*fl);
84 
85  theAllOuterLayers.reserve(allOuterBL.size() + allOuterFL.size());
86  for ( ConstBDLI bl = allOuterBL.begin(); bl != allOuterBL.end(); bl++ )
87  theAllOuterLayers.push_back(*bl);
88  for ( ConstFDLI fl = allOuterFL.begin(); fl != allOuterFL.end(); fl++ )
89  theAllOuterLayers.push_back(*fl);
90 
91  theInnerLayers.reserve(innerBL.size() + innerFL.size());
92  for ( ConstBDLI bl = innerBL.begin(); bl != innerBL.end(); bl++ )
93  theInnerLayers.push_back(*bl);
94  for ( ConstFDLI fl = innerFL.begin(); fl != innerFL.end(); fl++ )
95  theInnerLayers.push_back(*fl);
96 
97  theAllInnerLayers.reserve(allInnerBL.size() + allInnerFL.size());
98  for ( ConstBDLI bl = allInnerBL.begin(); bl != allInnerBL.end(); bl++ )
99  theAllInnerLayers.push_back(*bl);
100  for ( ConstFDLI fl = allInnerFL.begin(); fl != allInnerFL.end(); fl++ )
101  theAllInnerLayers.push_back(*fl);
102 
103 
104  // sort the outer layers
105  sort(theOuterLayers.begin(), theOuterLayers.end(), TkLayerLess());
111 
114 
115 }
116 
117 
118 
119 vector<const DetLayer*>
121 {
122  vector<const DetLayer*> result;
123 
124  // the order is the one in which layers
125  // should be checked for a reasonable trajectory
126 
127  if ( dir == insideOut ) {
128  return theOuterLayers;
129  }
130  else {
131  return theInnerLayers;
132  }
133 
134  return result;
135 }
136 
137 vector<const DetLayer*>
139  PropagationDirection dir) const
140 {
141  // This method contains the sequence in which the layers are tested.
142  // The iteration stops as soon as a layer contains the propagated state
143  // within epsilon
144 
145  vector<const DetLayer*> result;
146 
147  FreeTrajectoryState ftsWithoutErrors = (fts.hasError()) ?
148  FreeTrajectoryState(fts.parameters()) : fts;
149 
150  //establish whether the tracks is crossing the tracker from outer layers to inner ones
151  //or from inner to outer
152  //bool isInOutTrack = (fts.position().basicVector().dot(fts.momentum().basicVector())>0) ? 1 : 0;
153  float zpos = fts.position().z();
154  bool isInOutTrackFWD = fts.momentum().z()*zpos>0;
155  GlobalVector transversePosition(fts.position().x(), fts.position().y(), 0);
156  bool isInOutTrackBarrel = (transversePosition.dot(fts.momentum())>0) ? 1 : 0;
157 
158  //establish whether inner or outer layers are crossed after propagation, according
159  //to BOTH propagationDirection AND track momentum
160  bool dirOppositeXORisInOutTrackBarrel = ( !(dir == oppositeToMomentum) && isInOutTrackBarrel) || ( (dir == oppositeToMomentum) && !isInOutTrackBarrel);
161  bool dirOppositeXORisInOutTrackFWD = ( !(dir == oppositeToMomentum) && isInOutTrackFWD) || ( (dir == oppositeToMomentum) && !isInOutTrackFWD);
162  //bool dirOppositeXORisInOutTrack = ( !(dir == oppositeToMomentum) && isInOutTrack) || ( (dir == oppositeToMomentum) && !isInOutTrack);
163 
164  if ( dirOppositeXORisInOutTrackFWD && dirOppositeXORisInOutTrackBarrel ) { //standard tracks
165 
166  //wellInside(ftsWithoutErrors, dir, theOuterForwardLayers.begin(), theOuterForwardLayers.end(), result);
167  wellInside(ftsWithoutErrors, dir, theOuterLayers, result);
168 
169  }
170  else if (!dirOppositeXORisInOutTrackFWD && !dirOppositeXORisInOutTrackBarrel){ // !dirOppositeXORisInOutTrack
171 
172  //wellInside(ftsWithoutErrors, dir, theInnerForwardLayers.begin(), theInnerForwardLayers.end(), result);
173  wellInside(ftsWithoutErrors, dir, theInnerLayers, result);
174 
175  } else if (!dirOppositeXORisInOutTrackFWD && dirOppositeXORisInOutTrackBarrel ) {
176  wellInside(ftsWithoutErrors, dir, theInnerForwardLayers.begin(), theInnerForwardLayers.end(), result);
177  wellInside(ftsWithoutErrors, dir, theOuterBarrelLayers.begin(), theOuterBarrelLayers.end(), result);
178 
179  } else {
180  wellInside(ftsWithoutErrors, dir, theInnerBarrelLayers.begin(), theInnerBarrelLayers.end(), result);
181  wellInside(ftsWithoutErrors, dir, theOuterForwardLayers.begin(), theOuterForwardLayers.end(), result);
182 
183  }
184 /*
185  if ( dirOppositeXORisInOutTrackBarrel ) {
186 
187  wellInside(ftsWithoutErrors, dir, theOuterBarrelLayers.begin(), theOuterBarrelLayers.end(), result);
188 
189  }
190  else { // !dirOppositeXORisInOutTrack
191 
192  wellInside(ftsWithoutErrors, dir, theInnerBarrelLayers.begin(),theInnerBarrelLayers.end(), result);
193 
194  }
195 */
196 
197  return result;
198 }
199 
200 
201 vector<const DetLayer*>
203 {
205  edm::LogError("TkNavigation") << "ERROR: compatibleLayers() method used without all reachableLayers are set" ;
206  throw DetLayerException("compatibleLayers() method used without all reachableLayers are set");
207  }
208 
209  vector<const DetLayer*> result;
210 
211  if ( dir == insideOut ) {
212  return theAllOuterLayers;
213  }
214  else {
215  return theAllInnerLayers;
216  }
217  return result;
218 
219 }
220 
221 vector<const DetLayer*>
224 {
226  int counter = 0;
227  return SimpleNavigableLayer::compatibleLayers(fts,dir,counter);
228  // edm::LogError("TkNavigation") << "ERROR: compatibleLayers() method used without all reachableLayers are set" ;
229  // throw DetLayerException("compatibleLayers() method used without all reachableLayers are set");
230  }
231 
232  vector<const DetLayer*> result;
233  FreeTrajectoryState ftsWithoutErrors = (fts.hasError()) ?
234  FreeTrajectoryState(fts.parameters()) : fts;
235 
236  //establish whether the tracks is crossing the tracker from outer layers to inner ones
237  //or from inner to outer.
238  //bool isInOutTrack = (fts.position().basicVector().dot(fts.momentum().basicVector())>0) ? 1 : 0;
239 /* float zpos = fts.position().z();
240  bool isInOutTrack = fts.momentum().z()*zpos>0;
241 
242  //establish whether inner or outer layers are crossed after propagation, according
243  //to BOTH propagationDirection AND track momentum
244  bool dirOppositeXORisInOutTrack = ( !(dir == oppositeToMomentum) && isInOutTrack) || ((dir == oppositeToMomentum) && !isInOutTrack);
245 
246  if ( dirOppositeXORisInOutTrack ) {
247  wellInside(ftsWithoutErrors, dir, theAllOuterLayers, result);
248  }
249  else { // !dirOppositeXORisInOutTrack
250  wellInside(ftsWithoutErrors, dir, theAllInnerLayers, result);
251  }
252 */
253 
254  float zpos = fts.position().z();
255  bool isInOutTrackFWD = fts.momentum().z()*zpos>0;
256  GlobalVector transversePosition(fts.position().x(), fts.position().y(), 0);
257  bool isInOutTrackBarrel = (transversePosition.dot(fts.momentum())>0) ? 1 : 0;
258 
259  //establish whether inner or outer layers are crossed after propagation, according
260  //to BOTH propagationDirection AND track momentum
261  bool dirOppositeXORisInOutTrackBarrel = ( !(dir == oppositeToMomentum) && isInOutTrackBarrel) || ( (dir == oppositeToMomentum) && !isInOutTrackBarrel);
262  bool dirOppositeXORisInOutTrackFWD = ( !(dir == oppositeToMomentum) && isInOutTrackFWD) || ( (dir == oppositeToMomentum) && !isInOutTrackFWD);
263  //bool dirOppositeXORisInOutTrack = ( !(dir == oppositeToMomentum) && isInOutTrack) || ( (dir == oppositeToMomentum) && !isInOutTrack);
264 
265  if ( dirOppositeXORisInOutTrackFWD && dirOppositeXORisInOutTrackBarrel ) { //standard tracks
266 
267  //wellInside(ftsWithoutErrors, dir, theOuterForwardLayers.begin(), theOuterForwardLayers.end(), result);
268  wellInside(ftsWithoutErrors, dir, theAllOuterLayers, result);
269 
270  }
271  else if (!dirOppositeXORisInOutTrackFWD && !dirOppositeXORisInOutTrackBarrel){ // !dirOppositeXORisInOutTrack
272 
273  //wellInside(ftsWithoutErrors, dir, theInnerForwardLayers.begin(), theInnerForwardLayers.end(), result);
274  wellInside(ftsWithoutErrors, dir, theAllInnerLayers, result);
275 
276  } else if (!dirOppositeXORisInOutTrackFWD && dirOppositeXORisInOutTrackBarrel ) {
277 
278  wellInside(ftsWithoutErrors, dir, theAllInnerForwardLayers.begin(), theAllInnerForwardLayers.end(), result);
279  wellInside(ftsWithoutErrors, dir, theAllOuterBarrelLayers.begin(), theAllOuterBarrelLayers.end(), result);
280 
281  } else {
282 
283  wellInside(ftsWithoutErrors, dir, theAllInnerBarrelLayers.begin(), theAllInnerBarrelLayers.end(), result);
284  wellInside(ftsWithoutErrors, dir, theAllOuterForwardLayers.begin(), theAllOuterForwardLayers.end(), result);
285 
286  }
287  return result;
288 }
289 
290 
292 
294  cerr << "Warning: SimpleForwardNavigableLayer::setDetLayer called."
295  << endl << "This should never happen!" << endl;
296 }
297 
299  const FDLC& innerFL,
301 
302  theInnerBarrelLayers = innerBL;
303  theInnerForwardLayers = innerFL;
304 
305  theInnerLayers.clear();
306  theInnerLayers.reserve(innerBL.size() + innerFL.size());
307  for ( ConstBDLI bl = innerBL.begin(); bl != innerBL.end(); bl++ )
308  theInnerLayers.push_back(*bl);
309  for ( ConstFDLI fl = innerFL.begin(); fl != innerFL.end(); fl++ )
310  theInnerLayers.push_back(*fl);
311 
312  // sort the inner layers
313  sort(theInnerLayers.begin(), theInnerLayers.end(),sorter);
316 
317 }
318 
320  ForwardDetLayer* fadditional = dynamic_cast<ForwardDetLayer*>(additional);
321  BarrelDetLayer* badditional = dynamic_cast<BarrelDetLayer*>(additional);
322  if (badditional){
323  if (direction==insideOut){
324  theOuterBarrelLayers.push_back(badditional);
325  theAllOuterBarrelLayers.push_back(badditional);
326  theOuterLayers.push_back(badditional);
327  theAllOuterLayers.push_back(badditional);
328  return;
329  }
330  theInnerBarrelLayers.push_back(badditional);
331  theAllInnerBarrelLayers.push_back(badditional);
332  theInnerLayers.push_back(badditional);
333  theAllInnerLayers.push_back(badditional);
334  return;
335  } else if (fadditional){
336  if (direction==insideOut){
337  theOuterForwardLayers.push_back(fadditional);
338  theAllOuterForwardLayers.push_back(fadditional);
339  theOuterLayers.push_back(badditional);
340  theAllOuterLayers.push_back(badditional);
341  return;
342  }
343  theInnerForwardLayers.push_back(fadditional);
344  theAllInnerForwardLayers.push_back(fadditional);
345  theInnerLayers.push_back(badditional);
346  theAllInnerLayers.push_back(badditional);
347  return;
348  }
349  edm::LogError("TkNavigation") << "trying to add neither a ForwardDetLayer nor a BarrelDetLayer";
350  return;
351 }
virtual std::vector< const DetLayer * > nextLayers(NavigationDirection direction) const
Common base class.
virtual std::vector< const DetLayer * > compatibleLayers(NavigationDirection direction) const
const GlobalTrajectoryParameters & parameters() const
std::vector< BarrelDetLayer * > BDLC
T y() const
Definition: PV3DBase.h:57
virtual void setAdditionalLink(DetLayer *, NavigationDirection direction=insideOut)
PropagationDirection
virtual void setDetLayer(DetLayer *dl)
virtual DetLayer * detLayer() const
T z() const
Definition: PV3DBase.h:58
virtual std::vector< const DetLayer * > compatibleLayers(const FreeTrajectoryState &fts, PropagationDirection timeDirection, int &counter) const
tuple result
Definition: query.py:137
FDLC::const_iterator ConstFDLI
GlobalVector momentum() const
GlobalPoint position() const
bool wellInside(const FreeTrajectoryState &fts, PropagationDirection dir, const BarrelDetLayer *bl, DLC &result) const
std::vector< ForwardDetLayer * > FDLC
virtual void setInwardLinks(const BDLC &, const FDLC &, TkLayerLess sorter=TkLayerLess(outsideIn))
dbl *** dir
Definition: mlp_gen.cc:35
const double epsilon
T x() const
Definition: PV3DBase.h:56
BDLC::const_iterator ConstBDLI
SimpleForwardNavigableLayer(ForwardDetLayer *detLayer, const BDLC &outerBL, const FDLC &outerFL, const MagneticField *field, float epsilon, bool checkCrossingSide=true)