CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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< RPCChamber* >( *it ) != 0 ){
77  ++iRPCCHcount;
78  RPCChamber* ch = dynamic_cast< 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 
virtual void analyze(const edm::Event &, const edm::EventSetup &)
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:243
std::map< int, std::pair< double, double > > barzranges
const std::vector< const RPCRoll * > & rolls() const
Return the Rolls.
Definition: RPCChamber.cc:70
std::map< int, std::pair< double, double > > forRranges
const T & get() const
Definition: EventSetup.h:55
RPCGeometryServTest(const edm::ParameterSet &pset)
double a
Definition: hdecay.h:121
int nrolls() const
Retunr numbers of rolls.
Definition: RPCChamber.cc:76
const std::string & myName()
tuple cout
Definition: gather_cfg.py:121
const std::string dashedLine_
std::map< int, std::pair< double, double > > bacRranges