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
100 static const char *const EVENT_TREE_NAME;
101
103 StatusCode readFrom(::TFile *file, bool useTreeCache = true,
104 std::string_view treeName = EVENT_TREE_NAME);
106 StatusCode readFrom(::TTree *tree, bool useTreeCache = true);
108 StatusCode writeTo(::TFile *file, int autoFlush = 200,
109 std::string_view treeName = EVENT_TREE_NAME);
111 StatusCode finishWritingTo(::TFile *file);
112
114
117
118 // Bring the definition of Event::record into scope
119 using Event::record;
120
122 SG::IAuxStore *recordAux(const std::string &key,
125
127
130
132 ::Long64_t getEntries() const;
134 ::Int_t getEntry(::Long64_t entry, ::Int_t getall = 0);
135
137 ::Long64_t getFiles() const;
139 ::Int_t getFile(::Long64_t file, ::Int_t getall = 0);
140
142 ::Int_t fill();
143
145
146protected:
149
151 bool hasInput() const override;
153 bool hasOutput() const override;
154
156 StatusCode getNames(const std::string &targetClassName,
157 std::vector<std::string> &vkeys,
158 bool metadata) const override;
159
161 StatusCode connectObject(const std::string &key, bool silent) override;
163 StatusCode connectMetaObject(const std::string &key, bool silent) override;
165 StatusCode connectAux(const std::string &prefix, bool standalone) override;
168 StatusCode connectMetaAux(const std::string &prefix,
169 bool standalone) override;
170
172 StatusCode setAuxStore(const std::string &key, Details::IObjectManager &mgr,
173 bool metadata) override;
174
176 StatusCode record(void *obj, const std::string &typeName,
177 const std::string &key, bool overwrite, bool metadata,
178 bool isOwner) override;
180 StatusCode recordAux(TVirtualManager &mgr, const std::string &key,
181 bool metadata) override;
182
184
186 StatusCode initStats();
187
189 StatusCode record(std::unique_ptr<TAuxStore> store, const std::string &key);
192 StatusCode setUpDynamicStore(TObjectManager &mgr, ::TTree *tree);
194 StatusCode putAux(::TTree &outTree, TVirtualManager &mgr, bool metadata);
196 StatusCode recordAux(TAuxStore *store, const std::string &key);
197
200
202 ::TTree *m_inTree = nullptr;
205 bool m_inTreeMissing = false;
207 ::TChain *m_inChain = nullptr;
209 std::unique_ptr<TChainStateTracker> m_inChainTracker;
211 ::Int_t m_inTreeNumber = -1;
213 ::TTree *m_inMetaTree = nullptr;
215 ::Long64_t m_entry = -1;
216
218 std::unique_ptr<::TTree> m_outTree;
219
220 // Regular expression to match other MetaData trees in augmented files
221 // Other MetaData trees should be called MetaData_* but not named
222 // MetaDataHdr_* Those additional trees are only expected for augmented files
224 std::regex("^MetaData(?!Hdr)_.*$");
225}; // class TEvent
226
227} // namespace xAOD
228
229#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.
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.
::Long64_t getEntries() const
Get how many entries are available from the current input file(s)
StatusCode finishWritingTo(::TFile *file)
Finish writing to an output file.
::Int_t fill()
Function filling one event into the output tree.
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 readFrom(::TFile *file, bool useTreeCache=true, std::string_view treeName=EVENT_TREE_NAME)
Connect the object to a new input file.
StatusCode putAux(::TTree &outTree, TVirtualManager &mgr, bool metadata)
Function saving the dynamically created auxiliary properties.
EAuxMode m_auxMode
The auxiliary access mode.
TEvent(EAuxMode mode=kClassAccess)
Default constructor.
::Int_t getEntry(::Long64_t entry, ::Int_t getall=0)
Function loading a given entry of the input TTree.
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.
static const char *const EVENT_TREE_NAME
Default name of the event tree.
::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.
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