CMS 3D CMS Logo

MuonNavigationPrinter.cc
Go to the documentation of this file.
1 
22 
31 
32 #include <iostream>
33 #include <iomanip>
34 using namespace std;
35 
36 // #define VI_DEBUG
37 
38 #ifdef VI_DEBUG
39 #define PRINT(x) std::cout << x << ' '
40 #else
41 #define PRINT(x) edm::LogInfo(x)
42 #endif
43 
45  MuonNavigationSchool const& sh,
46  bool enableCSC,
47  bool enableRPC,
48  bool enableGEM,
49  bool enableME0)
50  : school(&sh) {
51  PRINT("MuonNavigationPrinter") << "MuonNavigationPrinter::MuonNavigationPrinter" << std::endl;
52  PRINT("MuonNavigationPrinter") << "================================" << std::endl;
53  PRINT("MuonNavigationPrinter") << "BARREL:" << std::endl;
54  vector<const DetLayer*> barrel;
55  if (enableRPC)
56  barrel = muonLayout->allBarrelLayers();
57  else
58  barrel = muonLayout->allDTLayers();
59 
60  PRINT("MuonNavigationPrinter") << "There are " << barrel.size() << " Barrel DetLayers";
61  for (auto i : barrel)
62  printLayer(i);
63  PRINT("MuonNavigationPrinter") << "================================" << std::endl;
64  PRINT("MuonNavigationPrinter") << "BACKWARD:" << std::endl;
65 
66  vector<const DetLayer*> backward;
67 
68  if (enableCSC & enableGEM & enableRPC & enableME0)
69  backward = muonLayout->allBackwardLayers();
70  else if (enableCSC & enableGEM & !enableRPC & !enableME0)
71  backward = muonLayout->allCscGemBackwardLayers(); // CSC + GEM
72  else if (!enableCSC & enableGEM & !enableRPC & !enableME0)
73  backward = muonLayout->backwardGEMLayers(); //GEM only
74  else if (enableCSC & !enableGEM & !enableRPC & !enableME0)
75  backward = muonLayout->backwardCSCLayers(); //CSC only
76  else if (enableCSC & !enableGEM & !enableRPC & enableME0)
77  backward = muonLayout->allCscME0BackwardLayers(); //CSC + ME0
78  else if (!enableCSC & !enableGEM & !enableRPC & enableME0)
79  backward = muonLayout->backwardME0Layers(); //ME0 only
80  else
81  backward = muonLayout->allBackwardLayers();
82 
83  PRINT("MuonNavigationPrinter") << "There are " << backward.size() << " Backward DetLayers";
84  for (auto i : backward)
85  printLayer(i);
86  PRINT("MuonNavigationPrinter") << "==============================" << std::endl;
87  PRINT("MuonNavigationPrinter") << "FORWARD:" << std::endl;
88  vector<const DetLayer*> forward;
89 
90  if (enableCSC & enableGEM & enableRPC & enableME0)
91  forward = muonLayout->allForwardLayers();
92  else if (enableCSC & enableGEM & !enableRPC & !enableME0)
93  forward = muonLayout->allCscGemForwardLayers(); // CSC + GEM
94  else if (!enableCSC & enableGEM & !enableRPC & !enableME0)
95  forward = muonLayout->forwardGEMLayers(); //GEM only
96  else if (enableCSC & !enableGEM & !enableRPC & !enableME0)
97  forward = muonLayout->forwardCSCLayers(); //CSC only
98  else if (enableCSC & !enableGEM & !enableRPC & enableME0)
99  forward = muonLayout->allCscME0ForwardLayers(); //CSC + ME0
100  else if (!enableCSC & !enableGEM & !enableRPC & enableME0)
101  forward = muonLayout->forwardME0Layers(); //ME0 only
102  else
103  forward = muonLayout->allForwardLayers();
104 
105  PRINT("MuonNavigationPrinter") << "There are " << forward.size() << " Forward DetLayers" << std::endl;
106  for (auto i : forward)
107  printLayer(i);
108 }
109 
111  MuonNavigationSchool const& sh,
113  : school(&sh) {
114  PRINT("MuonNavigationPrinter") << "MuonNavigationPrinter::MuonNavigationPrinter" << std::endl;
115  // vector<BarrelDetLayer*>::const_iterator tkiter;
116  // vector<ForwardDetLayer*>::const_iterator tkfiter;
117  PRINT("MuonNavigationPrinter") << "================================" << std::endl;
118  PRINT("MuonNavigationPrinter") << "BARREL:" << std::endl;
119  const vector<const BarrelDetLayer*>& tkbarrel = tracker->barrelLayers();
120  PRINT("MuonNavigationPrinter") << "There are " << tkbarrel.size() << " Tk Barrel DetLayers" << std::endl;
121  // for ( tkiter = tkbarrel.begin(); tkiter != tkbarrel.end(); tkiter++ ) printLayer(*tkiter);
122  vector<const DetLayer*> barrel = muonLayout->allBarrelLayers();
123  PRINT("MuonNavigationPrinter") << "There are " << barrel.size() << " Mu Barrel DetLayers";
124  for (auto i : barrel)
125  printLayer(i);
126  PRINT("MuonNavigationPrinter") << "================================" << std::endl;
127  PRINT("MuonNavigationPrinter") << "BACKWARD:" << std::endl;
128  const vector<const ForwardDetLayer*>& tkbackward = tracker->negForwardLayers();
129  PRINT("MuonNavigationPrinter") << "There are " << tkbackward.size() << " Tk Backward DetLayers" << std::endl;
131  vector<const DetLayer*> backward = muonLayout->allBackwardLayers();
132  PRINT("MuonNavigationPrinter") << "There are " << backward.size() << " Mu Backward DetLayers << std::endl";
133  for (auto i : backward)
134  printLayer(i);
135  PRINT("MuonNavigationPrinter") << "==============================" << std::endl;
136  PRINT("MuonNavigationPrinter") << "FORWARD:" << std::endl;
137  const vector<const ForwardDetLayer*>& tkforward = tracker->posForwardLayers();
138  PRINT("MuonNavigationPrinter") << "There are " << tkforward.size() << " Tk Forward DetLayers" << std::endl;
139  // for ( tkfiter = tkforward.begin(); tkfiter != tkforward.end(); tkfiter++ ) printLayer(*tkfiter);
140 
141  vector<const DetLayer*> forward = muonLayout->allForwardLayers();
142  PRINT("MuonNavigationPrinter") << "There are " << forward.size() << " Mu Forward DetLayers";
143  for (auto i : forward)
144  printLayer(i);
145 }
146 
149  vector<const DetLayer*> nextLayers = school->nextLayers(*layer, insideOut);
150  vector<const DetLayer*> compatibleLayers = school->compatibleLayers(*layer, insideOut);
151  if (const BarrelDetLayer* bdl = dynamic_cast<const BarrelDetLayer*>(layer)) {
152  PRINT("MuonNavigationPrinter") << layer->location() << " " << layer->subDetector()
153  << " layer at R: " << setiosflags(ios::showpoint | ios::fixed) << setw(8)
154  << setprecision(2) << bdl->specificSurface().radius() << " length: " << setw(6)
155  << setprecision(2) << layer->surface().bounds().length() << std::endl;
156 
157  } else if (const ForwardDetLayer* fdl = dynamic_cast<const ForwardDetLayer*>(layer)) {
158  PRINT("MuonNavigationPrinter") << endl
159  << layer->location() << " " << layer->subDetector()
160  << "layer at z: " << setiosflags(ios::showpoint | ios::fixed) << setw(8)
161  << setprecision(2) << layer->surface().position().z() << " inner r: " << setw(6)
162  << setprecision(2) << fdl->specificSurface().innerRadius()
163  << " outer r: " << setw(6) << setprecision(2)
164  << fdl->specificSurface().outerRadius() << std::endl;
165  }
166  PRINT("MuonNavigationPrinter") << " has " << nextLayers.size()
167  << " next layers in the direction inside-out: " << std::endl;
168  printLayers(nextLayers);
169 
170  nextLayers.clear();
171  nextLayers = school->nextLayers(*layer, outsideIn);
172 
173  PRINT("MuonNavigationPrinter") << " has " << nextLayers.size()
174  << " next layers in the direction outside-in: " << std::endl;
175  printLayers(nextLayers);
176 
177  PRINT("MuonNavigationPrinter") << " has " << compatibleLayers.size()
178  << " compatible layers in the direction inside-out:: " << std::endl;
179  printLayers(compatibleLayers);
180  compatibleLayers.clear();
181  compatibleLayers = school->compatibleLayers(*layer, outsideIn);
182 
183  PRINT("MuonNavigationPrinter") << " has " << compatibleLayers.size()
184  << " compatible layers in the direction outside-in: " << std::endl;
185  printLayers(compatibleLayers);
186 }
187 
189 void MuonNavigationPrinter::printLayers(const vector<const DetLayer*>& nextLayers) const {
190  for (vector<const DetLayer*>::const_iterator inext = nextLayers.begin(); inext != nextLayers.end(); inext++) {
191  PRINT("MuonNavigationPrinter") << " --> " << std::endl;
192  if ((*inext)->location() == GeomDetEnumerators::barrel) {
193  const BarrelDetLayer* l = dynamic_cast<const BarrelDetLayer*>(&(**inext));
194  PRINT("MuonNavigationPrinter") << (*inext)->location() << " " << (*inext)->subDetector()
195  << " layer at R: " << setiosflags(ios::showpoint | ios::fixed) << setw(8)
196  << setprecision(2) << l->specificSurface().radius() << " " << std::endl;
197  } else {
198  const ForwardDetLayer* l = dynamic_cast<const ForwardDetLayer*>(&(**inext));
199  PRINT("MuonNavigationPrinter") << (*inext)->location() << " " << (*inext)->subDetector()
200  << " layer at z: " << setiosflags(ios::showpoint | ios::fixed) << setw(8)
201  << setprecision(2) << l->surface().position().z() << " " << std::endl;
202  }
203  PRINT("MuonNavigationPrinter") << setiosflags(ios::showpoint | ios::fixed) << setprecision(1) << setw(6)
204  << (*inext)->surface().bounds().length() << ", " << setw(6)
205  << (*inext)->surface().bounds().width() << ", " << setw(4)
206  << (*inext)->surface().bounds().thickness() << " : "
207  << (*inext)->surface().position() << std::endl;
208  }
209 }
210 
212 
213 // /// determine whether the layer is forward or backward
214 // string MuonNavigationPrinter::layerPart(const DetLayer* layer) const {
215 
216 // string result = "unknown";
217 
218 // if ( layer->part() == barrel ) return "barrel";
219 // if ( layer->part() == forward && layer->surface().position().z() < 0 ) {
220 // result = "backward";
221 // }
222 // if ( layer->part() == forward && layer->surface().position().z() >= 0 ) {
223 // result = "forward";
224 // }
225 
226 // return result;
227 
228 // }
229 
230 // /// determine the module (pixel, sililcon, msgc, dt, csc, rpc)
231 // string MuonNavigationPrinter::layerModule(const DetLayer* layer) const {
232 
233 // string result = "unknown";
234 
235 // GeomDetEnumerators::SubDetector det = layer->subDetector();
236 
237 // if ( det == Pixel ) return "Pixel";
238 // if ( det == TIB || det == TOB
239 // || det == TID || det == TEC ) return "silicon";
240 // if ( det == DT ) return "DT";
241 // if ( det == CSC ) return "CSC";
242 // if ( det == RPC ) return "RPC";
243 
244 // return result;
245 
246 // }
const std::vector< const DetLayer * > & allBackwardLayers() const
return all backward (-Z) layers (CSC+RPC+GEM+ME0), inside-out
const std::vector< const DetLayer * > & forwardCSCLayers() const
return the forward (+Z) CSC DetLayers, inside-out
const std::vector< const DetLayer * > & allCscGemForwardLayers() const
return all endcap DetLayers (CSC+GEM), -Z to +Z
MuonNavigationPrinter(const MuonDetLayerGeometry *, MuonNavigationSchool const &, bool enableRPC=true, bool enableCSC=true, bool enableGEM=false, bool enableME0=false)
const std::vector< const DetLayer * > & backwardME0Layers() const
return the backward (-Z) ME0 DetLayers, inside-out
const std::vector< const DetLayer * > & allForwardLayers() const
return all forward (+Z) layers (CSC+RPC+GEM+ME0), inside-out
const std::vector< const DetLayer * > & allDTLayers() const
return the DT DetLayers (barrel), inside-out
const std::vector< const DetLayer * > & forwardME0Layers() const
return the forward (+Z) ME0 DetLayers, inside-out
MuonNavigationSchool const * school
return detector part (barrel, forward, backward)
#define PRINT(x)
std::vector< const DetLayer * > compatibleLayers(const DetLayer &detLayer, Args &&... args) const
Returns all layers compatible.
const std::vector< const DetLayer * > & forwardGEMLayers() const
return the forward (+Z) GEM DetLayers, inside-out
const std::vector< const DetLayer * > & allCscGemBackwardLayers() const
return all endcap DetLayers (CSC+GEM), -Z to +Z
void printLayers(const std::vector< const DetLayer *> &) const
print next layers
std::vector< const DetLayer * > nextLayers(const DetLayer &detLayer, Args &&... args) const
void printLayer(const DetLayer *) const
print layer
const std::vector< const DetLayer * > & backwardGEMLayers() const
return the backward (-Z) GEM DetLayers, inside-out
const std::vector< const DetLayer * > & backwardCSCLayers() const
return the backward (-Z) CSC DetLayers, inside-out
const std::vector< const DetLayer * > & allCscME0BackwardLayers() const
return all endcap DetLayers (CSC+ME0), -Z to +Z
const std::vector< const DetLayer * > & allBarrelLayers() const
return all barrel DetLayers (DT+RPC), inside-out
const std::vector< const DetLayer * > & allCscME0ForwardLayers() const
return all endcap DetLayers (CSC+ME0), -Z to +Z