CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  int iRPCCHcount = 0;
47  LocalPoint a(0., 0., 0.);
48  for (TrackingGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++) {
49  //----------------------- RPCCHAMBER TEST ---------------------------
50 
51  if (dynamic_cast<const RPCChamber*>(*it) != nullptr) {
52  ++iRPCCHcount;
53  const RPCChamber* ch = dynamic_cast<const RPCChamber*>(*it);
54 
55  std::vector<const RPCRoll*> rollsRaf = (ch->rolls());
56  for (std::vector<const RPCRoll*>::iterator r = rollsRaf.begin(); r != rollsRaf.end(); ++r) {
57  std::cout << dashedLine_ << " NEW ROLL" << std::endl;
58  std::cout << "Region = " << (*r)->id().region() << " Ring = " << (*r)->id().ring()
59  << " Station = " << (*r)->id().station() << " Sector = " << (*r)->id().sector()
60  << " Layer = " << (*r)->id().layer() << " Subsector = " << (*r)->id().subsector()
61  << " Roll = " << (*r)->id().roll() << std::endl;
62  RPCGeomServ s((*r)->id());
63  GlobalPoint g = (*r)->toGlobal(a);
64  std::cout << s.name() << " eta partition " << s.eta_partition() << " nroll=" << ch->nrolls() << " z=" << g.z()
65  << " phi=" << g.phi() << " R=" << g.perp() << std::endl;
66 
67  if ((*r)->id().region() == 0) {
68  if (barzranges.find(s.eta_partition()) != barzranges.end()) {
69  std::pair<double, double> cic = barzranges.find(s.eta_partition())->second;
70  double cmin = cic.first;
71  double cmax = cic.second;
72  if (g.z() < cmin)
73  cmin = g.z();
74  if (g.z() > cmax)
75  cmax = g.z();
76  std::pair<double, double> cic2(cmin, cmax);
77  barzranges[s.eta_partition()] = cic2;
78  } else {
79  std::pair<double, double> cic(g.z(), g.z());
80  barzranges[s.eta_partition()] = cic;
81  }
82  } else if ((*r)->id().region() == +1) {
83  if (forRranges.find(s.eta_partition()) != forRranges.end()) {
84  std::pair<double, double> cic = forRranges.find(s.eta_partition())->second;
85  double cmin = cic.first;
86  double cmax = cic.second;
87  if (g.perp() < cmin)
88  cmin = g.perp();
89  if (g.perp() > cmax)
90  cmax = g.perp();
91  std::pair<double, double> cic2(cmin, cmax);
92  forRranges[s.eta_partition()] = cic2;
93  } else {
94  std::pair<double, double> cic(g.perp(), g.perp());
95  forRranges[s.eta_partition()] = cic;
96  }
97  } else if ((*r)->id().region() == -1) {
98  if (bacRranges.find(s.eta_partition()) != bacRranges.end()) {
99  std::pair<double, double> cic = bacRranges.find(s.eta_partition())->second;
100  double cmin = cic.first;
101  double cmax = cic.second;
102  if (g.perp() < cmin)
103  cmin = g.perp();
104  if (g.perp() > cmax)
105  cmax = g.perp();
106  std::pair<double, double> cic2(cmin, cmax);
107  bacRranges[s.eta_partition()] = cic2;
108  } else {
109  std::pair<double, double> cic(g.perp(), g.perp());
110  bacRranges[s.eta_partition()] = cic;
111  }
112  }
113  }
114  }
115  }
116 
117  std::cout << std::endl;
118  std::map<int, std::pair<double, double> >::iterator ieta;
119 
120  for (ieta = bacRranges.begin(); ieta != bacRranges.end(); ieta++) {
121  std::cout << " Eta " << ieta->first << " Radii = ( " << ieta->second.first << ", " << ieta->second.second << ")"
122  << std::endl;
123  }
124 
125  for (ieta = barzranges.begin(); ieta != barzranges.end(); ieta++) {
126  std::cout << " Eta " << ieta->first << " Z = ( " << ieta->second.first << ", " << ieta->second.second << ")"
127  << std::endl;
128  }
129 
130  for (ieta = forRranges.begin(); ieta != forRranges.end(); ieta++) {
131  std::cout << " Eta " << ieta->first << " Radii = ( " << ieta->second.first << ", " << ieta->second.second << ")"
132  << std::endl;
133  }
134 
135  std::cout << dashedLine_ << " end" << std::endl;
136 }
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
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_
const std::vector< const RPCRoll * > & rolls() const
Return the Rolls.
Definition: RPCChamber.cc:40
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:119
int nrolls() const
Retunr numbers of rolls.
Definition: RPCChamber.cc:42
const std::string & myName()
tuple cout
Definition: gather_cfg.py:144
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
const std::string dashedLine_
std::map< int, std::pair< double, double > > bacRranges