ATLAS Offline Software
RDataSource.h
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 //
3 // Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
4 //
5 #ifndef XAODDATASOURCE_RDATASOURCE_H
6 #define XAODDATASOURCE_RDATASOURCE_H
7 
8 // Local include(s).
9 #include "RDataSourceEvent.h"
10 
11 // Framework include(s).
12 #include "xAODRootAccess/TStore.h"
13 
14 // ROOT include(s).
15 #include <ROOT/RDataSource.hxx>
16 #include <ROOT/RStringView.hxx>
17 #include <TChain.h>
18 
19 // System include(s).
20 #include <memory>
21 #include <string>
22 #include <unordered_map>
23 #include <vector>
24 
25 namespace xAOD {
26 
35  class RDataSource final : public ROOT::RDF::RDataSource {
36 
37  public:
39  RDataSource( std::string_view fileNameGlob,
40  std::string_view treeName = "CollectionTree" );
42  RDataSource( const std::vector< std::string >& fileNames,
43  std::string_view treeName = "CollectionTree" );
45  ~RDataSource();
46 
48  typedef std::vector< std::pair< ULong64_t, ULong64_t > > EntryRanges_t;
49 
52 
54  virtual void SetNSlots( unsigned int slots ) override final;
56 #if ROOT_VERSION_CODE < ROOT_VERSION(6,28,0)
57  virtual void Initialise() override final;
58 #else
59  virtual void Initialize() override final;
60 #endif
61  virtual void
63  InitSlot( unsigned int slot, ULong64_t firstEntry ) override final;
64 
65 #if ROOT_VERSION_CODE < ROOT_VERSION(6,28,0)
66  virtual void FinaliseSlot( unsigned int slot ) override final;
69  virtual void Finalise() override final;
70 #else
71  virtual void FinalizeSlot( unsigned int slot ) override final;
74  virtual void Finalize() override final;
75 #endif
76 
78  virtual const std::vector< std::string >&
79  GetColumnNames() const override final;
81  virtual bool HasColumn( std::string_view name ) const override final;
83  virtual std::string
84  GetTypeName( std::string_view column ) const override final;
85 
87  virtual EntryRanges_t GetEntryRanges() override final;
89  virtual bool
90  SetEntry( unsigned int slot, ULong64_t entry ) override final;
91 
93 
95  void setVerboseOutput( Bool_t value = kTRUE );
97  Bool_t isVerboseOutput() const;
98 
99  private:
101  virtual Record_t
102  GetColumnReadersImpl( std::string_view column,
103  const std::type_info& typeInfo ) override final;
105  void readInputMetadata();
106 
109 
111  std::vector< std::string > m_fileNames;
113  std::string m_treeName;
116 
118 
121 
123  std::vector< std::string > m_columnNames;
125  std::unordered_map< std::string, std::string > m_classNameMap;
126 
128 
131 
134 
136 
139 
141  std::vector< std::unique_ptr< TChain > > m_chains;
143  std::vector< std::unique_ptr< RDataSourceEvent > > m_events;
145  std::vector< std::unique_ptr< TStore > > m_stores;
146 
148 
149  }; // class RDataSource
150 
151 } // namespace xAOD
152 
153 #endif // XAODDATASOURCE_RDATASOURCE_H
xAOD::RDataSource::FinalizeSlot
virtual void FinalizeSlot(unsigned int slot) override final
Close the input file reading in one of the slots/threads.
Definition: RDataSource.cxx:294
xAOD::RDataSource::RDataSource
RDataSource(std::string_view fileNameGlob, std::string_view treeName="CollectionTree")
Constructor with the file name pattern.
Definition: RDataSource.cxx:105
xAOD::name
name
Definition: TriggerMenuJson_v1.cxx:29
xAOD::RDataSource::m_stores
std::vector< std::unique_ptr< TStore > > m_stores
In-memory whiteboards used during the event loop.
Definition: RDataSource.h:145
checkxAOD.fileNames
fileNames
Definition: Tools/PyUtils/bin/checkxAOD.py:79
xAOD::RDataSource::isVerboseOutput
Bool_t isVerboseOutput() const
Check whether verbose output is set up to be printed.
Definition: RDataSource.cxx:386
xAOD::RDataSource::GetEntryRanges
virtual EntryRanges_t GetEntryRanges() override final
Get the entry ranges in the input file(s)
Definition: RDataSource.cxx:347
xAOD::RDataSource::m_fileNames
std::vector< std::string > m_fileNames
Files to read.
Definition: RDataSource.h:111
DeMoUpdate.column
dictionary column
Definition: DeMoUpdate.py:1110
athena.value
value
Definition: athena.py:124
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::RDataSource::m_chains
std::vector< std::unique_ptr< TChain > > m_chains
Chains used in the file I/O.
Definition: RDataSource.h:141
xAOD::RDataSource::m_classNameMap
std::unordered_map< std::string, std::string > m_classNameMap
The object name -> class name map.
Definition: RDataSource.h:125
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
xAOD::RDataSource::m_events
std::vector< std::unique_ptr< RDataSourceEvent > > m_events
Event objects performing the file I/O.
Definition: RDataSource.h:143
xAOD::RDataSource::m_entryRanges
EntryRanges_t m_entryRanges
Optimal entry ranges to split the processing into.
Definition: RDataSource.h:133
xAOD::RDataSource::m_verboseOutput
Bool_t m_verboseOutput
Whether verbose output should be printed or not.
Definition: RDataSource.h:115
xAOD::RDataSource
Data source for xAOD input files.
Definition: RDataSource.h:35
xAOD::RDataSource::m_columnNames
std::vector< std::string > m_columnNames
Names of the columns/objects on the input.
Definition: RDataSource.h:123
xAOD::RDataSource::GetColumnReadersImpl
virtual Record_t GetColumnReadersImpl(std::string_view column, const std::type_info &typeInfo) override final
Return the type-erased vector of pointers to pointers to column values.
Definition: RDataSource.cxx:392
vector
Definition: MultiHisto.h:13
xAOD::RDataSource::Finalize
virtual void Finalize() override final
Finalize the data source, after the event loop.
Definition: RDataSource.cxx:303
dumpFileToPlots.treeName
string treeName
Definition: dumpFileToPlots.py:20
xAOD::RDataSource::Initialize
virtual void Initialize() override final
Initialize the data source, before the start of the event loop.
Definition: RDataSource.cxx:187
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
xAOD::RDataSource::HasColumn
virtual bool HasColumn(std::string_view name) const override final
Check if the dataset has a certain column/object.
Definition: RDataSource.cxx:318
xAOD::RDataSource::EntryRanges_t
std::vector< std::pair< ULong64_t, ULong64_t > > EntryRanges_t
Type describing the entry ranges of the input file(s)
Definition: RDataSource.h:48
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
xAOD::RDataSource::readInputMetadata
void readInputMetadata()
Fill the metadata variables.
Definition: RDataSource.cxx:415
xAOD::RDataSource::setVerboseOutput
void setVerboseOutput(Bool_t value=kTRUE)
Set whether verbose output should be printed (for debugging)
Definition: RDataSource.cxx:380
SetEntry
struct _SetEntry SetEntry
Internal structure representing an entry in the set.
Definition: set.h:73
xAOD::RDataSource::m_treeName
std::string m_treeName
Name of the event tree in the input files.
Definition: RDataSource.h:113
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition: TStore.h:44
xAOD::RDataSource::InitSlot
virtual void InitSlot(unsigned int slot, ULong64_t firstEntry) override final
Initialize one of the slots/threads.
Definition: RDataSource.cxx:246
xAOD::RDataSource::~RDataSource
~RDataSource()
Destructor.
Definition: RDataSource.cxx:120
xAOD::RDataSourceEvent
Extension to xAOD::TEvent, used by xAOD::RDataSource.
Definition: RDataSourceEvent.h:31
xAOD::RDataSource::GetColumnNames
virtual const std::vector< std::string > & GetColumnNames() const override final
Get the column/object names for the input file(s)
Definition: RDataSource.cxx:313
RDataSourceEvent.h
xAOD::RDataSource::GetTypeName
virtual std::string GetTypeName(std::string_view column) const override final
Get the type name of a given column/object.
Definition: RDataSource.cxx:324
TStore.h
xAOD::RDataSource::SetNSlots
virtual void SetNSlots(unsigned int slots) override final
Set the number of threads/slots that the data source should use.
Definition: RDataSource.cxx:127