ATLAS Offline Software
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 
23  ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName) ); //ABR only
24 
25  ATH_CHECK( m_Tool_InformationStore.retrieve() );
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 
36  return energy >= m_Config_TauConstituents_PreselectionMinEnergy;
37 }
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();
68  if (m_Config_UsePionMass) {
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 
84  double mvaValue = PanTau::TauConstituent::DefaultBDTValue();
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 }
PanTauSeed.h
PanTau::TauConstituent::t_Neutral
@ t_Neutral
Definition: TauConstituent.h:45
PanTau::Tool_InputConverter::passesPreselectionEnergy
virtual bool passesPreselectionEnergy(double energy) const
Definition: Tool_InputConverter.cxx:35
xAOD::TauJetParameters::IntermediateAxis
@ IntermediateAxis
Definition: TauDefs.h:338
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PanTau::TauConstituent::t_Charged
@ t_Charged
Definition: TauConstituent.h:44
xAOD::PFODetails::TauShot
@ TauShot
Definition: Event/xAOD/xAODPFlow/xAODPFlow/PFODefs.h:171
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
HelperFunctions.h
asg
Definition: DataHandleTestTool.h:28
PanTau::TauConstituent::setNPhotonsInShot
void setNPhotonsInShot(int nPhotons)
Definition: TauConstituent.cxx:247
xAOD::PFO_v1::associatedParticles
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
ParticleConstants::PDG2011::piZeroMassInMeV
constexpr double piZeroMassInMeV
the mass of the pi zero (in MeV)
Definition: ParticleConstants.h:38
Tool_InputConverter.h
TauConstituent.h
xAOD::PFODetails::tauShots_nPhotons
@ tauShots_nPhotons
Definition: Event/xAOD/xAODPFlow/xAODPFlow/PFODefs.h:162
xAOD::PFO_v1::e
virtual double e() const
The total energy of the particle.
Definition: PFO_v1.cxx:81
PanTau::Tool_InputConverter::initialize
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: Tool_InputConverter.cxx:18
PanTau::TauConstituent::DefaultBDTValue
static double DefaultBDTValue()
Definition: TauConstituent.h:54
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
ParticleGun_EoverP_Config.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:63
ParticleConstants.h
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
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
xAOD::PFO_v1::charge
float charge() const
get charge of PFO
xAOD::PFO_v1::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: PFO_v1.cxx:95
PanTau::Tool_InputConverter::ConvertToTauConstituent
virtual StatusCode ConvertToTauConstituent(const xAOD::PFO *pfo, PanTau::TauConstituent *&tauConstituent, const xAOD::TauJet *tauJet) const
Definition: Tool_InputConverter.cxx:41
PanTau::Tool_InputConverter::~Tool_InputConverter
virtual ~Tool_InputConverter()
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::PFO_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: PFO_v1.cxx:67
xAOD::PFO_v1::bdtPi0Score
float bdtPi0Score() const
get BDT Score used to classify clusters as Pi0 like or not
xAOD::PFO_v1::isCharged
bool isCharged() const
is a charged PFO
Definition: PFO_v1.cxx:251
PanTau::TauConstituent::addShot
void addShot(TauConstituent *shot)
Definition: TauConstituent.cxx:232
xAOD::PFO_v1
Class describing a particle flow object.
Definition: PFO_v1.h:35
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
PanTau::HelperFunctions::bindToolHandle
static StatusCode bindToolHandle(ToolHandle< T > &, std::string)
Definition: Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/HelperFunctions.h:56
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:192
xAOD::PFODetails::nPi0Proto
@ nPi0Proto
Definition: Event/xAOD/xAODPFlow/xAODPFlow/PFODefs.h:31
xAOD::PFO_v1::m
virtual double m() const
The invariant mass of the particle.
Definition: PFO_v1.cxx:74
PanTau::TauConstituent::t_Pi0Neut
@ t_Pi0Neut
Definition: TauConstituent.h:46
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::TauJet_v3::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: TauJet_v3.cxx:96
PanTau::TauConstituent::t_NoType
@ t_NoType
Definition: TauConstituent.h:43
PanTau::TauConstituent::t_nTypes
@ t_nTypes
Definition: TauConstituent.h:51
PanTau::TauConstituent
Definition: TauConstituent.h:25
PanTau::Tool_InputConverter::Tool_InputConverter
Tool_InputConverter(const std::string &name)
Definition: Tool_InputConverter.cxx:12