CMS 3D CMS Logo

RPCGeometryServTest.cc
Go to the documentation of this file.
1 
6 #include <memory>
7 #include <fstream>
9 
15 
21 
23 
24 #include <string>
25 #include <cmath>
26 #include <vector>
27 #include <map>
28 #include <iomanip>
29 #include <set>
30 
31 using namespace std;
32 
34  : dashedLineWidth_(104), dashedLine_(std::string(dashedLineWidth_, '-')), myName_("RPCGeometryServTest") {
35  std::cout << "======================== Opening output file" << std::endl;
36 }
37 
39 
42  iSetup.get<MuonGeometryRecord>().get(pDD);
43 
44  std::cout << myName() << ": Analyzer..." << std::endl;
45  std::cout << "start " << dashedLine_ << std::endl;
46 
47  std::cout << " Geometry node for RPCGeom is " << &(*pDD) << std::endl;
48  cout << " I have " << pDD->detTypes().size() << " detTypes" << endl;
49  cout << " I have " << pDD->detUnits().size() << " detUnits" << endl;
50  cout << " I have " << pDD->dets().size() << " dets" << endl;
51  cout << " I have " << pDD->rolls().size() << " rolls" << endl;
52  cout << " I have " << pDD->chambers().size() << " chambers" << endl;
53 
54  std::cout << myName() << ": Begin iteration over geometry..." << std::endl;
55  std::cout << "iter " << dashedLine_ << std::endl;
56 
57  int iRPCCHcount = 0;
58  LocalPoint a(0., 0., 0.);
59  for (TrackingGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++) {
60  //----------------------- RPCCHAMBER TEST ---------------------------
61 
62  if (dynamic_cast<const RPCChamber*>(*it) != nullptr) {
63  ++iRPCCHcount;
64  const RPCChamber* ch = dynamic_cast<const RPCChamber*>(*it);
65 
66  std::vector<const RPCRoll*> rollsRaf = (ch->rolls());
67  for (std::vector<const RPCRoll*>::iterator r = rollsRaf.begin(); r != rollsRaf.end(); ++r) {
68  std::cout << dashedLine_ << " NEW ROLL" << std::endl;
69  std::cout << "Region = " << (*r)->id().region() << " Ring = " << (*r)->id().ring()
70  << " Station = " << (*r)->id().station() << " Sector = " << (*r)->id().sector()
71  << " Layer = " << (*r)->id().layer() << " Subsector = " << (*r)->id().subsector()
72  << " Roll = " << (*r)->id().roll() << std::endl;
73  RPCGeomServ s((*r)->id());
74  GlobalPoint g = (*r)->toGlobal(a);
75  std::cout << s.name() << " eta partition " << s.eta_partition() << " nroll=" << ch->nrolls() << " z=" << g.z()
76  << " phi=" << g.phi() << " R=" << g.perp() << std::endl;
77 
78  if ((*r)->id().region() == 0) {
79  if (barzranges.find(s.eta_partition()) != barzranges.end()) {
80  std::pair<double, double> cic = barzranges.find(s.eta_partition())->second;
81  double cmin = cic.first;
82  double cmax = cic.second;
83  if (g.z() < cmin)
84  cmin = g.z();
85  if (g.z() > cmax)
86  cmax = g.z();
87  std::pair<double, double> cic2(cmin, cmax);
88  barzranges[s.eta_partition()] = cic2;
89  } else {
90  std::pair<double, double> cic(g.z(), g.z());
91  barzranges[s.eta_partition()] = cic;
92  }
93  } else if ((*r)->id().region() == +1) {
94  if (forRranges.find(s.eta_partition()) != forRranges.end()) {
95  std::pair<double, double> cic = forRranges.find(s.eta_partition())->second;
96  double cmin = cic.first;
97  double cmax = cic.second;
98  if (g.perp() < cmin)
99  cmin = g.perp();
100  if (g.perp() > cmax)
101  cmax = g.perp();
102  std::pair<double, double> cic2(cmin, cmax);
103  forRranges[s.eta_partition()] = cic2;
104  } else {
105  std::pair<double, double> cic(g.perp(), g.perp());
106  forRranges[s.eta_partition()] = cic;
107  }
108  } else if ((*r)->id().region() == -1) {
109  if (bacRranges.find(s.eta_partition()) != bacRranges.end()) {
110  std::pair<double, double> cic = bacRranges.find(s.eta_partition())->second;
111  double cmin = cic.first;
112  double cmax = cic.second;
113  if (g.perp() < cmin)
114  cmin = g.perp();
115  if (g.perp() > cmax)
116  cmax = g.perp();
117  std::pair<double, double> cic2(cmin, cmax);
118  bacRranges[s.eta_partition()] = cic2;
119  } else {
120  std::pair<double, double> cic(g.perp(), g.perp());
121  bacRranges[s.eta_partition()] = cic;
122  }
123  }
124  }
125  }
126  }
127 
128  std::cout << std::endl;
129  std::map<int, std::pair<double, double> >::iterator ieta;
130 
131  for (ieta = bacRranges.begin(); ieta != bacRranges.end(); ieta++) {
132  std::cout << " Eta " << ieta->first << " Radii = ( " << ieta->second.first << ", " << ieta->second.second << ")"
133  << std::endl;
134  }
135 
136  for (ieta = barzranges.begin(); ieta != barzranges.end(); ieta++) {
137  std::cout << " Eta " << ieta->first << " Z = ( " << ieta->second.first << ", " << ieta->second.second << ")"
138  << std::endl;
139  }
140 
141  for (ieta = forRranges.begin(); ieta != forRranges.end(); ieta++) {
142  std::cout << " Eta " << ieta->first << " Radii = ( " << ieta->second.first << ", " << ieta->second.second << ")"
143  << std::endl;
144  }
145 
146  std::cout << dashedLine_ << " end" << std::endl;
147 }
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
Definition: RPCGeometry.cc:22
const std::vector< const RPCRoll * > & rolls() const
Return a vector of all RPC rolls.
Definition: RPCGeometry.cc:44
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
const DetTypeContainer & detTypes() const override
Return a vector of all det types.
Definition: RPCGeometry.cc:20
U second(std::pair< T, U > const &p)
int iEvent
Definition: GenABIO.cc:224
std::map< int, std::pair< double, double > > barzranges
const std::vector< const RPCRoll * > & rolls() const
Return the Rolls.
Definition: RPCChamber.cc:40
const std::vector< const RPCChamber * > & chambers() const
Return a vector of all RPC chambers.
Definition: RPCGeometry.cc:42
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
Definition: RPCGeometry.cc:24
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
T get() const
Definition: EventSetup.h:73
int nrolls() const
Retunr numbers of rolls.
Definition: RPCChamber.cc:42
const std::string & myName()
const std::string dashedLine_
std::map< int, std::pair< double, double > > bacRranges