ATLAS Offline Software
Loading...
Searching...
No Matches
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).
10
11// Project include(s).
13
14// ROOT include(s).
15#include <Rtypes.h>
16
17// System include(s).
18#include <memory>
19#include <regex>
20#include <string>
21#include <string_view>
22
23// Forward declaration(s).
24class TFile;
25class TChain;
26class TTree;
27namespace CP {
28class xAODWriterAlg;
29}
31class xAODTMetaBranch;
32namespace SG {
33class IAuxStore;
34}
35
36namespace xAOD {
37
38// Forward declaration(s).
39class TAuxStore;
40class TObjectManager;
42class TFileMerger;
43class TEvent;
44class TTreeMgr;
45::TTree* MakeTransientTree ATLAS_NOT_THREAD_SAFE(TEvent &, const char* );
46
59class TEvent : public Event {
60
61 // Declare the friend functions/classes:
62 friend ::TTree* MakeTransientTree(TEvent &, const char* );
63 friend class ::xAODTEventBranch;
64 friend class ::xAODTMetaBranch;
65 friend class xAOD::TFileMerger;
66 friend class xAOD::TTreeMgr;
67 friend class CP::xAODWriterAlg;
68
69public:
76
80 TEvent(::TFile* file, EAuxMode mode = kClassAccess);
82 TEvent(::TTree* tree, EAuxMode mode = kClassAccess);
84 virtual ~TEvent();
85
91 void setOtherMetaDataTreeNamePattern(const std::string &pattern);
92
94 EAuxMode auxMode() const;
95
98
99
102 StatusCode readFrom(::TFile& inFile) override;
103
106 StatusCode readFrom(::TFile* file, bool useTreeCache = true,
107 std::string_view treeName = EVENT_TREE_NAME);
109 StatusCode readFrom(::TTree* tree, bool useTreeCache = true);
111 StatusCode writeTo(::TFile* file, int autoFlush = 200,
112 std::string_view treeName = EVENT_TREE_NAME);
114 StatusCode finishWritingTo(::TFile* file);
115
117
120
121 // Bring the definition of Event::record into scope
122 using Event::record;
123
125 SG::IAuxStore* recordAux(const std::string& key,
128
130
133
135 ::Long64_t getEntries() const override;
137 ::Int_t getEntry(::Long64_t entry, ::Int_t getall = 0) override;
138
140 ::Long64_t getFiles() const;
142 ::Int_t getFile(::Long64_t file, ::Int_t getall = 0);
143
145 ::Int_t fill();
146
148
149protected:
152
154 bool hasInput() const override;
156 bool hasOutput() const override;
157
159 StatusCode getNames(const std::string& targetClassName,
160 std::vector<std::string>& vkeys,
161 bool metadata) const override;
162
164 StatusCode connectObject(const std::string& key, bool silent) override;
166 StatusCode connectMetaObject(const std::string& key, bool silent) override;
168 StatusCode connectAux(const std::string& prefix, bool standalone) override;
171 StatusCode connectMetaAux(const std::string& prefix,
172 bool standalone) override;
173
175 StatusCode setAuxStore(const std::string& key, Details::IObjectManager& mgr,
176 bool metadata) override;
177
179 StatusCode record(void* obj, const std::string& typeName,
180 const std::string& key, bool overwrite, bool metadata,
181 bool isOwner) override;
183 StatusCode recordAux(TVirtualManager& mgr, const std::string& key,
184 bool metadata) override;
185
187
189 StatusCode initStats();
190
192 StatusCode record(std::unique_ptr<TAuxStore> store, const std::string& key);
195 StatusCode setUpDynamicStore(TObjectManager& mgr, ::TTree* tree);
197 StatusCode putAux(::TTree& outTree, TVirtualManager& mgr, bool metadata);
199 StatusCode recordAux(TAuxStore* store, const std::string& key);
200
203
205 ::TTree* m_inTree = nullptr;
208 bool m_inTreeMissing = false;
210 ::TChain* m_inChain = nullptr;
212 std::unique_ptr<TChainStateTracker> m_inChainTracker;
214 ::Int_t m_inTreeNumber = -1;
216 ::TTree* m_inMetaTree = nullptr;
218 ::Long64_t m_entry = -1;
219
221 std::unique_ptr<::TTree> m_outTree;
222
223 // Regular expression to match other MetaData trees in augmented files
224 // Other MetaData trees should be called MetaData_* but not named
225 // MetaDataHdr_* Those additional trees are only expected for augmented files
227 std::regex("^MetaData(?!Hdr)_.*$");
228}; // class TEvent
229
230} // namespace xAOD
231
232#endif // XAODROOTACCESS_TEVENT_H
Algorithm writing an xAOD output file.
AuxStoreType
Type of the auxiliary store.
@ AST_ContainerStore
The store describes a container.
Interface for non-const operations on an auxiliary store.
Definition IAuxStore.h:48
Specialised class for browsing xAOD event interface objects in ROOT.
Specialised class for browsing xAOD metadata interface objects in ROOT.
Manager for EDM objects created by ROOT.
static const char *const EVENT_TREE_NAME
Default name of the event TTree.
Definition Event.h:76
Event(std::string_view name)
Constructor with a name.
Definition EventCore.cxx:27
StatusCode record(T *obj, const std::string &key)
Add an output object to the event.
"ROOT @c TTree implementation" of IAuxStore
Definition TAuxStore.h:30
Class helping with tracking the state of TChain objects.
Tool for accessing xAOD files outside of Athena.
@ kAthenaAccess
Access containers/objects like Athena does.
@ kClassAccess
Access auxiliary data using the aux containers.
@ kBranchAccess
Access auxiliary data branch-by-branch.
::TTree * m_inMetaTree
Pointer to the metadata tree in the input file.
StatusCode connectObject(const std::string &key, bool silent) override
Function setting up access to a particular object.
StatusCode connectMetaAux(const std::string &prefix, bool standalone) override
Function setting up access to a set of auxiliary branches for a metadata object.
StatusCode connectAux(const std::string &prefix, bool standalone) override
Function setting up access to a set of auxiliary branches.
StatusCode writeTo(::TFile *file, int autoFlush=200, std::string_view treeName=EVENT_TREE_NAME)
Connect the object to an output file.
friend::TTree * MakeTransientTree(TEvent &, const char *)
bool hasOutput() const override
Check if an output file is connected to the object.
std::unique_ptr< TChainStateTracker > m_inChainTracker
Optional object for tracking the state changes of an input TChain.
StatusCode finishWritingTo(::TFile *file)
Finish writing to an output file.
::Int_t fill()
Function filling one event into the output tree.
::Int_t getEntry(::Long64_t entry, ::Int_t getall=0) override
Function loading a given entry of the input TTree.
StatusCode setAuxStore(const std::string &key, Details::IObjectManager &mgr, bool metadata) override
Function connecting a DV object to its auxiliary store.
EAuxMode auxMode() const
Get what auxiliary access mode the object was constructed with.
bool hasInput() const override
Check if an input file is connected to the object.
StatusCode initStats()
Function to initialise the statistics for all Tree content.
::Long64_t m_entry
The entry to look at from the input tree.
::Long64_t getFiles() const
Get how many files are available on the currently defined input.
void setOtherMetaDataTreeNamePattern(const std::string &pattern)
Change the pattern used for collecting information from other MetaData trees NB: Additional MetaData ...
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.
StatusCode setUpDynamicStore(TObjectManager &mgr, ::TTree *tree)
Function adding dynamic variable reading capabilities to an auxiliary store object.
::TChain * m_inChain
The (optional) chain provided as input.
StatusCode putAux(::TTree &outTree, TVirtualManager &mgr, bool metadata)
Function saving the dynamically created auxiliary properties.
EAuxMode m_auxMode
The auxiliary access mode.
StatusCode readFrom(::TFile &inFile) override
Set up the reading of an input file from TFile This method implements the interface from Event.
TEvent(EAuxMode mode=kClassAccess)
Default constructor.
SG::IAuxStore * recordAux(const std::string &key, SG::IAuxStoreHolder::AuxStoreType type=SG::IAuxStoreHolder::AST_ContainerStore)
Add an auxiliary store object to the output.
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.
std::unique_ptr<::TTree > m_outTree
The tree that we are writing to.
bool m_inTreeMissing
Internal status flag showing that an input file is open, but it doesn't contain an event tree.
::Int_t m_inTreeNumber
The number of the currently open tree in the input chain.
::Int_t getFile(::Long64_t file, ::Int_t getall=0)
Load the first event for a given file from the input TChain.
::TTree * m_inTree
The main tree that we are reading from.
StatusCode connectMetaObject(const std::string &key, bool silent) override
Function setting up access to a particular metadata object.
::Long64_t getEntries() const override
Get how many entries are available from the current input file(s)
Helper class for merging xAOD files.
Definition TFileMerger.h:47
Manager for EDM objects created by ROOT.
Class creating (a) transient tree(s) from xAOD files.
Definition TTreeMgr.h:34
Interface class for the "manager classes".
Select isolated Photons, Electrons and Muons.
Forward declaration.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
void ClearTransientTrees ATLAS_NOT_THREAD_SAFE()
Function cleaning up the managed memory.
TChain * tree
TFile * file