CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DirectMuonNavigation.cc
Go to the documentation of this file.
2 
14 
15 #include <algorithm>
16 
17 using namespace std;
18 
19 DirectMuonNavigation::DirectMuonNavigation(const edm::ESHandle<MuonDetLayerGeometry>& muonLayout) : theMuonDetLayerGeometry(muonLayout), epsilon_(100.), theEndcapFlag(true), theBarrelFlag(true) {
20 }
21 
22 DirectMuonNavigation::DirectMuonNavigation(const edm::ESHandle<MuonDetLayerGeometry>& muonLayout, const edm::ParameterSet& par) : theMuonDetLayerGeometry(muonLayout), epsilon_(100.), theEndcapFlag(par.getParameter<bool>("Endcap")), theBarrelFlag(par.getParameter<bool>("Barrel")) {
23 
24 }
25 
26 
27 /* return compatible layers for given trajectory state */
28 vector<const DetLayer*>
30  PropagationDirection dir ) const {
31 
32  float z0 = fts.position().z();
33  float zm = fts.momentum().z();
34 
35  bool inOut = outward(fts);
36 
37  vector<const DetLayer*> output;
38 
39  // check direction and position of FTS to get a correct order of DetLayers
40 
41  if (inOut) {
42  if ((zm * z0) >= 0) {
43  if (theBarrelFlag) inOutBarrel(fts,output);
44  if (theEndcapFlag) {
45  if ( z0 >= 0 ) inOutForward(fts,output);
46  else inOutBackward(fts,output);
47  }
48  } else {
49  if (theEndcapFlag) {
50  if ( z0 >= 0 ) outInForward(fts,output);
51  else outInBackward(fts,output);
52  }
53  if (theBarrelFlag) inOutBarrel(fts,output);
54  }
55  } else {
56  if ((zm * z0) >= 0) {
57  if (theBarrelFlag) outInBarrel(fts,output);
58  if (theEndcapFlag) {
59  if ( z0 >= 0 ) inOutForward(fts,output);
60  else inOutBackward(fts,output);
61  }
62  } else {
63  if (theEndcapFlag) {
64  if ( z0 >= 0 ) outInForward(fts,output);
65  else outInBackward(fts,output);
66  }
67  if (theBarrelFlag) outInBarrel(fts,output);
68  }
69  }
70 
71  if ( dir == oppositeToMomentum ) std::reverse(output.begin(),output.end());
72 
73  return output;
74 }
75 
76 /*
77 return compatible endcap layers on BOTH ends;
78 used for beam-halo muons
79 */
80 vector<const DetLayer*>
82  PropagationDirection dir ) const {
83 
84  float zm = fts.momentum().z();
85 
86  vector<const DetLayer*> output;
87 
88  // collect all endcap layers on 2 sides
89  outInBackward(fts,output);
90  inOutForward(fts,output);
91 
92  // check direction FTS to get a correct order of DetLayers
93  if ( ( zm > 0 && dir == oppositeToMomentum ) ||
94  ( zm < 0 && dir == alongMomentum ) )
95  std::reverse(output.begin(),output.end());
96 
97  return output;
98 }
99 
100 void DirectMuonNavigation::inOutBarrel(const FreeTrajectoryState& fts, vector<const DetLayer*>& output) const {
101 
102  bool cont = false;
103  const vector<const DetLayer*>& barrel = theMuonDetLayerGeometry->allBarrelLayers();
104 
105  for (vector<const DetLayer*>::const_iterator iter_B = barrel.begin(); iter_B != barrel.end(); iter_B++){
106 
107  if( cont ) output.push_back((*iter_B));
108  else if ( checkCompatible(fts,dynamic_cast<const BarrelDetLayer*>(*iter_B))) {
109  output.push_back((*iter_B));
110  cont = true;
111  }
112  }
113 }
114 
115 
116 void DirectMuonNavigation::outInBarrel(const FreeTrajectoryState& fts, vector<const DetLayer*>& output) const {
117 
118 // default barrel layers are in out, reverse order
119  const vector<const DetLayer*>& barrel = theMuonDetLayerGeometry->allBarrelLayers();
120 
121  bool cont = false;
122  vector<const DetLayer*>::const_iterator rbegin = barrel.end();
123  rbegin--;
124  vector<const DetLayer*>::const_iterator rend = barrel.begin();
125  rend--;
126 
127  for (vector<const DetLayer*>::const_iterator iter_B = rbegin; iter_B != rend; iter_B--){
128  if( cont ) output.push_back((*iter_B));
129  else if ( checkCompatible(fts,dynamic_cast<const BarrelDetLayer*>(*iter_B))) {
130  output.push_back((*iter_B));
131  cont = true;
132  }
133  }
134 }
135 
136 void DirectMuonNavigation::inOutForward(const FreeTrajectoryState& fts, vector<const DetLayer*>& output) const {
137 
138  const vector<const DetLayer*>& forward = theMuonDetLayerGeometry->allForwardLayers();
139  bool cont = false;
140  for (vector<const DetLayer*>::const_iterator iter_E = forward.begin(); iter_E != forward.end();
141  iter_E++){
142  if( cont ) output.push_back((*iter_E));
143  else if ( checkCompatible(fts,dynamic_cast<const ForwardDetLayer*>(*iter_E))) {
144  output.push_back((*iter_E));
145  cont = true;
146  }
147  }
148 }
149 
150 void DirectMuonNavigation::outInForward(const FreeTrajectoryState& fts, vector<const DetLayer*>& output) const {
151 // default forward layers are in out, reverse order
152 
153  bool cont = false;
154  const vector<const DetLayer*>& forward = theMuonDetLayerGeometry->allForwardLayers();
155  vector<const DetLayer*>::const_iterator rbegin = forward.end();
156  rbegin--;
157  vector<const DetLayer*>::const_iterator rend = forward.begin();
158  rend--;
159  for (vector<const DetLayer*>::const_iterator iter_E = rbegin; iter_E != rend;
160  iter_E--){
161  if( cont ) output.push_back((*iter_E));
162  else if ( checkCompatible(fts,dynamic_cast<const ForwardDetLayer*>(*iter_E))) {
163  output.push_back((*iter_E));
164  cont = true;
165  }
166  }
167 }
168 
169 void DirectMuonNavigation::inOutBackward(const FreeTrajectoryState& fts, vector<const DetLayer*>& output) const {
170  bool cont = false;
171  const vector<const DetLayer*>& backward = theMuonDetLayerGeometry->allBackwardLayers();
172 
173  for (vector<const DetLayer*>::const_iterator iter_E = backward.begin(); iter_E != backward.end();
174  iter_E++){
175  if( cont ) output.push_back((*iter_E));
176  else if ( checkCompatible(fts,dynamic_cast<const ForwardDetLayer*>(*iter_E))) {
177  output.push_back((*iter_E));
178  cont = true;
179  }
180  }
181 }
182 
183 void DirectMuonNavigation::outInBackward(const FreeTrajectoryState& fts, vector<const DetLayer*>& output) const {
184 
185  bool cont = false;
186  const vector<const DetLayer*>& backward = theMuonDetLayerGeometry->allBackwardLayers();
187 
188  vector<const DetLayer*>::const_iterator rbegin = backward.end();
189  rbegin--;
190  vector<const DetLayer*>::const_iterator rend = backward.begin();
191  rend--;
192  for (vector<const DetLayer*>::const_iterator iter_E = rbegin; iter_E != rend;
193  iter_E--){
194  if( cont ) output.push_back((*iter_E));
195  else if ( checkCompatible(fts,dynamic_cast<const ForwardDetLayer*>(*iter_E))) {
196  output.push_back((*iter_E));
197  cont = true;
198  }
199  }
200 
201 }
202 
203 
205 
206  float z0 = fts.position().z();
207  float r0 = fts.position().perp();
208  float zm = fts.momentum().z();
209  float rm = fts.momentum().perp();
210  float slope = zm/rm;
211  if (!outward(fts) ) slope = -slope;
212  const BoundCylinder bc = dl->specificSurface();
213  float radius = bc.radius();
214  float length = bc.bounds().length()/2.;
215 
216  float z1 = slope*(radius - r0) + z0;
217  return ( fabs(z1) <= fabs(length)+epsilon_ );
218 
219 }
220 
222 
223  float z0 = fts.position().z();
224  float r0 = fts.position().perp();
225  float zm = fts.momentum().z();
226  float rm = fts.momentum().perp();
227  float slope = rm/zm;
228 
229  if (!outward(fts) ) slope = -slope;
230 
231  const BoundDisk bd = dl->specificSurface();
232 
233  float outRadius = bd.outerRadius();
234  float inRadius = bd.innerRadius();
235  float z = bd.position().z();
236 
237  float r1 = slope*(z - z0) + r0;
238  return (r1 >= inRadius-epsilon_ && r1 <= outRadius+epsilon_);
239 
240 }
241 
243 
244 // return (fts.position().basicVector().dot(fts.momentum().basicVector())>0);
245 
246  float x0 = fts.position().x();
247  float y0 = fts.position().y();
248 
249  float xm = fts.momentum().x();
250  float ym = fts.momentum().y();
251 
252  return ((x0 * xm + y0 * ym ) > 0);
253 
254 
255 }
edm::ESHandle< MuonDetLayerGeometry > theMuonDetLayerGeometry
T perp() const
Definition: PV3DBase.h:72
std::vector< const DetLayer * > compatibleEndcapLayers(const FreeTrajectoryState &fts, PropagationDirection timeDirection) const
static const double slope[3]
void inOutBackward(const FreeTrajectoryState &, std::vector< const DetLayer * > &) const
T y() const
Definition: PV3DBase.h:63
void outInForward(const FreeTrajectoryState &, std::vector< const DetLayer * > &) const
void inOutForward(const FreeTrajectoryState &, std::vector< const DetLayer * > &) const
PropagationDirection
DirectMuonNavigation(const edm::ESHandle< MuonDetLayerGeometry > &)
float float float z
bool outward(const FreeTrajectoryState &fts) const
std::vector< const DetLayer * > compatibleLayers(const FreeTrajectoryState &fts, PropagationDirection timeDirection) const
bool checkCompatible(const FreeTrajectoryState &fts, const BarrelDetLayer *) const
void outInBarrel(const FreeTrajectoryState &, std::vector< const DetLayer * > &) const
T z() const
Definition: PV3DBase.h:64
virtual const BoundDisk & specificSurface() const
string rm
Definition: submit.py:76
void outInBackward(const FreeTrajectoryState &, std::vector< const DetLayer * > &) const
GlobalVector momentum() const
GlobalPoint position() const
virtual const BoundCylinder & specificSurface() const
Extension of the interface.
int cont
void inOutBarrel(const FreeTrajectoryState &, std::vector< const DetLayer * > &) const
dbl *** dir
Definition: mlp_gen.cc:35
T x() const
Definition: PV3DBase.h:62