EventAnalysis  1.3.0
Classes | Public Member Functions | Protected Member Functions | Private Types | Private Attributes | List of all members
EA::RootDataProviderV0 Class Reference

Data provider for Root file written by legacy RootPersistenceService. More...

#include <RootDataProviderV0.h>

Inheritance diagram for EA::RootDataProviderV0:
EA::DataProvider EA::Info EA::Configurable EA::ObjectProducer

Classes

struct  EvObjInfo
 
struct  GlobObjInfo
 

Public Member Functions

 RootDataProviderV0 (const std::string &name, const std::string &dataSource)
 Constructor. More...
 
bool Connect () override
 Connects to the input file(s). More...
 
bool Disconnect () override
 Closes the input file(s). More...
 
RetrievalResult GetObject (const std::string &name, ObjectCategory category, ObjectWrapper &wrapper, std::string &actualName) override
 Get the requested data object for current event. More...
 
bool SetCurrentEvent (unsigned int event, std::vector< std::string > &notValidGlobalObjects) override
 Set the current event. More...
 
bool IsEventAvailable (unsigned int event)
 Checks if the data provider can provide the given event. More...
 
virtual std::vector< std::string > FreeObjects (const std::vector< std::string > &objs, Memory::Status memStatus) override
 Free the memory for given objects. More...
 
- Public Member Functions inherited from EA::DataProvider
 DataProvider (const std::string &name, const std::string &dataSource)
 Constructor. More...
 
virtual ~DataProvider ()=default
 Destructor. More...
 
const std::string & GetDataSource ()
 Getter for data source string. More...
 
bool IsDisabled ()
 Check if the data provider is disabled. More...
 
bool SetDisabled (bool disabled=true)
 Disables/enables the data provider. More...
 
RetrievalResult RetrieveObject (const std::string &name, ObjectCategory category, ObjectWrapper &wrapper, std::string &actualName)
 Retrieve the requested data object for current event. More...
 
bool ConnectSource ()
 Opens the connection to the data source. More...
 
bool DisconnectSource ()
 Closes the connection to the data source. More...
 
bool SetEvent (unsigned int event, std::vector< std::string > &notValidGlobalObjects)
 Set the current event. More...
 
bool SetPass (unsigned int pass, unsigned int iteration)
 Set the current processing pass. More...
 
- Public Member Functions inherited from EA::Info
 Info (const std::string &name)
 Constructor. More...
 
virtual ~Info ()
 Destructor. More...
 
virtual const std::string GetType () const
 
virtual const std::string GetName () const
 The type (i.e. class) of the object. More...
 
virtual const std::string GetVersion () const
 The name of the object. More...
 
- Public Member Functions inherited from EA::Configurable
 Configurable ()
 Constructor. More...
 
template<typename T >
bool SetParameter (const std::string &name, const T &value)
 Set the value of a parameter. More...
 
bool SetParameter (const std::string &name, const char *value)
 Set the value of a string parameter using a string literal. More...
 
std::vector< std::string > GetParameters ()
 Get the names of the parameters. More...
 
- Public Member Functions inherited from EA::ObjectProducer
 ObjectProducer ()
 Constructor. More...
 
virtual ~ObjectProducer ()
 Destructor. More...
 
template<typename C >
void DeclareProducedObject (std::string name, ObjectCategory category, C aliases, std::string store)
 Declare a produced objects. More...
 
const ProducedObjectsGetProducedObjects () const
 Getter method for produced objects. More...
 
bool SetDisabled (bool disabled=true)
 Disables/enables the producer. More...
 
template<>
void DeclareProducedObject (std::string name, ObjectCategory category, const char *alias, std::string store)
 

Protected Member Functions

observer_ptr< TFile > GetCurrentFile ()
 Getter method for the current input file. More...
 
observer_ptr< TChain > GetEventChain ()
 Getter method for the event chain. More...
 
- Protected Member Functions inherited from EA::Info
 Info (const std::shared_ptr< Representation > &impl)
 
std::shared_ptr< Representation > & GetRepresentation ()
 
- Protected Member Functions inherited from EA::Configurable
template<typename T >
bool DefineParameter (const std::string &name, T &variable)
 Set a parameter. More...
 
 Configurable (const std::shared_ptr< Representation > &impl)
 
std::shared_ptr< Representation > & GetRepresentation ()
 
- Protected Member Functions inherited from EA::ObjectProducer
 ObjectProducer (const std::shared_ptr< Representation > &impl)
 
std::shared_ptr< Representation > & GetRepresentation ()
 

Private Types

using EvObjectsBook = std::unordered_map< std::string, EvObjInfo >
 
using GlobObjectsBook = std::unordered_map< std::string, GlobObjInfo >
 

Private Attributes

EvObjectsBook _eventBook
 
GlobObjectsBook _globalBook
 
TChain * _eventChain
 
unsigned int _currentEvent
 
bool _withoutTree
 
TFile * _fileWoTree
 
Long64_t _treeReadEntry
 
Int_t _treeNumber
 

Additional Inherited Members

- Public Types inherited from EA::ObjectProducer
using ProducedObjects = std::vector< ProducedObject >
 Type for container of produced objects. More...
 

Detailed Description

Data provider for Root file written by legacy RootPersistenceService.

This data provider reads event, pass and global objects from a Root file produced by the legacy RootPersistenceService found in EventAnalysis versions up to 1.1.

The code for this class is a copy-paste of the RootDataProvider class as found in commit 776c601e (version 1.1.0) and renamed to RootDataProviderV0 for coexisting with the current version of RootDataProvider.

