Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-02 03:38:58

0001 #include <stdexcept>
0002 #include <string>
0003 #include <iostream>
0004 #include <map>
0005 #include <vector>
0006 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 
0010 #include "FWCore/Framework/interface/EventSetup.h"
0011 #include "FWCore/Utilities/interface/ESGetToken.h"
0012 
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014 
0015 #include "CondFormats/CSCObjects/interface/CSCCrateMap.h"
0016 #include "CondFormats/DataRecord/interface/CSCCrateMapRcd.h"
0017 
0018 #include "CondFormats/CSCObjects/interface/CSCMapItem.h"
0019 
0020 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0021 
0022 using namespace std;
0023 namespace edmtest {
0024   class CSCReadoutMapTest : public edm::global::EDAnalyzer<> {
0025   public:
0026     explicit CSCReadoutMapTest(edm::ParameterSet const& p) : token_{esConsumes()} {}
0027     ~CSCReadoutMapTest() override {}
0028     void analyze(edm::StreamID, const edm::Event& e, const edm::EventSetup& c) const override;
0029 
0030   private:
0031     edm::ESGetToken<CSCCrateMap, CSCCrateMapRcd> token_;
0032   };
0033 
0034   void CSCReadoutMapTest::analyze(edm::StreamID, const edm::Event& e, const edm::EventSetup& context) const {
0035     using namespace edm::eventsetup;
0036 
0037     edm::LogSystem log("CSCCrateMap");
0038 
0039     log << "+===================+" << std::endl;
0040     log << "| CSCReadoutMapTest |" << std::endl;
0041     log << "+===================+" << std::endl;
0042 
0043     log << "run " << e.id().run() << std::endl;
0044     log << "event " << e.id().event() << std::endl;
0045 
0046     const CSCCrateMap* pcrate = &context.getData(token_);
0047 
0048     const int ncrates = 60;
0049     const int ndmb = 10;
0050     const int missing = 6;
0051     int count = 0;
0052     int countall = 0;
0053 
0054     for (int jc = 0; jc != ncrates; ++jc) {
0055       for (int jd = 0; jd != ndmb; ++jd) {
0056         if (jd + 1 == missing)
0057           continue;     // there's no dmb=6
0058         int jcfeb = 0;  // just set something
0059         ++countall;
0060         // The iterations here cover more than available chambers so need
0061         // to skip non-existing ones
0062         int jdmb = jd + 1;
0063         int jcrate = jc + 1;
0064 
0065         int cscid = jdmb;
0066         if (jdmb >= 6)
0067           --cscid;
0068         int key = jcrate * 10 + cscid;
0069         CSCCrateMap::CSCMap::const_iterator it = (pcrate->crate_map).find(key);
0070         if (it != (pcrate->crate_map).end()) {
0071           ++count;
0072           CSCDetId id = pcrate->detId(jcrate, jdmb, jcfeb);  // *** TEST THE detId BUILDER FOR CHAMBER ***
0073           log << "Built CSCDetId for chamber # " << count << " id= " << id << " count " << countall << std::endl;
0074 
0075           if (id.station() == 1 && id.ring() == 1) {
0076             jcfeb = 4;                                         // Split off ME1a
0077             CSCDetId id = pcrate->detId(jcrate, jdmb, jcfeb);  // *** TEST THE detId BUILDER FOR CHAMBER ME1a ***
0078             log << "Built CSCDetId for ME1a, id= " << id << " count " << countall << std::endl;
0079           }
0080 
0081           for (int il = 1; il != 7; ++il) {
0082             CSCDetId id = pcrate->detId(jcrate, jdmb, jcfeb, il);  // *** TEST THE detId BUILDER FOR LAYER ***
0083             log << "Built CSCDetId for layer # " << il << " id= " << id << std::endl;
0084           }
0085 
0086         } else {
0087           log << "no chamber at count = " << countall << std::endl;
0088         }
0089       }
0090     }
0091     log << "+==========================+" << std::endl;
0092     log << "| End of CSCReadoutMapTest |" << std::endl;
0093     log << "+==========================+" << std::endl;
0094 
0095   }  // namespace
0096   DEFINE_FWK_MODULE(CSCReadoutMapTest);
0097 }  // namespace edmtest