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