Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-18 23:28:56

0001 // user include files
0002 #include "FWCore/Framework/interface/Frameworkfwd.h"
0003 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0010 
0011 #include "Geometry/GEMGeometry/interface/GEMGeometry.h"
0012 #include "Geometry/GEMGeometry/interface/GEMChamber.h"
0013 #include "Geometry/CommonTopologies/interface/StripTopology.h"
0014 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0015 
0016 //STL headers
0017 #include <vector>
0018 #include <sstream>
0019 #include <fstream>
0020 #include <string>
0021 #include <iomanip>
0022 
0023 class GEMGeometryDump : public edm::one::EDAnalyzer<> {
0024 public:
0025   explicit GEMGeometryDump(const edm::ParameterSet&);
0026   static void fillDescriptions(edm::ConfigurationDescriptions&);
0027 
0028 private:
0029   void analyze(const edm::Event&, const edm::EventSetup&) override;
0030 
0031   const bool verbose_;
0032   const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> tokGeom_;
0033   const GEMGeometry* gemGeometry_;
0034 };
0035 
0036 GEMGeometryDump::GEMGeometryDump(const edm::ParameterSet& iC)
0037     : verbose_(iC.getParameter<bool>("verbose")),
0038       tokGeom_{esConsumes<GEMGeometry, MuonGeometryRecord>(edm::ESInputTag{})} {}
0039 
0040 void GEMGeometryDump::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0041   edm::ParameterSetDescription desc;
0042   desc.add<bool>("verbose", false);
0043   descriptions.add("gemGeometryDump", desc);
0044 }
0045 
0046 void GEMGeometryDump::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) {
0047   gemGeometry_ = &eventSetup.getData(tokGeom_);
0048 
0049   auto const& regions = gemGeometry_->regions();
0050   edm::LogVerbatim("GEMGeometry") << "GEMGeometry found with " << regions.size() << " regions\n";
0051   for (unsigned int k1 = 0; k1 < regions.size(); ++k1) {
0052     edm::LogVerbatim("GEMGeometry") << "\nRegion " << k1 << ":" << regions[k1]->region() << " with "
0053                                     << regions[k1]->nStations() << " staions";
0054     auto const& stations = regions[k1]->stations();
0055 
0056     for (unsigned int k2 = 0; k2 < stations.size(); ++k2) {
0057       edm::LogVerbatim("GEMGeometry") << "\nStation " << k2 << ":" << stations[k2]->station() << ":"
0058                                       << stations[k2]->getName() << " with " << stations[k2]->nRings() << " rings";
0059       auto const& rings = stations[k2]->rings();
0060 
0061       for (unsigned int k3 = 0; k3 < rings.size(); ++k3) {
0062         edm::LogVerbatim("GEMGeometry") << "\nRing " << k3 << ":" << rings[k3]->ring() << " with "
0063                                         << rings[k3]->nSuperChambers() << " superChambers";
0064         auto const& superChambers = rings[k3]->superChambers();
0065 
0066         for (unsigned int k4 = 0; k4 < superChambers.size(); ++k4) {
0067           auto pos = superChambers[k4]->position();
0068           edm::LogVerbatim("GEMGeometry")
0069               << "\nSuperChamber " << k4 << ":" << superChambers[k4]->id() << " with " << superChambers[k4]->nChambers()
0070               << " chambers. Position: " << pos.x() << " " << pos.y() << " " << pos.z();
0071           auto const& chambers = superChambers[k4]->chambers();
0072 
0073           for (unsigned int k5 = 0; k5 < chambers.size(); ++k5) {
0074             auto pos = chambers[k5]->position();
0075             edm::LogVerbatim("GEMGeometry")
0076                 << "\nChamber " << k5 << ":" << chambers[k5]->id() << " with " << chambers[k5]->nEtaPartitions()
0077                 << " etaPartitions. Position: " << pos.x() << " " << pos.y() << " " << pos.z();
0078             auto const& etaPartitions = chambers[k5]->etaPartitions();
0079 
0080             for (unsigned int k6 = 0; k6 < etaPartitions.size(); ++k6) {
0081               auto pos = chambers[k5]->position();
0082               edm::LogVerbatim("GEMGeometry")
0083                   << "\nEtaPartition " << k6 << ":" << etaPartitions[k6]->id() << etaPartitions[k6]->type().name()
0084                   << " with " << etaPartitions[k6]->nstrips() << " strips of pitch " << etaPartitions[k6]->pitch()
0085                   << " and " << etaPartitions[k6]->npads() << " pads of pitch " << etaPartitions[k6]->padPitch()
0086                   << ". Position: " << pos.x() << " " << pos.y() << " " << pos.z();
0087               ;
0088               if (verbose_) {
0089                 for (int k = 0; k < etaPartitions[k6]->nstrips(); ++k)
0090                   edm::LogVerbatim("GEMGeometry") << "Strip[" << k << "] " << etaPartitions[k6]->centreOfStrip(k);
0091                 for (int k = 0; k < etaPartitions[k6]->npads(); ++k)
0092                   edm::LogVerbatim("GEMGeometry") << "Pad[" << k << "] " << etaPartitions[k6]->centreOfPad(k);
0093               }
0094             }
0095           }
0096         }
0097       }
0098     }
0099   }
0100 }
0101 
0102 DEFINE_FWK_MODULE(GEMGeometryDump);