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