diff --git a/Reconstruction/Jet/JetMonitoring/JetMonitoring/JetHistoMatchedFiller.h b/Reconstruction/Jet/JetMonitoring/JetMonitoring/JetHistoMatchedFiller.h index a4cab57982da7c560c24ccec889319daf30127b9..65181058fba5e6fa7cb4393b85f3681d51123bab 100644 --- a/Reconstruction/Jet/JetMonitoring/JetMonitoring/JetHistoMatchedFiller.h +++ b/Reconstruction/Jet/JetMonitoring/JetMonitoring/JetHistoMatchedFiller.h @@ -1,6 +1,6 @@ // this file is -*- C++ -*- /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef JETMATCHEDFILLER_H @@ -25,7 +25,14 @@ private: Gaudi::Property<std::string> m_group {this,"Group", "undefined"}; SG::ReadDecorHandleKey<xAOD::JetContainer> m_matchedKey{this, "matched", "matched", "SG key for input matched decoration"}; - SG::ReadDecorHandleKey<xAOD::JetContainer> m_ptdiffKey{this, "ptdiff", "ptdiff", "SG key for input matched decoration"}; + SG::ReadDecorHandleKey<xAOD::JetContainer> m_ptdiffKey{this, "ptdiff", "ptdiff", "SG key for input matched ptdiff decoration"}; + SG::ReadDecorHandleKey<xAOD::JetContainer> m_energydiffKey{this, "energydiff", "energydiff", "SG key for input matched energydiff decoration"}; + SG::ReadDecorHandleKey<xAOD::JetContainer> m_massdiffKey{this, "massdiff", "massdiff", "SG key for input matched massdiff decoration"}; + SG::ReadDecorHandleKey<xAOD::JetContainer> m_ptrespKey{this, "ptresp", "ptresp", "SG key for input matched ptresp decoration"}; + SG::ReadDecorHandleKey<xAOD::JetContainer> m_energyrespKey{this, "energyresp", "energyresp", "SG key for input matched energyresp decoration"}; + SG::ReadDecorHandleKey<xAOD::JetContainer> m_massrespKey{this, "massresp", "massresp", "SG key for input matched massresp decoration"}; + SG::ReadDecorHandleKey<xAOD::JetContainer> m_ptrefKey{this, "ptref", "ptref", "SG key for input matched ptref decoration"}; + SG::ReadDecorHandleKey<xAOD::JetContainer> m_etarefKey{this, "etaref", "etaref", "SG key for input matched etaref decoration"}; }; #endif diff --git a/Reconstruction/Jet/JetMonitoring/JetMonitoring/JetMatcherAlg.h b/Reconstruction/Jet/JetMonitoring/JetMonitoring/JetMatcherAlg.h index 7c18a84a3526537919bbd7f31b964516b24db0d3..542ae3231f1aaa45ac84ff5c6525192300f08f5b 100644 --- a/Reconstruction/Jet/JetMonitoring/JetMonitoring/JetMatcherAlg.h +++ b/Reconstruction/Jet/JetMonitoring/JetMonitoring/JetMatcherAlg.h @@ -1,6 +1,6 @@ // this is a -*- C++ -*- file /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ ////////////////////////////////////////////////////////////////// @@ -35,10 +35,18 @@ class JetMatcherAlg : public AthReentrantAlgorithm { // input jet containers SG::ReadHandleKey<xAOD::JetContainer> m_jetContainerKey1, m_jetContainerKey2; // R matching property - Gaudi::Property<float> m_Rmatch {this, "Rmatch", 0.3, "R matching"}; + Gaudi::Property<float> m_Rmatch {this, "Rmatch", 0.3, "R matching"}; + Gaudi::Property<std::string> m_calibScale {this, "calibScale", "", "Calibration Scale at which to evaluate jet pT"}; // decorations SG::WriteDecorHandleKey<xAOD::JetContainer> m_matchedKey{this, "matched", "matched", "SG key for output matched decoration"}; SG::WriteDecorHandleKey<xAOD::JetContainer> m_ptDiffKey{this, "ptdiff", "ptdiff", "SG key for output pt difference decoration"}; + SG::WriteDecorHandleKey<xAOD::JetContainer> m_energyDiffKey{this, "energydiff", "energydiff", "SG key for output energy difference decoration"}; + SG::WriteDecorHandleKey<xAOD::JetContainer> m_massDiffKey{this, "massdiff", "massdiff", "SG key for output mass difference decoration"}; + SG::WriteDecorHandleKey<xAOD::JetContainer> m_ptRespKey{this, "ptdiff", "ptdiff", "SG key for output pt response decoration"}; + SG::WriteDecorHandleKey<xAOD::JetContainer> m_energyRespKey{this, "energydiff", "energydiff", "SG key for output energy response decoration"}; + SG::WriteDecorHandleKey<xAOD::JetContainer> m_massRespKey{this, "massdiff", "massdiff", "SG key for output mass response decoration"}; + SG::WriteDecorHandleKey<xAOD::JetContainer> m_ptRefKey{this, "ptRef", "ptRef", "SG key for output pt reference decoration"}; + SG::WriteDecorHandleKey<xAOD::JetContainer> m_etaRefKey{this, "etaRef", "etaRef", "SG key for output eta reference decoration"}; }; diff --git a/Reconstruction/Jet/JetMonitoring/src/JetHistoMatchedFiller.cxx b/Reconstruction/Jet/JetMonitoring/src/JetHistoMatchedFiller.cxx index b34696f16ed93013cda364be839d2ad4abbf3bbc..fb5581133730be179e68652e41b6e549786fd62e 100644 --- a/Reconstruction/Jet/JetMonitoring/src/JetHistoMatchedFiller.cxx +++ b/Reconstruction/Jet/JetMonitoring/src/JetHistoMatchedFiller.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "AthenaMonitoringKernel/GenericMonitoringTool.h" @@ -13,12 +13,26 @@ JetHistoMatchedFiller::JetHistoMatchedFiller( const std::string& type, const st declareInterface<IJetHistoFiller>(this); declareProperty("JetMatchedKey",m_matchedKey="NONE"); declareProperty("JetPtDiffKey", m_ptdiffKey="NONE"); + declareProperty("JetEnergyDiffKey", m_energydiffKey="NONE"); + declareProperty("JetMassDiffKey", m_massdiffKey="NONE"); + declareProperty("JetPtRespKey", m_ptrespKey="NONE"); + declareProperty("JetEnergyRespKey", m_energyrespKey="NONE"); + declareProperty("JetMassRespKey", m_massrespKey="NONE"); + declareProperty("JetPtRefKey", m_ptrefKey="NONE"); + declareProperty("JetEtaRefKey", m_etarefKey="NONE"); } StatusCode JetHistoMatchedFiller::initialize() { ATH_CHECK( m_matchedKey.initialize() ); ATH_CHECK( m_ptdiffKey.initialize() ); + ATH_CHECK( m_energydiffKey.initialize() ); + ATH_CHECK( m_massdiffKey.initialize() ); + ATH_CHECK( m_ptrespKey.initialize() ); + ATH_CHECK( m_energyrespKey.initialize() ); + ATH_CHECK( m_massrespKey.initialize() ); + ATH_CHECK( m_ptrefKey.initialize() ); + ATH_CHECK( m_etarefKey.initialize() ); return StatusCode::SUCCESS; } @@ -28,17 +42,38 @@ StatusCode JetHistoMatchedFiller::processJetContainer(const JetMonitoringAlg& pa SG::ReadDecorHandle<xAOD::JetContainer, char> matchedHandle(m_matchedKey, ctx); SG::ReadDecorHandle<xAOD::JetContainer, double> ptdiffHandle(m_ptdiffKey, ctx); + SG::ReadDecorHandle<xAOD::JetContainer, double> energydiffHandle(m_energydiffKey, ctx); + SG::ReadDecorHandle<xAOD::JetContainer, double> massdiffHandle(m_massdiffKey, ctx); + SG::ReadDecorHandle<xAOD::JetContainer, double> ptrespHandle(m_ptrespKey, ctx); + SG::ReadDecorHandle<xAOD::JetContainer, double> energyrespHandle(m_energyrespKey, ctx); + SG::ReadDecorHandle<xAOD::JetContainer, double> massrespHandle(m_massrespKey, ctx); + SG::ReadDecorHandle<xAOD::JetContainer, double> ptrefHandle(m_ptrefKey, ctx); + SG::ReadDecorHandle<xAOD::JetContainer, double> etarefHandle(m_etarefKey, ctx); auto matched = Monitored::Collection("matched", jets, [matchedHandle](const xAOD::Jet * jet) {return matchedHandle(*jet);}); auto dPt = Monitored::Scalar("ptdiff",0.0); + auto dEnergy = Monitored::Scalar("energydiff",0.0); + auto dMass = Monitored::Scalar("massdiff",0.0); + auto rPt = Monitored::Scalar("ptresp",0.0); + auto rEnergy = Monitored::Scalar("energyresp",0.0); + auto rMass = Monitored::Scalar("massresp",0.0); + auto ptRef = Monitored::Scalar("ptref",0.0); + auto etaRef = Monitored::Scalar("etaref",0.0); - // Loop over jets and fill pt difference between matched jets + // Loop over jets and fill pt, energy, mass differences and responses between matched jets, plus reference pT and eta for(const xAOD::Jet* jet : jets){ bool matched = matchedHandle(*jet); if(matched){ - dPt = ptdiffHandle(*jet); - parentAlg.fill(m_group,dPt); + dPt = ptdiffHandle(*jet); + dEnergy = energydiffHandle(*jet); + dMass = massdiffHandle(*jet); + rPt = ptrespHandle(*jet); + rEnergy = energyrespHandle(*jet); + rMass = massrespHandle(*jet); + ptRef = ptrefHandle(*jet); + etaRef = etarefHandle(*jet); + parentAlg.fill(m_group, dPt, dEnergy, dMass, rPt, rEnergy, rMass, ptRef, etaRef); } } diff --git a/Reconstruction/Jet/JetMonitoring/src/JetMatcherAlg.cxx b/Reconstruction/Jet/JetMonitoring/src/JetMatcherAlg.cxx index a2a5ba062f0090b7939552c5c4aba160c5af41d2..c6be5471fdba6a5409b8405e6b07a1af5fa5bd13 100644 --- a/Reconstruction/Jet/JetMonitoring/src/JetMatcherAlg.cxx +++ b/Reconstruction/Jet/JetMonitoring/src/JetMatcherAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "JetMonitoring/JetMatcherAlg.h" @@ -11,6 +11,7 @@ JetMatcherAlg::JetMatcherAlg( const std::string& name, ISvcLocator* pSvcLocator { declareProperty("JetContainerName1",m_jetContainerKey1="NONE"); declareProperty("JetContainerName2",m_jetContainerKey2="NONE"); + declareProperty("JetCalibScale", m_calibScale=""); } //********************************************************************** @@ -22,9 +23,25 @@ StatusCode JetMatcherAlg::initialize() { ATH_CHECK( m_jetContainerKey1.initialize() ); ATH_CHECK( m_jetContainerKey2.initialize() ); - m_ptDiffKey = m_jetContainerKey1.key()+".ptdiff_" + m_jetContainerKey2.key(); + std::string keyAppendix = m_jetContainerKey2.key(); + if (m_calibScale != "") keyAppendix = m_calibScale + "_" + m_jetContainerKey2.key(); + m_ptDiffKey = m_jetContainerKey1.key()+".ptdiff_" + keyAppendix; ATH_CHECK( m_ptDiffKey.initialize() ); - m_matchedKey = m_jetContainerKey1.key()+".matched_" + m_jetContainerKey2.key(); + m_energyDiffKey = m_jetContainerKey1.key()+".energydiff_" + keyAppendix; + ATH_CHECK( m_energyDiffKey.initialize() ); + m_massDiffKey = m_jetContainerKey1.key()+".massdiff_" + keyAppendix; + ATH_CHECK( m_massDiffKey.initialize() ); + m_ptRespKey = m_jetContainerKey1.key()+".ptresp_" + keyAppendix; + ATH_CHECK( m_ptRespKey.initialize() ); + m_energyRespKey = m_jetContainerKey1.key()+".energyresp_" + keyAppendix; + ATH_CHECK( m_energyRespKey.initialize() ); + m_massRespKey = m_jetContainerKey1.key()+".massresp_" + keyAppendix; + ATH_CHECK( m_massRespKey.initialize() ); + m_ptRefKey = m_jetContainerKey1.key()+".ptRef_" + keyAppendix; + ATH_CHECK( m_ptRefKey.initialize() ); + m_etaRefKey = m_jetContainerKey1.key()+".etaRef_" + keyAppendix; + ATH_CHECK( m_etaRefKey.initialize() ); + m_matchedKey = m_jetContainerKey1.key()+".matched_" + keyAppendix; ATH_CHECK( m_matchedKey.initialize() ); return StatusCode::SUCCESS; @@ -54,30 +71,71 @@ StatusCode JetMatcherAlg::execute(const EventContext& ctx) const { } SG::WriteDecorHandle<xAOD::JetContainer, double> ptDiffHandle(m_ptDiffKey, ctx); + SG::WriteDecorHandle<xAOD::JetContainer, double> energyDiffHandle(m_energyDiffKey, ctx); + SG::WriteDecorHandle<xAOD::JetContainer, double> massDiffHandle(m_massDiffKey, ctx); + SG::WriteDecorHandle<xAOD::JetContainer, double> ptRespHandle(m_ptRespKey, ctx); + SG::WriteDecorHandle<xAOD::JetContainer, double> energyRespHandle(m_energyRespKey, ctx); + SG::WriteDecorHandle<xAOD::JetContainer, double> massRespHandle(m_massRespKey, ctx); + SG::WriteDecorHandle<xAOD::JetContainer, double> ptRefHandle(m_ptRefKey, ctx); + SG::WriteDecorHandle<xAOD::JetContainer, double> etaRefHandle(m_etaRefKey, ctx); SG::WriteDecorHandle<xAOD::JetContainer, char> matchedHandle(m_matchedKey, ctx); + + std::vector<int> matchedIndices; //remembers which jets in jets2 are already matched, so they are not considered in future matching // Loop over first jet collection for(const xAOD::Jet* j1 : *jets1){ bool j1matched = false; - double ptDiff = 0; + double ptDiff = 0., energyDiff = 0., massDiff = 0., ptResp = 0., energyResp = 0., massResp = 0., ptRef = 0., etaRef = 0.; auto tlvjet1 = TLorentzVector(); - tlvjet1.SetPtEtaPhiE(j1->pt(),j1->eta(),j1->phi(),j1->e()); + if (m_calibScale == "" ) tlvjet1.SetPtEtaPhiE(j1->pt(),j1->eta(),j1->phi(),j1->e()); + else { //retrieve fourmomentum at specified calibration scale + xAOD::JetFourMom_t fourVec; + bool status = j1->getAttribute<xAOD::JetFourMom_t>( "Jet"+m_calibScale+"Momentum", fourVec ); + if(!status) { + ATH_MSG_ERROR("evtStore() cannot retrieve JetFourMomentum at " << m_calibScale); + return StatusCode::FAILURE; + } + tlvjet1.SetPtEtaPhiE(fourVec.Pt(),fourVec.Eta(),fourVec.Phi(),fourVec.E()); + } // Loop over second jet collectoin double Rmin = 1E8; + int jetIndex = 0, jetMatchIndex = 0; for(const xAOD::Jet* j2 : *jets2){ + bool alreadymatched = false; + for (int jetIndexIterator : matchedIndices) { //Loop over indices of already matched jets to skip them + if (jetIndex == jetIndexIterator) { alreadymatched = true; break; } + } + if (alreadymatched) { jetIndex++; continue; } auto tlvjet2 = TLorentzVector(); tlvjet2.SetPtEtaPhiE(j2->pt(),j2->eta(),j2->phi(),j2->e()); // calculate DeltaR(jet1,jet2) double dr = tlvjet1.DeltaR(tlvjet2); if(dr<m_Rmatch && dr<Rmin){ // decorate matching jets - j1matched = true; - ptDiff = tlvjet1.Pt()-tlvjet2.Pt(); - Rmin = dr; + j1matched = true; + ptDiff = tlvjet1.Pt()-tlvjet2.Pt(); + energyDiff = tlvjet1.E()-tlvjet2.E(); + massDiff = tlvjet1.M()-tlvjet2.M(); + ptResp = ptDiff/tlvjet2.Pt(); + energyResp = energyDiff/tlvjet2.E(); + massResp = massDiff/tlvjet2.M(); + ptRef = tlvjet2.Pt(); //second jet collection (=offline) is taken for reference pT and eta + etaRef = tlvjet2.Eta(); + Rmin = dr; + jetMatchIndex = jetIndex; } - } - matchedHandle(*j1) = j1matched; - ptDiffHandle(*j1) = ptDiff; - } + jetIndex++; + }//End Loop over second jet collection + matchedHandle(*j1) = j1matched; + ptDiffHandle(*j1) = ptDiff; + energyDiffHandle(*j1) = energyDiff; + massDiffHandle(*j1) = massDiff; + ptRespHandle(*j1) = ptResp; + energyRespHandle(*j1) = energyResp; + massRespHandle(*j1) = massResp; + ptRefHandle(*j1) = ptRef; + etaRefHandle(*j1) = etaRef; + if (j1matched) matchedIndices.push_back(jetMatchIndex); + }//End Loop over first jet collection return StatusCode::SUCCESS; diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitorAlgorithm.py b/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitorAlgorithm.py index 4355d5a4420e7dfb6005717d505963b8700390b2..f25a8b77e4e189c9a591f83491ff22eabe4c28e4 100644 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitorAlgorithm.py +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitorAlgorithm.py @@ -14,10 +14,10 @@ import sys,argparse # Offline jet collections to monitor ##################################### -OfflineJetCollections = [ - 'AntiKt4EMTopoJets', - 'AntiKt4EMPFlowJets', -] +OfflineJetCollections = { + 'AntiKt4EMTopoJets' : { 'MatchTo' : 'AntiKt4EMPFlowJets' }, + 'AntiKt4EMPFlowJets' : { 'MatchTo' : 'NONE' }, +} ########################################### # L1 jet collections and chains to monitor @@ -172,6 +172,8 @@ for var in [ "pt", "eta", "m" ]: for onlinescale in OnlineScaleMomenta: ExtraSmallROnlineHists.append("Jet"+onlinescale+"Momentum_"+var) +OnlineScaleMomenta.append("") #Adding this for convenience in the jet matching loop below +OfflineScaleMomenta.append("") from AthenaConfiguration.AllConfigFlags import ConfigFlags @@ -190,9 +192,20 @@ def TrigJetMonConfig(inputFlags): # Match HLT jets to offline jets for hltColl,collDict in JetCollections[InputType].items(): if collDict['MatchTo'] != 'NONE': - name = 'Matching_{}_{}'.format(hltColl,collDict['MatchTo']) - alg = CompFactory.JetMatcherAlg(name, JetContainerName1=hltColl,JetContainerName2=collDict['MatchTo']) - cfg.addEventAlgo(alg) + for jetcalibscale in OnlineScaleMomenta: + scalestring = jetcalibscale if jetcalibscale == "" else "_"+jetcalibscale + name = 'Matching_{}_{}_{}'.format(hltColl,scalestring,collDict['MatchTo']) + alg = CompFactory.JetMatcherAlg(name, JetContainerName1=hltColl,JetContainerName2=collDict['MatchTo'],JetCalibScale=jetcalibscale) + cfg.addEventAlgo(alg) + + # Match offline to offline jets + for offjetColl,collDict in OfflineJetCollections.items(): + if collDict['MatchTo'] != 'NONE': + for jetcalibscale in OfflineScaleMomenta: + scalestring = jetcalibscale if jetcalibscale == "" else "_"+jetcalibscale + name = 'Matching_{}_{}_{}'.format(offjetColl,scalestring,collDict['MatchTo']) + alg = CompFactory.JetMatcherAlg(name, JetContainerName1=offjetColl,JetContainerName2=collDict['MatchTo'],JetCalibScale=jetcalibscale) + cfg.addEventAlgo(alg) # The following class will make a sequence, configure algorithms, and link # them to GenericMonitoringTools @@ -327,19 +340,12 @@ def jetMonitoringConfig(inputFlags,jetcoll,athenaMT): InputType = 'Legacy' if not athenaMT else 'MT' conf = basicJetMonAlgSpec(jetcoll,isOnline,athenaMT) - def defineHistoForJetMatch(conf, parentAlg, monhelper , path): - # create a monitoring group with the histo path starting from the parentAlg - print('toplevel = '+str(conf.topLevelDir)) - print('bottomlevel = '+str(conf.bottomLevelDir)) - group = monhelper.addGroup(parentAlg, conf.Group, conf.topLevelDir+'/'+conf.bottomLevelDir+'/NoTriggerSelection/') - # define the histogram - group.defineHistogram('ptdiff',title='title', type="TH1F", path='MatchedJets_{}'.format(JetCollections[InputType][jetcoll]['MatchTo']), xbins=100 , xmin=-100000, xmax=100000. ,) - # Declare a configuration dictionnary for a JetContainer if isOnline: if 'AntiKt4' in jetcoll or 'a4tcem' in jetcoll: for hist in ExtraSmallROnlineHists: conf.appendHistos(hist) if 'ftf' in jetcoll: # dedicated histograms for FTF chains + conf.appendHistos("Jvt") conf.appendHistos("JVFCorr") conf.appendHistos("JvtRpt") conf.appendHistos("SumPtTrkPt500[0]") @@ -352,16 +358,64 @@ def jetMonitoringConfig(inputFlags,jetcoll,athenaMT): for hist in ExtraLargeROnlineHists: conf.appendHistos(hist) # Add matched jets plots if JetCollections[InputType][jetcoll]['MatchTo'] != 'NONE': - matchedJetColl = JetCollections[InputType][jetcoll]['MatchTo'] - name = 'jetMatched_{}_{}'.format(jetcoll,matchedJetColl) - jetmatchKey = '{}.matched_{}'.format(jetcoll,matchedJetColl) - jetptdiffKey = '{}.ptdiff_{}'.format(jetcoll,matchedJetColl) - conf.appendHistos(ToolSpec('JetHistoMatchedFiller',name,JetMatchedKey=jetmatchKey,JetPtDiffKey=jetptdiffKey,defineHistoFunc=defineHistoForJetMatch,Group='matchedJets_'+jetcoll)) + def defineHistoForHLTJetMatch(conf, parentAlg, monhelper , path): + # create a monitoring group with the histo path starting from the parentAlg + group = monhelper.addGroup(parentAlg, conf.Group, conf.topLevelDir+'/'+conf.bottomLevelDir+'/NoTriggerSelection/') + # define the histograms + for histname in [ 'ptdiff', 'energydiff', 'massdiff' ]: #defines which variable difference will be plotted + group.defineHistogram(histname,title=histname, type="TH1F", path='MatchedJets_{}'.format(JetCollections[InputType][jetcoll]['MatchTo']), xbins=100 , xmin=-100000., xmax=100000. ,) + for histname in [ 'ptresp', 'energyresp', 'massresp' ]: + group.defineHistogram(histname,title=histname, type="TH1F", path='MatchedJets_{}'.format(JetCollections[InputType][jetcoll]['MatchTo']), xbins=100 , xmin=-2., xmax=2. ,) + group.defineHistogram('ptresp,ptref;ptresp_vs_ptRef',title='ptresponse vs ptRef', type="TH2F", path='MatchedJets_{}'.format(JetCollections[InputType][jetcoll]['MatchTo']), xbins=10 , xmin=-2., xmax=2., ybins=10, ymin=0., ymax=500000.,) + group.defineHistogram('ptresp,etaref;ptresp_vs_etaRef',title='ptresponse vs etaRef', type="TH2F", path='MatchedJets_{}'.format(JetCollections[InputType][jetcoll]['MatchTo']), xbins=10 , xmin=-2., xmax=2., ybins=10, ymin=-5., ymax=5.,) + matchedJetColl = JetCollections[InputType][jetcoll]['MatchTo'] + jetmatchKey = '{}.matched_{}'.format(jetcoll,matchedJetColl) #we can get specific calibration scales by adding e.g. '_EtaJESScale' to the strings + jetptdiffKey = '{}.ptdiff_{}'.format(jetcoll,matchedJetColl) + jetenergydiffKey = '{}.energydiff_{}'.format(jetcoll,matchedJetColl) + jetmassdiffKey = '{}.massdiff_{}'.format(jetcoll,matchedJetColl) + jetptrespKey = '{}.ptresp_{}'.format(jetcoll,matchedJetColl) + jetenergyrespKey = '{}.energyresp_{}'.format(jetcoll,matchedJetColl) + jetmassrespKey = '{}.massresp_{}'.format(jetcoll,matchedJetColl) + jetptrefKey = '{}.ptRef_{}'.format(jetcoll,matchedJetColl) + jetetarefKey = '{}.etaRef_{}'.format(jetcoll,matchedJetColl) + name = 'jetMatched_{}_{}'.format(jetcoll,matchedJetColl) + conf.appendHistos(ToolSpec('JetHistoMatchedFiller',name,JetMatchedKey=jetmatchKey,JetPtDiffKey=jetptdiffKey,JetEnergyDiffKey=jetenergydiffKey, + JetMassDiffKey=jetmassdiffKey,JetPtRespKey=jetptrespKey,JetEnergyRespKey=jetenergyrespKey,JetMassRespKey=jetmassrespKey, + JetPtRefKey=jetptrefKey,JetEtaRefKey=jetetarefKey, + defineHistoFunc=defineHistoForHLTJetMatch,Group='matchedJets_'+jetcoll) + ) else: # offline for hist in ExtraOfflineHists: conf.appendHistos(hist) if 'PF' in jetcoll: # dedicated histograms for offline PFlow jets conf.appendHistos("SumPtChargedPFOPt500[0]") conf.appendHistos("fCharged") + if OfflineJetCollections[jetcoll]['MatchTo'] != 'NONE': + def defineHistoForOfflineJetMatch(conf, parentAlg, monhelper , path): + # create a monitoring group with the histo path starting from the parentAlg + group = monhelper.addGroup(parentAlg, conf.Group, conf.topLevelDir+'/'+conf.bottomLevelDir+'/standardHistos/') + # define the histograms + for histname in [ 'ptdiff', 'energydiff', 'massdiff' ]: #defines which variable difference will be plotted + group.defineHistogram(histname,title=histname, type="TH1F", path='MatchedJets_{}'.format(OfflineJetCollections[jetcoll]['MatchTo']), xbins=100 , xmin=-100000., xmax=100000. ,) + for histname in [ 'ptresp', 'energyresp', 'massresp' ]: + group.defineHistogram(histname,title=histname, type="TH1F", path='MatchedJets_{}'.format(OfflineJetCollections[jetcoll]['MatchTo']), xbins=100 , xmin=-2., xmax=2. ,) + group.defineHistogram('ptresp,ptref;ptresp_vs_ptRef',title='ptresp vs ptRef', type="TH2F", path='MatchedJets_{}'.format(OfflineJetCollections[jetcoll]['MatchTo']), xbins=10 , xmin=-2., xmax=2., ybins=10, ymin=0., ymax=500000.,) + group.defineHistogram('ptresp,etaref;ptresp_vs_etaRef',title='ptresp vs etaRef', type="TH2F", path='MatchedJets_{}'.format(OfflineJetCollections[jetcoll]['MatchTo']), xbins=10 , xmin=-2., xmax=2., ybins=10, ymin=-5., ymax=5.,) + matchedJetColl = OfflineJetCollections[jetcoll]['MatchTo'] + jetmatchKey = '{}.matched_{}'.format(jetcoll,matchedJetColl) + jetptdiffKey = '{}.ptdiff_{}'.format(jetcoll,matchedJetColl) + jetenergydiffKey = '{}.energydiff_{}'.format(jetcoll,matchedJetColl) + jetmassdiffKey = '{}.massdiff_{}'.format(jetcoll,matchedJetColl) + jetptrespKey = '{}.ptresp_{}'.format(jetcoll,matchedJetColl) + jetenergyrespKey = '{}.energyresp_{}'.format(jetcoll,matchedJetColl) + jetmassrespKey = '{}.massresp_{}'.format(jetcoll,matchedJetColl) + jetptrefKey = '{}.ptRef_{}'.format(jetcoll,matchedJetColl) + jetetarefKey = '{}.etaRef_{}'.format(jetcoll,matchedJetColl) + name = 'jetMatched_{}_{}'.format(jetcoll,matchedJetColl) + conf.appendHistos(ToolSpec('JetHistoMatchedFiller',name,JetMatchedKey=jetmatchKey,JetPtDiffKey=jetptdiffKey,JetEnergyDiffKey=jetenergydiffKey, + JetMassDiffKey=jetmassdiffKey,JetPtRespKey=jetptrespKey,JetEnergyRespKey=jetenergyrespKey,JetMassRespKey=jetmassrespKey, + JetPtRefKey=jetptrefKey,JetEtaRefKey=jetetarefKey, + defineHistoFunc=defineHistoForOfflineJetMatch,Group='matchedJets_'+jetcoll) + ) return conf @@ -443,6 +497,10 @@ def jetChainMonitoringConfig(inputFlags,jetcoll,chain,athenaMT,onlyUsePassingJet trigConf.appendHistos( EventHistoSpec(NjetHistName, (25,0,25), title=NjetHistName+';'+NjetHistName+';Entries' ), ) + if 'jvt' in chain: #track JVT variables for chains with JVT applied + trigConf.appendHistos("Jvt") + trigConf.appendHistos("JVFCorr") + trigConf.appendHistos("JvtRpt") return trigConf @@ -625,9 +683,20 @@ if __name__=='__main__': # Match HLT jets to offline jets for hltColl,collDict in JetCollections[InputType].items(): if collDict['MatchTo'] != 'NONE': - name = 'Matching_{}_{}'.format(hltColl,collDict['MatchTo']) - alg = CompFactory.JetMatcherAlg(name, JetContainerName1=hltColl,JetContainerName2=collDict['MatchTo']) - cfg.addEventAlgo(alg,sequenceName='AthMonSeq_TrigJetMonitorAlgorithm') # Add matchers to monitoring alg sequence + for jetcalibscale in OnlineScaleMomenta: + scalestring = jetcalibscale if jetcalibscale == "" else "_"+jetcalibscale + name = 'Matching_{}_{}_{}'.format(hltColl,scalestring,collDict['MatchTo']) + alg = CompFactory.JetMatcherAlg(name, JetContainerName1=hltColl,JetContainerName2=collDict['MatchTo'],JetCalibScale=jetcalibscale) + cfg.addEventAlgo(alg,sequenceName='AthMonSeq_TrigJetMonitorAlgorithm') # Add matchers to monitoring alg sequence + + # Match offline to offline jets + for offjetColl,collDict in OfflineJetCollections.items(): + if collDict['MatchTo'] != 'NONE': + for jetcalibscale in OfflineScaleMomenta: + scalestring = jetcalibscale if jetcalibscale == "" else "_"+jetcalibscale + name = 'Matching_{}_{}_{}'.format(offjetColl,scalestring,collDict['MatchTo']) + alg = CompFactory.JetMatcherAlg(name, JetContainerName1=offjetColl,JetContainerName2=collDict['MatchTo'],JetCalibScale=jetcalibscale) + cfg.addEventAlgo(alg,sequenceName='AthMonSeq_TrigJetMonitorAlgorithm') # Add matchers to monitoring alg sequence # Loop over L1 jet collectoins for jetcoll in L1JetCollections: