Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-04 01:25:52

0001 #include "DQM/L1TMonitor/interface/L1TStage2uGMTInputBxDistributions.h"
0002 
0003 L1TStage2uGMTInputBxDistributions::L1TStage2uGMTInputBxDistributions(const edm::ParameterSet& ps)
0004     : ugmtMuonToken_(consumes<l1t::MuonBxCollection>(ps.getParameter<edm::InputTag>("muonProducer"))),
0005       ugmtMuonShowerToken_(consumes<l1t::MuonShowerBxCollection>(ps.getParameter<edm::InputTag>("muonShowerProducer"))),
0006       monitorDir_(ps.getUntrackedParameter<std::string>("monitorDir")),
0007       emul_(ps.getUntrackedParameter<bool>("emulator")),
0008       verbose_(ps.getUntrackedParameter<bool>("verbose")),
0009       hadronicShowers_(ps.getUntrackedParameter<bool>("hadronicShowers")) {
0010   if (!emul_) {
0011     ugmtBMTFToken_ = consumes<l1t::RegionalMuonCandBxCollection>(ps.getParameter<edm::InputTag>("bmtfProducer"));
0012     ugmtOMTFToken_ = consumes<l1t::RegionalMuonCandBxCollection>(ps.getParameter<edm::InputTag>("omtfProducer"));
0013     ugmtEMTFToken_ = consumes<l1t::RegionalMuonCandBxCollection>(ps.getParameter<edm::InputTag>("emtfProducer"));
0014     ugmtEMTFShowerToken_ =
0015         consumes<l1t::RegionalMuonShowerBxCollection>(ps.getParameter<edm::InputTag>("emtfShowerProducer"));
0016   }
0017 }
0018 
0019 L1TStage2uGMTInputBxDistributions::~L1TStage2uGMTInputBxDistributions() {}
0020 
0021 void L1TStage2uGMTInputBxDistributions::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0022   edm::ParameterSetDescription desc;
0023   desc.add<edm::InputTag>("muonProducer")->setComment("uGMT output muons.");
0024 
0025   desc.add<edm::InputTag>("bmtfProducer")->setComment("RegionalMuonCands from BMTF.");
0026   desc.add<edm::InputTag>("omtfProducer")->setComment("RegionalMuonCands from OMTF.");
0027   desc.add<edm::InputTag>("emtfProducer")->setComment("RegionalMuonCands from EMTF.");
0028   desc.add<edm::InputTag>("muonShowerProducer")->setComment("uGMT output showers.");
0029   desc.add<edm::InputTag>("emtfShowerProducer")->setComment("RegionalMuonShowers from EMTF.");
0030   desc.addUntracked<std::string>("monitorDir", "")
0031       ->setComment("Target directory in the DQM file. Will be created if not existing.");
0032   desc.addUntracked<bool>("emulator", false)
0033       ->setComment("Create histograms for muonProducer input only. xmtfProducer inputs are ignored.");
0034   desc.addUntracked<bool>("verbose", false);
0035   desc.addUntracked<bool>("hadronicShowers", false);
0036   descriptions.add("l1tStage2uGMTInputBxDistributions", desc);
0037 }
0038 
0039 void L1TStage2uGMTInputBxDistributions::bookHistograms(DQMStore::IBooker& ibooker,
0040                                                        const edm::Run&,
0041                                                        const edm::EventSetup&) {
0042   if (!emul_) {
0043     // BMTF Input
0044     ibooker.setCurrentFolder(monitorDir_ + "/BMTFInput");
0045 
0046     ugmtBMTFBX = ibooker.book1D("ugmtBMTFBX", "uGMT BMTF Input BX", 7, -3.5, 3.5);
0047     ugmtBMTFBX->setAxisTitle("BX", 1);
0048 
0049     // OMTF Input
0050     ibooker.setCurrentFolder(monitorDir_ + "/OMTFInput");
0051 
0052     ugmtOMTFBX = ibooker.book1D("ugmtOMTFBX", "uGMT OMTF Input BX", 7, -3.5, 3.5);
0053     ugmtOMTFBX->setAxisTitle("BX", 1);
0054 
0055     // EMTF Input
0056     ibooker.setCurrentFolder(monitorDir_ + "/EMTFInput");
0057 
0058     ugmtEMTFBX = ibooker.book1D("ugmtEMTFBX", "uGMT EMTF Input BX", 7, -3.5, 3.5);
0059     ugmtEMTFBX->setAxisTitle("BX", 1);
0060 
0061     // EMTF muon showers
0062     if (hadronicShowers_) {
0063       ibooker.setCurrentFolder(monitorDir_ + "/EMTFInput/Muon showers");
0064 
0065       ugmtEMTFShowerTypeOccupancyPerBx =
0066           ibooker.book2D("ugmtEMTFShowerTypeOccupancyPerBx", "Shower type occupancy per BX", 7, -3.5, 3.5, 2, 1, 3);
0067       ugmtEMTFShowerTypeOccupancyPerBx->setAxisTitle("BX", 1);
0068       ugmtEMTFShowerTypeOccupancyPerBx->setAxisTitle("Shower type", 2);
0069       ugmtEMTFShowerTypeOccupancyPerBx->setBinLabel(IDX_TIGHT_SHOWER, "Tight", 2);
0070       ugmtEMTFShowerTypeOccupancyPerBx->setBinLabel(IDX_NOMINAL_SHOWER, "Nominal", 2);
0071 
0072       ugmtEMTFShowerSectorOccupancyPerBx = ibooker.book2D(
0073           "ugmtEMTFShowerSectorOccupancyPerBx", "Shower BX occupancy per sector", 7, -3.5, 3.5, 12, 1, 13);
0074       ugmtEMTFShowerSectorOccupancyPerBx->setAxisTitle("BX", 1);
0075       ugmtEMTFShowerSectorOccupancyPerBx->setAxisTitle("Processor", 2);
0076       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(12, "+6", 2);
0077       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(11, "+5", 2);
0078       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(10, "+4", 2);
0079       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(9, "+3", 2);
0080       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(8, "+2", 2);
0081       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(7, "+1", 2);
0082       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(6, "-6", 2);
0083       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(5, "-5", 2);
0084       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(4, "-4", 2);
0085       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(3, "-3", 2);
0086       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(2, "-2", 2);
0087       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(1, "-1", 2);
0088     }
0089   }
0090 
0091   // Subsystem Monitoring and Muon Output
0092   ibooker.setCurrentFolder(monitorDir_);
0093 
0094   if (!emul_) {
0095     ugmtBMTFBXvsProcessor =
0096         ibooker.book2D("ugmtBXvsProcessorBMTF", "uGMT BMTF Input BX vs Processor", 12, -0.5, 11.5, 5, -2.5, 2.5);
0097     ugmtBMTFBXvsProcessor->setAxisTitle("Wedge", 1);
0098     for (int bin = 1; bin <= 12; ++bin) {
0099       ugmtBMTFBXvsProcessor->setBinLabel(bin, std::to_string(bin), 1);
0100     }
0101     ugmtBMTFBXvsProcessor->setAxisTitle("BX", 2);
0102 
0103     ugmtOMTFBXvsProcessor =
0104         ibooker.book2D("ugmtBXvsProcessorOMTF", "uGMT OMTF Input BX vs Processor", 12, -0.5, 11.5, 5, -2.5, 2.5);
0105     ugmtOMTFBXvsProcessor->setAxisTitle("Sector (Detector Side)", 1);
0106     for (int bin = 1; bin <= 6; ++bin) {
0107       ugmtOMTFBXvsProcessor->setBinLabel(bin, std::to_string(7 - bin) + " (-)", 1);
0108       ugmtOMTFBXvsProcessor->setBinLabel(bin + 6, std::to_string(bin) + " (+)", 1);
0109     }
0110     ugmtOMTFBXvsProcessor->setAxisTitle("BX", 2);
0111 
0112     ugmtEMTFBXvsProcessor =
0113         ibooker.book2D("ugmtBXvsProcessorEMTF", "uGMT EMTF Input BX vs Processor", 12, -0.5, 11.5, 5, -2.5, 2.5);
0114     ugmtEMTFBXvsProcessor->setAxisTitle("Sector (Detector Side)", 1);
0115     for (int bin = 1; bin <= 6; ++bin) {
0116       ugmtEMTFBXvsProcessor->setBinLabel(bin, std::to_string(7 - bin) + " (-)", 1);
0117       ugmtEMTFBXvsProcessor->setBinLabel(bin + 6, std::to_string(bin) + " (+)", 1);
0118     }
0119     ugmtEMTFBXvsProcessor->setAxisTitle("BX", 2);
0120 
0121     ugmtBXvsLink = ibooker.book2D("ugmtBXvsLink", "uGMT BX vs Input Links", 36, 35.5, 71.5, 5, -2.5, 2.5);
0122     ugmtBXvsLink->setAxisTitle("Link", 1);
0123     for (int bin = 1; bin <= 6; ++bin) {
0124       ugmtBXvsLink->setBinLabel(bin, Form("E+%d", bin), 1);
0125       ugmtBXvsLink->setBinLabel(bin + 6, Form("O+%d", bin), 1);
0126       ugmtBXvsLink->setBinLabel(bin + 12, Form("B%d", bin), 1);
0127       ugmtBXvsLink->setBinLabel(bin + 18, Form("B%d", bin + 6), 1);
0128       ugmtBXvsLink->setBinLabel(bin + 24, Form("O-%d", bin), 1);
0129       ugmtBXvsLink->setBinLabel(bin + 30, Form("E-%d", bin), 1);
0130     }
0131     ugmtBXvsLink->setAxisTitle("BX", 2);
0132   }
0133 }
0134 
0135 void L1TStage2uGMTInputBxDistributions::analyze(const edm::Event& e, const edm::EventSetup& c) {
0136   if (verbose_)
0137     edm::LogInfo("L1TStage2uGMTInputBxDistributions") << "L1TStage2uGMTInputBxDistributions: analyze..." << std::endl;
0138 
0139   if (!emul_) {
0140     edm::Handle<l1t::RegionalMuonCandBxCollection> BMTFBxCollection;
0141     e.getByToken(ugmtBMTFToken_, BMTFBxCollection);
0142 
0143     for (int itBX = BMTFBxCollection->getFirstBX(); itBX <= BMTFBxCollection->getLastBX(); ++itBX) {
0144       for (l1t::RegionalMuonCandBxCollection::const_iterator BMTF = BMTFBxCollection->begin(itBX);
0145            BMTF != BMTFBxCollection->end(itBX);
0146            ++BMTF) {
0147         ugmtBMTFBX->Fill(itBX);
0148 
0149         ugmtBMTFBXvsProcessor->Fill(BMTF->processor(), itBX);
0150         ugmtBXvsLink->Fill(BMTF->link(), itBX);
0151       }
0152     }
0153 
0154     edm::Handle<l1t::RegionalMuonCandBxCollection> OMTFBxCollection;
0155     e.getByToken(ugmtOMTFToken_, OMTFBxCollection);
0156 
0157     for (int itBX = OMTFBxCollection->getFirstBX(); itBX <= OMTFBxCollection->getLastBX(); ++itBX) {
0158       for (l1t::RegionalMuonCandBxCollection::const_iterator OMTF = OMTFBxCollection->begin(itBX);
0159            OMTF != OMTFBxCollection->end(itBX);
0160            ++OMTF) {
0161         ugmtOMTFBX->Fill(itBX);
0162 
0163         l1t::tftype trackFinderType = OMTF->trackFinderType();
0164 
0165         if (trackFinderType == l1t::omtf_neg) {
0166           ugmtOMTFBXvsProcessor->Fill(5 - OMTF->processor(), itBX);
0167         } else {
0168           ugmtOMTFBXvsProcessor->Fill(OMTF->processor() + 6, itBX);
0169         }
0170 
0171         ugmtBXvsLink->Fill(OMTF->link(), itBX);
0172       }
0173     }
0174 
0175     edm::Handle<l1t::RegionalMuonCandBxCollection> EMTFBxCollection;
0176     e.getByToken(ugmtEMTFToken_, EMTFBxCollection);
0177 
0178     for (int itBX = EMTFBxCollection->getFirstBX(); itBX <= EMTFBxCollection->getLastBX(); ++itBX) {
0179       for (l1t::RegionalMuonCandBxCollection::const_iterator EMTF = EMTFBxCollection->begin(itBX);
0180            EMTF != EMTFBxCollection->end(itBX);
0181            ++EMTF) {
0182         ugmtEMTFBX->Fill(itBX);
0183 
0184         l1t::tftype trackFinderType = EMTF->trackFinderType();
0185 
0186         if (trackFinderType == l1t::emtf_neg) {
0187           ugmtEMTFBXvsProcessor->Fill(5 - EMTF->processor(), itBX);
0188         } else {
0189           ugmtEMTFBXvsProcessor->Fill(EMTF->processor() + 6, itBX);
0190         }
0191 
0192         ugmtBXvsLink->Fill(EMTF->link(), itBX);
0193       }
0194     }
0195 
0196     // Fill shower plots
0197     if (hadronicShowers_) {
0198       edm::Handle<l1t::RegionalMuonShowerBxCollection> EMTFShowersBxCollection;
0199       e.getByToken(ugmtEMTFShowerToken_, EMTFShowersBxCollection);
0200 
0201       for (int itBX = EMTFShowersBxCollection->getFirstBX(); itBX <= EMTFShowersBxCollection->getLastBX(); ++itBX) {
0202         for (l1t::RegionalMuonShowerBxCollection::const_iterator shower = EMTFShowersBxCollection->begin(itBX);
0203              shower != EMTFShowersBxCollection->end(itBX);
0204              ++shower) {
0205           if (not shower->isValid()) {
0206             continue;
0207           }
0208           if (shower->isOneNominalInTime()) {
0209             ugmtEMTFShowerSectorOccupancyPerBx->Fill(
0210                 itBX, shower->processor() + 1 + (shower->trackFinderType() == l1t::tftype::emtf_pos ? 6 : 0));
0211             ugmtEMTFShowerTypeOccupancyPerBx->Fill(itBX, IDX_NOMINAL_SHOWER);
0212           }
0213           if (shower->isOneTightInTime()) {
0214             ugmtEMTFShowerSectorOccupancyPerBx->Fill(
0215                 itBX, shower->processor() + 1 + (shower->trackFinderType() == l1t::tftype::emtf_pos ? 6 : 0));
0216             ugmtEMTFShowerTypeOccupancyPerBx->Fill(itBX, IDX_TIGHT_SHOWER);
0217           }
0218         }
0219       }
0220     }
0221   }
0222 }