Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:09:36

0001 #include "DQMOffline/L1Trigger/interface/L1TStage2CaloLayer2Offline.h"
0002 #include "DQMOffline/L1Trigger/interface/L1TFillWithinLimits.h"
0003 #include "DQMOffline/L1Trigger/interface/L1TCommon.h"
0004 
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007 // Geometry
0008 #include "DataFormats/Math/interface/deltaR.h"
0009 #include "DataFormats/Math/interface/deltaPhi.h"
0010 #include "DataFormats/Math/interface/LorentzVector.h"
0011 #include "TLorentzVector.h"
0012 
0013 const std::map<std::string, unsigned int> L1TStage2CaloLayer2Offline::PlotConfigNames = {
0014     {"nVertex", PlotConfig::nVertex}, {"ETvsET", PlotConfig::ETvsET}, {"PHIvsPHI", PlotConfig::PHIvsPHI}};
0015 
0016 //
0017 // -------------------------------------- Constructor --------------------------------------------
0018 //
0019 L1TStage2CaloLayer2Offline::L1TStage2CaloLayer2Offline(const edm::ParameterSet& ps)
0020     : thePFJetCollection_(consumes<reco::PFJetCollection>(ps.getParameter<edm::InputTag>("pfJetCollection"))),
0021       thecaloMETCollection_(consumes<reco::CaloMETCollection>(ps.getParameter<edm::InputTag>("caloMETCollection"))),
0022       thecaloETMHFCollection_(consumes<reco::CaloMETCollection>(ps.getParameter<edm::InputTag>("caloETMHFCollection"))),
0023       thePFMETNoMuCollection_(consumes<reco::PFMETCollection>(ps.getParameter<edm::InputTag>("pfMETNoMuCollection"))),
0024       thePVCollection_(consumes<reco::VertexCollection>(ps.getParameter<edm::InputTag>("PVCollection"))),
0025       theBSCollection_(consumes<reco::BeamSpot>(ps.getParameter<edm::InputTag>("beamSpotCollection"))),
0026       triggerInputTag_(consumes<trigger::TriggerEvent>(ps.getParameter<edm::InputTag>("triggerInputTag"))),
0027       triggerResultsInputTag_(consumes<edm::TriggerResults>(ps.getParameter<edm::InputTag>("triggerResults"))),
0028       triggerProcess_(ps.getParameter<std::string>("triggerProcess")),
0029       triggerNames_(ps.getParameter<std::vector<std::string>>("triggerNames")),
0030       histFolderEtSum_(ps.getParameter<std::string>("histFolderEtSum")),
0031       histFolderJet_(ps.getParameter<std::string>("histFolderJet")),
0032       efficiencyFolderEtSum_(histFolderEtSum_ + "/efficiency_raw"),
0033       efficiencyFolderJet_(histFolderJet_ + "/efficiency_raw"),
0034       stage2CaloLayer2JetToken_(
0035           consumes<l1t::JetBxCollection>(ps.getParameter<edm::InputTag>("stage2CaloLayer2JetSource"))),
0036       stage2CaloLayer2EtSumToken_(
0037           consumes<l1t::EtSumBxCollection>(ps.getParameter<edm::InputTag>("stage2CaloLayer2EtSumSource"))),
0038       jetEfficiencyThresholds_(ps.getParameter<std::vector<double>>("jetEfficiencyThresholds")),
0039       metEfficiencyThresholds_(ps.getParameter<std::vector<double>>("metEfficiencyThresholds")),
0040       mhtEfficiencyThresholds_(ps.getParameter<std::vector<double>>("mhtEfficiencyThresholds")),
0041       ettEfficiencyThresholds_(ps.getParameter<std::vector<double>>("ettEfficiencyThresholds")),
0042       httEfficiencyThresholds_(ps.getParameter<std::vector<double>>("httEfficiencyThresholds")),
0043       jetEfficiencyBins_(ps.getParameter<std::vector<double>>("jetEfficiencyBins")),
0044       metEfficiencyBins_(ps.getParameter<std::vector<double>>("metEfficiencyBins")),
0045       mhtEfficiencyBins_(ps.getParameter<std::vector<double>>("mhtEfficiencyBins")),
0046       ettEfficiencyBins_(ps.getParameter<std::vector<double>>("ettEfficiencyBins")),
0047       httEfficiencyBins_(ps.getParameter<std::vector<double>>("httEfficiencyBins")),
0048       recoHTTMaxEta_(ps.getParameter<double>("recoHTTMaxEta")),
0049       recoMHTMaxEta_(ps.getParameter<double>("recoMHTMaxEta")),
0050       hltConfig_(),
0051       triggerIndices_(),
0052       triggerResults_(),
0053       triggerEvent_(),
0054       histDefinitions_(dqmoffline::l1t::readHistDefinitions(ps.getParameterSet("histDefinitions"), PlotConfigNames)),
0055       h_nVertex_(),
0056       h_controlPlots_(),
0057       h_L1METvsCaloMET_(),
0058       h_L1ETMHFvsCaloETMHF_(),
0059       h_L1METvsPFMetNoMu_(),
0060       h_L1MHTvsRecoMHT_(),
0061       h_L1METTvsCaloETT_(),
0062       h_L1HTTvsRecoHTT_(),
0063       h_L1METPhivsCaloMETPhi_(),
0064       h_L1ETMHFPhivsCaloETMHFPhi_(),
0065       h_L1METPhivsPFMetNoMuPhi_(),
0066       h_L1MHTPhivsRecoMHTPhi_(),
0067       h_resolutionMET_(),
0068       h_resolutionETMHF_(),
0069       h_resolutionPFMetNoMu_(),
0070       h_resolutionMHT_(),
0071       h_resolutionETT_(),
0072       h_resolutionHTT_(),
0073       h_resolutionMETPhi_(),
0074       h_resolutionETMHFPhi_(),
0075       h_resolutionPFMetNoMuPhi_(),
0076       h_resolutionMHTPhi_(),
0077       h_efficiencyMET_pass_(),
0078       h_efficiencyETMHF_pass_(),
0079       h_efficiencyPFMetNoMu_pass_(),
0080       h_efficiencyMHT_pass_(),
0081       h_efficiencyETT_pass_(),
0082       h_efficiencyHTT_pass_(),
0083       h_efficiencyMET_total_(),
0084       h_efficiencyETMHF_total_(),
0085       h_efficiencyPFMetNoMu_total_(),
0086       h_efficiencyMHT_total_(),
0087       h_efficiencyETT_total_(),
0088       h_efficiencyHTT_total_(),
0089       h_L1JetETvsPFJetET_HB_(),
0090       h_L1JetETvsPFJetET_HE_(),
0091       h_L1JetETvsPFJetET_HF_(),
0092       h_L1JetETvsPFJetET_HB_HE_(),
0093       h_L1JetPhivsPFJetPhi_HB_(),
0094       h_L1JetPhivsPFJetPhi_HE_(),
0095       h_L1JetPhivsPFJetPhi_HF_(),
0096       h_L1JetPhivsPFJetPhi_HB_HE_(),
0097       h_L1JetEtavsPFJetEta_(),
0098       h_resolutionJetET_HB_(),
0099       h_resolutionJetET_HE_(),
0100       h_resolutionJetET_HF_(),
0101       h_resolutionJetET_HB_HE_(),
0102       h_resolutionJetPhi_HB_(),
0103       h_resolutionJetPhi_HE_(),
0104       h_resolutionJetPhi_HF_(),
0105       h_resolutionJetPhi_HB_HE_(),
0106       h_resolutionJetEta_(),
0107       h_efficiencyJetEt_HB_pass_(),
0108       h_efficiencyJetEt_HE_pass_(),
0109       h_efficiencyJetEt_HF_pass_(),
0110       h_efficiencyJetEt_HB_HE_pass_(),
0111       h_efficiencyJetEt_HB_total_(),
0112       h_efficiencyJetEt_HE_total_(),
0113       h_efficiencyJetEt_HF_total_(),
0114       h_efficiencyJetEt_HB_HE_total_() {
0115   edm::LogInfo("L1TStage2CaloLayer2Offline") << "Constructor "
0116                                              << "L1TStage2CaloLayer2Offline::L1TStage2CaloLayer2Offline " << std::endl;
0117 }
0118 
0119 //
0120 // -- Destructor
0121 //
0122 L1TStage2CaloLayer2Offline::~L1TStage2CaloLayer2Offline() {
0123   edm::LogInfo("L1TStage2CaloLayer2Offline")
0124       << "Destructor L1TStage2CaloLayer2Offline::~L1TStage2CaloLayer2Offline " << std::endl;
0125 }
0126 
0127 //
0128 // -------------------------------------- beginRun --------------------------------------------
0129 //
0130 void L1TStage2CaloLayer2Offline::dqmBeginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
0131   edm::LogInfo("L1TStage2CaloLayer2Offline") << "L1TStage2CaloLayer2Offline::beginRun" << std::endl;
0132   bool changed(true);
0133   if (!hltConfig_.init(iRun, iSetup, triggerProcess_, changed)) {
0134     edm::LogError("L1TStage2CaloLayer2Offline")
0135         << " HLT config extraction failure with process name " << triggerProcess_ << std::endl;
0136     triggerNames_.clear();
0137   } else {
0138     triggerIndices_ = dqmoffline::l1t::getTriggerIndices(triggerNames_, hltConfig_.triggerNames());
0139   }
0140 }
0141 //
0142 // -------------------------------------- bookHistos --------------------------------------------
0143 //
0144 void L1TStage2CaloLayer2Offline::bookHistograms(DQMStore::IBooker& ibooker_, edm::Run const&, edm::EventSetup const&) {
0145   edm::LogInfo("L1TStage2CaloLayer2Offline") << "L1TStage2CaloLayer2Offline::bookHistograms" << std::endl;
0146 
0147   //book at beginRun
0148   bookHistos(ibooker_);
0149 }
0150 //
0151 // -------------------------------------- Analyze --------------------------------------------
0152 //
0153 void L1TStage2CaloLayer2Offline::analyze(edm::Event const& e, edm::EventSetup const& eSetup) {
0154   edm::LogInfo("L1TStage2CaloLayer2Offline") << "L1TStage2CaloLayer2Offline::analyze" << std::endl;
0155 
0156   edm::Handle<edm::TriggerResults> triggerResultHandle;
0157   e.getByToken(triggerResultsInputTag_, triggerResultHandle);
0158   if (!triggerResultHandle.isValid()) {
0159     edm::LogWarning("L1TStage2CaloLayer2Offline") << "invalid edm::TriggerResults handle" << std::endl;
0160     return;
0161   }
0162   triggerResults_ = *triggerResultHandle;
0163 
0164   edm::Handle<trigger::TriggerEvent> triggerEventHandle;
0165   e.getByToken(triggerInputTag_, triggerEventHandle);
0166   if (!triggerEventHandle.isValid()) {
0167     edm::LogWarning("L1TStage2CaloLayer2Offline") << "invalid trigger::TriggerEvent handle" << std::endl;
0168     return;
0169   }
0170   triggerEvent_ = *triggerEventHandle;
0171 
0172   edm::Handle<reco::VertexCollection> vertexHandle;
0173   e.getByToken(thePVCollection_, vertexHandle);
0174   if (!vertexHandle.isValid()) {
0175     edm::LogWarning("L1TStage2CaloLayer2Offline") << "invalid collection: vertex " << std::endl;
0176     return;
0177   }
0178 
0179   unsigned int nVertex = vertexHandle->size();
0180   dqmoffline::l1t::fillWithinLimits(h_nVertex_, nVertex);
0181 
0182   // L1T
0183   if (!dqmoffline::l1t::passesAnyTriggerFromList(triggerIndices_, triggerResults_)) {
0184     return;
0185   }
0186   fillEnergySums(e, nVertex);
0187   fillJets(e, nVertex);
0188 }
0189 
0190 void L1TStage2CaloLayer2Offline::fillEnergySums(edm::Event const& e, const unsigned int nVertex) {
0191   edm::Handle<l1t::EtSumBxCollection> l1EtSums;
0192   e.getByToken(stage2CaloLayer2EtSumToken_, l1EtSums);
0193 
0194   edm::Handle<reco::PFJetCollection> pfJets;
0195   e.getByToken(thePFJetCollection_, pfJets);
0196 
0197   edm::Handle<reco::CaloMETCollection> caloMETs;
0198   e.getByToken(thecaloMETCollection_, caloMETs);
0199 
0200   edm::Handle<reco::CaloMETCollection> caloETMHFs;
0201   e.getByToken(thecaloETMHFCollection_, caloETMHFs);
0202 
0203   edm::Handle<reco::PFMETCollection> pfMETNoMus;
0204   e.getByToken(thePFMETNoMuCollection_, pfMETNoMus);
0205 
0206   if (!pfJets.isValid()) {
0207     edm::LogWarning("L1TStage2CaloLayer2Offline") << "invalid collection: PF jets " << std::endl;
0208     return;
0209   }
0210   if (!caloMETs.isValid()) {
0211     edm::LogWarning("L1TStage2CaloLayer2Offline") << "invalid collection: Offline E_{T}^{miss} " << std::endl;
0212     return;
0213   }
0214   if (!caloETMHFs.isValid()) {
0215     edm::LogWarning("L1TStage2CaloLayer2Offline") << "invalid collection: Offline E_{T}^{miss} (HF) " << std::endl;
0216     return;
0217   }
0218   if (!pfMETNoMus.isValid()) {
0219     edm::LogWarning("L1TStage2CaloLayer2Offline") << "invalid collection: Offline PF E_{T}^{miss} No Mu" << std::endl;
0220     return;
0221   }
0222   if (!l1EtSums.isValid()) {
0223     edm::LogWarning("L1TStage2CaloLayer2Offline") << "invalid collection: L1 ET sums " << std::endl;
0224     return;
0225   }
0226 
0227   int bunchCrossing = 0;
0228 
0229   double l1MET(0);
0230   double l1METPhi(0);
0231   double l1ETMHF(0);
0232   double l1ETMHFPhi(0);
0233   double l1MHT(0);
0234   double l1MHTPhi(0);
0235   double l1ETT(0);
0236   double l1HTT(0);
0237 
0238   for (auto etSum = l1EtSums->begin(bunchCrossing); etSum != l1EtSums->end(bunchCrossing); ++etSum) {
0239     double et = etSum->et();
0240     double phi = etSum->phi();
0241 
0242     switch (etSum->getType()) {
0243       case l1t::EtSum::EtSumType::kMissingEt:
0244         l1MET = et;
0245         l1METPhi = phi;
0246         break;
0247       case l1t::EtSum::EtSumType::kMissingEtHF:
0248         l1ETMHF = et;
0249         l1ETMHFPhi = phi;
0250         break;
0251       case l1t::EtSum::EtSumType::kTotalEt:
0252         l1ETT = et;
0253         break;
0254       case l1t::EtSum::EtSumType::kMissingHt:
0255         l1MHT = et;
0256         l1MHTPhi = phi;
0257         break;
0258       case l1t::EtSum::EtSumType::kTotalHt:
0259         l1HTT = et;
0260       default:
0261         break;
0262     }
0263   }
0264 
0265   double recoMET(caloMETs->front().et());
0266   double recoMETPhi(caloMETs->front().phi());
0267   double recoETMHF(caloETMHFs->front().et());
0268   double recoETMHFPhi(caloETMHFs->front().phi());
0269   double recoPFMetNoMu(pfMETNoMus->front().et());
0270   double recoPFMetNoMuPhi(pfMETNoMus->front().phi());
0271   double recoMHT(0);
0272   double recoMHTPhi(0);
0273   double recoETT(caloMETs->front().sumEt());
0274   double recoHTT(0);
0275 
0276   TVector2 mht(0., 0.);
0277 
0278   for (auto jet = pfJets->begin(); jet != pfJets->end(); ++jet) {
0279     double et = jet->et();
0280     if (et < 30) {
0281       continue;
0282     }
0283     TVector2 jetVec(et * cos(jet->phi()), et * sin(jet->phi()));
0284     if (std::abs(jet->eta()) < recoHTTMaxEta_) {
0285       recoHTT += et;
0286     }
0287     if (std::abs(jet->eta()) < recoMHTMaxEta_) {
0288       mht -= jetVec;
0289     }
0290   }
0291   recoMHT = mht.Mod();
0292   // phi in cms is defined between -pi and pi
0293   recoMHTPhi = TVector2::Phi_mpi_pi(mht.Phi());
0294 
0295   // if no reco value, relative resolution does not make sense -> sort to overflow
0296   double outOfBounds = 9999;
0297 
0298   double resolutionMET = recoMET > 0 ? (l1MET - recoMET) / recoMET : outOfBounds;
0299   double resolutionMETPhi = reco::deltaPhi(l1METPhi, recoMETPhi);
0300 
0301   double resolutionETMHF = recoETMHF > 0 ? (l1ETMHF - recoETMHF) / recoETMHF : outOfBounds;
0302   double resolutionETMHFPhi = reco::deltaPhi(l1ETMHFPhi, recoETMHFPhi);
0303 
0304   double resolutionPFMetNoMu = recoETMHF > 0 ? (l1MET - recoPFMetNoMu) / recoPFMetNoMu : outOfBounds;
0305   double resolutionPFMetNoMuPhi = reco::deltaPhi(l1METPhi, recoPFMetNoMuPhi);
0306 
0307   double resolutionMHT = recoMHT > 0 ? (l1MHT - recoMHT) / recoMHT : outOfBounds;
0308   double resolutionMHTPhi = reco::deltaPhi(l1MHTPhi, recoMHTPhi);
0309 
0310   double resolutionETT = recoETT > 0 ? (l1ETT - recoETT) / recoETT : outOfBounds;
0311   double resolutionHTT = recoHTT > 0 ? (l1HTT - recoHTT) / recoHTT : outOfBounds;
0312 
0313   using namespace dqmoffline::l1t;
0314   // control plots
0315   fillWithinLimits(h_controlPlots_[ControlPlots::L1MET], l1MET);
0316   fillWithinLimits(h_controlPlots_[ControlPlots::L1ETMHF], l1ETMHF);
0317   fillWithinLimits(h_controlPlots_[ControlPlots::L1MHT], l1MHT);
0318   fillWithinLimits(h_controlPlots_[ControlPlots::L1ETT], l1ETT);
0319   fillWithinLimits(h_controlPlots_[ControlPlots::L1HTT], l1HTT);
0320   fillWithinLimits(h_controlPlots_[ControlPlots::OfflineMET], recoMET);
0321   fillWithinLimits(h_controlPlots_[ControlPlots::OfflineETMHF], recoETMHF);
0322   fillWithinLimits(h_controlPlots_[ControlPlots::OfflinePFMetNoMu], recoPFMetNoMu);
0323   fillWithinLimits(h_controlPlots_[ControlPlots::OfflineMHT], recoMHT);
0324   fillWithinLimits(h_controlPlots_[ControlPlots::OfflineETT], recoETT);
0325   fillWithinLimits(h_controlPlots_[ControlPlots::OfflineHTT], recoHTT);
0326 
0327   fill2DWithinLimits(h_L1METvsCaloMET_, recoMET, l1MET);
0328   fill2DWithinLimits(h_L1ETMHFvsCaloETMHF_, recoETMHF, l1ETMHF);
0329   fill2DWithinLimits(h_L1METvsPFMetNoMu_, recoPFMetNoMu, l1MET);
0330   fill2DWithinLimits(h_L1MHTvsRecoMHT_, recoMHT, l1MHT);
0331   fill2DWithinLimits(h_L1METTvsCaloETT_, recoETT, l1ETT);
0332   fill2DWithinLimits(h_L1HTTvsRecoHTT_, recoHTT, l1HTT);
0333 
0334   fill2DWithinLimits(h_L1METPhivsCaloMETPhi_, recoMETPhi, l1METPhi);
0335   fill2DWithinLimits(h_L1ETMHFPhivsCaloETMHFPhi_, recoETMHFPhi, l1ETMHFPhi);
0336   fill2DWithinLimits(h_L1METPhivsPFMetNoMuPhi_, recoPFMetNoMuPhi, l1METPhi);
0337   fill2DWithinLimits(h_L1MHTPhivsRecoMHTPhi_, recoMHTPhi, l1MHTPhi);
0338 
0339   fillWithinLimits(h_resolutionMET_, resolutionMET);
0340   fillWithinLimits(h_resolutionETMHF_, resolutionETMHF);
0341   fillWithinLimits(h_resolutionPFMetNoMu_, resolutionPFMetNoMu);
0342   fillWithinLimits(h_resolutionMHT_, resolutionMHT);
0343   fillWithinLimits(h_resolutionETT_, resolutionETT);
0344   if (resolutionMHT < outOfBounds) {
0345     fillWithinLimits(h_resolutionMHT_, resolutionMHT);
0346   }
0347   if (resolutionHTT < outOfBounds) {
0348     fillWithinLimits(h_resolutionHTT_, resolutionHTT);
0349   }
0350 
0351   fillWithinLimits(h_resolutionMETPhi_, resolutionMETPhi);
0352   fillWithinLimits(h_resolutionETMHFPhi_, resolutionETMHFPhi);
0353   fillWithinLimits(h_resolutionPFMetNoMuPhi_, resolutionPFMetNoMuPhi);
0354   fillWithinLimits(h_resolutionMHTPhi_, resolutionMHTPhi);
0355 
0356   // efficiencies
0357   for (auto threshold : metEfficiencyThresholds_) {
0358     fillWithinLimits(h_efficiencyMET_total_[threshold], recoMET);
0359     fillWithinLimits(h_efficiencyETMHF_total_[threshold], recoETMHF);
0360     fillWithinLimits(h_efficiencyPFMetNoMu_total_[threshold], recoPFMetNoMu);
0361     if (l1MET > threshold) {
0362       fillWithinLimits(h_efficiencyMET_pass_[threshold], recoMET);
0363       fillWithinLimits(h_efficiencyETMHF_pass_[threshold], recoETMHF);
0364       fillWithinLimits(h_efficiencyPFMetNoMu_pass_[threshold], recoPFMetNoMu);
0365     }
0366   }
0367 
0368   for (auto threshold : mhtEfficiencyThresholds_) {
0369     fillWithinLimits(h_efficiencyMHT_total_[threshold], recoMHT);
0370     if (l1MHT > threshold)
0371       fillWithinLimits(h_efficiencyMHT_pass_[threshold], recoMHT);
0372   }
0373 
0374   for (auto threshold : ettEfficiencyThresholds_) {
0375     fillWithinLimits(h_efficiencyETT_total_[threshold], recoETT);
0376     if (l1ETT > threshold)
0377       fillWithinLimits(h_efficiencyETT_pass_[threshold], recoETT);
0378   }
0379 
0380   for (auto threshold : httEfficiencyThresholds_) {
0381     fillWithinLimits(h_efficiencyHTT_total_[threshold], recoHTT);
0382     if (l1HTT > threshold)
0383       fillWithinLimits(h_efficiencyHTT_pass_[threshold], recoHTT);
0384   }
0385 }
0386 
0387 void L1TStage2CaloLayer2Offline::fillJets(edm::Event const& e, const unsigned int nVertex) {
0388   edm::Handle<l1t::JetBxCollection> l1Jets;
0389   e.getByToken(stage2CaloLayer2JetToken_, l1Jets);
0390 
0391   edm::Handle<reco::PFJetCollection> pfJets;
0392   e.getByToken(thePFJetCollection_, pfJets);
0393 
0394   if (!pfJets.isValid()) {
0395     edm::LogWarning("L1TStage2CaloLayer2Offline") << "invalid collection: PF jets " << std::endl;
0396     return;
0397   }
0398   if (!l1Jets.isValid()) {
0399     edm::LogWarning("L1TStage2CaloLayer2Offline") << "invalid collection: L1 jets " << std::endl;
0400     return;
0401   }
0402 
0403   if (pfJets->empty()) {
0404     LogDebug("L1TStage2CaloLayer2Offline") << "no PF jets found" << std::endl;
0405     return;
0406   }
0407 
0408   auto leadingRecoJet = pfJets->front();
0409 
0410   // find corresponding L1 jet
0411   double minDeltaR = 0.3;
0412   l1t::Jet closestL1Jet;
0413   bool foundMatch = false;
0414 
0415   //    for (int bunchCrossing = l1Jets->getFirstBX(); bunchCrossing <= l1Jets->getLastBX(); ++bunchCrossing) {
0416   int bunchCrossing = 0;
0417   for (auto jet = l1Jets->begin(bunchCrossing); jet != l1Jets->end(bunchCrossing); ++jet) {
0418     double currentDeltaR = deltaR(jet->eta(), jet->phi(), leadingRecoJet.eta(), leadingRecoJet.phi());
0419     if (currentDeltaR >= minDeltaR) {
0420       continue;
0421     } else {
0422       minDeltaR = currentDeltaR;
0423       closestL1Jet = *jet;
0424       foundMatch = true;
0425     }
0426   }
0427   //    }
0428 
0429   if (!foundMatch) {
0430     LogDebug("L1TStage2CaloLayer2Offline") << "Could not find a matching L1 Jet " << std::endl;
0431   }
0432 
0433   if (!doesNotOverlapWithHLTObjects(closestL1Jet)) {
0434     return;
0435   }
0436 
0437   double recoEt = leadingRecoJet.et();
0438   double recoEta = leadingRecoJet.eta();
0439   double recoPhi = leadingRecoJet.phi();
0440 
0441   double outOfBounds = 9999;
0442   double l1Et = foundMatch ? closestL1Jet.et() : 0;
0443   double l1Eta = foundMatch ? closestL1Jet.eta() : outOfBounds;
0444   double l1Phi = foundMatch ? closestL1Jet.phi() : outOfBounds;
0445 
0446   double resolutionEt = recoEt > 0 ? (l1Et - recoEt) / recoEt : outOfBounds;
0447   double resolutionEta = l1Eta - recoEta;
0448   double resolutionPhi = l1Phi < outOfBounds ? reco::deltaPhi(l1Phi, recoPhi) : outOfBounds;
0449 
0450   using namespace dqmoffline::l1t;
0451   // fill efficiencies regardless of matched jet found
0452   fillJetEfficiencies(recoEt, l1Et, recoEta);
0453   // control plots
0454   fillWithinLimits(h_controlPlots_[ControlPlots::L1JetET], l1Et);
0455   fillWithinLimits(h_controlPlots_[ControlPlots::OfflineJetET], recoEt);
0456   // don't fill anything else if no matched L1 jet is found
0457   if (!foundMatch) {
0458     return;
0459   }
0460 
0461   // eta
0462   fill2DWithinLimits(h_L1JetEtavsPFJetEta_, recoEta, l1Eta);
0463   fillWithinLimits(h_resolutionJetEta_, resolutionEta);
0464 
0465   if (std::abs(recoEta) <= 1.479) {  // barrel
0466     // et
0467     fill2DWithinLimits(h_L1JetETvsPFJetET_HB_, recoEt, l1Et);
0468     fill2DWithinLimits(h_L1JetETvsPFJetET_HB_HE_, recoEt, l1Et);
0469     //resolution
0470     fillWithinLimits(h_resolutionJetET_HB_, resolutionEt);
0471     fillWithinLimits(h_resolutionJetET_HB_HE_, resolutionEt);
0472     // phi
0473     fill2DWithinLimits(h_L1JetPhivsPFJetPhi_HB_, recoPhi, l1Phi);
0474     fill2DWithinLimits(h_L1JetPhivsPFJetPhi_HB_HE_, recoPhi, l1Phi);
0475     // resolution
0476     fillWithinLimits(h_resolutionJetPhi_HB_, resolutionPhi);
0477     fillWithinLimits(h_resolutionJetPhi_HB_HE_, resolutionPhi);
0478   } else if (std::abs(recoEta) <= 3.0) {  // end-cap
0479     // et
0480     fill2DWithinLimits(h_L1JetETvsPFJetET_HE_, recoEt, l1Et);
0481     fill2DWithinLimits(h_L1JetETvsPFJetET_HB_HE_, recoEt, l1Et);
0482     //resolution
0483     fillWithinLimits(h_resolutionJetET_HE_, resolutionEt);
0484     fillWithinLimits(h_resolutionJetET_HB_HE_, resolutionEt);
0485     // phi
0486     fill2DWithinLimits(h_L1JetPhivsPFJetPhi_HE_, recoPhi, l1Phi);
0487     fill2DWithinLimits(h_L1JetPhivsPFJetPhi_HB_HE_, recoPhi, l1Phi);
0488     // resolution
0489     fillWithinLimits(h_resolutionJetPhi_HE_, resolutionPhi);
0490     fillWithinLimits(h_resolutionJetPhi_HB_HE_, resolutionPhi);
0491   } else {  // forward jets
0492     // et
0493     fill2DWithinLimits(h_L1JetETvsPFJetET_HF_, recoEt, l1Et);
0494     // resolution
0495     fillWithinLimits(h_resolutionJetET_HF_, resolutionEt);
0496     // phi
0497     fill2DWithinLimits(h_L1JetPhivsPFJetPhi_HF_, recoPhi, l1Phi);
0498     // resolution
0499     fillWithinLimits(h_resolutionJetPhi_HF_, resolutionPhi);
0500   }
0501 }
0502 
0503 void L1TStage2CaloLayer2Offline::fillJetEfficiencies(const double& recoEt, const double& l1Et, const double& recoEta) {
0504   using namespace dqmoffline::l1t;
0505   if (std::abs(recoEta) <= 1.479) {  // barrel
0506     for (auto threshold : jetEfficiencyThresholds_) {
0507       fillWithinLimits(h_efficiencyJetEt_HB_total_[threshold], recoEt);
0508       fillWithinLimits(h_efficiencyJetEt_HB_HE_total_[threshold], recoEt);
0509       if (l1Et > threshold) {
0510         fillWithinLimits(h_efficiencyJetEt_HB_pass_[threshold], recoEt);
0511         fillWithinLimits(h_efficiencyJetEt_HB_HE_pass_[threshold], recoEt);
0512       }
0513     }
0514   } else if (std::abs(recoEta) <= 3.0) {  // end-cap
0515     for (auto threshold : jetEfficiencyThresholds_) {
0516       fillWithinLimits(h_efficiencyJetEt_HE_total_[threshold], recoEt);
0517       fillWithinLimits(h_efficiencyJetEt_HB_HE_total_[threshold], recoEt);
0518       if (l1Et > threshold) {
0519         fillWithinLimits(h_efficiencyJetEt_HE_pass_[threshold], recoEt);
0520         fillWithinLimits(h_efficiencyJetEt_HB_HE_pass_[threshold], recoEt);
0521       }
0522     }
0523   } else {
0524     for (auto threshold : jetEfficiencyThresholds_) {
0525       fillWithinLimits(h_efficiencyJetEt_HF_total_[threshold], recoEt);
0526       if (l1Et > threshold) {
0527         fillWithinLimits(h_efficiencyJetEt_HF_pass_[threshold], recoEt);
0528       }
0529     }  // forward jets
0530   }
0531 }
0532 
0533 //
0534 // -------------------------------------- endRun --------------------------------------------
0535 //
0536 //
0537 // -------------------------------------- book histograms --------------------------------------------
0538 //
0539 void L1TStage2CaloLayer2Offline::bookHistos(DQMStore::IBooker& ibooker) {
0540   bookEnergySumHistos(ibooker);
0541   bookJetHistos(ibooker);
0542 }
0543 
0544 void L1TStage2CaloLayer2Offline::bookEnergySumHistos(DQMStore::IBooker& ibooker) {
0545   ibooker.cd();
0546   ibooker.setCurrentFolder(histFolderEtSum_);
0547 
0548   dqmoffline::l1t::HistDefinition nVertexDef = histDefinitions_[PlotConfig::nVertex];
0549   h_nVertex_ = ibooker.book1D(nVertexDef.name, nVertexDef.title, nVertexDef.nbinsX, nVertexDef.xmin, nVertexDef.xmax);
0550 
0551   // energy sums control plots (monitor beyond the limits of the 2D histograms)
0552   h_controlPlots_[ControlPlots::L1MET] =
0553       ibooker.book1D("L1MET", "L1 E_{T}^{miss}; L1 E_{T}^{miss} (GeV); events", 500, -0.5, 4999.5);
0554   h_controlPlots_[ControlPlots::L1ETMHF] =
0555       ibooker.book1D("L1ETMHF", "L1 E_{T}^{miss} (HF); L1 E_{T}^{miss} (HF) (GeV); events", 500, -0.5, 4999.5);
0556   h_controlPlots_[ControlPlots::L1MHT] = ibooker.book1D("L1MHT", "L1 MHT; L1 MHT (GeV); events", 500, -0.5, 4999.5);
0557   h_controlPlots_[ControlPlots::L1ETT] = ibooker.book1D("L1ETT", "L1 ETT; L1 ETT (GeV); events", 500, -0.5, 4999.5);
0558   h_controlPlots_[ControlPlots::L1HTT] = ibooker.book1D("L1HTT", "L1 HTT; L1 HTT (GeV); events", 500, -0.5, 4999.5);
0559 
0560   h_controlPlots_[ControlPlots::OfflineMET] =
0561       ibooker.book1D("OfflineMET", "Offline E_{T}^{miss}; Offline E_{T}^{miss} (GeV); events", 500, -0.5, 4999.5);
0562   h_controlPlots_[ControlPlots::OfflineETMHF] = ibooker.book1D(
0563       "OfflineETMHF", "Offline E_{T}^{miss} (HF); Offline E_{T}^{miss} (HF) (GeV); events", 500, -0.5, 4999.5);
0564   h_controlPlots_[ControlPlots::OfflinePFMetNoMu] =
0565       ibooker.book1D("OfflinePFMetNoMu",
0566                      "Offline E_{T}^{miss} (PFMetNoMu); Offline E_{T}^{miss} (PFMetNoMu) (GeV); events",
0567                      500,
0568                      -0.5,
0569                      4999.5);
0570   h_controlPlots_[ControlPlots::OfflineMHT] =
0571       ibooker.book1D("OfflineMHT", "Offline MHT; Offline MHT (GeV); events", 500, -0.5, 4999.5);
0572   h_controlPlots_[ControlPlots::OfflineETT] =
0573       ibooker.book1D("OfflineETT", "Offline ETT; Offline ETT (GeV); events", 500, -0.5, 4999.5);
0574   h_controlPlots_[ControlPlots::OfflineHTT] =
0575       ibooker.book1D("OfflineHTT", "Offline HTT; Offline HTT (GeV); events", 500, -0.5, 4999.5);
0576 
0577   // energy sums reco vs L1
0578   dqmoffline::l1t::HistDefinition templateETvsET = histDefinitions_[PlotConfig::ETvsET];
0579   h_L1METvsCaloMET_ =
0580       ibooker.book2D("L1METvsCaloMET",
0581                      "L1 E_{T}^{miss} vs Offline E_{T}^{miss};Offline E_{T}^{miss} (GeV);L1 E_{T}^{miss} (GeV)",
0582                      templateETvsET.nbinsX,
0583                      &templateETvsET.binsX[0],
0584                      templateETvsET.nbinsY,
0585                      &templateETvsET.binsY[0]);
0586   h_L1ETMHFvsCaloETMHF_ = ibooker.book2D(
0587       "L1ETMHFvsCaloETMHF",
0588       "L1 E_{T}^{miss} vs Offline E_{T}^{miss} (HF);Offline E_{T}^{miss} (HF) (GeV);L1 E_{T}^{miss} (HF) (GeV)",
0589       templateETvsET.nbinsX,
0590       &templateETvsET.binsX[0],
0591       templateETvsET.nbinsY,
0592       &templateETvsET.binsY[0]);
0593   h_L1METvsPFMetNoMu_ = ibooker.book2D("L1METvsPFMetNoMu",
0594                                        "L1 E_{T}^{miss} vs Offline E_{T}^{miss} (PFMetNoMu);Offline E_{T}^{miss} "
0595                                        "(PFMetNoMu) (GeV);L1 E_{T}^{miss} (GeV)",
0596                                        templateETvsET.nbinsX,
0597                                        &templateETvsET.binsX[0],
0598                                        templateETvsET.nbinsY,
0599                                        &templateETvsET.binsY[0]);
0600   h_L1MHTvsRecoMHT_ = ibooker.book2D("L1MHTvsRecoMHT",
0601                                      "L1 MHT vs reco MHT;reco MHT (GeV);L1 MHT (GeV)",
0602                                      templateETvsET.nbinsX,
0603                                      &templateETvsET.binsX[0],
0604                                      templateETvsET.nbinsY,
0605                                      &templateETvsET.binsY[0]);
0606   h_L1METTvsCaloETT_ = ibooker.book2D("L1ETTvsCaloETT",
0607                                       "L1 ETT vs calo ETT;calo ETT (GeV);L1 ETT (GeV)",
0608                                       templateETvsET.nbinsX,
0609                                       &templateETvsET.binsX[0],
0610                                       templateETvsET.nbinsY,
0611                                       &templateETvsET.binsY[0]);
0612   h_L1HTTvsRecoHTT_ =
0613       ibooker.book2D("L1HTTvsRecoHTT",
0614                      "L1 Total H_{T} vs Offline Total H_{T};Offline Total H_{T} (GeV);L1 Total H_{T} (GeV)",
0615                      templateETvsET.nbinsX,
0616                      &templateETvsET.binsX[0],
0617                      templateETvsET.nbinsY,
0618                      &templateETvsET.binsY[0]);
0619 
0620   dqmoffline::l1t::HistDefinition templatePHIvsPHI = histDefinitions_[PlotConfig::PHIvsPHI];
0621   h_L1METPhivsCaloMETPhi_ =
0622       ibooker.book2D("L1METPhivsCaloMETPhi",
0623                      "L1 E_{T}^{miss} #phi vs Offline E_{T}^{miss} #phi;Offline E_{T}^{miss} #phi;L1 E_{T}^{miss} #phi",
0624                      templatePHIvsPHI.nbinsX,
0625                      templatePHIvsPHI.xmin,
0626                      templatePHIvsPHI.xmax,
0627                      templatePHIvsPHI.nbinsY,
0628                      templatePHIvsPHI.ymin,
0629                      templatePHIvsPHI.ymax);
0630   h_L1ETMHFPhivsCaloETMHFPhi_ = ibooker.book2D(
0631       "L1ETMHFPhivsCaloETMHFPhi",
0632       "L1 E_{T}^{miss} #phi vs Offline E_{T}^{miss} (HF) #phi;Offline E_{T}^{miss} (HF) #phi;L1 E_{T}^{miss} #phi",
0633       templatePHIvsPHI.nbinsX,
0634       templatePHIvsPHI.xmin,
0635       templatePHIvsPHI.xmax,
0636       templatePHIvsPHI.nbinsY,
0637       templatePHIvsPHI.ymin,
0638       templatePHIvsPHI.ymax);
0639   h_L1METPhivsPFMetNoMuPhi_ = ibooker.book2D("L1METPhivsPFMetNoMuPhi",
0640                                              "L1 E_{T}^{miss} #phi vs Offline E_{T}^{miss} (PFMetNoMu) #phi;Offline "
0641                                              "E_{T}^{miss} (PFMetNoMu) #phi;L1 E_{T}^{miss} #phi",
0642                                              templatePHIvsPHI.nbinsX,
0643                                              templatePHIvsPHI.xmin,
0644                                              templatePHIvsPHI.xmax,
0645                                              templatePHIvsPHI.nbinsY,
0646                                              templatePHIvsPHI.ymin,
0647                                              templatePHIvsPHI.ymax);
0648   h_L1MHTPhivsRecoMHTPhi_ = ibooker.book2D("L1MHTPhivsRecoMHTPhi",
0649                                            "L1 MHT #phi vs reco MHT #phi;reco MHT #phi;L1 MHT #phi",
0650                                            templatePHIvsPHI.nbinsX,
0651                                            templatePHIvsPHI.xmin,
0652                                            templatePHIvsPHI.xmax,
0653                                            templatePHIvsPHI.nbinsY,
0654                                            templatePHIvsPHI.ymin,
0655                                            templatePHIvsPHI.ymax);
0656 
0657   // energy sum resolutions
0658   h_resolutionMET_ =
0659       ibooker.book1D("resolutionMET",
0660                      "MET resolution; (L1 E_{T}^{miss} - Offline E_{T}^{miss})/Offline E_{T}^{miss}; events",
0661                      70,
0662                      -1.0,
0663                      2.5);
0664   h_resolutionETMHF_ =
0665       ibooker.book1D("resolutionETMHF",
0666                      "MET resolution (HF); (L1 E_{T}^{miss} - Offline E_{T}^{miss})/Offline E_{T}^{miss} (HF); events",
0667                      70,
0668                      -1.0,
0669                      2.5);
0670   h_resolutionPFMetNoMu_ = ibooker.book1D(
0671       "resolutionPFMetNoMu",
0672       "PFMetNoMu resolution; (L1 E_{T}^{miss} - Offline E_{T}^{miss})/Offline E_{T}^{miss} (PFMetNoMu); events",
0673       70,
0674       -1.0,
0675       2.5);
0676   h_resolutionMHT_ =
0677       ibooker.book1D("resolutionMHT", "MHT resolution; (L1 MHT - reco MHT)/reco MHT; events", 70, -1.0, 2.5);
0678   h_resolutionETT_ =
0679       ibooker.book1D("resolutionETT", "ETT resolution; (L1 ETT - calo ETT)/calo ETT; events", 70, -1.0, 2.5);
0680   h_resolutionHTT_ =
0681       ibooker.book1D("resolutionHTT",
0682                      "HTT resolution; (L1 Total H_{T} - Offline Total H_{T})/Offline Total H_{T}; events",
0683                      70,
0684                      -1.0,
0685                      2.5);
0686 
0687   h_resolutionMETPhi_ = ibooker.book1D(
0688       "resolutionMETPhi", "MET #phi resolution; (L1 E_{T}^{miss} #phi - reco MET #phi); events", 200, -1, 1);
0689   h_resolutionETMHFPhi_ = ibooker.book1D(
0690       "resolutionETMHFPhi", "MET #phi resolution (HF); (L1 E_{T}^{miss} #phi - reco MET #phi) (HF); events", 200, -1, 1);
0691   h_resolutionPFMetNoMuPhi_ =
0692       ibooker.book1D("resolutionPFMetNoMuPhi",
0693                      "MET #phi resolution (PFMetNoMu); (L1 E_{T}^{miss} #phi - reco MET #phi) (PFMetNoMu); events",
0694                      200,
0695                      -1,
0696                      1);
0697   h_resolutionMHTPhi_ =
0698       ibooker.book1D("resolutionMHTPhi", "MET #phi resolution; (L1 MHT #phi - reco MHT #phi); events", 200, -1, 1);
0699 
0700   // energy sum turn ons
0701   ibooker.setCurrentFolder(efficiencyFolderEtSum_);
0702 
0703   std::vector<float> metBins(metEfficiencyBins_.begin(), metEfficiencyBins_.end());
0704   std::vector<float> mhtBins(mhtEfficiencyBins_.begin(), mhtEfficiencyBins_.end());
0705   std::vector<float> ettBins(ettEfficiencyBins_.begin(), ettEfficiencyBins_.end());
0706   std::vector<float> httBins(httEfficiencyBins_.begin(), httEfficiencyBins_.end());
0707 
0708   for (auto threshold : metEfficiencyThresholds_) {
0709     std::string str_threshold = std::to_string(int(threshold));
0710     h_efficiencyMET_pass_[threshold] = ibooker.book1D("efficiencyMET_threshold_" + str_threshold + "_Num",
0711                                                       "MET efficiency (numerator); Offline E_{T}^{miss} (GeV);",
0712                                                       metBins.size() - 1,
0713                                                       &(metBins[0]));
0714     h_efficiencyMET_total_[threshold] = ibooker.book1D("efficiencyMET_threshold_" + str_threshold + "_Den",
0715                                                        "MET efficiency (denominator); Offline E_{T}^{miss} (GeV);",
0716                                                        metBins.size() - 1,
0717                                                        &(metBins[0]));
0718 
0719     h_efficiencyETMHF_pass_[threshold] = ibooker.book1D("efficiencyETMHF_threshold_" + str_threshold + "_Num",
0720                                                         "MET efficiency (numerator); Offline E_{T}^{miss} (GeV) (HF);",
0721                                                         metBins.size() - 1,
0722                                                         &(metBins[0]));
0723     h_efficiencyETMHF_total_[threshold] =
0724         ibooker.book1D("efficiencyETMHF_threshold_" + str_threshold + "_Den",
0725                        "MET efficiency (denominator); Offline E_{T}^{miss} (GeV) (HF);",
0726                        metBins.size() - 1,
0727                        &(metBins[0]));
0728 
0729     h_efficiencyPFMetNoMu_pass_[threshold] =
0730         ibooker.book1D("efficiencyPFMetNoMu_threshold_" + str_threshold + "_Num",
0731                        "MET efficiency (numerator); Offline E_{T}^{miss} (GeV) (PFMetNoMu);",
0732                        metBins.size() - 1,
0733                        &(metBins[0]));
0734     h_efficiencyPFMetNoMu_total_[threshold] =
0735         ibooker.book1D("efficiencyPFMetNoMu_threshold_" + str_threshold + "_Den",
0736                        "MET efficiency (denominator); Offline E_{T}^{miss} (GeV) (PFMetNoMu);",
0737                        metBins.size() - 1,
0738                        &(metBins[0]));
0739   }
0740 
0741   for (auto threshold : mhtEfficiencyThresholds_) {
0742     std::string str_threshold = std::to_string(int(threshold));
0743     h_efficiencyMHT_pass_[threshold] = ibooker.book1D("efficiencyMHT_threshold_" + str_threshold + "_Num",
0744                                                       "MHT efficiency (numerator); Offline MHT (GeV);",
0745                                                       mhtBins.size() - 1,
0746                                                       &(mhtBins[0]));
0747     h_efficiencyMHT_total_[threshold] = ibooker.book1D("efficiencyMHT_threshold_" + str_threshold + "_Den",
0748                                                        "MHT efficiency (denominator); Offline MHT (GeV);",
0749                                                        mhtBins.size() - 1,
0750                                                        &(mhtBins[0]));
0751   }
0752 
0753   for (auto threshold : ettEfficiencyThresholds_) {
0754     std::string str_threshold = std::to_string(int(threshold));
0755     h_efficiencyETT_pass_[threshold] = ibooker.book1D("efficiencyETT_threshold_" + str_threshold + "_Num",
0756                                                       "ETT efficiency (numerator); Offline ETT (GeV);",
0757                                                       ettBins.size() - 1,
0758                                                       &(ettBins[0]));
0759     h_efficiencyETT_total_[threshold] = ibooker.book1D("efficiencyETT_threshold_" + str_threshold + "_Den",
0760                                                        "ETT efficiency (denominator); Offline ETT (GeV);",
0761                                                        ettBins.size() - 1,
0762                                                        &(ettBins[0]));
0763   }
0764   for (auto threshold : httEfficiencyThresholds_) {
0765     std::string str_threshold = std::to_string(int(threshold));
0766     h_efficiencyHTT_pass_[threshold] = ibooker.book1D("efficiencyHTT_threshold_" + str_threshold + "_Num",
0767                                                       "HTT efficiency (numerator); Offline Total H_{T} (GeV);",
0768                                                       httBins.size() - 1,
0769                                                       &(httBins[0]));
0770     h_efficiencyHTT_total_[threshold] = ibooker.book1D("efficiencyHTT_threshold_" + str_threshold + "_Den",
0771                                                        "HTT efficiency (denominator); Offline Total H_{T} (GeV);",
0772                                                        httBins.size() - 1,
0773                                                        &(httBins[0]));
0774   }
0775 
0776   ibooker.cd();
0777 }
0778 
0779 void L1TStage2CaloLayer2Offline::bookJetHistos(DQMStore::IBooker& ibooker) {
0780   ibooker.cd();
0781   ibooker.setCurrentFolder(histFolderJet_);
0782   // jets control plots (monitor beyond the limits of the 2D histograms)
0783   h_controlPlots_[ControlPlots::L1JetET] =
0784       ibooker.book1D("L1JetET", "L1 Jet E_{T}; L1 Jet E_{T} (GeV); events", 500, 0, 5e3);
0785   h_controlPlots_[ControlPlots::OfflineJetET] =
0786       ibooker.book1D("OfflineJetET", "Offline Jet E_{T}; Offline Jet E_{T} (GeV); events", 500, 0, 5e3);
0787   // jet reco vs L1
0788   dqmoffline::l1t::HistDefinition templateETvsET = histDefinitions_[PlotConfig::ETvsET];
0789   h_L1JetETvsPFJetET_HB_ =
0790       ibooker.book2D("L1JetETvsPFJetET_HB",
0791                      "L1 Jet E_{T} vs Offline Jet E_{T} (HB); Offline Jet E_{T} (GeV); L1 Jet E_{T} (GeV)",
0792                      templateETvsET.nbinsX,
0793                      &templateETvsET.binsX[0],
0794                      templateETvsET.nbinsY,
0795                      &templateETvsET.binsY[0]);
0796   h_L1JetETvsPFJetET_HE_ =
0797       ibooker.book2D("L1JetETvsPFJetET_HE",
0798                      "L1 Jet E_{T} vs Offline Jet E_{T} (HE); Offline Jet E_{T} (GeV); L1 Jet E_{T} (GeV)",
0799                      templateETvsET.nbinsX,
0800                      &templateETvsET.binsX[0],
0801                      templateETvsET.nbinsY,
0802                      &templateETvsET.binsY[0]);
0803   h_L1JetETvsPFJetET_HF_ =
0804       ibooker.book2D("L1JetETvsPFJetET_HF",
0805                      "L1 Jet E_{T} vs Offline Jet E_{T} (HF); Offline Jet E_{T} (GeV); L1 Jet E_{T} (GeV)",
0806                      templateETvsET.nbinsX,
0807                      &templateETvsET.binsX[0],
0808                      templateETvsET.nbinsY,
0809                      &templateETvsET.binsY[0]);
0810   h_L1JetETvsPFJetET_HB_HE_ =
0811       ibooker.book2D("L1JetETvsPFJetET_HB_HE",
0812                      "L1 Jet E_{T} vs Offline Jet E_{T} (HB+HE); Offline Jet E_{T} (GeV); L1 Jet E_{T} (GeV)",
0813                      templateETvsET.nbinsX,
0814                      &templateETvsET.binsX[0],
0815                      templateETvsET.nbinsY,
0816                      &templateETvsET.binsY[0]);
0817 
0818   dqmoffline::l1t::HistDefinition templatePHIvsPHI = histDefinitions_[PlotConfig::PHIvsPHI];
0819   h_L1JetPhivsPFJetPhi_HB_ =
0820       ibooker.book2D("L1JetPhivsPFJetPhi_HB",
0821                      "#phi_{jet}^{L1} vs #phi_{jet}^{offline} (HB); #phi_{jet}^{offline}; #phi_{jet}^{L1}",
0822                      templatePHIvsPHI.nbinsX,
0823                      templatePHIvsPHI.xmin,
0824                      templatePHIvsPHI.xmax,
0825                      templatePHIvsPHI.nbinsY,
0826                      templatePHIvsPHI.ymin,
0827                      templatePHIvsPHI.ymax);
0828   h_L1JetPhivsPFJetPhi_HE_ =
0829       ibooker.book2D("L1JetPhivsPFJetPhi_HE",
0830                      "#phi_{jet}^{L1} vs #phi_{jet}^{offline} (HE); #phi_{jet}^{offline}; #phi_{jet}^{L1}",
0831                      templatePHIvsPHI.nbinsX,
0832                      templatePHIvsPHI.xmin,
0833                      templatePHIvsPHI.xmax,
0834                      templatePHIvsPHI.nbinsY,
0835                      templatePHIvsPHI.ymin,
0836                      templatePHIvsPHI.ymax);
0837   h_L1JetPhivsPFJetPhi_HF_ =
0838       ibooker.book2D("L1JetPhivsPFJetPhi_HF",
0839                      "#phi_{jet}^{L1} vs #phi_{jet}^{offline} (HF); #phi_{jet}^{offline}; #phi_{jet}^{L1}",
0840                      templatePHIvsPHI.nbinsX,
0841                      templatePHIvsPHI.xmin,
0842                      templatePHIvsPHI.xmax,
0843                      templatePHIvsPHI.nbinsY,
0844                      templatePHIvsPHI.ymin,
0845                      templatePHIvsPHI.ymax);
0846   h_L1JetPhivsPFJetPhi_HB_HE_ =
0847       ibooker.book2D("L1JetPhivsPFJetPhi_HB_HE",
0848                      "#phi_{jet}^{L1} vs #phi_{jet}^{offline} (HB+HE); #phi_{jet}^{offline}; #phi_{jet}^{L1}",
0849                      templatePHIvsPHI.nbinsX,
0850                      templatePHIvsPHI.xmin,
0851                      templatePHIvsPHI.xmax,
0852                      templatePHIvsPHI.nbinsY,
0853                      templatePHIvsPHI.ymin,
0854                      templatePHIvsPHI.ymax);
0855 
0856   h_L1JetEtavsPFJetEta_ = ibooker.book2D("L1JetEtavsPFJetEta_HB",
0857                                          "L1 Jet #eta vs Offline Jet #eta; Offline Jet #eta; L1 Jet #eta",
0858                                          100,
0859                                          -10,
0860                                          10,
0861                                          100,
0862                                          -10,
0863                                          10);
0864 
0865   // jet resolutions
0866   h_resolutionJetET_HB_ =
0867       ibooker.book1D("resolutionJetET_HB",
0868                      "jet ET resolution (HB); (L1 Jet E_{T} - Offline Jet E_{T})/Offline Jet E_{T}; events",
0869                      50,
0870                      -1,
0871                      1.5);
0872   h_resolutionJetET_HE_ =
0873       ibooker.book1D("resolutionJetET_HE",
0874                      "jet ET resolution (HE); (L1 Jet E_{T} - Offline Jet E_{T})/Offline Jet E_{T}; events",
0875                      50,
0876                      -1,
0877                      1.5);
0878   h_resolutionJetET_HF_ =
0879       ibooker.book1D("resolutionJetET_HF",
0880                      "jet ET resolution (HF); (L1 Jet E_{T} - Offline Jet E_{T})/Offline Jet E_{T}; events",
0881                      50,
0882                      -1,
0883                      1.5);
0884   h_resolutionJetET_HB_HE_ =
0885       ibooker.book1D("resolutionJetET_HB_HE",
0886                      "jet ET resolution (HB+HE); (L1 Jet E_{T} - Offline Jet E_{T})/Offline Jet E_{T}; events",
0887                      50,
0888                      -1,
0889                      1.5);
0890 
0891   h_resolutionJetPhi_HB_ =
0892       ibooker.book1D("resolutionJetPhi_HB",
0893                      "#phi_{jet} resolution (HB); (#phi_{jet}^{L1} - #phi_{jet}^{offline}); events",
0894                      120,
0895                      -0.3,
0896                      0.3);
0897   h_resolutionJetPhi_HE_ = ibooker.book1D("resolutionJetPhi_HE",
0898                                           "jet #phi resolution (HE); (#phi_{jet}^{L1} - #phi_{jet}^{offline}); events",
0899                                           120,
0900                                           -0.3,
0901                                           0.3);
0902   h_resolutionJetPhi_HF_ = ibooker.book1D("resolutionJetPhi_HF",
0903                                           "jet #phi resolution (HF); (#phi_{jet}^{L1} - #phi_{jet}^{offline}); events",
0904                                           120,
0905                                           -0.3,
0906                                           0.3);
0907   h_resolutionJetPhi_HB_HE_ =
0908       ibooker.book1D("resolutionJetPhi_HB_HE",
0909                      "jet #phi resolution (HB+HE); (#phi_{jet}^{L1} - #phi_{jet}^{offline}); events",
0910                      120,
0911                      -0.3,
0912                      0.3);
0913 
0914   h_resolutionJetEta_ = ibooker.book1D(
0915       "resolutionJetEta", "jet #eta resolution  (HB); (L1 Jet #eta - Offline Jet #eta); events", 120, -0.3, 0.3);
0916 
0917   // jet turn-ons
0918   ibooker.setCurrentFolder(efficiencyFolderJet_);
0919   std::vector<float> jetBins(jetEfficiencyBins_.begin(), jetEfficiencyBins_.end());
0920   int nBins = jetBins.size() - 1;
0921   float* jetBinArray = &(jetBins[0]);
0922 
0923   for (auto threshold : jetEfficiencyThresholds_) {
0924     std::string str_threshold = std::to_string(int(threshold));
0925     h_efficiencyJetEt_HB_pass_[threshold] =
0926         ibooker.book1D("efficiencyJetEt_HB_threshold_" + str_threshold + "_Num",
0927                        "jet efficiency (HB) (numerator); Offline Jet E_{T} (GeV); events",
0928                        nBins,
0929                        jetBinArray);
0930     h_efficiencyJetEt_HE_pass_[threshold] =
0931         ibooker.book1D("efficiencyJetEt_HE_threshold_" + str_threshold + "_Num",
0932                        "jet efficiency (HE) (numerator); Offline Jet E_{T} (GeV); events",
0933                        nBins,
0934                        jetBinArray);
0935     h_efficiencyJetEt_HF_pass_[threshold] =
0936         ibooker.book1D("efficiencyJetEt_HF_threshold_" + str_threshold + "_Num",
0937                        "jet efficiency (HF) (numerator); Offline Jet E_{T} (GeV); events",
0938                        nBins,
0939                        jetBinArray);
0940     h_efficiencyJetEt_HB_HE_pass_[threshold] =
0941         ibooker.book1D("efficiencyJetEt_HB_HE_threshold_" + str_threshold + "_Num",
0942                        "jet efficiency (HB+HE) (numerator); Offline Jet E_{T} (GeV); events",
0943                        nBins,
0944                        jetBinArray);
0945 
0946     h_efficiencyJetEt_HB_total_[threshold] =
0947         ibooker.book1D("efficiencyJetEt_HB_threshold_" + str_threshold + "_Den",
0948                        "jet efficiency (HB) (denominator); Offline Jet E_{T} (GeV); events",
0949                        nBins,
0950                        jetBinArray);
0951     h_efficiencyJetEt_HE_total_[threshold] =
0952         ibooker.book1D("efficiencyJetEt_HE_threshold_" + str_threshold + "_Den",
0953                        "jet efficiency (HE) (denominator); Offline Jet E_{T} (GeV); events",
0954                        nBins,
0955                        jetBinArray);
0956     h_efficiencyJetEt_HF_total_[threshold] =
0957         ibooker.book1D("efficiencyJetEt_HF_threshold_" + str_threshold + "_Den",
0958                        "jet efficiency (HF) (denominator); Offline Jet E_{T} (GeV); events",
0959                        nBins,
0960                        jetBinArray);
0961     h_efficiencyJetEt_HB_HE_total_[threshold] =
0962         ibooker.book1D("efficiencyJetEt_HB_HE_threshold_" + str_threshold + "_Den",
0963                        "jet efficiency (HB+HE) (denominator); Offline Jet E_{T} (GeV); events",
0964                        nBins,
0965                        jetBinArray);
0966   }
0967 
0968   ibooker.cd();
0969 }
0970 
0971 bool L1TStage2CaloLayer2Offline::doesNotOverlapWithHLTObjects(const l1t::Jet& jet) const {
0972   // get HLT objects of fired triggers
0973   using namespace dqmoffline::l1t;
0974   std::vector<bool> results = getTriggerResults(triggerIndices_, triggerResults_);
0975   std::vector<unsigned int> firedTriggers = getFiredTriggerIndices(triggerIndices_, results);
0976   std::vector<edm::InputTag> hltFilters = getHLTFilters(firedTriggers, hltConfig_, triggerProcess_);
0977   const trigger::TriggerObjectCollection hltObjects = getTriggerObjects(hltFilters, triggerEvent_);
0978   // only take objects with et() > 27 GeV
0979   trigger::TriggerObjectCollection filteredHltObjects;
0980   std::copy_if(hltObjects.begin(), hltObjects.end(), std::back_inserter(filteredHltObjects), [](auto obj) {
0981     return obj.et() > 27;
0982   });
0983   double l1Eta = jet.eta();
0984   double l1Phi = jet.phi();
0985   const trigger::TriggerObjectCollection matchedObjects = getMatchedTriggerObjects(l1Eta, l1Phi, 0.3, hltObjects);
0986 
0987   return matchedObjects.empty();
0988 }
0989 
0990 void L1TStage2CaloLayer2Offline::normalise2DHistogramsToBinArea() {
0991   std::vector<MonitorElement*> monElementstoNormalize = {
0992       h_L1METvsCaloMET_,         h_L1ETMHFvsCaloETMHF_,       h_L1METvsPFMetNoMu_,      h_L1MHTvsRecoMHT_,
0993       h_L1METTvsCaloETT_,        h_L1HTTvsRecoHTT_,           h_L1METPhivsCaloMETPhi_,  h_L1ETMHFPhivsCaloETMHFPhi_,
0994       h_L1METPhivsPFMetNoMuPhi_, h_L1MHTPhivsRecoMHTPhi_,     h_L1JetETvsPFJetET_HB_,   h_L1JetETvsPFJetET_HE_,
0995       h_L1JetETvsPFJetET_HF_,    h_L1JetETvsPFJetET_HB_HE_,   h_L1JetPhivsPFJetPhi_HB_, h_L1JetPhivsPFJetPhi_HE_,
0996       h_L1JetPhivsPFJetPhi_HF_,  h_L1JetPhivsPFJetPhi_HB_HE_, h_L1JetEtavsPFJetEta_,
0997   };
0998 
0999   for (auto mon : monElementstoNormalize) {
1000     if (mon != nullptr) {
1001       auto h = mon->getTH2F();
1002       if (h != nullptr) {
1003         h->Scale(1, "width");
1004       }
1005     }
1006   }
1007 }
1008 
1009 //define this as a plug-in
1010 DEFINE_FWK_MODULE(L1TStage2CaloLayer2Offline);