 |
ATLAS Offline Software
|
Go to the documentation of this file.
26 std::unique_ptr< TChain >
31 std::unique_ptr< TChain >
chain;
33 R__LOCKGUARD( gROOTMutex );
38 chain->ResetBit( kMustCleanup );
52 template<
typename FIRST,
typename SECOND >
54 const std::pair< FIRST, SECOND >& pair ) {
56 out <<
"[" << pair.first <<
", " << pair.second <<
"]";
61 template<
typename T >
65 for(
size_t i = 0;
i <
vec.size(); ++
i ) {
67 if(
i + 1 <
vec.size() ) {
76 template<
typename T >
78 const std::unordered_map< T, T >& umap ) {
82 for(
auto& upair : umap ) {
86 out << upair.first <<
" : " << upair.second;
96 #define PRINT_VERBOSE(MSG) \
98 if( m_verboseOutput ) { \
99 std::cout << "xAOD::RDataSource VERBOSE " << MSG << std::endl; \
130 ::Error(
"xAOD::RDataSource::SetNSlots",
132 throw std::invalid_argument(
"Zero slots requested" );
135 ::Error(
"xAOD::RDataSource::SetNSlots",
137 throw std::runtime_error(
"Function called multiple times" );
145 <<
" slots for the chains, events and stores" );
148 for(
unsigned int i = 0;
i < slots; ++
i ) {
153 std::make_unique< RDataSourceEvent >(
m_auxmode ) );
154 m_stores.push_back( std::make_unique< TStore >() );
159 if( !
event->readFrom(
chain ).isSuccess() ) {
160 ::Error(
"xAOD::RDataSource::SetNSlots",
161 XAOD_MESSAGE(
"Failed to set up xAOD::RDataSourceEvent "
162 "for slot %u" ),
i );
163 throw std::runtime_error(
"Failed to set up "
164 "xAOD::RDataSourceEvent" );
172 if(
event->getEntry( 0 ) < 0 ) {
173 ::Error(
"xAOD::RDataSource::SetNSlots",
175 throw std::runtime_error(
"Failed to load entry for slot" );
180 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,35,99)
182 ROOT::RDF::RDataSource::SetNSlots( slots );
193 ::Fatal(
"xAOD::RDataSource::Initialize",
194 XAOD_MESSAGE(
"Function called on an initialized object" ) );
201 TObjArray* filesInChain =
chain->GetListOfFiles();
204 Long64_t fileOffset = 0;
208 const char*
fileName = filesInChain->At(
ifile )->GetTitle();
209 auto file = std::unique_ptr< TFile >( TFile::Open(
fileName,
211 if( ( !
file ) ||
file->IsZombie() ) {
212 ::Error(
"xAOD::RDataSource::Initialize",
214 throw std::runtime_error(
"Failed to open file: " +
230 TTree::TClusterIterator clusterIter(
tree->GetClusterIterator( 0 ) );
231 Long64_t clusterStart = 0;
232 while( ( clusterStart = clusterIter() ) <
entries ) {
235 clusterIter.GetNextEntry() );
251 ::Error(
"xAOD::RDataSource::InitSlot",
253 throw std::runtime_error(
"Invalid slot received" );
257 if(
m_events[ slot ]->getEntry( firstEntry ) < 0 ) {
258 ::Error(
"xAOD::RDataSource::InitSlot",
259 XAOD_MESSAGE(
"Failed to load entry %lld for slot %u" ),
261 throw std::runtime_error(
"Failed to load entry for slot" );
263 PRINT_VERBOSE(
"InitSlot: Retrieved entry " << firstEntry <<
" for slot "
269 PRINT_VERBOSE(
"InitSlot: Activated and cleared transient store for slot "
309 ::Error(
"xAOD::RDataSource::GetTypeName",
312 throw std::runtime_error(
"Column/object \"" + std::string(
column ) +
313 "\" not available" );
320 ::Fatal(
"xAOD::RDataSource::GetTypeName",
324 <<
"\" is: " << itr->second );
343 ::Error(
"xAOD::RDataSource::SetEntry",
345 throw std::runtime_error(
"Invalid slot received" );
347 PRINT_VERBOSE(
"SetEntry: Called for slot " << slot <<
" and entry "
383 RDataSource::Record_t
385 const std::type_info& typeInfo ) {
389 ::Error(
"xAOD::RDataSource::GetColumnReadersImpl",
392 throw std::runtime_error(
"Column/object \"" + std::string(
column ) +
393 "\" not available" );
395 PRINT_VERBOSE(
"GetColumnReadersImpl: Creating column readers for \""
412 if( !
event.readFrom(
chain.get() ).isSuccess() ) {
413 ::Error(
"xAOD::RDataSource::readInputMetadata",
414 XAOD_MESSAGE(
"Failed to connect to the input chain" ) );
415 throw std::runtime_error(
"Failed to connect to the input chain" );
419 if(
event.getEntries() > 0 ) {
420 if(
event.getEntry( 0 ) < 0 ) {
421 ::Error(
"xAOD::RDataSource::readInputMetadata",
422 "Couldn't load the first event of the input" );
423 throw std::runtime_error(
"Couldn't load the first event of the "
430 auto names =
event.columnAndTypeNames();
433 for(
const auto& pair : names ) {
def makeChain(flags, name, L1Thresholds, ChainSteps, Streams="physics:Main", Groups=["RATE:TestRateGroup", "BW:TestBW"])
virtual void FinalizeSlot(unsigned int slot) override final
Close the input file reading in one of the slots/threads.
RDataSource(std::string_view fileNameGlob, std::string_view treeName="CollectionTree")
Constructor with the file name pattern.
std::vector< std::unique_ptr< TStore > > m_stores
In-memory whiteboards used during the event loop.
std::string find(const std::string &s)
return a remapped string
Bool_t isVerboseOutput() const
Check whether verbose output is set up to be printed.
std::string normalizedTypeinfoName(const std::type_info &info)
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
virtual EntryRanges_t GetEntryRanges() override final
Get the entry ranges in the input file(s)
std::vector< std::string > m_fileNames
Files to read.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
std::vector< size_t > vec
std::vector< std::unique_ptr< TChain > > m_chains
Chains used in the file I/O.
std::unordered_map< std::string, std::string > m_classNameMap
The object name -> class name map.
std::vector< std::unique_ptr< RDataSourceEvent > > m_events
Event objects performing the file I/O.
virtual bool SetEntry(unsigned int slot, ULong64_t entry) override final
Set which entry a give slot/thread should be processing.
EntryRanges_t m_entryRanges
Optimal entry ranges to split the processing into.
Bool_t m_verboseOutput
Whether verbose output should be printed or not.
Data source for xAOD input files.
std::vector< std::string > m_columnNames
Names of the columns/objects on the input.
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.
virtual void Finalize() override final
Finalize the data source, after the event loop.
TEvent::EAuxMode auxMode() const
Get the auxiliary access mode.
virtual void Initialize() override final
Initialize the data source, before the start of the event loop.
void setAuxMode(TEvent::EAuxMode mode)
Set the auxiliary access mode.
virtual bool HasColumn(std::string_view name) const override final
Check if the dataset has a certain column/object.
std::vector< std::pair< ULong64_t, ULong64_t > > EntryRanges_t
Type describing the entry ranges of the input file(s)
void readInputMetadata()
Fill the metadata variables.
void setVerboseOutput(Bool_t value=kTRUE)
Set whether verbose output should be printed (for debugging)
#define PRINT_VERBOSE(MSG)
Helper macro for printing verbose messages for debugging.
std::string m_treeName
Name of the event tree in the input files.
EAuxMode
Auxiliary store "mode".
TEvent::EAuxMode m_auxmode
Auxiliary access mode.
virtual void InitSlot(unsigned int slot, ULong64_t firstEntry) override final
Initialize one of the slots/threads.
~RDataSource()
Destructor.
Extension to xAOD::TEvent, used by xAOD::RDataSource.
virtual const std::vector< std::string > & GetColumnNames() const override final
Get the column/object names for the input file(s)
virtual std::string GetTypeName(std::string_view column) const override final
Get the type name of a given column/object.
virtual void SetNSlots(unsigned int slots) override final
Set the number of threads/slots that the data source should use.
std::ostream & operator<<(std::ostream &out, const std::pair< FIRST, SECOND > &pair)
Helper print operator.