ATLAS Offline Software
Loading...
Searching...
No Matches
TauTrack_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// EDM include(s):
7
8// Local include(s):
10#define TAUTRACK_V1_ACCESSORS
11#include "TauJetAccessors_v3.h"
12
14#include "xAODTau/TauJet.h"
15
17
18#include <cmath>
19
20namespace xAOD {
21
25
29
30 // Pion mass, as assumed for the track:
31 static const double PION_MASS = ParticleConstants::chargedPionMassInMeV;
32
35 p4.SetPtEtaPhiM( pt(), eta(), phi(), m());
36 return p4;
37 }
38
42
43 void TauTrack_v1::setP4(double pt, double eta, double phi, double /*m*/) {
44
45 // Set the raw variables:
46 static const Accessor< float > acc1( "pt" );
47 static const Accessor< float > acc2( "eta" );
48 static const Accessor< float > acc3( "phi" );
49 acc1( *this ) = pt;
50 acc2( *this ) = eta;
51 acc3( *this ) = phi;
52
53 return;
54 }
55
56
57 Type::ObjectType TauTrack_v1::type() const {
58 return Type::CompositeParticle;
59 }
60
61
62 double TauTrack_v1::rapidity() const {
63 return genvecP4().Rapidity();
64 }
65
66 double TauTrack_v1::m() const {
67 return PION_MASS;
68 }
69
70 double TauTrack_v1::e() const {
71 return genvecP4().E();
72 }
73
75
76 bool TauTrack_v1::flag(TauJetParameters::TauTrackFlag flag) const{
77 static const Accessor< TauTrack_v1::TrackFlagType > trackFlags("flagSet");
78 TrackFlagType f(trackFlags(*this));
79 std::bitset<8*sizeof(TrackFlagType)> thisTracksFlags(f);
80 return thisTracksFlags[flag];
81 }
82
83 bool TauTrack_v1::flagWithMask(unsigned int flags) const{
84 static const Accessor< TauTrack_v1::TrackFlagType > trackFlags("flagSet");
85 TrackFlagType f(trackFlags(*this));
86 return ((f&flags)==flags);
87 }
88
90 static const Accessor< TauTrack_v1::TrackFlagType > trackFlags("flagSet");
91 TrackFlagType& f(trackFlags(*this));
92 std::bitset<8*sizeof(TrackFlagType)> thisTracksFlags(f);
93 thisTracksFlags[flag] = value;
94 f = thisTracksFlags.to_ulong();
95 }
96
97 // superseded by z0sinthetaTJVA()
99 const xAOD::TrackParticle* xTrackParticle = this->track();
100 const xAOD::TauJet* tau = dynamic_cast<const xAOD::TauJet*> (&part);
101 if( tau ) {
102 float zv = 0.0;
103 if( tau->vertexLink().isValid() ) {
104 zv = tau->vertex()->z();
105 }
106 return ( ( xTrackParticle->z0() + xTrackParticle->vz() - zv ) *
107 std::sin( xTrackParticle->theta() ) );
108 } else {
109 std::cerr << "ERROR xAOD::TauTrack::z0sinThetaTJVA cannot get TauJet" << std::endl;
110 return 0;
111 }
112 }
113
114 static const SG::Accessor< float > d0TJVAAcc( "d0TJVA" );
115 float TauTrack_v1::d0TJVA() const {
116 return d0TJVAAcc(*this);
117 }
118
119 static const SG::Accessor< float > d0SigTJVAAcc( "d0SigTJVA" );
121 return d0SigTJVAAcc(*this);
122 }
123
124 static const SG::Accessor< float > z0sinthetaTJVAAcc( "z0sinthetaTJVA" );
126 return z0sinthetaTJVAAcc(*this);
127 }
128
129 static const SG::Accessor< float > z0sinthetaSigTJVAAcc( "z0sinthetaSigTJVA" );
131 return z0sinthetaSigTJVAAcc(*this);
132 }
133
134 float TauTrack_v1::rConv() const{
135 return std::sqrt(std::fabs(this->d0TJVA())*this->pt()/(0.3 /*0.15*2.*/));
136 }
137
138 float TauTrack_v1::rConvII() const{
139 return std::sqrt( std::fabs( this->d0TJVA() * this->pt() ) / (0.3) )*(this->d0TJVA()/fabs(this->d0TJVA()))*this->track()->charge();
140 }
141
143 const xAOD::TauJet* tau = dynamic_cast<const xAOD::TauJet*> (&part);
144 if(tau)
145 return tau->jet()->p4().DeltaR(this->p4());//this function should take jet seed as input
146 else {
147 std::cerr << "ERROR xAOD::TauTrack::z0sinThetaTJVA cannot get TauJet" << std::endl;
148 }
149 return 0.;
150 }
151
153 // Get the detail accessor:
154 const Accessor< float >* acc = xAODTau::trackDetailsAccessorV3<float>( detail );
155 if( ! acc ) return false;
156 if( ! acc->isAvailable( *this ) ) return false;
157
158 // Retrieve the detail value:
159 value = ( *acc )( *this );
160 return true;
161
162 }
163
165 ( *( xAODTau::trackDetailsAccessorV3<float>( detail ) ) )( *this ) = value;
166 }
167
168 // setters and getters for bdt values
170 std::vector<float>,
171 bdtScores,
172 setBdtScores )
173
174 static const SG::Accessor< std::vector<float> > bdtScoreAcc( "bdtScores" );
175
176 float TauTrack_v1::bdtScore( size_t i) const {
177 return bdtScoreAcc(*this).at(i);
178 }
179
180 //number of clusters
182 return bdtScoreAcc( *this ).size();
183 }
184
186 void TauTrack_v1::addBdtScore( const float score){
187 bdtScoreAcc( *this ).push_back(score);
188 }
189
192 bdtScoreAcc( *this ).clear();
193 }
194
195 // ----------------------------------------------------------------------------
196 // setters and getters for the track link
197 // ----------------------------------------------------------------------------
200 trackLinks,
201 setTrackLinks )
202
204
205 const TrackParticle* TauTrack_v1::track() const {
206 return ( *trackAcc( *this )[0] );
207 }
208
210 //clearTrackLinks();
211 trackAcc( *this ).push_back( tr );
212 return;
213 }
214
216 trackAcc( *this ).clear();
217 return;
218 }
219
220
221
222} // namespace xAOD
Scalar eta() const
pseudorapidity method
#define AUXSTORE_PRIMITIVE_GETTER_WITH_CAST(CL, PERSTYPE, TRANSTYPE, NAME)
Macro creating a getter function with a type conversion.
#define AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of primitive auxiliary properties.
#define AUXSTORE_OBJECT_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of complex auxiliary properties.
A number of constexpr particle constants to avoid hardcoding them directly in various places.
Class providing the definition of the 4-vector interface.
IParticle()=default
TLorentzVector FourMom_t
Definition of the 4-momentum type.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition Jet_v1.cxx:71
const VertexLink_t & vertexLink() const
const Vertex * vertex() const
const Jet * jet() const
virtual double e() const
The total energy of the particle.
void addBdtScore(const float score)
add a cluster to the tau
virtual double rapidity() const
The true rapidity (y) of the particle.
size_t nBdtScores() const
uint16_t TrackFlagType
Definition TauTrack_v1.h:61
bool detail(TauJetParameters::TrackDetail detail, float &value) const
virtual FourMom_t p4() const
The full 4-momentum of the particle.
float rConvII() const
void clearTrackLinks()
Remove all tracks from the collection.
virtual double eta() const
The pseudorapidity ( ) of the particle.
GenVecFourMom_t genvecP4() const
The full 4-momentum of the particle : internal taus type.
float bdtScore(size_t i) const
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > GenVecFourMom_t
Base 4 Momentum type for taus.
Definition TauTrack_v1.h:46
TauTrack_v1()
Default constructor.
float d0TJVA() const
void setFlag(TauJetParameters::TauTrackFlag flag, bool value)
bool flag(TauJetParameters::TauTrackFlag flag) const
float z0sinthetaSigTJVA() const
void clearBdtScores()
Remove all clusters from the tau.
void setP4(double pt, double eta, double phi, double m)
Set methods for IParticle values.
float z0sinthetaTJVA() const
float rConv() const
virtual double phi() const
The azimuthal angle ( ) of the particle.
bool flagWithMask(unsigned int) const
virtual double pt() const
The transverse momentum ( ) of the particle.
float d0SigTJVA() const
void addTrackLink(const ElementLink< TrackParticleContainer > &tr)
add a track to the collection
void setDetail(TauJetParameters::TrackDetail detail, float value)
float dRJetSeedAxis(const xAOD::IParticle &) const
std::vector< ElementLink< xAOD::TrackParticleContainer > > TrackParticleLinks_t
Definition TauTrack_v1.h:91
float z0sinThetaTJVA(const xAOD::IParticle &) const
virtual Type::ObjectType type() const
The type of the object as a simple enumeration.
const TrackParticle * track() const
virtual double m() const
The invariant mass of the particle.
float z0() const
Returns the parameter.
float theta() const
Returns the parameter, which has range 0 to .
float vz() const
The z origin for the parameters.
float charge() const
Returns the charge.
float z() const
Returns the z position.
TauTrackFlag
Enum for tau track flags.
Definition TauDefs.h:400
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
static const SG::Accessor< float > d0TJVAAcc("d0TJVA")
setStrategy setMatchFlag ElementLink< TrackParticleContainer >
static const SG::AuxElement::Accessor< Vertex_v1::TrackParticleLinks_t > trackAcc("trackParticleLinks")
Accessor for the track links.
setRcore setEtHad setFside pt
static const SG::Accessor< float > z0sinthetaTJVAAcc("z0sinthetaTJVA")
static const double PION_MASS
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TauJet_v3 TauJet
Definition of the current "tau version".
setBGCode setTAP setLVL2ErrorBits bool
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.
static const SG::Accessor< float > d0SigTJVAAcc("d0SigTJVA")
static const SG::Accessor< float > z0sinthetaSigTJVAAcc("z0sinthetaSigTJVA")