ATLAS Offline Software
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-2021 CERN for the benefit of the ATLAS collaboration
5 */
15 #include "SkimDecisionFillerTool.h"
18 
19 
20 namespace 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\
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 
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 (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
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
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
SkimDecisionCollection.h
D3PD::AddVariable::addVariable
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Add a variable to the tuple.
Definition: AddVariable.cxx:85
SkimDecisionFillerTool.h
Block filler tool for SkimDecisions. Fills one branch per flag.
D3PD::SkimDecisionFillerTool::book
StatusCode book()
Book variables for this block.
Definition: SkimDecisionFillerTool.cxx:52
SkimDecisionCollection
Definition: SkimDecisionCollection.h:21
D3PD::SkimDecisionFillerTool::m_vars
std::vector< Var > m_vars
List of variables being written.
Definition: SkimDecisionFillerTool.h:80
D3PD
Block filler tool for noisy FEB information.
Definition: InnerDetector/InDetMonitoring/InDetGlobalMonitoring/macros/EnhancedPrimaryVertexMonitoring/TrigD3PD/ChainGroup.h:21
D3PD::SkimDecisionFillerTool::fill
StatusCode fill(const SkimDecisionCollection &p)
Fill one block — type-safe version.
Definition: SkimDecisionFillerTool.cxx:95
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
test_pyathena.parent
parent
Definition: test_pyathena.py:15
D3PD::BlockFillerTool
Type-safe wrapper for block filler tools.
Definition: BlockFillerTool.h:68
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
errorcheck.h
Helpers for checking error return status codes and reporting errors.
D3PD::SkimDecisionFillerTool::Var
Description of each variable being written.
Definition: SkimDecisionFillerTool.h:74
python.PyAthena.v
v
Definition: PyAthena.py:157
LArG4AODNtuplePlotter.varname
def varname(hname)
Definition: LArG4AODNtuplePlotter.py:37
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
SkimDecision
Definition: SkimDecision.h:16
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_passed
bool * m_passed
Variable: Set to true if any of the specified flags passed.
Definition: SkimDecisionFillerTool.h:83
D3PD::SkimDecisionFillerTool::m_flags
std::vector< std::string > m_flags
Property: List of decision flags to write.
Definition: SkimDecisionFillerTool.h:66