ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDMaker
EventCommonD3PDMaker
src
SkimDecisionFillerTool.cxx
Go to the documentation of this file.
1
// This file's extension implies that it's C, but it's really -*- C++ -*-.
2
3
/*
4
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5
*/
13
14
15
#include "
SkimDecisionFillerTool.h
"
16
#include "
AthenaKernel/errorcheck.h
"
17
#include "
EventBookkeeperMetaData/SkimDecisionCollection.h
"
18
19
20
namespace
D3PD
{
21
22
29
SkimDecisionFillerTool::SkimDecisionFillerTool
(
const
std::string&
type
,
30
const
std::string& name,
31
const
IInterface* parent )
32
:
BlockFillerTool
<
SkimDecisionCollection
>(
type
, name, parent ),
33
m_passed
(0)
34
{
35
declareProperty (
"Flags"
,
m_flags
,
36
"Specify variables to fill.\n\
37
This is a collection of strings of the form FLAG:VAR:DOCSTRING.\n\
38
FLAG is the name of the flag to fill.\n\
39
VAR is the name of the D3PD variable to fill. If left empty,\n\
40
FLAG will be used as the variable name.\n\
41
DOCSTRING is the documentation string to use for this variable."
);
42
43
declareProperty (
"AnyPassedName"
,
m_anyPassedName
,
44
"If set, this names a variable to be set to true\n\
45
if any flags in this block are true."
);
46
}
47
48
52
StatusCode
SkimDecisionFillerTool::book
()
53
{
54
m_vars
.reserve (
m_flags
.size());
55
for
(
const
std::string& s :
m_flags
) {
56
Var
var;
57
std::string::size_type ipos = s.find (
':'
);
58
var.key = s.substr (0, ipos);
59
std::string varname;
60
std::string docstring;
61
if
(ipos != std::string::npos) {
62
++ipos;
63
std::string::size_type jpos = s.find (
':'
, ipos);
64
if
(jpos != std::string::npos) {
65
varname = s.substr (ipos, jpos-ipos);
66
docstring = s.substr (jpos+1);
67
}
68
else
69
varname = s.substr (ipos);
70
}
71
if
(varname.empty())
72
varname = var.key;
73
var.val = 0;
74
m_vars
.push_back (std::move(var));
75
76
CHECK
(
addVariable
(varname,
m_vars
.back().val, docstring) );
77
}
78
79
if
(!
m_anyPassedName
.empty())
80
CHECK
(
addVariable
(
m_anyPassedName
,
m_passed
,
81
"True if any flags in this block were true."
) );
82
83
return
StatusCode::SUCCESS;
84
}
85
86
95
StatusCode
SkimDecisionFillerTool::fill
(
const
SkimDecisionCollection
& p)
96
{
97
for
(
const
SkimDecision
* s : p) {
98
for
(
Var
& v :
m_vars
) {
99
if
(s->isAccepted() && s->getName() == v.key) {
100
*v.val =
true
;
101
if
(
m_passed
)
102
*
m_passed
=
true
;
103
break
;
104
}
105
}
106
}
107
108
return
StatusCode::SUCCESS;
109
}
110
111
112
}
// namespace D3PD
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
SkimDecisionCollection.h
SkimDecisionFillerTool.h
Block filler tool for SkimDecisions. Fills one branch per flag.
D3PD::BlockFillerTool< SkimDecisionCollection >::addVariable
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Definition
AddVariable.cxx:85
D3PD::BlockFillerTool
Type-safe wrapper for block filler tools.
Definition
BlockFillerTool.h:65
D3PD::SkimDecisionFillerTool::SkimDecisionFillerTool
SkimDecisionFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
Definition
SkimDecisionFillerTool.cxx:29
D3PD::SkimDecisionFillerTool::m_flags
std::vector< std::string > m_flags
Property: List of decision flags to write.
Definition
SkimDecisionFillerTool.h:66
D3PD::SkimDecisionFillerTool::m_passed
bool * m_passed
Variable: Set to true if any of the specified flags passed.
Definition
SkimDecisionFillerTool.h:83
D3PD::SkimDecisionFillerTool::m_anyPassedName
std::string m_anyPassedName
Property: Name of a variable to set to true if any of the specified decision flags are true.
Definition
SkimDecisionFillerTool.h:70
D3PD::SkimDecisionFillerTool::fill
StatusCode fill(const SkimDecisionCollection &p)
Fill one block — type-safe version.
Definition
SkimDecisionFillerTool.cxx:95
D3PD::SkimDecisionFillerTool::m_vars
std::vector< Var > m_vars
List of variables being written.
Definition
SkimDecisionFillerTool.h:80
D3PD::SkimDecisionFillerTool::book
StatusCode book()
Book variables for this block.
Definition
SkimDecisionFillerTool.cxx:52
SkimDecisionCollection
Definition
SkimDecisionCollection.h:21
SkimDecision
Definition
SkimDecision.h:16
D3PD
Block filler tool for noisy FEB information.
Definition
CaloCellDetailsFillerTool.cxx:29
D3PD::SkimDecisionFillerTool::Var
Description of each variable being written.
Definition
SkimDecisionFillerTool.h:74
type
Generated on
for ATLAS Offline Software by
1.17.0