CMS 3D CMS Logo

SimpleForwardNavigableLayer.cc
Go to the documentation of this file.
2 
6 
9 
12 
13 using namespace std;
14 
16  const BDLC& outerBL,
17  const FDLC& outerFL,
18  const MagneticField* field,
19  float epsilon,
20  bool checkCrossingSide)
21  : SimpleNavigableLayer(field, epsilon, checkCrossingSide),
22  theDetLayer(detLayer),
23  theOuterBarrelLayers(outerBL),
24  theInnerBarrelLayers(0),
25  theOuterForwardLayers(outerFL),
26  theInnerForwardLayers(0),
27  theOuterLayers(0),
28  theInnerLayers(0) {
29  // put barrel and forward layers together
30  theOuterLayers.reserve(outerBL.size() + outerFL.size());
31  for (ConstBDLI bl = outerBL.begin(); bl != outerBL.end(); bl++)
32  theOuterLayers.push_back(*bl);
33  for (ConstFDLI fl = outerFL.begin(); fl != outerFL.end(); fl++)
34  theOuterLayers.push_back(*fl);
35 
36  // sort the outer layers
37  sort(theOuterLayers.begin(), theOuterLayers.end(), TkLayerLess());
40 }
41 
43  vector<const DetLayer*> result;
44 
45  // the order is the one in which layers
46  // should be checked for a reasonable trajectory
47 
48  if (dir == insideOut) {
49  return theOuterLayers;
50  } else {
51  return theInnerLayers;
52  }
53 
54  return result;
55 }
56 
58  PropagationDirection dir) const {
59  // This method contains the sequence in which the layers are tested.
60  // The iteration stops as soon as a layer contains the propagated state
61  // within epsilon
62 
63  vector<const DetLayer*> result;
64 
65  FreeTrajectoryState ftsWithoutErrors = (fts.hasError()) ? FreeTrajectoryState(fts.parameters()) : fts;
66 
67  auto const position = fts.position();
68  auto const momentum = fts.momentum();
69 
70  //establish whether the tracks is crossing the tracker from outer layers to inner ones
71  //or from inner to outer
72  float zpos = position.z();
73  bool isInOutTrackFWD = momentum.z() * zpos > 0;
74  GlobalVector transversePosition(position.x(), position.y(), 0);
75  bool isInOutTrackBarrel = (transversePosition.dot(momentum) > 0);
76 
77  //establish whether inner or outer layers are crossed after propagation, according
78  //to BOTH propagationDirection AND track momentum
79  bool dirOppositeXORisInOutTrackBarrel =
80  (!(dir == oppositeToMomentum) && isInOutTrackBarrel) || ((dir == oppositeToMomentum) && !isInOutTrackBarrel);
81  bool dirOppositeXORisInOutTrackFWD =
82  (!(dir == oppositeToMomentum) && isInOutTrackFWD) || ((dir == oppositeToMomentum) && !isInOutTrackFWD);
83  //bool dirOppositeXORisInOutTrack = ( !(dir == oppositeToMomentum) && isInOutTrack) || ( (dir == oppositeToMomentum) && !isInOutTrack);
84 
85  if
86  LIKELY(dirOppositeXORisInOutTrackFWD && dirOppositeXORisInOutTrackBarrel) { //standard tracks
87  wellInside(ftsWithoutErrors, dir, theOuterLayers, result);
88  }
89  else if (!dirOppositeXORisInOutTrackFWD && !dirOppositeXORisInOutTrackBarrel) { // !dirOppositeXORisInOutTrack
90  wellInside(ftsWithoutErrors, dir, theInnerLayers, result);
91  } else if (!dirOppositeXORisInOutTrackFWD && dirOppositeXORisInOutTrackBarrel) {
92  wellInside(ftsWithoutErrors, dir, theInnerForwardLayers.begin(), theInnerForwardLayers.end(), result);
93  wellInside(ftsWithoutErrors, dir, theOuterBarrelLayers.begin(), theOuterBarrelLayers.end(), result);
94  } else {
95  wellInside(ftsWithoutErrors, dir, theInnerBarrelLayers.begin(), theInnerBarrelLayers.end(), result);
96  wellInside(ftsWithoutErrors, dir, theOuterForwardLayers.begin(), theOuterForwardLayers.end(), result);
97  }
98 
99  return result;
100 }
101 
103  edm::LogError("TkNavigation") << "ERROR: compatibleLayers() method used without all reachableLayers are set";
104  throw DetLayerException("compatibleLayers() method used without all reachableLayers are set");
105  return vector<const DetLayer*>();
106 }
107 
109  cerr << "Warning: SimpleForwardNavigableLayer::setDetLayer called." << endl << "This should never happen!" << endl;
110 }
111 
113  theInnerBarrelLayers = innerBL;
114  theInnerForwardLayers = innerFL;
115 
116  theInnerLayers.clear();
117  theInnerLayers.reserve(innerBL.size() + innerFL.size());
118  for (ConstBDLI bl = innerBL.begin(); bl != innerBL.end(); bl++)
119  theInnerLayers.push_back(*bl);
120  for (ConstFDLI fl = innerFL.begin(); fl != innerFL.end(); fl++)
121  theInnerLayers.push_back(*fl);
122 
123  // sort the inner layers
124  sort(theInnerLayers.begin(), theInnerLayers.end(), sorter);
125  sort(theInnerForwardLayers.begin(), theInnerForwardLayers.end(), sorter);
126  sort(theInnerBarrelLayers.begin(), theInnerBarrelLayers.end(), sorter);
127 }
128 
130  const ForwardDetLayer* fadditional = dynamic_cast<const ForwardDetLayer*>(additional);
131  const BarrelDetLayer* badditional = dynamic_cast<const BarrelDetLayer*>(additional);
132  if (badditional) {
133  if (direction == insideOut) {
134  theOuterBarrelLayers.push_back(badditional);
135  theOuterLayers.push_back(badditional);
136  return;
137  }
138  theInnerBarrelLayers.push_back(badditional);
139  theInnerLayers.push_back(badditional);
140  return;
141  } else if (fadditional) {
142  if (direction == insideOut) {
143  theOuterForwardLayers.push_back(fadditional);
144  theOuterLayers.push_back(badditional);
145  return;
146  }
147  theInnerForwardLayers.push_back(fadditional);
148  theInnerLayers.push_back(badditional);
149  return;
150  }
151  edm::LogError("TkNavigation") << "trying to add neither a ForwardDetLayer nor a BarrelDetLayer";
152  return;
153 }
void setDetLayer(const DetLayer *dl) override
Common base class.
const GlobalTrajectoryParameters & parameters() const
std::vector< const DetLayer * > compatibleLayers(NavigationDirection direction) const override
#define LIKELY(x)
Definition: Likely.h:20
PropagationDirection
SimpleForwardNavigableLayer(const ForwardDetLayer *detLayer, const BDLC &outerBL, const FDLC &outerFL, const MagneticField *field, float epsilon, bool checkCrossingSide=true)
std::vector< const DetLayer * > nextLayers(NavigationDirection direction) const override
std::vector< const ForwardDetLayer * > FDLC
FDLC::const_iterator ConstFDLI
GlobalVector momentum() const
GlobalPoint position() const
bool wellInside(const FreeTrajectoryState &fts, PropagationDirection dir, const BarrelDetLayer *bl, DLC &result) const
static int position[264][3]
Definition: ReadPGInfo.cc:289
void setAdditionalLink(const DetLayer *, NavigationDirection direction=insideOut) override
BDLC::const_iterator ConstBDLI
void setInwardLinks(const BDLC &, const FDLC &, TkLayerLess sorter=TkLayerLess(outsideIn)) override
std::vector< const BarrelDetLayer * > BDLC