Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
/**
 * \class L1TStage2uGT
 *
 * Description: DQM for L1 Micro Global Trigger.
 *
 * \author Mateusz Zarucki 2016
 * \author J. Berryhill, I. Mikulec
 * \author Vasile Mihai Ghete - HEPHY Vienna
 *
 */

#include "DQM/L1TMonitor/interface/L1TStage2uGT.h"

// Constructor
L1TStage2uGT::L1TStage2uGT(const edm::ParameterSet& params)
    : l1tStage2uGtSource_(consumes<GlobalAlgBlkBxCollection>(params.getParameter<edm::InputTag>("l1tStage2uGtSource"))),
      monitorDir_(params.getUntrackedParameter<std::string>("monitorDir", "")),
      verbose_(params.getUntrackedParameter<bool>("verbose", false)),
      gtUtil_(new l1t::L1TGlobalUtil(params,
                                     consumesCollector(),
                                     *this,
                                     params.getParameter<edm::InputTag>("l1tStage2uGtSource"),
                                     params.getParameter<edm::InputTag>("l1tStage2uGtSource"))),
      numAlgs_(0) {}

// Destructor
L1TStage2uGT::~L1TStage2uGT() {}

void L1TStage2uGT::dqmBeginRun(edm::Run const& iRun, edm::EventSetup const& evtSetup) {
  // Get the trigger menu information
  gtUtil_->retrieveL1Setup(evtSetup);
  // Find the number of algos defined
  numAlgs_ = static_cast<int>(gtUtil_->decisionsInitial().size());
}

