ATLAS Offline Software
TauIDVarCalculator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
13 
14 #include "CaloGeoHelpers/CaloSampling.h"
16 
17 #include "TLorentzVector.h"
18 
19 #define GeV 1000
20 const float TauIDVarCalculator::LOW_NUMBER = -1111.;
21 
24  declareProperty("VertexCorrection", m_doVertexCorrection = true);
25 }
26 
27 
28 
30  static const SG::AuxElement::Accessor<float> acc_absipSigLeadTrk("absipSigLeadTrk");
31  acc_absipSigLeadTrk(tau) = (tau.nTracks()>0) ? std::abs(tau.track(0)->d0SigTJVA()) : 0.;
32 
33  if(inTrigger()) return StatusCode::SUCCESS;
34 
35  //everything below is just for EleBDT!
36  static const SG::AuxElement::Accessor<float> acc_absEtaLead("ABS_ETA_LEAD_TRACK");
37  static const SG::AuxElement::Accessor<float> acc_absDeltaEta("TAU_ABSDELTAETA");
38  static const SG::AuxElement::Accessor<float> acc_absDeltaPhi("TAU_ABSDELTAPHI");
39  static const SG::AuxElement::ConstAccessor<float> acc_sumEMCellEtOverLeadTrkPt("sumEMCellEtOverLeadTrkPt");
40  static const SG::AuxElement::ConstAccessor<float> acc_etHadAtEMScale("etHadAtEMScale");
41  static const SG::AuxElement::ConstAccessor<float> acc_etEMAtEMScale("etEMAtEMScale");
42  static const SG::AuxElement::Accessor<float> acc_EMFractionAtEMScaleMOVEE3("EMFRACTIONATEMSCALE_MOVEE3");
43  static const SG::AuxElement::Accessor<float> acc_seedTrkSecMaxStripEtOverPt("TAU_SEEDTRK_SECMAXSTRIPETOVERPT");
44  static const SG::AuxElement::ConstAccessor<float> acc_secMaxStripEt("secMaxStripEt");
45  static const SG::AuxElement::ConstAccessor<float> acc_centFrac("centFrac");
46 
47  // Will: Fixed variables for R21
48  static const SG::AuxElement::Accessor<float> acc_EMFracFixed("EMFracFixed");
49  static const SG::AuxElement::Accessor<float> acc_hadLeakFracFixed("hadLeakFracFixed");
50  static const SG::AuxElement::Accessor<float> acc_etHotShotDR1("etHotShotDR1"); // replace secMaxStripEt
51  static const SG::AuxElement::Accessor<float> acc_etHotShotWin("etHotShotWin"); // replace secMaxStripEt
52  static const SG::AuxElement::Accessor<float> acc_etHotShotDR1OverPtLeadTrk("etHotShotDR1OverPtLeadTrk"); // replace TAU_SEEDTRK_SECMAXSTRIPETOVERPT
53  static const SG::AuxElement::Accessor<float> acc_etHotShotWinOverPtLeadTrk("etHotShotWinOverPtLeadTrk"); // replace TAU_SEEDTRK_SECMAXSTRIPETOVERPT
54 
55 
56  // EMFracFixed and eHad1AtEMScaleFixed (for acc_hadLeakFracFixed)
57  // --------------------------------------------------------------
58  // ECAL Layers: 0, 1, 2. Don't include 3 because it is mismodelled!
59  std::vector<CaloSampling::CaloSample> EMSamps = {
63  // All HCAL Layers
64  std::vector<CaloSampling::CaloSample> HadSamps = {
69  // First HCal Layer
70  std::vector<CaloSampling::CaloSample> Had1Samps = {
72 
73  float eEMAtEMScaleFixed = 0.;
74  float eHadAtEMScaleFixed = 0.;
75  float eHad1AtEMScaleFixed = 0.;
76 
77  TLorentzVector tauAxis = tauRecTools::getTauAxis(tau, m_doVertexCorrection);
78 
79  std::vector<xAOD::CaloVertexedTopoCluster> vertexedClusterList = tau.vertexedClusters();
80  for (const xAOD::CaloVertexedTopoCluster& vertexedCluster : vertexedClusterList){
81  TLorentzVector clusterP4 = vertexedCluster.p4();
82 
83  if( clusterP4.DeltaR(tauAxis) > 0.2 ) continue;
84 
85  const xAOD::CaloCluster& cluster = vertexedCluster.clust();
86  for( auto samp : EMSamps )
87  eEMAtEMScaleFixed += cluster.eSample(samp);
88  for( auto samp : HadSamps )
89  eHadAtEMScaleFixed += cluster.eSample(samp);
90  for( auto samp : Had1Samps )
91  eHad1AtEMScaleFixed += cluster.eSample(samp);
92  }
93  acc_EMFracFixed(tau) = ( eEMAtEMScaleFixed + eHadAtEMScaleFixed ) != 0. ?
94  eEMAtEMScaleFixed / ( eEMAtEMScaleFixed + eHadAtEMScaleFixed ) : LOW_NUMBER;
95 
96  if(tau.nTracks() > 0){
97  const xAOD::TrackParticle* track = tau.track(0)->track();
98  acc_absEtaLead(tau) = std::abs( track->eta() );
99  acc_absDeltaEta(tau) = std::abs( track->eta() - tau.eta() );
100  acc_absDeltaPhi(tau) = std::abs( track->p4().DeltaPhi(tau.p4()) );
101  //EMFRACTIONATEMSCALE_MOVEE3:
102  float etEMScale1 = acc_etEMAtEMScale(tau);
103  float etEMScale2 = acc_etHadAtEMScale(tau);
104  float tau_sumETCellsLAr = acc_sumEMCellEtOverLeadTrkPt(tau) * track->pt();
105  float tau_E3 = tau_sumETCellsLAr - etEMScale1;
106  float tau_seedCalo_etHadAtEMScale_noE3 = etEMScale2 - tau_E3;
107  float tau_seedCalo_etEMAtEMScale_yesE3 = etEMScale1 + tau_E3;
108  acc_EMFractionAtEMScaleMOVEE3(tau) = tau_seedCalo_etEMAtEMScale_yesE3 / (tau_seedCalo_etEMAtEMScale_yesE3 + tau_seedCalo_etHadAtEMScale_noE3);
109  //TAU_SEEDTRK_SECMAXSTRIPETOVERPT:
110  acc_seedTrkSecMaxStripEtOverPt(tau) = (track->pt() != 0.) ? acc_secMaxStripEt(tau) / track->pt() : LOW_NUMBER;
111 
112  // hadLeakFracFixed
113  acc_hadLeakFracFixed(tau) = (track->p4().P() != 0.) ? eHad1AtEMScaleFixed / track->p4().P() : LOW_NUMBER;
114 
115  // HOT SHOTS!!!!!
116  // --------------
117  // Get track position extrapolated to EM1
118  const xAOD::TauTrack* tauTrack = tau.track(0);
119  float etaCalo = -10.0;
120  float phiCalo = -10.0;
121  if( not tauTrack->detail(xAOD::TauJetParameters::CaloSamplingEtaEM, etaCalo))
122  ATH_MSG_WARNING("Failed to retrieve extrapolated chargedPFO eta");
123  if( not tauTrack->detail(xAOD::TauJetParameters::CaloSamplingPhiEM, phiCalo))
124  ATH_MSG_WARNING("Failed to retrieve extrapolated chargedPFO phi");
125  ATH_MSG_DEBUG("track EM " << ", eta: " << etaCalo << ", phi: " << phiCalo );
126 
127  // Get hottest shot in dR<0.1 and in 0.05 x 0.1 window
128  float etHotShotDR1 = 0.;
129  float etHotShotWin = 0.;
130  for( const auto& shotLink : tau.shotPFOLinks() ){
131  if( not shotLink.isValid() ){
132  ATH_MSG_WARNING("Invalid shotLink");
133  continue;
134  }
135  const xAOD::PFO* shot = *shotLink;
136  float etShot = 0.;
138 
139  // In dR < 0.1
140  if(xAOD::P4Helpers::deltaR(*shot, etaCalo, phiCalo, false) and etShot > etHotShotDR1){
141  etHotShotDR1 = etShot;
142  }
143  // In 0.012 x 0.1 window
144  if(std::abs(shot->eta() - etaCalo) > 0.012 ) continue;
145  if(std::abs(xAOD::P4Helpers::deltaPhi(shot->phi(), phiCalo)) > 0.1 ) continue;
146  if(etShot > etHotShotWin) etHotShotWin = etShot;
147  }
148  acc_etHotShotDR1(tau) = etHotShotDR1;
149  acc_etHotShotWin(tau) = etHotShotWin;
150  acc_etHotShotDR1OverPtLeadTrk(tau) = (track->pt() != 0.) ? etHotShotDR1 / track->pt() : LOW_NUMBER;
151  acc_etHotShotWinOverPtLeadTrk(tau) = (track->pt() != 0.) ? etHotShotWin / track->pt() : LOW_NUMBER;
152 
153  }
154  else{
155  acc_absEtaLead(tau) = LOW_NUMBER;
156  acc_absDeltaEta(tau) = LOW_NUMBER;
157  acc_absDeltaPhi(tau) = LOW_NUMBER;
158  acc_EMFractionAtEMScaleMOVEE3(tau) = LOW_NUMBER;
159  acc_seedTrkSecMaxStripEtOverPt(tau) = LOW_NUMBER;
160  acc_hadLeakFracFixed(tau) = LOW_NUMBER;
161  acc_etHotShotDR1(tau) = LOW_NUMBER;
162  acc_etHotShotWin(tau) = LOW_NUMBER;
163  acc_etHotShotDR1OverPtLeadTrk(tau) = LOW_NUMBER;
164  acc_etHotShotWinOverPtLeadTrk(tau) = LOW_NUMBER;
165  }
166 
167  return StatusCode::SUCCESS;
168 }
TauIDVarCalculator::execute
virtual StatusCode execute(xAOD::TauJet &) const override
Execute - called for each tau candidate.
Definition: TauIDVarCalculator.cxx:29
CaloCell_ID_FCS::TileExt2
@ TileExt2
Definition: FastCaloSim_CaloCell_ID.h:39
constants.EMB1
int EMB1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:53
xAOD::TauTrack_v1::d0SigTJVA
float d0SigTJVA() const
Definition: TauTrack_v1.cxx:129
xAOD::TauJet_v3::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
xAODP4Helpers.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
xAOD::TauJetParameters::CaloSamplingPhiEM
@ CaloSamplingPhiEM
Definition: TauDefs.h:422
tauRecTools::getTauAxis
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 ...
Definition: Reconstruction/tauRecTools/Root/HelperFunctions.cxx:33
CaloCell_ID_FCS::TileExt0
@ TileExt0
Definition: FastCaloSim_CaloCell_ID.h:37
CaloCell_ID_FCS::TileBar1
@ TileBar1
Definition: FastCaloSim_CaloCell_ID.h:32
TauIDVarCalculator::m_doVertexCorrection
bool m_doVertexCorrection
Definition: TauIDVarCalculator.h:34
xAOD::PFO_v1::attribute
bool attribute(PFODetails::PFOAttributes AttributeType, T &anAttribute) const
get a PFO Variable via enum
xAOD::PFO_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: PFO_v1.cxx:60
xAOD::TauJet_v3::nTracks
size_t nTracks(TauJetParameters::TauTrackFlag flag=TauJetParameters::TauTrackFlag::classifiedCharged) const
Definition: TauJet_v3.cxx:526
TauRecToolBase
The base class for all tau tools.
Definition: TauRecToolBase.h:21
xAOD::P4Helpers::deltaPhi
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition: xAODP4Helpers.h:69
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
xAOD::PFODetails::tauShots_pt3
@ tauShots_pt3
Definition: Event/xAOD/xAODPFlow/xAODPFlow/PFODefs.h:145
CaloCell_ID_FCS::HEC2
@ HEC2
Definition: FastCaloSim_CaloCell_ID.h:29
TauRecToolBase::inTrigger
bool inTrigger() const
Definition: TauRecToolBase.h:87
TauIDVarCalculator::TauIDVarCalculator
TauIDVarCalculator(const std::string &name="TauIDVarCalculator")
Definition: TauIDVarCalculator.cxx:22
CaloCell_ID_FCS::TileGap3
@ TileGap3
Definition: FastCaloSim_CaloCell_ID.h:36
xAOD::TauTrack_v1::detail
bool detail(TauJetParameters::TrackDetail detail, float &value) const
Definition: TauTrack_v1.cxx:166
TauIDVarCalculator.h
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
CaloCell_ID_FCS::HEC1
@ HEC1
Definition: FastCaloSim_CaloCell_ID.h:28
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
xAOD::P4Helpers::deltaR
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Definition: xAODP4Helpers.h:150
CaloCell_ID_FCS::TileBar0
@ TileBar0
Definition: FastCaloSim_CaloCell_ID.h:31
xAOD::TauJet_v3::shotPFOLinks
const PFOLinks_t & shotPFOLinks() const
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CaloCell_ID_FCS::TileGap2
@ TileGap2
Definition: FastCaloSim_CaloCell_ID.h:35
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
xAOD::TauJet_v3::track
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...
Definition: TauJet_v3.cxx:450
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
xAOD::PFO_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: PFO_v1.cxx:67
CaloCell_ID_FCS::TileGap1
@ TileGap1
Definition: FastCaloSim_CaloCell_ID.h:34
xAOD::PFO_v1
Class describing a particle flow object.
Definition: PFO_v1.h:35
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CaloCell_ID_FCS::TileExt1
@ TileExt1
Definition: FastCaloSim_CaloCell_ID.h:38
xAOD::TauJet_v3::vertexedClusters
std::vector< xAOD::CaloVertexedTopoCluster > vertexedClusters() const
Definition: TauJet_v3.cxx:626
TauIDVarCalculator::LOW_NUMBER
static const float LOW_NUMBER
Definition: TauIDVarCalculator.h:30
CaloCell_ID_FCS::HEC0
@ HEC0
Definition: FastCaloSim_CaloCell_ID.h:27
xAOD::CaloCluster_v1::eSample
float eSample(const CaloSample sampling) const
Definition: CaloCluster_v1.cxx:521
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CaloCell_ID_FCS::PreSamplerE
@ PreSamplerE
Definition: FastCaloSim_CaloCell_ID.h:23
xAOD::TauTrack_v1
Definition: TauTrack_v1.h:27
CaloCell_ID_FCS::PreSamplerB
@ PreSamplerB
Definition: FastCaloSim_CaloCell_ID.h:19
xAOD::TauJet_v3::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: TauJet_v3.cxx:97
HelperFunctions.h
xAOD::TauTrack_v1::track
const TrackParticle * track() const
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
xAOD::CaloVertexedTopoCluster
Evaluate cluster kinematics with a different vertex / signal state.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloVertexedTopoCluster.h:38
xAOD::TauJetParameters::CaloSamplingEtaEM
@ CaloSamplingEtaEM
Definition: TauDefs.h:420
CaloCell_ID_FCS::HEC3
@ HEC3
Definition: FastCaloSim_CaloCell_ID.h:30
CaloCell_ID_FCS::TileBar2
@ TileBar2
Definition: FastCaloSim_CaloCell_ID.h:33
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56