ATLAS Offline Software
ReaderAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 // Gaudi/Athena include(s):
8 
9 // Local include(s):
10 #include "ReaderAlg.h"
11 #include "IReaderD3PD.h"
12 
13 namespace D3PD {
14 
15  ReaderAlg::ReaderAlg( const std::string& name, ISvcLocator* svcloc )
16  : AthAlgorithm( name, svcloc ),
17  m_d3pdSvc( "D3PD::RootReaderD3PDSvc", name ),
18  m_tools( this ),
19  m_d3pd( 0 ),
20  m_booked( false ) {
21 
22  declareProperty( "D3PDSvc", m_d3pdSvc,
23  "The D3PD creation service." );
24  declareProperty( "Tools", m_tools,
25  "List of IObjFillerTool instances to run." );
26  declareProperty( "TuplePath", m_tuplePath = "dummy",
27  "The name of the tuple. The interpretation of this "
28  "depends on the D3PDSvc." );
29 
30  declareProperty( "Prefix", m_prefix = "",
31  "Common prefix to the D3PD variable names" );
32 
33  declareProperty( "Directory", m_dir = "./",
34  "Output directory for the generated sources" );
35  declareProperty( "ClassName", m_classname = "Dummy",
36  "Name of the C++ class to be generated" );
37  }
38 
40 
41  CHECK( m_d3pdSvc.retrieve() );
42  CHECK( m_tools.retrieve() );
43 
44  // Create a new D3PD:
45  ID3PD* d3pd = 0;
46  CHECK( m_d3pdSvc->make( m_tuplePath, d3pd ) );
47 
48  // Check that the service created the correct type of D3PD object:
49  m_d3pd = dynamic_cast< IReaderD3PD* >( d3pd );
50  if( ! m_d3pd ) {
51  REPORT_MESSAGE( MSG::ERROR ) << "The configured service ("
52  << m_d3pdSvc << ") did not create a "
53  << "D3PD::IReaderD3PD object!";
54  return StatusCode::FAILURE;
55  }
56 
57  // Configure the object:
59 
60  // Configure each tool.
61  for( size_t i = 0; i < m_tools.size(); ++i ) {
62  CHECK( m_tools[ i ]->configureD3PD( m_d3pd ) );
63  }
64 
65  m_booked = false;
66  return StatusCode::SUCCESS;
67  }
68 
70 
71  // Let the D3PD generate the source code that can read it back:
73 
74  return StatusCode::SUCCESS;
75  }
76 
78 
79  // Instruct all the tools to declare their variables to the D3PD object:
80  if( ! m_booked ) {
81  m_booked = true;
82  for( size_t i = 0; i < m_tools.size(); ++i ) {
83  CHECK( m_tools[ i ]->book() );
84  }
85  }
86 
87  return StatusCode::SUCCESS;
88  }
89 
90 } // namespace D3PD
D3PD::ReaderAlg::m_prefix
std::string m_prefix
Common variable name prefix.
Definition: ReaderAlg.h:66
D3PD::ReaderAlg::execute
virtual StatusCode execute()
Standard Gaudi execute method.
Definition: ReaderAlg.cxx:77
D3PD::IReaderD3PD::createReader
virtual StatusCode createReader(const std::string &classname, const std::string &dir="./") const =0
Function creating the D3PDReader code.
D3PD::ID3PD
Define an abstract interface for building a D3PD tree.
Definition: ID3PD.h:37
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
IReaderD3PD.h
D3PD::IReaderD3PD::setPrefix
virtual void setPrefix(const std::string &prefix)=0
Set the common prefix of the variables.
D3PD::ReaderAlg::m_tools
ToolHandleArray< IObjFillerTool > m_tools
Property: List of object filler tools to run.
Definition: ReaderAlg.h:61
D3PD::ReaderAlg::initialize
virtual StatusCode initialize()
Standard Gaudi initialize method.
Definition: ReaderAlg.cxx:39
D3PD
Block filler tool for noisy FEB information.
Definition: InnerDetector/InDetMonitoring/InDetGlobalMonitoring/macros/EnhancedPrimaryVertexMonitoring/TrigD3PD/ChainGroup.h:21
D3PD::ReaderAlg::m_d3pd
IReaderD3PD * m_d3pd
The created tuple. Note: we don't take ownership.
Definition: ReaderAlg.h:72
book
T * book(const std::string &n, const std::string &t, unsigned nbins)
Definition: main_benchmark.cxx:138
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::ReaderAlg::m_dir
std::string m_dir
Directory where the sources should be put.
Definition: ReaderAlg.h:68
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
D3PD::ReaderAlg::m_tuplePath
std::string m_tuplePath
Property: The tuple name.
Definition: ReaderAlg.h:64
AthAlgorithm
Definition: AthAlgorithm.h:47
D3PD::ReaderAlg::finalize
virtual StatusCode finalize()
Standard Gaudi finalize method.
Definition: ReaderAlg.cxx:69
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
D3PD::ReaderAlg::m_d3pdSvc
ServiceHandle< ID3PDSvc > m_d3pdSvc
Property: The D3PD creation service.
Definition: ReaderAlg.h:59
ReaderAlg.h
D3PD::ReaderAlg::m_booked
bool m_booked
Flag that we've called book().
Definition: ReaderAlg.h:74
D3PD::ReaderAlg::ReaderAlg
ReaderAlg(const std::string &name, ISvcLocator *svcloc)
Standard algorithm constructor.
Definition: ReaderAlg.cxx:15
D3PD::ReaderAlg::m_classname
std::string m_classname
Name of the generated class.
Definition: ReaderAlg.h:69
D3PD::IReaderD3PD
Common interface for the code generator D3PD classes.
Definition: IReaderD3PD.h:29