CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/Validation/MuonRPCGeometry/plugins/RPCGeometryServTest.cc

Go to the documentation of this file.
00001 
00006 #include <memory>
00007 #include <fstream>
00008 #include <FWCore/Framework/interface/Frameworkfwd.h>
00009 
00010 #include <FWCore/Framework/interface/EDAnalyzer.h>
00011 #include <FWCore/Framework/interface/Event.h>
00012 #include <FWCore/Framework/interface/EventSetup.h>
00013 #include <FWCore/Framework/interface/ESHandle.h>
00014 #include <FWCore/ParameterSet/interface/ParameterSet.h>
00015 
00016 #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
00017 #include "Geometry/RPCGeometry/interface/RPCGeomServ.h"
00018 #include <Geometry/Records/interface/MuonGeometryRecord.h>
00019 #include <Geometry/CommonTopologies/interface/RectangularStripTopology.h>
00020 #include <Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h>
00021 
00022 
00023 #include "Validation/MuonRPCGeometry/plugins/RPCGeometryServTest.h"
00024 
00025 #include <string>
00026 #include <cmath>
00027 #include <vector>
00028 #include <map>
00029 #include <iomanip>
00030 #include <set>
00031 
00032 using namespace std;
00033 
00034 
00035 RPCGeometryServTest::RPCGeometryServTest( const edm::ParameterSet& iConfig )
00036   : dashedLineWidth_(104), dashedLine_( std::string(dashedLineWidth_, '-') ), 
00037     myName_( "RPCGeometryServTest" ) 
00038 { 
00039   std::cout <<"======================== Opening output file"<< std::endl;
00040 }
00041 
00042 
00043 RPCGeometryServTest::~RPCGeometryServTest() 
00044 {
00045 }
00046 
00047 void
00048 RPCGeometryServTest::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetup )
00049 {
00050   edm::ESHandle<RPCGeometry> pDD;
00051   iSetup.get<MuonGeometryRecord>().get( pDD );     
00052 
00053   std::cout << myName() << ": Analyzer..." << std::endl;
00054   std::cout << "start " << dashedLine_ << std::endl;
00055 
00056 
00057   std::cout << " Geometry node for RPCGeom is  " << &(*pDD) << std::endl;   
00058   cout << " I have "<<pDD->detTypes().size()    << " detTypes" << endl;
00059   cout << " I have "<<pDD->detUnits().size()    << " detUnits" << endl;
00060   cout << " I have "<<pDD->dets().size()        << " dets" << endl;
00061   cout << " I have "<<pDD->rolls().size()       << " rolls" << endl;
00062   cout << " I have "<<pDD->chambers().size()    << " chambers" << endl;
00063 
00064   std::cout << myName() << ": Begin iteration over geometry..." << std::endl;
00065   std::cout << "iter " << dashedLine_ << std::endl;
00066 
00067   
00068 
00069   int iRPCCHcount = 0;
00070   LocalPoint a(0.,0.,0.);
00071   for(TrackingGeometry::DetContainer::const_iterator it = 
00072         pDD->dets().begin(); it != pDD->dets().end(); it++){
00073     
00074     //----------------------- RPCCHAMBER TEST ---------------------------
00075 
00076     if( dynamic_cast< RPCChamber* >( *it ) != 0 ){
00077       ++iRPCCHcount;
00078       RPCChamber* ch = dynamic_cast< RPCChamber* >( *it ); 
00079       
00080       std::vector< const RPCRoll*> rollsRaf = (ch->rolls());
00081       for(std::vector<const RPCRoll*>::iterator r = rollsRaf.begin();
00082           r != rollsRaf.end(); ++r){
00083         std::cout << dashedLine_ << " NEW ROLL" << std::endl;
00084         std::cout<<"Region = "<<(*r)->id().region()
00085                  <<"  Ring = "<<(*r)->id().ring()
00086                  <<"  Station = "<<(*r)->id().station()
00087                  <<"  Sector = "<<(*r)->id().sector()
00088                  <<"  Layer = "<<(*r)->id().layer()
00089                  <<"  Subsector = "<<(*r)->id().subsector()
00090                  <<"  Roll = "<<(*r)->id().roll()<<std::endl;
00091         RPCGeomServ s( (*r)->id());
00092         GlobalPoint g= (*r)->toGlobal(a);
00093         std::cout <<s.name()<<" eta partition "<<s.eta_partition()<< " nroll="<<ch->nrolls()
00094                   <<" z="<<g.z()<<" phi="<<g.phi()<<" R="<<g.perp()
00095                   <<std::endl;
00096 
00097         if((*r)->id().region() ==  0 ){
00098           if (barzranges.find(s.eta_partition()) != barzranges.end()){
00099             std::pair<double, double> cic=barzranges.find(s.eta_partition())->second;
00100             double cmin = cic.first;
00101             double cmax = cic.second;
00102             if (g.z()<cmin)
00103               cmin = g.z();
00104             if (g.z()>cmax)
00105               cmax = g.z();
00106             std::pair<double,double>  cic2(cmin,cmax);
00107             barzranges[s.eta_partition()]=cic2;
00108           }else{
00109             std::pair<double, double> cic(g.z(),g.z());
00110             barzranges[s.eta_partition()]=cic;
00111           }
00112         }
00113         else if((*r)->id().region() ==  +1 ){
00114           if (forRranges.find(s.eta_partition()) != forRranges.end()){
00115             std::pair<double, double> cic=forRranges.find(s.eta_partition())->second;
00116             double cmin = cic.first;
00117             double cmax = cic.second;
00118             if (g.perp()<cmin)
00119               cmin = g.perp();
00120             if (g.perp()>cmax)
00121               cmax = g.perp();
00122             std::pair<double,double>  cic2(cmin,cmax);
00123             forRranges[s.eta_partition()]=cic2;
00124           }else{
00125             std::pair<double, double> cic(g.perp(),g.perp());
00126             forRranges[s.eta_partition()]=cic;
00127           }
00128         }
00129         else if((*r)->id().region() ==  -1 ){
00130           if (bacRranges.find(s.eta_partition()) != bacRranges.end()){
00131             std::pair<double, double> cic=bacRranges.find(s.eta_partition())->second;
00132             double cmin = cic.first;
00133             double cmax = cic.second;
00134             if (g.perp()<cmin)
00135               cmin = g.perp();
00136             if (g.perp()>cmax)
00137               cmax = g.perp();
00138             std::pair<double,double>  cic2(cmin,cmax);
00139             bacRranges[s.eta_partition()]=cic2;
00140           }else{
00141             std::pair<double, double> cic(g.perp(),g.perp());
00142             bacRranges[s.eta_partition()]=cic;
00143           }
00144         }
00145       }
00146     }
00147   }
00148 
00149   std::cout <<std::endl;
00150   std::map<int, std::pair<double, double> >::iterator ieta;
00151 
00152   for (ieta=bacRranges.begin(); ieta != bacRranges.end(); ieta++){
00153     std::cout <<" Eta "<<ieta->first<<" Radii = ( "<<ieta->second.first
00154               <<", "<<ieta->second.second<<")"<<std::endl;
00155   }
00156 
00157   for (ieta=barzranges.begin(); ieta != barzranges.end(); ieta++){
00158     std::cout <<" Eta "<<ieta->first<<" Z = ( "<<ieta->second.first
00159               <<", "<<ieta->second.second<<")"<<std::endl;
00160   }
00161 
00162   for (ieta=forRranges.begin(); ieta != forRranges.end(); ieta++){
00163     std::cout <<" Eta "<<ieta->first<<" Radii = ( "<<ieta->second.first
00164               <<", "<<ieta->second.second<<")"<<std::endl;
00165   }
00166 
00167 
00168   std::cout << dashedLine_ << " end" << std::endl;
00169 }
00170