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::ConstAccessor<float> acc_centFrac("centFrac");
36
37 // Will: Fixed variables for R21
38 static const SG::Accessor<float> acc_EMFracFixed("EMFracFixed");
39 static const SG::Accessor<float> acc_hadLeakFracFixed("hadLeakFracFixed");
40 static const SG::Accessor<float> acc_etHotShotWin("etHotShotWin");
41 static const SG::Accessor<float> acc_etHotShotWinOverPtLeadTrk("etHotShotWinOverPtLeadTrk");
42
43
44 // EMFracFixed and eHad1AtEMScaleFixed (for acc_hadLeakFracFixed)
45 // --------------------------------------------------------------
46 // ECAL Layers: 0, 1, 2. Don't include 3 because it is mismodelled!
47 std::vector<CaloSampling::CaloSample> EMSamps = {
48 CaloSampling::PreSamplerB, CaloSampling::PreSamplerE,
49 CaloSampling::EMB1, CaloSampling::EME1,
50 CaloSampling::EMB2, CaloSampling::EME2 };
51 // All HCAL Layers
52 std::vector<CaloSampling::CaloSample> HadSamps = {
53 CaloSampling::HEC0, CaloSampling::HEC1, CaloSampling::HEC2, CaloSampling::HEC3,
54 CaloSampling::TileBar0, CaloSampling::TileBar1, CaloSampling::TileBar2,
55 CaloSampling::TileGap1, CaloSampling::TileGap2, CaloSampling::TileGap3,
56 CaloSampling::TileExt0, CaloSampling::TileExt1, CaloSampling::TileExt2};
57 // First HCal Layer
58 std::vector<CaloSampling::CaloSample> Had1Samps = {
59 CaloSampling::HEC0, CaloSampling::TileBar0, CaloSampling::TileGap1, CaloSampling::TileExt0};
60
61 float eEMAtEMScaleFixed = 0.;
62 float eHadAtEMScaleFixed = 0.;
63 float eHad1AtEMScaleFixed = 0.;
64
65 TLorentzVector tauAxis = tauRecTools::getTauAxis(tau, m_doVertexCorrection);
66
67 std::vector<xAOD::CaloVertexedTopoCluster> vertexedClusterList = tau.vertexedClusters();
68 for (const xAOD::CaloVertexedTopoCluster& vertexedCluster : vertexedClusterList){
69 TLorentzVector clusterP4 = vertexedCluster.p4();
70
71 if( clusterP4.DeltaR(tauAxis) > 0.2 ) continue;
72
73 const xAOD::CaloCluster& cluster = vertexedCluster.clust();
74 for( auto samp : EMSamps )
75 eEMAtEMScaleFixed += cluster.eSample(samp);
76 for( auto samp : HadSamps )
77 eHadAtEMScaleFixed += cluster.eSample(samp);
78 for( auto samp : Had1Samps )
79 eHad1AtEMScaleFixed += cluster.eSample(samp);
80 }
81 acc_EMFracFixed(tau) = ( eEMAtEMScaleFixed + eHadAtEMScaleFixed ) != 0. ?
82 eEMAtEMScaleFixed / ( eEMAtEMScaleFixed + eHadAtEMScaleFixed ) : LOW_NUMBER;
83
84 if(tau.nTracks() > 0){
85 const xAOD::TrackParticle* track = tau.track(0)->track();
86 acc_absEtaLead(tau) = std::abs( track->eta() );
87
88 // hadLeakFracFixed
89 acc_hadLeakFracFixed(tau) = (track->p4().P() != 0.) ? eHad1AtEMScaleFixed / track->p4().P() : LOW_NUMBER;
90
91 // HOT SHOTS!!!!!
92 // --------------
93 // Get track position extrapolated to EM1
94 const xAOD::TauTrack* tauTrack = tau.track(0);
95 float etaCalo = -10.0;
96 float phiCalo = -10.0;
97 if( not tauTrack->detail(xAOD::TauJetParameters::CaloSamplingEtaEM, etaCalo))
98 ATH_MSG_WARNING("Failed to retrieve extrapolated chargedPFO eta");
99 if( not tauTrack->detail(xAOD::TauJetParameters::CaloSamplingPhiEM, phiCalo))
100 ATH_MSG_WARNING("Failed to retrieve extrapolated chargedPFO phi");
101 ATH_MSG_DEBUG("track EM " << ", eta: " << etaCalo << ", phi: " << phiCalo );
102
103 // Get hottest shot in dR<0.1 and in 0.05 x 0.1 window
104 float etHotShotWin = 0.;
105 for( const auto& shotLink : tau.shotPFOLinks() ){
106 if( not shotLink.isValid() ){
107 ATH_MSG_WARNING("Invalid shotLink");
108 continue;
109 }
110 const xAOD::PFO* shot = *shotLink;
111 float etShot = 0.;
113
114 // In 0.012 x 0.1 window
115 if(std::abs(shot->eta() - etaCalo) > 0.012 ) continue;
116 if(std::abs(xAOD::P4Helpers::deltaPhi(shot->phi(), phiCalo)) > 0.1 ) continue;
117 if(etShot > etHotShotWin) etHotShotWin = etShot;
118 }
119 acc_etHotShotWin(tau) = etHotShotWin;
120 acc_etHotShotWinOverPtLeadTrk(tau) = (track->pt() != 0.) ? etHotShotWin / track->pt() : LOW_NUMBER;
121
122 }
123 else{
124 acc_absEtaLead(tau) = LOW_NUMBER;
125 acc_hadLeakFracFixed(tau) = LOW_NUMBER;
126 acc_etHotShotWin(tau) = LOW_NUMBER;
127 acc_etHotShotWinOverPtLeadTrk(tau) = LOW_NUMBER;
128 }
129
130 return StatusCode::SUCCESS;
131}
#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.
Helper class to provide constant 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".