Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /**
0002  * \class L1TStage2uGTTiming
0003  *
0004  * Description: DQM for L1 Micro Global Trigger timing.
0005  *
0006  */
0007 
0008 #include "DQM/L1TMonitor/interface/L1TStage2uGTTiming.h"
0009 
0010 // Constructor
0011 L1TStage2uGTTiming::L1TStage2uGTTiming(const edm::ParameterSet& params)
0012     : l1tStage2uGtSource_(consumes<GlobalAlgBlkBxCollection>(params.getParameter<edm::InputTag>("l1tStage2uGtSource"))),
0013       monitorDir_(params.getUntrackedParameter<std::string>("monitorDir", "")),
0014       verbose_(params.getUntrackedParameter<bool>("verbose", false)),
0015       gtUtil_(new l1t::L1TGlobalUtil(params,
0016                                      consumesCollector(),
0017                                      *this,
0018                                      params.getParameter<edm::InputTag>("l1tStage2uGtSource"),
0019                                      params.getParameter<edm::InputTag>("l1tStage2uGtSource"))),
0020       numAlgs_(0),
0021       algoBitFirstBxInTrain_(-1),
0022       algoBitLastBxInTrain_(-1),
0023       algoBitIsoBx_(-1),
0024       algoNameFirstBxInTrain_(params.getUntrackedParameter<std::string>("firstBXInTrainAlgo", "")),
0025       algoNameLastBxInTrain_(params.getUntrackedParameter<std::string>("lastBXInTrainAlgo", "")),
0026       algoNameIsoBx_(params.getUntrackedParameter<std::string>("isoBXAlgo", "")),
0027       unprescaledAlgoShortList_(params.getUntrackedParameter<std::vector<std::string>>("unprescaledAlgoShortList")),
0028       prescaledAlgoShortList_(params.getUntrackedParameter<std::vector<std::string>>("prescaledAlgoShortList")) {
0029   if (params.getUntrackedParameter<std::string>("useAlgoDecision").find("final") == 0) {
0030     useAlgoDecision_ = 2;
0031   } else if (params.getUntrackedParameter<std::string>("useAlgoDecision").find("intermediate") == 0) {
0032     useAlgoDecision_ = 1;
0033   } else {
0034     useAlgoDecision_ = 0;
0035   }
0036 }
0037 
0038 // Destructor
0039 L1TStage2uGTTiming::~L1TStage2uGTTiming() {}
0040 
0041 void L1TStage2uGTTiming::dqmBeginRun(edm::Run const& iRun, edm::EventSetup const& evtSetup) {
0042   // Get the trigger menu information
0043   gtUtil_->retrieveL1Setup(evtSetup);
0044 
0045   // Find the number of algos defined
0046   numAlgs_ = static_cast<int>(gtUtil_->decisionsInitial().size());
0047 
0048   // Get the algo bits needed for the timing histograms
0049   if (!gtUtil_->getAlgBitFromName(algoNameFirstBxInTrain_, algoBitFirstBxInTrain_)) {
0050     edm::LogWarning("L1TStage2uGTTiming") << "Algo \"" << algoNameFirstBxInTrain_ << "\" not found in the trigger menu "
0051                                           << gtUtil_->gtTriggerMenuName() << ". Could not retrieve algo bit number.";
0052   }
0053 
0054   if (!gtUtil_->getAlgBitFromName(algoNameLastBxInTrain_, algoBitLastBxInTrain_)) {
0055     edm::LogWarning("L1TStage2uGTTiming") << "Algo \"" << algoNameLastBxInTrain_ << "\" not found in the trigger menu "
0056                                           << gtUtil_->gtTriggerMenuName() << ". Could not retrieve algo bit number.";
0057   }
0058 
0059   if (!gtUtil_->getAlgBitFromName(algoNameIsoBx_, algoBitIsoBx_)) {
0060     edm::LogWarning("L1TStage2uGTTiming") << "Algo \"" << algoNameIsoBx_ << "\" not found in the trigger menu "
0061                                           << gtUtil_->gtTriggerMenuName() << ". Could not retrieve algo bit number.";
0062   }
0063 
0064   int algoBitUnpre_ = -1;
0065   for (unsigned int i = 0; i < unprescaledAlgoShortList_.size(); i++) {
0066     if (gtUtil_->getAlgBitFromName(unprescaledAlgoShortList_.at(i), algoBitUnpre_)) {
0067       unprescaledAlgoBitName_.emplace_back(unprescaledAlgoShortList_.at(i), algoBitUnpre_);
0068     } else {
0069       edm::LogWarning("L1TStage2uGTTiming")
0070           << "Algo \"" << unprescaledAlgoShortList_.at(i) << "\" not found in the trigger menu "
0071           << gtUtil_->gtTriggerMenuName() << ". Could not retrieve algo bit number.";
0072     }
0073   }
0074 
0075   int algoBitPre_ = -1;
0076   for (unsigned int i = 0; i < prescaledAlgoShortList_.size(); i++) {
0077     if ((gtUtil_->getAlgBitFromName(prescaledAlgoShortList_.at(i), algoBitPre_))) {
0078       prescaledAlgoBitName_.emplace_back(prescaledAlgoShortList_.at(i), algoBitPre_);
0079     } else {
0080       edm::LogWarning("L1TStage2uGTTiming")
0081           << "Algo \"" << prescaledAlgoShortList_.at(i) << "\" not found in the trigger menu "
0082           << gtUtil_->gtTriggerMenuName() << ". Could not retrieve algo bit number.";
0083     }
0084   }
0085 }
0086 
0087 void L1TStage2uGTTiming::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const& evtSetup) {
0088   // Book histograms
0089   const auto numAlgs_d = static_cast<double>(numAlgs_);
0090   const auto preAlgs_d = static_cast<double>(prescaledAlgoBitName_.size());
0091   const auto unpreAlgs_d = static_cast<double>(unprescaledAlgoBitName_.size());
0092 
0093   ibooker.setCurrentFolder(monitorDir_);
0094 
0095   first_collision_in_train_minus2_ =
0096       ibooker.book2D("first_bunch_in_train_minus2",
0097                      "uGT: Algorithm Trigger Bits (first bunch in train minus 2) vs. BX Number In Event;Bunch Crossing "
0098                      "Number In Event;Algorithm Trigger Bits",
0099                      5,
0100                      -2.5,
0101                      2.5,
0102                      numAlgs_,
0103                      -0.5,
0104                      numAlgs_d - 0.5);
0105   den_first_collision_in_train_minus2_ =
0106       ibooker.book2D("den_first_bunch_in_train_minus2",
0107                      "uGT: Algorithm Trigger Bits (all entries for each trigget bit first bunch in train minus 2) vs. "
0108                      "BX Number In Event;Bunch Crossing Number In Event;Algorithm Trigger Bits",
0109                      5,
0110                      -2.5,
0111                      2.5,
0112                      numAlgs_,
0113                      -0.5,
0114                      numAlgs_d - 0.5);
0115 
0116   first_collision_in_train_minus1_ =
0117       ibooker.book2D("first_bunch_in_train_minus1",
0118                      "uGT: Algorithm Trigger Bits (first bunch in train minus 1) vs. BX Number In Event;Bunch Crossing "
0119                      "Number In Event;Algorithm Trigger Bits",
0120                      5,
0121                      -2.5,
0122                      2.5,
0123                      numAlgs_,
0124                      -0.5,
0125                      numAlgs_d - 0.5);
0126   den_first_collision_in_train_minus1_ =
0127       ibooker.book2D("den_first_bunch_in_train_minus1",
0128                      "uGT: Algorithm Trigger Bits (all entries for each trigget bit first bunch in train minus 1) vs. "
0129                      "BX Number In Event;Bunch Crossing Number In Event;Algorithm Trigger Bits",
0130                      5,
0131                      -2.5,
0132                      2.5,
0133                      numAlgs_,
0134                      -0.5,
0135                      numAlgs_d - 0.5);
0136 
0137   first_collision_in_train_ =
0138       ibooker.book2D("first_bunch_in_train",
0139                      "uGT: Algorithm Trigger Bits (first bunch in train) vs. BX Number In Event;Bunch Crossing Number "
0140                      "In Event;Algorithm Trigger Bits (first bunch in train)",
0141                      5,
0142                      -2.5,
0143                      2.5,
0144                      numAlgs_,
0145                      -0.5,
0146                      numAlgs_d - 0.5);
0147   den_first_collision_in_train_ =
0148       ibooker.book2D("den_first_bunch_in_train",
0149                      "uGT: Algorithm Trigger Bits (all entries for each trigget bit first bunch in train) vs. BX "
0150                      "Number In Event;Bunch Crossing Number In Event;Algorithm Trigger Bits (first bunch in train)",
0151                      5,
0152                      -2.5,
0153                      2.5,
0154                      numAlgs_,
0155                      -0.5,
0156                      numAlgs_d - 0.5);
0157 
0158   last_collision_in_train_ =
0159       ibooker.book2D("last_bunch_in_train",
0160                      "uGT: Algorithm Trigger Bits (last bunch in train) vs. BX Number In Event;Bunch Crossing Number "
0161                      "In Event;Algorithm Trigger Bits (last bunch in train)",
0162                      5,
0163                      -2.5,
0164                      2.5,
0165                      numAlgs_,
0166                      -0.5,
0167                      numAlgs_d - 0.5);
0168   den_last_collision_in_train_ =
0169       ibooker.book2D("den_last_bunch_in_train",
0170                      "uGT: Algorithm Trigger Bits (all entries for each trigget bit last bunch in train) vs. BX Number "
0171                      "In Event;Bunch Crossing Number In Event;Algorithm Trigger Bits (last bunch in train)",
0172                      5,
0173                      -2.5,
0174                      2.5,
0175                      numAlgs_,
0176                      -0.5,
0177                      numAlgs_d - 0.5);
0178 
0179   isolated_collision_ = ibooker.book2D(
0180       "isolated_bunch",
0181       "uGT: Algorithm Trigger Bits vs. BX Number In Event;Bunch Crossing Number In Event;Algorithm Trigger Bits",
0182       5,
0183       -2.5,
0184       2.5,
0185       numAlgs_,
0186       -0.5,
0187       numAlgs_d - 0.5);
0188   den_isolated_collision_ =
0189       ibooker.book2D("den_isolated_bunch_in_train",
0190                      "uGT: Algorithm Trigger Bits (all entries for each trigget bit isolated bunch in train) vs. BX "
0191                      "Number In Event;Bunch Crossing Number In Event;Algorithm Trigger Bits (isolated bunch in train)",
0192                      5,
0193                      -2.5,
0194                      2.5,
0195                      numAlgs_,
0196                      -0.5,
0197                      numAlgs_d - 0.5);
0198 
0199   // Prescaled and Unprescaled Algo Trigger Bits
0200   // First bunch in train
0201   prescaled_algo_first_collision_in_train_ =
0202       ibooker.book2D("prescaled_algo_first_collision_in_train_",
0203                      "uGT: Prescaled Algorithm Trigger Bits  vs. BX Number In Event;Bunch Crossing Number In "
0204                      "Event;Algorithm Trigger Names + Bits",
0205                      5,
0206                      -2.5,
0207                      2.5,
0208                      prescaledAlgoBitName_.size(),
0209                      -0.5,
0210                      preAlgs_d - 0.5);
0211   for (unsigned int algo = 0; algo < prescaledAlgoBitName_.size(); ++algo) {
0212     prescaled_algo_first_collision_in_train_->setBinLabel(
0213         algo + 1,
0214         prescaledAlgoBitName_.at(algo).first + " (" + std::to_string(prescaledAlgoBitName_.at(algo).second) + ")",
0215         2);
0216   }
0217 
0218   den_prescaled_algo_first_collision_in_train_ =
0219       ibooker.book2D("den_prescaled_algo_first_collision_in_train_",
0220                      "uGT: Prescaled Algorithm Trigger Bits Deno vs. BX Number In Event;Bunch Crossing Number In "
0221                      "Event;Algorithm Trigger Names + Bits",
0222                      5,
0223                      -2.5,
0224                      2.5,
0225                      prescaledAlgoBitName_.size(),
0226                      -0.5,
0227                      preAlgs_d - 0.5);
0228   for (unsigned int algo = 0; algo < prescaledAlgoBitName_.size(); ++algo) {
0229     den_prescaled_algo_first_collision_in_train_->setBinLabel(
0230         algo + 1,
0231         prescaledAlgoBitName_.at(algo).first + " (" + std::to_string(prescaledAlgoBitName_.at(algo).second) + ")",
0232         2);
0233   }
0234 
0235   unprescaled_algo_first_collision_in_train_ =
0236       ibooker.book2D("unprescaled_algo_first_collision_in_train_",
0237                      "uGT: Unprescaled Algorithm Trigger Bits  vs. BX Number In Event;Bunch Crossing Number In "
0238                      "Event;Algorithm Trigger Names + Bits",
0239                      5,
0240                      -2.5,
0241                      2.5,
0242                      unprescaledAlgoBitName_.size(),
0243                      -0.5,
0244                      unpreAlgs_d - 0.5);
0245   for (unsigned int algo = 0; algo < unprescaledAlgoBitName_.size(); ++algo) {
0246     unprescaled_algo_first_collision_in_train_->setBinLabel(
0247         algo + 1,
0248         unprescaledAlgoBitName_.at(algo).first + " (" + std::to_string(unprescaledAlgoBitName_.at(algo).second) + ")",
0249         2);
0250   }
0251 
0252   den_unprescaled_algo_first_collision_in_train_ =
0253       ibooker.book2D("den_unprescaled_algo_first_collision_in_train_",
0254                      "uGT: Unprescaled Algorithm Trigger Bits Deno vs. BX Number In Event;Bunch Crossing Number In "
0255                      "Event;Algorithm Trigger Names + Bits",
0256                      5,
0257                      -2.5,
0258                      2.5,
0259                      unprescaledAlgoBitName_.size(),
0260                      -0.5,
0261                      unpreAlgs_d - 0.5);
0262   for (unsigned int algo = 0; algo < unprescaledAlgoBitName_.size(); ++algo) {
0263     den_unprescaled_algo_first_collision_in_train_->setBinLabel(
0264         algo + 1,
0265         unprescaledAlgoBitName_.at(algo).first + " (" + std::to_string(unprescaledAlgoBitName_.at(algo).second) + ")",
0266         2);
0267   }
0268 
0269   // Isolated bunch
0270   prescaled_algo_isolated_collision_ =
0271       ibooker.book2D("prescaled_algo_isolated_collision_",
0272                      "uGT: Prescaled Algorithm Trigger Bits vs. BX Number In Event;Bunch Crossing Number In "
0273                      "Event;Algorithm Trigger Names + Bits",
0274                      5,
0275                      -2.5,
0276                      2.5,
0277                      prescaledAlgoBitName_.size(),
0278                      -0.5,
0279                      preAlgs_d - 0.5);
0280   for (unsigned int algo = 0; algo < prescaledAlgoBitName_.size(); ++algo) {
0281     prescaled_algo_isolated_collision_->setBinLabel(
0282         algo + 1,
0283         prescaledAlgoBitName_.at(algo).first + " (" + std::to_string(prescaledAlgoBitName_.at(algo).second) + ")",
0284         2);
0285   }
0286 
0287   den_prescaled_algo_isolated_collision_ =
0288       ibooker.book2D("den_prescaled_algo_isolated_collision_",
0289                      "uGT: Prescaled Algorithm Trigger Bits Deno vs. BX Number In Event;Bunch Crossing Number In "
0290                      "Event;Algorithm Trigger Names + Bits",
0291                      5,
0292                      -2.5,
0293                      2.5,
0294                      prescaledAlgoBitName_.size(),
0295                      -0.5,
0296                      preAlgs_d - 0.5);
0297   for (unsigned int algo = 0; algo < prescaledAlgoBitName_.size(); ++algo) {
0298     den_prescaled_algo_isolated_collision_->setBinLabel(
0299         algo + 1,
0300         prescaledAlgoBitName_.at(algo).first + " (" + std::to_string(prescaledAlgoBitName_.at(algo).second) + ")",
0301         2);
0302   }
0303 
0304   unprescaled_algo_isolated_collision_ =
0305       ibooker.book2D("unprescaled_algo_isolated_collision_",
0306                      "uGT: Unprescaled Algorithm Trigger Bits vs. BX Number In Event;Bunch Crossing Number In "
0307                      "Event;Algorithm Trigger Names + Bits",
0308                      5,
0309                      -2.5,
0310                      2.5,
0311                      unprescaledAlgoBitName_.size(),
0312                      -0.5,
0313                      unpreAlgs_d - 0.5);
0314   for (unsigned int algo = 0; algo < unprescaledAlgoBitName_.size(); ++algo) {
0315     unprescaled_algo_isolated_collision_->setBinLabel(
0316         algo + 1,
0317         unprescaledAlgoBitName_.at(algo).first + " (" + std::to_string(unprescaledAlgoBitName_.at(algo).second) + ")",
0318         2);
0319   }
0320 
0321   den_unprescaled_algo_isolated_collision_ =
0322       ibooker.book2D("den_unprescaled_algo_isolated_collision_",
0323                      "uGT: Unprescaled Algorithm Trigger Bits Deno vs. BX Number In Event;Bunch Crossing Number In "
0324                      "Event;Algorithm Trigger Names + Bits",
0325                      5,
0326                      -2.5,
0327                      2.5,
0328                      unprescaledAlgoBitName_.size(),
0329                      -0.5,
0330                      unpreAlgs_d - 0.5);
0331   for (unsigned int algo = 0; algo < unprescaledAlgoBitName_.size(); ++algo) {
0332     den_unprescaled_algo_isolated_collision_->setBinLabel(
0333         algo + 1,
0334         unprescaledAlgoBitName_.at(algo).first + " (" + std::to_string(unprescaledAlgoBitName_.at(algo).second) + ")",
0335         2);
0336   }
0337 
0338   // Last bunch in train
0339   prescaled_algo_last_collision_in_train_ =
0340       ibooker.book2D("prescaled_algo_last_collision_in_train_",
0341                      "uGT: Prescaled Algorithm Trigger Bits vs. BX Number In Event;Bunch Crossing Number In "
0342                      "Event;Algorithm Trigger Names + Bits",
0343                      5,
0344                      -2.5,
0345                      2.5,
0346                      prescaledAlgoBitName_.size(),
0347                      -0.5,
0348                      preAlgs_d - 0.5);
0349   for (unsigned int algo = 0; algo < prescaledAlgoBitName_.size(); ++algo) {
0350     prescaled_algo_last_collision_in_train_->setBinLabel(
0351         algo + 1,
0352         prescaledAlgoBitName_.at(algo).first + " (" + std::to_string(prescaledAlgoBitName_.at(algo).second) + ")",
0353         2);
0354   }
0355 
0356   den_prescaled_algo_last_collision_in_train_ =
0357       ibooker.book2D("den_prescaled_algo_last_collision_in_train_",
0358                      "uGT: Prescaled Algorithm Trigger Bits Deno vs. BX Number In Event;Bunch Crossing Number In "
0359                      "Event;Algorithm Trigger Names + Bits",
0360                      5,
0361                      -2.5,
0362                      2.5,
0363                      prescaledAlgoBitName_.size(),
0364                      -0.5,
0365                      preAlgs_d - 0.5);
0366   for (unsigned int algo = 0; algo < prescaledAlgoBitName_.size(); ++algo) {
0367     den_prescaled_algo_last_collision_in_train_->setBinLabel(
0368         algo + 1,
0369         prescaledAlgoBitName_.at(algo).first + " (" + std::to_string(prescaledAlgoBitName_.at(algo).second) + ")",
0370         2);
0371   }
0372 
0373   unprescaled_algo_last_collision_in_train_ =
0374       ibooker.book2D("unprescaled_algo_last_collision_in_train_",
0375                      "uGT: Unprescaled Algorithm Trigger Bits vs. BX Number In Event;Bunch Crossing Number In "
0376                      "Event;Algorithm Trigger Names + Bits",
0377                      5,
0378                      -2.5,
0379                      2.5,
0380                      unprescaledAlgoBitName_.size(),
0381                      -0.5,
0382                      unpreAlgs_d - 0.5);
0383   for (unsigned int algo = 0; algo < unprescaledAlgoBitName_.size(); ++algo) {
0384     unprescaled_algo_last_collision_in_train_->setBinLabel(
0385         algo + 1,
0386         unprescaledAlgoBitName_.at(algo).first + " (" + std::to_string(unprescaledAlgoBitName_.at(algo).second) + ")",
0387         2);
0388   }
0389 
0390   den_unprescaled_algo_last_collision_in_train_ =
0391       ibooker.book2D("den_unprescaled_algo_last_collision_in_train_",
0392                      "uGT: Unprescaled Algorithm Trigger Bits Deno vs. BX Number In Event;Bunch Crossing Number In "
0393                      "Event;Algorithm Trigger Names + Bits",
0394                      5,
0395                      -2.5,
0396                      2.5,
0397                      unprescaledAlgoBitName_.size(),
0398                      -0.5,
0399                      unpreAlgs_d - 0.5);
0400   for (unsigned int algo = 0; algo < unprescaledAlgoBitName_.size(); ++algo) {
0401     den_unprescaled_algo_last_collision_in_train_->setBinLabel(
0402         algo + 1,
0403         unprescaledAlgoBitName_.at(algo).first + " (" + std::to_string(unprescaledAlgoBitName_.at(algo).second) + ")",
0404         2);
0405   }
0406 }
0407 
0408 void L1TStage2uGTTiming::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
0409   if (verbose_) {
0410     edm::LogInfo("L1TStage2uGTTiming") << "L1TStage2uGTTiming DQM: Analyzing.." << std::endl;
0411   }
0412 
0413   // Open uGT readout record
0414   edm::Handle<GlobalAlgBlkBxCollection> uGtAlgs;
0415   evt.getByToken(l1tStage2uGtSource_, uGtAlgs);
0416 
0417   if (!uGtAlgs.isValid()) {
0418     edm::LogInfo("L1TStage2uGTTiming") << "Cannot find uGT readout record.";
0419     return;
0420   }
0421 
0422   // Find out in which BX the first collision in train, isolated bunch, and last collision in train have fired.
0423   // In case of pre firing it will be in BX 1 or BX 2 and this will determine the BX shift that
0424   // will be applied to the timing histogram later.
0425   int bxShiftFirst = -999;
0426   int bxShiftLast = -999;
0427   int bxShiftIso = -999;
0428   for (int bx = uGtAlgs->getFirstBX(); bx <= uGtAlgs->getLastBX(); ++bx) {
0429     for (GlobalAlgBlkBxCollection::const_iterator itr = uGtAlgs->begin(bx); itr != uGtAlgs->end(bx); ++itr) {
0430       // first bunch in train
0431       if (algoBitFirstBxInTrain_ != -1) {
0432         bool bit = false;
0433         switch (useAlgoDecision_) {
0434           case 0:
0435             bit = itr->getAlgoDecisionInitial(algoBitFirstBxInTrain_);
0436             break;
0437           case 1:
0438             bit = itr->getAlgoDecisionInterm(algoBitFirstBxInTrain_);
0439             break;
0440           case 2:
0441             bit = itr->getAlgoDecisionFinal(algoBitFirstBxInTrain_);
0442             break;
0443         }
0444         if (bit) {
0445           bxShiftFirst = bx;
0446         }
0447       }
0448       // last bunch in train
0449       if (algoBitLastBxInTrain_ != -1) {
0450         bool bit = false;
0451         switch (useAlgoDecision_) {
0452           case 0:
0453             bit = itr->getAlgoDecisionInitial(algoBitLastBxInTrain_);
0454             break;
0455           case 1:
0456             bit = itr->getAlgoDecisionInterm(algoBitLastBxInTrain_);
0457             break;
0458           case 2:
0459             bit = itr->getAlgoDecisionFinal(algoBitLastBxInTrain_);
0460             break;
0461         }
0462         if (bit) {
0463           bxShiftLast = bx;
0464         }
0465       }
0466       // isolated bunch
0467       if (algoBitIsoBx_ != -1) {
0468         bool bit = false;
0469         switch (useAlgoDecision_) {
0470           case 0:
0471             bit = itr->getAlgoDecisionInitial(algoBitIsoBx_);
0472             break;
0473           case 1:
0474             bit = itr->getAlgoDecisionInterm(algoBitIsoBx_);
0475             break;
0476           case 2:
0477             bit = itr->getAlgoDecisionFinal(algoBitIsoBx_);
0478             break;
0479         }
0480         if (bit) {
0481           bxShiftIso = bx;
0482         }
0483       }
0484     }
0485   }
0486 
0487   // fill the first bunch in train maps
0488   if (bxShiftFirst > -999) {
0489     auto minBx = std::max(uGtAlgs->getFirstBX(), uGtAlgs->getFirstBX() + bxShiftFirst);
0490     auto maxBx = std::min(uGtAlgs->getLastBX(), uGtAlgs->getLastBX() + bxShiftFirst);
0491 
0492     for (GlobalAlgBlkBxCollection::const_iterator itr = uGtAlgs->begin(bxShiftFirst); itr != uGtAlgs->end(bxShiftFirst);
0493          ++itr) {
0494       for (int ibx = minBx; ibx <= maxBx; ++ibx) {
0495         for (auto itr2 = uGtAlgs->begin(ibx); itr2 != uGtAlgs->end(ibx); ++itr2) {
0496           auto algoBits = itr2->getAlgoDecisionInitial();
0497           for (size_t algo = 0; algo < algoBits.size(); ++algo) {
0498             if (algoBits.at(algo)) {
0499               first_collision_in_train_->Fill(ibx - bxShiftFirst, algo);
0500               for (int ibx2 = minBx; ibx2 <= maxBx; ++ibx2) {
0501                 den_first_collision_in_train_->Fill(ibx2 - bxShiftFirst, algo);
0502               }
0503             }
0504           }
0505           for (unsigned int algo = 0; algo < prescaledAlgoBitName_.size(); ++algo) {
0506             if (itr2->getAlgoDecisionInitial(prescaledAlgoBitName_.at(algo).second)) {
0507               prescaled_algo_first_collision_in_train_->Fill(ibx - bxShiftFirst, algo);
0508               for (int ibx2 = minBx; ibx2 <= maxBx; ++ibx2) {
0509                 den_prescaled_algo_first_collision_in_train_->Fill(ibx2 - bxShiftFirst, algo);
0510               }
0511             }
0512           }
0513           for (unsigned int algo = 0; algo < unprescaledAlgoBitName_.size(); ++algo) {
0514             if (itr2->getAlgoDecisionInitial(unprescaledAlgoBitName_.at(algo).second)) {
0515               unprescaled_algo_first_collision_in_train_->Fill(ibx - bxShiftFirst, algo);
0516               for (int ibx2 = minBx; ibx2 <= maxBx; ++ibx2) {
0517                 den_unprescaled_algo_first_collision_in_train_->Fill(ibx2 - bxShiftFirst, algo);
0518               }
0519             }
0520           }
0521         }
0522       }
0523     }
0524   }
0525 
0526   // fill the last bunch in train maps
0527   if (bxShiftLast > -999) {
0528     auto minBx = std::max(uGtAlgs->getFirstBX(), uGtAlgs->getFirstBX() + bxShiftLast);
0529     auto maxBx = std::min(uGtAlgs->getLastBX(), uGtAlgs->getLastBX() + bxShiftLast);
0530 
0531     for (GlobalAlgBlkBxCollection::const_iterator itr = uGtAlgs->begin(bxShiftLast); itr != uGtAlgs->end(bxShiftLast);
0532          ++itr) {
0533       for (int ibx = minBx; ibx <= maxBx; ++ibx) {
0534         for (auto itr2 = uGtAlgs->begin(ibx); itr2 != uGtAlgs->end(ibx); ++itr2) {
0535           auto algoBits = itr2->getAlgoDecisionInitial();
0536           for (size_t algo = 0; algo < algoBits.size(); ++algo) {
0537             if (algoBits.at(algo)) {
0538               last_collision_in_train_->Fill(ibx - bxShiftLast, algo);
0539               for (int ibx2 = minBx; ibx2 <= maxBx; ++ibx2) {
0540                 den_last_collision_in_train_->Fill(ibx2 - bxShiftLast, algo);
0541               }
0542             }
0543           }
0544           for (unsigned int algo = 0; algo < prescaledAlgoBitName_.size(); ++algo) {
0545             if (itr2->getAlgoDecisionInitial(prescaledAlgoBitName_.at(algo).second)) {
0546               prescaled_algo_last_collision_in_train_->Fill(ibx - bxShiftLast, algo);
0547               for (int ibx2 = minBx; ibx2 <= maxBx; ++ibx2) {
0548                 den_prescaled_algo_last_collision_in_train_->Fill(ibx2 - bxShiftLast, algo);
0549               }
0550             }
0551           }
0552           for (unsigned int algo = 0; algo < unprescaledAlgoBitName_.size(); ++algo) {
0553             if (itr2->getAlgoDecisionInitial(unprescaledAlgoBitName_.at(algo).second)) {
0554               unprescaled_algo_last_collision_in_train_->Fill(ibx - bxShiftLast, algo);
0555               for (int ibx2 = minBx; ibx2 <= maxBx; ++ibx2) {
0556                 den_unprescaled_algo_last_collision_in_train_->Fill(ibx2 - bxShiftLast, algo);
0557               }
0558             }
0559           }
0560         }
0561       }
0562     }
0563   }
0564 
0565   // fill the isolated bunch maps
0566   if (bxShiftIso > -999) {
0567     auto minBx = std::max(uGtAlgs->getFirstBX(), uGtAlgs->getFirstBX() + bxShiftIso);
0568     auto maxBx = std::min(uGtAlgs->getLastBX(), uGtAlgs->getLastBX() + bxShiftIso);
0569 
0570     for (GlobalAlgBlkBxCollection::const_iterator itr = uGtAlgs->begin(bxShiftIso); itr != uGtAlgs->end(bxShiftIso);
0571          ++itr) {
0572       for (int ibx = minBx; ibx <= maxBx; ++ibx) {
0573         for (auto itr2 = uGtAlgs->begin(ibx); itr2 != uGtAlgs->end(ibx); ++itr2) {
0574           auto algoBits = itr2->getAlgoDecisionInitial();
0575           for (size_t algo = 0; algo < algoBits.size(); ++algo) {
0576             if (algoBits.at(algo)) {
0577               isolated_collision_->Fill(ibx - bxShiftIso, algo);
0578               for (int ibx2 = minBx; ibx2 <= maxBx; ++ibx2) {
0579                 den_isolated_collision_->Fill(ibx2 - bxShiftIso, algo);
0580               }
0581             }
0582           }
0583           for (unsigned int algo = 0; algo < prescaledAlgoBitName_.size(); ++algo) {
0584             if (itr2->getAlgoDecisionInitial(prescaledAlgoBitName_.at(algo).second)) {
0585               prescaled_algo_isolated_collision_->Fill(ibx - bxShiftIso, algo);
0586               for (int ibx2 = minBx; ibx2 <= maxBx; ++ibx2) {
0587                 den_prescaled_algo_isolated_collision_->Fill(ibx2 - bxShiftIso, algo);
0588               }
0589             }
0590           }
0591           for (unsigned int algo = 0; algo < unprescaledAlgoBitName_.size(); ++algo) {
0592             if (itr2->getAlgoDecisionInitial(unprescaledAlgoBitName_.at(algo).second)) {
0593               unprescaled_algo_isolated_collision_->Fill(ibx - bxShiftIso, algo);
0594               for (int ibx2 = minBx; ibx2 <= maxBx; ++ibx2) {
0595                 den_unprescaled_algo_isolated_collision_->Fill(ibx2 - bxShiftIso, algo);
0596               }
0597             }
0598           }
0599         }
0600       }
0601     }
0602   }
0603 
0604   // If algoBitFirstBxInTrain_ fired in L1A BX 2 something else must have prefired in the actual BX -2 before the first bunch crossing in the train
0605   if (uGtAlgs->getLastBX() >= 2) {
0606     for (auto itr = uGtAlgs->begin(2); itr != uGtAlgs->end(2); ++itr) {
0607       if (algoBitFirstBxInTrain_ != -1 && itr->getAlgoDecisionInitial(algoBitFirstBxInTrain_)) {
0608         for (int ibx = uGtAlgs->getFirstBX(); ibx <= uGtAlgs->getLastBX(); ++ibx) {
0609           for (auto itr2 = uGtAlgs->begin(ibx); itr2 != uGtAlgs->end(ibx); ++itr2) {
0610             auto algoBits = itr2->getAlgoDecisionInitial();
0611             for (size_t algo = 0; algo < algoBits.size(); ++algo) {
0612               if (algoBits.at(algo)) {
0613                 first_collision_in_train_minus2_->Fill(ibx, algo);
0614                 for (int ibx2 = uGtAlgs->getFirstBX(); ibx2 <= uGtAlgs->getLastBX(); ++ibx2) {
0615                   den_first_collision_in_train_minus2_->Fill(ibx2, algo);
0616                 }
0617               }
0618             }
0619           }
0620         }
0621       }
0622     }
0623   }
0624 
0625   // If algoBitFirstBxInTrain_ fired in L1A BX 1 something else must have prefired in the actual BX -1 before the first bunch crossing in the train
0626   if (uGtAlgs->getLastBX() >= 1) {
0627     for (auto itr = uGtAlgs->begin(1); itr != uGtAlgs->end(1); ++itr) {
0628       if (algoBitFirstBxInTrain_ != -1 && itr->getAlgoDecisionInitial(algoBitFirstBxInTrain_)) {
0629         for (int ibx = uGtAlgs->getFirstBX(); ibx <= uGtAlgs->getLastBX(); ++ibx) {
0630           for (auto itr2 = uGtAlgs->begin(ibx); itr2 != uGtAlgs->end(ibx); ++itr2) {
0631             auto algoBits = itr2->getAlgoDecisionInitial();
0632             for (size_t algo = 0; algo < algoBits.size(); ++algo) {
0633               if (algoBits.at(algo)) {
0634                 first_collision_in_train_minus1_->Fill(ibx, algo);
0635                 for (int ibx2 = uGtAlgs->getFirstBX(); ibx2 <= uGtAlgs->getLastBX(); ++ibx2) {
0636                   den_first_collision_in_train_minus1_->Fill(ibx2, algo);
0637                 }
0638               }
0639             }
0640           }
0641         }
0642       }
0643     }
0644   }
0645 }