CMS 3D CMS Logo

MTDNavigationSchool.cc
Go to the documentation of this file.
1 
16 
17 /* Collaborating Class Header */
28 
29 #include <algorithm>
30 #include <iostream>
31 using namespace std;
32 
34 MTDNavigationSchool::MTDNavigationSchool(const MTDDetLayerGeometry* mtdLayout, bool enableBTL, bool enableETL)
35  : theMTDDetLayerGeometry(mtdLayout) {
36  theAllDetLayersInSystem = &mtdLayout->allLayers();
37  theAllNavigableLayer.resize(mtdLayout->allLayers().size(), nullptr);
38 
39  // get all barrel DetLayers (BTL)
40  vector<const DetLayer*> barrel;
41  if (enableBTL)
42  barrel = mtdLayout->allBarrelLayers();
43  else
44  barrel = mtdLayout->allBarrelLayers();
45 
46  for (auto i = barrel.begin(); i != barrel.end(); i++) {
47  const BarrelDetLayer* mbp = dynamic_cast<const BarrelDetLayer*>(*i);
48  if (mbp == nullptr)
49  throw cms::Exception("MTDNavigationSchool", "Bad BarrelDetLayer");
50  addBarrelLayer(mbp);
51  }
52 
53  // get all endcap DetLayers (ETL)
54  vector<const DetLayer*> endcap;
55  if (enableETL)
56  endcap = mtdLayout->allEndcapLayers();
57  else
58  endcap = mtdLayout->allEndcapLayers();
59 
60  for (auto i = endcap.begin(); i != endcap.end(); i++) {
61  const ForwardDetLayer* mep = dynamic_cast<const ForwardDetLayer*>(*i);
62  if (mep == nullptr)
63  throw cms::Exception("MTDNavigationSchool", "Bad ForwardDetLayer");
64  addEndcapLayer(mep);
65  }
66 
67  // create outward links for all DetLayers
71 
72  // create inverse links
74 }
75 
78  for_each(theBarrelNLC.begin(), theBarrelNLC.end(), delete_layer());
79  for_each(theForwardNLC.begin(), theForwardNLC.end(), delete_layer());
80  for_each(theBackwardNLC.begin(), theBackwardNLC.end(), delete_layer());
81 }
82 
86 
87  vector<BTLNavigableLayer*>::const_iterator ib;
88  vector<ETLNavigableLayer*>::const_iterator ie;
89 
90  for (ib = theBarrelNLC.begin(); ib != theBarrelNLC.end(); ib++) {
91  result.push_back(*ib);
92  }
93 
94  for (ie = theForwardNLC.begin(); ie != theForwardNLC.end(); ie++) {
95  result.push_back(*ie);
96  }
97 
98  for (ie = theBackwardNLC.begin(); ie != theBackwardNLC.end(); ie++) {
99  result.push_back(*ie);
100  }
101 
102  return result;
103 }
104 
107  const BoundCylinder& bc = mbp->specificSurface();
108  float radius = bc.radius();
109  float length = bc.bounds().length() / 2.;
110 
111  float eta_max = calculateEta(radius, length);
112  float eta_min = -eta_max;
113 
115 }
116 
119  const BoundDisk& bd = mep->specificSurface();
120  float outRadius = bd.outerRadius();
121  float inRadius = bd.innerRadius();
122  float thick = bd.bounds().length() / 2.;
123  float z = bd.position().z();
124 
125  if (z > 0.) {
126  float eta_min = calculateEta(outRadius, z - thick);
127  float eta_max = calculateEta(inRadius, z + thick);
129  } else {
130  float eta_max = calculateEta(outRadius, z + thick);
131  float eta_min = calculateEta(inRadius, z - thick);
133  }
134 }
135 
137 float MTDNavigationSchool::calculateEta(const float& r, const float& z) const {
138  if (z > 0)
139  return -log((tan(atan(r / z) / 2.)));
140  return log(-(tan(atan(r / z) / 2.)));
141 }
142 
145  for (MapBI bl = theBarrelLayers.begin(); bl != theBarrelLayers.end(); bl++) {
146  MTDEtaRange range = (*bl).second;
147 
148  // first add next barrel layer
149  MapBI plusOne(bl);
150  plusOne++;
151  MapB outerBarrel;
152  MapB allOuterBarrel;
153  if (plusOne != theBarrelLayers.end()) {
154  outerBarrel.insert(*plusOne);
155  }
156  // add all outer barrel layers
157  for (MapBI iMBI = plusOne; iMBI != theBarrelLayers.end(); iMBI++) {
158  allOuterBarrel.insert(*iMBI);
159  }
160  // then add all compatible backward layers with an eta criteria
161  MapE allOuterBackward;
162  for (MapEI el = theBackwardLayers.begin(); el != theBackwardLayers.end(); el++) {
163  if ((*el).second.isCompatible(range)) {
164  allOuterBackward.insert(*el);
165  }
166  }
167  //add the backward next layer with an eta criteria
168  MapE outerBackward;
169  for (MapEI el = theBackwardLayers.begin(); el != theBackwardLayers.end(); el++) {
170  if ((*el).second.isCompatible(range)) {
171  outerBackward.insert(*el);
172  break;
173  }
174  }
175 
176  // then add all compatible forward layers with an eta criteria
177  MapE allOuterForward;
178  for (MapEI el = theForwardLayers.begin(); el != theForwardLayers.end(); el++) {
179  if ((*el).second.isCompatible(range)) {
180  allOuterForward.insert(*el);
181  }
182  }
183 
184  // then add forward next layer with an eta criteria
185  MapE outerForward;
186  for (MapEI el = theForwardLayers.begin(); el != theForwardLayers.end(); el++) {
187  if ((*el).second.isCompatible(range)) {
188  outerForward.insert(*el);
189  break;
190  }
191  }
192 
193  theBarrelNLC.push_back(new BTLNavigableLayer(
194  (*bl).first, outerBarrel, outerBackward, outerForward, allOuterBarrel, allOuterBackward, allOuterForward));
195  }
196 }
198 void MTDNavigationSchool::linkEndcapLayers(const MapE& layers, vector<ETLNavigableLayer*>& result) {
199  for (MapEI el = layers.begin(); el != layers.end(); el++) {
200  MTDEtaRange range = (*el).second;
201  // first add next endcap layer (if compatible)
202  MapEI plusOne(el);
203  plusOne++;
204  MapE outerLayers;
205  if (plusOne != layers.end() && (*plusOne).second.isCompatible(range)) {
206  outerLayers.insert(*plusOne);
207  if (!range.isInside((*plusOne).second)) {
208  // then look if the next layer has a wider eta range, if so add it
209  MapEI tmpel(plusOne);
210  tmpel++;
211  MTDEtaRange max((*plusOne).second);
212  for (MapEI l = tmpel; l != layers.end(); l++) {
213  MTDEtaRange next = (*l).second;
214  if (next.isCompatible(max) && !range.isInside(next) && !next.isInside(max) &&
215  next.subtract(max).isInside(range)) {
216  max = max.add(next);
217  outerLayers.insert(*l);
218  }
219  }
220  }
221  }
222 
223  MapE allOuterLayers;
224  for (MapEI iMEI = plusOne; iMEI != layers.end(); iMEI++) {
225  if ((*iMEI).second.isCompatible(range))
226  allOuterLayers.insert(*iMEI);
227  }
228 
229  result.push_back(new ETLNavigableLayer((*el).first, outerLayers, allOuterLayers));
230  }
231 }
232 
235  // set outward link
236  // NavigationSetter setter(*this);
237 
239 
240  // find for each layer which are the layers pointing to it
241  typedef map<const DetLayer*, MapB, less<const DetLayer*> > BarrelMapType;
242  typedef map<const DetLayer*, MapE, less<const DetLayer*> > ForwardMapType;
243 
244  // map of all DetLayers which can reach a specific DetLayer
245  BarrelMapType reachedBarrelLayersMap;
246  ForwardMapType reachedForwardLayersMap;
247 
248  // map of all DetLayers which is compatible with a specific DetLayer
249  BarrelMapType compatibleBarrelLayersMap;
250  ForwardMapType compatibleForwardLayersMap;
251 
252  // collect all reacheable layers starting from a barrel layer
253  for (MapBI bli = theBarrelLayers.begin(); bli != theBarrelLayers.end(); bli++) {
254  // barrel
255  BTLNavigableLayer* mbnl = dynamic_cast<BTLNavigableLayer*>(theAllNavigableLayer[((*bli).first)->seqNum()]);
256  MapB reacheableB = mbnl->getOuterBarrelLayers();
257  for (MapBI i = reacheableB.begin(); i != reacheableB.end(); i++) {
258  reachedBarrelLayersMap[(*i).first].insert(*bli);
259  }
260  MapB compatibleB = mbnl->getAllOuterBarrelLayers();
261  for (MapBI i = compatibleB.begin(); i != compatibleB.end(); i++) {
262  compatibleBarrelLayersMap[(*i).first].insert(*bli);
263  }
264  MapE reacheableE = mbnl->getOuterBackwardLayers();
265  for (MapEI i = reacheableE.begin(); i != reacheableE.end(); i++) {
266  reachedBarrelLayersMap[(*i).first].insert(*bli);
267  }
268  reacheableE = mbnl->getOuterForwardLayers();
269  for (MapEI i = reacheableE.begin(); i != reacheableE.end(); i++) {
270  reachedBarrelLayersMap[(*i).first].insert(*bli);
271  }
272  MapE compatibleE = mbnl->getAllOuterBackwardLayers();
273  for (MapEI i = compatibleE.begin(); i != compatibleE.end(); i++) {
274  compatibleBarrelLayersMap[(*i).first].insert(*bli);
275  }
276  compatibleE = mbnl->getAllOuterForwardLayers();
277  for (MapEI i = compatibleE.begin(); i != compatibleE.end(); i++) {
278  compatibleBarrelLayersMap[(*i).first].insert(*bli);
279  }
280  }
281 
282  // collect all reacheable layer starting from a backward layer
283  for (MapEI eli = theBackwardLayers.begin(); eli != theBackwardLayers.end(); eli++) {
284  MapE reacheableE =
285  dynamic_cast<ETLNavigableLayer*>(theAllNavigableLayer[((*eli).first)->seqNum()])->getOuterEndcapLayers();
286  for (MapEI i = reacheableE.begin(); i != reacheableE.end(); i++) {
287  reachedForwardLayersMap[(*i).first].insert(*eli);
288  }
289  // collect all compatible layer starting from a backward layer
290  MapE compatibleE =
291  dynamic_cast<ETLNavigableLayer*>(theAllNavigableLayer[((*eli).first)->seqNum()])->getAllOuterEndcapLayers();
292  for (MapEI i = compatibleE.begin(); i != compatibleE.end(); i++) {
293  compatibleForwardLayersMap[(*i).first].insert(*eli);
294  }
295  }
296 
297  for (MapEI eli = theForwardLayers.begin(); eli != theForwardLayers.end(); eli++) {
298  // collect all reacheable layer starting from a forward layer
299  MapE reacheableE =
300  dynamic_cast<ETLNavigableLayer*>(theAllNavigableLayer[((*eli).first)->seqNum()])->getOuterEndcapLayers();
301  for (MapEI i = reacheableE.begin(); i != reacheableE.end(); i++) {
302  reachedForwardLayersMap[(*i).first].insert(*eli);
303  }
304  // collect all compatible layer starting from a forward layer
305  MapE compatibleE =
306  dynamic_cast<ETLNavigableLayer*>(theAllNavigableLayer[((*eli).first)->seqNum()])->getAllOuterEndcapLayers();
307  for (MapEI i = compatibleE.begin(); i != compatibleE.end(); i++) {
308  compatibleForwardLayersMap[(*i).first].insert(*eli);
309  }
310  }
311 
312  // now set inverse link for barrel layers
313  for (MapBI bli = theBarrelLayers.begin(); bli != theBarrelLayers.end(); bli++) {
314  BTLNavigableLayer* mbnl = dynamic_cast<BTLNavigableLayer*>(theAllNavigableLayer[((*bli).first)->seqNum()]);
315  mbnl->setInwardLinks(reachedBarrelLayersMap[(*bli).first]);
316  mbnl->setInwardCompatibleLinks(compatibleBarrelLayersMap[(*bli).first]);
317  }
318  //BACKWARD
319  for (MapEI eli = theBackwardLayers.begin(); eli != theBackwardLayers.end(); eli++) {
320  ETLNavigableLayer* mfnl = dynamic_cast<ETLNavigableLayer*>(theAllNavigableLayer[((*eli).first)->seqNum()]);
321  // for backward next layers
322  mfnl->setInwardLinks(reachedBarrelLayersMap[(*eli).first], reachedForwardLayersMap[(*eli).first]);
323  // for backward compatible layers
324  mfnl->setInwardCompatibleLinks(compatibleBarrelLayersMap[(*eli).first], compatibleForwardLayersMap[(*eli).first]);
325  }
326  //FORWARD
327  for (MapEI eli = theForwardLayers.begin(); eli != theForwardLayers.end(); eli++) {
328  ETLNavigableLayer* mfnl = dynamic_cast<ETLNavigableLayer*>(theAllNavigableLayer[((*eli).first)->seqNum()]);
329  // and for forward next layers
330  mfnl->setInwardLinks(reachedBarrelLayersMap[(*eli).first], reachedForwardLayersMap[(*eli).first]);
331  // and for forward compatible layers
332  mfnl->setInwardCompatibleLinks(compatibleBarrelLayersMap[(*eli).first], compatibleForwardLayersMap[(*eli).first]);
333  }
334 }
MTDNavigationSchool::addBarrelLayer
void addBarrelLayer(const BarrelDetLayer *)
add barrel layer
Definition: MTDNavigationSchool.cc:106
BTLNavigableLayer::setInwardCompatibleLinks
void setInwardCompatibleLinks(const MapB &)
Definition: BTLNavigableLayer.cc:147
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
ETLNavigableLayer::setInwardLinks
void setInwardLinks(const MapB &, const MapE &)
set inward links
Definition: ETLNavigableLayer.cc:144
BTLNavigableLayer::getOuterBackwardLayers
MapE getOuterBackwardLayers() const
Definition: BTLNavigableLayer.h:116
mps_fire.i
i
Definition: mps_fire.py:355
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
MTDNavigationSchool::MTDNavigationSchool
MTDNavigationSchool(const MTDDetLayerGeometry *, bool enableBTL=true, bool enableETL=true)
Constructor.
Definition: MTDNavigationSchool.cc:34
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
BTLNavigableLayer::getOuterForwardLayers
MapE getOuterForwardLayers() const
Definition: BTLNavigableLayer.h:118
BoundDisk.h
MTDNavigationSchool::theBackwardLayers
MapE theBackwardLayers
+z endcap
Definition: MTDNavigationSchool.h:66
MTDNavigationSchool.h
egammaIdentification.eta_min
eta_min
Definition: egammaIdentification.py:20
MTDNavigationSchool::theBarrelNLC
std::vector< BTLNavigableLayer * > theBarrelNLC
-z endcap
Definition: MTDNavigationSchool.h:68
MTDNavigationSchool::addEndcapLayer
void addEndcapLayer(const ForwardDetLayer *)
add endcap layer (backward and forward)
Definition: MTDNavigationSchool.cc:118
MTDNavigationSchool::createInverseLinks
void createInverseLinks()
establish inward links
Definition: MTDNavigationSchool.cc:234
MapBI
MapB::const_iterator MapBI
Definition: MTDDetLayerMap.h:38
BoundCylinder.h
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
BTLNavigableLayer.h
MTDEtaRange
Definition: MTDEtaRange.h:15
MTDNavigationSchool::theBarrelLayers
MapB theBarrelLayers
Definition: MTDNavigationSchool.h:64
BoundDisk
MTDNavigationSchool::theBackwardNLC
std::vector< ETLNavigableLayer * > theBackwardNLC
Definition: MTDNavigationSchool.h:70
MTDNavigationSchool::linkBarrelLayers
void linkBarrelLayers()
link barrel layers
Definition: MTDNavigationSchool.cc:144
MTDDetLayerMap.h
MTDNavigationSchool::calculateEta
float calculateEta(const float &, const float &) const
calculate pseudorapidity from r and z
Definition: MTDNavigationSchool.cc:137
MTDDetLayerGeometry::allBarrelLayers
const std::vector< const DetLayer * > & allBarrelLayers() const
return all barrel layers
Definition: MTDDetLayerGeometry.cc:62
BTLNavigableLayer
Definition: BTLNavigableLayer.h:29
MTDNavigationSchool::~MTDNavigationSchool
~MTDNavigationSchool() override
Destructor.
Definition: MTDNavigationSchool.cc:77
MapEI
MapE::const_iterator MapEI
Definition: MTDDetLayerMap.h:39
MTDNavigationSchool::linkEndcapLayers
void linkEndcapLayers(const MapE &, std::vector< ETLNavigableLayer * > &)
link endcap layers
Definition: MTDNavigationSchool.cc:198
DDAxes::z
NavigationSchool::theAllNavigableLayer
StateType theAllNavigableLayer
Definition: NavigationSchool.h:60
BTLNavigableLayer::getAllOuterForwardLayers
MapE getAllOuterForwardLayers() const
Definition: BTLNavigableLayer.h:125
NavigationSchool::StateType
std::vector< NavigableLayer * > StateType
Definition: NavigationSchool.h:26
BTLNavigableLayer::getOuterBarrelLayers
MapB getOuterBarrelLayers() const
Definition: BTLNavigableLayer.h:114
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
BTLNavigableLayer::getAllOuterBarrelLayers
MapB getAllOuterBarrelLayers() const
Definition: BTLNavigableLayer.h:121
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
MTDNavigationSchool::delete_layer
Definition: MTDNavigationSchool.h:54
distMuonTCMETValueMapProducer_cff.eta_max
eta_max
Definition: distMuonTCMETValueMapProducer_cff.py:9
MTDNavigationSchool::navigableLayers
StateType navigableLayers() override
return navigable layers, from base class
Definition: MTDNavigationSchool.cc:84
NavigationSchool::theAllDetLayersInSystem
const std::vector< const DetLayer * > * theAllDetLayersInSystem
Definition: NavigationSchool.h:67
BarrelDetLayer.h
cuy.ib
ib
Definition: cuy.py:662
MTDDetLayerGeometry
Definition: MTDDetLayerGeometry.h:19
BarrelDetLayer
Definition: BarrelDetLayer.h:22
ETLNavigableLayer
Definition: ETLNavigableLayer.h:33
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
ETLNavigableLayer::setInwardCompatibleLinks
void setInwardCompatibleLinks(const MapB &, const MapE &)
Definition: ETLNavigableLayer.cc:148
BTLNavigableLayer::getAllOuterBackwardLayers
MapE getAllOuterBackwardLayers() const
Definition: BTLNavigableLayer.h:123
alignCSCRings.r
r
Definition: alignCSCRings.py:93
MTDDetLayerGeometry::allLayers
const std::vector< const DetLayer * > & allLayers() const
return all DetLayers (barrel + endcap), -Z to +Z
Definition: MTDDetLayerGeometry.cc:74
std
Definition: JetResolutionObject.h:76
MTDEtaRange.h
MTDDetLayerGeometry.h
ForwardDetLayer
Definition: ForwardDetLayer.h:22
MapE
std::map< const ForwardDetLayer *, MTDEtaRange, MTDDetLayerComp > MapE
Definition: MTDDetLayerMap.h:37
ForwardDetLayer.h
Exception
Definition: hltDiff.cc:246
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
MTDDetLayerGeometry::allEndcapLayers
const std::vector< const DetLayer * > & allEndcapLayers() const
return all endcap layers
Definition: MTDDetLayerGeometry.cc:64
BoundCylinder
Exception.h
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
MTDNavigationSchool::theForwardLayers
MapE theForwardLayers
barrel
Definition: MTDNavigationSchool.h:65
mps_fire.result
result
Definition: mps_fire.py:303
NavigationSchool::setState
void setState(const StateType &state)
Definition: NavigationSchool.h:47
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
MTDNavigationSchool::theForwardNLC
std::vector< ETLNavigableLayer * > theForwardNLC
Definition: MTDNavigationSchool.h:69
ForwardDetLayer::specificSurface
virtual const BoundDisk & specificSurface() const final
Definition: ForwardDetLayer.h:39
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
BTLNavigableLayer::setInwardLinks
void setInwardLinks(const MapB &)
set inward links
Definition: BTLNavigableLayer.cc:146
ETLNavigableLayer.h