void L1TStage2uGT::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const& evtSetup) {
  // Book histograms
  const int numLS = 2000;
  const double numLS_d = static_cast<double>(numLS);
  const double numAlgs_d = static_cast<double>(numAlgs_);
  const int numBx = 3564;
  const double numBx_d = static_cast<double>(numBx);

  ibooker.setCurrentFolder(monitorDir_);

  // Algorithm bits
  algoBits_before_bxmask_ = ibooker.book1D(
      "algoBits_before_bxmask", "uGT: Algorithm Trigger Bits (before AlgoBX mask)", numAlgs_, -0.5, numAlgs_d - 0.5);
  algoBits_before_bxmask_->setAxisTitle("Algorithm Trigger Bits (before AlgoBX mask)", 1);

  algoBits_before_prescale_ = ibooker.book1D(
      "algoBits_before_prescale", "uGT: Algorithm Trigger Bits (before prescale)", numAlgs_, -0.5, numAlgs_d - 0.5);
  algoBits_before_prescale_->setAxisTitle("Algorithm Trigger Bits (before prescale)", 1);

  algoBits_after_prescale_ = ibooker.book1D(
      "algoBits_after_prescale", "uGT: Algorithm Trigger Bits (after prescale)", numAlgs_, -0.5, numAlgs_d - 0.5);
  algoBits_after_prescale_->setAxisTitle("Algorithm Trigger Bits (after prescale)", 1);

  // Algorithm bits correlation
  algoBits_before_bxmask_corr_ = ibooker.book2D("algoBits_before_bxmask_corr",
                                                "uGT: Algorithm Trigger Bit Correlation (before AlgoBX mask)",
                                                numAlgs_,
                                                -0.5,
                                                numAlgs_d - 0.5,
                                                numAlgs_,
                                                -0.5,
                                                numAlgs_d - 0.5);
  algoBits_before_bxmask_corr_->setAxisTitle("Algorithm Trigger Bits (before AlgoBX mask)", 1);
  algoBits_before_bxmask_corr_->setAxisTitle("Algorithm Trigger Bits (before AlgoBX mask)", 2);

  algoBits_before_prescale_corr_ = ibooker.book2D("algoBits_before_prescale_corr",
                                                  "uGT: Algorithm Trigger Bit Correlation (before prescale)",
                                                  numAlgs_,
                                                  -0.5,
                                                  numAlgs_d - 0.5,
                                                  numAlgs_,
                                                  -0.5,
                                                  numAlgs_d - 0.5);
  algoBits_before_prescale_corr_->setAxisTitle("Algorithm Trigger Bits (before prescale)", 1);
  algoBits_before_prescale_corr_->setAxisTitle("Algorithm Trigger Bits (before prescale)", 2);

  algoBits_after_prescale_corr_ = ibooker.book2D("algoBits_after_prescale_corr",
                                                 "uGT: Algorithm Trigger Bit Correlation (after prescale)",
                                                 numAlgs_,
                                                 -0.5,
                                                 numAlgs_d - 0.5,
                                                 numAlgs_,
                                                 -0.5,
                                                 numAlgs_d - 0.5);
  algoBits_after_prescale_corr_->setAxisTitle("Algorithm Trigger Bits (after prescale)", 1);
  algoBits_after_prescale_corr_->setAxisTitle("Algorithm Trigger Bits (after prescale)", 2);

  // Algorithm bits vs global BX number
  algoBits_before_bxmask_bx_global_ =
      ibooker.book2D("algoBits_before_bxmask_bx_global",
                     "uGT: Algorithm Trigger Bits (before AlgoBX mask) vs. Global BX Number",
                     numBx,
                     0.5,
                     numBx_d + 0.5,
                     numAlgs_,
                     -0.5,
                     numAlgs_d - 0.5);
  algoBits_before_bxmask_bx_global_->setAxisTitle("Global Bunch Crossing Number", 1);
  algoBits_before_bxmask_bx_global_->setAxisTitle("Algorithm Trigger Bits (before AlgoBX mask)", 2);

  algoBits_before_prescale_bx_global_ =
      ibooker.book2D("algoBits_before_prescale_bx_global",
                     "uGT: Algorithm Trigger Bits (before prescale) vs. Global BX Number",
                     numBx,
                     0.5,
                     numBx_d + 0.5,
                     numAlgs_,
                     -0.5,
                     numAlgs_d - 0.5);
  algoBits_before_prescale_bx_global_->setAxisTitle("Global Bunch Crossing Number", 1);
  algoBits_before_prescale_bx_global_->setAxisTitle("Algorithm Trigger Bits (before prescale)", 2);

  algoBits_after_prescale_bx_global_ =
      ibooker.book2D("algoBits_after_prescale_bx_global",
                     "uGT: Algorithm Trigger Bits (after prescale) vs. Global BX Number",
                     numBx,
                     0.5,
                     numBx_d + 0.5,
                     numAlgs_,
                     -0.5,
                     numAlgs_d - 0.5);
  algoBits_after_prescale_bx_global_->setAxisTitle("Global Bunch Crossing Number", 1);
  algoBits_after_prescale_bx_global_->setAxisTitle("Algorithm Trigger Bits (after prescale)", 2);

  // Algorithm bits vs BX number in event
  algoBits_before_bxmask_bx_inEvt_ =
      ibooker.book2D("algoBits_before_bxmask_bx_inEvt",
                     "uGT: Algorithm Trigger Bits (before AlgoBX mask) vs. BX Number in Event",
                     5,
                     -2.5,
                     2.5,
                     numAlgs_,
                     -0.5,
                     numAlgs_d - 0.5);
  algoBits_before_bxmask_bx_inEvt_->setAxisTitle("Bunch Crossing Number in Event", 1);
  algoBits_before_bxmask_bx_inEvt_->setAxisTitle("Algorithm Trigger Bits (before AlgoBX mask)", 2);

  algoBits_before_prescale_bx_inEvt_ =
      ibooker.book2D("algoBits_before_prescale_bx_inEvt",
                     "uGT: Algorithm Trigger Bits (before prescale) vs. BX Number in Event",
                     5,
                     -2.5,
                     2.5,
                     numAlgs_,
                     -0.5,
                     numAlgs_d - 0.5);
  algoBits_before_prescale_bx_inEvt_->setAxisTitle("Bunch Crossing Number in Event", 1);
  algoBits_before_prescale_bx_inEvt_->setAxisTitle("Algorithm Trigger Bits (before prescale)", 2);

  algoBits_after_prescale_bx_inEvt_ =
      ibooker.book2D("algoBits_after_prescale_bx_inEvt",
                     "uGT: Algorithm Trigger Bits (after prescale) vs. BX Number in Event",
                     5,
                     -2.5,
                     2.5,
                     numAlgs_,
                     -0.5,
                     numAlgs_d - 0.5);
  algoBits_after_prescale_bx_inEvt_->setAxisTitle("Bunch Crossing Number in Event", 1);
  algoBits_after_prescale_bx_inEvt_->setAxisTitle("Algorithm Trigger Bits (after prescale)", 2);

  // Algorithm bits vs LS
  algoBits_before_bxmask_lumi_ = ibooker.book2D("algoBits_before_bxmask_lumi",
                                                "uGT: Algorithm Trigger Bits (before AlgoBX mask) vs. LS",
                                                numLS,
                                                0.,
                                                numLS_d,
                                                numAlgs_,
                                                -0.5,
                                                numAlgs_d - 0.5);
  algoBits_before_bxmask_lumi_->setAxisTitle("Luminosity Segment", 1);
  algoBits_before_bxmask_lumi_->setAxisTitle("Algorithm Trigger Bits (before AlgoBX mask)", 2);

  algoBits_before_prescale_lumi_ = ibooker.book2D("algoBits_before_prescale_lumi",
                                                  "uGT: Algorithm Trigger Bits (before prescale) vs. LS",
                                                  numLS,
                                                  0.,
                                                  numLS_d,
                                                  numAlgs_,
                                                  -0.5,
                                                  numAlgs_d - 0.5);
  algoBits_before_prescale_lumi_->setAxisTitle("Luminosity Segment", 1);
  algoBits_before_prescale_lumi_->setAxisTitle("Algorithm Trigger Bits (before prescale)", 2);

  algoBits_after_prescale_lumi_ = ibooker.book2D("algoBits_after_prescale_lumi",
                                                 "uGT: Algorithm Trigger Bits (after prescale) vs. LS",
                                                 numLS,
                                                 0.,
                                                 numLS_d,
                                                 numAlgs_,
                                                 -0.5,
                                                 numAlgs_d - 0.5);
  algoBits_after_prescale_lumi_->setAxisTitle("Luminosity Segment", 1);
  algoBits_after_prescale_lumi_->setAxisTitle("Algorithm Trigger Bits (after prescale)", 2);

  // Prescale factor index
  prescaleFactorSet_ =
      ibooker.book2D("prescaleFactorSet", "uGT: Index of Prescale Factor Set vs. LS", numLS, 0., numLS_d, 25, 0., 25.);
  prescaleFactorSet_->setAxisTitle("Luminosity Segment", 1);
  prescaleFactorSet_->setAxisTitle("Prescale Factor Set Index", 2);
}

