|
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" );
184 #if ROOT_VERSION_CODE < ROOT_VERSION(6,28,00)
185 void RDataSource::Initialise() {
192 ::Fatal(
"xAOD::RDataSource::Initialize",
193 XAOD_MESSAGE(
"Function called on an initialized object" ) );
200 TObjArray* filesInChain =
chain->GetListOfFiles();
203 Long64_t fileOffset = 0;
207 const char*
fileName = filesInChain->At(
ifile )->GetTitle();
208 auto file = std::unique_ptr< TFile >( TFile::Open(
fileName,
210 if( ( !
file ) ||
file->IsZombie() ) {
211 ::Error(
"xAOD::RDataSource::Initialize",
213 throw std::runtime_error(
"Failed to open file: " +
229 TTree::TClusterIterator clusterIter(
tree->GetClusterIterator( 0 ) );
230 Long64_t clusterStart = 0;
231 while( ( clusterStart = clusterIter() ) <
entries ) {
234 clusterIter.GetNextEntry() );
250 ::Error(
"xAOD::RDataSource::InitSlot",
252 throw std::runtime_error(
"Invalid slot received" );
256 if(
m_events[ slot ]->getEntry( firstEntry ) < 0 ) {
257 ::Error(
"xAOD::RDataSource::InitSlot",
258 XAOD_MESSAGE(
"Failed to load entry %lld for slot %u" ),
260 throw std::runtime_error(
"Failed to load entry for slot" );
262 PRINT_VERBOSE(
"InitSlot: Retrieved entry " << firstEntry <<
" for slot "
268 PRINT_VERBOSE(
"InitSlot: Activated and cleared transient store for slot "
275 #if ROOT_VERSION_CODE < ROOT_VERSION(6,28,00)
276 void RDataSource::FinaliseSlot(
unsigned int slot ) {
285 void RDataSource::Finalise() {
328 ::Error(
"xAOD::RDataSource::GetTypeName",
331 throw std::runtime_error(
"Column/object \"" + std::string(
column ) +
332 "\" not available" );
339 ::Fatal(
"xAOD::RDataSource::GetTypeName",
343 <<
"\" is: " << itr->second );
362 ::Error(
"xAOD::RDataSource::SetEntry",
364 throw std::runtime_error(
"Invalid slot received" );
366 PRINT_VERBOSE(
"SetEntry: Called for slot " << slot <<
" and entry "
391 RDataSource::Record_t
393 const std::type_info& typeInfo ) {
397 ::Error(
"xAOD::RDataSource::GetColumnReadersImpl",
400 throw std::runtime_error(
"Column/object \"" + std::string(
column ) +
401 "\" not available" );
403 PRINT_VERBOSE(
"GetColumnReadersImpl: Creating column readers for \""
421 ::Error(
"xAOD::RDataSource::readInputMetadata",
422 XAOD_MESSAGE(
"Failed to connect to the input chain" ) );
423 throw std::runtime_error(
"Failed to connect to the input chain" );
429 ::Error(
"xAOD::RDataSource::readInputMetadata",
430 "Couldn't load the first event of the input" );
431 throw std::runtime_error(
"Couldn't load the first event of the "
438 auto names =
event.columnAndTypeNames();
441 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.