ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Generators
TruthUtils
TruthUtils
DecayProducts.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 TRUTHUTILS_DECAYPRODUCTS_H
5
#define TRUTHUTILS_DECAYPRODUCTS_H
6
#include <vector>
7
#include <type_traits>
8
#include <algorithm>
9
#include <map>
10
#include <vector>
13
template
<
class
T>
class
DecayBase
{
14
public
:
15
void
count
(
const
int
c) {
m_pids
[c]++;
m_apids
[std::abs(c)]++;
m_size
++;}
16
int
pd
(
int
i)
const
{
return
m_pids
.count(i)?
m_pids
.at(i):0; }
17
int
pd
(
int
i1,
int
i2)
const
{
int
ret = 0;
for
(
auto
&
a
:
m_pids
)
if
(i1 <=
a
.first &&
a
.first <= i2) ret +=
a
.second;
return
ret; }
18
int
apd
(
int
i1,
int
i2)
const
{
int
ret = 0;
for
(
auto
&
a
:
m_apids
)
if
(i1 <=
a
.first &&
a
.first <= i2) ret +=
a
.second;
return
ret; }
19
int
apd
(
int
i)
const
{
return
m_apids
.count(i)?
m_apids
.at(i):0; }
20
int
pd
(
const
std::vector<int>& i)
const
{
int
ret = 0;
for
(
auto
ii: i) ret +=
pd
(ii);
return
ret;}
21
int
apd
(
const
std::vector<int>& i)
const
{
int
ret = 0;
for
(
auto
ii: i) ret +=
apd
(ii);
return
ret; }
22
size_t
size
()
const
{
return
m_size
; }
23
int
apply
(
bool
(*func)(
const
int
&))
const
{
int
ret = 0;
for
(
auto
&
a
:
m_pids
)
if
(func(
a
.first)) ret+=
a
.second;
return
ret; }
24
std::map<int,int>
m_pids
;
25
std::map<int,int>
m_apids
;
26
size_t
m_size
= 0;
27
};
28
#ifdef ATLASHEPMC_GENEVENT_H
29
#ifdef ATLASHEPMC_GENPARTICLE_H
30
template <class Y, std::enable_if_t<std::is_same<Y, HepMC::GenParticlePtr>::value ||std::is_same<Y, HepMC::ConstGenParticlePtr>::value,
bool
> =
true
>
31
DecayBase<Y>
DecayProducts(
const
Y& p) {
32
DecayBase<Y>
t;
33
auto
v = p->end_vertex();
34
if
(v)
for
(
auto
prod: *v)
if
(prod) t.count(prod->pdg_id());
35
return
t;
36
}
37
#endif
38
#ifdef ATLASHEPMC_GENVERTEX_H
39
template <class Y, std::enable_if_t<std::is_same<Y, HepMC::GenVertexPtr>::value ||std::is_same<Y, HepMC::ConstGenVertexPtr>::value,
bool
> =
true
>
40
DecayBase<Y>
DecayProducts(
const
Y& p) {
41
DecayBase<Y>
t
;
42
if
(p)
for
(
auto
prod: *p)
if
(prod)
t
.count(prod->pdg_id());
43
return
t
;
44
}
45
#endif
46
#endif
47
#ifdef XAODTRUTH_TRUTHPARTICLE_H
48
template <class Y, std::enable_if_t<std::is_same<Y, xAOD::TruthParticle>::value,
bool
> =
true
>
49
DecayBase<Y>
DecayProducts(
const
Y& p) {
50
DecayBase<Y>
t
;
51
auto
v
=
p
.end_vertex();
52
if
(v)
for
(
auto
prod:
v
->particles_out())
if
(prod)
t
.count(prod->pdg_id());
53
return
t
;
54
}
55
template <class Y, std::enable_if_t<std::is_same<Y, xAOD::TruthParticle*>::value || std::is_same<Y, xAOD::TruthParticle const*>::value,
bool
> =
true
>
56
DecayBase<Y>
DecayProducts(
const
Y& p) {
57
DecayBase<Y>
t
;
58
auto
v
=
p
->end_vertex();
59
if
(v)
for
(
auto
prod:
v
->particles_out())
if
(prod)
t
.count(prod->pdg_id());
60
return
t
;
61
}
62
template
<
class
Y, std::enable_if_t<std::is_same<Y, std::vector<const xAOD::TruthParticle*> >::value,
bool
> = true>
63
DecayBase<Y>
DecayProducts(
const
Y& p) {
64
DecayBase<Y>
t
;
65
for
(
auto
prod: p)
if
(prod)
t
.count(prod->pdg_id());
66
return
t
;
67
}
68
#endif
69
#ifdef XAODTRUTH_TRUTHVERTEX_H
70
template <class Y, std::enable_if_t<std::is_same<Y, xAOD::TruthVertex*>::value || std::is_same<Y, xAOD::TruthVertex const*>::value,
bool
> =
true
>
71
DecayBase<Y>
DecayProducts(
const
Y& p) {
72
DecayBase<Y>
t
;
73
if
(p)
for
(
auto
prod:
p
->particles_out())
if
(prod)
t
.count(prod->pdg_id());
74
return
t
;
75
}
76
#endif
77
#endif
a
static Double_t a
Definition
LArPhysWaveHECTool.cxx:38
DecayBase
A class that allows for a fast calculation of the flavours of the descendants of a vertex,...
Definition
DecayProducts.h:13
DecayBase::apply
int apply(bool(*func)(const int &)) const
Definition
DecayProducts.h:23
DecayBase::pd
int pd(int i1, int i2) const
Definition
DecayProducts.h:17
DecayBase::apd
int apd(int i) const
Definition
DecayProducts.h:19
DecayBase::apd
int apd(const std::vector< int > &i) const
Definition
DecayProducts.h:21
DecayBase::count
void count(const int c)
Definition
DecayProducts.h:15
DecayBase::pd
int pd(int i) const
Definition
DecayProducts.h:16
DecayBase::m_size
size_t m_size
Definition
DecayProducts.h:26
DecayBase::m_apids
std::map< int, int > m_apids
Definition
DecayProducts.h:25
DecayBase::apd
int apd(int i1, int i2) const
Definition
DecayProducts.h:18
DecayBase::pd
int pd(const std::vector< int > &i) const
Definition
DecayProducts.h:20
DecayBase::m_pids
std::map< int, int > m_pids
Definition
DecayProducts.h:24
DecayBase::size
size_t size() const
Definition
DecayProducts.h:22
python.PyAthena.v
v
Definition
PyAthena.py:153
python.utils.AtlRunQueryDQUtils.p
p
Definition
AtlRunQueryDQUtils.py:209
read_hist_ntuple.t
t
Definition
read_hist_ntuple.py:8
Generated on
for ATLAS Offline Software by
1.17.0