CMS 3D CMS Logo

MuonNavigationSchool.cc
Go to the documentation of this file.
1 
23 
24 /* Collaborating Class Header */
27 // #include "TrackingTools/DetLayers/interface/NavigationSetter.h"
36 
37 #include <algorithm>
38 #include <iostream>
39 using namespace std;
40 
42 MuonNavigationSchool::MuonNavigationSchool(const MuonDetLayerGeometry * muonLayout, bool enableRPC, bool enableCSC, bool enableGEM, bool enableME0 ) : theMuonDetLayerGeometry(muonLayout) {
43 
44  theAllDetLayersInSystem=&muonLayout->allLayers();
45  theAllNavigableLayer.resize(muonLayout->allLayers().size(),nullptr);
46 
47 
48 
49  // get all barrel DetLayers (DT + optional RPC)
50  vector<const DetLayer*> barrel;
51  if ( enableRPC ) barrel = muonLayout->allBarrelLayers();
52  else barrel = muonLayout->allDTLayers();
53 
54  for ( auto i = barrel.begin(); i != barrel.end(); i++ ) {
55  const BarrelDetLayer* mbp = dynamic_cast<const BarrelDetLayer*>(*i);
56  if ( mbp == nullptr ) throw cms::Exception("MuonNavigationSchool", "Bad BarrelDetLayer");
57  addBarrelLayer(mbp);
58  }
59 
60 
61  // get all endcap DetLayers (CSC + optional RPC, GEM, ME0)
62  vector<const DetLayer*> endcap;
63  if ( enableCSC & enableGEM & enableRPC & enableME0) endcap = muonLayout->allEndcapLayers(); //CSC + RPC + GEM +ME0
64  else if ( enableCSC & enableGEM & !enableRPC & !enableME0) endcap = muonLayout->allEndcapCscGemLayers(); // CSC + GEM
65  else if ( !enableCSC & enableGEM & !enableRPC & !enableME0) endcap = muonLayout->allGEMLayers(); //GEM only
66  else if ( enableCSC & !enableGEM & !enableRPC & !enableME0) endcap = muonLayout->allCSCLayers(); //CSC only
67  else if ( enableCSC & !enableGEM & !enableRPC & enableME0) endcap = muonLayout->allEndcapCscME0Layers(); // CSC + ME0
68  else if ( !enableCSC & !enableGEM & !enableRPC & enableME0) endcap = muonLayout->allME0Layers(); // ME0 only
69  //else endcap = muonLayout->allCSCLayers(); //CSC only for all the remaining cases
70  //Trying allEndcaplayers in all other cases, as in the GEM PR
71  else endcap = muonLayout->allEndcapLayers();
72 
73  for ( auto i = endcap.begin(); i != endcap.end(); i++ ) {
74  const ForwardDetLayer* mep = dynamic_cast<const ForwardDetLayer*>(*i);
75  if ( mep == nullptr ) throw cms::Exception("MuonNavigationSchool", "Bad ForwardDetLayer");
76  addEndcapLayer(mep);
77  }
78 
79  // create outward links for all DetLayers
83 
84  // create inverse links
86 
87 }
88 
89 
92 
93  for_each(theBarrelNLC.begin(),theBarrelNLC.end(), delete_layer());
94  for_each(theForwardNLC.begin(),theForwardNLC.end(), delete_layer());
95  for_each(theBackwardNLC.begin(),theBackwardNLC.end(), delete_layer());
96 
97 }
98 
99 
103 
105 
106  vector<MuonBarrelNavigableLayer*>::const_iterator ib;
107  vector<MuonForwardNavigableLayer*>::const_iterator ie;
108 
109  for ( ib = theBarrelNLC.begin(); ib != theBarrelNLC.end(); ib++ ) {
110  result.push_back(*ib);
111  }
112 
113  for ( ie = theForwardNLC.begin(); ie != theForwardNLC.end(); ie++ ) {
114  result.push_back(*ie);
115  }
116 
117  for ( ie = theBackwardNLC.begin(); ie != theBackwardNLC.end(); ie++ ) {
118  result.push_back(*ie);
119  }
120 
121  return result;
122 
123 }
124 
125 
128 
129  const BoundCylinder& bc = mbp->specificSurface();
130  float radius = bc.radius();
131  float length = bc.bounds().length()/2.;
132 
133  float eta_max = calculateEta(radius, length);
134  float eta_min = -eta_max;
135 
136  theBarrelLayers[mbp] = MuonEtaRange(eta_max, eta_min);
137 
138 }
139 
140 
143 
144  const BoundDisk& bd = mep->specificSurface();
145  float outRadius = bd.outerRadius();
146  float inRadius = bd.innerRadius();
147  float thick = bd.bounds().length()/2.;
148  float z = bd.position().z();
149 
150  if ( z > 0. ) {
151  float eta_min = calculateEta(outRadius, z-thick);
152  float eta_max = calculateEta(inRadius, z+thick);
153  theForwardLayers[mep] = MuonEtaRange(eta_max, eta_min);
154  } else {
155  float eta_max = calculateEta(outRadius, z+thick);
156  float eta_min = calculateEta(inRadius, z-thick);
157  theBackwardLayers[mep] = MuonEtaRange(eta_max, eta_min);
158  }
159 
160 }
161 
162 
164 float MuonNavigationSchool::calculateEta(const float& r, const float& z) const {
165 
166  if ( z > 0 ) return -log((tan(atan(r/z)/2.)));
167  return log(-(tan(atan(r/z)/2.)));
168 
169 }
170 
173 
174  for (MapBI bl = theBarrelLayers.begin();
175  bl != theBarrelLayers.end(); bl++) {
176 
177  MuonEtaRange range = (*bl).second;
178 
179  // first add next barrel layer
180  MapBI plusOne(bl);
181  plusOne++;
182  MapB outerBarrel;
183  MapB allOuterBarrel;
184  if ( plusOne != theBarrelLayers.end() ) { outerBarrel.insert(*plusOne);}
185  // add all outer barrel layers
186  for ( MapBI iMBI = plusOne; iMBI!= theBarrelLayers.end(); iMBI++){
187  allOuterBarrel.insert(*iMBI);
188  }
189  // then add all compatible backward layers with an eta criteria
190  MapE allOuterBackward;
191  for (MapEI el = theBackwardLayers.begin();
192  el != theBackwardLayers.end(); el++) {
193  if ( (*el).second.isCompatible(range) ) {
194  allOuterBackward.insert(*el);
195  }
196  }
197  //add the backward next layer with an eta criteria
198  MapE outerBackward;
199  for (MapEI el = theBackwardLayers.begin();
200  el != theBackwardLayers.end(); el++) {
201  if ( (*el).second.isCompatible(range) ) {
202  outerBackward.insert(*el);
203  break;
204  }
205  }
206 
207  // then add all compatible forward layers with an eta criteria
208  MapE allOuterForward;
209  for (MapEI el = theForwardLayers.begin();
210  el != theForwardLayers.end(); el++) {
211  if ( (*el).second.isCompatible(range) ) {
212  allOuterForward.insert(*el);
213  }
214  }
215 
216  // then add forward next layer with an eta criteria
217  MapE outerForward;
218  for (MapEI el = theForwardLayers.begin();
219  el != theForwardLayers.end(); el++) {
220  if ( (*el).second.isCompatible(range) ) {
221  outerForward.insert(*el);
222  break;
223  }
224  }
225 
227  (*bl).first,outerBarrel, outerBackward, outerForward,
228  allOuterBarrel,allOuterBackward,allOuterForward));
229 
230  }
231 
232 }
235  vector<MuonForwardNavigableLayer*>& result) {
236 
237  for (MapEI el = layers.begin(); el != layers.end(); el++) {
238 
239  MuonEtaRange range = (*el).second;
240  // first add next endcap layer (if compatible)
241  MapEI plusOne(el);
242  plusOne++;
243  MapE outerLayers;
244  if ( plusOne != layers.end() && (*plusOne).second.isCompatible(range) ) {
245  outerLayers.insert(*plusOne);
246  if ( !range.isInside((*plusOne).second) ) {
247  // then look if the next layer has a wider eta range, if so add it
248  MapEI tmpel(plusOne);
249  tmpel++;
250  MuonEtaRange max((*plusOne).second);
251  for ( MapEI l = tmpel; l != layers.end(); l++ ) {
252  MuonEtaRange next = (*l).second;
253  if ( next.isCompatible(max) && !range.isInside(next) &&
254  !next.isInside(max) && next.subtract(max).isInside(range) ) {
255  max = max.add(next);
256  outerLayers.insert(*l);
257  }
258  }
259  }
260  }
261 
262  MapE allOuterLayers;
263  for (MapEI iMEI = plusOne; iMEI!=layers.end(); iMEI++){
264  if ((*iMEI).second.isCompatible(range)) allOuterLayers.insert(*iMEI);
265  }
266 
267  result.push_back(new MuonForwardNavigableLayer(
268  (*el).first,outerLayers, allOuterLayers));
269  }
270 
271 }
272 
273 
276 
277  // set outward link
278  // NavigationSetter setter(*this);
279 
281 
282 
283  // find for each layer which are the layers pointing to it
284  typedef map<const DetLayer*, MapB, less<const DetLayer*> > BarrelMapType;
285  typedef map<const DetLayer*, MapE, less<const DetLayer*> > ForwardMapType;
286 
287  // map of all DetLayers which can reach a specific DetLayer
288  BarrelMapType reachedBarrelLayersMap;
289  ForwardMapType reachedForwardLayersMap;
290 
291  // map of all DetLayers which is compatible with a specific DetLayer
292  BarrelMapType compatibleBarrelLayersMap;
293  ForwardMapType compatibleForwardLayersMap;
294 
295  // collect all reacheable layers starting from a barrel layer
296  for ( MapBI bli = theBarrelLayers.begin();
297  bli != theBarrelLayers.end(); bli++ ) {
298  // barrel
300  dynamic_cast<MuonBarrelNavigableLayer*>(theAllNavigableLayer[((*bli).first)->seqNum()]);
301  MapB reacheableB = mbnl->getOuterBarrelLayers();
302  for (MapBI i = reacheableB.begin(); i != reacheableB.end(); i++ ) {
303  reachedBarrelLayersMap[(*i).first].insert(*bli);
304  }
305  MapB compatibleB = mbnl->getAllOuterBarrelLayers();
306  for (MapBI i = compatibleB.begin(); i != compatibleB.end(); i++ ) {
307  compatibleBarrelLayersMap[(*i).first].insert(*bli);
308  }
309  MapE reacheableE = mbnl->getOuterBackwardLayers();
310  for (MapEI i = reacheableE.begin(); i != reacheableE.end(); i++ ) {
311  reachedBarrelLayersMap[(*i).first].insert(*bli);
312  }
313  reacheableE = mbnl->getOuterForwardLayers();
314  for (MapEI i = reacheableE.begin(); i != reacheableE.end(); i++ ) {
315  reachedBarrelLayersMap[(*i).first].insert(*bli);
316  }
317  MapE compatibleE = mbnl->getAllOuterBackwardLayers();
318  for (MapEI i = compatibleE.begin(); i != compatibleE.end(); i++ ) {
319  compatibleBarrelLayersMap[(*i).first].insert(*bli);
320  }
321  compatibleE = mbnl->getAllOuterForwardLayers();
322  for (MapEI i = compatibleE.begin(); i != compatibleE.end(); i++ ) {
323  compatibleBarrelLayersMap[(*i).first].insert(*bli);
324  }
325 
326  }
327 
328  // collect all reacheable layer starting from a backward layer
329  for ( MapEI eli = theBackwardLayers.begin();
330  eli != theBackwardLayers.end(); eli++ ) {
331  MapE reacheableE =
332  dynamic_cast<MuonForwardNavigableLayer*>(theAllNavigableLayer[((*eli).first)->seqNum()])->getOuterEndcapLayers();
333  for (MapEI i = reacheableE.begin(); i != reacheableE.end(); i++ ) {
334  reachedForwardLayersMap[(*i).first].insert(*eli);
335  }
336  // collect all compatible layer starting from a backward layer
337  MapE compatibleE =
338  dynamic_cast<MuonForwardNavigableLayer*>(theAllNavigableLayer[((*eli).first)->seqNum()])->getAllOuterEndcapLayers();
339  for (MapEI i = compatibleE.begin(); i != compatibleE.end(); i++ ) {
340  compatibleForwardLayersMap[(*i).first].insert(*eli);
341  }
342  }
343 
344  for ( MapEI eli = theForwardLayers.begin();
345  eli != theForwardLayers.end(); eli++ ) {
346  // collect all reacheable layer starting from a forward layer
347  MapE reacheableE =
348  dynamic_cast<MuonForwardNavigableLayer*>(theAllNavigableLayer[((*eli).first)->seqNum()])->getOuterEndcapLayers();
349  for (MapEI i = reacheableE.begin(); i != reacheableE.end(); i++ ) {
350  reachedForwardLayersMap[(*i).first].insert(*eli);
351  }
352  // collect all compatible layer starting from a forward layer
353  MapE compatibleE =
354  dynamic_cast<MuonForwardNavigableLayer*>(theAllNavigableLayer[((*eli).first)->seqNum()])->getAllOuterEndcapLayers();
355  for (MapEI i = compatibleE.begin(); i != compatibleE.end(); i++ ) {
356  compatibleForwardLayersMap[(*i).first].insert(*eli);
357  }
358  }
359 
360  // now set inverse link for barrel layers
361  for ( MapBI bli = theBarrelLayers.begin();
362  bli != theBarrelLayers.end(); bli++ ) {
364  dynamic_cast<MuonBarrelNavigableLayer*>(theAllNavigableLayer[((*bli).first)->seqNum()]);
365  mbnl->setInwardLinks(reachedBarrelLayersMap[(*bli).first]);
366  mbnl->setInwardCompatibleLinks(compatibleBarrelLayersMap[(*bli).first]);
367 
368  }
369  //BACKWARD
370  for ( MapEI eli = theBackwardLayers.begin();
371  eli != theBackwardLayers.end(); eli++ ) {
373  dynamic_cast<MuonForwardNavigableLayer*>(theAllNavigableLayer[((*eli).first)->seqNum()]);
374  // for backward next layers
375  mfnl->setInwardLinks(reachedBarrelLayersMap[(*eli).first],
376  reachedForwardLayersMap[(*eli).first]);
377  // for backward compatible layers
378  mfnl->setInwardCompatibleLinks(compatibleBarrelLayersMap[(*eli).first],
379  compatibleForwardLayersMap[(*eli).first]);
380  }
381  //FORWARD
382  for ( MapEI eli = theForwardLayers.begin();
383  eli != theForwardLayers.end(); eli++ ) {
385  dynamic_cast<MuonForwardNavigableLayer*>(theAllNavigableLayer[((*eli).first)->seqNum()]);
386  // and for forward next layers
387  mfnl->setInwardLinks(reachedBarrelLayersMap[(*eli).first],
388  reachedForwardLayersMap[(*eli).first]);
389  // and for forward compatible layers
390  mfnl->setInwardCompatibleLinks(compatibleBarrelLayersMap[(*eli).first],
391  compatibleForwardLayersMap[(*eli).first]);
392  }
393 
394 }
void createInverseLinks()
establish inward links
const std::vector< const DetLayer * > & allEndcapCscME0Layers() const
return all endcap DetLayers (CSC+ME0), -Z to +Z
StateType navigableLayers() override
return navigable layers, from base class
std::vector< MuonForwardNavigableLayer * > theForwardNLC
MuonEtaRange add(const MuonEtaRange &) const
create maximum of ranges
Definition: MuonEtaRange.cc:59
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
MapE theBackwardLayers
+z endcap
const std::vector< const DetLayer * > & allEndcapLayers() const
return all endcap DetLayers (CSC+RPC+GEM+ME0), -Z to +Z
void addEndcapLayer(const ForwardDetLayer *)
add endcap layer (backward and forward)
MapB::const_iterator MapBI
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
std::map< const BarrelDetLayer *, MuonEtaRange, MuonDetLayerComp > MapB
const std::vector< const DetLayer * > & allCSCLayers() const
return the CSC DetLayers (endcap), -Z to +Z
void setInwardLinks(const MapB &, const MapE &)
set inward links
void setInwardCompatibleLinks(const MapB &)
std::vector< MuonForwardNavigableLayer * > theBackwardNLC
float calculateEta(const float &, const float &) const
calculate pseudorapidity from r and z
MapE::const_iterator MapEI
std::vector< MuonBarrelNavigableLayer * > theBarrelNLC
-z endcap
StateType theAllNavigableLayer
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
void linkBarrelLayers()
link barrel layers
const std::vector< const DetLayer * > & allBarrelLayers() const
return all barrel DetLayers (DT+RPC), inside-out
std::vector< NavigableLayer * > StateType
const std::vector< const DetLayer * > * theAllDetLayersInSystem
const std::vector< const DetLayer * > & allME0Layers() const
return the ME0 DetLayers (endcap), -Z to +Z
std::map< const ForwardDetLayer *, MuonEtaRange, MuonDetLayerComp > MapE
const std::vector< const DetLayer * > & allDTLayers() const
return the DT DetLayers (barrel), inside-out
virtual const BoundDisk & specificSurface() const final
void addBarrelLayer(const BarrelDetLayer *)
add barrel layer
bool isInside(float eta, float error=0.) const
Definition: MuonEtaRange.cc:43
~MuonNavigationSchool() override
Destructor.
void linkEndcapLayers(const MapE &, std::vector< MuonForwardNavigableLayer * > &)
link endcap layers
bool isCompatible(const MuonEtaRange &range) const
true if this overlaps with range
Definition: MuonEtaRange.cc:54
void setInwardLinks(const MapB &)
set inward links
void setInwardCompatibleLinks(const MapB &, const MapE &)
const std::vector< const DetLayer * > & allGEMLayers() const
return the GEM DetLayers (endcap), -Z to +Z
MuonNavigationSchool(const MuonDetLayerGeometry *, bool enableRPC=true, bool enableCSC=true, bool enableGEM=false, bool enableME0=false)
Constructor.
const std::vector< const DetLayer * > & allLayers() const
return all layers (DT+CSC+RPC+GEM), order: backward, barrel, forward
MuonEtaRange subtract(const MuonEtaRange &) const
create new range of size this minus range
Definition: MuonEtaRange.cc:65
const std::vector< const DetLayer * > & allEndcapCscGemLayers() const
return all endcap DetLayers (CSC+GEM), -Z to +Z
void setState(const StateType &state)
ib
Definition: cuy.py:660