ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigMonitoring
TrigIDR4Monitoring
src
AncestorFinder.h
Go to the documentation of this file.
1
11
12
13
#ifndef IDTPM2_ANCESTORFINDER_H
14
#define IDTPM2_ANCESTORFINDER_H
15
16
#include "
ConfiguredValue.h
"
17
18
#include <cmath>
19
20
23
24
namespace
IDTPM2
{
25
26
template
<
typename
T>
27
class
IFinder
{
28
29
public
:
30
31
virtual
~IFinder
() =
default
;
32
33
const
T*
findAncestor
(
const
T* t)
const
{
34
35
// reached the end ...
36
if
(!t)
return
0;
37
39
if
(
predicate
(t) )
return
t;
40
41
for
(
size_t
p=0 ; p<t->nParents() ; p++ ) {
42
const
T* parent = t->parent(p);
43
44
if
( parent==t )
continue
;
45
47
if
(
const
T* found =
findAncestor
(parent) )
return
found;
48
}
49
50
return
0;
51
}
52
53
virtual
bool
predicate
(
const
T* t )
const
= 0;
54
55
};
56
57
58
60
61
template
<
typename
T,
typename
Predicate>
62
class
GenericAncestorFinder
:
public
IFinder
<T> {
63
64
public
:
65
66
GenericAncestorFinder
( Predicate p ) :
m_predicate
(p) { }
67
68
bool
predicate
(
const
T* t )
const override
{
return
m_predicate
(t); }
69
70
private
:
71
72
Predicate
m_predicate
;
73
74
};
75
76
77
80
81
template
<
typename
T>
82
class
IPredicate
{
83
public
:
84
virtual
~IPredicate
() {}
85
virtual
bool
operator()
(
const
T* t)
const
= 0;
86
};
87
88
89
95
96
template
<
typename
T>
97
class
PdgIdHelper
:
public
IPredicate
<T> {
98
99
public
:
100
101
PdgIdHelper
(
int
pdgid) :
m_pdgid
(
std
::abs(pdgid)) {}
102
107
bool
operator()
(
const
T* t)
const
{
return
std::abs(t->pdgId()) ==
m_pdgid
; }
108
109
private
:
110
111
int
m_pdgid
;
112
113
};
114
115
116
117
template
<
typename
T>
118
class
PtHelper
:
public
IPredicate
<T> {
119
120
public
:
121
122
PtHelper
(
ConfiguredValue<float>
pt={} ) :
m_pt
(pt) {}
123
125
bool
operator()
(
const
T* t)
const
{
126
if
( std::abs(t->pt()) <
m_pt
)
return
false
;
127
return
true
;
128
}
129
130
private
:
131
132
ConfiguredValue<float>
m_pt
;
133
134
};
135
136
137
template
<
typename
T,
typename
U=T>
138
class
PtPdgIdHelper
:
public
IPredicate
<T> {
139
140
public
:
141
142
PtPdgIdHelper
(
ConfiguredValue<float>
pt={},
const
ConfiguredValue<int>
pdgid={}) :
143
m_pt
(pt),
m_pdgid
(pdgid) {}
144
146
bool
operator()
(
const
T* t)
const
{
147
if
( std::abs(t->pt()) <
m_pt
)
return
false
;
148
if
( std::abs(t->template as<U>()->pdgId()) !=
m_pdgid
)
return
false
;
149
return
true
;
150
}
151
152
private
:
153
154
ConfiguredValue<float>
m_pt
;
155
ConfiguredValue<int>
m_pdgid
;
156
157
};
158
159
160
161
165
166
template
<
typename
T>
167
class
PdgAncestorFinder
:
public
GenericAncestorFinder
<T, PdgIdHelper<T>> {
168
public
:
169
PdgAncestorFinder
(
int
i ) :
GenericAncestorFinder
<T,
PdgIdHelper
<T> >(
PdgIdHelper
<T>(i)) { }
170
};
171
172
173
174
180
181
template
<
typename
T,
typename
P=
bool
(*)(const T*)>
182
class
PredicateAncestorFinder
:
public
GenericAncestorFinder
<T, P> {
183
public
:
184
PredicateAncestorFinder
(
P
p ) :
GenericAncestorFinder
<T,
P
>(p) { }
185
};
186
187
188
189
194
195
template
<
typename
T>
196
class
HadronAncestorFinder
:
public
IFinder
<T> {
197
198
public
:
199
200
using
Predicate
= bool (T::*)()
const
;
201
202
HadronAncestorFinder
(
Predicate
p ) :
m_predicate
(p) { }
203
204
bool
predicate
(
const
T* t )
const override
{
return
(t->*
m_predicate
)(); }
205
206
private
:
207
208
Predicate
m_predicate
;
209
210
};
211
212
213
}
// namespace IDTPM2
214
215
216
#endif
// IDTPM2_ANCESTORFINDER_H
217
218
219
220
221
222
223
224
225
226
ConfiguredValue.h
P
static Double_t P(Double_t *tt, Double_t *par)
Definition
LArPhysWaveHECTool.cxx:280
IDTPM2::GenericAncestorFinder::m_predicate
Predicate m_predicate
Definition
AncestorFinder.h:72
IDTPM2::GenericAncestorFinder::GenericAncestorFinder
GenericAncestorFinder(Predicate p)
Definition
AncestorFinder.h:66
IDTPM2::GenericAncestorFinder::predicate
bool predicate(const T *t) const override
Definition
AncestorFinder.h:68
IDTPM2::HadronAncestorFinder::HadronAncestorFinder
HadronAncestorFinder(Predicate p)
Definition
AncestorFinder.h:202
IDTPM2::HadronAncestorFinder::Predicate
bool(T::*)() const Predicate
Definition
AncestorFinder.h:200
IDTPM2::HadronAncestorFinder::predicate
bool predicate(const T *t) const override
Definition
AncestorFinder.h:204
IDTPM2::HadronAncestorFinder::m_predicate
Predicate m_predicate
Definition
AncestorFinder.h:208
IDTPM2::IFinder
Definition
AncestorFinder.h:27
IDTPM2::IFinder::~IFinder
virtual ~IFinder()=default
IDTPM2::IFinder::findAncestor
const T * findAncestor(const T *t) const
Definition
AncestorFinder.h:33
IDTPM2::IFinder::predicate
virtual bool predicate(const T *t) const =0
IDTPM2::IPredicate
predicate base class, so we can take any predicates and store them on a vector or in a unique_ptr<IPr...
Definition
AncestorFinder.h:82
IDTPM2::IPredicate::~IPredicate
virtual ~IPredicate()
Definition
AncestorFinder.h:84
IDTPM2::IPredicate::operator()
virtual bool operator()(const T *t) const =0
IDTPM2::PdgAncestorFinder::PdgAncestorFinder
PdgAncestorFinder(int i)
Definition
AncestorFinder.h:169
IDTPM2::PdgIdHelper
and a specific PDG ID helper, so we can select particles of a particular type NB: this is a class,...
Definition
AncestorFinder.h:97
IDTPM2::PdgIdHelper::m_pdgid
int m_pdgid
Definition
AncestorFinder.h:111
IDTPM2::PdgIdHelper::operator()
bool operator()(const T *t) const
this is quite clever - if we want to pass in an actual class the if we defined operator() then for an...
Definition
AncestorFinder.h:107
IDTPM2::PdgIdHelper::PdgIdHelper
PdgIdHelper(int pdgid)
Definition
AncestorFinder.h:101
IDTPM2::PredicateAncestorFinder::PredicateAncestorFinder
PredicateAncestorFinder(P p)
Definition
AncestorFinder.h:184
IDTPM2::PtHelper::operator()
bool operator()(const T *t) const
this is quite clever - can pass the class instance and use it like a function
Definition
AncestorFinder.h:125
IDTPM2::PtHelper::PtHelper
PtHelper(ConfiguredValue< float > pt={})
Definition
AncestorFinder.h:122
IDTPM2::PtHelper::m_pt
ConfiguredValue< float > m_pt
Definition
AncestorFinder.h:132
IDTPM2::PtPdgIdHelper::operator()
bool operator()(const T *t) const
this is quite clever - can pass the class instance and use it like a function
Definition
AncestorFinder.h:146
IDTPM2::PtPdgIdHelper::PtPdgIdHelper
PtPdgIdHelper(ConfiguredValue< float > pt={}, const ConfiguredValue< int > pdgid={})
Definition
AncestorFinder.h:142
IDTPM2::PtPdgIdHelper::m_pt
ConfiguredValue< float > m_pt
Definition
AncestorFinder.h:154
IDTPM2::PtPdgIdHelper::m_pdgid
ConfiguredValue< int > m_pdgid
Definition
AncestorFinder.h:155
IDTPM2
Search the ancestor history, looking for an ancestor that satifies the predicate ....
Definition
AnalysisR4.h:31
std
STL namespace.
ConfiguredValue
Definition
ConfiguredValue.h:25
Generated on
for ATLAS Offline Software by
1.17.0