Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:54

0001 /**
0002  *
0003  *  \author M. Maggi - INFN Bari
0004  */
0005 
0006 #include <memory>
0007 #include <fstream>
0008 #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
0009 #include "Geometry/RPCGeometry/interface/RPCGeomServ.h"
0010 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0011 #include "Geometry/CommonTopologies/interface/RectangularStripTopology.h"
0012 #include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h"
0013 #include "Validation/MuonRPCGeometry/plugins/RPCGeometryServTest.h"
0014 
0015 #include <cmath>
0016 #include <vector>
0017 #include <iomanip>
0018 #include <set>
0019 
0020 using namespace std;
0021 
0022 RPCGeometryServTest::RPCGeometryServTest(const edm::ParameterSet& iConfig)
0023     : dashedLineWidth_(104), dashedLine_(std::string(dashedLineWidth_, '-')), myName_("RPCGeometryServTest") {
0024   std::cout << "======================== Opening output file" << std::endl;
0025   rpcGeomToken_ = esConsumes();
0026 }
0027 
0028 RPCGeometryServTest::~RPCGeometryServTest() {}
0029 
0030 void RPCGeometryServTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0031   const auto& pDD = iSetup.getHandle(rpcGeomToken_);
0032 
0033   std::cout << myName() << ": Analyzer..." << std::endl;
0034   std::cout << "start " << dashedLine_ << std::endl;
0035 
0036   std::cout << " Geometry node for RPCGeom is  " << &(*pDD) << std::endl;
0037   cout << " I have " << pDD->detTypes().size() << " detTypes" << endl;
0038   cout << " I have " << pDD->detUnits().size() << " detUnits" << endl;
0039   cout << " I have " << pDD->dets().size() << " dets" << endl;
0040   cout << " I have " << pDD->rolls().size() << " rolls" << endl;
0041   cout << " I have " << pDD->chambers().size() << " chambers" << endl;
0042 
0043   std::cout << myName() << ": Begin iteration over geometry..." << std::endl;
0044   std::cout << "iter " << dashedLine_ << std::endl;
0045 
0046   LocalPoint a(0., 0., 0.);
0047   for (TrackingGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++) {
0048     //----------------------- RPCCHAMBER TEST ---------------------------
0049 
0050     if (dynamic_cast<const RPCChamber*>(*it) != nullptr) {
0051       const RPCChamber* ch = dynamic_cast<const RPCChamber*>(*it);
0052 
0053       std::vector<const RPCRoll*> rollsRaf = (ch->rolls());
0054       for (std::vector<const RPCRoll*>::iterator r = rollsRaf.begin(); r != rollsRaf.end(); ++r) {
0055         std::cout << dashedLine_ << " NEW ROLL" << std::endl;
0056         std::cout << "Region = " << (*r)->id().region() << "  Ring = " << (*r)->id().ring()
0057                   << "  Station = " << (*r)->id().station() << "  Sector = " << (*r)->id().sector()
0058                   << "  Layer = " << (*r)->id().layer() << "  Subsector = " << (*r)->id().subsector()
0059                   << "  Roll = " << (*r)->id().roll() << std::endl;
0060         RPCGeomServ s((*r)->id());
0061         GlobalPoint g = (*r)->toGlobal(a);
0062         std::cout << s.name() << " eta partition " << s.eta_partition() << " nroll=" << ch->nrolls() << " z=" << g.z()
0063                   << " phi=" << g.phi() << " R=" << g.perp() << std::endl;
0064 
0065         if ((*r)->id().region() == 0) {
0066           if (barzranges.find(s.eta_partition()) != barzranges.end()) {
0067             std::pair<double, double> cic = barzranges.find(s.eta_partition())->second;
0068             double cmin = cic.first;
0069             double cmax = cic.second;
0070             if (g.z() < cmin)
0071               cmin = g.z();
0072             if (g.z() > cmax)
0073               cmax = g.z();
0074             std::pair<double, double> cic2(cmin, cmax);
0075             barzranges[s.eta_partition()] = cic2;
0076           } else {
0077             std::pair<double, double> cic(g.z(), g.z());
0078             barzranges[s.eta_partition()] = cic;
0079           }
0080         } else if ((*r)->id().region() == +1) {
0081           if (forRranges.find(s.eta_partition()) != forRranges.end()) {
0082             std::pair<double, double> cic = forRranges.find(s.eta_partition())->second;
0083             double cmin = cic.first;
0084             double cmax = cic.second;
0085             if (g.perp() < cmin)
0086               cmin = g.perp();
0087             if (g.perp() > cmax)
0088               cmax = g.perp();
0089             std::pair<double, double> cic2(cmin, cmax);
0090             forRranges[s.eta_partition()] = cic2;
0091           } else {
0092             std::pair<double, double> cic(g.perp(), g.perp());
0093             forRranges[s.eta_partition()] = cic;
0094           }
0095         } else if ((*r)->id().region() == -1) {
0096           if (bacRranges.find(s.eta_partition()) != bacRranges.end()) {
0097             std::pair<double, double> cic = bacRranges.find(s.eta_partition())->second;
0098             double cmin = cic.first;
0099             double cmax = cic.second;
0100             if (g.perp() < cmin)
0101               cmin = g.perp();
0102             if (g.perp() > cmax)
0103               cmax = g.perp();
0104             std::pair<double, double> cic2(cmin, cmax);
0105             bacRranges[s.eta_partition()] = cic2;
0106           } else {
0107             std::pair<double, double> cic(g.perp(), g.perp());
0108             bacRranges[s.eta_partition()] = cic;
0109           }
0110         }
0111       }
0112     }
0113   }
0114 
0115   std::cout << std::endl;
0116   std::map<int, std::pair<double, double> >::iterator ieta;
0117 
0118   for (ieta = bacRranges.begin(); ieta != bacRranges.end(); ieta++) {
0119     std::cout << " Eta " << ieta->first << " Radii = ( " << ieta->second.first << ", " << ieta->second.second << ")"
0120               << std::endl;
0121   }
0122 
0123   for (ieta = barzranges.begin(); ieta != barzranges.end(); ieta++) {
0124     std::cout << " Eta " << ieta->first << " Z = ( " << ieta->second.first << ", " << ieta->second.second << ")"
0125               << std::endl;
0126   }
0127 
0128   for (ieta = forRranges.begin(); ieta != forRranges.end(); ieta++) {
0129     std::cout << " Eta " << ieta->first << " Radii = ( " << ieta->second.first << ", " << ieta->second.second << ")"
0130               << std::endl;
0131   }
0132 
0133   std::cout << dashedLine_ << " end" << std::endl;
0134 }