ATLAS Offline Software
ContainerFlagFillerTool.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 // $Id$
16 
17 
18 namespace D3PD {
19 
20 
22  const std::string& name,
23  const IInterface* parent)
25  m_getters (this),
26  m_map (this, m_getters, m_allowMissing)
27 {
28  declareProperty ("FlagNames", m_flagNames,
29  "Names of the flags added to the D3PD."
30 "May be followed by a string of the form `@TYPE/KEY', in which case the "
31 "corresponding entry in Getters is automatically initialized (only available "
32 "when the Python configuration wrapper is used). May be followed by a "
33 "docstring following a colon.");
34  declareProperty ("Getters", m_getters,
35  "Getter tools for the INav4MomLinkContainer objects.");
36  declareProperty ("AllowMissing", m_allowMissing,
37  "If true, missing containers will not be considered errors.");
38 }
39 
40 
45 {
46  // Check that the configuration makes sense:
47  if( m_getters.size() != m_flagNames.size() ) {
49  << "Different number of getter tools and flags specified";
50  return StatusCode::FAILURE;
51  }
52 
54 
55  return StatusCode::SUCCESS;
56 }
57 
58 
68  const std::type_info& ti)
69 {
70  CHECK( m_map.configureD3PD (ti) );
72  return StatusCode::SUCCESS;
73 }
74 
75 
82 {
83  // Resize the flag vector to the right size:
84  m_flags.resize( m_flagNames.size(), 0 );
85 
86  // Book the flag variable(s):
87  for( size_t i = 0; i < m_flagNames.size(); ++i ) {
88  std::string flagname = m_flagNames[i];
89  std::string desc = "Was this object selected according to X criteria?";
90  std::string::size_type ipos = flagname.find (':');
91  if (ipos != std::string::npos) {
92  desc = flagname.substr (ipos+1, std::string::npos);
93  flagname.resize (ipos);
94  }
95  CHECK( addVariable (flagname, m_flags[ i ], desc) );
96  }
97 
98  return StatusCode::SUCCESS;
99 }
100 
101 
113  bool /*again = false*/)
114 {
115  if (m_flags.empty())
116  return StatusCode(EMPTY);
117 
118  CHECK( m_map.reset() );
119  for (size_t i = 0; i < m_flags.size(); i++)
120  *m_flags[i] = (m_map.findIndex (p, i) != -1);
121  return StatusCode::SUCCESS;
122 }
123 
124 
125 } // namespace D3PD
D3PD::IAddVariable
Common interface for adding a variable to a tuple.
Definition: IAddVariable.h:70
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
D3PD::IndexMap::findIndex
int findIndex(const void *p)
Find the index corresponding to an element.
Definition: IndexMap.cxx:255
D3PD::ContainerFlagFillerTool::fillUntyped
virtual StatusCode fillUntyped(const void *p, bool again=false)
Fill one block.
Definition: ContainerFlagFillerTool.cxx:112
D3PD::AddVariable::configureD3PD
StatusCode configureD3PD(IAddVariable *tree)
Configure the parent tree.
Definition: AddVariable.cxx:61
initialize
void initialize()
Definition: run_EoverP.cxx:894
tree
TChain * tree
Definition: tile_monitor.h:30
D3PD::IndexMap::reset
StatusCode reset()
Call before asking for an index. Rebuilds cache if needed.
Definition: IndexMap.cxx:227
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
D3PD::ContainerFlagFillerTool::initialize
virtual StatusCode initialize()
Function initializing the tool.
Definition: ContainerFlagFillerTool.cxx:44
D3PD
Block filler tool for noisy FEB information.
Definition: InnerDetector/InDetMonitoring/InDetGlobalMonitoring/macros/EnhancedPrimaryVertexMonitoring/TrigD3PD/ChainGroup.h:21
D3PD::ContainerFlagFillerTool::m_allowMissing
bool m_allowMissing
Property: If true, missing containers will not be considered errors.
Definition: ContainerFlagFillerTool.h:101
CaloCondBlobAlgs_fillNoiseFromASCII.desc
desc
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:54
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
D3PD::ContainerFlagFillerTool::configureD3PD
virtual StatusCode configureD3PD(IAddVariable *tree, const std::type_info &ti)
Configure during initialization: type-check.
Definition: ContainerFlagFillerTool.cxx:67
test_pyathena.parent
parent
Definition: test_pyathena.py:15
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
D3PD::ContainerFlagFillerTool::m_flags
std::vector< bool * > m_flags
Variables: The flags created in the D3PD.
Definition: ContainerFlagFillerTool.h:104
D3PD::ContainerFlagFillerTool::m_map
IndexMap m_map
Map to manage index lookups.
Definition: ContainerFlagFillerTool.h:107
D3PD::IndexMap::configureD3PD
StatusCode configureD3PD()
Configure during initialization: type-check.
Definition: IndexMap.cxx:137
D3PD::ContainerFlagFillerTool::m_getters
ToolHandleArray< ICollectionGetterTool > m_getters
Property: The container getters that are used to compute the flags.
Definition: ContainerFlagFillerTool.h:98
D3PD::ContainerFlagFillerTool::book
virtual StatusCode book()
Declare tuple variables.
Definition: ContainerFlagFillerTool.cxx:81
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
errorcheck.h
Helpers for checking error return status codes and reporting errors.
REPORT_MESSAGE
#define REPORT_MESSAGE(LVL)
Report a message.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:365
ContainerFlagFillerTool.h
Flag objects that are present in other containers.
D3PD::BlockFillerToolImpl
Non-template parts of BlockFillerTool.
Definition: BlockFillerToolImpl.h:44
D3PD::ContainerFlagFillerTool::m_flagNames
std::vector< std::string > m_flagNames
Property: The flag names.
Definition: ContainerFlagFillerTool.h:95
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
D3PD::ContainerFlagFillerTool::ContainerFlagFillerTool
ContainerFlagFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
Definition: ContainerFlagFillerTool.cxx:21