From 7f7d0a47fac1bb5a87c68a4db943912b2454b75a Mon Sep 17 00:00:00 2001 From: ecarquin <e.carquin.pphysics@gmail.com> Date: Wed, 2 Dec 2020 18:15:24 +0100 Subject: [PATCH] Monitoring of Jet ID BDT related variables for the tau trigger --- .../python/TrigTauMonitoringConfigMT.py | 47 +++++++- .../src/TrigTauMonitorAlgorithm.cxx | 104 +++++++++++++++++- .../src/TrigTauMonitorAlgorithm.h | 2 + 3 files changed, 148 insertions(+), 5 deletions(-) diff --git a/Trigger/TrigMonitoring/TrigTauMonitoring/python/TrigTauMonitoringConfigMT.py b/Trigger/TrigMonitoring/TrigTauMonitoring/python/TrigTauMonitoringConfigMT.py index ff7c9d506a9..178fdc3687e 100644 --- a/Trigger/TrigMonitoring/TrigTauMonitoring/python/TrigTauMonitoringConfigMT.py +++ b/Trigger/TrigMonitoring/TrigTauMonitoring/python/TrigTauMonitoringConfigMT.py @@ -216,6 +216,11 @@ class TrigTauMonAlgBuilder: self.bookbasicVars( monAlg, trigger, online=False ) self.bookHLTEffHistograms( monAlg, trigger,nProng='1P') self.bookHLTEffHistograms( monAlg, trigger,nProng='MP') + else: + self.bookBDTOut( monAlg, trigger, nProng='1P') + self.bookBDTOut( monAlg, trigger, nProng='MP') + self.bookBDTNoCorr( monAlg, trigger, nProng='1P') + self.bookBDTNoCorr( monAlg, trigger, nProng='MP') #remove duplicated from L1 seed list l1seeds = list(dict.fromkeys(l1seeds)) @@ -345,7 +350,6 @@ class TrigTauMonAlgBuilder: monGroup.defineHistogram('hEFEta;hEFPhi', type='TH2F', title='EF TrigCaloCluster Eta vs Phi; #eta ; #phi', path=monGroupPath, xbins=26,xmin=-2.6,xmax=2.6,ybins=16,ymin=-3.2,ymax=3.2) - #addHistogram(new TH2F("hEFEtaVsPhi","EF TrigCaloCluster Eta vs Phi; #eta ; #phi ; Nevents",26,-2.6,2.6,16,-3.2,3.2)); monGroup.defineHistogram('hEFEt;hEFPhi', type='TH2F', title='Et from tau Jet vs #phi; #phi^{EF}; Raw E_{T} [GeV]', path=monGroupPath, xbins=16,xmin=-3.2,xmax=3.2,ybins=50,ymin=0,ymax=100) @@ -357,5 +361,42 @@ class TrigTauMonAlgBuilder: monGroup.defineHistogram('hEFEtRaw', title='EF Et Raw;Uncalibrated E_{T}[GeV];Nevents',xbins=50,xmin=0,xmax=100) monGroup.defineHistogram('hEFnWideTrack', title='EF number of wide tracks;number of tracks;Nevents',xbins=10,xmin=0,xmax=10) - #monGroup.defineHistogram('hEFIsoFrac', title='Iso Fraction at EF; isoFrac at EF; Candidates',xbins=50,xmin=-0.1,xmax=1.1) - #monGroup.defineHistogram('hEFEMFraction', title='Em Fraction at EF; EM Fraction at EF; Candidates',xbins=50,xmin=-0.05,xmax=1.1) + # + # Book BDT Variables + # + def bookBDTOut( self, monAlg, trigger, nProng): + + monGroupName = trigger+'_BDT_HLT_Out_'+nProng + monGroupPath = 'BDT/Out_'+nProng+'/'+trigger + monGroup = self.helper.addGroup( monAlg, monGroupName, + self.basePath+'/'+monGroupPath ) + + print('MonGroup name is python: ', monGroupName) + + monGroup.defineHistogram('BDTJetScore', title='BDT Score ('+nProng+') ; HLT BDT Score; Candidates',xbins=50,xmin=0,xmax=1) + monGroup.defineHistogram('BDTJetScoreSigTrans', title='Flattened BDT Score ('+nProng+') ; HLT BDT Score; Candidates',xbins=50,xmin=0,xmax=1) + + + def bookBDTNoCorr( self, monAlg, trigger, nProng ): + + monGroupName = trigger+'_BDT_HLT_NoCorr_'+nProng + monGroupPath = 'BDT/NoCorr_'+nProng+'/'+trigger + monGroup = self.helper.addGroup( monAlg, monGroupName, + self.basePath+'/'+monGroupPath ) + + monGroup.defineHistogram('CentFrac', title='Centrality Fraction ('+nProng+') non-corrected; centFrac; Candidates',xbins=50,xmin=-0.05,xmax=1.2) + monGroup.defineHistogram('ChPiEMEOverCaloEME', title='ChPiEMEOverCaloEME ('+nProng+') non-corrected; ChPiEMEOverCaloEME; Candidates',xbins=51,xmin=-20,xmax=20) + monGroup.defineHistogram('EMPOverTrkSys', title='EMPOverTrkSys ('+nProng+') non-corrected; EMPOverTrkSys; Candidates',xbins=41,xmin=0,xmax=40) + monGroup.defineHistogram('etOverPtLeadTrk', title='etOverPtLeadTrk ('+nProng+') non-corrected; etOverPtLeadTrk; Candidates',xbins=51,xmin=-0.1,xmax=25) + monGroup.defineHistogram('innerTrkAvgDist', title='innerTrkAvgDist ('+nProng+') non-corrected; innerTrkAvgDist; Candidates',xbins=50,xmin=-0.05,xmax=0.5) + monGroup.defineHistogram('ptRatioEflowApprox', title='ptRatioEflowApprox ('+nProng+') non-corrected; ptRatioEflowApprox; Candidates',xbins=50,xmin=0,xmax=2) + monGroup.defineHistogram('massTrkSys', title='massTrkSys log ('+nProng+'); massTrkSys_log; Events',xbins=50,xmin=0.,xmax=3.) + + if nProng=='1P': + monGroup.defineHistogram('SumPtTrkFrac', title='SumPtTrkFrac ('+nProng+') non-corrected; SumPtTrkFrac; Candidates',xbins=50,xmin=-0.5,xmax=1.1) + + if nProng=='MP': + monGroup.defineHistogram('dRmax', title='dRmax ('+nProng+') non-corrected; dRmax; Candidates',xbins=50,xmin=-0.1,xmax=0.3) + monGroup.defineHistogram('massTrkSys', title='massTrkSys ('+nProng+') non-corrected; massTrkSys; Candidates',xbins=50,xmin=-0.1,xmax=15) + monGroup.defineHistogram('mEflowApprox', title='mEflowApprox ('+nProng+') non-corrected; mEflowApprox; Candidates',xbins=61,xmin=-0.2,xmax=60.2) + monGroup.defineHistogram('trFlightPathSig', title='trFlightPathSig ('+nProng+') non-corrected; trFlightPathSig; Candidates',xbins=50,xmin=-20,xmax=20) diff --git a/Trigger/TrigMonitoring/TrigTauMonitoring/src/TrigTauMonitorAlgorithm.cxx b/Trigger/TrigMonitoring/TrigTauMonitoring/src/TrigTauMonitorAlgorithm.cxx index 21e8d2ca357..0408f39bdac 100644 --- a/Trigger/TrigMonitoring/TrigTauMonitoring/src/TrigTauMonitorAlgorithm.cxx +++ b/Trigger/TrigMonitoring/TrigTauMonitoring/src/TrigTauMonitorAlgorithm.cxx @@ -107,6 +107,9 @@ StatusCode TrigTauMonitorAlgorithm::executeNavigation( const EventContext& ctx, return StatusCode::FAILURE; } + std::string tauContainerName = "HLT_TrigTauRecMerged_Precision"; + if(trigItem.find("EF_")!=std::string::npos || trigItem.find("MVA_")!=std::string::npos) tauContainerName="HLT_TrigTauRecMerged_MVA"; + for(const auto& Tau : *offTaus ){ const TrigCompositeUtils::Decision *dec=nullptr; @@ -115,7 +118,7 @@ StatusCode TrigTauMonitorAlgorithm::executeNavigation( const EventContext& ctx, if((pidname.find("mediumRNN") != std::string::npos) && !Tau->isTau(xAOD::TauJetParameters::JetRNNSigMedium)) continue; - auto vec = m_trigDecTool->features<xAOD::TauJetContainer>(trigItem,TrigDefs::includeFailedDecisions ,"HLT_TrigTauRecMerged_MVA"); + auto vec = m_trigDecTool->features<xAOD::TauJetContainer>(trigItem,TrigDefs::includeFailedDecisions , tauContainerName ); for( auto &featLinkInfo : vec ){ if(! featLinkInfo.isValid() ) continue; const auto *feat = *(featLinkInfo.link); @@ -173,7 +176,11 @@ void TrigTauMonitorAlgorithm::fillDistributions(const EventContext& ctx, std::ve fillbasicVars( trigger, offline_tau_vec_mp, false); } - auto vec = m_trigDecTool->features<xAOD::TauJetContainer>(trigger,TrigDefs::includeFailedDecisions ,"HLT_TrigTauRecMerged_MVA" ); + std::string tauContainerName = "HLT_TrigTauRecMerged_Precision"; + if(trigger.find("EF_")!=std::string::npos || trigger.find("MVA_")!=std::string::npos) tauContainerName="HLT_TrigTauRecMerged_MVA"; + ATH_MSG_DEBUG("Tau ContainerName is: " << tauContainerName); + + auto vec = m_trigDecTool->features<xAOD::TauJetContainer>(trigger,TrigDefs::includeFailedDecisions , tauContainerName ); for( auto &featLinkInfo : vec ){ const auto *feat = *(featLinkInfo.link); if(!feat) continue; @@ -188,6 +195,8 @@ void TrigTauMonitorAlgorithm::fillDistributions(const EventContext& ctx, std::ve } } + if(online_tau_vec_1p.size()==0 && online_tau_vec_mp.size()==0) return; + if(info.isRNN){ fillRNNInputVars( trigger, online_tau_vec_1p,"1P", true ); fillRNNInputVars( trigger, online_tau_vec_mp,"MP", true ); @@ -197,7 +206,13 @@ void TrigTauMonitorAlgorithm::fillDistributions(const EventContext& ctx, std::ve fillRNNCluster( trigger, online_tau_vec_mp, true ); fillbasicVars( trigger, online_tau_vec_1p, true); fillbasicVars( trigger, online_tau_vec_mp, true); + }else { + fillBDTOut( trigger,online_tau_vec_1p,"1P"); + fillBDTOut( trigger,online_tau_vec_mp,"MP"); + fillBDTNoCorr( trigger,online_tau_vec_1p,"1P"); + fillBDTNoCorr( trigger,online_tau_vec_mp,"MP"); } + if(info.isRNN){ fillHLTEfficiencies(ctx, trigger, offline_tau_vec_1p, online_tau_vec_1p, "1P"); @@ -309,6 +324,91 @@ const xAOD::EmTauRoI* TrigTauMonitorAlgorithm::findLVL1_ROI(const EventContext& } +void TrigTauMonitorAlgorithm::fillBDTOut(const std::string trigger, std::vector<const xAOD::TauJet*> tau_vec,const std::string nProng) const +{ + ATH_MSG_DEBUG("Fill BDT output: " << trigger); + + std::string monGroupName = trigger+"_BDT_HLT_Out_"+nProng; + + auto monGroup = getGroup(monGroupName); + + auto BDTJetScore = Monitored::Collection("BDTJetScore", tau_vec, [] (const xAOD::TauJet* tau){ + return (tau->discriminant(xAOD::TauJetParameters::TauID::BDTJetScore));}); + auto BDTJetScoreSigTrans = Monitored::Collection("BDTJetScoreSigTrans", tau_vec, [] (const xAOD::TauJet* tau){ + return (tau->discriminant(xAOD::TauJetParameters::TauID::BDTJetScoreSigTrans));}); + + fill(monGroup, BDTJetScore,BDTJetScoreSigTrans); + ATH_MSG_DEBUG("AFTER BDT output: " << trigger); +} + +void TrigTauMonitorAlgorithm::fillBDTNoCorr(const std::string trigger, std::vector<const xAOD::TauJet*> tau_vec,const std::string nProng) const +{ + ATH_MSG_DEBUG("Fill BDT non Corrected: " << trigger); + + std::string monGroupName = trigger+"_BDT_HLT_NoCorr_"+nProng; + + auto monGroup = getGroup(monGroupName); + + + auto centFrac = Monitored::Collection("centFrac", tau_vec, [] (const xAOD::TauJet* tau){ + float detail = -999; + if (tau->detail(xAOD::TauJetParameters::centFrac, detail)){ + detail = std::min(detail, 1.0f); + } return detail;}); + auto ChPiEMEOverCaloEME = Monitored::Collection("ChPiEMEOverCaloEME", tau_vec, [] (const xAOD::TauJet* tau){ + float detail = -999; + if (tau->detail(xAOD::TauJetParameters::ChPiEMEOverCaloEME, detail)){ + } return detail;}); + auto emPOverTrkSysP = Monitored::Collection("emPOverTrkSysP", tau_vec, [] (const xAOD::TauJet* tau){ + float detail = -999; + if (tau->detail(xAOD::TauJetParameters::EMPOverTrkSysP, detail)){ + detail = TMath::Log10(std::max(detail, 1e-3f)); + } return detail;}); + auto etOverPtLeadTrk = Monitored::Collection("etOverPtLeadTrk", tau_vec, [] (const xAOD::TauJet* tau){ + float detail = -999; + if (tau->detail(xAOD::TauJetParameters::etOverPtLeadTrk, detail)){ + detail = TMath::Log10(std::max(detail, 0.1f)); + } return detail;}); + auto innerTrkAvgDist = Monitored::Collection("innerTrkAvgDist", tau_vec, [] (const xAOD::TauJet* tau){ + float detail = -999; + if (tau->detail(xAOD::TauJetParameters::innerTrkAvgDist, detail)){ + } return detail;}); + auto ptRatioEflowApprox = Monitored::Collection("ptRatioEflowApprox", tau_vec, [] (const xAOD::TauJet* tau){ + float detail = -999; + if (tau->detail(xAOD::TauJetParameters::ptRatioEflowApprox, detail)){ + detail = std::min(detail, 4.0f); + } return detail;}); + if(nProng=="1P"){ + auto sumPtTrkFrac = Monitored::Collection("sumPtTrkFrac", tau_vec, [] (const xAOD::TauJet* tau){ + float detail = -999; + if (tau->detail(xAOD::TauJetParameters::SumPtTrkFrac, detail)){ + } return detail;}); + fill(monGroup, centFrac,ChPiEMEOverCaloEME,emPOverTrkSysP,etOverPtLeadTrk,innerTrkAvgDist,ptRatioEflowApprox,sumPtTrkFrac); + + } + else if(nProng=="MP"){ + auto dRmax = Monitored::Collection("dRmax", tau_vec, [] (const xAOD::TauJet* tau){ + float detail = -999; + if (tau->detail(xAOD::TauJetParameters::dRmax, detail)){ + } return detail;}); + auto massTrkSys = Monitored::Collection("massTrkSys", tau_vec, [&nProng] (const xAOD::TauJet* tau){ + float detail = -999; + if ( tau->detail(xAOD::TauJetParameters::massTrkSys, detail) && nProng.find("MP") != std::string::npos ){ + detail = TMath::Log10(std::max(detail, 140.0f)); + }return detail;}); + auto mEflowApprox = Monitored::Collection("mEflowApprox", tau_vec, [] (const xAOD::TauJet* tau){ + float detail = -999; + if (tau->detail(xAOD::TauJetParameters::mEflowApprox, detail)){ + detail = TMath::Log10(std::max(detail, 140.0f)); + }return detail;}); + auto trFlightPathSig = Monitored::Collection("trFlightPathSig", tau_vec, [] (const xAOD::TauJet* tau){ + float detail = -999; + if (tau->detail(xAOD::TauJetParameters::trFlightPathSig, detail)){ + } return detail;}); + fill(monGroup, centFrac,ChPiEMEOverCaloEME,emPOverTrkSysP,etOverPtLeadTrk,innerTrkAvgDist,ptRatioEflowApprox,dRmax,massTrkSys,mEflowApprox,trFlightPathSig); + + } +} void TrigTauMonitorAlgorithm::fillRNNInputVars(const std::string trigger, std::vector<const xAOD::TauJet*> tau_vec,const std::string nProng, bool online) const diff --git a/Trigger/TrigMonitoring/TrigTauMonitoring/src/TrigTauMonitorAlgorithm.h b/Trigger/TrigMonitoring/TrigTauMonitoring/src/TrigTauMonitorAlgorithm.h index def74a7a069..2e02461cd9d 100644 --- a/Trigger/TrigMonitoring/TrigTauMonitoring/src/TrigTauMonitorAlgorithm.h +++ b/Trigger/TrigMonitoring/TrigTauMonitoring/src/TrigTauMonitorAlgorithm.h @@ -50,6 +50,8 @@ class TrigTauMonitorAlgorithm : public AthMonitorAlgorithm { void fillRNNTrack(const std::string trigger, std::vector<const xAOD::TauJet*> tau_vec, bool online) const; void fillRNNCluster(const std::string trigger, std::vector<const xAOD::TauJet*> tau_vec, bool online) const; void fillbasicVars(const std::string trigger, std::vector<const xAOD::TauJet*> tau_vec, bool online) const; + void fillBDTNoCorr(const std::string trigger, std::vector<const xAOD::TauJet*> tau_vec,const std::string nProng) const; + void fillBDTOut(const std::string trigger, std::vector<const xAOD::TauJet*> tau_vec,const std::string nProng) const; void fillDistributions(const EventContext& ctx, std::vector< std::pair< const xAOD::TauJet*, const TrigCompositeUtils::Decision * >> pairObjs, const std::string trigger, const bool fill_l1eff, const std::string trigL1Item) const; void fillHLTEfficiencies(const EventContext& ctx,const std::string trigger, std::vector<const xAOD::TauJet*> offline_tau_vec, std::vector<const xAOD::TauJet*> online_tau_vec, std::string nProng) const; void fillL1Efficiencies(const EventContext& ctx, const std::string trigger, std::vector<const xAOD::TauJet*> offline_tau_vec,std::string nProng, const std::string trigL1Item) const; -- GitLab