void L1TStage2uGT::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
  if (verbose_) {
    edm::LogInfo("L1TStage2uGT") << "L1TStage2uGT DQM: Analyzing.." << std::endl;
  }

  // Get standard event parameters
  int lumi = evt.luminosityBlock();
  int bx = evt.bunchCrossing();

  // Open uGT readout record
  edm::Handle<GlobalAlgBlkBxCollection> uGtAlgs;
  evt.getByToken(l1tStage2uGtSource_, uGtAlgs);

  if (!uGtAlgs.isValid()) {
    edm::LogInfo("L1TStage2uGT") << "Cannot find uGT readout record.";
    return;
  }

  //algoBits_->Fill(-1.); // fill underflow to normalize // FIXME: needed?
  for (int ibx = uGtAlgs->getFirstBX(); ibx <= uGtAlgs->getLastBX(); ++ibx) {
    for (auto itr = uGtAlgs->begin(ibx); itr != uGtAlgs->end(ibx); ++itr) {  // FIXME: redundant loop?

      // Fills prescale factor set histogram
      prescaleFactorSet_->Fill(lumi, itr->getPreScColumn());

      // Fills algorithm bits histograms
      for (int algoBit = 0; algoBit < numAlgs_; ++algoBit) {
        // Algorithm bits before AlgoBX mask
        if (itr->getAlgoDecisionInitial(algoBit)) {
          algoBits_before_bxmask_->Fill(algoBit);
          algoBits_before_bxmask_lumi_->Fill(lumi, algoBit);
          algoBits_before_bxmask_bx_inEvt_->Fill(ibx, algoBit);  // FIXME: or itr->getbxInEventNr()/getbxNr()?
          algoBits_before_bxmask_bx_global_->Fill(bx + ibx, algoBit);

          for (int algoBit2 = 0; algoBit2 < numAlgs_; ++algoBit2) {
            if (itr->getAlgoDecisionInitial(algoBit2)) {
              algoBits_before_bxmask_corr_->Fill(algoBit, algoBit2);
            }
          }
        }

        // Algorithm bits before prescale
        if (itr->getAlgoDecisionInterm(algoBit)) {
          algoBits_before_prescale_->Fill(algoBit);
          algoBits_before_prescale_lumi_->Fill(lumi, algoBit);
          algoBits_before_prescale_bx_inEvt_->Fill(ibx, algoBit);
          algoBits_before_prescale_bx_global_->Fill(bx + ibx, algoBit);

          for (int algoBit2 = 0; algoBit2 < numAlgs_; ++algoBit2) {
            if (itr->getAlgoDecisionInterm(algoBit2)) {
              algoBits_before_prescale_corr_->Fill(algoBit, algoBit2);
            }
          }
        }

        // Algorithm bits after prescale
        if (itr->getAlgoDecisionFinal(algoBit)) {
          algoBits_after_prescale_->Fill(algoBit);
          algoBits_after_prescale_lumi_->Fill(lumi, algoBit);
          algoBits_after_prescale_bx_inEvt_->Fill(ibx, algoBit);
          algoBits_after_prescale_bx_global_->Fill(bx + ibx, algoBit);

          for (int algoBit2 = 0; algoBit2 < numAlgs_; ++algoBit2) {
            if (itr->getAlgoDecisionFinal(algoBit2)) {
              algoBits_after_prescale_corr_->Fill(algoBit, algoBit2);
            }
          }
        }
      }
    }
  }
}

// End section