PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
podio::PythonEventStore Class Reference

#include <PythonEventStore.h>

Public Member Functions

 PythonEventStore (const char *filename)
 constructor from filename
 
const podio::CollectionBaseget (const char *name)
 access a collection.
 
void endOfEvent ()
 signify end of event
 
void goToEvent (unsigned ievent)
 go to a given event
 
unsigned getEntries () const
 get number of entries in the tree
 
bool isZombie () const
 is the input file accessible?
 
bool isValid () const
 
void close ()
 
const std::vector< std::string > & getCollectionNames () const
 list available collections
 
const podio::GenericParametersgetEventMetaData ()
 

Detailed Description

Definition at line 13 of file PythonEventStore.h.

Constructor & Destructor Documentation

◆ PythonEventStore()

podio::PythonEventStore::PythonEventStore ( const char *  filename)

constructor from filename

Definition at line 10 of file PythonEventStore.cc.

10 : m_reader(podio::createReader(name)), m_store() {
11 std::ifstream inputfile(name);
12 m_isZombie = inputfile.good() ? false : true;
13
14 if (m_reader) {
15 if (m_isZombie && dynamic_cast<podio::ROOTReader*>(m_reader.get())) {
16 // the file could be a remote file that we cannot access but root
17 // knows how to handle via the xrootd protocol.
18 // if that is the case we ignore m_isZombie.
19 if (!std::string("root:/").compare(0, 6, name, 6)) {
20 m_isZombie = false;
21 }
22 }
23 }
24
25 if (!m_isZombie) {
26 // at this point we have a combination of file and reader that should work
27 m_reader->openFile(name);
28 m_store.setReader(m_reader.get());
29 }
30}
void setReader(IReader *reader)
set the reader
Definition: EventStore.cc:149
std::unique_ptr< podio::IReader > createReader(const std::string &filename)
Definition: IOHelpers.cc:10

Member Function Documentation

◆ close()

void podio::PythonEventStore::close ( )
inline

Definition at line 38 of file PythonEventStore.h.

38 {
39 m_reader->closeFile();
40 }

◆ endOfEvent()

void podio::PythonEventStore::endOfEvent ( )

signify end of event

Definition at line 38 of file PythonEventStore.cc.

38 {
39 m_store.clear();
40 m_reader->endOfEvent();
41}
void clear()
clears itself; deletes collections (use at end of event processing)
Definition: EventStore.cc:126

◆ get()

const podio::CollectionBase * podio::PythonEventStore::get ( const char *  name)

access a collection.

Definition at line 32 of file PythonEventStore.cc.

32 {
33 const podio::CollectionBase* coll(nullptr);
34 m_store.get(name, coll);
35 return coll;
36}
bool get(const std::string &name, const T *&collection)
access a collection by name. returns true if successful
Definition: EventStore.h:143

◆ getCollectionNames()

const std::vector< std::string > & podio::PythonEventStore::getCollectionNames ( ) const

list available collections

Definition at line 52 of file PythonEventStore.cc.

52 {
53 return m_store.getCollectionIDTable()->names();
54}
const std::vector< std::string > & names() const
return registered names
CollectionIDTable * getCollectionIDTable() const
Definition: EventStore.h:86

◆ getEntries()

unsigned podio::PythonEventStore::getEntries ( ) const

get number of entries in the tree

Definition at line 48 of file PythonEventStore.cc.

48 {
49 return m_reader->getEntries();
50}

◆ getEventMetaData()

const podio::GenericParameters & podio::PythonEventStore::getEventMetaData ( )
inline

Definition at line 45 of file PythonEventStore.h.

45 {
46 return m_store.getEventMetaData();
47 }
GenericParameters & getEventMetaData() override
return the event meta data for the current event
Definition: EventStore.cc:89

◆ goToEvent()

void podio::PythonEventStore::goToEvent ( unsigned  ievent)

go to a given event

Definition at line 43 of file PythonEventStore.cc.

43 {
44 m_store.clear();
45 m_reader->goToEvent(ievent);
46}

◆ isValid()

bool podio::PythonEventStore::isValid ( ) const
inline

Definition at line 35 of file PythonEventStore.h.

35 {
36 return m_reader && m_reader->isValid();
37 }

◆ isZombie()

bool podio::PythonEventStore::isZombie ( ) const
inline

is the input file accessible?

Definition at line 31 of file PythonEventStore.h.

31 {
32 return m_isZombie;
33 }

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