ATLAS Offline Software
Loading...
Searching...
No Matches
IMCTruthClassifier.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef MCTRUTHCLASSIFIER_IMCTRUTHCLASSIFIER_H
5#define MCTRUTHCLASSIFIER_IMCTRUTHCLASSIFIER_H
6
12
14#include "AsgTools/IAsgTool.h"
19
20#include <memory>
21#include <unordered_map>
22#include <vector>
23#include <optional>
24
25#ifndef GENERATIONBASE
29#include "xAODJet/Jet.h"
30#include "xAODMuon/Muon.h"
32#endif
33
34class IMCTruthClassifier : virtual public asg::IAsgTool
35{
37protected:
38 // Additional information that can be returned by the classifier.
39 // Originally, these were all held in member variables in the classifier,
40 // but that prevents the classifier methods from being made const.
41 // Not all of these are filled by all classifier calls; it would probably
42 // be better to split this up into a hierarchy of structures.
43 class Info
44 {
45 public:
46 Info() : eventContext(Gaudi::Hive::currentContext()) {}
47 Info(const EventContext& ctx) : eventContext(ctx) {}
48
49 ~Info() = default;
50
51 const EventContext& eventContext;
52 const xAOD::TruthParticle* genPart = nullptr;
53
55
56#ifndef GENERATIONBASE /*Disable when no reconstruction packages are expected*/
57 float deltaRMatch = -999;
58 float deltaPhi = -999;
59 float probTrkToTruth = 0;
60 uint8_t numOfSiHits = 0;
61
62 std::vector<const xAOD::TruthParticle*> egPartPtr;
63 std::vector<float> egPartdR;
64 std::vector<std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>> egPartClas;
65
66 std::vector<const xAOD::TrackParticle*> cnvPhotTrkPtr;
67 std::vector<const xAOD::TruthParticle*> cnvPhotTrkToTruthPart;
68 std::vector<MCTruthPartClassifier::ParticleType> cnvPhotPartType;
69 std::vector<MCTruthPartClassifier::ParticleOrigin> cnvPhotPartOrig;
70#endif
71 };
72public:
74 virtual ~IMCTruthClassifier() = default;
75
76// Methods for Truth Particle classification
77protected:
78 virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
80
81#ifndef GENERATIONBASE
82 // Methods for Reco Particle classification
83 // Rely on the Reco to Truth association and then the Truth classification
84 virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
86
87 virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
89
90 virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
92
93 virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
95
96 virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
98
99#endif
100public:
102 template <typename T> std::tuple<MCTruthPartClassifier::ParticleType,
104 const xAOD::TruthParticle*,
106 particleTruthClassifier_full(const T* p, std::optional<std::reference_wrapper<const EventContext>> ctx = std::nullopt) const {
108 auto classification = particleTruthClassifier(p, &info);
109 return {classification.first,classification.second,info.genPart,info.particleOutCome};
110 }
111
112 template <typename T> std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
113 particleTruthClassifier(const T* p, std::optional<std::reference_wrapper<const EventContext>> ctx = std::nullopt) const
114 {
115 if (!ctx) return particleTruthClassifier(p, nullptr);
116 IMCTruthClassifier::Info info(ctx->get());
117 return particleTruthClassifier(p, &info);
118 }
119
120};
121
122#endif // MCTRUTHCLASSIFIER_IMCTRUTHCLASSIFIER_H
#define ASG_TOOL_INTERFACE(CLASSNAME)
std::vector< MCTruthPartClassifier::ParticleOrigin > cnvPhotPartOrig
std::vector< const xAOD::TruthParticle * > egPartPtr
std::vector< float > egPartdR
std::vector< const xAOD::TruthParticle * > cnvPhotTrkToTruthPart
MCTruthPartClassifier::ParticleOutCome particleOutCome
Info(const EventContext &ctx)
std::vector< MCTruthPartClassifier::ParticleType > cnvPhotPartType
std::vector< const xAOD::TrackParticle * > cnvPhotTrkPtr
const EventContext & eventContext
std::vector< std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > > egPartClas
const xAOD::TruthParticle * genPart
virtual ~IMCTruthClassifier()=default
Virtual destructor.
virtual std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier(const xAOD::Muon *, IMCTruthClassifier::Info *info) const =0
std::tuple< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin, const xAOD::TruthParticle *, MCTruthPartClassifier::ParticleOutCome > particleTruthClassifier_full(const T *p, std::optional< std::reference_wrapper< const EventContext > > ctx=std::nullopt) const
Returns more info than the particleTruthClassifier.
std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier(const T *p, std::optional< std::reference_wrapper< const EventContext > > ctx=std::nullopt) const
virtual std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier(const xAOD::CaloCluster *, IMCTruthClassifier::Info *info) const =0
virtual std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier(const xAOD::Electron *, IMCTruthClassifier::Info *info) const =0
virtual std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier(const xAOD::Photon *, IMCTruthClassifier::Info *info) const =0
virtual std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier(const xAOD::TruthParticle *, IMCTruthClassifier::Info *info) const =0
virtual std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier(const xAOD::TrackParticle *, IMCTruthClassifier::Info *info) const =0
Base class for the dual-use tool interface classes.
Definition IAsgTool.h:41
=============================================================================
ParticleOutCome
Outcome of a (simulated) truth particle: what happened to it after being produced,...
@ UnknownOutCome
End vertex exists, but its content matches none of the patterns below.
ParticleOrigin
Origin of a truth particle, as assigned by MCTruthClassifier::particleTruthClassifier (the second mem...
ParticleType
Type of a truth particle, as assigned by MCTruthClassifier::particleTruthClassifier (the first member...
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
Reference the current persistent version:
Definition Muon.h:13
Photon_v1 Photon
Definition of the current "egamma version".
Definition Photon.h:17
Electron_v1 Electron
Definition of the current "egamma version".
Definition Electron.h:17