ATLAS Offline Software
Control/xAODRootAccess/xAODRootAccess/TEvent.h
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 //
3 // Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4 //
5 #ifndef XAODROOTACCESS_TEVENT_H
6 #define XAODROOTACCESS_TEVENT_H
7 
8 // Local include(s).
9 #include "xAODRootAccess/Event.h"
10 
11 // Project include(s).
13 
14 // ROOT include(s).
15 #include <Rtypes.h>
16 
17 // System include(s).
18 #include <memory>
19 #include <string_view>
20 
21 // Forward declaration(s).
22 class TFile;
23 class TChain;
24 class TTree;
25 namespace CP {
26 class xAODWriterAlg;
27 }
28 class xAODTEventBranch;
29 class xAODTMetaBranch;
30 namespace SG {
31 class IAuxStore;
32 }
33 
34 namespace xAOD {
35 
36 // Forward declaration(s).
37 class TAuxStore;
38 class TObjectManager;
39 class TChainStateTracker;
40 class TFileMerger;
41 class TEvent;
42 class TTreeMgr;
43 ::TTree* MakeTransientTree ATLAS_NOT_THREAD_SAFE(TEvent&, const char*);
44 
57 class TEvent : public Event {
58 
59  // Declare the friend functions/classes:
60  friend ::TTree* MakeTransientTree(TEvent&, const char*);
61  friend class ::xAODTEventBranch;
62  friend class ::xAODTMetaBranch;
63  friend class xAOD::TFileMerger;
64  friend class xAOD::TTreeMgr;
65  friend class CP::xAODWriterAlg;
66 
67  public:
69  enum EAuxMode {
72  kAthenaAccess = 2
73  };
74 
78  TEvent(::TFile* file, EAuxMode mode = kClassAccess);
80  TEvent(::TTree* tree, EAuxMode mode = kClassAccess);
82  virtual ~TEvent();
83 
85  EAuxMode auxMode() const;
86 
89 
91  static const char* const EVENT_TREE_NAME;
92 
94  StatusCode readFrom(::TFile* file, bool useTreeCache = true,
95  std::string_view treeName = EVENT_TREE_NAME);
97  StatusCode readFrom(::TTree* tree, bool useTreeCache = true);
99  StatusCode writeTo(::TFile* file, int autoFlush = 200,
100  std::string_view treeName = EVENT_TREE_NAME);
102  StatusCode finishWritingTo(::TFile* file);
103 
105 
108 
109  // Bring the definition of Event::record into scope
110  using Event::record;
111 
113  SG::IAuxStore* recordAux(const std::string& key,
116 
118 
121 
123  ::Long64_t getEntries() const;
125  ::Int_t getEntry(::Long64_t entry, ::Int_t getall = 0);
126 
128  ::Long64_t getFiles() const;
130  ::Int_t getFile(::Long64_t file, ::Int_t getall = 0);
131 
133  ::Int_t fill();
134 
136 
137  protected:
140 
142  bool hasInput() const override;
144  bool hasOutput() const override;
145 
147  StatusCode getNames(const std::string& targetClassName,
148  std::vector<std::string>& vkeys,
149  bool metadata) const override;
150 
152  StatusCode connectObject(const std::string& key, bool silent) override;
154  StatusCode connectMetaObject(const std::string& key, bool silent) override;
156  StatusCode connectAux(const std::string& prefix, bool standalone) override;
159  StatusCode connectMetaAux(const std::string& prefix,
160  bool standalone) override;
161 
164  bool metadata) override;
165 
167  StatusCode record(void* obj, const std::string& typeName,
168  const std::string& key, bool overwrite, bool metadata,
169  bool isOwner) override;
171  StatusCode recordAux(TVirtualManager& mgr, const std::string& key,
172  bool metadata) override;
173 
175 
178 
180  StatusCode record(std::unique_ptr<TAuxStore> store, const std::string& key);
185  StatusCode putAux(::TTree& outTree, TVirtualManager& mgr, bool metadata);
187  StatusCode recordAux(TAuxStore* store, const std::string& key);
188 
191 
193  ::TTree* m_inTree = nullptr;
196  bool m_inTreeMissing = false;
198  ::TChain* m_inChain = nullptr;
200  std::unique_ptr<TChainStateTracker> m_inChainTracker;
202  ::Int_t m_inTreeNumber = -1;
204  ::TTree* m_inMetaTree = nullptr;
206  ::Long64_t m_entry = -1;
207 
209  std::unique_ptr<::TTree> m_outTree;
210 
211 }; // class TEvent
212 
213 } // namespace xAOD
214 
215 #endif // XAODROOTACCESS_TEVENT_H
xAOD::TEvent::m_inTreeNumber
::Int_t m_inTreeNumber
The number of the currently open tree in the input chain.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:202
xAOD::TEvent::m_inTreeMissing
bool m_inTreeMissing
Internal status flag showing that an input file is open, but it doesn't contain an event tree.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:196
xAOD::TEvent::finishWritingTo
StatusCode finishWritingTo(::TFile *file)
Finish writing to an output file.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:447
SGTest::store
TestStore store
Definition: TestStore.cxx:23
xAOD::TTreeMgr
Class creating (a) transient tree(s) from xAOD files.
Definition: TTreeMgr.h:34
xAOD::TEvent::m_inChainTracker
std::unique_ptr< TChainStateTracker > m_inChainTracker
Optional object for tracking the state changes of an input TChain.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:200
xAOD::TEvent::TEvent
TEvent(EAuxMode mode=kClassAccess)
Default constructor.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:77
xAOD::TEvent::m_auxMode
EAuxMode m_auxMode
The auxiliary access mode.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:190
IAuxStoreHolder.h
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
L1CaloPhase1Monitoring.standalone
standalone
Definition: L1CaloPhase1Monitoring.py:139
xAOD::TEvent::record
StatusCode record(void *obj, const std::string &typeName, const std::string &key, bool overwrite, bool metadata, bool isOwner) override
Record an object into a connected output file.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:1638
xAOD::TEvent::kAthenaAccess
@ kAthenaAccess
Access containers/objects like Athena does.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:72
xAOD::TEvent::getFile
::Int_t getFile(::Long64_t file, ::Int_t getall=0)
Load the first event for a given file from the input TChain.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:780
xAOD::TEvent::m_inChain
::TChain * m_inChain
The (optional) chain provided as input.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:198
tree
TChain * tree
Definition: tile_monitor.h:30
xAOD::TEvent::getNames
StatusCode getNames(const std::string &targetClassName, std::vector< std::string > &vkeys, bool metadata) const override
Function determining the list keys associated with a type name.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:903
xAOD::TEvent::hasInput
bool hasInput() const override
Check if an input file is connected to the object.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:893
xAOD::TAuxStore
"ROOT @c TTree implementation" of IAuxStore
Definition: TAuxStore.h:30
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::TEvent::~TEvent
virtual ~TEvent()
Destructor.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:91
xAOD::TVirtualManager
Interface class for the "manager classes".
Definition: TVirtualManager.h:24
xAOD::TEvent::kClassAccess
@ kClassAccess
Access auxiliary data using the aux containers.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:71
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:25
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
xAOD::TEvent::m_inMetaTree
::TTree * m_inMetaTree
Pointer to the metadata tree in the input file.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:204
xAOD::TEvent::connectAux
StatusCode connectAux(const std::string &prefix, bool standalone) override
Function setting up access to a set of auxiliary branches.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:1329
xAOD::TEvent::hasOutput
bool hasOutput() const override
Check if an output file is connected to the object.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:898
xAOD::TEvent::connectMetaAux
StatusCode connectMetaAux(const std::string &prefix, bool standalone) override
Function setting up access to a set of auxiliary branches for a metadata object.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:1401
xAOD::TEvent::auxMode
EAuxMode auxMode() const
Get what auxiliary access mode the object was constructed with.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:108
python.checkMetadata.metadata
metadata
Definition: checkMetadata.py:175
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
xAODTMetaBranch
Specialised class for browsing xAOD metadata interface objects in ROOT.
Definition: xAODTMetaBranch.h:27
SG::IAuxStoreHolder::AuxStoreType
AuxStoreType
Type of the auxiliary store.
Definition: IAuxStoreHolder.h:66
xAOD::ATLAS_NOT_THREAD_SAFE
void ErrorHandler ATLAS_NOT_THREAD_SAFE(Int_t level, Bool_t abort, const char *location, const char *message)
Function filtering the warnings coming from ROOT.
Definition: Init.cxx:105
xAOD::TEvent::m_inTree
::TTree * m_inTree
The main tree that we are reading from.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:193
xAOD::TEvent::getEntries
::Long64_t getEntries() const
Get how many entries are available from the current input file(s)
Definition: Control/xAODRootAccess/Root/TEvent.cxx:621
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::TEvent::getEntry
::Int_t getEntry(::Long64_t entry, ::Int_t getall=0)
Function loading a given entry of the input TTree.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:650
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
file
TFile * file
Definition: tile_monitor.h:29
dumpFileToPlots.treeName
string treeName
Definition: dumpFileToPlots.py:19
Preparation.mode
mode
Definition: Preparation.py:107
CP::xAODWriterAlg
Algorithm writing an xAOD output file.
Definition: xAODWriterAlg.h:29
Event.h
xAOD::Event::record
StatusCode record(T *obj, const std::string &key)
Add an output object to the event.
xAOD::TEvent::EVENT_TREE_NAME
static const char *const EVENT_TREE_NAME
Default name of the event tree.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:91
xAOD::TEvent::m_outTree
std::unique_ptr<::TTree > m_outTree
The tree that we are writing to.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:209
xAOD::TEvent::MakeTransientTree
friend ::TTree * MakeTransientTree(TEvent &, const char *)
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
xAOD::TEvent::readFrom
StatusCode readFrom(::TFile *file, bool useTreeCache=true, std::string_view treeName=EVENT_TREE_NAME)
Connect the object to a new input file.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:122
xAOD::TEvent::initStats
StatusCode initStats()
Function to initialise the statistics for all Tree content.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:1808
xAOD::TObjectManager
Manager for EDM objects created by ROOT.
Definition: TObjectManager.h:29
xAODTEventBranch
Specialised class for browsing xAOD event interface objects in ROOT.
Definition: xAODTEventBranch.h:32
xAOD::TEvent::fill
::Int_t fill()
Function filling one event into the output tree.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:814
xAOD::TFileMerger
Helper class for merging xAOD files.
Definition: TFileMerger.h:47
SG::IAuxStore
Interface for non-const operations on an auxiliary store.
Definition: IAuxStore.h:48
xAOD::TEvent::putAux
StatusCode putAux(::TTree &outTree, TVirtualManager &mgr, bool metadata)
Function saving the dynamically created auxiliary properties.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:2127
xAOD::TEvent::setUpDynamicStore
StatusCode setUpDynamicStore(TObjectManager &mgr, ::TTree *tree)
Function adding dynamic variable reading capabilities to an auxiliary store object.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:2041
xAOD::TEvent::EAuxMode
EAuxMode
Auxiliary store "mode".
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:69
xAOD::TEvent::getFiles
::Long64_t getFiles() const
Get how many files are available on the currently defined input.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:760
python.trfDecorators.silent
def silent(func)
Redirect stdout/err to /dev/null Useful wrapper to get rid of ROOT verbosity...
Definition: trfDecorators.py:24
xAOD::TEvent::m_entry
::Long64_t m_entry
The entry to look at from the input tree.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:206
xAOD::TEvent::connectMetaObject
StatusCode connectMetaObject(const std::string &key, bool silent) override
Function setting up access to a particular metadata object.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:1228
xAOD::TEvent::recordAux
SG::IAuxStore * recordAux(const std::string &key, SG::IAuxStoreHolder::AuxStoreType type=SG::IAuxStoreHolder::AST_ContainerStore)
Add an auxiliary store object to the output.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:562
xAOD::TEvent::setAuxStore
StatusCode setAuxStore(const std::string &key, Details::IObjectManager &mgr, bool metadata) override
Function connecting a DV object to its auxiliary store.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:1465
ReadCalibFromCool.typeName
typeName
Definition: ReadCalibFromCool.py:477
xAOD::TEvent::kBranchAccess
@ kBranchAccess
Access auxiliary data branch-by-branch.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:70
xAOD::TEvent::connectObject
StatusCode connectObject(const std::string &key, bool silent) override
Function setting up access to a particular object.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:1059
xAOD::Details::IObjectManager
Manager for EDM objects created by ROOT.
Definition: IObjectManager.h:20
xAOD::Event
Base class for the event (xAOD::TEvent and xAOD::REvent) classes.
Definition: Event.h:59
python.PyAthena.obj
obj
Definition: PyAthena.py:132
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:57
xAOD::TEvent::writeTo
StatusCode writeTo(::TFile *file, int autoFlush=200, std::string_view treeName=EVENT_TREE_NAME)
Connect the object to an output file.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:408
SG::IAuxStoreHolder::AST_ContainerStore
@ AST_ContainerStore
The store describes a container.
Definition: IAuxStoreHolder.h:68
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37