CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
44 MuonNavigationPrinter::MuonNavigationPrinter(const MuonDetLayerGeometry * muonLayout, MuonNavigationSchool const & sh, bool enableCSC, bool enableRPC, bool enableGEM, bool enableME0) :
45  school(&sh) {
46 
47  PRINT("MuonNavigationPrinter")<< "MuonNavigationPrinter::MuonNavigationPrinter" << std::endl;
48  PRINT("MuonNavigationPrinter")<<"================================" << std::endl;
49  PRINT("MuonNavigationPrinter")<< "BARREL:" << std::endl;
50  vector<const DetLayer*> barrel;
51  if ( enableRPC ) barrel = muonLayout->allBarrelLayers();
52  else barrel = muonLayout->allDTLayers();
53 
54  PRINT("MuonNavigationPrinter")<<"There are "<<barrel.size()<<" Barrel DetLayers";
55  for (auto i: barrel ) printLayer(i);
56  PRINT("MuonNavigationPrinter")<<"================================" << std::endl;
57  PRINT("MuonNavigationPrinter") << "BACKWARD:" << std::endl;
58 
59  vector<const DetLayer*> backward;
60 
61  if ( enableCSC & enableGEM & enableRPC & enableME0) backward = muonLayout->allBackwardLayers();
62  else if ( enableCSC & enableGEM & !enableRPC & !enableME0) backward = muonLayout->allCscGemBackwardLayers(); // CSC + GEM
63  else if ( !enableCSC & enableGEM & !enableRPC & !enableME0 ) backward = muonLayout->backwardGEMLayers(); //GEM only
64  else if ( enableCSC & !enableGEM & !enableRPC & !enableME0 ) backward = muonLayout->backwardCSCLayers(); //CSC only
65  else if ( enableCSC & !enableGEM & !enableRPC & enableME0) backward = muonLayout->allCscME0BackwardLayers(); //CSC + ME0
66  else if ( !enableCSC & !enableGEM & !enableRPC & enableME0) backward = muonLayout->backwardME0Layers(); //ME0 only
67  else backward = muonLayout->allBackwardLayers();
68 
69  PRINT("MuonNavigationPrinter")<<"There are "<<backward.size()<<" Backward DetLayers";
70  for (auto i : backward ) printLayer(i);
71  PRINT("MuonNavigationPrinter") << "==============================" << std::endl;
72  PRINT("MuonNavigationPrinter") << "FORWARD:" << std::endl;
73  vector<const DetLayer*> forward;
74 
75  if ( enableCSC & enableGEM & enableRPC & enableME0 ) forward = muonLayout->allForwardLayers();
76  else if ( enableCSC & enableGEM & !enableRPC & !enableME0) forward = muonLayout->allCscGemForwardLayers(); // CSC + GEM
77  else if ( !enableCSC & enableGEM & !enableRPC & !enableME0 ) forward = muonLayout->forwardGEMLayers(); //GEM only
78  else if ( enableCSC & !enableGEM & !enableRPC & !enableME0 ) forward = muonLayout->forwardCSCLayers(); //CSC only
79  else if ( enableCSC & !enableGEM & !enableRPC & enableME0) forward = muonLayout->allCscME0ForwardLayers(); //CSC + ME0
80  else if ( !enableCSC & !enableGEM & !enableRPC & enableME0) forward = muonLayout->forwardME0Layers(); //ME0 only
81  else forward = muonLayout->allForwardLayers();
82 
83  PRINT("MuonNavigationPrinter")<<"There are "<<forward.size()<<" Forward DetLayers" << std::endl;
84  for (auto i : forward ) printLayer(i);
85 
86 }
87 
89  school(&sh){
90 
91  PRINT("MuonNavigationPrinter")<< "MuonNavigationPrinter::MuonNavigationPrinter" << std::endl ;
92 // vector<BarrelDetLayer*>::const_iterator tkiter;
93 // vector<ForwardDetLayer*>::const_iterator tkfiter;
94  PRINT("MuonNavigationPrinter")<<"================================" << std::endl;
95  PRINT("MuonNavigationPrinter")<< "BARREL:" << std::endl;
96  vector<const BarrelDetLayer*> tkbarrel = tracker->barrelLayers();
97  PRINT("MuonNavigationPrinter")<<"There are "<<tkbarrel.size()<<" Tk Barrel DetLayers" << std::endl;
98 // for ( tkiter = tkbarrel.begin(); tkiter != tkbarrel.end(); tkiter++ ) printLayer(*tkiter);
99  vector<const DetLayer*> barrel = muonLayout->allBarrelLayers();
100  PRINT("MuonNavigationPrinter")<<"There are "<<barrel.size()<<" Mu Barrel DetLayers";
101  for ( auto i : barrel ) printLayer(i);
102  PRINT("MuonNavigationPrinter")<<"================================" << std::endl;
103  PRINT("MuonNavigationPrinter") << "BACKWARD:" << std::endl;
104  vector<const ForwardDetLayer*> tkbackward = tracker->negForwardLayers();
105  PRINT("MuonNavigationPrinter")<<"There are "<<tkbackward.size()<<" Tk Backward DetLayers" << std::endl;
107  vector<const DetLayer*> backward = muonLayout->allBackwardLayers();
108  PRINT("MuonNavigationPrinter")<<"There are "<<backward.size()<<" Mu Backward DetLayers << std::endl";
109  for (auto i : backward ) printLayer(i);
110  PRINT("MuonNavigationPrinter") << "==============================" << std::endl;
111  PRINT("MuonNavigationPrinter") << "FORWARD:" << std::endl;
112  vector<const ForwardDetLayer*> tkforward = tracker->posForwardLayers();
113  PRINT("MuonNavigationPrinter")<<"There are "<<tkforward.size()<<" Tk Forward DetLayers" << std::endl;
114 // for ( tkfiter = tkforward.begin(); tkfiter != tkforward.end(); tkfiter++ ) printLayer(*tkfiter);
115 
116  vector<const DetLayer*> forward = muonLayout->allForwardLayers();
117  PRINT("MuonNavigationPrinter")<<"There are "<<forward.size()<<" Mu Forward DetLayers";
118  for ( auto i : forward ) printLayer(i);
119 
120 }
121 
123 void MuonNavigationPrinter::printLayer(const DetLayer* layer) const {
124  vector<const DetLayer*> nextLayers = school->nextLayers(*layer,insideOut);
125  vector<const DetLayer*> compatibleLayers = school->compatibleLayers(*layer,insideOut);
126  if (const BarrelDetLayer* bdl = dynamic_cast<const BarrelDetLayer*>(layer)) {
127  PRINT("MuonNavigationPrinter")
128  << layer->location() << " " << layer->subDetector() << " layer at R: "
129  << setiosflags(ios::showpoint | ios::fixed)
130  << setw(8) << setprecision(2)
131  << bdl->specificSurface().radius() << " length: "
132  << setw(6) << setprecision(2)
133  << layer->surface().bounds().length() << std::endl;
134 
135  }
136  else if (const ForwardDetLayer* fdl = dynamic_cast<const ForwardDetLayer*>(layer)) {
137  PRINT("MuonNavigationPrinter") << endl
138  << layer->location() << " " << layer->subDetector() << "layer at z: "
139  << setiosflags(ios::showpoint | ios::fixed)
140  << setw(8) << setprecision(2)
141  << layer->surface().position().z() << " inner r: "
142  << setw(6) << setprecision(2)
143  << fdl->specificSurface().innerRadius() << " outer r: "
144  << setw(6) << setprecision(2)
145  << fdl->specificSurface().outerRadius() << std::endl;
146  }
147  PRINT("MuonNavigationPrinter") << " has " << nextLayers.size() << " next layers in the direction inside-out: " << std::endl;
148  printLayers(nextLayers);
149 
150  nextLayers.clear();
151  nextLayers = school->nextLayers(*layer,outsideIn);
152 
153  PRINT("MuonNavigationPrinter") << " has " << nextLayers.size() << " next layers in the direction outside-in: " << std::endl;
154  printLayers(nextLayers);
155 
156  PRINT("MuonNavigationPrinter") << " has " << compatibleLayers.size() << " compatible layers in the direction inside-out:: " << std::endl;
157  printLayers(compatibleLayers);
158  compatibleLayers.clear();
159  compatibleLayers = school->compatibleLayers(*layer,outsideIn);
160 
161  PRINT("MuonNavigationPrinter") << " has " << compatibleLayers.size() << " compatible layers in the direction outside-in: " << std::endl;
162  printLayers(compatibleLayers);
163 
164 }
165 
167 void MuonNavigationPrinter::printLayers(const vector<const DetLayer*>& nextLayers) const {
168 
169  for ( vector<const DetLayer*>::const_iterator inext = nextLayers.begin();
170  inext != nextLayers.end(); inext++ ) {
171 
172  PRINT("MuonNavigationPrinter") << " --> " << std::endl;
173  if ( (*inext)->location() == GeomDetEnumerators::barrel ) {
174  const BarrelDetLayer* l = dynamic_cast<const BarrelDetLayer*>(&(**inext));
175  PRINT("MuonNavigationPrinter") << (*inext)->location() << " "
176  << (*inext)->subDetector()
177  << " layer at R: "
178  << setiosflags(ios::showpoint | ios::fixed)
179  << setw(8) << setprecision(2)
180  << l->specificSurface().radius() << " " << std::endl;
181  }
182  else {
183  const ForwardDetLayer* l = dynamic_cast<const ForwardDetLayer*>(&(**inext));
184  PRINT("MuonNavigationPrinter") << (*inext)->location() << " "
185  << (*inext)->subDetector()
186  << " layer at z: "
187  << setiosflags(ios::showpoint | ios::fixed)
188  << setw(8) << setprecision(2)
189  << l->surface().position().z() << " " << std::endl;
190  }
191  PRINT("MuonNavigationPrinter") << setiosflags(ios::showpoint | ios::fixed)
192  << setprecision(1)
193  << setw(6) << (*inext)->surface().bounds().length() << ", "
194  << setw(6) << (*inext)->surface().bounds().width() << ", "
195  << setw(4) <<(*inext)->surface().bounds().thickness() << " : "
196  << (*inext)->surface().position() << std::endl;
197  }
198 
199 }
200 
201 
203 
204 // /// determine whether the layer is forward or backward
205 // string MuonNavigationPrinter::layerPart(const DetLayer* layer) const {
206 
207 // string result = "unknown";
208 
209 // if ( layer->part() == barrel ) return "barrel";
210 // if ( layer->part() == forward && layer->surface().position().z() < 0 ) {
211 // result = "backward";
212 // }
213 // if ( layer->part() == forward && layer->surface().position().z() >= 0 ) {
214 // result = "forward";
215 // }
216 
217 // return result;
218 
219 // }
220 
221 // /// determine the module (pixel, sililcon, msgc, dt, csc, rpc)
222 // string MuonNavigationPrinter::layerModule(const DetLayer* layer) const {
223 
224 // string result = "unknown";
225 
226 // GeomDetEnumerators::SubDetector det = layer->subDetector();
227 
228 // if ( det == Pixel ) return "Pixel";
229 // if ( det == TIB || det == TOB
230 // || det == TID || det == TEC ) return "silicon";
231 // if ( det == DT ) return "DT";
232 // if ( det == CSC ) return "CSC";
233 // if ( det == RPC ) return "RPC";
234 
235 // return result;
236 
237 // }
238 
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
int i
Definition: DBlmapReader.cc:9
const std::vector< const DetLayer * > & backwardGEMLayers() const
return the backward (-Z) GEM DetLayers, inside-out
virtual float length() const =0
MuonNavigationPrinter(const MuonDetLayerGeometry *, MuonNavigationSchool const &, bool enableRPC=true, bool enableCSC=true, bool enableGEM=false, bool enableME0=false)
const std::vector< const DetLayer * > & allCscGemBackwardLayers() const
return all endcap DetLayers (CSC+GEM), -Z to +Z
std::vector< ForwardDetLayer const * > const & posForwardLayers() const
virtual Location location() const =0
Which part of the detector (barrel, endcap)
virtual SubDetector subDetector() const =0
The type of detector (PixelBarrel, PixelEndcap, TIB, TOB, TID, TEC, CSC, DT, RPCBarrel, RPCEndcap)
const Bounds & bounds() const
Definition: Surface.h:120
void printLayers(const std::vector< const DetLayer * > &) const
print next layers
MuonNavigationSchool const * school
return detector part (barrel, forward, backward)
const std::vector< const DetLayer * > & forwardME0Layers() const
return the forward (+Z) ME0 DetLayers, inside-out
#define PRINT(x)
const std::vector< const DetLayer * > & allCscME0ForwardLayers() const
return all endcap DetLayers (CSC+ME0), -Z to +Z
const std::vector< const DetLayer * > & allForwardLayers() const
return all forward (+Z) layers (CSC+RPC+GEM+ME0), inside-out
T z() const
Definition: PV3DBase.h:64
std::vector< const DetLayer * > compatibleLayers(const DetLayer &detLayer, Args &&...args) const
Returns all layers compatible.
std::vector< ForwardDetLayer const * > const & negForwardLayers() const
const std::vector< const DetLayer * > & allBarrelLayers() const
return all barrel DetLayers (DT+RPC), inside-out
const std::vector< const DetLayer * > & allDTLayers() const
return the DT DetLayers (barrel), inside-out
const std::vector< const DetLayer * > & backwardME0Layers() const
return the backward (-Z) ME0 DetLayers, inside-out
const std::vector< const DetLayer * > & forwardCSCLayers() const
return the forward (+Z) CSC DetLayers, inside-out
std::vector< const DetLayer * > nextLayers(const DetLayer &detLayer, Args &&...args) const
NavigationDirection.
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
virtual const BoundSurface & surface() const final
The surface of the GeometricSearchDet.
const std::vector< const DetLayer * > & allCscME0BackwardLayers() const
return all endcap DetLayers (CSC+ME0), -Z to +Z
const std::vector< const DetLayer * > & allBackwardLayers() const
return all backward (-Z) layers (CSC+RPC+GEM+ME0), inside-out
const std::vector< const DetLayer * > & forwardGEMLayers() const
return the forward (+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 * > & allCscGemForwardLayers() const
return all endcap DetLayers (CSC+GEM), -Z to +Z
const PositionType & position() const
void printLayer(const DetLayer *) const
print layer
std::vector< BarrelDetLayer const * > const & barrelLayers() const