ATLAS Offline Software
Loading...
Searching...
No Matches
AsgxAODNTupleMakerAlg.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 ASGANALYSISALGORITHMS_ASGXAODNTUPLEMAKERALG_H
6#define ASGANALYSISALGORITHMS_ASGXAODNTUPLEMAKERALG_H
7
8// System include(s):
9#include <unordered_map>
10#include <string>
11#include <vector>
12#include <memory>
13#include <list>
14
15// Framework include(s):
22
23// EDM include(s):
26
27// Forward declaration(s):
28class TClass;
29class TTree;
30class TVirtualCollectionProxy;
31namespace SG {
32 class AuxVectorBase;
34}
35
36namespace CP {
37
60
61 public:
64
67
69 StatusCode initialize() override;
70
72 StatusCode execute() override;
73
75 StatusCode finalize() override;
76
78
79 private:
81 StatusCode setupTree();
82
84 StatusCode setupBranch( const std::string &branchDecl,
85 const CP::SystematicSet &sys );
86
89
91 Gaudi::Property<std::string> m_treeName {this, "TreeName", "physics", "Name of the tree to write"};
93 Gaudi::Property<std::vector<std::string>> m_branches {this, "Branches", {}, "Branches to write to the output tree"};
94
96
104
105 public:
113
123 StatusCode process( const SG::AuxElement& element );
124
141 StatusCode addBranch( TTree& tree, const std::string& auxName,
142 const std::string& branchName,
143 bool allowMissing,
144 bool &created );
145
146 private:
163
164 public:
179 StatusCode setup( TTree& tree, const std::string& auxName,
180 const std::string& branchName,
181 MsgStream& msg );
182
195 StatusCode process( const SG::AuxElement& element,
196 MsgStream& msg );
197
199 std::string m_branchName;
201 std::unique_ptr< SG::TypelessConstAccessor > m_acc;
205 std::unique_ptr< SG::IAuxTypeVector > m_data;
207 void* m_dataPtr = nullptr;
208
209 }; // class BranchProcessor
210
220 std::list< BranchProcessor > m_branches;
221
222 }; // class ElementProcessor
223
236
237 public:
245
256 StatusCode process( const SG::AuxVectorBase& container, const TClass& cl);
257
274 StatusCode addBranch( TTree& tree, const std::string& auxName,
275 const std::string& branchName,
276 bool allowMissing,
277 bool &created );
278
279 private:
302
303 public:
305 StatusCode setup( TTree& tree, const std::string& auxName,
306 const std::string& branchName,
307 MsgStream& msg );
309 StatusCode resize( size_t size, MsgStream& msg );
311 StatusCode process( const SG::AuxElement& element, size_t index,
312 MsgStream& msg );
313
315 std::string m_branchName;
317 std::unique_ptr< SG::TypelessConstAccessor > m_acc;
321 std::unique_ptr< SG::IAuxTypeVector > m_data;
323 void* m_dataPtr = nullptr;
324
325 }; // class BranchProcessor
326
336 std::list< BranchProcessor > m_branches;
338 TVirtualCollectionProxy* m_collProxy = nullptr;
341
342 }; // class ContainerProcessor
343
346
348 TTree* m_tree = nullptr;
349
351 std::unordered_map< std::string, ElementProcessor > m_elements;
353 std::unordered_map< std::string, ContainerProcessor > m_containers;
354
361 bool m_isInitialized = false;
362
364 ServiceHandle<ISystematicsSvc> m_systematicsService {this, "systematicsService", "SystematicsSvc", "systematics service"};
365
367
368 }; // class AsgxAODNTupleMakerAlg
369
370} // namespace CP
371
372#endif // ASGANALYSISALGORITHMS_ASGXAODNTUPLEMAKERALG_H
Base class for elements of a container that can have aux data.
Abstract interface for manipulating vectors of arbitrary types.
Define macros for attributes used to control the static checker.
TTree * tree(const std::string &treeName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered TTrees.
Class writing one variable from an xAOD object into a branch.
std::unique_ptr< SG::IAuxTypeVector > m_data
The object managing the memory of the written variable.
const SG::IAuxTypeVectorFactory * m_factory
Pointer to the helper object that handles this variable.
void * m_dataPtr
Helper variable, pointing at the object to be written.
std::unique_ptr< SG::TypelessConstAccessor > m_acc
Object accessing the variable in question.
StatusCode resize(size_t size, MsgStream &msg)
Function (re)sizing the variable for a new event.
std::list< BranchProcessor > m_branches
List of branch processors set up for this xAOD object.
StatusCode addBranch(TTree &tree, const std::string &auxName, const std::string &branchName, bool allowMissing, bool &created)
Add one branch to the output tree.
TVirtualCollectionProxy * m_collProxy
Collection proxy used for iterating over the container.
int m_auxElementOffset
Offset of the element type to SG::AuxElement.
Class writing one variable from an xAOD object into a branch.
std::unique_ptr< SG::TypelessConstAccessor > m_acc
Object accessing the variable in question.
const SG::IAuxTypeVectorFactory * m_factory
Pointer to the helper object that handles this variable.
void * m_dataPtr
Helper variable, pointing at the object to be written.
std::string m_branchName
Name of the branch being written.
std::unique_ptr< SG::IAuxTypeVector > m_data
The object managing the memory of the written variable.
StatusCode addBranch(TTree &tree, const std::string &auxName, const std::string &branchName, bool allowMissing, bool &created)
Add one branch to the output tree.
std::list< BranchProcessor > m_branches
List of branch processors set up for this xAOD object.
Algorithm that can write a simple ntuple from xAOD objects/variables.
ServiceHandle< ISystematicsSvc > m_systematicsService
the handle for the systematics service
StatusCode execute() override
Function executed once per event.
StatusCode setupBranch(const std::string &branchDecl, const CP::SystematicSet &sys)
Function setting up an individual branch on the first event.
std::unordered_map< std::string, ElementProcessor > m_elements
Objects to write branches from.
StatusCode finalize() override
Function executed as part of the job finalisation.
bool m_isInitialized
Internal status flag, showing whether the algorithm is initialised.
Gaudi::Property< std::string > m_treeName
The name of the output tree to write.
StatusCode setupTree()
Function setting up the internal data structures on the first event.
TTree * m_tree
The tree being written.
Gaudi::Property< std::vector< std::string > > m_branches
The branches to write into this output tree.
std::unordered_map< std::string, ContainerProcessor > m_containers
Containers to write branches from.
Class to wrap a set of SystematicVariations.
the (new) base class for EventLoop algorithms
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
Base class for elements of a container that can have aux data.
Definition AuxElement.h:483
Manage index tracking and synchronization of auxiliary data.
Interface for factory objects that create vectors.
Class mimicking the AthMessaging class from the offline software.
MsgStream & msg() const
The standard message stream.
bool setup(asg::AnaToolHandle< Interface > &tool, const std::string &type, const std::vector< std::string > &config, const std::string &progressFile="")
mostly useful for athena, which will otherwise re-use the previous tool
const std::string process
Select isolated Photons, Electrons and Muons.
Forward declaration.
Definition index.py:1
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
void initialize()