ATLAS Offline Software
Loading...
Searching...
No Matches
TauIDVarCalculator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
10
13
14#include "CaloGeoHelpers/CaloSampling.h"
16
17#include "TLorentzVector.h"
18
19const float TauIDVarCalculator::LOW_NUMBER = -1111.;
20
22 TauRecToolBase(name) {
23}
24
25
26
28 static const SG::Accessor<float> acc_absipSigLeadTrk("absipSigLeadTrk");
29 acc_absipSigLeadTrk(tau) = (tau.nTracks()>0) ? std::abs(tau.track(0)->d0SigTJVA()) : 0.;
30
31 if(inTrigger()) return StatusCode::SUCCESS;
32
33 //everything below is just for EleBDT!
34 static const SG::Accessor<float> acc_absEtaLead("ABS_ETA_LEAD_TRACK");
35 static const SG::Accessor<float> acc_EMFracFixed("EMFracFixed");
36 static const SG::Accessor<float> acc_hadLeakFracFixed("hadLeakFracFixed");
37 static const SG::Accessor<float> acc_etHotShotWin("etHotShotWin");
38 static const SG::Accessor<float> acc_etHotShotWinOverPtLeadTrk("etHotShotWinOverPtLeadTrk");
39
40
41 // EMFracFixed and eHad1AtEMScaleFixed (for acc_hadLeakFracFixed)
42 // --------------------------------------------------------------
43 // ECAL Layers: 0, 1, 2. Don't include 3 because it is mismodelled!
44 std::vector<CaloSampling::CaloSample> EMSamps = {
45 CaloSampling::PreSamplerB, CaloSampling::PreSamplerE,
46 CaloSampling::EMB1, CaloSampling::EME1,
47 CaloSampling::EMB2, CaloSampling::EME2 };
48 // All HCAL Layers
49 std::vector<CaloSampling::CaloSample> HadSamps = {
50 CaloSampling::HEC0, CaloSampling::HEC1, CaloSampling::HEC2, CaloSampling::HEC3,
51 CaloSampling::TileBar0, CaloSampling::TileBar1, CaloSampling::TileBar2,
52 CaloSampling::TileGap1, CaloSampling::TileGap2, CaloSampling::TileGap3,
53 CaloSampling::TileExt0, CaloSampling::TileExt1, CaloSampling::TileExt2};
54 // First HCal Layer
55 std::vector<CaloSampling::CaloSample> Had1Samps = {
56 CaloSampling::HEC0, CaloSampling::TileBar0, CaloSampling::TileGap1, CaloSampling::TileExt0};
57
58 float eEMAtEMScaleFixed = 0.;
59 float eHadAtEMScaleFixed = 0.;
60 float eHad1AtEMScaleFixed = 0.;
61
62 TLorentzVector tauAxis = tauRecTools::getTauAxis(tau, m_doVertexCorrection);
63
64 std::vector<xAOD::CaloVertexedTopoCluster> vertexedClusterList = tau.vertexedClusters();
65 for (const xAOD::CaloVertexedTopoCluster& vertexedCluster : vertexedClusterList){
66 TLorentzVector clusterP4 = vertexedCluster.p4();
67
68 if( clusterP4.DeltaR(tauAxis) > 0.2 ) continue;
69
70 const xAOD::CaloCluster& cluster = vertexedCluster.clust();
71 for( auto samp : EMSamps )
72 eEMAtEMScaleFixed += cluster.eSample(samp);
73 for( auto samp : HadSamps )
74 eHadAtEMScaleFixed += cluster.eSample(samp);
75 for( auto samp : Had1Samps )
76 eHad1AtEMScaleFixed += cluster.eSample(samp);
77 }
78 acc_EMFracFixed(tau) = ( eEMAtEMScaleFixed + eHadAtEMScaleFixed ) != 0. ?
79 eEMAtEMScaleFixed / ( eEMAtEMScaleFixed + eHadAtEMScaleFixed ) : LOW_NUMBER;
80
81 if(tau.nTracks() > 0){
82 const xAOD::TrackParticle* track = tau.track(0)->track();
83 acc_absEtaLead(tau) = std::abs( track->eta() );
84
85 // hadLeakFracFixed
86 acc_hadLeakFracFixed(tau) = (track->p4().P() != 0.) ? eHad1AtEMScaleFixed / track->p4().P() : LOW_NUMBER;
87
88 // HOT SHOTS!!!!!
89 // --------------
90 // Get track position extrapolated to EM1
91 const xAOD::TauTrack* tauTrack = tau.track(0);
92 float etaCalo = -10.0;
93 float phiCalo = -10.0;
94 if( not tauTrack->detail(xAOD::TauJetParameters::CaloSamplingEtaEM, etaCalo))
95 ATH_MSG_WARNING("Failed to retrieve extrapolated chargedPFO eta");
96 if( not tauTrack->detail(xAOD::TauJetParameters::CaloSamplingPhiEM, phiCalo))
97 ATH_MSG_WARNING("Failed to retrieve extrapolated chargedPFO phi");
98 ATH_MSG_DEBUG("track EM " << ", eta: " << etaCalo << ", phi: " << phiCalo );
99
100 // Get hottest shot in dR<0.1 and in 0.05 x 0.1 window
101 float etHotShotWin = 0.;
102 for( const auto& shotLink : tau.shotPFOLinks() ){
103 if( not shotLink.isValid() ){
104 ATH_MSG_WARNING("Invalid shotLink");
105 continue;
106 }
107 const xAOD::PFO* shot = *shotLink;
108 float etShot = 0.;
110
111 // In 0.012 x 0.1 window
112 if(std::abs(shot->eta() - etaCalo) > 0.012 ) continue;
113 if(std::abs(xAOD::P4Helpers::deltaPhi(shot->phi(), phiCalo)) > 0.1 ) continue;
114 if(etShot > etHotShotWin) etHotShotWin = etShot;
115 }
116 acc_etHotShotWin(tau) = etHotShotWin;
117 acc_etHotShotWinOverPtLeadTrk(tau) = (track->pt() != 0.) ? etHotShotWin / track->pt() : LOW_NUMBER;
118
119 }
120 else{
121 acc_absEtaLead(tau) = LOW_NUMBER;
122 acc_hadLeakFracFixed(tau) = LOW_NUMBER;
123 acc_etHotShotWin(tau) = LOW_NUMBER;
124 acc_etHotShotWinOverPtLeadTrk(tau) = LOW_NUMBER;
125 }
126
127 return StatusCode::SUCCESS;
128}
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t P(Double_t *tt, Double_t *par)
Helper class to provide type-safe access to aux data.
static const float LOW_NUMBER
Tau ID input variable calculator tool.
TauIDVarCalculator(const std::string &name="TauIDVarCalculator")
virtual StatusCode execute(xAOD::TauJet &) const override
Execute - called for each tau candidate.
Gaudi::Property< bool > m_doVertexCorrection
TauRecToolBase(const std::string &name)
bool inTrigger() const
float eSample(const CaloSample sampling) const
Evaluate cluster kinematics with a different vertex / signal state.
bool attribute(PFODetails::PFOAttributes AttributeType, T &anAttribute) const
get a PFO Variable via enum
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition PFO_v1.cxx:60
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition PFO_v1.cxx:67
std::vector< xAOD::CaloVertexedTopoCluster > vertexedClusters() const
const PFOLinks_t & shotPFOLinks() const
const TauTrack * track(size_t i, TauJetParameters::TauTrackFlag flag=TauJetParameters::TauTrackFlag::classifiedCharged, int *container_index=0) const
Get the pointer to a given tauTrack associated with this tau /*container index needed by trackNonCons...
size_t nTracks(TauJetParameters::TauTrackFlag flag=TauJetParameters::TauTrackFlag::classifiedCharged) const
bool detail(TauJetParameters::TrackDetail detail, float &value) const
float d0SigTJVA() const
const TrackParticle * track() const
TLorentzVector getTauAxis(const xAOD::TauJet &tau, bool doVertexCorrection=true)
Return the four momentum of the tau axis The tau axis is widely used to select clusters and cells in ...
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
PFO_v1 PFO
Definition of the current "pfo version".
Definition PFO.h:17
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TauTrack_v1 TauTrack
Definition of the current version.
Definition TauTrack.h:16
TauJet_v3 TauJet
Definition of the current "tau version".