CMS 3D CMS Logo

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