ATLAS Offline Software
PhysicsAnalysis
TopPhys
xAOD
TopEventSelectionTools
Root
JetNGhostSelector.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TopEventSelectionTools/JetNGhostSelector.h
"
6
7
namespace
top
{
8
JetNGhostSelector::JetNGhostSelector
(
const
std::string&
params
)
9
:
SignValueSelector
(
""
, parseType(
params
)) {
10
switch
(
m_type
) {
11
case
c
:
m_name
=
"JET_N_GHOST c"
+
SignValueSelector::name
();
12
break
;
13
14
case
C
:
m_name
=
"JET_N_GHOST C"
+
SignValueSelector::name
();
15
break
;
16
17
case
b
:
m_name
=
"JET_N_GHOST b"
+
SignValueSelector::name
();
18
break
;
19
20
case
B
:
m_name
=
"JET_N_GHOST B"
+
SignValueSelector::name
();
21
break
;
22
23
case
t
:
m_name
=
"JET_N_GHOST t"
+
SignValueSelector::name
();
24
break
;
25
26
case
W
:
m_name
=
"JET_N_GHOST W"
+
SignValueSelector::name
();
27
break
;
28
29
case
Z
:
m_name
=
"JET_N_GHOST Z"
+
SignValueSelector::name
();
30
break
;
31
32
case
H
:
m_name
=
"JET_N_GHOST H"
+
SignValueSelector::name
();
33
break
;
34
35
case
tau
:
m_name
=
"JET_N_GHOST tau"
+
SignValueSelector::name
();
36
break
;
37
38
case
Invalid
:
m_name
=
"JET_N_GHOST !!! INVALID !!"
;
39
break
;
40
}
41
checkMultiplicityIsInteger
();
42
}
43
44
std::string
JetNGhostSelector::parseType
(
const
std::string&
params
) {
45
// Initialise the type variable
46
m_type
=
Invalid
;
47
// Skip leading whitespace
48
std::size_t
pos
{
49
0
50
};
51
while
(
pos
<
params
.length() - 1 && std::isspace(
params
[
pos
])) {
52
++
pos
;
53
}
54
55
// list of allowed chars
56
static
const
std::vector<char> allowedChar = {
57
'c'
,
'C'
,
'b'
,
'B'
,
't'
,
'W'
,
'Z'
,
'H'
58
};
59
60
// check if the char is allowed
61
if
(
std::find
(allowedChar.begin(), allowedChar.end(),
params
[
pos
]) == allowedChar.end()) {
62
throw
std::invalid_argument {
63
"Cannot parse the type from the parameter string"
64
};
65
}
66
67
// process the char
68
if
(
pos
+ 1 <
params
.length() && std::isspace(
params
[
pos
+ 1 ])) {
69
m_type
=
static_cast<
Type
>
(
params
[
pos
]);
70
return
params
.substr(
pos
+ 2);
71
}
else
if
(
params
.compare(
pos
, 4,
"tau "
) == 0) {
72
m_type
=
tau
;
73
return
params
.substr(
pos
+ 4);
74
}
else
{
75
throw
std::invalid_argument {
76
"Cannot parse the type from the parameter string for the common configuration"
77
};
78
}
79
}
80
81
bool
JetNGhostSelector::applyParticleLevel
(
const
top::ParticleLevelEvent
& plEvent)
const
{
82
// If any of the required collections is a nullptr (i.e. has not been
83
// loaded) return false.
84
if
(!plEvent.
m_jets
) {
85
return
false
;
86
}
87
88
auto
func = [&](
const
xAOD::Jet
* truJetPtr) ->
bool
{
89
switch
(
m_type
) {
90
case
c
: {
91
return
truJetPtr->auxdata<
int
>(
"GhostCQuarksFinalCount"
);
92
}
93
94
case
C
: {
95
return
truJetPtr->auxdata<
int
>(
"GhostCHadronsFinalCount"
);
96
}
97
98
case
b
: {
99
return
truJetPtr->auxdata<
int
>(
"GhostBQuarksFinalCount"
);
100
}
101
102
case
B
: {
103
return
truJetPtr->auxdata<
int
>(
"GhostBHadronsFinalCount"
);
104
}
105
106
case
t
: {
107
return
truJetPtr->auxdata<
int
>(
"GhostTQuarksFinalCount"
);
108
}
109
110
case
W
: {
111
return
truJetPtr->auxdata<
int
>(
"GhostWBosonsCount"
);
112
}
113
114
case
Z
: {
115
return
truJetPtr->auxdata<
int
>(
"GhostZBosonsCount"
);
116
}
117
118
case
H
: {
119
return
truJetPtr->auxdata<
int
>(
"GhostHBosonsCount"
);
120
}
121
122
case
tau
: {
123
return
truJetPtr->auxdata<
int
>(
"GhostTausFinalCount"
);
124
}
125
126
default
:
/* No-Op */
return
0;
127
}
128
};
129
auto
count
= std::count_if(plEvent.
m_jets
->
begin
(), plEvent.
m_jets
->
end
(), func);
130
return
checkInt
(
count
,
value
());
131
}
132
133
std::string
JetNGhostSelector::name
()
const
{
134
return
m_name
;
135
}
136
}
top::SignValueSelector::checkInt
bool checkInt(int value, int cut) const
Compare a cut supplied by the user with the value calculated in the event.
Definition:
SignValueSelector.cxx:159
top::JetNGhostSelector::m_name
std::string m_name
Definition:
JetNGhostSelector.h:53
top
TopConfig A simple configuration that is NOT a singleton.
Definition:
AnalysisTrackingHelper.cxx:58
JetNGhostSelector.h
find
std::string find(const std::string &s)
return a remapped string
Definition:
hcg.cxx:135
top::JetNGhostSelector::t
@ t
Definition:
JetNGhostSelector.h:44
top::JetNGhostSelector::Invalid
@ Invalid
Definition:
JetNGhostSelector.h:49
top::ParticleLevelEvent::m_jets
const xAOD::JetContainer * m_jets
Pointer to truth level jets.
Definition:
ParticleLevelEvent.h:54
top::JetNGhostSelector::W
@ W
Definition:
JetNGhostSelector.h:45
top::JetNGhostSelector::b
@ b
Definition:
JetNGhostSelector.h:42
top::JetNGhostSelector::JetNGhostSelector
JetNGhostSelector(const std::string ¶ms)
Definition:
JetNGhostSelector.cxx:8
top::SignValueSelector
Many of the tools need a sign (>=) and a value (2).
Definition:
SignValueSelector.h:16
XMLtoHeader.count
count
Definition:
XMLtoHeader.py:85
top::JetNGhostSelector::Z
@ Z
Definition:
JetNGhostSelector.h:46
top::JetNGhostSelector::name
std::string name() const override
The name is generated in the constructor for this kind of tool.
Definition:
JetNGhostSelector.cxx:133
top::JetNGhostSelector::c
@ c
Definition:
JetNGhostSelector.h:40
top::JetNGhostSelector::B
@ B
Definition:
JetNGhostSelector.h:43
top::ParticleLevelEvent
Definition:
ParticleLevelEvent.h:24
top::JetNGhostSelector::tau
@ tau
Definition:
JetNGhostSelector.h:48
top::JetNGhostSelector::H
@ H
Definition:
JetNGhostSelector.h:47
xAODType
Definition:
ObjectType.h:13
top::SignValueSelector::checkMultiplicityIsInteger
void checkMultiplicityIsInteger()
Integers are annoying in C++.
Definition:
SignValueSelector.cxx:82
top::JetNGhostSelector::parseType
std::string parseType(const std::string ¶ms)
Definition:
JetNGhostSelector.cxx:44
top::SignValueSelector::value
double value() const
Get the cut value assigned in the constructor.
Definition:
SignValueSelector.cxx:94
python.LumiBlobConversion.pos
pos
Definition:
LumiBlobConversion.py:18
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
top::JetNGhostSelector::applyParticleLevel
bool applyParticleLevel(const top::ParticleLevelEvent &plEvent) const override
Apply on particle level.
Definition:
JetNGhostSelector.cxx:81
xAOD::Jet_v1
Class describing a jet.
Definition:
Jet_v1.h:57
top::JetNGhostSelector::C
@ C
Definition:
JetNGhostSelector.h:41
PowhegControl_ttFCNC_NLO.params
params
Definition:
PowhegControl_ttFCNC_NLO.py:226
top::SignValueSelector::name
virtual std::string name() const override
The name is generated in the constructor for this kind of tool.
Definition:
SignValueSelector.cxx:70
top::JetNGhostSelector::m_type
Type m_type
Definition:
JetNGhostSelector.h:51
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Generated on Fri Jul 5 2024 21:18:59 for ATLAS Offline Software by
1.8.18