Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQM/L1TMonitor/interface/L1TObjectsTiming.h"
0002 
0003 L1TObjectsTiming::L1TObjectsTiming(const edm::ParameterSet& ps)
0004     : ugmtMuonToken_(consumes<l1t::MuonBxCollection>(ps.getParameter<edm::InputTag>("muonProducer"))),
0005       stage2CaloLayer2JetToken_(
0006           consumes<l1t::JetBxCollection>(ps.getParameter<edm::InputTag>("stage2CaloLayer2JetProducer"))),
0007       stage2CaloLayer2EGammaToken_(
0008           consumes<l1t::EGammaBxCollection>(ps.getParameter<edm::InputTag>("stage2CaloLayer2EGammaProducer"))),
0009       stage2CaloLayer2TauToken_(
0010           consumes<l1t::TauBxCollection>(ps.getParameter<edm::InputTag>("stage2CaloLayer2TauProducer"))),
0011       stage2CaloLayer2EtSumToken_(
0012           consumes<l1t::EtSumBxCollection>(ps.getParameter<edm::InputTag>("stage2CaloLayer2EtSumProducer"))),
0013       l1tStage2uGtProducer_(consumes<GlobalAlgBlkBxCollection>(ps.getParameter<edm::InputTag>("ugtProducer"))),
0014       monitorDir_(ps.getUntrackedParameter<std::string>("monitorDir")),
0015       verbose_(ps.getUntrackedParameter<bool>("verbose")),
0016       gtUtil_(new l1t::L1TGlobalUtil(ps,
0017                                      consumesCollector(),
0018                                      *this,
0019                                      ps.getParameter<edm::InputTag>("ugtProducer"),
0020                                      ps.getParameter<edm::InputTag>("ugtProducer"))),
0021       algoBitFirstBxInTrain_(-1),
0022       algoBitLastBxInTrain_(-1),
0023       algoBitIsoBx_(-1),
0024       algoNameFirstBxInTrain_(ps.getUntrackedParameter<std::string>("firstBXInTrainAlgo", "")),
0025       algoNameLastBxInTrain_(ps.getUntrackedParameter<std::string>("lastBXInTrainAlgo", "")),
0026       algoNameIsoBx_(ps.getUntrackedParameter<std::string>("isoBXAlgo", "")),
0027       bxrange_(5),
0028       egammaPtCuts_(ps.getUntrackedParameter<std::vector<double>>("egammaPtCuts")),
0029       jetPtCut_(ps.getUntrackedParameter<double>("jetPtCut")),
0030       egammaPtCut_(0.),
0031       tauPtCut_(ps.getUntrackedParameter<double>("tauPtCut")),
0032       etsumPtCut_(ps.getUntrackedParameter<double>("etsumPtCut")),
0033       muonPtCut_(ps.getUntrackedParameter<double>("muonPtCut")),
0034       muonQualCut_(ps.getUntrackedParameter<int>("muonQualCut")) {
0035   if (ps.getUntrackedParameter<std::string>("useAlgoDecision").find("final") == 0) {
0036     useAlgoDecision_ = 2;
0037   } else if (ps.getUntrackedParameter<std::string>("useAlgoDecision").find("intermediate") == 0) {
0038     useAlgoDecision_ = 1;
0039   } else {
0040     useAlgoDecision_ = 0;
0041   }
0042 
0043   // Take the first element of the cuts vector as the one to use for the all bunches histograms
0044   if (not egammaPtCuts_.empty()) {
0045     egammaPtCut_ = egammaPtCuts_.at(0);
0046   }
0047 }
0048 
0049 L1TObjectsTiming::~L1TObjectsTiming() {}
0050 
0051 void L1TObjectsTiming::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0052   edm::ParameterSetDescription desc;
0053   desc.add<edm::InputTag>("muonProducer")->setComment("L1T muons");
0054   ;
0055   desc.add<edm::InputTag>("stage2CaloLayer2JetProducer")->setComment("L1T jets");
0056   desc.add<edm::InputTag>("stage2CaloLayer2EGammaProducer")->setComment("L1T egamma");
0057   desc.add<edm::InputTag>("stage2CaloLayer2TauProducer")->setComment("L1T taus");
0058   desc.add<edm::InputTag>("stage2CaloLayer2EtSumProducer")->setComment("L1T etsums");
0059   desc.add<edm::InputTag>("ugtProducer")->setComment("uGT output");
0060   desc.addUntracked<std::string>("monitorDir", "")
0061       ->setComment("Target directory in the DQM file. Will be created if not existing.");
0062   desc.addUntracked<bool>("verbose", false);
0063   desc.addUntracked<std::string>("firstBXInTrainAlgo", "")
0064       ->setComment("Pick the right algo name for L1 First Collision In Train");
0065   desc.addUntracked<std::string>("lastBXInTrainAlgo", "")
0066       ->setComment("Pick the right algo name for L1 Last Collision In Train");
0067   desc.addUntracked<std::string>("isoBXAlgo", "")->setComment("Pick the right algo name for L1 Isolated Bunch");
0068   desc.addUntracked<std::string>("useAlgoDecision", "initial")
0069       ->setComment("Which algo decision should be checked [initial, intermediate, final].");
0070   desc.addUntracked<std::vector<double>>("egammaPtCuts", {20., 10., 30.})->setComment("List if min egamma pT vaules");
0071   desc.addUntracked<double>("jetPtCut", 20.)->setComment("Min jet pT");
0072   desc.addUntracked<double>("tauPtCut", 20.)->setComment("Min tau pT");
0073   desc.addUntracked<double>("etsumPtCut", 20.)->setComment("Min etsum pT");
0074   desc.addUntracked<double>("muonPtCut", 8.)->setComment("Min muon pT");
0075   desc.addUntracked<int>("muonQualCut", 12)->setComment("Min muon quality");
0076   descriptions.add("l1tObjectsTiming", desc);
0077 }
0078 
0079 void L1TObjectsTiming::dqmBeginRun(const edm::Run& r, const edm::EventSetup& c) {
0080   // Get the trigger menu information
0081   gtUtil_->retrieveL1Setup(c);
0082 
0083   // Get the algo bits needed for the timing histograms
0084   if (!gtUtil_->getAlgBitFromName(algoNameFirstBxInTrain_, algoBitFirstBxInTrain_)) {
0085     edm::LogWarning("L1TObjectsTiming") << "Algo \"" << algoNameFirstBxInTrain_ << "\" not found in the trigger menu "
0086                                         << gtUtil_->gtTriggerMenuName() << ". Could not retrieve algo bit number.";
0087   }
0088 
0089   if (!gtUtil_->getAlgBitFromName(algoNameLastBxInTrain_, algoBitLastBxInTrain_)) {
0090     edm::LogWarning("L1TObjectsTiming") << "Algo \"" << algoNameLastBxInTrain_ << "\" not found in the trigger menu "
0091                                         << gtUtil_->gtTriggerMenuName() << ". Could not retrieve algo bit number.";
0092   }
0093 
0094   if (!gtUtil_->getAlgBitFromName(algoNameIsoBx_, algoBitIsoBx_)) {
0095     edm::LogWarning("L1TObjectsTiming") << "Algo \"" << algoNameIsoBx_ << "\" not found in the trigger menu "
0096                                         << gtUtil_->gtTriggerMenuName() << ". Could not retrieve algo bit number.";
0097   }
0098 }
0099 
0100 void L1TObjectsTiming::bookHistograms(DQMStore::IBooker& ibooker, const edm::Run&, const edm::EventSetup&) {
0101   std::array<std::string, 5> bx_obj{{"minus2", "minus1", "0", "plus1", "plus2"}};
0102 
0103   // generate cut value strings for the histogram titles
0104   auto muonQualCutStr = std::to_string(muonQualCut_);
0105   auto muonPtCutStr = std::to_string(muonPtCut_);
0106   muonPtCutStr.resize(muonPtCutStr.size() - 5);  // cut some decimal digits
0107 
0108   auto jetPtCutStr = std::to_string(jetPtCut_);
0109   jetPtCutStr.resize(jetPtCutStr.size() - 5);  // cut some decimal digits
0110 
0111   auto egammaPtCutStr = std::to_string(egammaPtCut_);
0112   egammaPtCutStr.resize(egammaPtCutStr.size() - 5);  // cut some decimal digits
0113 
0114   auto tauPtCutStr = std::to_string(tauPtCut_);
0115   tauPtCutStr.resize(tauPtCutStr.size() - 5);  // cut some decimal digits
0116 
0117   auto etsumPtCutStr = std::to_string(etsumPtCut_);
0118   etsumPtCutStr.resize(etsumPtCutStr.size() - 5);  // cut some decimal digits
0119 
0120   // all bunches
0121   ibooker.setCurrentFolder(monitorDir_ + "/L1TMuon/timing");
0122   for (unsigned int i = 0; i < bxrange_; ++i) {
0123     muons_eta_phi.push_back(ibooker.book2D("muons_eta_phi_bx_" + bx_obj[i],
0124                                            "L1T Muon p_{T}#geq" + muonPtCutStr + " GeV qual#geq" + muonQualCutStr +
0125                                                " #eta vs #phi BX=" + bx_obj[i] + ";#eta;#phi",
0126                                            25,
0127                                            -2.5,
0128                                            2.5,
0129                                            25,
0130                                            -3.2,
0131                                            3.2));
0132   }
0133   denominator_muons = ibooker.book2D(
0134       "denominator_muons",
0135       "Denominator for L1T Muon p_{T}#geq" + muonPtCutStr + " GeV qual#geq" + muonQualCutStr + ";#eta;#phi",
0136       25,
0137       -2.5,
0138       2.5,
0139       25,
0140       -3.2,
0141       3.2);
0142 
0143   ibooker.setCurrentFolder(monitorDir_ + "/L1TJet/timing");
0144   for (unsigned int i = 0; i < bxrange_; ++i) {
0145     jet_eta_phi.push_back(
0146         ibooker.book2D("jet_eta_phi_bx_" + bx_obj[i],
0147                        "L1T Jet p_{T}#geq" + jetPtCutStr + " GeV #eta vs #phi BX=" + bx_obj[i] + ";#eta;#phi",
0148                        50,
0149                        -5.,
0150                        5.,
0151                        25,
0152                        -3.2,
0153                        3.2));
0154   }
0155   denominator_jet = ibooker.book2D("denominator_jet",
0156                                    "Denominator for L1T Jet p_{T}#geq" + jetPtCutStr + " GeV;#eta;#phi",
0157                                    50,
0158                                    -5.,
0159                                    5.,
0160                                    25,
0161                                    -3.2,
0162                                    3.2);
0163 
0164   ibooker.setCurrentFolder(monitorDir_ + "/L1TEGamma/timing");
0165   for (unsigned int i = 0; i < bxrange_; ++i) {
0166     egamma_eta_phi.push_back(
0167         ibooker.book2D("egamma_eta_phi_bx_" + bx_obj[i],
0168                        "L1T EGamma p_{T}#geq" + egammaPtCutStr + " GeV #eta vs #phi BX=" + bx_obj[i] + ";#eta;#phi",
0169                        30,
0170                        -3.,
0171                        3.,
0172                        25,
0173                        -3.2,
0174                        3.2));
0175   }
0176   denominator_egamma = ibooker.book2D("denominator_egamma",
0177                                       "Denominator for L1T EGamma p_{T}#geq" + egammaPtCutStr + " GeV;#eta;#phi",
0178                                       30,
0179                                       -3.,
0180                                       3.,
0181                                       25,
0182                                       -3.2,
0183                                       3.2);
0184 
0185   ibooker.setCurrentFolder(monitorDir_ + "/L1TTau/timing");
0186   for (unsigned int i = 0; i < bxrange_; ++i) {
0187     tau_eta_phi.push_back(
0188         ibooker.book2D("tau_eta_phi_bx_" + bx_obj[i],
0189                        "L1T Tau p_{T}#geq" + tauPtCutStr + " GeV #eta vs #phi BX=" + bx_obj[i] + ";#eta;#phi",
0190                        30,
0191                        -3.,
0192                        3.,
0193                        25,
0194                        -3.2,
0195                        3.2));
0196   }
0197   denominator_tau = ibooker.book2D("denominator_tau",
0198                                    "Denominator for L1T Tau p_{T}#geq" + tauPtCutStr + " GeV;#eta;#phi",
0199                                    30,
0200                                    -3.,
0201                                    3.,
0202                                    25,
0203                                    -3.2,
0204                                    3.2);
0205 
0206   ibooker.setCurrentFolder(monitorDir_ + "/L1TEtSum/timing");
0207   for (unsigned int i = 0; i < bxrange_; ++i) {
0208     etsum_eta_phi_MET.push_back(
0209         ibooker.book1D("etsum_phi_bx_MET_" + bx_obj[i],
0210                        "L1T EtSum MET p_{T}#geq" + etsumPtCutStr + " GeV #phi BX=" + bx_obj[i] + ";#phi",
0211                        25,
0212                        -3.2,
0213                        3.2));
0214     etsum_eta_phi_METHF.push_back(
0215         ibooker.book1D("etsum_phi_bx_METHF_" + bx_obj[i],
0216                        "L1T EtSum METHF p_{T}#geq" + etsumPtCutStr + " GeV #phi BX=" + bx_obj[i] + ";#phi",
0217                        25,
0218                        -3.2,
0219                        3.2));
0220     etsum_eta_phi_MHT.push_back(
0221         ibooker.book1D("etsum_phi_bx_MHT_" + bx_obj[i],
0222                        "L1T EtSum MHT p_{T}#geq" + etsumPtCutStr + " GeV #phi BX=" + bx_obj[i] + ";#phi",
0223                        25,
0224                        -3.2,
0225                        3.2));
0226     etsum_eta_phi_MHTHF.push_back(
0227         ibooker.book1D("etsum_phi_bx_MHTHF_" + bx_obj[i],
0228                        "L1T EtSum MHTHF p_{T}#geq" + etsumPtCutStr + " GeV #phi BX=" + bx_obj[i] + ";#phi",
0229                        25,
0230                        -3.2,
0231                        3.2));
0232   }
0233   denominator_etsum_MET = ibooker.book1D(
0234       "denominator_etsum_MET", "Denominator for L1T EtSum MET p_{T}#geq" + etsumPtCutStr + " GeV;#phi", 25, -3.2, 3.2);
0235   denominator_etsum_METHF = ibooker.book1D("denominator_etsum_METHF",
0236                                            "Denominator for L1T EtSum METHF p_{T}#geq" + etsumPtCutStr + " GeV;#phi",
0237                                            25,
0238                                            -3.2,
0239                                            3.2);
0240   denominator_etsum_MHT = ibooker.book1D(
0241       "denominator_etsum_MHT", "Denominator for L1T EtSum MHT p_{T}#geq" + etsumPtCutStr + " GeV;#phi", 25, -3.2, 3.2);
0242   denominator_etsum_MHTHF = ibooker.book1D("denominator_etsum_MHTHF",
0243                                            "Denominator for L1T EtSum MHTHF p_{T}#geq" + etsumPtCutStr + " GeV;#phi",
0244                                            25,
0245                                            -3.2,
0246                                            3.2);
0247 
0248   // isolated bunch
0249   if (algoBitIsoBx_ > -1) {
0250     ibooker.setCurrentFolder(monitorDir_ + "/L1TMuon/timing/Isolated_bunch");
0251     for (unsigned int i = 0; i < bxrange_; ++i) {
0252       muons_eta_phi_isolated.push_back(
0253           ibooker.book2D("muons_eta_phi_bx_isolated_" + bx_obj[i],
0254                          "L1T Muon p_{T}#geq" + muonPtCutStr + " GeV qual#geq" + muonQualCutStr +
0255                              " #eta vs #phi for isolated bunch BX=" + bx_obj[i] + ";#eta;#phi",
0256                          25,
0257                          -2.5,
0258                          2.5,
0259                          25,
0260                          -3.2,
0261                          3.2));
0262     }
0263     denominator_muons_isolated = ibooker.book2D(
0264         "denominator_muons_isolated",
0265         "Denominator for Isolated Bunch for L1T Muon p_{T}#geq" + muonPtCutStr + " GeV qual#geq" + muonQualCutStr,
0266         25,
0267         -2.5,
0268         2.5,
0269         25,
0270         -3.2,
0271         3.2);
0272 
0273     ibooker.setCurrentFolder(monitorDir_ + "/L1TJet/timing/Isolated_bunch");
0274     for (unsigned int i = 0; i < bxrange_; ++i) {
0275       jet_eta_phi_isolated.push_back(ibooker.book2D(
0276           "jet_eta_phi_bx_isolated_" + bx_obj[i],
0277           "L1T Jet p_{T}#geq" + jetPtCutStr + " GeV #eta vs #phi for isolated bunch BX=" + bx_obj[i] + ";#eta;#phi",
0278           50,
0279           -5.,
0280           5.,
0281           25,
0282           -3.2,
0283           3.2));
0284     }
0285     denominator_jet_isolated =
0286         ibooker.book2D("denominator_jet_isolated",
0287                        "Denominator for Isolated Bunch for L1T Jet p_{T}#geq" + jetPtCutStr + " GeV;#eta;#phi",
0288                        50,
0289                        -5.,
0290                        5.,
0291                        25,
0292                        -3.2,
0293                        3.2);
0294 
0295     for (const auto egammaPtCut : egammaPtCuts_) {
0296       auto egammaPtCutStr = std::to_string(egammaPtCut);
0297       egammaPtCutStr.resize(egammaPtCutStr.size() - 5);  // cut some decimal digits
0298       auto egammaPtCutStrAlpha = egammaPtCutStr;
0299       std::replace(egammaPtCutStrAlpha.begin(),
0300                    egammaPtCutStrAlpha.end(),
0301                    '.',
0302                    'p');  // replace the decimal dot with a 'p' to please the DQMStore
0303 
0304       ibooker.setCurrentFolder(monitorDir_ + "/L1TEGamma/timing/Isolated_bunch/ptmin_" + egammaPtCutStrAlpha + "_gev");
0305       std::vector<MonitorElement*> vHelper;
0306       for (unsigned int i = 0; i < bxrange_; ++i) {
0307         vHelper.push_back(ibooker.book2D("egamma_eta_phi_bx_isolated_" + bx_obj[i],
0308                                          "L1T EGamma p_{T}#geq" + egammaPtCutStr +
0309                                              " GeV #eta vs #phi for first bunch BX=" + bx_obj[i] + ";#eta;#phi",
0310                                          30,
0311                                          -3.,
0312                                          3.,
0313                                          25,
0314                                          -3.2,
0315                                          3.2));
0316       }
0317       egamma_eta_phi_isolated.push_back(vHelper);
0318 
0319       denominator_egamma_isolated.push_back(
0320           ibooker.book2D("denominator_egamma_isolated",
0321                          "Denominator for Isolated Bunch for L1T EGamma p_{T}#geq" + egammaPtCutStr + " GeV;#eta;#phi",
0322                          30,
0323                          -3.,
0324                          3.,
0325                          25,
0326                          -3.2,
0327                          3.2));
0328 
0329       egamma_iso_bx_ieta_isolated.push_back(
0330           ibooker.book2D("egamma_iso_bx_ieta_isolated_ptmin" + egammaPtCutStrAlpha,
0331                          "L1T EGamma iso with pT#geq" + egammaPtCutStr +
0332                              " GeV BX vs. i#eta for first bunch in train;BX in event (corrected);i#eta",
0333                          5,
0334                          -2.5,
0335                          2.5,
0336                          70,
0337                          -70,
0338                          70));
0339 
0340       egamma_noniso_bx_ieta_isolated.push_back(
0341           ibooker.book2D("egamma_noniso_bx_ieta_isolated_ptmin" + egammaPtCutStrAlpha,
0342                          "L1T EGamma non iso with pT#geq" + egammaPtCutStr +
0343                              " GeV BX vs. i#eta for first bunch in train;BX in event (corrected);i#eta",
0344                          5,
0345                          -2.5,
0346                          2.5,
0347                          70,
0348                          -70,
0349                          70));
0350     }
0351 
0352     ibooker.setCurrentFolder(monitorDir_ + "/L1TTau/timing/Isolated_bunch");
0353     for (unsigned int i = 0; i < bxrange_; ++i) {
0354       tau_eta_phi_isolated.push_back(ibooker.book2D(
0355           "tau_eta_phi_bx_isolated_" + bx_obj[i],
0356           "L1T Tau p_{T}#geq" + tauPtCutStr + " GeV #eta vs #phi for isolated bunch BX=" + bx_obj[i] + ";#eta;#phi",
0357           30,
0358           -3.,
0359           3.,
0360           25,
0361           -3.2,
0362           3.2));
0363     }
0364     denominator_tau_isolated =
0365         ibooker.book2D("denominator_tau_isolated",
0366                        "Denominator for Isolated Bunch for L1T Tau p_{T}#geq" + tauPtCutStr + " GeV;#eta;#phi",
0367                        30,
0368                        -3.,
0369                        3.,
0370                        25,
0371                        -3.2,
0372                        3.2);
0373 
0374     ibooker.setCurrentFolder(monitorDir_ + "/L1TEtSum/timing/Isolated_bunch");
0375     for (unsigned int i = 0; i < bxrange_; ++i) {
0376       etsum_eta_phi_MET_isolated.push_back(ibooker.book1D(
0377           "etsum_phi_bx_MET_isolated_" + bx_obj[i],
0378           "L1T EtSum MET p_{T}#geq" + etsumPtCutStr + " GeV #phi for isolated bunch BX=" + bx_obj[i] + ";#phi",
0379           25,
0380           -3.2,
0381           3.2));
0382       etsum_eta_phi_METHF_isolated.push_back(ibooker.book1D(
0383           "etsum_phi_bx_METHF_isolated_" + bx_obj[i],
0384           "L1T EtSum METHF p_{T}#geq" + etsumPtCutStr + " GeV #phi for isolated bunch BX=" + bx_obj[i] + ";#phi",
0385           25,
0386           -3.2,
0387           3.2));
0388       etsum_eta_phi_MHT_isolated.push_back(ibooker.book1D(
0389           "etsum_phi_bx_MHT_isolated_" + bx_obj[i],
0390           "L1T EtSum MHT p_{T}#geq" + etsumPtCutStr + " GeV #phi for isolated bunch BX=" + bx_obj[i] + ";#phi",
0391           25,
0392           -3.2,
0393           3.2));
0394       etsum_eta_phi_MHTHF_isolated.push_back(ibooker.book1D(
0395           "etsum_phi_bx_MHTHF_isolated_" + bx_obj[i],
0396           "L1T EtSum MHTHF p_{T}#geq" + etsumPtCutStr + " GeV #phi for isolated bunch BX=" + bx_obj[i] + ";#phi",
0397           25,
0398           -3.2,
0399           3.2));
0400     }
0401     denominator_etsum_isolated_MET =
0402         ibooker.book1D("denominator_etsum_isolated_MET",
0403                        "Denominator for Isolated Bunch for L1T EtSum MET p_{T}#geq" + etsumPtCutStr + " GeV;#phi",
0404                        25,
0405                        -3.2,
0406                        3.2);
0407     denominator_etsum_isolated_METHF =
0408         ibooker.book1D("denominator_etsum_isolated_METHF",
0409                        "Denominator for Isolated Bunch for L1T EtSum METHF p_{T}#geq" + etsumPtCutStr + " GeV;#phi",
0410                        25,
0411                        -3.2,
0412                        3.2);
0413     denominator_etsum_isolated_MHT =
0414         ibooker.book1D("denominator_etsum_isolated_MHT",
0415                        "Denominator for Isolated Bunch for L1T EtSum MHT p_{T}#geq" + etsumPtCutStr + " GeV;#phi",
0416                        25,
0417                        -3.2,
0418                        3.2);
0419     denominator_etsum_isolated_MHTHF =
0420         ibooker.book1D("denominator_etsum_isolated_MHTHF",
0421                        "Denominator for Isolated Bunch for L1T EtSum MHTHF p_{T}#geq" + etsumPtCutStr + " GeV;#phi",
0422                        25,
0423                        -3.2,
0424                        3.2);
0425   }
0426 
0427   if (algoBitFirstBxInTrain_ > -1) {
0428     // first bunch in train
0429     ibooker.setCurrentFolder(monitorDir_ + "/L1TMuon/timing/First_bunch");
0430     for (unsigned int i = 0; i < bxrange_ - 2; ++i) {
0431       muons_eta_phi_firstbunch.push_back(
0432           ibooker.book2D("muons_eta_phi_bx_firstbunch_" + bx_obj[i],
0433                          "L1T Muon p_{T}#geq" + muonPtCutStr + " GeV qual#geq" + muonQualCutStr +
0434                              " #eta vs #phi for first bunch BX=" + bx_obj[i] + ";#eta;#phi",
0435                          25,
0436                          -2.5,
0437                          2.5,
0438                          25,
0439                          -3.2,
0440                          3.2));
0441     }
0442     denominator_muons_firstbunch = ibooker.book2D(
0443         "denominator_muons_firstbunch",
0444         "Denominator for First Bunch for L1T Muon p_{T}#geq" + muonPtCutStr + " GeV qual#geq" + muonQualCutStr,
0445         25,
0446         -2.5,
0447         2.5,
0448         25,
0449         -3.2,
0450         3.2);
0451 
0452     ibooker.setCurrentFolder(monitorDir_ + "/L1TJet/timing/First_bunch");
0453     for (unsigned int i = 0; i < bxrange_ - 2; ++i) {
0454       jet_eta_phi_firstbunch.push_back(ibooker.book2D(
0455           "jet_eta_phi_bx_firstbunch_" + bx_obj[i],
0456           "L1T Jet p_{T}#geq" + jetPtCutStr + " GeV #eta vs #phi for first bunch BX=" + bx_obj[i] + ";#eta;#phi",
0457           50,
0458           -5.,
0459           5.,
0460           25,
0461           -3.2,
0462           3.2));
0463     }
0464     denominator_jet_firstbunch =
0465         ibooker.book2D("denominator_jet_firstbunch",
0466                        "Denominator for First Bunch for L1T Jet p_{T}#geq" + jetPtCutStr + " GeV;#eta;#phi",
0467                        50,
0468                        -5.,
0469                        5.,
0470                        25,
0471                        -3.2,
0472                        3.2);
0473 
0474     for (const auto egammaPtCut : egammaPtCuts_) {
0475       auto egammaPtCutStr = std::to_string(egammaPtCut);
0476       egammaPtCutStr.resize(egammaPtCutStr.size() - 5);  // cut some decimal digits
0477       auto egammaPtCutStrAlpha = egammaPtCutStr;
0478       std::replace(egammaPtCutStrAlpha.begin(),
0479                    egammaPtCutStrAlpha.end(),
0480                    '.',
0481                    'p');  // replace the decimal dot with a 'p' to please the DQMStore
0482 
0483       ibooker.setCurrentFolder(monitorDir_ + "/L1TEGamma/timing/First_bunch/ptmin_" + egammaPtCutStrAlpha + "_gev");
0484       std::vector<MonitorElement*> vHelper;
0485       for (unsigned int i = 0; i < bxrange_ - 2; ++i) {
0486         vHelper.push_back(ibooker.book2D("egamma_eta_phi_bx_firstbunch_" + bx_obj[i],
0487                                          "L1T EGamma p_{T}#geq" + egammaPtCutStr +
0488                                              " GeV #eta vs #phi for first bunch BX=" + bx_obj[i] + ";#eta;#phi",
0489                                          30,
0490                                          -3.,
0491                                          3.,
0492                                          25,
0493                                          -3.2,
0494                                          3.2));
0495       }
0496       egamma_eta_phi_firstbunch.push_back(vHelper);
0497 
0498       denominator_egamma_firstbunch.push_back(
0499           ibooker.book2D("denominator_egamma_firstbunch",
0500                          "Denominator for First Bunch for L1T EGamma p_{T}#geq" + egammaPtCutStr + " GeV;#eta;#phi",
0501                          30,
0502                          -3.,
0503                          3.,
0504                          25,
0505                          -3.2,
0506                          3.2));
0507 
0508       egamma_iso_bx_ieta_firstbunch.push_back(
0509           ibooker.book2D("egamma_iso_bx_ieta_firstbunch_ptmin" + egammaPtCutStrAlpha,
0510                          "L1T EGamma iso with pT#geq" + egammaPtCutStr +
0511                              " GeV BX vs. i#eta for first bunch in train;BX in event (corrected);i#eta",
0512                          5,
0513                          -2.5,
0514                          2.5,
0515                          70,
0516                          -70,
0517                          70));
0518 
0519       egamma_noniso_bx_ieta_firstbunch.push_back(
0520           ibooker.book2D("egamma_noniso_bx_ieta_firstbunch_ptmin" + egammaPtCutStrAlpha,
0521                          "L1T EGamma non iso with pT#geq" + egammaPtCutStr +
0522                              " GeV BX vs. i#eta for first bunch in train;BX in event (corrected);i#eta",
0523                          5,
0524                          -2.5,
0525                          2.5,
0526                          70,
0527                          -70,
0528                          70));
0529     }
0530 
0531     ibooker.setCurrentFolder(monitorDir_ + "/L1TTau/timing/First_bunch");
0532     for (unsigned int i = 0; i < bxrange_ - 2; ++i) {
0533       tau_eta_phi_firstbunch.push_back(ibooker.book2D(
0534           "tau_eta_phi_bx_firstbunch_" + bx_obj[i],
0535           "L1T Tau p_{T}#geq" + tauPtCutStr + " GeV #eta vs #phi for first bunch BX=" + bx_obj[i] + ";#eta;#phi",
0536           30,
0537           -3.,
0538           3.,
0539           25,
0540           -3.2,
0541           3.2));
0542     }
0543     denominator_tau_firstbunch =
0544         ibooker.book2D("denominator_tau_firstbunch",
0545                        "Denominator for First Bunch for L1T Tau p_{T}#geq" + tauPtCutStr + " GeV;#eta;#phi",
0546                        30,
0547                        -3.,
0548                        3.,
0549                        25,
0550                        -3.2,
0551                        3.2);
0552 
0553     ibooker.setCurrentFolder(monitorDir_ + "/L1TEtSum/timing/First_bunch");
0554     for (unsigned int i = 0; i < bxrange_ - 2; ++i) {
0555       etsum_eta_phi_MET_firstbunch.push_back(ibooker.book1D(
0556           "etsum_phi_bx_MET_firstbunch_" + bx_obj[i],
0557           "L1T EtSum MET p_{T}#geq" + etsumPtCutStr + " GeV #phi for firstbunch bunch BX=" + bx_obj[i] + ";#phi",
0558           25,
0559           -3.2,
0560           3.2));
0561       etsum_eta_phi_METHF_firstbunch.push_back(ibooker.book1D(
0562           "etsum_phi_bx_METHF_firstbunch_" + bx_obj[i],
0563           "L1T EtSum METHF p_{T}#geq" + etsumPtCutStr + " GeV #phi for firstbunch bunch BX=" + bx_obj[i] + ";#phi",
0564           25,
0565           -3.2,
0566           3.2));
0567       etsum_eta_phi_MHT_firstbunch.push_back(ibooker.book1D(
0568           "etsum_phi_bx_MHT_firstbunch_" + bx_obj[i],
0569           "L1T EtSum MHT p_{T}#geq" + etsumPtCutStr + " GeV #phi for firstbunch bunch BX=" + bx_obj[i] + ";#phi",
0570           25,
0571           -3.2,
0572           3.2));
0573       etsum_eta_phi_MHTHF_firstbunch.push_back(ibooker.book1D(
0574           "etsum_phi_bx_MHTHF_firstbunch_" + bx_obj[i],
0575           "L1T EtSum MHTHF p_{T}#geq" + etsumPtCutStr + " GeV #phi for firstbunch bunch BX=" + bx_obj[i] + ";#phi",
0576           25,
0577           -3.2,
0578           3.2));
0579     }
0580     denominator_etsum_firstbunch_MET =
0581         ibooker.book1D("denominator_etsum_firstbunch_MET",
0582                        "Denominator for First Bunch for L1T EtSum MET p_{T}#geq" + etsumPtCutStr + " GeV;#phi",
0583                        25,
0584                        -3.2,
0585                        3.2);
0586     denominator_etsum_firstbunch_METHF =
0587         ibooker.book1D("denominator_etsum_firstbunch_METHF",
0588                        "Denominator for First Bunch for L1T EtSum METHF p_{T}#geq" + etsumPtCutStr + " GeV;#phi",
0589                        25,
0590                        -3.2,
0591                        3.2);
0592     denominator_etsum_firstbunch_MHT =
0593         ibooker.book1D("denominator_etsum_firstbunch_MHT",
0594                        "Denominator for First Bunch for L1T EtSum MHT p_{T}#geq" + etsumPtCutStr + " GeV;#phi",
0595                        25,
0596                        -3.2,
0597                        3.2);
0598     denominator_etsum_firstbunch_MHTHF =
0599         ibooker.book1D("denominator_etsum_firstbunch_MHTHF",
0600                        "Denominator for First Bunch for L1T EtSum MHTHF p_{T}#geq" + etsumPtCutStr + " GeV;#phi",
0601                        25,
0602                        -3.2,
0603                        3.2);
0604   }
0605 
0606   // last bunch in train
0607   if (algoBitLastBxInTrain_ > -1) {
0608     ibooker.setCurrentFolder(monitorDir_ + "/L1TMuon/timing/Last_bunch");
0609     for (unsigned int i = 0; i < bxrange_ - 2; ++i) {
0610       muons_eta_phi_lastbunch.push_back(
0611           ibooker.book2D("muons_eta_phi_bx_lastbunch_" + bx_obj[i + 2],
0612                          "L1T Muon p_{T}#geq" + muonPtCutStr + " GeV qual#geq" + muonQualCutStr +
0613                              " #eta vs #phi for last bunch BX=" + bx_obj[i] + ";#eta;#phi",
0614                          25,
0615                          -2.5,
0616                          2.5,
0617                          25,
0618                          -3.2,
0619                          3.2));
0620     }
0621     denominator_muons_lastbunch = ibooker.book2D(
0622         "denominator_muons_lastbunch",
0623         "Denominator for Last Bunch for L1T Muon p_{T}#geq" + muonPtCutStr + " GeV qual#geq" + muonQualCutStr,
0624         25,
0625         -2.5,
0626         2.5,
0627         25,
0628         -3.2,
0629         3.2);
0630 
0631     ibooker.setCurrentFolder(monitorDir_ + "/L1TJet/timing/Last_bunch");
0632     for (unsigned int i = 0; i < bxrange_ - 2; ++i) {
0633       jet_eta_phi_lastbunch.push_back(ibooker.book2D(
0634           "jet_eta_phi_bx_lastbunch_" + bx_obj[i + 2],
0635           "L1T Jet p_{T}#geq" + jetPtCutStr + " GeV #eta vs #phi for last bunch BX=" + bx_obj[i] + ";#eta;#phi",
0636           50,
0637           -5.,
0638           5.,
0639           25,
0640           -3.2,
0641           3.2));
0642     }
0643     denominator_jet_lastbunch =
0644         ibooker.book2D("denominator_jet_lastbunch",
0645                        "Denominator for Last Bunch for L1T Jet p_{T}#geq" + jetPtCutStr + " GeV;#eta;#phi",
0646                        50,
0647                        -5.,
0648                        5.,
0649                        25,
0650                        -3.2,
0651                        3.2);
0652 
0653     for (const auto egammaPtCut : egammaPtCuts_) {
0654       auto egammaPtCutStr = std::to_string(egammaPtCut);
0655       egammaPtCutStr.resize(egammaPtCutStr.size() - 5);  // cut some decimal digits
0656       auto egammaPtCutStrAlpha = egammaPtCutStr;
0657       std::replace(egammaPtCutStrAlpha.begin(),
0658                    egammaPtCutStrAlpha.end(),
0659                    '.',
0660                    'p');  // replace the decimal dot with a 'p' to please the DQMStore
0661 
0662       ibooker.setCurrentFolder(monitorDir_ + "/L1TEGamma/timing/Last_bunch/ptmin_" + egammaPtCutStrAlpha + "_gev");
0663       std::vector<MonitorElement*> vHelper;
0664       for (unsigned int i = 0; i < bxrange_ - 2; ++i) {
0665         vHelper.push_back(ibooker.book2D("egamma_eta_phi_bx_lastbunch_" + bx_obj[i + 2],
0666                                          "L1T EGamma p_{T}#geq" + egammaPtCutStr +
0667                                              " GeV #eta vs #phi for first bunch BX=" + bx_obj[i] + ";#eta;#phi",
0668                                          30,
0669                                          -3.,
0670                                          3.,
0671                                          25,
0672                                          -3.2,
0673                                          3.2));
0674       }
0675       egamma_eta_phi_lastbunch.push_back(vHelper);
0676 
0677       denominator_egamma_lastbunch.push_back(
0678           ibooker.book2D("denominator_egamma_lastbunch",
0679                          "Denominator for Last Bunch for L1T EGamma p_{T}#geq" + egammaPtCutStr + " GeV;#eta;#phi",
0680                          30,
0681                          -3.,
0682                          3.,
0683                          25,
0684                          -3.2,
0685                          3.2));
0686 
0687       egamma_iso_bx_ieta_lastbunch.push_back(
0688           ibooker.book2D("egamma_iso_bx_ieta_lastbunch_ptmin" + egammaPtCutStrAlpha,
0689                          "L1T EGamma iso with pT#geq" + egammaPtCutStr +
0690                              " GeV BX vs. i#eta for first bunch in train;BX in event (corrected);i#eta",
0691                          5,
0692                          -2.5,
0693                          2.5,
0694                          70,
0695                          -70,
0696                          70));
0697 
0698       egamma_noniso_bx_ieta_lastbunch.push_back(
0699           ibooker.book2D("egamma_noniso_bx_ieta_lastbunch_ptmin" + egammaPtCutStrAlpha,
0700                          "L1T EGamma non iso with pT#geq" + egammaPtCutStr +
0701                              " GeV BX vs. i#eta for first bunch in train;BX in event (corrected);i#eta",
0702                          5,
0703                          -2.5,
0704                          2.5,
0705                          70,
0706                          -70,
0707                          70));
0708     }
0709 
0710     ibooker.setCurrentFolder(monitorDir_ + "/L1TTau/timing/Last_bunch");
0711     for (unsigned int i = 0; i < bxrange_ - 2; ++i) {
0712       tau_eta_phi_lastbunch.push_back(ibooker.book2D(
0713           "tau_eta_phi_bx_lastbunch_" + bx_obj[i + 2],
0714           "L1T Tau p_{T}#geq" + tauPtCutStr + " GeV #eta vs #phi for last bunch BX=" + bx_obj[i] + ";#eta;#phi",
0715           30,
0716           -3.,
0717           3.,
0718           25,
0719           -3.2,
0720           3.2));
0721     }
0722     denominator_tau_lastbunch =
0723         ibooker.book2D("denominator_tau_lastbunch",
0724                        "Denominator for Last Bunch for L1T Tau p_{T}#geq" + tauPtCutStr + " GeV;#eta;#phi",
0725                        30,
0726                        -3.,
0727                        3.,
0728                        25,
0729                        -3.2,
0730                        3.2);
0731 
0732     ibooker.setCurrentFolder(monitorDir_ + "/L1TEtSum/timing/Last_bunch");
0733     for (unsigned int i = 0; i < bxrange_ - 2; ++i) {
0734       etsum_eta_phi_MET_lastbunch.push_back(ibooker.book1D(
0735           "etsum_phi_bx_MET_lastbunch_" + bx_obj[i + 2],
0736           "L1T EtSum MET p_{T}#geq" + etsumPtCutStr + " GeV #phi for lastbunch bunch BX=" + bx_obj[i] + ";#phi",
0737           25,
0738           -3.2,
0739           3.2));
0740       etsum_eta_phi_METHF_lastbunch.push_back(ibooker.book1D(
0741           "etsum_phi_bx_METHF_lastbunch_" + bx_obj[i + 2],
0742           "L1T EtSum METHF p_{T}#geq" + etsumPtCutStr + " GeV #phi for lastbunch bunch BX=" + bx_obj[i] + ";#phi",
0743           25,
0744           -3.2,
0745           3.2));
0746       etsum_eta_phi_MHT_lastbunch.push_back(ibooker.book1D(
0747           "etsum_phi_bx_MHT_lastbunch_" + bx_obj[i + 2],
0748           "L1T EtSum MHT p_{T}#geq" + etsumPtCutStr + " GeV #phi for lastbunch bunch BX=" + bx_obj[i] + ";#phi",
0749           25,
0750           -3.2,
0751           3.2));
0752       etsum_eta_phi_MHTHF_lastbunch.push_back(ibooker.book1D(
0753           "etsum_phi_bx_MHTHF_lastbunch_" + bx_obj[i + 2],
0754           "L1T EtSum MHTHF p_{T}#geq" + etsumPtCutStr + " GeV #phi for lastbunch bunch BX=" + bx_obj[i] + ";#phi",
0755           25,
0756           -3.2,
0757           3.2));
0758     }
0759     denominator_etsum_lastbunch_MET =
0760         ibooker.book1D("denominator_etsum_lastbunch_MET",
0761                        "Denominator for Last Bunch for L1T EtSum MET p_{T}#geq" + etsumPtCutStr + " GeV;#phi",
0762                        25,
0763                        -3.2,
0764                        3.2);
0765     denominator_etsum_lastbunch_METHF =
0766         ibooker.book1D("denominator_etsum_lastbunch_METHF",
0767                        "Denominator for Last Bunch for L1T EtSum METHF p_{T}#geq" + etsumPtCutStr + " GeV;#phi",
0768                        25,
0769                        -3.2,
0770                        3.2);
0771     denominator_etsum_lastbunch_MHT =
0772         ibooker.book1D("denominator_etsum_lastbunch_MHT",
0773                        "Denominator for Last Bunch for L1T EtSum MHT p_{T}#geq" + etsumPtCutStr + " GeV;#phi",
0774                        25,
0775                        -3.2,
0776                        3.2);
0777     denominator_etsum_lastbunch_MHTHF =
0778         ibooker.book1D("denominator_etsum_lastbunch_MHTHF",
0779                        "Denominator for Last Bunch for L1T EtSum MHTHF p_{T}#geq" + etsumPtCutStr + " GeV;#phi",
0780                        25,
0781                        -3.2,
0782                        3.2);
0783   }
0784 }
0785 
0786 void L1TObjectsTiming::analyze(const edm::Event& e, const edm::EventSetup& c) {
0787   if (verbose_)
0788     edm::LogInfo("L1TObjectsTiming") << "L1TObjectsTiming: analyze..." << std::endl;
0789 
0790   // Muon Collection
0791   edm::Handle<l1t::MuonBxCollection> MuonBxCollection;
0792   e.getByToken(ugmtMuonToken_, MuonBxCollection);
0793   // Jet Collection
0794   edm::Handle<l1t::JetBxCollection> JetBxCollection;
0795   e.getByToken(stage2CaloLayer2JetToken_, JetBxCollection);
0796   // EGamma Collection
0797   edm::Handle<l1t::EGammaBxCollection> EGammaBxCollection;
0798   e.getByToken(stage2CaloLayer2EGammaToken_, EGammaBxCollection);
0799   // Tau Collection
0800   edm::Handle<l1t::TauBxCollection> TauBxCollection;
0801   e.getByToken(stage2CaloLayer2TauToken_, TauBxCollection);
0802   // EtSum Collection
0803   edm::Handle<l1t::EtSumBxCollection> EtSumBxCollection;
0804   e.getByToken(stage2CaloLayer2EtSumToken_, EtSumBxCollection);
0805 
0806   // Open uGT readout record
0807   edm::Handle<GlobalAlgBlkBxCollection> uGtAlgs;
0808   e.getByToken(l1tStage2uGtProducer_, uGtAlgs);
0809 
0810   // Filling eta-phi map for muons for BX=-2,-1,0,+1,+2
0811   for (int itBX = MuonBxCollection->getFirstBX(); itBX <= MuonBxCollection->getLastBX(); ++itBX) {
0812     for (l1t::MuonBxCollection::const_iterator Muon = MuonBxCollection->begin(itBX);
0813          Muon != MuonBxCollection->end(itBX);
0814          ++Muon) {
0815       if (Muon->pt() >= muonPtCut_ and Muon->hwQual() >= muonQualCut_) {
0816         denominator_muons->Fill(Muon->eta(), Muon->phi());
0817         // the correlation from itBX to respective index of the vector
0818         int index = (int)itBX - std::min(0, 1 - (int)bxrange_ % 2 - (int)std::floor(bxrange_ / 2.));
0819         muons_eta_phi.at(index)->Fill(Muon->eta(), Muon->phi());
0820       }
0821     }
0822   }
0823 
0824   // Filling eta-phi map for jets for BX=-2,-1,0,+1,+2
0825   for (int itBX = JetBxCollection->getFirstBX(); itBX <= JetBxCollection->getLastBX(); ++itBX) {
0826     for (l1t::JetBxCollection::const_iterator jet = JetBxCollection->begin(itBX); jet != JetBxCollection->end(itBX);
0827          ++jet) {
0828       if (jet->pt() >= jetPtCut_) {
0829         denominator_jet->Fill(jet->eta(), jet->phi());
0830         int index =
0831             itBX - std::min(0,
0832                             1 - (int)bxrange_ % 2 -
0833                                 (int)std::floor(bxrange_ /
0834                                                 2.));  // the correlation from itBX to respective index of the vector
0835         jet_eta_phi.at(index)->Fill(jet->eta(), jet->phi());
0836       }
0837     }
0838   }
0839 
0840   // Filling eta-phi map for egamma for BX=-2,-1,0,+1,+2
0841   for (int itBX = EGammaBxCollection->getFirstBX(); itBX <= EGammaBxCollection->getLastBX(); ++itBX) {
0842     for (l1t::EGammaBxCollection::const_iterator egamma = EGammaBxCollection->begin(itBX);
0843          egamma != EGammaBxCollection->end(itBX);
0844          ++egamma) {
0845       if (egamma->pt() >= egammaPtCut_) {
0846         denominator_egamma->Fill(egamma->eta(), egamma->phi());
0847         int index =
0848             itBX - std::min(0,
0849                             1 - (int)bxrange_ % 2 -
0850                                 (int)std::floor(bxrange_ /
0851                                                 2.));  // the correlation from itBX to respective index of the vector
0852         egamma_eta_phi.at(index)->Fill(egamma->eta(), egamma->phi());
0853       }
0854     }
0855   }
0856 
0857   // Filling eta-phi map for tau for BX=-2,-1,0,+1,+2
0858   for (int itBX = TauBxCollection->getFirstBX(); itBX <= TauBxCollection->getLastBX(); ++itBX) {
0859     for (l1t::TauBxCollection::const_iterator tau = TauBxCollection->begin(itBX); tau != TauBxCollection->end(itBX);
0860          ++tau) {
0861       if (tau->pt() >= tauPtCut_) {
0862         denominator_tau->Fill(tau->eta(), tau->phi());
0863         int index =
0864             itBX - std::min(0,
0865                             1 - (int)bxrange_ % 2 -
0866                                 (int)std::floor(bxrange_ /
0867                                                 2.));  // the correlation from itBX to respective index of the vector
0868         tau_eta_phi.at(index)->Fill(tau->eta(), tau->phi());
0869       }
0870     }
0871   }
0872 
0873   // Filling eta-phi map for etsum for BX=-2,-1,0,+1,+2
0874   for (int itBX = EtSumBxCollection->getFirstBX(); itBX <= EtSumBxCollection->getLastBX(); ++itBX) {
0875     for (l1t::EtSumBxCollection::const_iterator EtSum = EtSumBxCollection->begin(itBX);
0876          EtSum != EtSumBxCollection->end(itBX);
0877          ++EtSum) {
0878       if (EtSum->pt() >= etsumPtCut_) {
0879         int index =
0880             itBX - std::min(0,
0881                             1 - (int)bxrange_ % 2 -
0882                                 (int)std::floor(bxrange_ /
0883                                                 2.));  // the correlation from itBX to respective index of the vector
0884         if (l1t::EtSum::EtSumType::kMissingEt == EtSum->getType()) {
0885           etsum_eta_phi_MET.at(index)->Fill(EtSum->phi());
0886           denominator_etsum_MET->Fill(EtSum->phi());
0887         } else if (l1t::EtSum::EtSumType::kMissingEtHF == EtSum->getType()) {
0888           etsum_eta_phi_METHF.at(index)->Fill(EtSum->phi());
0889           denominator_etsum_METHF->Fill(EtSum->phi());
0890 
0891         } else if (l1t::EtSum::EtSumType::kMissingHt == EtSum->getType()) {
0892           etsum_eta_phi_MHT.at(index)->Fill(EtSum->phi());
0893           denominator_etsum_MHT->Fill(EtSum->phi());
0894 
0895         } else if (l1t::EtSum::EtSumType::kMissingHtHF == EtSum->getType()) {
0896           etsum_eta_phi_MHTHF.at(index)->Fill(EtSum->phi());
0897           denominator_etsum_MHTHF->Fill(EtSum->phi());
0898         }
0899       }
0900     }
0901   }
0902 
0903   // Find out in which BX the first collision in train, isolated bunch, and last collision in train have fired.
0904   // In case of pre firing it will be in BX 1 or BX 2 and this will determine the BX shift that
0905   // will be applied to the timing histogram later.
0906   int bxShiftFirst = -999;
0907   int bxShiftIso = -999;
0908   int bxShiftLast = -999;
0909   for (int bx = uGtAlgs->getFirstBX(); bx <= uGtAlgs->getLastBX(); ++bx) {
0910     for (GlobalAlgBlkBxCollection::const_iterator itr = uGtAlgs->begin(bx); itr != uGtAlgs->end(bx); ++itr) {
0911       // first bunch in train
0912       if (algoBitFirstBxInTrain_ != -1) {
0913         bool bit = false;
0914         switch (useAlgoDecision_) {
0915           case 0:
0916             bit = itr->getAlgoDecisionInitial(algoBitFirstBxInTrain_);
0917             break;
0918           case 1:
0919             bit = itr->getAlgoDecisionInterm(algoBitFirstBxInTrain_);
0920             break;
0921           case 2:
0922             bit = itr->getAlgoDecisionFinal(algoBitFirstBxInTrain_);
0923             break;
0924         }
0925         if (bit) {
0926           bxShiftFirst = bx;
0927         }
0928       }
0929       // last bunch in train
0930       if (algoBitLastBxInTrain_ != -1) {
0931         bool bit = false;
0932         switch (useAlgoDecision_) {
0933           case 0:
0934             bit = itr->getAlgoDecisionInitial(algoBitLastBxInTrain_);
0935             break;
0936           case 1:
0937             bit = itr->getAlgoDecisionInterm(algoBitLastBxInTrain_);
0938             break;
0939           case 2:
0940             bit = itr->getAlgoDecisionFinal(algoBitLastBxInTrain_);
0941             break;
0942         }
0943         if (bit) {
0944           bxShiftLast = bx;
0945         }
0946       }
0947       // isolated bunch
0948       if (algoBitIsoBx_ != -1) {
0949         bool bit = false;
0950         switch (useAlgoDecision_) {
0951           case 0:
0952             bit = itr->getAlgoDecisionInitial(algoBitIsoBx_);
0953             break;
0954           case 1:
0955             bit = itr->getAlgoDecisionInterm(algoBitIsoBx_);
0956             break;
0957           case 2:
0958             bit = itr->getAlgoDecisionFinal(algoBitIsoBx_);
0959             break;
0960         }
0961         if (bit) {
0962           bxShiftIso = bx;
0963         }
0964       }
0965     }
0966   }
0967 
0968   // fill the first bunch in train maps
0969   if (bxShiftFirst > -999) {
0970     // muons
0971     for (int itBX = std::max(MuonBxCollection->getFirstBX(), MuonBxCollection->getFirstBX() + bxShiftFirst);
0972          itBX <= std::min(MuonBxCollection->getLastBX(), MuonBxCollection->getLastBX() + bxShiftFirst);
0973          ++itBX) {
0974       int index = itBX - bxShiftFirst - uGtAlgs->getFirstBX();
0975       if (index >= 0 and index < (int)muons_eta_phi_firstbunch.size()) {
0976         for (l1t::MuonBxCollection::const_iterator muon = MuonBxCollection->begin(itBX);
0977              muon != MuonBxCollection->end(itBX);
0978              ++muon) {  // Starting with Muons
0979           if (muon->pt() >= muonPtCut_ and muon->hwQual() >= muonQualCut_) {
0980             denominator_muons_firstbunch->Fill(muon->eta(), muon->phi());
0981             muons_eta_phi_firstbunch.at(index)->Fill(muon->eta(), muon->phi());
0982           }
0983         }
0984       }
0985     }
0986     // jets
0987     for (int itBX = std::max(JetBxCollection->getFirstBX(), JetBxCollection->getFirstBX() + bxShiftFirst);
0988          itBX <= std::min(JetBxCollection->getLastBX(), JetBxCollection->getLastBX() + bxShiftFirst);
0989          ++itBX) {
0990       int index = itBX - bxShiftFirst - uGtAlgs->getFirstBX();
0991       if (index >= 0 and index < (int)jet_eta_phi_firstbunch.size()) {
0992         for (l1t::JetBxCollection::const_iterator jet = JetBxCollection->begin(itBX); jet != JetBxCollection->end(itBX);
0993              ++jet) {
0994           if (jet->pt() >= jetPtCut_) {
0995             denominator_jet_firstbunch->Fill(jet->eta(), jet->phi());
0996             jet_eta_phi_firstbunch.at(index)->Fill(jet->eta(), jet->phi());
0997           }
0998         }
0999       }
1000     }
1001     // egammas
1002     for (int itBX = std::max(EGammaBxCollection->getFirstBX(), EGammaBxCollection->getFirstBX() + bxShiftFirst);
1003          itBX <= std::min(EGammaBxCollection->getLastBX(), EGammaBxCollection->getLastBX() + bxShiftFirst);
1004          ++itBX) {
1005       int index = itBX - bxShiftFirst - uGtAlgs->getFirstBX();
1006       for (l1t::EGammaBxCollection::const_iterator egamma = EGammaBxCollection->begin(itBX);
1007            egamma != EGammaBxCollection->end(itBX);
1008            ++egamma) {
1009         for (size_t i = 0; i < egammaPtCuts_.size(); ++i) {
1010           if (egamma->pt() >= egammaPtCuts_.at(i)) {
1011             if (index >= 0 and index < (int)egamma_eta_phi_firstbunch.size()) {
1012               denominator_egamma_firstbunch.at(i)->Fill(egamma->eta(), egamma->phi());
1013               egamma_eta_phi_firstbunch.at(i).at(index)->Fill(egamma->eta(), egamma->phi());
1014             }
1015             if ((bool)egamma->hwIso()) {
1016               egamma_iso_bx_ieta_firstbunch.at(i)->Fill(itBX - bxShiftFirst, egamma->hwEta());
1017             }
1018             egamma_noniso_bx_ieta_firstbunch.at(i)->Fill(itBX - bxShiftFirst, egamma->hwEta());
1019           }
1020         }
1021       }
1022     }
1023     // taus
1024     for (int itBX = std::max(TauBxCollection->getFirstBX(), TauBxCollection->getFirstBX() + bxShiftFirst);
1025          itBX <= std::min(TauBxCollection->getLastBX(), TauBxCollection->getLastBX() + bxShiftFirst);
1026          ++itBX) {
1027       int index = itBX - bxShiftFirst - uGtAlgs->getFirstBX();
1028       if (index >= 0 and index < (int)tau_eta_phi_firstbunch.size()) {
1029         for (l1t::TauBxCollection::const_iterator tau = TauBxCollection->begin(itBX); tau != TauBxCollection->end(itBX);
1030              ++tau) {
1031           if (tau->pt() >= tauPtCut_) {
1032             denominator_tau_firstbunch->Fill(tau->eta(), tau->phi());
1033             tau_eta_phi_firstbunch.at(index)->Fill(tau->eta(), tau->phi());
1034           }
1035         }
1036       }
1037     }
1038     // etsums
1039     for (int itBX = std::max(EtSumBxCollection->getFirstBX(), EtSumBxCollection->getFirstBX() + bxShiftFirst);
1040          itBX <= std::min(EtSumBxCollection->getLastBX(), EtSumBxCollection->getLastBX() + bxShiftFirst);
1041          ++itBX) {
1042       int index = itBX - bxShiftFirst - uGtAlgs->getFirstBX();
1043       if (index >= 0) {
1044         for (l1t::EtSumBxCollection::const_iterator EtSum = EtSumBxCollection->begin(itBX);
1045              EtSum != EtSumBxCollection->end(itBX);
1046              ++EtSum) {
1047           if (EtSum->pt() >= etsumPtCut_) {
1048             if (l1t::EtSum::EtSumType::kMissingEt == EtSum->getType()) {
1049               if (index < (int)etsum_eta_phi_MET_firstbunch.size()) {
1050                 denominator_etsum_firstbunch_MET->Fill(EtSum->phi());
1051                 etsum_eta_phi_MET_firstbunch.at(index)->Fill(EtSum->phi());
1052               }
1053             } else if (l1t::EtSum::EtSumType::kMissingEtHF == EtSum->getType()) {
1054               if (index < (int)etsum_eta_phi_METHF_firstbunch.size()) {
1055                 denominator_etsum_firstbunch_METHF->Fill(EtSum->phi());
1056                 etsum_eta_phi_METHF_firstbunch.at(index)->Fill(EtSum->phi());
1057               }
1058             } else if (l1t::EtSum::EtSumType::kMissingHt == EtSum->getType()) {
1059               if (index < (int)etsum_eta_phi_MHT_firstbunch.size()) {
1060                 denominator_etsum_firstbunch_MHT->Fill(EtSum->phi());
1061                 etsum_eta_phi_MHT_firstbunch.at(index)->Fill(EtSum->phi());
1062               }
1063             } else if (l1t::EtSum::EtSumType::kMissingHtHF == EtSum->getType()) {
1064               if (index < (int)etsum_eta_phi_MHTHF_firstbunch.size()) {
1065                 denominator_etsum_firstbunch_MHTHF->Fill(EtSum->phi());
1066                 etsum_eta_phi_MHTHF_firstbunch.at(index)->Fill(EtSum->phi());
1067               }
1068             }
1069           }
1070         }
1071       }
1072     }
1073   }
1074 
1075   // fill the last bunch in train maps
1076   if (bxShiftLast > -999) {
1077     // muons
1078     for (int itBX = std::max(MuonBxCollection->getFirstBX(), MuonBxCollection->getFirstBX() + bxShiftLast);
1079          itBX <= std::min(MuonBxCollection->getLastBX(), MuonBxCollection->getLastBX() + bxShiftLast);
1080          ++itBX) {
1081       auto correctedBx = itBX - bxShiftLast;
1082       if (correctedBx >= 0 and correctedBx < (int)muons_eta_phi_lastbunch.size()) {
1083         for (l1t::MuonBxCollection::const_iterator muon = MuonBxCollection->begin(itBX);
1084              muon != MuonBxCollection->end(itBX);
1085              ++muon) {  // Starting with Muons
1086           if (muon->pt() >= muonPtCut_ and muon->hwQual() >= muonQualCut_) {
1087             denominator_muons_lastbunch->Fill(muon->eta(), muon->phi());
1088             muons_eta_phi_lastbunch.at(correctedBx)->Fill(muon->eta(), muon->phi());
1089           }
1090         }
1091       }
1092     }
1093     // jets
1094     for (int itBX = std::max(JetBxCollection->getFirstBX(), JetBxCollection->getFirstBX() + bxShiftLast);
1095          itBX <= std::min(JetBxCollection->getLastBX(), JetBxCollection->getLastBX() + bxShiftLast);
1096          ++itBX) {
1097       auto correctedBx = itBX - bxShiftLast;
1098       if (correctedBx >= 0 and correctedBx < (int)jet_eta_phi_lastbunch.size()) {
1099         for (l1t::JetBxCollection::const_iterator jet = JetBxCollection->begin(itBX); jet != JetBxCollection->end(itBX);
1100              ++jet) {
1101           if (jet->pt() >= jetPtCut_) {
1102             denominator_jet_lastbunch->Fill(jet->eta(), jet->phi());
1103             jet_eta_phi_lastbunch.at(correctedBx)->Fill(jet->eta(), jet->phi());
1104           }
1105         }
1106       }
1107     }
1108     // egammas
1109     for (int itBX = std::max(EGammaBxCollection->getFirstBX(), EGammaBxCollection->getFirstBX() + bxShiftLast);
1110          itBX <= std::min(EGammaBxCollection->getLastBX(), EGammaBxCollection->getLastBX() + bxShiftLast);
1111          ++itBX) {
1112       auto correctedBx = itBX - bxShiftLast;
1113       for (l1t::EGammaBxCollection::const_iterator egamma = EGammaBxCollection->begin(itBX);
1114            egamma != EGammaBxCollection->end(itBX);
1115            ++egamma) {
1116         for (size_t i = 0; i < egammaPtCuts_.size(); ++i) {
1117           if (egamma->pt() >= egammaPtCuts_.at(i)) {
1118             if (correctedBx >= 0 and correctedBx < (int)egamma_eta_phi_lastbunch.size()) {
1119               denominator_egamma_lastbunch.at(i)->Fill(egamma->eta(), egamma->phi());
1120               egamma_eta_phi_lastbunch.at(i).at(correctedBx)->Fill(egamma->eta(), egamma->phi());
1121             }
1122             if ((bool)egamma->hwIso()) {
1123               egamma_iso_bx_ieta_lastbunch.at(i)->Fill(correctedBx, egamma->hwEta());
1124             }
1125             egamma_noniso_bx_ieta_lastbunch.at(i)->Fill(correctedBx, egamma->hwEta());
1126           }
1127         }
1128       }
1129     }
1130     // taus
1131     for (int itBX = std::max(TauBxCollection->getFirstBX(), TauBxCollection->getFirstBX() + bxShiftLast);
1132          itBX <= std::min(TauBxCollection->getLastBX(), TauBxCollection->getLastBX() + bxShiftLast);
1133          ++itBX) {
1134       auto correctedBx = itBX - bxShiftLast;
1135       if (correctedBx >= 0 and correctedBx < (int)tau_eta_phi_lastbunch.size()) {
1136         for (l1t::TauBxCollection::const_iterator tau = TauBxCollection->begin(itBX); tau != TauBxCollection->end(itBX);
1137              ++tau) {
1138           if (tau->pt() >= tauPtCut_) {
1139             denominator_tau_lastbunch->Fill(tau->eta(), tau->phi());
1140             tau_eta_phi_lastbunch.at(correctedBx)->Fill(tau->eta(), tau->phi());
1141           }
1142         }
1143       }
1144     }
1145     // etsums
1146     for (int itBX = std::max(EtSumBxCollection->getFirstBX(), EtSumBxCollection->getFirstBX() + bxShiftLast);
1147          itBX <= std::min(EtSumBxCollection->getLastBX(), EtSumBxCollection->getLastBX() + bxShiftLast);
1148          ++itBX) {
1149       auto correctedBx = itBX - bxShiftLast;
1150       if (correctedBx >= 0) {
1151         for (l1t::EtSumBxCollection::const_iterator EtSum = EtSumBxCollection->begin(itBX);
1152              EtSum != EtSumBxCollection->end(itBX);
1153              ++EtSum) {
1154           if (EtSum->pt() >= etsumPtCut_) {
1155             if (l1t::EtSum::EtSumType::kMissingEt == EtSum->getType()) {
1156               if (correctedBx < (int)etsum_eta_phi_MET_lastbunch.size()) {
1157                 denominator_etsum_lastbunch_MET->Fill(EtSum->phi());
1158                 etsum_eta_phi_MET_lastbunch.at(correctedBx)->Fill(EtSum->phi());
1159               }
1160             } else if (l1t::EtSum::EtSumType::kMissingEtHF == EtSum->getType()) {
1161               if (correctedBx < (int)etsum_eta_phi_METHF_lastbunch.size()) {
1162                 denominator_etsum_lastbunch_METHF->Fill(EtSum->phi());
1163                 etsum_eta_phi_METHF_lastbunch.at(correctedBx)->Fill(EtSum->phi());
1164               }
1165             } else if (l1t::EtSum::EtSumType::kMissingHt == EtSum->getType()) {
1166               if (correctedBx < (int)etsum_eta_phi_MHT_lastbunch.size()) {
1167                 denominator_etsum_lastbunch_MHT->Fill(EtSum->phi());
1168                 etsum_eta_phi_MHT_lastbunch.at(correctedBx)->Fill(EtSum->phi());
1169               }
1170             } else if (l1t::EtSum::EtSumType::kMissingHtHF == EtSum->getType()) {
1171               if (correctedBx < (int)etsum_eta_phi_MHTHF_lastbunch.size()) {
1172                 denominator_etsum_lastbunch_MHTHF->Fill(EtSum->phi());
1173                 etsum_eta_phi_MHTHF_lastbunch.at(correctedBx)->Fill(EtSum->phi());
1174               }
1175             }
1176           }
1177         }
1178       }
1179     }
1180   }
1181 
1182   // fill the isolated bunch
1183   if (bxShiftIso > -999) {
1184     // muons
1185     for (int itBX = std::max(MuonBxCollection->getFirstBX(), MuonBxCollection->getFirstBX() + bxShiftIso);
1186          itBX <= std::min(MuonBxCollection->getLastBX(), MuonBxCollection->getLastBX() + bxShiftIso);
1187          ++itBX) {
1188       int index = itBX - bxShiftIso - uGtAlgs->getFirstBX();
1189       if (index >= 0 and index < (int)muons_eta_phi_isolated.size()) {
1190         for (l1t::MuonBxCollection::const_iterator muon = MuonBxCollection->begin(itBX);
1191              muon != MuonBxCollection->end(itBX);
1192              ++muon) {  // Starting with Muons
1193           if (muon->pt() >= muonPtCut_ and muon->hwQual() >= muonQualCut_) {
1194             denominator_muons_isolated->Fill(muon->eta(), muon->phi());
1195             muons_eta_phi_isolated.at(index)->Fill(muon->eta(), muon->phi());
1196           }
1197         }
1198       }
1199     }
1200     // jets
1201     for (int itBX = std::max(JetBxCollection->getFirstBX(), JetBxCollection->getFirstBX() + bxShiftIso);
1202          itBX <= std::min(JetBxCollection->getLastBX(), JetBxCollection->getLastBX() + bxShiftIso);
1203          ++itBX) {
1204       int index = itBX - bxShiftIso - uGtAlgs->getFirstBX();
1205       if (index >= 0 and index < (int)jet_eta_phi_isolated.size()) {
1206         for (l1t::JetBxCollection::const_iterator jet = JetBxCollection->begin(itBX); jet != JetBxCollection->end(itBX);
1207              ++jet) {
1208           if (jet->pt() >= jetPtCut_) {
1209             denominator_jet_isolated->Fill(jet->eta(), jet->phi());
1210             jet_eta_phi_isolated.at(index)->Fill(jet->eta(), jet->phi());
1211           }
1212         }
1213       }
1214     }
1215     // egammas
1216     for (int itBX = std::max(EGammaBxCollection->getFirstBX(), EGammaBxCollection->getFirstBX() + bxShiftIso);
1217          itBX <= std::min(EGammaBxCollection->getLastBX(), EGammaBxCollection->getLastBX() + bxShiftIso);
1218          ++itBX) {
1219       int index = itBX - bxShiftIso - uGtAlgs->getFirstBX();
1220       for (l1t::EGammaBxCollection::const_iterator egamma = EGammaBxCollection->begin(itBX);
1221            egamma != EGammaBxCollection->end(itBX);
1222            ++egamma) {
1223         for (size_t i = 0; i < egammaPtCuts_.size(); ++i) {
1224           if (egamma->pt() >= egammaPtCuts_.at(i)) {
1225             if (index >= 0 and index < (int)egamma_eta_phi_isolated.size()) {
1226               denominator_egamma_isolated.at(i)->Fill(egamma->eta(), egamma->phi());
1227               egamma_eta_phi_isolated.at(i).at(index)->Fill(egamma->eta(), egamma->phi());
1228             }
1229             if ((bool)egamma->hwIso()) {
1230               egamma_iso_bx_ieta_isolated.at(i)->Fill(itBX - bxShiftIso, egamma->hwEta());
1231             }
1232             egamma_noniso_bx_ieta_isolated.at(i)->Fill(itBX - bxShiftIso, egamma->hwEta());
1233           }
1234         }
1235       }
1236     }
1237     // taus
1238     for (int itBX = std::max(TauBxCollection->getFirstBX(), TauBxCollection->getFirstBX() + bxShiftIso);
1239          itBX <= std::min(TauBxCollection->getLastBX(), TauBxCollection->getLastBX() + bxShiftIso);
1240          ++itBX) {
1241       int index = itBX - bxShiftIso - uGtAlgs->getFirstBX();
1242       if (index >= 0 and index < (int)tau_eta_phi_isolated.size()) {
1243         for (l1t::TauBxCollection::const_iterator tau = TauBxCollection->begin(itBX); tau != TauBxCollection->end(itBX);
1244              ++tau) {
1245           if (tau->pt() >= tauPtCut_) {
1246             denominator_tau_isolated->Fill(tau->eta(), tau->phi());
1247             tau_eta_phi_isolated.at(index)->Fill(tau->eta(), tau->phi());
1248           }
1249         }
1250       }
1251     }
1252     // etsums
1253     for (int itBX = std::max(EtSumBxCollection->getFirstBX(), EtSumBxCollection->getFirstBX() + bxShiftIso);
1254          itBX <= std::min(EtSumBxCollection->getLastBX(), EtSumBxCollection->getLastBX() + bxShiftIso);
1255          ++itBX) {
1256       int index = itBX - bxShiftIso - uGtAlgs->getFirstBX();
1257       if (index >= 0) {
1258         for (l1t::EtSumBxCollection::const_iterator EtSum = EtSumBxCollection->begin(itBX);
1259              EtSum != EtSumBxCollection->end(itBX);
1260              ++EtSum) {
1261           if (EtSum->pt() >= etsumPtCut_) {
1262             if (l1t::EtSum::EtSumType::kMissingEt == EtSum->getType()) {
1263               if (index < (int)etsum_eta_phi_MET_isolated.size()) {
1264                 denominator_etsum_isolated_MET->Fill(EtSum->phi());
1265                 etsum_eta_phi_MET_isolated.at(index)->Fill(EtSum->phi());
1266               }
1267             } else if (l1t::EtSum::EtSumType::kMissingEtHF == EtSum->getType()) {
1268               if (index < (int)etsum_eta_phi_METHF_isolated.size()) {
1269                 denominator_etsum_isolated_METHF->Fill(EtSum->phi());
1270                 etsum_eta_phi_METHF_isolated.at(index)->Fill(EtSum->phi());
1271               }
1272             } else if (l1t::EtSum::EtSumType::kMissingHt == EtSum->getType()) {
1273               if (index < (int)etsum_eta_phi_MHT_isolated.size()) {
1274                 denominator_etsum_isolated_MHT->Fill(EtSum->phi());
1275                 etsum_eta_phi_MHT_isolated.at(index)->Fill(EtSum->phi());
1276               }
1277             } else if (l1t::EtSum::EtSumType::kMissingHtHF == EtSum->getType()) {
1278               if (index < (int)etsum_eta_phi_MHTHF_isolated.size()) {
1279                 denominator_etsum_isolated_MHTHF->Fill(EtSum->phi());
1280                 etsum_eta_phi_MHTHF_isolated.at(index)->Fill(EtSum->phi());
1281               }
1282             }
1283           }
1284         }
1285       }
1286     }
1287   }
1288 }