ATLAS Offline Software
Loading...
Searching...
No Matches
PhysicsAnalysis/POOLRootAccess/POOLRootAccess/TEvent.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef POOLROOTACCESS_TEVENT_H
6#define POOLROOTACCESS_TEVENT_H
7
9
10#include "GaudiKernel/Bootstrap.h"
11
12#include "GaudiKernel/IIncidentSvc.h"
13#include "Gaudi/Interfaces/IOptionsSvc.h"
16
17#include "GaudiKernel/IAppMgrUI.h"
18
19//include the CLIDs of simple types so that we don't need to do this ourselves from ROOT prompt
20//when reading in kTreeAccess
23#include "SGTools/StlMapClids.h"
24
25class TFile;
26class TChain;
27class IEventProcessor;
28
29//Bootstraps the minimal gaudi environment + a few extra defaults (see basic.opts)
30namespace Gaudi {
31 IAppMgrUI* Init();
32}
33
34namespace POOL {
35
37 IAppMgrUI* Init( const char* options = "POOLRootAccess/basic.opts" );
38
39
40 class TEvent {
41 public:
42 enum EReadMode {
43 kTreeAccess = -2, //read the TTree directly
44 kPOOLAccess = -1, //cannot be used in the same session as the other access modes
49 };
50
51 static IAppMgrUI* Init( const char* options = "POOLRootAccess/basic.opts" ) { return POOL::Init(options); }
52
53
54 TEvent( const std::string& name = "StoreGateSvc" );
55 TEvent( EReadMode mode, const std::string& name = "StoreGateSvc" );
56
57 ~TEvent();
58
62
63 template<typename T> void setEvtSelProperty( const char* name, const T& val ) {
64 if constexpr (std::is_convertible_v<T, std::string>) {
65 // Gaudi::Utils::toString adds extra quotes, don't do this for strings:
66 m_joSvc->set(m_evtSelect.name() + "." + name, std::string(val));
67 }
68 else {
69 m_joSvc->set(m_evtSelect.name() + "." + name, Gaudi::Utils::toString(val));
70 }
71 }
72
73 //forward retrieve calls to the evtStore
74 template<typename T> StatusCode retrieve( const T*& obj ) {
75 return evtStore()->retrieve( obj );
76 }
77
78 template<typename T> StatusCode retrieve( T*& obj ) {
79 return evtStore()->retrieve( obj );
80 }
81
82 template<typename T> StatusCode retrieve( const T*& obj , const std::string& key ){
83 return evtStore()->retrieve( obj, key );
84 }
85 template<typename T> StatusCode retrieve( T*& obj , const std::string& key ){
86 return evtStore()->retrieve( obj, key );
87 }
88
89 //forward calls to metadata store
90 template<typename T> StatusCode retrieveMetaInput( const T*& obj, const std::string& key ) {
91 return inputMetaStore()->retrieve( obj, key );
92 }
93
94 int getEntry( long entry ); //return -1 if failure. otherwise 0
95 long getEntries();
96
97 StatusCode readFrom( TFile* file );
98 StatusCode readFrom( const char* file ); //also takes a comma-separated list and can take wild cards
99 StatusCode readFrom( TChain* files ); //multi-file input
100
102 void setActive();
103
104
106 PyObject* retrieve( PyObject* tp, PyObject* pykey );
107 PyObject* get_item( PyObject* pykey ); //typess retrieve, which is slower than retrieve above
108 PyObject* contains( PyObject* tp, PyObject* pykey );
110 PyObject* record (PyObject* obj, PyObject* pykey,bool allowMods = true,bool resetOnly = true,bool noHist = false);
111
112 private:
113 long m_curEntry = -1; //if this becomes >=0 then the TEvent is considered 'initialized'
114 long m_size = -1; //cache of the event size, filled on first call to getEntries
115
116 IEventProcessor* m_evtProcessor;
117
120
121 ServiceHandle<IEventSeek> m_evtLoop; //the AthenaEventLoopMgr
122 ServiceHandle<IEvtSelectorSeek> m_evtSelect; //the EventSelectorAthenaPool
124
126
127 };
128
129}
130
131
132#endif
Abstract interface for seeking within an event stream.
Extension to IEvtSelector to allow for seeking.
_object PyObject
TEvent(const std::string &name="StoreGateSvc")
PyObject * contains(PyObject *tp, PyObject *pykey)
ServiceHandle< IEvtSelectorSeek > m_evtSelect
PyObject * record(PyObject *obj, PyObject *pykey, bool allowMods=true, bool resetOnly=true, bool noHist=false)
static IAppMgrUI * Init(const char *options="POOLRootAccess/basic.opts")
ServiceHandle< Gaudi::Interfaces::IOptionsSvc > m_joSvc
ServiceHandle< StoreGateSvc > & evtStore()
StatusCode retrieveMetaInput(const T *&obj, const std::string &key)
StatusCode retrieve(T *&obj, const std::string &key)
void setActive()
ensure we are the active store, for the purpose of element links etc
ServiceHandle< StoreGateSvc > & inputMetaStore()
void setEvtSelProperty(const char *name, const T &val)
StatusCode retrieve(const T *&obj, const std::string &key)
std::vector< std::string > files
file names and file pointers
Definition hcg.cxx:50
=============================================================================
IAppMgrUI * Init(const char *options="POOLRootAccess/basic.opts")
Bootstraps (creates and configures) the Gaudi Application with the provided options file.
TFile * file