From 8fd4f3f22568bd09b1234d1b51bea842d5df4324 Mon Sep 17 00:00:00 2001 From: Jannik Geisen <jannik.geisen@cern.ch> Date: Thu, 29 Oct 2020 12:25:43 +0100 Subject: [PATCH] New default plotting of chain jets for AthenaMT sample in Legacy tool --- .../TrigJetMonitoring/src/HLTJetMonTool.cxx | 104 ++++++++++++++++-- .../TrigJetMonitoring/src/HLTJetMonTool.h | 1 + 2 files changed, 97 insertions(+), 8 deletions(-) diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/HLTJetMonTool.cxx b/Trigger/TrigMonitoring/TrigJetMonitoring/src/HLTJetMonTool.cxx index 15c87be8ae84..462b8628196b 100755 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/HLTJetMonTool.cxx +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/HLTJetMonTool.cxx @@ -724,12 +724,20 @@ void HLTJetMonTool::bookJetHists() { nvar = basicKineVar(varlist,bookvars); levels.clear(); levels.push_back("HLT"); /*levels.push_back("L1");*/ for(JetSigIter k= m_basicHLTTrig.begin(); k != m_basicHLTTrig.end(); ++k ) { - const std::string theDir = HLTdir + "/" + (*k).first; + std::string theDir = HLTdir + "/" + (*k).first; m_monGroups[(*k).first] = theDir; ATH_MSG_DEBUG("Booking histograms for " << theDir); addMonGroup (new MonGroup(this, theDir, run)); setCurrentMonGroup(theDir); bookBasicHists(levels,bookvars); + //Add MonGroup for plots based only on jets passing the chain criteria, + //to be stored in expert folder chain/PassingJets + theDir = HLTdir + "/" + (*k).first + "/PassingJets"; + m_monGroups[(*k).first + "_PJ"] = theDir; + ATH_MSG_DEBUG("Booking histograms for " << theDir); + addMonGroup (new MonGroup(this, theDir, run)); + setCurrentMonGroup(theDir); + bookBasicHists(levels,bookvars); } /* @@ -1855,12 +1863,77 @@ void HLTJetMonTool::fillBasicHLTforChain( const std::string& theChain, double th }// loop over features container } else { // TrigComposite mode + + // First: retrieve all jets in the underlying jet container + // so that we can compare with the Legacy code above + + std::string jetcollname = GetJetCollectionName(theChain); //need to retrieve underlying jet container name - hard-coded function! + const xAOD::JetContainer *jcont = 0; + StatusCode sc = StatusCode::SUCCESS; + sc = evtStore()->retrieve(jcont, jetcollname); + if(sc.isFailure() || !jcont) { + ATH_MSG_INFO ("Could not retrieve JetCollection with key \"" << jetcollname << "\" from TDS" ); + } + else { + ATH_MSG_DEBUG("FOUND JetCollection with key \"" << jetcollname << "\" from TDS" ); + for (const xAOD::Jet* j : *jcont) { + + double e = (j->e())/Gaudi::Units::GeV; + double et = 0., epsilon = 1.e-3; + + if(j->p4().Et() > epsilon) et = (j->p4().Et())/Gaudi::Units::GeV; + + ATH_MSG_DEBUG("jet et = "<<et); + + if(et < epsilon) et = 0; + bool hlt_thr_pass = ( et > thrHLT ); + if(hlt_thr_pass) { + double eta = j->eta(); + double phi = j->phi(); + double m = j->m()/Gaudi::Units::GeV; + float emfrac =1; + float hecfrac =1; + if ((m_isPP || m_isCosmic || m_isMC) && + j->getAttribute<float>(xAOD::JetAttribute::EMFrac, emfrac)) + { + hecfrac = j->getAttribute<float>(xAOD::JetAttribute::HECFrac); + } + + v_thisjet.SetPtEtaPhiE(j->pt()/Gaudi::Units::GeV,j->eta(), j->phi(),j->e()/Gaudi::Units::GeV); + m_v_HLTjet.push_back(v_thisjet); + m_n_index++; + + if((h = hist("HLTJet_Et"))) h->Fill(et, m_lumi_weight); + if((h = hist("HLTJet_HighEt"))) h->Fill(et, m_lumi_weight); + if((h = hist("HLTJet_eta"))) h->Fill(eta, m_lumi_weight); + if((h = hist("HLTJet_phi"))) h->Fill(phi, m_lumi_weight); + if((h = hist("HLTJet_m"))) h->Fill(m, m_lumi_weight); + if((h = hist("HLTJet_emfrac"))) h->Fill(emfrac, m_lumi_weight); + if((h = hist("HLTJet_hecfrac"))) h->Fill(hecfrac, m_lumi_weight); + + if (count==0){ + if((h = hist("HLTJet_Leading_Et"))) h->Fill(et, m_lumi_weight); + } + + if((h2 = hist2("HLTJet_phi_vs_eta"))) h2->Fill(eta,phi,m_lumi_weight); + if((h2 = hist2("HLTJet_E_vs_eta"))) h2->Fill(eta,e,m_lumi_weight); + if((h2 = hist2("HLTJet_E_vs_phi"))) h2->Fill(phi,e,m_lumi_weight); + + }// if hlt threshold + count++; + }// loop over jet container + if((h = hist("HLTJet_n"))) h->Fill(count, m_lumi_weight); + } //else found jetcontainer + m_v_HLTindex.push_back(m_n_index); + // Note: Only getting jets which pass theChain here - const std::vector< TrigCompositeUtils::LinkInfo<xAOD::JetContainer> > fc = + // Thus, setting path for plots to a subfolder "/PassingJets" of the chain + setCurrentMonGroup(m_monGroups[Form("%s_PJ",theChain.c_str())]); + count=0; + const std::vector< TrigCompositeUtils::LinkInfo<xAOD::JetContainer> > lifc = getTDT()->features<xAOD::JetContainer>( chain ); - std::list<const xAOD::Jet*> jetList; //structure needed to sort jets by ET - for(const auto& jetLinkInfo : fc) { + for(const auto& jetLinkInfo : lifc) { if (!jetLinkInfo.isValid()) { ATH_MSG_ERROR("Invalid ElementLink to online jet"); continue; @@ -1869,7 +1942,7 @@ void HLTJetMonTool::fillBasicHLTforChain( const std::string& theChain, double th const xAOD::Jet *trigjet = dynamic_cast<const xAOD::Jet*>(*j); jetList.push_back( trigjet ); } - auto sort = [] (const xAOD::Jet * j1, const xAOD::Jet * j2) {return j1->p4().Et() > j2->p4().Et(); } ; + auto sort = [] (const xAOD::Jet * j1, const xAOD::Jet * j2) {return j1->p4().Et() > j2->p4().Et(); } ; //can choose different way of sorting! jetList.sort( sort ); for(const xAOD::Jet* j : jetList) { // ATH_MSG_INFO("Loop Over Features"); @@ -1894,9 +1967,9 @@ void HLTJetMonTool::fillBasicHLTforChain( const std::string& theChain, double th hecfrac = j->getAttribute<float>(xAOD::JetAttribute::HECFrac); } - v_thisjet.SetPtEtaPhiE(j->pt()/Gaudi::Units::GeV,j->eta(), j->phi(),j->e()/Gaudi::Units::GeV); - m_v_HLTjet.push_back(v_thisjet); - m_n_index++; + //v_thisjet.SetPtEtaPhiE(j->pt()/Gaudi::Units::GeV,j->eta(), j->phi(),j->e()/Gaudi::Units::GeV); + //m_v_HLTjet.push_back(v_thisjet); + //m_n_index++; if((h = hist("HLTJet_Et"))) h->Fill(et, m_lumi_weight); if((h = hist("HLTJet_HighEt"))) h->Fill(et, m_lumi_weight); @@ -2345,6 +2418,7 @@ StatusCode HLTJetMonTool::fillDiJetHists() { if (theChain == m_hlt_DijetChains[k]){ ATH_MSG_DEBUG("pass"); setCurrentMonGroup(m_monGroups[(*hj).first]); + std::cout<<"JANNIK: HLTvsHLT: trying to setCurrentMonGroup to m_monGroups["<<(*hj).first<<"] = "<< m_monGroups[(*hj).first] <<std::endl; if (hltlead && hltsublead){ if((h2 = hist2(Form("%s_leadEt_vs_%s_subleadEt",theChain.c_str(),theChain.c_str())))) h2->Fill(v_leadjet.Et(),v_subleadjet.Et(),m_lumi_weight); @@ -3302,3 +3376,17 @@ int HLTJetMonTool::basicKineVar(const std::string& hist, std::vector<std::string return retval; } // ------------------------------------------------------------------------------------ +std::string HLTJetMonTool::GetJetCollectionName(const std::string& theChain) { + std::string jetcoll = "HLT_AntiKt4EMTopoJets_subjesIS"; //default small-R EMTopo jets + if (theChain.find("a10t") != std::string::npos) jetcoll = "HLT_AntiKt10LCTopoTrimmedPtFrac5SmallR20Jets_jes"; + else if(theChain.find("a10r") != std::string::npos) jetcoll = "HLT_AntiKt10JetRCJets_subjesIS"; + else if(theChain.find("a10") != std::string::npos) jetcoll = "HLT_AntiKt10LCTopoJets_subjes"; //default large-R jets + else if(theChain.find("ftf") != std::string::npos) { //EMPFlow jets + if (theChain.find("subjesgsc") != std::string::npos) jetcoll = "HLT_AntiKt4EMPFlowJets_subjesgscIS_ftf"; + else if (theChain.find("pf_nojcalib") != std::string::npos) jetcoll = "HLT_AntiKt4EMPFlowJets_nojcalib_ftf"; + else if (theChain.find("csskpf_nojcalib") != std::string::npos) jetcoll = "HLT_AntiKt4EMPFlowCSSKJets_nojcalib_ftf"; + else jetcoll = "HLT_AntiKt4EMPFlowJets_subjesIS_ftf"; //default small-R EMPFlow + } + return jetcoll; +} +// ------------------------------------------------------------------------------------ diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/HLTJetMonTool.h b/Trigger/TrigMonitoring/TrigJetMonitoring/src/HLTJetMonTool.h index 8ed6e84559a7..bb1212fb3334 100755 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/HLTJetMonTool.h +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/HLTJetMonTool.h @@ -205,6 +205,7 @@ class HLTJetMonTool : public IHLTMonTool { void setHistProperties(TH1* h); void set2DHistProperties(TH2* h); int basicKineVar(const std::string& hist, std::vector<std::string>& kinevars); + std::string GetJetCollectionName(const std::string& theChain); void clearVectors(); // offline jet cuts -- GitLab