HepMC3 event record library
ReaderuprootTree.h
1 #ifndef READERUPROOTTREE_H
2 #define READERUPROOTTREE_H
3 #include "HepMC3/GenEvent.h"
4 #include "HepMC3/FourVector.h"
5 #include "HepMC3/Print.h"
6 #include "HepMC3/Reader.h"
9 #include <iostream>
10 #include "HepMC3/Units.h"
11 #include "HepMC3/Version.h"
12 #include "Python.h"
13 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
14 #include "numpy/arrayobject.h"
15 
16 namespace HepMC3
17 {
18 /** @brief ReaderuprootTree */
19 class ReaderuprootTree : public Reader
20 {
21 public:
22  /** @brief Constructor with tree and branch names*/
23  ReaderuprootTree(const std::string &filename,const std::string &treename="hepmc3_tree",const std::string &branchname="hepmc3_event");
24 
25  /// @brief skip events
26  bool skip(const int) override;
27 
28  /** @brief Read event from file
29  *
30  * @param[out] evt Contains parsed event
31  */
32  bool read_event(GenEvent &evt) override;
33 
34  /** @brief Close file */
35  void close() override;
36 
37  /** @brief Get file error state */
38  bool failed() override;
39 
41 private:
42  /** @brief init routine */
43  bool init(const std::string &filename);
44 
45  int m_events_count; //!< Events count. Needed to read the tree
46  GenEventData* m_event_data; //!< Pointer to structure that holds event data
47  GenRunInfoData* m_run_info_data; //!< Pointer to structure that holds run info data
48  std::string m_tree_name; //!< Name of TTree
49  std::string m_branch_name; //!< Name of TBranch in TTree
50 
51  //PyThreadState* m_thread_state;
52  PyObject* m_file; //!< Python file handler
53 
54  PyObject* m_tree; //!< Python tree handler.
55 
56  PyObject* m_genruninfo; //!< Python runInfo handler.
57 
58  PyObject* m_access_function; //!< Python access function for arrays
59 
60  PyObject* m_python_module; //!< Python module
61 
62  long int m_tree_getEntries; //!< number of processed events
63 
64  PyObject* get_function(PyObject*, const std::string& ); //!< Get python functions
65 
66  PyObject* init_python_module(const std::string&); //!< Init python module
67 
68  template <class T> std::vector<T> get_vector(PyObject * file_name,const std::string& array_name,std::string desired_type=""); //!< Get arrays
69 };
70 
71 }
72 #endif
Definition of class FourVector.
Definition of struct GenEventData.
Definition of class GenEvent.
Definition of struct GenRunInfoData.
Definition of static class Print.
Definition of interface Reader.
Definition of class Units.
Stores event-related information.
Definition: GenEvent.h:41
Base class for all I/O readers.
Definition: Reader.h:25
ReaderuprootTree(const std::string &filename, const std::string &treename="hepmc3_tree", const std::string &branchname="hepmc3_event")
Constructor with tree and branch names.
PyObject * m_genruninfo
Python runInfo handler.
bool read_event(GenEvent &evt) override
Read event from file.
long int m_tree_getEntries
number of processed events
std::vector< T > get_vector(PyObject *file_name, const std::string &array_name, std::string desired_type="")
Get arrays.
PyObject * m_access_function
Python access function for arrays.
bool failed() override
Get file error state.
bool skip(const int) override
skip events
PyObject * m_tree
Python tree handler.
bool init(const std::string &filename)
init routine
GenEventData * m_event_data
Pointer to structure that holds event data.
int m_events_count
Events count. Needed to read the tree.
void close() override
Close file.
std::string m_tree_name
Name of TTree.
PyObject * get_function(PyObject *, const std::string &)
Get python functions.
std::string m_branch_name
Name of TBranch in TTree.
PyObject * init_python_module(const std::string &)
Init python module.
GenRunInfoData * m_run_info_data
Pointer to structure that holds run info data.
PyObject * m_python_module
Python module.
PyObject * m_file
Python file handler.
HepMC3 main namespace.
Stores serializable event information.
Definition: GenEventData.h:26
Stores serializable run information.