Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:10:45

0001 /**
0002  * \class L1TStage2uGT
0003  *
0004  * Description: DQM for L1 Micro Global Trigger.
0005  *
0006  * \author Mateusz Zarucki 2016
0007  * \author J. Berryhill, I. Mikulec
0008  * \author Vasile Mihai Ghete - HEPHY Vienna
0009  *
0010  */
0011 
0012 #include "DQM/L1TMonitor/interface/L1TStage2uGT.h"
0013 
0014 // Constructor
0015 L1TStage2uGT::L1TStage2uGT(const edm::ParameterSet& params)
0016     : l1tStage2uGtSource_(consumes<GlobalAlgBlkBxCollection>(params.getParameter<edm::InputTag>("l1tStage2uGtSource"))),
0017       monitorDir_(params.getUntrackedParameter<std::string>("monitorDir", "")),
0018       verbose_(params.getUntrackedParameter<bool>("verbose", false)),
0019       gtUtil_(new l1t::L1TGlobalUtil(params,
0020                                      consumesCollector(),
0021                                      *this,
0022                                      params.getParameter<edm::InputTag>("l1tStage2uGtSource"),
0023                                      params.getParameter<edm::InputTag>("l1tStage2uGtSource"))),
0024       numAlgs_(0) {}
0025 
0026 // Destructor
0027 L1TStage2uGT::~L1TStage2uGT() {}
0028 
0029 void L1TStage2uGT::dqmBeginRun(edm::Run const& iRun, edm::EventSetup const& evtSetup) {
0030   // Get the trigger menu information
0031   gtUtil_->retrieveL1Setup(evtSetup);
0032   // Find the number of algos defined
0033   numAlgs_ = static_cast<int>(gtUtil_->decisionsInitial().size());
0034 }
0035 
0036 void L1TStage2uGT::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const& evtSetup) {
0037   // Book histograms
0038   const int numLS = 2000;
0039   const double numLS_d = static_cast<double>(numLS);
0040   const double numAlgs_d = static_cast<double>(numAlgs_);
0041   const int numBx = 3564;
0042   const double numBx_d = static_cast<double>(numBx);
0043 
0044   ibooker.setCurrentFolder(monitorDir_);
0045 
0046   // Algorithm bits
0047   algoBits_before_bxmask_ = ibooker.book1D(
0048       "algoBits_before_bxmask", "uGT: Algorithm Trigger Bits (before AlgoBX mask)", numAlgs_, -0.5, numAlgs_d - 0.5);
0049   algoBits_before_bxmask_->setAxisTitle("Algorithm Trigger Bits (before AlgoBX mask)", 1);
0050 
0051   algoBits_before_prescale_ = ibooker.book1D(
0052       "algoBits_before_prescale", "uGT: Algorithm Trigger Bits (before prescale)", numAlgs_, -0.5, numAlgs_d - 0.5);
0053   algoBits_before_prescale_->setAxisTitle("Algorithm Trigger Bits (before prescale)", 1);
0054 
0055   algoBits_after_prescale_ = ibooker.book1D(
0056       "algoBits_after_prescale", "uGT: Algorithm Trigger Bits (after prescale)", numAlgs_, -0.5, numAlgs_d - 0.5);
0057   algoBits_after_prescale_->setAxisTitle("Algorithm Trigger Bits (after prescale)", 1);
0058 
0059   // Algorithm bits correlation
0060   algoBits_before_bxmask_corr_ = ibooker.book2D("algoBits_before_bxmask_corr",
0061                                                 "uGT: Algorithm Trigger Bit Correlation (before AlgoBX mask)",
0062                                                 numAlgs_,
0063                                                 -0.5,
0064                                                 numAlgs_d - 0.5,
0065                                                 numAlgs_,
0066                                                 -0.5,
0067                                                 numAlgs_d - 0.5);
0068   algoBits_before_bxmask_corr_->setAxisTitle("Algorithm Trigger Bits (before AlgoBX mask)", 1);
0069   algoBits_before_bxmask_corr_->setAxisTitle("Algorithm Trigger Bits (before AlgoBX mask)", 2);
0070 
0071   algoBits_before_prescale_corr_ = ibooker.book2D("algoBits_before_prescale_corr",
0072                                                   "uGT: Algorithm Trigger Bit Correlation (before prescale)",
0073                                                   numAlgs_,
0074                                                   -0.5,
0075                                                   numAlgs_d - 0.5,
0076                                                   numAlgs_,
0077                                                   -0.5,
0078                                                   numAlgs_d - 0.5);
0079   algoBits_before_prescale_corr_->setAxisTitle("Algorithm Trigger Bits (before prescale)", 1);
0080   algoBits_before_prescale_corr_->setAxisTitle("Algorithm Trigger Bits (before prescale)", 2);
0081 
0082   algoBits_after_prescale_corr_ = ibooker.book2D("algoBits_after_prescale_corr",
0083                                                  "uGT: Algorithm Trigger Bit Correlation (after prescale)",
0084                                                  numAlgs_,
0085                                                  -0.5,
0086                                                  numAlgs_d - 0.5,
0087                                                  numAlgs_,
0088                                                  -0.5,
0089                                                  numAlgs_d - 0.5);
0090   algoBits_after_prescale_corr_->setAxisTitle("Algorithm Trigger Bits (after prescale)", 1);
0091   algoBits_after_prescale_corr_->setAxisTitle("Algorithm Trigger Bits (after prescale)", 2);
0092 
0093   // Algorithm bits vs global BX number
0094   algoBits_before_bxmask_bx_global_ =
0095       ibooker.book2D("algoBits_before_bxmask_bx_global",
0096                      "uGT: Algorithm Trigger Bits (before AlgoBX mask) vs. Global BX Number",
0097                      numBx,
0098                      0.5,
0099                      numBx_d + 0.5,
0100                      numAlgs_,
0101                      -0.5,
0102                      numAlgs_d - 0.5);
0103   algoBits_before_bxmask_bx_global_->setAxisTitle("Global Bunch Crossing Number", 1);
0104   algoBits_before_bxmask_bx_global_->setAxisTitle("Algorithm Trigger Bits (before AlgoBX mask)", 2);
0105 
0106   algoBits_before_prescale_bx_global_ =
0107       ibooker.book2D("algoBits_before_prescale_bx_global",
0108                      "uGT: Algorithm Trigger Bits (before prescale) vs. Global BX Number",
0109                      numBx,
0110                      0.5,
0111                      numBx_d + 0.5,
0112                      numAlgs_,
0113                      -0.5,
0114                      numAlgs_d - 0.5);
0115   algoBits_before_prescale_bx_global_->setAxisTitle("Global Bunch Crossing Number", 1);
0116   algoBits_before_prescale_bx_global_->setAxisTitle("Algorithm Trigger Bits (before prescale)", 2);
0117 
0118   algoBits_after_prescale_bx_global_ =
0119       ibooker.book2D("algoBits_after_prescale_bx_global",
0120                      "uGT: Algorithm Trigger Bits (after prescale) vs. Global BX Number",
0121                      numBx,
0122                      0.5,
0123                      numBx_d + 0.5,
0124                      numAlgs_,
0125                      -0.5,
0126                      numAlgs_d - 0.5);
0127   algoBits_after_prescale_bx_global_->setAxisTitle("Global Bunch Crossing Number", 1);
0128   algoBits_after_prescale_bx_global_->setAxisTitle("Algorithm Trigger Bits (after prescale)", 2);
0129 
0130   // Algorithm bits vs BX number in event
0131   algoBits_before_bxmask_bx_inEvt_ =
0132       ibooker.book2D("algoBits_before_bxmask_bx_inEvt",
0133                      "uGT: Algorithm Trigger Bits (before AlgoBX mask) vs. BX Number in Event",
0134                      5,
0135                      -2.5,
0136                      2.5,
0137                      numAlgs_,
0138                      -0.5,
0139                      numAlgs_d - 0.5);
0140   algoBits_before_bxmask_bx_inEvt_->setAxisTitle("Bunch Crossing Number in Event", 1);
0141   algoBits_before_bxmask_bx_inEvt_->setAxisTitle("Algorithm Trigger Bits (before AlgoBX mask)", 2);
0142 
0143   algoBits_before_prescale_bx_inEvt_ =
0144       ibooker.book2D("algoBits_before_prescale_bx_inEvt",
0145                      "uGT: Algorithm Trigger Bits (before prescale) vs. BX Number in Event",
0146                      5,
0147                      -2.5,
0148                      2.5,
0149                      numAlgs_,
0150                      -0.5,
0151                      numAlgs_d - 0.5);
0152   algoBits_before_prescale_bx_inEvt_->setAxisTitle("Bunch Crossing Number in Event", 1);
0153   algoBits_before_prescale_bx_inEvt_->setAxisTitle("Algorithm Trigger Bits (before prescale)", 2);
0154 
0155   algoBits_after_prescale_bx_inEvt_ =
0156       ibooker.book2D("algoBits_after_prescale_bx_inEvt",
0157                      "uGT: Algorithm Trigger Bits (after prescale) vs. BX Number in Event",
0158                      5,
0159                      -2.5,
0160                      2.5,
0161                      numAlgs_,
0162                      -0.5,
0163                      numAlgs_d - 0.5);
0164   algoBits_after_prescale_bx_inEvt_->setAxisTitle("Bunch Crossing Number in Event", 1);
0165   algoBits_after_prescale_bx_inEvt_->setAxisTitle("Algorithm Trigger Bits (after prescale)", 2);
0166 
0167   // Algorithm bits vs LS
0168   algoBits_before_bxmask_lumi_ = ibooker.book2D("algoBits_before_bxmask_lumi",
0169                                                 "uGT: Algorithm Trigger Bits (before AlgoBX mask) vs. LS",
0170                                                 numLS,
0171                                                 0.,
0172                                                 numLS_d,
0173                                                 numAlgs_,
0174                                                 -0.5,
0175                                                 numAlgs_d - 0.5);
0176   algoBits_before_bxmask_lumi_->setAxisTitle("Luminosity Segment", 1);
0177   algoBits_before_bxmask_lumi_->setAxisTitle("Algorithm Trigger Bits (before AlgoBX mask)", 2);
0178 
0179   algoBits_before_prescale_lumi_ = ibooker.book2D("algoBits_before_prescale_lumi",
0180                                                   "uGT: Algorithm Trigger Bits (before prescale) vs. LS",
0181                                                   numLS,
0182                                                   0.,
0183                                                   numLS_d,
0184                                                   numAlgs_,
0185                                                   -0.5,
0186                                                   numAlgs_d - 0.5);
0187   algoBits_before_prescale_lumi_->setAxisTitle("Luminosity Segment", 1);
0188   algoBits_before_prescale_lumi_->setAxisTitle("Algorithm Trigger Bits (before prescale)", 2);
0189 
0190   algoBits_after_prescale_lumi_ = ibooker.book2D("algoBits_after_prescale_lumi",
0191                                                  "uGT: Algorithm Trigger Bits (after prescale) vs. LS",
0192                                                  numLS,
0193                                                  0.,
0194                                                  numLS_d,
0195                                                  numAlgs_,
0196                                                  -0.5,
0197                                                  numAlgs_d - 0.5);
0198   algoBits_after_prescale_lumi_->setAxisTitle("Luminosity Segment", 1);
0199   algoBits_after_prescale_lumi_->setAxisTitle("Algorithm Trigger Bits (after prescale)", 2);
0200 
0201   // Prescale factor index
0202   prescaleFactorSet_ =
0203       ibooker.book2D("prescaleFactorSet", "uGT: Index of Prescale Factor Set vs. LS", numLS, 0., numLS_d, 25, 0., 25.);
0204   prescaleFactorSet_->setAxisTitle("Luminosity Segment", 1);
0205   prescaleFactorSet_->setAxisTitle("Prescale Factor Set Index", 2);
0206 }
0207 
0208 void L1TStage2uGT::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
0209   if (verbose_) {
0210     edm::LogInfo("L1TStage2uGT") << "L1TStage2uGT DQM: Analyzing.." << std::endl;
0211   }
0212 
0213   // Get standard event parameters
0214   int lumi = evt.luminosityBlock();
0215   int bx = evt.bunchCrossing();
0216 
0217   // Open uGT readout record
0218   edm::Handle<GlobalAlgBlkBxCollection> uGtAlgs;
0219   evt.getByToken(l1tStage2uGtSource_, uGtAlgs);
0220 
0221   if (!uGtAlgs.isValid()) {
0222     edm::LogInfo("L1TStage2uGT") << "Cannot find uGT readout record.";
0223     return;
0224   }
0225 
0226   //algoBits_->Fill(-1.); // fill underflow to normalize // FIXME: needed?
0227   for (int ibx = uGtAlgs->getFirstBX(); ibx <= uGtAlgs->getLastBX(); ++ibx) {
0228     for (auto itr = uGtAlgs->begin(ibx); itr != uGtAlgs->end(ibx); ++itr) {  // FIXME: redundant loop?
0229 
0230       // Fills prescale factor set histogram
0231       prescaleFactorSet_->Fill(lumi, itr->getPreScColumn());
0232 
0233       // Fills algorithm bits histograms
0234       for (int algoBit = 0; algoBit < numAlgs_; ++algoBit) {
0235         // Algorithm bits before AlgoBX mask
0236         if (itr->getAlgoDecisionInitial(algoBit)) {
0237           algoBits_before_bxmask_->Fill(algoBit);
0238           algoBits_before_bxmask_lumi_->Fill(lumi, algoBit);
0239           algoBits_before_bxmask_bx_inEvt_->Fill(ibx, algoBit);  // FIXME: or itr->getbxInEventNr()/getbxNr()?
0240           algoBits_before_bxmask_bx_global_->Fill(bx + ibx, algoBit);
0241 
0242           for (int algoBit2 = 0; algoBit2 < numAlgs_; ++algoBit2) {
0243             if (itr->getAlgoDecisionInitial(algoBit2)) {
0244               algoBits_before_bxmask_corr_->Fill(algoBit, algoBit2);
0245             }
0246           }
0247         }
0248 
0249         // Algorithm bits before prescale
0250         if (itr->getAlgoDecisionInterm(algoBit)) {
0251           algoBits_before_prescale_->Fill(algoBit);
0252           algoBits_before_prescale_lumi_->Fill(lumi, algoBit);
0253           algoBits_before_prescale_bx_inEvt_->Fill(ibx, algoBit);
0254           algoBits_before_prescale_bx_global_->Fill(bx + ibx, algoBit);
0255 
0256           for (int algoBit2 = 0; algoBit2 < numAlgs_; ++algoBit2) {
0257             if (itr->getAlgoDecisionInterm(algoBit2)) {
0258               algoBits_before_prescale_corr_->Fill(algoBit, algoBit2);
0259             }
0260           }
0261         }
0262 
0263         // Algorithm bits after prescale
0264         if (itr->getAlgoDecisionFinal(algoBit)) {
0265           algoBits_after_prescale_->Fill(algoBit);
0266           algoBits_after_prescale_lumi_->Fill(lumi, algoBit);
0267           algoBits_after_prescale_bx_inEvt_->Fill(ibx, algoBit);
0268           algoBits_after_prescale_bx_global_->Fill(bx + ibx, algoBit);
0269 
0270           for (int algoBit2 = 0; algoBit2 < numAlgs_; ++algoBit2) {
0271             if (itr->getAlgoDecisionFinal(algoBit2)) {
0272               algoBits_after_prescale_corr_->Fill(algoBit, algoBit2);
0273             }
0274           }
0275         }
0276       }
0277     }
0278   }
0279 }
0280 
0281 // End section