Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-13 03:16:24

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   int iRPCCHcount = 0;
0047   LocalPoint a(0., 0., 0.);
0048   for (TrackingGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++) {
0049     //----------------------- RPCCHAMBER TEST ---------------------------
0050 
0051     if (dynamic_cast<const RPCChamber*>(*it) != nullptr) {
0052       ++iRPCCHcount;
0053       const RPCChamber* ch = dynamic_cast<const RPCChamber*>(*it);
0054 
0055       std::vector<const RPCRoll*> rollsRaf = (ch->rolls());
0056       for (std::vector<const RPCRoll*>::iterator r = rollsRaf.begin(); r != rollsRaf.end(); ++r) {
0057         std::cout << dashedLine_ << " NEW ROLL" << std::endl;
0058         std::cout << "Region = " << (*r)->id().region() << "  Ring = " << (*r)->id().ring()
0059                   << "  Station = " << (*r)->id().station() << "  Sector = " << (*r)->id().sector()
0060                   << "  Layer = " << (*r)->id().layer() << "  Subsector = " << (*r)->id().subsector()
0061                   << "  Roll = " << (*r)->id().roll() << std::endl;
0062         RPCGeomServ s((*r)->id());
0063         GlobalPoint g = (*r)->toGlobal(a);
0064         std::cout << s.name() << " eta partition " << s.eta_partition() << " nroll=" << ch->nrolls() << " z=" << g.z()
0065                   << " phi=" << g.phi() << " R=" << g.perp() << std::endl;
0066 
0067         if ((*r)->id().region() == 0) {
0068           if (barzranges.find(s.eta_partition()) != barzranges.end()) {
0069             std::pair<double, double> cic = barzranges.find(s.eta_partition())->second;
0070             double cmin = cic.first;
0071             double cmax = cic.second;
0072             if (g.z() < cmin)
0073               cmin = g.z();
0074             if (g.z() > cmax)
0075               cmax = g.z();
0076             std::pair<double, double> cic2(cmin, cmax);
0077             barzranges[s.eta_partition()] = cic2;
0078           } else {
0079             std::pair<double, double> cic(g.z(), g.z());
0080             barzranges[s.eta_partition()] = cic;
0081           }
0082         } else if ((*r)->id().region() == +1) {
0083           if (forRranges.find(s.eta_partition()) != forRranges.end()) {
0084             std::pair<double, double> cic = forRranges.find(s.eta_partition())->second;
0085             double cmin = cic.first;
0086             double cmax = cic.second;
0087             if (g.perp() < cmin)
0088               cmin = g.perp();
0089             if (g.perp() > cmax)
0090               cmax = g.perp();
0091             std::pair<double, double> cic2(cmin, cmax);
0092             forRranges[s.eta_partition()] = cic2;
0093           } else {
0094             std::pair<double, double> cic(g.perp(), g.perp());
0095             forRranges[s.eta_partition()] = cic;
0096           }
0097         } else if ((*r)->id().region() == -1) {
0098           if (bacRranges.find(s.eta_partition()) != bacRranges.end()) {
0099             std::pair<double, double> cic = bacRranges.find(s.eta_partition())->second;
0100             double cmin = cic.first;
0101             double cmax = cic.second;
0102             if (g.perp() < cmin)
0103               cmin = g.perp();
0104             if (g.perp() > cmax)
0105               cmax = g.perp();
0106             std::pair<double, double> cic2(cmin, cmax);
0107             bacRranges[s.eta_partition()] = cic2;
0108           } else {
0109             std::pair<double, double> cic(g.perp(), g.perp());
0110             bacRranges[s.eta_partition()] = cic;
0111           }
0112         }
0113       }
0114     }
0115   }
0116 
0117   std::cout << std::endl;
0118   std::map<int, std::pair<double, double> >::iterator ieta;
0119 
0120   for (ieta = bacRranges.begin(); ieta != bacRranges.end(); ieta++) {
0121     std::cout << " Eta " << ieta->first << " Radii = ( " << ieta->second.first << ", " << ieta->second.second << ")"
0122               << std::endl;
0123   }
0124 
0125   for (ieta = barzranges.begin(); ieta != barzranges.end(); ieta++) {
0126     std::cout << " Eta " << ieta->first << " Z = ( " << ieta->second.first << ", " << ieta->second.second << ")"
0127               << std::endl;
0128   }
0129 
0130   for (ieta = forRranges.begin(); ieta != forRranges.end(); ieta++) {
0131     std::cout << " Eta " << ieta->first << " Radii = ( " << ieta->second.first << ", " << ieta->second.second << ")"
0132               << std::endl;
0133   }
0134 
0135   std::cout << dashedLine_ << " end" << std::endl;
0136 }