CMS 3D CMS Logo

MTDNavigationPrinter.cc
Go to the documentation of this file.
1 
12 
21 
22 #include <iostream>
23 #include <iomanip>
24 using namespace std;
25 
26 // #define VI_DEBUG
27 
28 #ifdef VI_DEBUG
29 #define PRINT(x) std::cout << x << ' '
30 #else
31 #define PRINT(x) edm::LogInfo(x)
32 #endif
33 
34 MTDNavigationPrinter::MTDNavigationPrinter(const MTDDetLayerGeometry * mtdLayout, MTDNavigationSchool const & sh, bool enableBTL, bool enableETL) :
35  school(&sh) {
36 
37  PRINT("MTDNavigationPrinter")<< "MTDNavigationPrinter::MTDNavigationPrinter" << std::endl;
38  PRINT("MTDNavigationPrinter")<<"================================" << std::endl;
39  PRINT("MTDNavigationPrinter")<< "BARREL:" << std::endl;
40  vector<const DetLayer*> barrel;
41  if ( enableBTL ) barrel = mtdLayout->allBarrelLayers();
42  else barrel = mtdLayout->allBarrelLayers();
43 
44  PRINT("MTDNavigationPrinter")<<"There are "<<barrel.size()<<" Barrel DetLayers";
45  for (auto i: barrel ) printLayer(i);
46  PRINT("MTDNavigationPrinter")<<"================================" << std::endl;
47  PRINT("MTDNavigationPrinter") << "BACKWARD:" << std::endl;
48 
49  vector<const DetLayer*> backward;
50 
51  if ( enableETL ) backward = mtdLayout->allBackwardLayers();
52  else backward = mtdLayout->allBackwardLayers();
53 
54  PRINT("MTDNavigationPrinter")<<"There are "<<backward.size()<<" Backward DetLayers";
55  for (auto i : backward ) printLayer(i);
56  PRINT("MTDNavigationPrinter") << "==============================" << std::endl;
57  PRINT("MTDNavigationPrinter") << "FORWARD:" << std::endl;
58  vector<const DetLayer*> forward;
59 
60  if ( enableETL ) forward = mtdLayout->allForwardLayers();
61  else forward = mtdLayout->allForwardLayers();
62 
63  PRINT("MTDNavigationPrinter")<<"There are "<<forward.size()<<" Forward DetLayers" << std::endl;
64  for (auto i : forward ) printLayer(i);
65 
66 }
67 
69  school(&sh){
70 
71  PRINT("MTDNavigationPrinter")<< "MTDNavigationPrinter::MTDNavigationPrinter" << std::endl ;
72 // vector<BarrelDetLayer*>::const_iterator tkiter;
73 // vector<ForwardDetLayer*>::const_iterator tkfiter;
74  PRINT("MTDNavigationPrinter")<<"================================" << std::endl;
75  PRINT("MTDNavigationPrinter")<< "BARREL:" << std::endl;
76  const vector<const BarrelDetLayer*>& tkbarrel = tracker->barrelLayers();
77  PRINT("MTDNavigationPrinter")<<"There are "<<tkbarrel.size()<<" Tk Barrel DetLayers" << std::endl;
78 // for ( tkiter = tkbarrel.begin(); tkiter != tkbarrel.end(); tkiter++ ) printLayer(*tkiter);
79  vector<const DetLayer*> barrel = mtdLayout->allBarrelLayers();
80  PRINT("MTDNavigationPrinter")<<"There are "<<barrel.size()<<" Mu Barrel DetLayers";
81  for ( auto i : barrel ) printLayer(i);
82  PRINT("MTDNavigationPrinter")<<"================================" << std::endl;
83  PRINT("MTDNavigationPrinter") << "BACKWARD:" << std::endl;
84  const vector<const ForwardDetLayer*>& tkbackward = tracker->negForwardLayers();
85  PRINT("MTDNavigationPrinter")<<"There are "<<tkbackward.size()<<" Tk Backward DetLayers" << std::endl;
87  vector<const DetLayer*> backward = mtdLayout->allBackwardLayers();
88  PRINT("MTDNavigationPrinter")<<"There are "<<backward.size()<<" Mu Backward DetLayers << std::endl";
89  for (auto i : backward ) printLayer(i);
90  PRINT("MTDNavigationPrinter") << "==============================" << std::endl;
91  PRINT("MTDNavigationPrinter") << "FORWARD:" << std::endl;
92  const vector<const ForwardDetLayer*>& tkforward = tracker->posForwardLayers();
93  PRINT("MTDNavigationPrinter")<<"There are "<<tkforward.size()<<" Tk Forward DetLayers" << std::endl;
94 // for ( tkfiter = tkforward.begin(); tkfiter != tkforward.end(); tkfiter++ ) printLayer(*tkfiter);
95 
96  vector<const DetLayer*> forward = mtdLayout->allForwardLayers();
97  PRINT("MTDNavigationPrinter")<<"There are "<<forward.size()<<" Mu Forward DetLayers";
98  for ( auto i : forward ) printLayer(i);
99 
100 }
101 
103 void MTDNavigationPrinter::printLayer(const DetLayer* layer) const {
104  vector<const DetLayer*> nextLayers = school->nextLayers(*layer,insideOut);
105  vector<const DetLayer*> compatibleLayers = school->compatibleLayers(*layer,insideOut);
106  if (const BarrelDetLayer* bdl = dynamic_cast<const BarrelDetLayer*>(layer)) {
107  PRINT("MTDNavigationPrinter")
108  << layer->location() << " " << layer->subDetector() << " layer at R: "
109  << setiosflags(ios::showpoint | ios::fixed)
110  << setw(8) << setprecision(2)
111  << bdl->specificSurface().radius() << " length: "
112  << setw(6) << setprecision(2)
113  << layer->surface().bounds().length() << std::endl;
114 
115  }
116  else if (const ForwardDetLayer* fdl = dynamic_cast<const ForwardDetLayer*>(layer)) {
117  PRINT("MTDNavigationPrinter") << endl
118  << layer->location() << " " << layer->subDetector() << "layer at z: "
119  << setiosflags(ios::showpoint | ios::fixed)
120  << setw(8) << setprecision(2)
121  << layer->surface().position().z() << " inner r: "
122  << setw(6) << setprecision(2)
123  << fdl->specificSurface().innerRadius() << " outer r: "
124  << setw(6) << setprecision(2)
125  << fdl->specificSurface().outerRadius() << std::endl;
126  }
127  PRINT("MTDNavigationPrinter") << " has " << nextLayers.size() << " next layers in the direction inside-out: " << std::endl;
128  printLayers(nextLayers);
129 
130  nextLayers.clear();
131  nextLayers = school->nextLayers(*layer,outsideIn);
132 
133  PRINT("MTDNavigationPrinter") << " has " << nextLayers.size() << " next layers in the direction outside-in: " << std::endl;
134  printLayers(nextLayers);
135 
136  PRINT("MTDNavigationPrinter") << " has " << compatibleLayers.size() << " compatible layers in the direction inside-out:: " << std::endl;
137  printLayers(compatibleLayers);
138  compatibleLayers.clear();
139  compatibleLayers = school->compatibleLayers(*layer,outsideIn);
140 
141  PRINT("MTDNavigationPrinter") << " has " << compatibleLayers.size() << " compatible layers in the direction outside-in: " << std::endl;
142  printLayers(compatibleLayers);
143 
144 }
145 
147 void MTDNavigationPrinter::printLayers(const vector<const DetLayer*>& nextLayers) const {
148 
149  for ( vector<const DetLayer*>::const_iterator inext = nextLayers.begin();
150  inext != nextLayers.end(); inext++ ) {
151 
152  PRINT("MTDNavigationPrinter") << " --> " << std::endl;
153  if ( (*inext)->location() == GeomDetEnumerators::barrel ) {
154  const BarrelDetLayer* l = dynamic_cast<const BarrelDetLayer*>(&(**inext));
155  PRINT("MTDNavigationPrinter") << (*inext)->location() << " "
156  << (*inext)->subDetector()
157  << " layer at R: "
158  << setiosflags(ios::showpoint | ios::fixed)
159  << setw(8) << setprecision(2)
160  << l->specificSurface().radius() << " " << std::endl;
161  }
162  else {
163  const ForwardDetLayer* l = dynamic_cast<const ForwardDetLayer*>(&(**inext));
164  PRINT("MTDNavigationPrinter") << (*inext)->location() << " "
165  << (*inext)->subDetector()
166  << " layer at z: "
167  << setiosflags(ios::showpoint | ios::fixed)
168  << setw(8) << setprecision(2)
169  << l->surface().position().z() << " " << std::endl;
170  }
171  PRINT("MTDNavigationPrinter") << setiosflags(ios::showpoint | ios::fixed)
172  << setprecision(1)
173  << setw(6) << (*inext)->surface().bounds().length() << ", "
174  << setw(6) << (*inext)->surface().bounds().width() << ", "
175  << setw(4) <<(*inext)->surface().bounds().thickness() << " : "
176  << (*inext)->surface().position() << std::endl;
177  }
178 
179 }
virtual float length() const =0
MTDNavigationSchool const * school
return detector part (barrel, forward, backward)
std::vector< ForwardDetLayer const * > const & posForwardLayers() const
#define PRINT(x)
virtual SubDetector subDetector() const =0
The type of detector (PixelBarrel, PixelEndcap, TIB, TOB, TID, TEC, CSC, DT, RPCBarrel, RPCEndcap)
virtual Location location() const =0
Which part of the detector (barrel, endcap)
const Bounds & bounds() const
Definition: Surface.h:120
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
const std::vector< const DetLayer * > & allBackwardLayers() const
return all endcap layers
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
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
void printLayers(const std::vector< const DetLayer * > &) const
print next layers
std::vector< const DetLayer * > nextLayers(const DetLayer &detLayer, Args &&...args) const
NavigationDirection.
void printLayer(const DetLayer *) const
print layer
const std::vector< const DetLayer * > & allForwardLayers() const
return all endcap layers
const BoundSurface & surface() const final
The surface of the GeometricSearchDet.
const std::vector< const DetLayer * > & allBarrelLayers() const
return all barrel layers
MTDNavigationPrinter(const MTDDetLayerGeometry *, MTDNavigationSchool const &, bool enableBTL=true, bool enableETL=true)
const PositionType & position() const
std::vector< BarrelDetLayer const * > const & barrelLayers() const