16TauTruthTrackMatchingTool::TauTruthTrackMatchingTool(
const std::string& name )
21TauTruthTrackMatchingTool::~TauTruthTrackMatchingTool( )
25StatusCode TauTruthTrackMatchingTool::initialize()
27 return StatusCode::SUCCESS;
31StatusCode TauTruthTrackMatchingTool::classifyTrack(
const xAOD::TauTrack& xTrackParticle)
const
34 if (!m_bIsHadronicTrackAvailable.isValid())
37 bool avail = accIsHadronicTrack.isAvailable(xTrackParticle);
38 m_bIsHadronicTrackAvailable.set (avail);
41 ATH_MSG_DEBUG(
"IsHadronicTrack decoration is available on first track processed, switched of rerun for further taus.");
42 ATH_MSG_DEBUG(
"If a truth track matching needs to be redone, please pass a shallow copy of the original track.");
45 if (*m_bIsHadronicTrackAvailable.ptr())
46 return StatusCode::SUCCESS;
48 ATH_CHECK(checkTrackIsTauInheritant(xTrackParticle));
49 ATH_CHECK(checkTrackType(xTrackParticle));
50 return StatusCode::SUCCESS;
54StatusCode TauTruthTrackMatchingTool::classifyTracks(std::vector<const xAOD::TauTrack*>& vTrackParticles)
const
56 for (
auto xTrackParticle : vTrackParticles)
58 ATH_CHECK(checkTrackIsTauInheritant(*xTrackParticle));
59 ATH_CHECK(checkTrackType(*xTrackParticle));
61 return StatusCode::SUCCESS;
66StatusCode TauTruthTrackMatchingTool::checkTrackType(
const xAOD::TauTrack& xTrackParticle)
const
74 return StatusCode::SUCCESS;
79 if (accTruthMatchProbability(*(xTrackParticle.
track())) < 0.5)
82 return StatusCode::SUCCESS;
87 if (
static_cast<bool>(accIsHadronicTrack(xTrackParticle)) and accIsHadronicTrackDecayDepth(xTrackParticle) == 0)
90 return StatusCode::SUCCESS;
102 ATH_MSG_DEBUG(
"unique ID not available for this truth track. Will mark as UnclassifiedTrack ");
104 return StatusCode::SUCCESS;
111 return StatusCode::SUCCESS;
121 return StatusCode::SUCCESS;
127 return StatusCode::SUCCESS;
129 for (
size_t iIncomingParticle = 0; iIncomingParticle < xProdVertex->
nIncomingParticles(); ++iIncomingParticle )
134 ATH_MSG_WARNING(
"Truth parent of tau decay was not found in TruthParticles container. Please ensure that this container has the full tau decay information or produce the TruthTaus container in AtlasDerivation.\nInformation on how to do this can be found here:\nhttps://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/TauPreRecommendations2015#Accessing_Tau_Truth_Information");
136 return StatusCode::SUCCESS;
142 return StatusCode::SUCCESS;
146 size_t iElectrons = 0;
147 for (
size_t iOutgoingParticle = 0; iOutgoingParticle < xProdVertex->
nOutgoingParticles(); ++iOutgoingParticle )
152 ATH_MSG_WARNING(
"Truth daughter of tau decay was not found in TruthParticles container. Please ensure that this container has the full tau decay information or produce the TruthTaus container in AtlasDerivation.\nInformation on how to do this can be found here:\nhttps://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/TauPreRecommendations2015#Accessing_Tau_Truth_Information");
154 return StatusCode::SUCCESS;
160 return StatusCode::SUCCESS;
167 return StatusCode::SUCCESS;
170 return StatusCode::SUCCESS;
177 auto xTruthParticleLink = accTruthParticleLink(*(xTrackParticle.
track()));
179 if (xTruthParticleLink.isValid())
180 return (*xTruthParticleLink);
185StatusCode TauTruthTrackMatchingTool::checkTrackIsTauInheritant(
const xAOD::TauTrack& xTrackParticle)
const
190 decIsHadronicTrack(xTrackParticle) = (
char)
false;
193 std::string sHistory =
"";
196 sHistory = std::to_string(xTruthParticle->
pdgId());
197 if (checkTruthParent(*xTruthParticle, iDepth, sHistory))
199 decIsHadronicTrack(xTrackParticle) = (
char)
true;
202 decIsHadronicTrackDecayDepth(xTrackParticle) = iDepth;
203 decDecayHistory(xTrackParticle) = std::move(sHistory);
205 return StatusCode::SUCCESS;
209bool TauTruthTrackMatchingTool::checkTruthParent(
const xAOD::TruthParticle& xTruthParticle,
int& iDepth, std::string& sHistory)
const
220 if (xTruthParticleParent) {
222 sHistory.insert(0, std::to_string(xTruthParticleParent->
pdgId())+
":");
229 return checkTruthParent(*xTruthParticleParent, iDepth, sHistory);
232 ATH_MSG_WARNING(
"vertex has incoming particles but no valid parent particle");
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
ATLAS-specific HepMC functions.
Helper class to provide constant type-safe access to aux data.
const TrackParticle * track() const
int pdgId() const
PDG ID code.
bool hasProdVtx() const
Check for a production vertex on this particle.
const TruthVertex_v1 * prodVtx() const
The production vertex of this particle.
bool isElectron() const
Whether the particle is an electron (or positron).
bool isPhoton() const
Whether the particle is a photon.
const TruthParticle_v1 * outgoingParticle(size_t index) const
Get one of the outgoing particles.
const TruthParticle_v1 * incomingParticle(size_t index) const
Get one of the incoming particles.
size_t nOutgoingParticles() const
Get the number of outgoing particles.
size_t nIncomingParticles() const
Get the number of incoming particles.
bool is_simulation_particle(const T &p)
Method to establish if a particle was created during the simulation (based on the status value).
bool no_truth_link(const T &p)
Method to establish if the object is linked to something which was never saved to the HepMC Truth - f...
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle *, bool debug=false)
return the truthParticle associated to the given IParticle (if any)
TruthVertex_v1 TruthVertex
Typedef to implementation.
TauTrack_v1 TauTrack
Definition of the current version.
TruthParticle_v1 TruthParticle
Typedef to implementation.