CMS 3D CMS Logo

RPCGeometryServTest.cc
Go to the documentation of this file.
1 
6 #include <memory>
7 #include <fstream>
14 
15 #include <cmath>
16 #include <vector>
17 #include <iomanip>
18 #include <set>
19 
20 using namespace std;
21 
23  : dashedLineWidth_(104), dashedLine_(std::string(dashedLineWidth_, '-')), myName_("RPCGeometryServTest") {
24  std::cout << "======================== Opening output file" << std::endl;
26 }
27 
29 
31  const auto& pDD = iSetup.getHandle(rpcGeomToken_);
32 
33  std::cout << myName() << ": Analyzer..." << std::endl;
34  std::cout << "start " << dashedLine_ << std::endl;
35 
36  std::cout << " Geometry node for RPCGeom is " << &(*pDD) << std::endl;
37  cout << " I have " << pDD->detTypes().size() << " detTypes" << endl;
38  cout << " I have " << pDD->detUnits().size() << " detUnits" << endl;
39  cout << " I have " << pDD->dets().size() << " dets" << endl;
40  cout << " I have " << pDD->rolls().size() << " rolls" << endl;
41  cout << " I have " << pDD->chambers().size() << " chambers" << endl;
42 
43  std::cout << myName() << ": Begin iteration over geometry..." << std::endl;
44  std::cout << "iter " << dashedLine_ << std::endl;
45 
46  LocalPoint a(0., 0., 0.);
47  for (TrackingGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++) {
48  //----------------------- RPCCHAMBER TEST ---------------------------
49 
50  if (dynamic_cast<const RPCChamber*>(*it) != nullptr) {
51  const RPCChamber* ch = dynamic_cast<const RPCChamber*>(*it);
52 
53  std::vector<const RPCRoll*> rollsRaf = (ch->rolls());
54  for (std::vector<const RPCRoll*>::iterator r = rollsRaf.begin(); r != rollsRaf.end(); ++r) {
55  std::cout << dashedLine_ << " NEW ROLL" << std::endl;
56  std::cout << "Region = " << (*r)->id().region() << " Ring = " << (*r)->id().ring()
57  << " Station = " << (*r)->id().station() << " Sector = " << (*r)->id().sector()
58  << " Layer = " << (*r)->id().layer() << " Subsector = " << (*r)->id().subsector()
59  << " Roll = " << (*r)->id().roll() << std::endl;
60  RPCGeomServ s((*r)->id());
61  GlobalPoint g = (*r)->toGlobal(a);
62  std::cout << s.name() << " eta partition " << s.eta_partition() << " nroll=" << ch->nrolls() << " z=" << g.z()
63  << " phi=" << g.phi() << " R=" << g.perp() << std::endl;
64 
65  if ((*r)->id().region() == 0) {
66  if (barzranges.find(s.eta_partition()) != barzranges.end()) {
67  std::pair<double, double> cic = barzranges.find(s.eta_partition())->second;
68  double cmin = cic.first;
69  double cmax = cic.second;
70  if (g.z() < cmin)
71  cmin = g.z();
72  if (g.z() > cmax)
73  cmax = g.z();
74  std::pair<double, double> cic2(cmin, cmax);
75  barzranges[s.eta_partition()] = cic2;
76  } else {
77  std::pair<double, double> cic(g.z(), g.z());
78  barzranges[s.eta_partition()] = cic;
79  }
80  } else if ((*r)->id().region() == +1) {
81  if (forRranges.find(s.eta_partition()) != forRranges.end()) {
82  std::pair<double, double> cic = forRranges.find(s.eta_partition())->second;
83  double cmin = cic.first;
84  double cmax = cic.second;
85  if (g.perp() < cmin)
86  cmin = g.perp();
87  if (g.perp() > cmax)
88  cmax = g.perp();
89  std::pair<double, double> cic2(cmin, cmax);
90  forRranges[s.eta_partition()] = cic2;
91  } else {
92  std::pair<double, double> cic(g.perp(), g.perp());
93  forRranges[s.eta_partition()] = cic;
94  }
95  } else if ((*r)->id().region() == -1) {
96  if (bacRranges.find(s.eta_partition()) != bacRranges.end()) {
97  std::pair<double, double> cic = bacRranges.find(s.eta_partition())->second;
98  double cmin = cic.first;
99  double cmax = cic.second;
100  if (g.perp() < cmin)
101  cmin = g.perp();
102  if (g.perp() > cmax)
103  cmax = g.perp();
104  std::pair<double, double> cic2(cmin, cmax);
105  bacRranges[s.eta_partition()] = cic2;
106  } else {
107  std::pair<double, double> cic(g.perp(), g.perp());
108  bacRranges[s.eta_partition()] = cic;
109  }
110  }
111  }
112  }
113  }
114 
115  std::cout << std::endl;
116  std::map<int, std::pair<double, double> >::iterator ieta;
117 
118  for (ieta = bacRranges.begin(); ieta != bacRranges.end(); ieta++) {
119  std::cout << " Eta " << ieta->first << " Radii = ( " << ieta->second.first << ", " << ieta->second.second << ")"
120  << std::endl;
121  }
122 
123  for (ieta = barzranges.begin(); ieta != barzranges.end(); ieta++) {
124  std::cout << " Eta " << ieta->first << " Z = ( " << ieta->second.first << ", " << ieta->second.second << ")"
125  << std::endl;
126  }
127 
128  for (ieta = forRranges.begin(); ieta != forRranges.end(); ieta++) {
129  std::cout << " Eta " << ieta->first << " Radii = ( " << ieta->second.first << ", " << ieta->second.second << ")"
130  << std::endl;
131  }
132 
133  std::cout << dashedLine_ << " end" << std::endl;
134 }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
int nrolls() const
Retunr numbers of rolls.
Definition: RPCChamber.cc:42
U second(std::pair< T, U > const &p)
int iEvent
Definition: GenABIO.cc:224
std::map< int, std::pair< double, double > > barzranges
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeomToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
std::map< int, std::pair< double, double > > forRranges
void analyze(const edm::Event &, const edm::EventSetup &) override
RPCGeometryServTest(const edm::ParameterSet &pset)
double a
Definition: hdecay.h:121
const std::string & myName()
const std::vector< const RPCRoll * > & rolls() const
Return the Rolls.
Definition: RPCChamber.cc:40
const std::string dashedLine_
std::map< int, std::pair< double, double > > bacRranges