diff --git a/Reconstruction/tauRec/python/tauRecFlags.py b/Reconstruction/tauRec/python/tauRecFlags.py index a0cf47e37dbc5c336d5add60cccd90208e475712..30554f51414906deacf7b4e34ead6892214a52e9 100644 --- a/Reconstruction/tauRec/python/tauRecFlags.py +++ b/Reconstruction/tauRec/python/tauRecFlags.py @@ -109,14 +109,14 @@ class tauRecCalibrateLCConfig(JobProperty): """ statusOn=True allowedTypes=['string'] - StoredValue='TES_MC16a_prelim.root' + StoredValue='CaloTES_R22_v1.root' class tauRecMvaTESConfig(JobProperty): """Config file for MvaTESEvaluator """ statusOn=True allowedTypes=['string'] - StoredValue='MvaTES_20170207_v2_BDTG.weights.root' + StoredValue='MVATES_r22_mar1.weights.root' class tauRecCombinedTESConfig(JobProperty): """Config file for TauCombinedTES diff --git a/Reconstruction/tauRecTools/CMakeLists.txt b/Reconstruction/tauRecTools/CMakeLists.txt index ee5cc87be660073aa597d89edaa3b7f3de26eddf..f5d1137ee7828b20c852e85f4ea2649036b15010 100644 --- a/Reconstruction/tauRecTools/CMakeLists.txt +++ b/Reconstruction/tauRecTools/CMakeLists.txt @@ -32,7 +32,7 @@ atlas_add_library( tauRecToolsLib LINK_LIBRARIES ${Boost_LIBRARIES} ${EIGEN_LIBRARIES} ${LWTNN_LIBRARIES} ${ROOT_LIBRARIES} CxxUtils AthLinks AsgMessagingLib AsgDataHandlesLib AsgTools xAODCaloEvent - xAODEventInfo xAODJet xAODParticleEvent xAODPFlow xAODTau xAODTracking + xAODEventInfo xAODJet xAODParticleEvent xAODPFlow xAODTau xAODTracking xAODEventShape MVAUtils ${extra_public_libs} PRIVATE_LINK_LIBRARIES CaloGeoHelpers FourMomUtils PathResolver ) diff --git a/Reconstruction/tauRecTools/Root/MvaTESEvaluator.cxx b/Reconstruction/tauRecTools/Root/MvaTESEvaluator.cxx index f7517575ff60bd02fc4829d05d07f1dac4d72aeb..e76ae092d9992fe7d3c452e641ba6f578d052883 100644 --- a/Reconstruction/tauRecTools/Root/MvaTESEvaluator.cxx +++ b/Reconstruction/tauRecTools/Root/MvaTESEvaluator.cxx @@ -7,7 +7,6 @@ #include "tauRecTools/HelperFunctions.h" #include <TTree.h> - #include <vector> //_____________________________________________________________________________ @@ -39,18 +38,17 @@ StatusCode MvaTESEvaluator::execute(xAOD::TauJet& xTau) const { if(!inTrigger()) { availableVars.insert( std::make_pair("TauJetsAuxDyn.mu", &vars.mu) ); availableVars.insert( std::make_pair("TauJetsAuxDyn.nVtxPU", &vars.nVtxPU) ); - + availableVars.insert( std::make_pair("TauJetsAuxDyn.rho", &vars.rho) ); availableVars.insert( std::make_pair("TauJetsAuxDyn.ClustersMeanCenterLambda", &vars.center_lambda) ); availableVars.insert( std::make_pair("TauJetsAuxDyn.ClustersMeanFirstEngDens", &vars.first_eng_dens) ); availableVars.insert( std::make_pair("TauJetsAuxDyn.ClustersMeanSecondLambda", &vars.second_lambda) ); availableVars.insert( std::make_pair("TauJetsAuxDyn.ClustersMeanPresamplerFrac", &vars.presampler_frac) ); - availableVars.insert( std::make_pair("TauJetsAuxDyn.ClustersMeanEMProbability", &vars.eprobability) ); - + availableVars.insert( std::make_pair("TauJetsAuxDyn.ClustersMeanEMProbability", &vars.eprobability) ); + availableVars.insert( std::make_pair("TauJetsAuxDyn.ptTauAxisEM/TauJetsAuxDyn.ptDetectorAxis", &vars.ptEM_D_ptLC) ); availableVars.insert( std::make_pair("TauJetsAuxDyn.pt_combined", &vars.ptCombined) ); availableVars.insert( std::make_pair("TauJetsAuxDyn.ptDetectorAxis/TauJetsAuxDyn.pt_combined", &vars.ptLC_D_ptCombined) ); availableVars.insert( std::make_pair("TauJetsAuxDyn.ptPanTauCellBased/TauJetsAuxDyn.pt_combined", &vars.ptConstituent_D_ptCombined) ); - availableVars.insert( std::make_pair("TauJetsAuxDyn.etaPanTauCellBased", &vars.etaConstituent) ); - + availableVars.insert( std::make_pair("TauJetsAuxDyn.etaPanTauCellBased", &vars.etaConstituent) ); availableVars.insert( std::make_pair("TauJetsAuxDyn.PanTau_BDTValue_1p0n_vs_1p1n", &vars.PanTauBDT_1p0n_vs_1p1n) ); availableVars.insert( std::make_pair("TauJetsAuxDyn.PanTau_BDTValue_1p1n_vs_1pXn", &vars.PanTauBDT_1p1n_vs_1pXn) ); availableVars.insert( std::make_pair("TauJetsAuxDyn.PanTau_BDTValue_3p0n_vs_3pXn", &vars.PanTauBDT_3p0n_vs_3pXn) ); @@ -70,11 +68,9 @@ StatusCode MvaTESEvaluator::execute(xAOD::TauJet& xTau) const { availableVars.insert( std::make_pair("TrigTauJetsAuxDyn.etaDetectorAxis", &vars.etaDetectorAxis) ); } - // Retrieve event info + // Retrieve average pileup static const SG::AuxElement::ConstAccessor<float> acc_mu("mu"); - static const SG::AuxElement::ConstAccessor<int> acc_nVtxPU("nVtxPU"); vars.mu = acc_mu(xTau); - vars.nVtxPU = acc_nVtxPU(xTau); // Retrieve cluster moments xTau.detail(xAOD::TauJetParameters::ClustersMeanCenterLambda, vars.center_lambda); @@ -84,6 +80,15 @@ StatusCode MvaTESEvaluator::execute(xAOD::TauJet& xTau) const { xTau.detail(xAOD::TauJetParameters::ClustersMeanPresamplerFrac, vars.presampler_frac); if(!inTrigger()) { + static const SG::AuxElement::ConstAccessor<int> acc_nVtxPU("nVtxPU"); + vars.nVtxPU = acc_nVtxPU(xTau); + + static const SG::AuxElement::ConstAccessor<float> acc_rho("rho"); + vars.rho = acc_rho(xTau); + + static const SG::AuxElement::ConstAccessor<float> acc_ptIntermediateAxisEM("ptIntermediateAxisEM"); + float ptIntermediateAxisEM = acc_ptIntermediateAxisEM(xTau); + vars.ptEM_D_ptLC = (xTau.ptIntermediateAxis()!=0.) ? ptIntermediateAxisEM/xTau.ptIntermediateAxis() : 0.; // Retrieve pantau and LC-precalib TES vars.etaConstituent = xTau.etaPanTauCellBased(); diff --git a/Reconstruction/tauRecTools/Root/MvaTESVariableDecorator.cxx b/Reconstruction/tauRecTools/Root/MvaTESVariableDecorator.cxx index 332e1895d9e8b1b04de6fe185d24ea28f207d0b6..257016938e842af189d05a6553ee6e167a3b96e9 100644 --- a/Reconstruction/tauRecTools/Root/MvaTESVariableDecorator.cxx +++ b/Reconstruction/tauRecTools/Root/MvaTESVariableDecorator.cxx @@ -24,6 +24,7 @@ StatusCode MvaTESVariableDecorator::initialize() { ATH_CHECK(m_aveIntPerXKey.initialize()); ATH_CHECK(m_vertexContainerKey.initialize(SG::AllowEmpty)); + ATH_CHECK(m_eventShapeKey.initialize(SG::AllowEmpty)); return StatusCode::SUCCESS; } @@ -31,19 +32,21 @@ StatusCode MvaTESVariableDecorator::initialize() { StatusCode MvaTESVariableDecorator::execute(xAOD::TauJet& xTau) const { - - // need to check mu can be retrieved via EventInfo for Run3 trigger + int mu = 0; SG::ReadDecorHandle<xAOD::EventInfo, float> eventInfoDecorHandle( m_aveIntPerXKey ); if (!eventInfoDecorHandle.isPresent()) { ATH_MSG_WARNING ( "EventInfo decoration not available! Will set mu=0." ); } else { - mu = eventInfoDecorHandle(0); - } + // convert from float to int to ignore peculiar values used in MC + mu = (int)eventInfoDecorHandle(0); + } + static const SG::AuxElement::Accessor<float> acc_mu("mu"); + acc_mu(xTau) = mu; - int nVtxPU = 0; if(!m_vertexContainerKey.empty()) { + int nVtxPU = 0; SG::ReadHandle<xAOD::VertexContainer> vertexInHandle( m_vertexContainerKey ); if (!vertexInHandle.isValid()) { ATH_MSG_WARNING ("Could not retrieve HiveDataObj with key " << vertexInHandle.key() << ", will set nVtxPU=0."); @@ -55,13 +58,22 @@ StatusCode MvaTESVariableDecorator::execute(xAOD::TauJet& xTau) const { ++nVtxPU; } } + static const SG::AuxElement::Accessor<int> acc_nVtxPU("nVtxPU"); + acc_nVtxPU(xTau) = nVtxPU; + } + + if(!m_eventShapeKey.empty()) { + double rho = 0.; + SG::ReadHandle<xAOD::EventShape> eventShape(m_eventShapeKey); + if(!eventShape.isValid()) { + ATH_MSG_WARNING ("Could not retrieve EventShape with key " << m_eventShapeKey ); + } + else if (!eventShape->getDensity(xAOD::EventShape::Density, rho)) { + ATH_MSG_WARNING ("Could not retrieve rho."); + } + static const SG::AuxElement::Accessor<float> acc_rho("rho"); + acc_rho(xTau) = (float)rho; } - - static const SG::AuxElement::Accessor<float> acc_mu("mu"); - static const SG::AuxElement::Accessor<int> acc_nVtxPU("nVtxPU"); - - acc_mu(xTau) = mu; - acc_nVtxPU(xTau) = nVtxPU; double center_lambda=0. , first_eng_dens=0. , em_probability=0. , second_lambda=0. ; double mean_center_lambda=0. , mean_first_eng_dens=0. , mean_em_probability=0. , mean_second_lambda=0. ; @@ -73,11 +85,15 @@ StatusCode MvaTESVariableDecorator::execute(xAOD::TauJet& xTau) const { clusters_EM_P4.SetPtEtaPhiM(0,0,0,0); TLorentzVector clusters_had_P4; clusters_had_P4.SetPtEtaPhiM(0,0,0,0); + TLorentzVector tauIntermediateAxisEM; + tauIntermediateAxisEM.SetPtEtaPhiM(0,0,0,0); TLorentzVector tauAxis = tauRecTools::getTauAxis(xTau, m_doVertexCorrection); + const xAOD::Vertex* vertex = tauRecTools::getTauVertex(xTau, inTrigger()); + // Loop through clusters and jet constituents std::vector<xAOD::CaloVertexedTopoCluster> vertexedClusterList = xTau.vertexedClusters(); - for (const xAOD::CaloVertexedTopoCluster& vertexedCluster : vertexedClusterList){ + for (const xAOD::CaloVertexedTopoCluster& vertexedCluster : vertexedClusterList) { TLorentzVector clusterP4 = vertexedCluster.p4(); if (clusterP4.DeltaR(tauAxis) > 0.2) continue; @@ -100,7 +116,7 @@ StatusCode MvaTESVariableDecorator::execute(xAOD::TauJet& xTau) const { mean_em_probability += clE*em_probability; // FIXME: should we use calE for EMTopo clusters ? - // what's the energy scale when calculating thee cluster momentum + // what's the energy scale when calculating the cluster momentum if(em_probability>0.5) clusters_EM_P4 += cluster.p4(xAOD::CaloCluster::State::CALIBRATED); else clusters_had_P4 += cluster.p4(xAOD::CaloCluster::State::CALIBRATED); } @@ -111,6 +127,15 @@ StatusCode MvaTESVariableDecorator::execute(xAOD::TauJet& xTau) const { else ATH_MSG_WARNING("Failed to retrieve moment: SECOND_LAMBDA"); mean_presampler_frac += (cluster.eSample(CaloSampling::PreSamplerB) + cluster.eSample(CaloSampling::PreSamplerE)); + + // EM-scale equivalent of IntermediateAxis p4 + if(vertex) { + xAOD::CaloVertexedTopoCluster vertexedClusterEM(cluster, xAOD::CaloCluster::State::UNCALIBRATED, vertex->position()); + tauIntermediateAxisEM += vertexedClusterEM.p4(); + } + else { + tauIntermediateAxisEM += cluster.p4(xAOD::CaloCluster::State::UNCALIBRATED); + } } // calculate mean values @@ -139,6 +164,9 @@ StatusCode MvaTESVariableDecorator::execute(xAOD::TauJet& xTau) const { static const SG::AuxElement::Accessor<float> acc_ClusterTotalEnergy("ClusterTotalEnergy"); acc_ClusterTotalEnergy(xTau) = (float) Etot; + static const SG::AuxElement::Accessor<float> acc_ptIntermediateAxisEM("ptIntermediateAxisEM"); + acc_ptIntermediateAxisEM(xTau) = (float) tauIntermediateAxisEM.Pt(); + // online-specific, not defined in TauDefs enum static const SG::AuxElement::Accessor<float> acc_LeadClusterFrac("LeadClusterFrac"); static const SG::AuxElement::Accessor<float> acc_UpsilonCluster("UpsilonCluster"); diff --git a/Reconstruction/tauRecTools/tauRecTools/MvaTESEvaluator.h b/Reconstruction/tauRecTools/tauRecTools/MvaTESEvaluator.h index c1f438416a1b9cbc473c5ae931d041c33a96849d..ce7b42dc011226c9ac4e607174ff393c715cec0b 100644 --- a/Reconstruction/tauRecTools/tauRecTools/MvaTESEvaluator.h +++ b/Reconstruction/tauRecTools/tauRecTools/MvaTESEvaluator.h @@ -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 */ #ifndef TAURECTOOLSDEV_MVATESEVALUATOR_H @@ -7,7 +7,6 @@ // tauRecTools include(s) #include "tauRecTools/TauRecToolBase.h" - #include "tauRecTools/BDTHelper.h" #include <map> @@ -30,6 +29,7 @@ class MvaTESEvaluator { float mu{0.0}; //! float nVtxPU{0.0}; //! + float rho{0.0}; //! float center_lambda{0.0}; //! float first_eng_dens{0.0}; //! @@ -37,6 +37,7 @@ class MvaTESEvaluator float presampler_frac{0.0}; //! float eprobability{0.0}; //! + float ptEM_D_ptLC{0.0}; //! float ptCombined{0.0}; //! float ptLC_D_ptCombined{0.0}; //! float ptConstituent_D_ptCombined{0.0};//! @@ -48,15 +49,8 @@ class MvaTESEvaluator float nTracks{0.0}; //! float PFOEngRelDiff{0.0}; //! - // Spectators - float truthPtVis{0.0}; //! - float pt{0.0}; //! - float ptPanTauCellBased{0.0}; //! - float ptDetectorAxis{0.0}; //! - float truthDecayMode{0.0}; //! - float PanTau_DecayMode{0.0}; //! - // for online calibration + float ptDetectorAxis{0.0}; //! float etaDetectorAxis{0.0}; //! float upsilon_cluster{0.0}; //! float lead_cluster_frac{0.0}; //! diff --git a/Reconstruction/tauRecTools/tauRecTools/MvaTESVariableDecorator.h b/Reconstruction/tauRecTools/tauRecTools/MvaTESVariableDecorator.h index 684f6dc6b7e1f212ad4468da7f24e2ac0992fde1..fc51096c2a93d71fcfe76c154da0d682e0d6a4c6 100644 --- a/Reconstruction/tauRecTools/tauRecTools/MvaTESVariableDecorator.h +++ b/Reconstruction/tauRecTools/tauRecTools/MvaTESVariableDecorator.h @@ -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 */ #ifndef TAURECTOOLS_MVATESVARIABLEDECORATOR_H @@ -8,10 +8,10 @@ #include "tauRecTools/TauRecToolBase.h" #include "xAODEventInfo/EventInfo.h" +#include "xAODEventShape/EventShape.h" #include "AsgDataHandles/ReadHandleKey.h" #include "AsgDataHandles/ReadDecorHandleKey.h" - class MvaTESVariableDecorator : public TauRecToolBase { public: @@ -39,6 +39,12 @@ private: "Key_vertexInputContainer", "PrimaryVertices", "input vertex container key"}; + + SG::ReadHandleKey<xAOD::EventShape> m_eventShapeKey {this, + "EventShapeKey", + "Kt4LCTopoOriginEventShape", + "EventShape key"}; + }; #endif // TAURECTOOLS_MVATESVARIABLEDECORATOR_H diff --git a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py index c38bcd1d131e780032c8a53cbb4b599362682869..43d361ed1dfe2cd115266b6b8f43428a848f8c6a 100644 --- a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py +++ b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py @@ -122,6 +122,7 @@ def getMvaTESVariableDecorator(): VertexCorrection = doVertexCorrection) MvaTESVariableDecorator.Key_vertexInputContainer = "" + MvaTESVariableDecorator.EventShapeKey = "" ToolSvc += MvaTESVariableDecorator cached_instances[_name] = MvaTESVariableDecorator diff --git a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfigMT.py b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfigMT.py index 492ed8c881e6c639d11324d28f258ad22755cb4a..8128eb194101cc77cc30ae0bc27d84b5475b1124 100644 --- a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfigMT.py +++ b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfigMT.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration from TrigTauRec.TrigTauRecConf import TrigTauRecMergedMT from TrigTauRec.TrigTauRecMonitoring import tauMonitoringCaloOnly, tauMonitoringCaloOnlyMVA, tauMonitoringPreselection, tauMonitoringPrecision, tauMonitoringPrecisionMVA @@ -309,7 +309,8 @@ def TrigTauRecMergedMTOnlyMVACfg(flags): VertexCorrection = False)) # Compute MVA TES (ATR-17649), stores MVA TES as default tau pt() tools.append(CompFactory.MvaTESVariableDecorator(Key_vertexInputContainer='', - VertexCorrection = False)) + EventShapeKey='', + VertexCorrection = False)) tools.append(CompFactory.MvaTESEvaluator(WeightFileName = 'OnlineMvaTES_BRT_v1.weights.root')) #TODO use tauFlags.tauRecMvaTESConfig() once available for tool in tools: