CMS 3D CMS Logo

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