Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-24 22:38:23

0001 /*
0002  * \file L1TRPCTPG.cc
0003  *
0004  * \author J. Berryhill
0005  *
0006  */
0007 
0008 #include "DQM/L1TMonitor/interface/L1TRPCTPG.h"
0009 
0010 using namespace std;
0011 using namespace edm;
0012 
0013 L1TRPCTPG::L1TRPCTPG(const ParameterSet& ps)
0014     : rpctpgSource_(ps.getParameter<InputTag>("rpctpgSource")),
0015       rpctpgSource_token_(consumes<RPCDigiCollection>(ps.getParameter<InputTag>("rpctpgSource"))),
0016       rpctfSource_(ps.getParameter<InputTag>("rpctfSource")),
0017       rpctfSource_token_(consumes<L1MuGMTReadoutCollection>(ps.getParameter<InputTag>("rpctfSource"))) {
0018   // verbosity switch
0019   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
0020 
0021   if (verbose_)
0022     cout << "L1TRPCTPG: constructor...." << endl;
0023 
0024   outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
0025   if (!outputFile_.empty()) {
0026     cout << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
0027   }
0028 
0029   bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
0030   if (disable) {
0031     outputFile_ = "";
0032   }
0033   rpcgeomToken_ = esConsumes();
0034 }
0035 
0036 L1TRPCTPG::~L1TRPCTPG() {}
0037 
0038 void L1TRPCTPG::dqmBeginRun(edm::Run const& r, edm::EventSetup const& c) {
0039   //
0040 }
0041 
0042 void L1TRPCTPG::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const&) {
0043   nev_ = 0;
0044 
0045   ibooker.setCurrentFolder("L1T/L1TRPCTPG");
0046 
0047   rpctpgbx = ibooker.book1D("RPCTPG_bx", "RPC digis bx - all events", 9, -4.5, 4.5);
0048 
0049   rpctpgndigi[1] = ibooker.book1D("RPCTPG_ndigi", "RPCTPG nDigi bx 0", 100, -0.5, 99.5);
0050   rpctpgndigi[2] = ibooker.book1D("RPCTPG_ndigi_+1", "RPCTPG nDigi bx +1", 100, -0.5, 99.5);
0051   rpctpgndigi[0] = ibooker.book1D("RPCTPG_ndigi_-1", "RPCTPG nDigi bx -1", 100, -0.5, 99.5);
0052 
0053   m_digiBxRPCBar = ibooker.book1D("RPCDigiRPCBmu_noDTmu_bx", "RPC digis bx - RPC, !DT", 9, -4.5, 4.5);
0054 
0055   m_digiBxRPCEnd = ibooker.book1D("RPCDigiRPCEmu_noCSCmu_bx", "RPC digis bx - RPC, !CSC", 9, -4.5, 4.5);
0056 
0057   m_digiBxDT = ibooker.book1D("RPCDigiDTmu_noRPCBmu_bx", "RPC digis bx - !RPC, DT", 9, -4.5, 4.5);
0058 
0059   m_digiBxCSC = ibooker.book1D("RPCDigiCSCmu_noRPCEmu_bx", "RPC digis bx - !RPC, CSC", 9, -4.5, 4.5);
0060 }
0061 
0062 void L1TRPCTPG::analyze(const Event& e, const EventSetup& c) {
0063   nev_++;
0064   if (verbose_)
0065     cout << "L1TRPCTPG: analyze...." << endl;
0066 
0067   /// RPC Geometry
0068   const auto& rpcGeo = c.getHandle(rpcgeomToken_);
0069   if (!rpcGeo.isValid()) {
0070     edm::LogInfo("DataNotFound") << "can't find RPCGeometry" << endl;
0071     return;
0072   }
0073   //   char layerLabel[328];
0074   //   char meId [328];
0075 
0076   /// DIGI
0077   edm::Handle<RPCDigiCollection> rpcdigis;
0078   e.getByToken(rpctpgSource_token_, rpcdigis);
0079 
0080   if (!rpcdigis.isValid()) {
0081     edm::LogInfo("DataNotFound") << "can't find RPCDigiCollection with label " << rpctpgSource_ << endl;
0082     return;
0083   }
0084 
0085   // Calculate the number of DT and CSC cands present
0086   edm::Handle<L1MuGMTReadoutCollection> pCollection;
0087   e.getByToken(rpctfSource_token_, pCollection);
0088 
0089   if (!pCollection.isValid()) {
0090     edm::LogInfo("DataNotFound") << "can't find L1MuGMTReadoutCollection with label " << rpctfSource_.label();
0091     return;
0092   }
0093 
0094   L1MuGMTReadoutCollection const* gmtrc = pCollection.product();
0095   vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
0096   vector<L1MuGMTReadoutRecord>::const_iterator RRItr;
0097 
0098   int nRPCTrackBarrel, nRPCTrackEndcap, nDTTrack, nCSCTrack;
0099   nRPCTrackBarrel = 0;
0100   nRPCTrackEndcap = 0;
0101   nDTTrack = 0;
0102   nCSCTrack = 0;
0103 
0104   for (RRItr = gmt_records.begin(); RRItr != gmt_records.end(); RRItr++) {
0105     // DTs
0106     vector<L1MuRegionalCand> DTCands = RRItr->getDTBXCands();
0107     for (vector<L1MuRegionalCand>::const_iterator ECItr = DTCands.begin(); ECItr != DTCands.end(); ++ECItr) {
0108       if (!ECItr->empty()) {
0109         ++nDTTrack;
0110       }
0111     }
0112     // CSCs
0113     vector<L1MuRegionalCand> CSCCands = RRItr->getCSCCands();
0114     for (vector<L1MuRegionalCand>::const_iterator ECItr = CSCCands.begin(); ECItr != CSCCands.end(); ++ECItr) {
0115       if (!ECItr->empty()) {
0116         ++nCSCTrack;
0117       }
0118     }
0119 
0120     //RPC barrel
0121     vector<L1MuRegionalCand> RPCBCands = RRItr->getBrlRPCCands();
0122     for (vector<L1MuRegionalCand>::const_iterator ECItr = RPCBCands.begin(); ECItr != RPCBCands.end(); ++ECItr) {
0123       if (!ECItr->empty()) {
0124         ++nRPCTrackBarrel;
0125       }
0126     }
0127 
0128     //RPC endcap
0129     vector<L1MuRegionalCand> RPCECands = RRItr->getFwdRPCCands();
0130     for (vector<L1MuRegionalCand>::const_iterator ECItr = RPCECands.begin(); ECItr != RPCECands.end(); ++ECItr) {
0131       if (!ECItr->empty()) {
0132         ++nRPCTrackEndcap;
0133       }
0134     }
0135   }
0136 
0137   int numberofDigi[3] = {0, 0, 0};
0138 
0139   RPCDigiCollection::DigiRangeIterator collectionItr;
0140   for (collectionItr = rpcdigis->begin(); collectionItr != rpcdigis->end(); ++collectionItr) {
0141     RPCDigiCollection::const_iterator digiItr;
0142     for (digiItr = ((*collectionItr).second).first; digiItr != ((*collectionItr).second).second; ++digiItr) {
0143       // strips is a list of hit strips (regardless of bx) for this roll
0144       //        int strip= (*digiItr).strip();
0145       //        strips.push_back(strip);
0146       int bx = (*digiItr).bx();
0147       rpctpgbx->Fill(bx);
0148       //
0149 
0150       if (nRPCTrackBarrel == 0 && nDTTrack != 0) {
0151         m_digiBxDT->Fill(bx);
0152       } else if (nRPCTrackBarrel != 0 && nDTTrack == 0) {
0153         m_digiBxRPCBar->Fill(bx);
0154       }
0155 
0156       if (nRPCTrackEndcap == 0 && nCSCTrack != 0) {
0157         m_digiBxCSC->Fill(bx);
0158       } else if (nRPCTrackEndcap != 0 && nCSCTrack == 0) {
0159         m_digiBxRPCEnd->Fill(bx);
0160       }
0161 
0162       if (bx == -1) {
0163         numberofDigi[0]++;
0164       }
0165       if (bx == 0) {
0166         //         sprintf(meId,"Occupancy_%s",detUnitLabel);
0167         //  meMap[meId]->Fill(strip);
0168         numberofDigi[1]++;
0169       }
0170       if (bx == 2) {
0171         numberofDigi[2]++;
0172       }
0173 
0174       //        sprintf(meId,"BXN_%s",detUnitLabel);
0175       //        meMap[meId]->Fill(bx);
0176       //        sprintf(meId,"BXN_vs_strip_%s",detUnitLabel);
0177       //        meMap[meId]->Fill(strip,bx);
0178     }
0179   }
0180 
0181   rpctpgndigi[0]->Fill(numberofDigi[0]);
0182   rpctpgndigi[1]->Fill(numberofDigi[1]);
0183   rpctpgndigi[2]->Fill(numberofDigi[2]);
0184 
0185   if (verbose_)
0186     cout << "L1TRPCTPG: end job...." << endl;
0187   LogInfo("EndJob") << "analyzed " << nev_ << " events";
0188 }