Loading [MathJax]/jax/output/SVG/config.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 #include "xAODTau/TauJet.h"
11 #include "xAODPFlow/PFO.h"
12 #include "xAODPFlow/PFODefs.h"
13 
14 
16  asg::AsgTool(name)
17 {
18 }
19 
21 
23 
24  ATH_MSG_INFO(" initialize()");
25  m_init=true;
26 
27  ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName) ); //ABR only
28 
29  ATH_CHECK( m_Tool_InformationStore.retrieve() );
30 
31  ATH_CHECK( m_Tool_InformationStore->getInfo_Int("TauConstituents_UsePionMass", m_Config_UsePionMass) );
32  ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_Types_DeltaRCore", m_Config_TauConstituents_Types_DeltaRCore) );
33  ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_PreselectionMinEnergy", m_Config_TauConstituents_PreselectionMinEnergy) );
34  ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_BinEdges_Eta", m_Config_CellBased_BinEdges_Eta) );
35  ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_EtaBinned_Pi0MVACut_1prong", m_Config_CellBased_EtaBinned_Pi0MVACut_1prong) );
36  ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_EtaBinned_Pi0MVACut_3prong", m_Config_CellBased_EtaBinned_Pi0MVACut_3prong) );
37 
38  return StatusCode::SUCCESS;
39 }
40 
41 
43  return energy >= m_Config_TauConstituents_PreselectionMinEnergy;
44 }
45 
46 
47 // PFO converter
49  PanTau::TauConstituent* &tauConstituent,
50  const xAOD::TauJet* tauJet) const {
51 
52  // check for invalid eta, phi, e "NAN" values -- likely no longer needed, raise severity to be sure
53  if (pfo->eta() != pfo->eta() || pfo->phi() != pfo->phi() || pfo->e() != pfo->e()) {
54  ATH_MSG_ERROR("Will not convert PFO with eta value of " << pfo->eta() << " -> return to Tool_TauConstituentGetter");
55  return StatusCode::FAILURE;
56  }
57 
58  // Check whether neutral input pfo has pion mass (it may have if xAOD is being reprocessed)
59  // If it does,
60  // - old (R21) approach: make it massless again and use that
61  // - new (R22) approach: complain and abort, reconstruction from AOD implies rebuilding PFOs upstream, so the mass should not have been set at that point
62  if (!pfo->isCharged() && pfo->m() != 0) {
63  ATH_MSG_ERROR("Input neutral PFO should have null mass. If reconstruction runs from AOD, PFOs must be rebuilt!");
64  return StatusCode::FAILURE;
65  }
66 
67  // preselection to veto very low energy PFOs
68  if (!passesPreselectionEnergy(pfo->e())) {
69  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);
70  return StatusCode::SUCCESS;
71  }
72 
73  // get the mass correct & build 4-vector
74  double constituentMass = pfo->m();
75  if (m_Config_UsePionMass) {
76 
77  // clusters: don't touch the measured energy. set mass to pion mass, so momentum will be altered
78  if (!pfo->isCharged()) {
79  constituentMass = 134.98;
80  }
81  }
82 
83  TLorentzVector momentum;
84  PanTau::SetP4EEtaPhiM( momentum, pfo->e(), pfo->eta(), pfo->phi(), constituentMass);
85 
86  // get type (based on charge and DR to tau)
87  std::vector<int> typeFlags = std::vector<int>((unsigned int)PanTau::TauConstituent::t_nTypes, 0);
88  if (typeFlags.size() < (unsigned int)PanTau::TauConstituent::t_nTypes) std::abort(); // suppress cppcheck warning
89  typeFlags.at((int)PanTau::TauConstituent::t_NoType) = 1;
90 
91  double mvaValue = PanTau::TauConstituent::DefaultBDTValue();
92 
93  TLorentzVector tlv_intAxis = tauJet->p4(xAOD::TauJetParameters::IntermediateAxis);
94  double deltaR_toTauJet = tlv_intAxis.DeltaR( pfo->p4() );
95 
96  if (deltaR_toTauJet > m_Config_TauConstituents_Types_DeltaRCore) {
97  if (pfo->isCharged()) {
98  typeFlags.at((int)PanTau::TauConstituent::t_Charged) = 1;
99  }
100  else {
101  typeFlags.at((int)PanTau::TauConstituent::t_OutNeut) = 1;
102  mvaValue = pfo->bdtPi0Score();
103  }
104  }//end if pfo is not in core
105 
106  if (deltaR_toTauJet <= m_Config_TauConstituents_Types_DeltaRCore) {
107 
108  if (pfo->isCharged()) {
109  typeFlags.at((int)PanTau::TauConstituent::t_Charged) = 1;
110  }
111  else {
112  typeFlags.at((int)PanTau::TauConstituent::t_Neutral) = 1;
113 
114  //neutral PFO arranging --- check for pi0 tag
115  mvaValue = pfo->bdtPi0Score();
116 
117  int nPi0sPerCluster = 0;
118  if ( !pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0sPerCluster) ) {
119  ATH_MSG_WARNING("WARNING: Could not retrieve nPi0Proto. Will set it to 1.");
120  nPi0sPerCluster = 1;
121  }
122  if (nPi0sPerCluster > 0) typeFlags.at((int)PanTau::TauConstituent::t_Pi0Neut) = 1;
123 
124  }
125  }//end if pfo is in core
126 
127  // create the tau constituent
128  tauConstituent = new PanTau::TauConstituent(momentum, static_cast<int>(pfo->charge()), typeFlags, mvaValue, pfo);
129  tauConstituent->makePrivateStore();
130 
131  // Check if the pfo object has shots:
132  std::vector<const xAOD::IParticle*> list_TauShots = std::vector<const xAOD::IParticle*>(0);
133  if (!(pfo->associatedParticles(xAOD::PFODetails::TauShot, list_TauShots))) {
134  ATH_MSG_DEBUG("WARNING: Could not get shots from current pfo");
135  }
136 
137  for (unsigned int iShot=0; iShot<list_TauShots.size(); iShot++) {
138 
139  if (list_TauShots.at(iShot) == nullptr) {
140  ATH_MSG_WARNING("Shot number " << iShot << " points to 0! Skip it");
141  continue;
142  }
143 
144  const xAOD::PFO* curShot = dynamic_cast<const xAOD::PFO*>(list_TauShots.at(iShot));
145  TLorentzVector shotMomentum;
146  PanTau::SetP4EEtaPhiM( shotMomentum, curShot->e(), curShot->eta(), curShot->phi(), curShot->m());
147  std::vector<int> shotTypeFlags = std::vector<int>((unsigned int)PanTau::TauConstituent::t_nTypes, 0);
148  PanTau::TauConstituent* shotConstituent = new PanTau::TauConstituent(shotMomentum, 0, typeFlags, PanTau::TauConstituent::DefaultBDTValue(), curShot);
149  shotConstituent->makePrivateStore();
150 
151  int nPhotons = 0;
152  if (!curShot->attribute(xAOD::PFODetails::tauShots_nPhotons, nPhotons)) {
153  nPhotons = -1;
154  ATH_MSG_DEBUG("WARNING: Could not get nPhotons for this shot! Set to -1");
155  }
156  shotConstituent->setNPhotonsInShot(nPhotons);
157  tauConstituent->addShot(shotConstituent);
158  }//end loop over shots
159 
160  return StatusCode::SUCCESS;
161 }
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:42
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:250
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
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::TauConstituent::t_OutNeut
@ t_OutNeut
Definition: TauConstituent.h:48
PFO.h
PanTau::Tool_InputConverter::initialize
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: Tool_InputConverter.cxx:22
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
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:48
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:235
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:57
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
Tool_InformationStore.h
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:97
PanTau::TauConstituent::t_NoType
@ t_NoType
Definition: TauConstituent.h:43
TauJet.h
PFODefs.h
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:15