|
ATLAS Offline Software
|
Go to the documentation of this file.
6 #ifndef TRUTHUTILS_MAGICNUMBERS_H
7 #define TRUTHUTILS_MAGICNUMBERS_H
13 #include <type_traits>
14 #if !defined(XAOD_STANDALONE)
21 class TruthParticle_v1;
64 template <
typename T>
struct is_smart_ptr<std::shared_ptr<T>> : std::true_type {};
65 template <
typename T>
struct is_smart_ptr<std::unique_ptr<T>> : std::true_type {};
66 template <
typename T>
struct is_smart_ptr<std::weak_ptr<T>> : std::true_type {};
75 #if defined(XAOD_STANDALONE)
77 template <
class T>
inline int barcode(
const T&
p){
78 if constexpr (std::is_pointer_v<T> || is_smart_ptr_v<T>){
85 template <>
inline int barcode(
const int&
p){
return p;}
89 template <
typename T>
inline int uniqueID(
const T&
p) {
90 if constexpr (std::is_integral_v<T>) {
93 else if constexpr (std::is_integral_v<std::remove_pointer_t<T>>) {
96 else if constexpr (std::is_same_v<T, xAOD::TruthParticle_v1> || std::is_same_v<T, xAOD::TruthVertex_v1>) {
102 else if constexpr (std::is_same_v<T, CaloCalibrationHit>) {
103 return p.particleUID();
106 return p->particleUID();
108 else if constexpr (std::is_pointer_v<T> || is_smart_ptr_v<T>){
117 if constexpr (std::is_integral_v<T>) {
120 else if constexpr (std::is_integral_v<std::remove_pointer_t<T>>) {
123 else if constexpr (std::is_same_v<T, CaloCalibrationHit>) {
124 return p.particleUID();
127 return p->particleUID();
129 else if constexpr (std::is_pointer_v<T> || is_smart_ptr_v<T>){
138 template <
typename T>
inline int status(
const T&
p) {
139 if constexpr (std::is_integral_v<T>) {
142 else if constexpr (std::is_integral_v<std::remove_pointer_t<T>>) {
145 else if constexpr (std::is_same_v<T, xAOD::TruthVertex_v1>) {
151 else if constexpr (std::is_pointer_v<T> || is_smart_ptr_v<T>){
158 #if !defined(HEPMC3) && !defined(XAOD_STANDALONE)
167 auto pv =
p->production_vertex();
169 for (
auto pa:
pv->particles_in()) {
170 if (pa->pdg_id() !=
p->pdg_id())
continue;
180 auto pv =
p->end_vertex();
182 for (
auto pa:
pv->particles_out()) {
183 if (pa->pdg_id() !=
p->pdg_id())
continue;
195 namespace BarcodeBased {
227 namespace StatusBased {
244 return p.linkIsNull();
247 return p->linkIsNull();
280 if (id1 ==
id2) {
return true;}
283 if (generations1 == generations2) {
return false; }
286 const int direction = (generations2 > generations1) ? -1 : 1;
288 if (
std::find(history2.begin(),history2.end(), id1) == history2.end()) {
return false; }
292 const int direction = (generations1 > generations2) ? -1 : 1;
294 if (
std::find(history1.begin(),history1.end(),
id2) == history1.end()) {
return false; }
311 if (id1 ==
id2) {
return true;}
314 if (generations1 == generations2) {
return false; }
317 constexpr
int descendents = 1;
319 if (
std::find(history2.begin(),history2.end(), id1) == history2.end()) {
return false; }
323 constexpr
int ancestors = -1;
325 if (
std::find(history1.begin(),history1.end(),
id2) == history1.end()) {
return false; }
388 for (
auto p:
evt->particles()) {
391 for (
auto v:
evt->vertices()) {
395 for (
auto p =
evt->particles_begin();
p !=
evt->particles_end(); ++
p) {
396 (*p)->set_status (particle_status ((*p)->barcode(), (*p)->status()));
398 for (
auto v =
evt->vertices_begin();
v !=
evt->vertices_end(); ++
v) {
399 (*v)->set_id (vertex_status ((*v)->barcode(), (*v)->id()));
425 #if !defined(XAOD_STANDALONE)
431 auto allbarcodes = genEvent->attribute<HepMC::GenEventBarcodes>(
"barcodes");
432 for (
const auto& bp: allbarcodes->barcode_to_particle_map()) {
436 for (
auto currentGenParticle: *genEvent) {
448 auto allbarcodes = genEvent->attribute<HepMC::GenEventBarcodes>(
"barcodes");
449 for (
const auto& bp: allbarcodes->barcode_to_vertex_map()) {
453 HepMC::GenEvent::vertex_const_iterator currentGenVertexIter;
454 for (currentGenVertexIter= genEvent->vertices_begin();
455 currentGenVertexIter!= genEvent->vertices_end();
456 ++currentGenVertexIter) {
457 const int barcode((*currentGenVertexIter)->barcode());
HepMC::GenVertex * GenVertexPtr
bool is_simulation_vertex(const T &v)
Method to establish if the vertex was created during simulation from the status.
int old_vertex_status_from_new(const int newStatus)
Get vertex status in the old scheme from the status in the new scheme.
constexpr int SIM_BARCODE_THRESHOLD
Constant defining the barcode threshold for simulated particles, eg. can be used to separate generato...
bool is_same_vertex(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same vertex.
bool is_truth_suppressed_pileup(const T &p)
Method to establish if a particle corresponds to truth-suppressed pile-up.
std::string find(const std::string &s)
return a remapped string
bool is_sim_secondary(const T &p)
Method to establish if a particle (or barcode) is a new seondary created during the simulation (only ...
int generations(const T &p)
Method to return how many interactions a particle has undergone during simulation based on the status...
bool ignoreTruthLink(const T &p, bool vetoPileUp)
Helper function for SDO creation in PileUpTools.
constexpr int SIM_STATUS_INCREMENT
Constant defining the barcode threshold for regenerated particles, i.e. particles surviving an intera...
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (only to be used in ...
bool is_sim_secondary(const T &p)
Method to establish if a particle is a new seondary created during the simulation based on the status...
constexpr int INVALID_PARTICLE_ID
int maxGeneratedVertexBarcode(const HepMC::GenEvent *genEvent)
Get the maximal absolute value of barcode of vertex present in the event. Returns a negative number.
bool ignoreTruthLink(const T &p, bool vetoPileUp)
Helper function for SDO creation in PileUpTools.
bool is_sim_descendant(const T1 &p1, const T2 &p2)
Method to check if the first particle is a descendant of the second in the simulation,...
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
bool no_truth_link(const T &p)
Method to establish if a if the object is linked to something which was never saved to the HepMC Trut...
bool ignoreTruthLink(const T &p, bool vetoPileUp)
Helper function for SDO creation in PileUpTools.
constexpr int INVALID_PARTICLE_BARCODE
constexpr bool is_smart_ptr_v
bool is_same_particle(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same particle.
@ u
Enums for curvilinear frames.
int generations(const T &p)
Method to return how many interactions a particle has undergone during simulation (only to be used in...
constexpr int FORWARD_TRANSPORT_MODEL_PROCESS
Special Forward transport Geant process for vertices.
a link optimized in size for a GenParticle in a McEventCollection
constexpr int SUPPRESSED_PILEUP_BARCODE(std::numeric_limits< int32_t >::max())
This barcode is used by objects matched to particles from pile-up interactions in standard MC Product...
bool is_same_generator_particle(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same generated particle.
bool is_same_object(const T1 &p1, const T2 &p2)
Method to establish if two particles/vertices in the GenEvent actually represent the same particle.
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
bool no_truth_link(const T &p)
Method to establish if a if the object is linked to something which was never saved to the HepMC Trut...
int old_particle_status_from_new(const int newStatus)
Get particle status in the old scheme from the status in the new scheme.
Class describing a truth particle in the MC record.
int new_vertex_status_from_old(const int oldStatus, const int barcode)
Get vertex status in the new scheme from the barcode and status in the old scheme.
std::pair< std::vector< unsigned int >, bool > res
std::deque< int > simulation_history(const T &p, const int direction)
Function to calculate all the descendants(direction=1)/ancestors(direction=-1) of the particle.
bool is_simulation_vertex(const T &v)
Method to establish if the vertex was created during simulation (TODO migrate to be based on status).
bool is_same_generator_particle(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same generated particle.
constexpr int UNDEFINED_ID
constexpr int SIM_REGENERATION_INCREMENT
Constant defining the barcode threshold for regenerated particles, i.e. particles surviving an intera...
constexpr int INVALID_VERTEX_ID
bool is_simulation_vertex(const T &v)
Method to establish if the vertex was created during simulation (only to be used in legacy TP convert...
Class describing a truth vertex in the MC record.
bool is_simulation_particle(const T &p)
Method to establish if a particle was created during the simulation based on the status value.
Class to store calorimeter calibration hit.
constexpr int SIM_STATUS_THRESHOLD
Constant definiting the status threshold for simulated particles, eg. can be used to separate generat...
void old_to_new_simulation_scheme(T &evt)
Function that converts the old scheme of labeling the simulation particles (barcodes) into the new sc...
bool is_same_generator_particle(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same generated particle.
bool is_truth_suppressed_pileup(const T &p)
Method to establish if a particle (or barcode) corresponds to truth-suppressed pile-up.
void get_particle_history(const T &p, std::deque< int > &out, const int direction=0)
Function to calculate all the descendants(direction=1)/ancestors(direction=-1) of the particle.
bool is_same_object(const T1 &p1, const T2 &p2)
Method to establish if two particles/vertices in the GenEvent actually represent the same generated p...
int maxGeneratedParticleBarcode(const HepMC::GenEvent *genEvent)
Get the maximal value of barcode of particle present in the event.
bool is_sim_descendant(const T1 &p1, const T2 &p2)
Method to check if the first particle is a descendant of the second in the simulation,...
typename remove_smart_pointer< T >::type remove_smart_pointer_t
bool is_sim_descendant(const T1 &p1, const T2 &p2)
Method to check if the first particle is a descendant of the second in the simulation,...
const HepMC::GenVertex * ConstGenVertexPtr
int generations(const T &p)
Method to return how many interactions a particle has undergone during simulation (TODO migrate to be...
bool is_truth_suppressed_pileup(const T &p)
Method to establish if a particle (or barcode) corresponds to truth-suppressed pile-up (TODO update t...
bool no_truth_link(const T &p)
Method to establish if a if the object is linked to something which was never saved to the HepMC Trut...
int new_particle_status_from_old(const int oldStatus, const int barcode)
Get particle status in the new scheme from the barcode and status in the old scheme.