|
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;
63 template <
typename T>
struct is_smart_ptr<std::shared_ptr<T>> : std::true_type {};
64 template <
typename T>
struct is_smart_ptr<std::unique_ptr<T>> : std::true_type {};
65 template <
typename T>
struct is_smart_ptr<std::weak_ptr<T>> : std::true_type {};
74 #if defined(XAOD_STANDALONE)
76 template <
class T>
inline int barcode(
const T&
p){
77 if constexpr (std::is_pointer_v<T> || is_smart_ptr_v<T>){
84 template <>
inline int barcode(
const int&
p){
return p;}
88 template <
typename T>
inline int uniqueID(
const T&
p) {
89 if constexpr (std::is_integral_v<T>) {
92 else if constexpr (std::is_integral_v<std::remove_pointer_t<T>>) {
95 else if constexpr (std::is_same_v<T, xAOD::TruthParticle_v1> || std::is_same_v<T, xAOD::TruthVertex_v1>) {
101 else if constexpr (std::is_pointer_v<T> || is_smart_ptr_v<T>){
110 if constexpr (std::is_integral_v<T>) {
113 else if constexpr (std::is_integral_v<std::remove_pointer_t<T>>) {
116 else if constexpr (std::is_pointer_v<T> || is_smart_ptr_v<T>){
125 template <
typename T>
inline int status(
const T&
p) {
126 if constexpr (std::is_integral_v<T>) {
129 else if constexpr (std::is_integral_v<std::remove_pointer_t<T>>) {
132 else if constexpr (std::is_same_v<T, xAOD::TruthVertex_v1>) {
138 else if constexpr (std::is_pointer_v<T> || is_smart_ptr_v<T>){
145 #if !defined(HEPMC3) && !defined(XAOD_STANDALONE)
154 auto pv =
p->production_vertex();
156 for (
auto pa:
pv->particles_in()) {
157 if (pa->pdg_id() !=
p->pdg_id())
continue;
167 auto pv =
p->end_vertex();
169 for (
auto pa:
pv->particles_out()) {
170 if (pa->pdg_id() !=
p->pdg_id())
continue;
182 namespace BarcodeBased {
214 namespace StatusBased {
231 return p.linkIsNull();
234 return p->linkIsNull();
267 if (id1 ==
id2) {
return true;}
270 if (generations1 == generations2) {
return false; }
273 const int direction = (generations2 > generations1) ? -1 : 1;
275 if (
std::find(history2.begin(),history2.end(), id1) == history2.end()) {
return false; }
279 const int direction = (generations1 > generations2) ? -1 : 1;
281 if (
std::find(history1.begin(),history1.end(),
id2) == history1.end()) {
return false; }
298 if (id1 ==
id2) {
return true;}
301 if (generations1 == generations2) {
return false; }
304 constexpr
int descendents = 1;
306 if (
std::find(history2.begin(),history2.end(), id1) == history2.end()) {
return false; }
310 constexpr
int ancestors = -1;
312 if (
std::find(history1.begin(),history1.end(),
id2) == history1.end()) {
return false; }
375 for (
auto p:
evt->particles()) {
378 for (
auto v:
evt->vertices()) {
382 for (
auto p =
evt->particles_begin();
p !=
evt->particles_end(); ++
p) {
383 (*p)->set_status (particle_status ((*p)->barcode(), (*p)->status()));
385 for (
auto v =
evt->vertices_begin();
v !=
evt->vertices_end(); ++
v) {
386 (*v)->set_id (vertex_status ((*v)->barcode(), (*v)->id()));
412 #if !defined(XAOD_STANDALONE)
418 auto allbarcodes = genEvent->attribute<HepMC::GenEventBarcodes>(
"barcodes");
419 for (
const auto& bp: allbarcodes->barcode_to_particle_map()) {
423 for (
auto currentGenParticle: *genEvent) {
435 auto allbarcodes = genEvent->attribute<HepMC::GenEventBarcodes>(
"barcodes");
436 for (
const auto& bp: allbarcodes->barcode_to_vertex_map()) {
440 HepMC::GenEvent::vertex_const_iterator currentGenVertexIter;
441 for (currentGenVertexIter= genEvent->vertices_begin();
442 currentGenVertexIter!= genEvent->vertices_end();
443 ++currentGenVertexIter) {
444 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.
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.