ATLAS Offline Software
Loading...
Searching...
No Matches
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
18
19
20namespace D3PD {
21
22
30 const std::string& name,
31 const IInterface* parent )
33 m_passed (0)
34{
35 declareProperty ("Flags", m_flags,
36 "Specify variables to fill.\n\
37This is a collection of strings of the form FLAG:VAR:DOCSTRING.\n\
38FLAG is the name of the flag to fill.\n\
39VAR is the name of the D3PD variable to fill. If left empty,\n\
40FLAG will be used as the variable name.\n\
41DOCSTRING 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\
45if any flags in this block are true.");
46}
47
48
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())
81 "True if any flags in this block were true.") );
82
83 return StatusCode::SUCCESS;
84}
85
86
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
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
Block filler tool for SkimDecisions. Fills one branch per flag.
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Type-safe wrapper for block filler tools.
SkimDecisionFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
std::vector< std::string > m_flags
Property: List of decision flags to write.
bool * m_passed
Variable: Set to true if any of the specified flags passed.
std::string m_anyPassedName
Property: Name of a variable to set to true if any of the specified decision flags are true.
StatusCode fill(const SkimDecisionCollection &p)
Fill one block — type-safe version.
std::vector< Var > m_vars
List of variables being written.
StatusCode book()
Book variables for this block.
Block filler tool for noisy FEB information.
Description of each variable being written.