Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:56

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, 3, 1, 4);
0067       ugmtEMTFShowerTypeOccupancyPerBx->setAxisTitle("BX", 1);
0068       ugmtEMTFShowerTypeOccupancyPerBx->setAxisTitle("Shower type", 2);
0069       ugmtEMTFShowerTypeOccupancyPerBx->setBinLabel(IDX_LOOSE_SHOWER, "Loose", 2);
0070       ugmtEMTFShowerTypeOccupancyPerBx->setBinLabel(IDX_TIGHT_SHOWER, "Tight", 2);
0071       ugmtEMTFShowerTypeOccupancyPerBx->setBinLabel(IDX_NOMINAL_SHOWER, "Nominal", 2);
0072 
0073       ugmtEMTFShowerSectorOccupancyPerBx = ibooker.book2D(
0074           "ugmtEMTFShowerSectorOccupancyPerBx", "Shower BX occupancy per sector", 7, -3.5, 3.5, 12, 1, 13);
0075       ugmtEMTFShowerSectorOccupancyPerBx->setAxisTitle("BX", 1);
0076       ugmtEMTFShowerSectorOccupancyPerBx->setAxisTitle("Processor", 2);
0077       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(12, "+6", 2);
0078       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(11, "+5", 2);
0079       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(10, "+4", 2);
0080       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(9, "+3", 2);
0081       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(8, "+2", 2);
0082       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(7, "+1", 2);
0083       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(6, "-6", 2);
0084       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(5, "-5", 2);
0085       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(4, "-4", 2);
0086       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(3, "-3", 2);
0087       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(2, "-2", 2);
0088       ugmtEMTFShowerSectorOccupancyPerBx->setBinLabel(1, "-1", 2);
0089     }
0090   }
0091 
0092   // Subsystem Monitoring and Muon Output
0093   ibooker.setCurrentFolder(monitorDir_);
0094 
0095   if (!emul_) {
0096     ugmtBMTFBXvsProcessor =
0097         ibooker.book2D("ugmtBXvsProcessorBMTF", "uGMT BMTF Input BX vs Processor", 12, -0.5, 11.5, 5, -2.5, 2.5);
0098     ugmtBMTFBXvsProcessor->setAxisTitle("Wedge", 1);
0099     for (int bin = 1; bin <= 12; ++bin) {
0100       ugmtBMTFBXvsProcessor->setBinLabel(bin, std::to_string(bin), 1);
0101     }
0102     ugmtBMTFBXvsProcessor->setAxisTitle("BX", 2);
0103 
0104     ugmtOMTFBXvsProcessor =
0105         ibooker.book2D("ugmtBXvsProcessorOMTF", "uGMT OMTF Input BX vs Processor", 12, -0.5, 11.5, 5, -2.5, 2.5);
0106     ugmtOMTFBXvsProcessor->setAxisTitle("Sector (Detector Side)", 1);
0107     for (int bin = 1; bin <= 6; ++bin) {
0108       ugmtOMTFBXvsProcessor->setBinLabel(bin, std::to_string(7 - bin) + " (-)", 1);
0109       ugmtOMTFBXvsProcessor->setBinLabel(bin + 6, std::to_string(bin) + " (+)", 1);
0110     }
0111     ugmtOMTFBXvsProcessor->setAxisTitle("BX", 2);
0112 
0113     ugmtEMTFBXvsProcessor =
0114         ibooker.book2D("ugmtBXvsProcessorEMTF", "uGMT EMTF Input BX vs Processor", 12, -0.5, 11.5, 5, -2.5, 2.5);
0115     ugmtEMTFBXvsProcessor->setAxisTitle("Sector (Detector Side)", 1);
0116     for (int bin = 1; bin <= 6; ++bin) {
0117       ugmtEMTFBXvsProcessor->setBinLabel(bin, std::to_string(7 - bin) + " (-)", 1);
0118       ugmtEMTFBXvsProcessor->setBinLabel(bin + 6, std::to_string(bin) + " (+)", 1);
0119     }
0120     ugmtEMTFBXvsProcessor->setAxisTitle("BX", 2);
0121 
0122     ugmtBXvsLink = ibooker.book2D("ugmtBXvsLink", "uGMT BX vs Input Links", 36, 35.5, 71.5, 5, -2.5, 2.5);
0123     ugmtBXvsLink->setAxisTitle("Link", 1);
0124     for (int bin = 1; bin <= 6; ++bin) {
0125       ugmtBXvsLink->setBinLabel(bin, Form("E+%d", bin), 1);
0126       ugmtBXvsLink->setBinLabel(bin + 6, Form("O+%d", bin), 1);
0127       ugmtBXvsLink->setBinLabel(bin + 12, Form("B%d", bin), 1);
0128       ugmtBXvsLink->setBinLabel(bin + 18, Form("B%d", bin + 6), 1);
0129       ugmtBXvsLink->setBinLabel(bin + 24, Form("O-%d", bin), 1);
0130       ugmtBXvsLink->setBinLabel(bin + 30, Form("E-%d", bin), 1);
0131     }
0132     ugmtBXvsLink->setAxisTitle("BX", 2);
0133   }
0134 }
0135 
0136 void L1TStage2uGMTInputBxDistributions::analyze(const edm::Event& e, const edm::EventSetup& c) {
0137   if (verbose_)
0138     edm::LogInfo("L1TStage2uGMTInputBxDistributions") << "L1TStage2uGMTInputBxDistributions: analyze..." << std::endl;
0139 
0140   if (!emul_) {
0141     edm::Handle<l1t::RegionalMuonCandBxCollection> BMTFBxCollection;
0142     e.getByToken(ugmtBMTFToken_, BMTFBxCollection);
0143 
0144     for (int itBX = BMTFBxCollection->getFirstBX(); itBX <= BMTFBxCollection->getLastBX(); ++itBX) {
0145       for (l1t::RegionalMuonCandBxCollection::const_iterator BMTF = BMTFBxCollection->begin(itBX);
0146            BMTF != BMTFBxCollection->end(itBX);
0147            ++BMTF) {
0148         ugmtBMTFBX->Fill(itBX);
0149 
0150         ugmtBMTFBXvsProcessor->Fill(BMTF->processor(), itBX);
0151         ugmtBXvsLink->Fill(BMTF->link(), itBX);
0152       }
0153     }
0154 
0155     edm::Handle<l1t::RegionalMuonCandBxCollection> OMTFBxCollection;
0156     e.getByToken(ugmtOMTFToken_, OMTFBxCollection);
0157 
0158     for (int itBX = OMTFBxCollection->getFirstBX(); itBX <= OMTFBxCollection->getLastBX(); ++itBX) {
0159       for (l1t::RegionalMuonCandBxCollection::const_iterator OMTF = OMTFBxCollection->begin(itBX);
0160            OMTF != OMTFBxCollection->end(itBX);
0161            ++OMTF) {
0162         ugmtOMTFBX->Fill(itBX);
0163 
0164         l1t::tftype trackFinderType = OMTF->trackFinderType();
0165 
0166         if (trackFinderType == l1t::omtf_neg) {
0167           ugmtOMTFBXvsProcessor->Fill(5 - OMTF->processor(), itBX);
0168         } else {
0169           ugmtOMTFBXvsProcessor->Fill(OMTF->processor() + 6, itBX);
0170         }
0171 
0172         ugmtBXvsLink->Fill(OMTF->link(), itBX);
0173       }
0174     }
0175 
0176     edm::Handle<l1t::RegionalMuonCandBxCollection> EMTFBxCollection;
0177     e.getByToken(ugmtEMTFToken_, EMTFBxCollection);
0178 
0179     for (int itBX = EMTFBxCollection->getFirstBX(); itBX <= EMTFBxCollection->getLastBX(); ++itBX) {
0180       for (l1t::RegionalMuonCandBxCollection::const_iterator EMTF = EMTFBxCollection->begin(itBX);
0181            EMTF != EMTFBxCollection->end(itBX);
0182            ++EMTF) {
0183         ugmtEMTFBX->Fill(itBX);
0184 
0185         l1t::tftype trackFinderType = EMTF->trackFinderType();
0186 
0187         if (trackFinderType == l1t::emtf_neg) {
0188           ugmtEMTFBXvsProcessor->Fill(5 - EMTF->processor(), itBX);
0189         } else {
0190           ugmtEMTFBXvsProcessor->Fill(EMTF->processor() + 6, itBX);
0191         }
0192 
0193         ugmtBXvsLink->Fill(EMTF->link(), itBX);
0194       }
0195     }
0196 
0197     // Fill shower plots
0198     if (hadronicShowers_) {
0199       edm::Handle<l1t::RegionalMuonShowerBxCollection> EMTFShowersBxCollection;
0200       e.getByToken(ugmtEMTFShowerToken_, EMTFShowersBxCollection);
0201 
0202       for (int itBX = EMTFShowersBxCollection->getFirstBX(); itBX <= EMTFShowersBxCollection->getLastBX(); ++itBX) {
0203         for (l1t::RegionalMuonShowerBxCollection::const_iterator shower = EMTFShowersBxCollection->begin(itBX);
0204              shower != EMTFShowersBxCollection->end(itBX);
0205              ++shower) {
0206           if (not shower->isValid()) {
0207             continue;
0208           }
0209           if (shower->isOneNominalInTime()) {
0210             ugmtEMTFShowerSectorOccupancyPerBx->Fill(
0211                 itBX, shower->processor() + 1 + (shower->trackFinderType() == l1t::tftype::emtf_pos ? 6 : 0));
0212             ugmtEMTFShowerTypeOccupancyPerBx->Fill(itBX, IDX_NOMINAL_SHOWER);
0213           }
0214           if (shower->isOneTightInTime()) {
0215             ugmtEMTFShowerSectorOccupancyPerBx->Fill(
0216                 itBX, shower->processor() + 1 + (shower->trackFinderType() == l1t::tftype::emtf_pos ? 6 : 0));
0217             ugmtEMTFShowerTypeOccupancyPerBx->Fill(itBX, IDX_TIGHT_SHOWER);
0218           }
0219           if (shower->isOneLooseInTime()) {
0220             ugmtEMTFShowerSectorOccupancyPerBx->Fill(
0221                 itBX, shower->processor() + 1 + (shower->trackFinderType() == l1t::tftype::emtf_pos ? 6 : 0));
0222             ugmtEMTFShowerTypeOccupancyPerBx->Fill(itBX, IDX_LOOSE_SHOWER);
0223           }
0224         }
0225       }
0226     }
0227   }
0228 }