Loading [MathJax]/extensions/tex2jax.js
 |
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; \
115 m_verboseOutput( kFALSE ) {
131 ::Error(
"xAOD::RDataSource::SetNSlots",
133 throw std::invalid_argument(
"Zero slots requested" );
136 ::Error(
"xAOD::RDataSource::SetNSlots",
138 throw std::runtime_error(
"Function called multiple times" );
146 <<
" slots for the chains, events and stores" );
149 for(
unsigned int i = 0;
i < slots; ++
i ) {
153 m_events.push_back( std::make_unique< RDataSourceEvent >() );
154 m_stores.push_back( std::make_unique< TStore >() );
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" );
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 );
189 #if ROOT_VERSION_CODE < ROOT_VERSION(6,28,00)
190 void RDataSource::Initialise() {
197 ::Fatal(
"xAOD::RDataSource::Initialize",
198 XAOD_MESSAGE(
"Function called on an initialized object" ) );
205 TObjArray* filesInChain =
chain->GetListOfFiles();
208 Long64_t fileOffset = 0;
212 const char*
fileName = filesInChain->At(
ifile )->GetTitle();
213 auto file = std::unique_ptr< TFile >( TFile::Open(
fileName,
215 if( ( !
file ) ||
file->IsZombie() ) {
216 ::Error(
"xAOD::RDataSource::Initialize",
218 throw std::runtime_error(
"Failed to open file: " +
234 TTree::TClusterIterator clusterIter(
tree->GetClusterIterator( 0 ) );
235 Long64_t clusterStart = 0;
236 while( ( clusterStart = clusterIter() ) <
entries ) {
239 clusterIter.GetNextEntry() );
255 ::Error(
"xAOD::RDataSource::InitSlot",
257 throw std::runtime_error(
"Invalid slot received" );
261 if(
m_events[ slot ]->getEntry( firstEntry ) < 0 ) {
262 ::Error(
"xAOD::RDataSource::InitSlot",
263 XAOD_MESSAGE(
"Failed to load entry %lld for slot %u" ),
265 throw std::runtime_error(
"Failed to load entry for slot" );
267 PRINT_VERBOSE(
"InitSlot: Retrieved entry " << firstEntry <<
" for slot "
273 PRINT_VERBOSE(
"InitSlot: Activated and cleared transient store for slot "
280 #if ROOT_VERSION_CODE < ROOT_VERSION(6,28,00)
281 void RDataSource::FinaliseSlot(
unsigned int slot ) {
290 void RDataSource::Finalise() {
333 ::Error(
"xAOD::RDataSource::GetTypeName",
336 throw std::runtime_error(
"Column/object \"" + std::string(
column ) +
337 "\" not available" );
344 ::Fatal(
"xAOD::RDataSource::GetTypeName",
348 <<
"\" is: " << itr->second );
367 ::Error(
"xAOD::RDataSource::SetEntry",
369 throw std::runtime_error(
"Invalid slot received" );
371 PRINT_VERBOSE(
"SetEntry: Called for slot " << slot <<
" and entry "
396 RDataSource::Record_t
398 const std::type_info& typeInfo ) {
402 ::Error(
"xAOD::RDataSource::GetColumnReadersImpl",
405 throw std::runtime_error(
"Column/object \"" + std::string(
column ) +
406 "\" not available" );
408 PRINT_VERBOSE(
"GetColumnReadersImpl: Creating column readers for \""
426 ::Error(
"xAOD::RDataSource::readInputMetadata",
427 XAOD_MESSAGE(
"Failed to connect to the input chain" ) );
428 throw std::runtime_error(
"Failed to connect to the input chain" );
434 ::Error(
"xAOD::RDataSource::readInputMetadata",
435 "Couldn't load the first event of the input" );
436 throw std::runtime_error(
"Couldn't load the first event of the "
443 auto names =
event.columnAndTypeNames();
446 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.
StatusCode readFrom(TFile *file)
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.
POOL::TEvent event(POOL::TEvent::kClassAccess)
virtual void Finalize() override final
Finalize the data source, after the event loop.
virtual void Initialize() override final
Initialize the data source, before the start of the event loop.
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.
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.