00001
00002
00003 #ifndef XAODROOTACCESS_TEVENT_H
00004 #define XAODROOTACCESS_TEVENT_H
00005
00006
00007 #include <map>
00008 #include <set>
00009 #include <string>
00010 #include <vector>
00011 #include <memory>
00012
00013
00014 #include <Rtypes.h>
00015
00016
00017 #include "xAODEventFormat/EventFormat.h"
00018 #include "AthContainersInterfaces/IAuxStoreHolder.h"
00019
00020
00021 #include "xAODRootAccessInterfaces/TVirtualEvent.h"
00022
00023
00024 #include "xAODRootAccess/tools/TReturnCode.h"
00025
00026
00027 class TFile;
00028 class TChain;
00029 class TTree;
00030 namespace std {
00031 class type_info;
00032 }
00033 namespace SG {
00034 class IAuxStore;
00035 }
00036
00037 namespace xAOD {
00038
00039
00040 class TVirtualManager;
00041 class TVirtualIncidentListener;
00042 class TObjectManager;
00043 class TAuxStore;
00044 class TChainStateTracker;
00045 class TEventBranch;
00046 class TMetaBranch;
00047 class TFileMerger;
00048 class TEvent;
00049 class TTreeMgr;
00050 ::TTree* MakeTransientTree( TEvent&, const char* );
00051
00067 class TEvent : public TVirtualEvent {
00068
00069
00070 friend ::TTree* MakeTransientTree( TEvent&, const char* );
00071 friend class xAOD::TEventBranch;
00072 friend class xAOD::TMetaBranch;
00073 friend class xAOD::TFileMerger;
00074 friend class xAOD::TTreeMgr;
00075
00076 public:
00078 enum EAuxMode {
00079 kBranchAccess = 0,
00080 kClassAccess = 1,
00081 kAthenaAccess = 2,
00082 kUndefinedAccess = 3
00083 };
00084
00086 TEvent( EAuxMode mode = kUndefinedAccess );
00088 TEvent( ::TFile* file, EAuxMode mode = kUndefinedAccess );
00090 TEvent( ::TTree* tree, EAuxMode mode = kUndefinedAccess );
00092 ~TEvent();
00093
00095 EAuxMode auxMode() const;
00096
00098 std::string dump();
00099
00101 void printIOStats() const;
00102
00105
00107 TReturnCode readFrom( ::TFile* file, Bool_t useTreeCache = kTRUE,
00108 const char* treeName = EVENT_TREE_NAME );
00110 TReturnCode readFrom( ::TTree* tree, Bool_t useTreeCache = kTRUE );
00112 TReturnCode writeTo( ::TFile* file, Int_t autoFlush = 200,
00113 const char* treeName = EVENT_TREE_NAME );
00115 TReturnCode finishWritingTo( ::TFile* file );
00116
00118 void setActive() const;
00119
00121 void setAuxItemList( const std::string& containerKey,
00122 const std::string& itemList );
00123
00125 TReturnCode addListener( TVirtualIncidentListener* listener );
00127 TReturnCode removeListener( TVirtualIncidentListener* listener );
00129 void clearListeners();
00130
00132 TReturnCode addNameRemap( const std::string& onfile,
00133 const std::string& newName );
00135 void clearNameRemap();
00137 void printNameRemap() const;
00138
00140
00143
00145 template< typename T >
00146 ::Bool_t contains( const std::string& key );
00148 template< typename T >
00149 ::Bool_t transientContains( const std::string& key ) const;
00150
00152 template< typename T >
00153 TReturnCode retrieve( const T*& obj, const std::string& key );
00155 template< typename T >
00156 TReturnCode retrieve( T*& obj, const std::string& key );
00157
00159 template< typename T >
00160 TReturnCode record( T* obj, const std::string& key,
00161 ::Int_t basketSize = 32000, ::Int_t splitLevel = 0 );
00163 template< typename T >
00164 TReturnCode record( std::unique_ptr< T > obj, const std::string& key,
00165 ::Int_t basketSize = 32000, ::Int_t splitLevel = 0 );
00166
00168 SG::IAuxStore* recordAux( const std::string& key,
00169 SG::IAuxStoreHolder::AuxStoreType type =
00170 SG::IAuxStoreHolder::AST_ContainerStore,
00171 Int_t basketSize = 32000,
00172 Int_t splitLevel = 0 );
00173
00175 TReturnCode copy( const std::string& key,
00176 ::Int_t basketSize = 32000, ::Int_t splitLevel = 0 );
00178 TReturnCode copy( ::Int_t basketSize = 32000, ::Int_t splitLevel = 0 );
00179
00181
00184
00186 template< typename T >
00187 ::Bool_t containsMeta( const std::string& key );
00189 template< typename T >
00190 ::Bool_t transientContainsMeta( const std::string& key ) const;
00191
00193 template< typename T >
00194 TReturnCode retrieveMetaInput( const T*& obj, const std::string& key );
00195
00197 template< typename T >
00198 TReturnCode retrieveMetaOutput( const T*& obj, const std::string& key );
00200 template< typename T >
00201 TReturnCode retrieveMetaOutput( T*& obj, const std::string& key );
00202
00204 template< typename T >
00205 TReturnCode recordMeta( T* obj, const std::string& key,
00206 ::Int_t basketSize = 32000,
00207 ::Int_t splitLevel = 1 );
00210 template< typename T >
00211 TReturnCode recordMeta( std::unique_ptr< T > obj, const std::string& key,
00212 ::Int_t basketSize = 32000,
00213 ::Int_t splitLevel = 1 );
00214
00216
00219
00221 ::Long64_t getEntries() const;
00223 ::Int_t getEntry( ::Long64_t entry, ::Int_t getall = 0 );
00224
00226 ::Long64_t getFiles() const;
00228 ::Int_t getFile( ::Long64_t file, ::Int_t getall = 0 );
00229
00231 ::Int_t fill();
00232
00234 const EventFormat* inputEventFormat() const;
00236 const EventFormat* outputEventFormat() const;
00237
00239
00242
00244 virtual uint32_t getHash( const std::string& key ) const;
00246 virtual uint32_t getKey( const void* obj ) const;
00248 virtual const std::string& getName( const void* obj ) const;
00250 virtual const std::string& getName( uint32_t hash ) const;
00251
00252 protected:
00254 virtual void* getOutputObject( uint32_t key,
00255 const std::type_info& ti );
00257 virtual const void* getInputObject( uint32_t key,
00258 const std::type_info& ti,
00259 bool silent = false );
00260
00262
00264 TReturnCode initStats();
00266 void* getOutputObject( const std::string& key,
00267 const std::type_info& ti,
00268 ::Bool_t metadata = kFALSE ) const;
00270 const void* getInputObject( const std::string& key,
00271 const std::type_info& ti,
00272 ::Bool_t silent = kFALSE,
00273 ::Bool_t metadata = kFALSE );
00275 TReturnCode record( void* obj, const std::string& typeName,
00276 const std::string& key,
00277 ::Int_t basketSize, ::Int_t splitLevel,
00278 ::Bool_t overwrite = kFALSE,
00279 ::Bool_t metadata = kFALSE,
00280 ::Bool_t isOwner = kTRUE );
00282 TReturnCode record( TAuxStore* store, const std::string& key,
00283 ::Int_t basketSize, ::Int_t splitLevel,
00284 ::Bool_t ownsStore = kFALSE );
00286 TReturnCode connectBranch( const std::string& key,
00287 ::Bool_t silent = kFALSE );
00289 TReturnCode connectMetaBranch( const std::string& key,
00290 ::Bool_t silent = kFALSE );
00292 TReturnCode connectAux( const std::string& prefix, ::Bool_t standalone );
00295 TReturnCode connectMetaAux( const std::string& prefix,
00296 ::Bool_t standalone );
00299 TReturnCode setUpDynamicStore( TObjectManager& mgr, ::TTree* tree );
00301 TReturnCode setAuxStore( TObjectManager& mgr,
00302 ::Bool_t metadata = kFALSE );
00304 TReturnCode putAux( ::TTree& outTree, TVirtualManager& mgr,
00305 ::Int_t basketSize = 32000, ::Int_t splitLevel = 0,
00306 ::Bool_t metadata = kFALSE );
00308 static ::Bool_t hasAuxStore( const TObjectManager& mgr );
00310 static ::Bool_t isAuxStore( const TObjectManager& mgr );
00312 static ::Bool_t isStandalone( const TObjectManager& mgr );
00314 ::Bool_t contains( const std::string& key,
00315 const std::type_info& ti,
00316 ::Bool_t metadata = kFALSE );
00318 ::Bool_t transientContains( const std::string& key,
00319 const std::type_info& ti,
00320 ::Bool_t metadata = kFALSE ) const;
00321
00323 typedef std::map< std::string,
00324 TVirtualManager* > Object_t;
00326 typedef std::vector< TVirtualIncidentListener* > Listener_t;
00327
00329 static const ::Int_t CACHE_SIZE;
00331 static const char* EVENT_TREE_NAME;
00333 static const char* METADATA_TREE_NAME;
00334
00336 EAuxMode m_auxMode;
00337
00339 ::TTree* m_inTree;
00342 ::Bool_t m_inTreeMissing;
00344 ::TChain* m_inChain;
00346 TChainStateTracker* m_inChainTracker;
00348 ::Int_t m_inTreeNumber;
00350 ::TTree* m_inMetaTree;
00352 ::Long64_t m_entry;
00353
00355 ::TTree* m_outTree;
00356
00358 Object_t m_inputObjects;
00360 Object_t m_outputObjects;
00361
00363 Object_t m_inputMetaObjects;
00365 Object_t m_outputMetaObjects;
00366
00368 EventFormat m_inputEventFormat;
00370 EventFormat* m_outputEventFormat;
00371
00373 std::map< std::string, std::set< std::string > > m_auxItemList;
00374
00376 Listener_t m_listeners;
00377
00379 std::map< std::string, std::string > m_nameRemapping;
00380
00381 };
00382
00383 }
00384
00385
00386 #ifndef __GCCXML__
00387 # include "TEvent.icc"
00388 #endif // __GCCXML__
00389
00390 #endif // XAODROOTACCESS_TEVENT_H