ATLAS Offline Software
Loading...
Searching...
No Matches
Tool_InputConverter.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
11
13 asg::AsgTool(name)
14{}
15
17
19
20 ATH_MSG_INFO(" initialize()");
21 m_init=true;
22
24
26
27 ATH_CHECK( m_Tool_InformationStore->getInfo_Int("TauConstituents_UsePionMass", m_Config_UsePionMass) );
28 ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_Types_DeltaRCore", m_Config_TauConstituents_Types_DeltaRCore) );
29 ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_PreselectionMinEnergy", m_Config_TauConstituents_PreselectionMinEnergy) );
30
31 return StatusCode::SUCCESS;
32}
33
34
38
39
40// PFO converter
42 PanTau::TauConstituent* &tauConstituent,
43 const xAOD::TauJet* tauJet) const {
44
45 // check for invalid eta, phi, e "NAN" values -- likely no longer needed, raise severity to be sure
46 if (pfo->eta() != pfo->eta() || pfo->phi() != pfo->phi() || pfo->e() != pfo->e()) {
47 ATH_MSG_ERROR("Will not convert PFO with eta value of " << pfo->eta() << " -> return to Tool_TauConstituentGetter");
48 return StatusCode::FAILURE;
49 }
50
51 // Check whether neutral input pfo has pion mass (it may have if xAOD is being reprocessed)
52 // If it does,
53 // - old (R21) approach: make it massless again and use that
54 // - new (R22) approach: complain and abort, reconstruction from AOD implies rebuilding PFOs upstream, so the mass should not have been set at that point
55 if (!pfo->isCharged() && pfo->m() != 0) {
56 ATH_MSG_ERROR("Input neutral PFO should have null mass. If reconstruction runs from AOD, PFOs must be rebuilt!");
57 return StatusCode::FAILURE;
58 }
59
60 // preselection to veto very low energy PFOs
61 if (!passesPreselectionEnergy(pfo->e())) {
62 ATH_MSG_DEBUG("EFO of charge " << static_cast<int>(pfo->charge()) << " and energy " << pfo->e() << " does not pass presel Energy cut of " << m_Config_TauConstituents_PreselectionMinEnergy);
63 return StatusCode::SUCCESS;
64 }
65
66 // get the mass correct & build 4-vector
67 double constituentMass = pfo->m();
69
70 // clusters: don't touch the measured energy. set mass to pion mass, so momentum will be altered
71 if (!pfo->isCharged()) {
72 constituentMass = ParticleConstants::piZeroMassInMeV;
73 }
74 }
75
76 TLorentzVector momentum;
77 PanTau::SetP4EEtaPhiM( momentum, pfo->e(), pfo->eta(), pfo->phi(), constituentMass);
78
79 // get type (based on charge and DR to tau)
80 std::vector<int> typeFlags = std::vector<int>((unsigned int)PanTau::TauConstituent::t_nTypes, 0);
81 if (typeFlags.size() < (unsigned int)PanTau::TauConstituent::t_nTypes) std::abort(); // suppress cppcheck warning
82 typeFlags.at(static_cast<int>(PanTau::TauConstituent::t_NoType)) = 1;
83
85
86 TLorentzVector tlv_intAxis = tauJet->p4(xAOD::TauJetParameters::IntermediateAxis);
87 double deltaR_toTauJet = tlv_intAxis.DeltaR( pfo->p4() );
88
89 if (deltaR_toTauJet > m_Config_TauConstituents_Types_DeltaRCore) {
90 if (pfo->isCharged()) {
91 typeFlags.at(static_cast<int>(PanTau::TauConstituent::t_Charged)) = 1;
92 }
93 }//end if pfo is not in core
94
95 if (deltaR_toTauJet <= m_Config_TauConstituents_Types_DeltaRCore) {
96
97 if (pfo->isCharged()) {
98 typeFlags.at(static_cast<int>(PanTau::TauConstituent::t_Charged)) = 1;
99 }
100 else {
101 typeFlags.at(static_cast<int>(PanTau::TauConstituent::t_Neutral)) = 1;
102
103 //neutral PFO arranging --- check for pi0 tag
104 mvaValue = pfo->bdtPi0Score();
105
106 int nPi0sPerCluster = 0;
107 if ( !pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0sPerCluster) ) {
108 ATH_MSG_WARNING("WARNING: Could not retrieve nPi0Proto. Will set it to 1.");
109 nPi0sPerCluster = 1;
110 }
111 if (nPi0sPerCluster > 0) typeFlags.at(static_cast<int>(PanTau::TauConstituent::t_Pi0Neut)) = 1;
112
113 }
114 }//end if pfo is in core
115
116 // create the tau constituent
117 tauConstituent = new PanTau::TauConstituent(momentum, static_cast<int>(pfo->charge()), typeFlags, mvaValue, pfo);
118 tauConstituent->makePrivateStore();
119
120 // Check if the pfo object has shots:
121 std::vector<const xAOD::IParticle*> list_TauShots = std::vector<const xAOD::IParticle*>(0);
122 if (!(pfo->associatedParticles(xAOD::PFODetails::TauShot, list_TauShots))) {
123 ATH_MSG_DEBUG("WARNING: Could not get shots from current pfo");
124 }
125
126 for (unsigned int iShot=0; iShot<list_TauShots.size(); iShot++) {
127
128 if (list_TauShots.at(iShot) == nullptr) {
129 ATH_MSG_WARNING("Shot number " << iShot << " points to 0! Skip it");
130 continue;
131 }
132
133 const xAOD::PFO* curShot = dynamic_cast<const xAOD::PFO*>(list_TauShots.at(iShot));
134 TLorentzVector shotMomentum;
135 PanTau::SetP4EEtaPhiM( shotMomentum, curShot->e(), curShot->eta(), curShot->phi(), curShot->m());
136 std::vector<int> shotTypeFlags = std::vector<int>((unsigned int)PanTau::TauConstituent::t_nTypes, 0);
137 PanTau::TauConstituent* shotConstituent = new PanTau::TauConstituent(shotMomentum, 0, typeFlags, PanTau::TauConstituent::DefaultBDTValue(), curShot);
138 shotConstituent->makePrivateStore();
139
140 int nPhotons = 0;
141 if (!curShot->attribute(xAOD::PFODetails::tauShots_nPhotons, nPhotons)) {
142 nPhotons = -1;
143 ATH_MSG_DEBUG("WARNING: Could not get nPhotons for this shot! Set to -1");
144 }
145 shotConstituent->setNPhotonsInShot(nPhotons);
146 tauConstituent->addShot(shotConstituent);
147 }//end loop over shots
148
149 return StatusCode::SUCCESS;
150}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
A number of constexpr particle constants to avoid hardcoding them directly in various places.
static StatusCode bindToolHandle(ToolHandle< T > &, std::string)
Input object for PanTau.
void addShot(TauConstituent *shot)
static double DefaultBDTValue()
void setNPhotonsInShot(int nPhotons)
Tool_InputConverter(const std::string &name)
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
virtual bool passesPreselectionEnergy(double energy) const
Gaudi::Property< std::string > m_Tool_InformationStoreName
virtual StatusCode ConvertToTauConstituent(const xAOD::PFO *pfo, PanTau::TauConstituent *&tauConstituent, const xAOD::TauJet *tauJet) const
ToolHandle< PanTau::ITool_InformationStore > m_Tool_InformationStore
void makePrivateStore()
Create a new (empty) private store for this object.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
bool attribute(PFODetails::PFOAttributes AttributeType, T &anAttribute) const
get a PFO Variable via enum
bool isCharged() const
is a charged PFO
Definition PFO_v1.cxx:251
bool associatedParticles(PFODetails::PFOParticleType ParticleType, std::vector< const IParticle * > &theParticles) const
get a vector of PFO constituent particle types via enum
Definition PFO_v1.cxx:610
float bdtPi0Score() const
get BDT Score used to classify clusters as Pi0 like or not
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition PFO_v1.cxx:95
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition PFO_v1.cxx:60
virtual double m() const
The invariant mass of the particle.
Definition PFO_v1.cxx:74
virtual double e() const
The total energy of the particle.
Definition PFO_v1.cxx:81
float charge() const
get charge of PFO
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition PFO_v1.cxx:67
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition TauJet_v3.cxx:96
static void SetP4EEtaPhiM(TLorentzVector &hlv, double e, double eta, double phi, double m)
Definition PanTauSeed.h:233
constexpr double piZeroMassInMeV
the mass of the pi zero (in MeV)
PFO_v1 PFO
Definition of the current "pfo version".
Definition PFO.h:17
TauJet_v3 TauJet
Definition of the current "tau version".