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 }
MuonDetLayerGeometry::allBarrelLayers
const std::vector< const DetLayer * > & allBarrelLayers() const
return all barrel DetLayers (DT+RPC), inside-out
Definition: MuonDetLayerGeometry.cc:189
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
mps_fire.i
i
Definition: mps_fire.py:428
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
MuonDetLayerGeometry::allCSCLayers
const std::vector< const DetLayer * > & allCSCLayers() const
return the CSC DetLayers (endcap), -Z to +Z
Definition: MuonDetLayerGeometry.cc:152
MuonNavigationSchool::~MuonNavigationSchool
~MuonNavigationSchool() override
Destructor.
Definition: MuonNavigationSchool.cc:98
MuonNavigationSchool::theForwardNLC
std::vector< MuonForwardNavigableLayer * > theForwardNLC
Definition: MuonNavigationSchool.h:80
MuonDetLayerGeometry::allEndcapCscME0Layers
const std::vector< const DetLayer * > & allEndcapCscME0Layers() const
return all endcap DetLayers (CSC+ME0), -Z to +Z
Definition: MuonDetLayerGeometry.cc:207
MuonNavigationSchool::createInverseLinks
void createInverseLinks()
establish inward links
Definition: MuonNavigationSchool.cc:255
MuonNavigationSchool::delete_layer
Definition: MuonNavigationSchool.h:65
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
BoundDisk.h
deep_tau::DeepTauBase::BasicDiscriminator
BasicDiscriminator
Definition: DeepTauBase.h:115
MuonForwardNavigableLayer::setInwardLinks
void setInwardLinks(const MapB &, const MapE &)
set inward links
Definition: MuonForwardNavigableLayer.cc:147
egammaIdentification.eta_min
eta_min
Definition: egammaIdentification.py:19
MapBI
MapB::const_iterator MapBI
Definition: MTDDetLayerMap.h:38
MuonNavigationSchool::MuonNavigationSchool
MuonNavigationSchool(const MuonDetLayerGeometry *, bool enableRPC=true, bool enableCSC=true, bool enableGEM=false, bool enableME0=false)
Constructor.
Definition: MuonNavigationSchool.cc:42
MuonDetLayerGeometry::allDTLayers
const std::vector< const DetLayer * > & allDTLayers() const
return the DT DetLayers (barrel), inside-out
Definition: MuonDetLayerGeometry.cc:150
BoundCylinder.h
MuonBarrelNavigableLayer::getAllOuterForwardLayers
MapE getAllOuterForwardLayers() const
Definition: MuonBarrelNavigableLayer.h:133
MuonDetLayerGeometry.h
MuonBarrelNavigableLayer::getOuterBarrelLayers
MapB getOuterBarrelLayers() const
Definition: MuonBarrelNavigableLayer.h:122
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
BoundDisk
MuonBarrelNavigableLayer::getAllOuterBarrelLayers
MapB getAllOuterBarrelLayers() const
Definition: MuonBarrelNavigableLayer.h:129
MuonNavigationSchool::theForwardLayers
MapE theForwardLayers
barrel
Definition: MuonNavigationSchool.h:76
MuonEtaRange.h
MuonNavigationSchool::addEndcapLayer
void addEndcapLayer(const ForwardDetLayer *)
add endcap layer (backward and forward)
Definition: MuonNavigationSchool.cc:139
MuonEtaRange
Definition: MuonEtaRange.h:15
MuonNavigationSchool::linkEndcapLayers
void linkEndcapLayers(const MapE &, std::vector< MuonForwardNavigableLayer * > &)
link endcap layers
Definition: MuonNavigationSchool.cc:219
MuonDetLayerGeometry
Definition: MuonDetLayerGeometry.h:21
MuonDetLayerGeometry::allEndcapLayers
const std::vector< const DetLayer * > & allEndcapLayers() const
return all endcap DetLayers (CSC+RPC+GEM+ME0), -Z to +Z
Definition: MuonDetLayerGeometry.cc:191
MuonDetLayerMap.h
MuonNavigationSchool::addBarrelLayer
void addBarrelLayer(const BarrelDetLayer *)
add barrel layer
Definition: MuonNavigationSchool.cc:127
MapEI
MapE::const_iterator MapEI
Definition: MTDDetLayerMap.h:39
MuonBarrelNavigableLayer.h
DDAxes::z
MuonNavigationSchool::theBarrelLayers
MapB theBarrelLayers
Definition: MuonNavigationSchool.h:75
NavigationSchool::theAllNavigableLayer
StateType theAllNavigableLayer
Definition: NavigationSchool.h:60
MuonBarrelNavigableLayer::setInwardCompatibleLinks
void setInwardCompatibleLinks(const MapB &)
Definition: MuonBarrelNavigableLayer.cc:152
MuonBarrelNavigableLayer
Definition: MuonBarrelNavigableLayer.h:34
MuonForwardNavigableLayer.h
NavigationSchool::StateType
std::vector< NavigableLayer * > StateType
Definition: NavigationSchool.h:26
MuonBarrelNavigableLayer::getOuterBackwardLayers
MapE getOuterBackwardLayers() const
Definition: MuonBarrelNavigableLayer.h:124
MuonNavigationSchool::theBarrelNLC
std::vector< MuonBarrelNavigableLayer * > theBarrelNLC
-z endcap
Definition: MuonNavigationSchool.h:79
MuonDetLayerGeometry::allGEMLayers
const std::vector< const DetLayer * > & allGEMLayers() const
return the GEM DetLayers (endcap), -Z to +Z
Definition: MuonDetLayerGeometry.cc:159
MuonBarrelNavigableLayer::getOuterForwardLayers
MapE getOuterForwardLayers() const
Definition: MuonBarrelNavigableLayer.h:126
MuonForwardNavigableLayer::setInwardCompatibleLinks
void setInwardCompatibleLinks(const MapB &, const MapE &)
Definition: MuonForwardNavigableLayer.cc:151
MuonNavigationSchool::linkBarrelLayers
void linkBarrelLayers()
link barrel layers
Definition: MuonNavigationSchool.cc:165
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
MapB
std::map< const BarrelDetLayer *, MTDEtaRange, MTDDetLayerComp > MapB
Definition: MTDDetLayerMap.h:36
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
distMuonTCMETValueMapProducer_cff.eta_max
eta_max
Definition: distMuonTCMETValueMapProducer_cff.py:9
NavigationSchool::theAllDetLayersInSystem
const std::vector< const DetLayer * > * theAllDetLayersInSystem
Definition: NavigationSchool.h:67
BarrelDetLayer.h
cuy.ib
ib
Definition: cuy.py:662
MuonDetLayerGeometry::allEndcapCscGemLayers
const std::vector< const DetLayer * > & allEndcapCscGemLayers() const
return all endcap DetLayers (CSC+GEM), -Z to +Z
Definition: MuonDetLayerGeometry.cc:199
MuonBarrelNavigableLayer::setInwardLinks
void setInwardLinks(const MapB &)
set inward links
Definition: MuonBarrelNavigableLayer.cc:151
BarrelDetLayer
Definition: BarrelDetLayer.h:22
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
alignCSCRings.r
r
Definition: alignCSCRings.py:93
std
Definition: JetResolutionObject.h:76
ForwardDetLayer
Definition: ForwardDetLayer.h:22
MapE
std::map< const ForwardDetLayer *, MTDEtaRange, MTDDetLayerComp > MapE
Definition: MTDDetLayerMap.h:37
MuonNavigationSchool::calculateEta
float calculateEta(const float &, const float &) const
calculate pseudorapidity from r and z
Definition: MuonNavigationSchool.cc:158
ForwardDetLayer.h
Exception
Definition: hltDiff.cc:246
MuonNavigationSchool.h
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
MuonNavigationSchool::navigableLayers
StateType navigableLayers() override
return navigable layers, from base class
Definition: MuonNavigationSchool.cc:105
BoundCylinder
Exception.h
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
MuonForwardNavigableLayer
Definition: MuonForwardNavigableLayer.h:33
mps_fire.result
result
Definition: mps_fire.py:311
MuonDetLayerGeometry::allLayers
const std::vector< const DetLayer * > & allLayers() const
return all layers (DT+CSC+RPC+GEM), order: backward, barrel, forward
Definition: MuonDetLayerGeometry.cc:187
NavigationSchool::setState
void setState(const StateType &state)
Definition: NavigationSchool.h:47
MuonNavigationSchool::theBackwardLayers
MapE theBackwardLayers
+z endcap
Definition: MuonNavigationSchool.h:77
MuonDetLayerGeometry::allME0Layers
const std::vector< const DetLayer * > & allME0Layers() const
return the ME0 DetLayers (endcap), -Z to +Z
Definition: MuonDetLayerGeometry.cc:169
MuonBarrelNavigableLayer::getAllOuterBackwardLayers
MapE getAllOuterBackwardLayers() const
Definition: MuonBarrelNavigableLayer.h:131
BarrelDetLayer::specificSurface
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
Definition: BarrelDetLayer.h:39
hgcalTopologyTester_cfi.layers
layers
Definition: hgcalTopologyTester_cfi.py:8
MuonNavigationSchool::theBackwardNLC
std::vector< MuonForwardNavigableLayer * > theBackwardNLC
Definition: MuonNavigationSchool.h:81
ForwardDetLayer::specificSurface
virtual const BoundDisk & specificSurface() const final
Definition: ForwardDetLayer.h:39
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31