Member Typedef Documentation

◆ EvObjectsBook

using EA::RootDataProviderV0::EvObjectsBook = std::unordered_map<std::string, EvObjInfo>
private

◆ GlobObjectsBook

using EA::RootDataProviderV0::GlobObjectsBook = std::unordered_map<std::string, GlobObjInfo>
private

Constructor & Destructor Documentation

◆ RootDataProviderV0()

EA::RootDataProviderV0::RootDataProviderV0 ( const std::string &  name,
const std::string &  dataSource 
)

Constructor.

The dataSource parameter must be a name of a Root file created with #RootPersistenceService, or a txt file containing a list of Root files to be chained.

Parameters
nameThe name of the data provider.
dataSourceA Root file created with #RootPersistenceService

Member Function Documentation

◆ Connect()

bool EA::RootDataProviderV0::Connect ( )
overridevirtual

Connects to the input file(s).

Opens the input file(s) passed as data source to the constructor and sets all the contained objects as produced by the data provider. If a list of Root files has been given then this method will return false if there are inconsistencies between files or if one of them does not have any event object.

Returns
true if the data source file has the right format and has been correctly opened for input.

Reimplemented from EA::DataProvider.

◆ Disconnect()

bool EA::RootDataProviderV0::Disconnect ( )
overridevirtual

Closes the input file(s).

Returns
true if the file(s) have been correctly closed.

Reimplemented from EA::DataProvider.

◆ FreeObjects()

std::vector< std::string > EA::RootDataProviderV0::FreeObjects ( const std::vector< std::string > &  objs,
Memory::Status  memStatus 
)
overridevirtual

Free the memory for given objects.

This override of DataProvider::FreeObjects will delete all the event objects in the objs vector if the memory status is EXHAUSTED. Nothing is done if the memory status is less severe.

Parameters
objsThe list of objects whose memory can be freed.
Returns
A list of objects whose memory has been released.
See also
#Memory::GetState

Reimplemented from EA::ObjectProducer.

◆ GetCurrentFile()

observer_ptr< TFile > EA::RootDataProviderV0::GetCurrentFile ( )
protected

Getter method for the current input file.

Derived classes can use this method to get access to the current input file.

Returns
A pointer to the current input file.

◆ GetEventChain()

observer_ptr<TChain> EA::RootDataProviderV0::GetEventChain ( )
inlineprotected

Getter method for the event chain.

Derived classes can use this method to get access to the input event chain.

Returns
A pointer to the event chain.

◆ GetObject()

RetrievalResult EA::RootDataProviderV0::GetObject ( const std::string &  name,
ObjectCategory  category,
ObjectWrapper wrapper,
std::string &  actualName 
)
overridevirtual

Get the requested data object for current event.

Overrides of this method implements the actual retrieval of a data object from the provider's data source.

The possible return values are:

In case of RetrievalResult::SUCCESS, the requested object must be returned to the caller by means of the wrapper parameter; if the implementation recognizes the name of the requested parameter as an alias then it must return the actual object name by setting the actualName parameter. In any other case wrapper must be set equal to nullptr and actualName to "".

Parameters
nameThe name of the object.
categoryThe category of the object to be retrieved (ObjectCategory::EVENT, ObjectCategory::PASS or ObjectCategory::GLOBAL).
wrapperReturn wrapper for the desired object (wraps nothing if the object is non-existent or not available for the current event).
actualNamethe actual object name, in case name has been recognized as an alias.
Returns
the outcome of the retrieve operation.

Reimplemented from EA::DataProvider.

◆ IsEventAvailable()

bool EA::RootDataProviderV0::IsEventAvailable ( unsigned int  event)
virtual

Checks if the data provider can provide the given event.

This method checks if the given event is available in the Root chain.

Parameters
eventThe number of the event.
Returns
true if the given event can be provided, false otherwise.

Reimplemented from EA::DataProvider.

◆ SetCurrentEvent()

bool EA::RootDataProviderV0::SetCurrentEvent ( unsigned int  event,
std::vector< std::string > &  notValidGlobalObjects 
)
overridevirtual

Set the current event.

Overrides of this method implements the setting of the current event.

This method will be called to communicate to the data provider the number of the current event. Subsequent calls to the GetObject method must load the data objects for the given event. In case the requested event is not available (e.g. there are less events than required) then the returned value must be false.

A list of global objects that were already provided by the provider in previous events, and that will need to be provided again for the current event, must be returned to the caller by filling the notValidGlobalObjects vector parameter.

Parameters
eventThe number of the current event.
notValidGlobalObjectsA list of global objects which are no longer valid and will need to be re-provided for the current event.
Returns
true if the requested event is available, false otherwise.

Reimplemented from EA::DataProvider.

Member Data Documentation

◆ _currentEvent

unsigned int EA::RootDataProviderV0::_currentEvent
private

◆ _eventBook

EvObjectsBook EA::RootDataProviderV0::_eventBook
private

◆ _eventChain

TChain* EA::RootDataProviderV0::_eventChain
private

◆ _fileWoTree

TFile* EA::RootDataProviderV0::_fileWoTree
private

◆ _globalBook

GlobObjectsBook EA::RootDataProviderV0::_globalBook
private

◆ _treeNumber

Int_t EA::RootDataProviderV0::_treeNumber
private

◆ _treeReadEntry

Long64_t EA::RootDataProviderV0::_treeReadEntry
private

◆ _withoutTree

bool EA::RootDataProviderV0::_withoutTree
private

The documentation for this class was generated from the following files: