ATLAS Offline Software
Loading...
Searching...
No Matches
MagicNumbers.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4/* Author: Andrii Verbytskyi andrii.verbytskyi@mpp.mpg.de */
5
6#ifndef TRUTHUTILS_MAGICNUMBERS_H
7#define TRUTHUTILS_MAGICNUMBERS_H
8
9#include <limits>
10#include <cstdint>
11#include <memory>
12#include <algorithm>
13#include <deque>
14#include <type_traits>
15#if !defined(XAOD_STANDALONE)
16#include "AtlasHepMC/GenEvent.h"
19#endif
20namespace xAOD {
21 // Temporarily specialize for xAOD::Truth classes ahead of the barcode migration - TODO remove this
22 class TruthParticle_v1;
23 class TruthVertex_v1;
24}
25class TrackRecord;
28
29enum EBC_SUPPRESSED_TRUTH : unsigned char {
30 EBC_UNSUPPRESSED = 0, // Truth particle expected to be found in McEventCollection
31 EBC_PU_SUPPRESSED, // Link points to a suppressed pile-up truth particle do not attempt to resolve it.
33};
34
35namespace HepMC {
36
38 constexpr int SIM_BARCODE_THRESHOLD = 200000;
39
41 constexpr int SIM_REGENERATION_INCREMENT = 1000000;
42
44 constexpr int SIM_STATUS_INCREMENT = 100000;
45
47 constexpr int SIM_STATUS_THRESHOLD = 20000;
48
51
53 constexpr int SUPPRESSED_PILEUP_BARCODE(std::numeric_limits<int32_t>::max());
54
55 constexpr int INVALID_PARTICLE_BARCODE = -1;
56
57 constexpr int UNDEFINED_ID = 0;
58 constexpr int INVALID_PARTICLE_ID = -1;
59 constexpr int INVALID_VERTEX_ID = 1;
60
61 // TODO The definitions of is_smart_ptr and remove_smart_pointer
62 // below are probably too generic for this header, but putting them
63 // here initially.
64 template <typename T> struct is_smart_ptr : std::false_type {};
65 template <typename T> struct is_smart_ptr<std::shared_ptr<T>> : std::true_type {};
66 template <typename T> struct is_smart_ptr<std::unique_ptr<T>> : std::true_type {};
67 template <typename T> struct is_smart_ptr<std::weak_ptr<T>> : std::true_type {};
68 template <class T> inline constexpr bool is_smart_ptr_v = is_smart_ptr<T>::value;
69
70 template <class T> struct remove_smart_pointer { typedef T type; };
71 template <class T> struct remove_smart_pointer<std::shared_ptr<T>> { typedef T type; };
72 template <class T> struct remove_smart_pointer<std::unique_ptr<T>> { typedef T type; };
73 template <class T> struct remove_smart_pointer<std::weak_ptr<T>> { typedef T type; };
74 template <class T> using remove_smart_pointer_t = typename remove_smart_pointer<T>::type;
75
76#if defined(XAOD_STANDALONE)
77 // Needed as we can't pick up the helper functions from AtlasHepMC in this case
78 template <class T> inline int barcode(const T& p){
79 if constexpr (std::is_pointer_v<T> || is_smart_ptr_v<T>){ //T is ptr
80 return p->barcode();
81 }
82 else {
83 return p.barcode();
84 }
85 }
86 template <> inline int barcode(const int& p){ return p;}
87#endif
88 // Temporarily specialize uniqueID for xAOD::Truth classes ahead of the barcode migration - TODO remove this
89#if defined(HEPMC3)
90 template <typename T> inline int uniqueID(const T& p) {
91 if constexpr (std::is_integral_v<T>) {
92 return p;
93 }
94 else if constexpr (std::is_integral_v<std::remove_pointer_t<T>>) {
95 return *p;
96 }
97 else if constexpr (std::is_same_v<T, xAOD::TruthParticle_v1> || std::is_same_v<T, xAOD::TruthVertex_v1>) {
98 return p.uid();
99 }
100 else if constexpr (std::is_same_v<std::remove_const_t<remove_smart_pointer_t<std::remove_pointer_t<T>>>, xAOD::TruthParticle_v1> || std::is_same_v<std::remove_const_t<remove_smart_pointer_t<std::remove_pointer_t<T>>>, xAOD::TruthVertex_v1>) {
101 return p->uid();
102 }
103 else if constexpr (std::is_same_v<T, CaloCalibrationHit>) {
104 return p.particleUID();
105 }
106 else if constexpr (std::is_same_v<std::remove_const_t<remove_smart_pointer_t<std::remove_pointer_t<T>>>, CaloCalibrationHit>) {
107 return p->particleUID();
108 }
109 else if constexpr (std::is_pointer_v<T> || is_smart_ptr_v<T>){ //T is ptr
110 return p->id();
111 }
112 else {
113 return p.id();
114 }
115 }
116#else
117 template <typename T> inline int uniqueID(const T& p) {
118 if constexpr (std::is_integral_v<T>) {
119 return p;
120 }
121 else if constexpr (std::is_integral_v<std::remove_pointer_t<T>>) {
122 return *p;
123 }
124 else if constexpr (std::is_same_v<T, xAOD::TruthParticle_v1> || std::is_same_v<T, xAOD::TruthVertex_v1>) {
125 return p.uid();
126 }
127 else if constexpr (std::is_same_v<std::remove_const_t<remove_smart_pointer_t<std::remove_pointer_t<T>>>, xAOD::TruthParticle_v1> || std::is_same_v<std::remove_const_t<remove_smart_pointer_t<std::remove_pointer_t<T>>>, xAOD::TruthVertex_v1>) {
128 return p->uid();
129 }
130 else if constexpr (std::is_same_v<T, CaloCalibrationHit>) {
131 return p.particleUID();
132 }
133 else if constexpr (std::is_same_v<std::remove_const_t<remove_smart_pointer_t<std::remove_pointer_t<T>>>, CaloCalibrationHit>) {
134 return p->particleUID();
135 }
136 else if constexpr (std::is_pointer_v<T> || is_smart_ptr_v<T>){ //T is ptr
137 return p->barcode();
138 }
139 else {
140 return p.barcode();
141 }
142 }
143#endif
144 template <typename T> inline int status(const T& p) {
145 if constexpr (std::is_integral_v<T>) {
146 return p;
147 }
148 else if constexpr (std::is_integral_v<std::remove_pointer_t<T>>) {
149 return *p;
150 }
151 else if constexpr (std::is_pointer_v<T> || is_smart_ptr_v<T>){ //T is ptr
152 return p->status();
153 }
154 else {
155 return p.status();
156 }
157 }
158#if !defined(HEPMC3) && !defined(XAOD_STANDALONE)
159 template <> inline int status(const ConstGenVertexPtr& v1){ return v1->id();}
160 template <> inline int status(const GenVertexPtr& v1){ return v1->id();}
161#endif
162
164 template <class T> inline void get_particle_history(const T& p, std::deque<int>& out, const int direction = 0) {
165 if (direction < 0) {
166 if (p->status()>SIM_STATUS_INCREMENT) {
167 auto pv = p->production_vertex();
168 if (pv) {
169 for (auto pa: pv->particles_in()) {
170 if (!pa || pa->pdg_id() != p->pdg_id()) continue;
171 out.push_front(uniqueID(p));
172 get_particle_history(pa, out, -1);
173 break;
174 }
175 }
176 }
177 }
178 if (direction > 0) {
179 if (p->status()>SIM_STATUS_INCREMENT) {
180 auto pv = p->end_vertex();
181 if (pv) {
182 for (auto pa: pv->particles_out()) {
183 if (!pa || pa->pdg_id() != p->pdg_id()) continue;
184 out.push_back(uniqueID(p));
185 get_particle_history(pa, out, 1);
186 break;
187 }
188 }
189 }
190 }
191 }
192
193 template <class T> inline std::deque<int> simulation_history(const T& p, const int direction ) { std::deque<int> res; res.push_back(uniqueID(p)); get_particle_history(p, res, direction); return res;}
194
195 namespace BarcodeBased {
197 template <class T> inline bool is_truth_suppressed_pileup(const T& p){ return (barcode(p) == SUPPRESSED_PILEUP_BARCODE);}
198
200 template <class T> inline bool no_truth_link(const T& p){ return (barcode(p) == UNDEFINED_ID);}
201
203 template <class T> inline bool ignoreTruthLink(const T& p, bool vetoPileUp){ const int b = barcode(p); return no_truth_link(b) || (vetoPileUp && is_truth_suppressed_pileup(b)); }
204
206 template <class T> inline bool is_simulation_particle(const T& p){ return (barcode(p)>SIM_BARCODE_THRESHOLD);}
207
209 template <class T> inline bool is_sim_secondary(const T& p){ return (barcode(p)%SIM_REGENERATION_INCREMENT > SIM_BARCODE_THRESHOLD); }
210
212 template <class T> inline int generations(const T& p){ return (barcode(p)/SIM_REGENERATION_INCREMENT);}
213
215 template <class T> inline bool is_simulation_vertex(const T& v){ return (barcode(v)<-SIM_BARCODE_THRESHOLD);}
216
218 template <class T1, class T2> inline bool is_same_generator_particle(const T1& p1,const T2& p2) { int b1 = barcode(p1); int b2 = barcode(p2); return b1% SIM_REGENERATION_INCREMENT == b2 % SIM_REGENERATION_INCREMENT; }
219
221 template <class T1, class T2> inline bool is_same_object(const T1& p1,const T2& p2) { int b1 = uniqueID(p1); int b2 = uniqueID(p2); return b1 == b2; } // NB Still need to adapt CaloCalibrationHits
222
224 template <class T1, class T2> inline bool is_sim_descendant(const T1& p1,const T2& p2) { int b1 = barcode(p1); int b2 = barcode(p2); return b1 % SIM_REGENERATION_INCREMENT == b2;}
225 }
226
227 namespace StatusBased {
229 template <class T> inline bool is_truth_suppressed_pileup(const T& p){
230 if constexpr (std::is_same_v<std::remove_const_t<T>, HepMcParticleLink>) {
231 return p.getTruthSuppressionType() == EBC_PU_SUPPRESSED;
232 }
233 else if constexpr (std::is_same_v<std::remove_const_t<remove_smart_pointer_t<std::remove_pointer_t<T>>>, HepMcParticleLink>) {
234 return p->getTruthSuppressionType() == EBC_PU_SUPPRESSED;
235 }
236 else {
237 return p == EBC_PU_SUPPRESSED;
238 }
239 }
240
242 template <class T> inline bool no_truth_link(const T& p){
243 if constexpr (std::is_same_v<std::remove_const_t<T>, HepMcParticleLink>) {
244 return p.linkIsNull();
245 }
246 else if constexpr (std::is_same_v<std::remove_const_t<remove_smart_pointer_t<std::remove_pointer_t<T>>>, HepMcParticleLink>) {
247 return p->linkIsNull();
248 }
249 else {
250 return (uniqueID(p) == UNDEFINED_ID);
251 }
252 }
253
255 template <class T> inline bool ignoreTruthLink(const T& p, bool vetoPileUp){
256 if constexpr (std::is_same_v<std::remove_const_t<remove_smart_pointer_t<std::remove_pointer_t<T>>>, HepMcParticleLink>) {
257 return no_truth_link(p) || (vetoPileUp && is_truth_suppressed_pileup(p));
258 }
259 else {
260 const int u = uniqueID(p); return no_truth_link(u) || (vetoPileUp && is_truth_suppressed_pileup(u));
261 }
262 }
263
265 template <class T> inline bool is_simulation_particle(const T& p){ return (status(p)>SIM_STATUS_THRESHOLD);}
266
268 template <class T> inline bool is_sim_secondary(const T& p){ return (status(p)%SIM_STATUS_INCREMENT > SIM_STATUS_THRESHOLD); }
269
271 template <class T> inline int generations(const T& p){ return (status(p)/SIM_STATUS_INCREMENT);}
272
274 template <class T> inline bool is_simulation_vertex(const T& v){ return (status(v)>SIM_STATUS_THRESHOLD);}
275
277 template <class T1, class T2> inline bool is_same_generator_particle(const T1& p1,const T2& p2) {
278 const int id1 = uniqueID(p1);
279 const int id2 = uniqueID(p2);
280 if (id1 == id2) { return true;} // simplest case
281 const int generations1 = generations(p1);
282 const int generations2 = generations(p2);
283 if (generations1 == generations2) { return false; } // if the id values don't match and the particles have the same generation number then they cannot be the same particle.
284 if constexpr (std::is_same_v<std::remove_const_t<remove_smart_pointer_t<std::remove_pointer_t<T1>>>, TrackRecord>) {
285 // No choice, but to get the history of one of the particles:
286 const int direction = (generations2 > generations1) ? -1 : 1;
287 std::deque<int> history2 = simulation_history( p2, direction );
288 if (std::find(history2.begin(),history2.end(), id1) == history2.end()) { return false; }
289 }
290 else {
291 // No choice, but to get the history of one of the particles:
292 const int direction = (generations1 > generations2) ? -1 : 1;
293 std::deque<int> history1 = simulation_history( p1, direction );
294 if (std::find(history1.begin(),history1.end(), id2) == history1.end()) { return false; }
295 }
296 return true;
297 }
298
300 template <class T1, class T2> inline bool is_same_object(const T1& p1,const T2& p2) {
301 const int id1 = uniqueID(p1);
302 const int id2 = uniqueID(p2);
303 return (id1 == id2);
304 }
305
306
308 template <class T1, class T2> inline bool is_sim_descendant(const T1& p1,const T2& p2) {
309 const int id1 = uniqueID(p1);
310 const int id2 = uniqueID(p2);
311 if (id1 == id2) { return true;} // simplest case
312 const int generations1 = generations(p1);
313 const int generations2 = generations(p2);
314 if (generations1 == generations2) { return false; } // if the id values don't match and the particles have the same generation number then they cannot be the same particle.
315 if constexpr (std::is_same_v<std::remove_const_t<remove_smart_pointer_t<std::remove_pointer_t<T1>>>, TrackRecord>) {
316 // No choice, but to get the descendents of p2
317 constexpr int descendents = 1;
318 std::deque<int> history2 = simulation_history( p2, descendents );
319 if (std::find(history2.begin(),history2.end(), id1) == history2.end()) { return false; }
320 }
321 else {
322 // No choice, but to get the history of p1
323 constexpr int ancestors = -1;
324 std::deque<int> history1 = simulation_history( p1, ancestors );
325 if (std::find(history1.begin(),history1.end(), id2) == history1.end()) { return false; }
326 }
327 return true;
328 }
329 }
330
332 template <class T> inline bool is_truth_suppressed_pileup(const T& p){
333 if constexpr (std::is_same_v<std::remove_const_t<remove_smart_pointer_t<std::remove_pointer_t<T>>>, HepMcParticleLink>) {
335 }
336 else {
338 }
339 }
340
342 template <class T> inline bool no_truth_link(const T& p){ return StatusBased::no_truth_link(p);}
343
345 template <class T> inline bool ignoreTruthLink(const T& p, bool vetoPileUp){
346 if constexpr (std::is_same_v<std::remove_const_t<remove_smart_pointer_t<std::remove_pointer_t<T>>>, HepMcParticleLink>) {
347 return StatusBased::ignoreTruthLink(p, vetoPileUp);
348 }
349 else {
350 return BarcodeBased::ignoreTruthLink(p, vetoPileUp);
351 }
352 }
353
355 template <class T> inline bool is_simulation_particle(const T& p){ return StatusBased::is_simulation_particle(p);}
356
358 template <class T> inline int generations(const T& p){ return StatusBased::generations(p);}
359
361 template <class T> inline bool is_simulation_vertex(const T& v){ return StatusBased::is_simulation_vertex(v);}
362
364 template <class T1,class T2> inline bool is_same_generator_particle(const T1& p1,const T2& p2) { return StatusBased::is_same_generator_particle(p1, p2); }
365
367 template <class T1,class T2> inline bool is_same_particle(const T1& p1,const T2& p2) { return StatusBased::is_same_object(p1, p2); }
368
370 template <class T1,class T2> inline bool is_same_vertex(const T1& p1,const T2& p2) { return StatusBased::is_same_object(p1, p2); }
371
373 template <class T1,class T2> inline bool is_sim_descendant(const T1& p1,const T2& p2) { return StatusBased::is_sim_descendant(p1, p2);}
374
376 template <class T> void old_to_new_simulation_scheme(T& evt) {
377 auto particle_status = [] (int barcode, int status) {
381 return status;
382 };
383 auto vertex_status = [] (int barcode, int status) {
385 return status;
386 };
387#ifdef HEPMC3
388 for (auto p: evt->particles()) {
389 p->set_status (particle_status (HepMC::barcode(p), p->status()));
390 }
391 for (auto v: evt->vertices()) {
392 v->set_status (vertex_status (HepMC::barcode(v), v->status()));
393 }
394#else
395 for (auto p = evt->particles_begin(); p != evt->particles_end(); ++p) {
396 (*p)->set_status (particle_status ((*p)->barcode(), (*p)->status()));
397 }
398 for (auto v = evt->vertices_begin(); v != evt->vertices_end(); ++v) {
399 (*v)->set_id (vertex_status ((*v)->barcode(), (*v)->id()));
400 }
401#endif
402 }
403
405 inline int new_particle_status_from_old(const int oldStatus,const int barcode) {
406 int generations_barcode_based = (barcode/SIM_REGENERATION_INCREMENT);
407 bool is_sim_secondary_barcode_based = (barcode%SIM_REGENERATION_INCREMENT > SIM_BARCODE_THRESHOLD);
408 return oldStatus + SIM_STATUS_INCREMENT*generations_barcode_based + (is_sim_secondary_barcode_based? SIM_STATUS_THRESHOLD : 0);
409 }
410
412 inline int old_particle_status_from_new(const int newStatus) { return newStatus%SIM_STATUS_THRESHOLD; }
413
415 inline int new_vertex_status_from_old(const int oldStatus,const int barcode) {
416 bool is_simulation_vertex_barcode_based = (barcode<-SIM_BARCODE_THRESHOLD);
417 return (is_simulation_vertex_barcode_based? SIM_STATUS_THRESHOLD : 0) + oldStatus;
418 }
419
421 inline int old_vertex_status_from_new(const int newStatus) {
422 bool is_simulation_vertex_status_based = (newStatus>SIM_STATUS_THRESHOLD);
423 return ( is_simulation_vertex_status_based ? -SIM_STATUS_THRESHOLD : 0) + newStatus; }
424}
425#if !defined(XAOD_STANDALONE)
426namespace HepMC {
428inline int maxGeneratedParticleBarcode(const HepMC::GenEvent *genEvent) {
429 int maxBarcode = 0;
430#ifdef HEPMC3
431 auto allbarcodes = genEvent->attribute<HepMC::GenEventBarcodes>("barcodes");
432 for (const auto& bp: allbarcodes->barcode_to_particle_map()) {
433 if (!HepMC::BarcodeBased::is_simulation_particle(bp.first)) { maxBarcode=std::max(maxBarcode,bp.first); }
434 }
435#else
436 for (auto currentGenParticle: *genEvent) {
437 const int barcode=HepMC::barcode(currentGenParticle);
438 if (barcode > maxBarcode && !HepMC::BarcodeBased::is_simulation_particle(barcode)) { maxBarcode=barcode; }
439 }
440#endif
441 return maxBarcode;
442}
443
445inline int maxGeneratedVertexBarcode(const HepMC::GenEvent *genEvent) {
446 int maxBarcode=0;
447#ifdef HEPMC3
448 auto allbarcodes = genEvent->attribute<HepMC::GenEventBarcodes>("barcodes");
449 for (const auto& bp: allbarcodes->barcode_to_vertex_map()) {
450 if (!HepMC::BarcodeBased::is_simulation_vertex(bp.first)) { maxBarcode=std::min(maxBarcode,bp.first); }
451 }
452#else
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());
458 if (barcode < maxBarcode && !HepMC::BarcodeBased::is_simulation_vertex(barcode)) { maxBarcode=barcode; }
459 }
460#endif
461 return maxBarcode;
462}
463}
464#endif
465
466#endif
std::pair< std::vector< unsigned int >, bool > res
HWIdentifier id2
EBC_SUPPRESSED_TRUTH
@ EBC_NSUPP
@ EBC_PU_SUPPRESSED
@ EBC_UNSUPPRESSED
Class to store calorimeter calibration hit.
STL class.
Class describing a truth particle in the MC record.
Class describing a truth vertex in the MC record.
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...
bool is_sim_secondary(const T &p)
Method to establish if a particle (or barcode) is a new seondary created during the simulation (only ...
bool is_truth_suppressed_pileup(const T &p)
Method to establish if a particle (or barcode) corresponds to truth-suppressed pile-up.
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...
int generations(const T &p)
Method to return how many interactions a particle has undergone during simulation (only to be used in...
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 ignoreTruthLink(const T &p, bool vetoPileUp)
Helper function for SDO creation in PileUpTools.
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 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_descendant(const T1 &p1, const T2 &p2)
Method to check if the first particle is a descendant of the second in the simulation,...
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...
int generations(const T &p)
Method to return how many interactions a particle has undergone during simulation based on the status...
bool is_simulation_vertex(const T &v)
Method to establish if the vertex was created during simulation from the status.
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_truth_suppressed_pileup(const T &p)
Method to establish if a particle corresponds to truth-suppressed pile-up.
bool is_simulation_particle(const T &p)
Method to establish if a particle was created during the simulation based on the status value.
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 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,...
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 maxGeneratedVertexBarcode(const HepMC::GenEvent *genEvent)
Get the maximal absolute value of barcode of vertex present in the event. Returns a negative number.
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 INVALID_PARTICLE_ID
bool is_simulation_vertex(const T &v)
Method to establish if the vertex was created during simulation (TODO migrate to be based on status).
void old_to_new_simulation_scheme(T &evt)
Function that converts the old scheme of labeling the simulation particles (barcodes) into the new sc...
int barcode(const T *p)
Definition Barcode.h:16
int uniqueID(const T &p)
constexpr int UNDEFINED_ID
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.
typename remove_smart_pointer< T >::type remove_smart_pointer_t
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...
constexpr int INVALID_PARTICLE_BARCODE
constexpr int SIM_STATUS_INCREMENT
Constant defining the barcode threshold for regenerated particles, i.e. particles surviving an intera...
HepMC::GenVertex * GenVertexPtr
Definition GenVertex.h:59
constexpr int SIM_STATUS_THRESHOLD
Constant definiting the status threshold for simulated particles, eg. can be used to separate generat...
int status(const T &p)
bool is_same_particle(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same particle.
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.
int old_vertex_status_from_new(const int newStatus)
Get vertex status in the old scheme from the status in the new scheme.
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...
int maxGeneratedParticleBarcode(const HepMC::GenEvent *genEvent)
Get the maximal value of barcode of particle present in the event.
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...
constexpr int INVALID_VERTEX_ID
constexpr int FORWARD_TRANSPORT_MODEL_PROCESS
Special Forward transport Geant process for vertices.
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.
constexpr bool is_smart_ptr_v
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.
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_same_vertex(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same vertex.
int generations(const T &p)
Method to return how many interactions a particle has undergone during simulation (TODO migrate to be...
constexpr int SIM_BARCODE_THRESHOLD
Constant defining the barcode threshold for simulated particles, eg. can be used to separate generato...
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
Definition GenVertex.h:60
bool ignoreTruthLink(const T &p, bool vetoPileUp)
Helper function for SDO creation in PileUpTools.
constexpr int SIM_REGENERATION_INCREMENT
Constant defining the barcode threshold for regenerated particles, i.e. particles surviving an intera...
STL namespace.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.