ATLAS Offline Software
AsgxAODNTupleMakerAlg.h
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 //
3 // Copyright (C) 2002-2024 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):
28 class TClass;
29 class TTree;
30 class TVirtualCollectionProxy;
31 namespace SG {
32  class AuxVectorBase;
33  class IAuxTypeVectorFactory;
34 }
35 
36 namespace 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::AuxElement::TypelessConstAccessor > m_acc;
203  const SG::IAuxTypeVectorFactory* m_factory = nullptr;
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::AuxElement::TypelessConstAccessor > m_acc;
319  const SG::IAuxTypeVectorFactory* m_factory = nullptr;
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;
340  int m_auxElementOffset = -1;
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
CP::AsgxAODNTupleMakerAlg
Algorithm that can write a simple ntuple from xAOD objects/variables.
Definition: AsgxAODNTupleMakerAlg.h:59
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:53
PropertyWrapper.h
CP::AsgxAODNTupleMakerAlg::ContainerProcessor
Class writing all variables from one DataVector container.
Definition: AsgxAODNTupleMakerAlg.h:235
CP::AsgxAODNTupleMakerAlg::ElementProcessor::m_branches
std::list< BranchProcessor > m_branches
List of branch processors set up for this xAOD object.
Definition: AsgxAODNTupleMakerAlg.h:220
CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor::m_acc
std::unique_ptr< SG::AuxElement::TypelessConstAccessor > m_acc
Object accessing the variable in question.
Definition: AsgxAODNTupleMakerAlg.h:317
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
ATLAS_NOT_THREAD_SAFE
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Definition: checker_macros.h:212
index
Definition: index.py:1
SG::AuxElement
Base class for elements of a container that can have aux data.
Definition: AuxElement.h:446
SysListHandle.h
initialize
void initialize()
Definition: run_EoverP.cxx:894
tree
TChain * tree
Definition: tile_monitor.h:30
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor
Class writing one variable from an xAOD object into a branch.
Definition: AsgxAODNTupleMakerAlg.h:301
CP::AsgxAODNTupleMakerAlg::ElementProcessor::BranchProcessor::m_data
std::unique_ptr< SG::IAuxTypeVector > m_data
The object managing the memory of the written variable.
Definition: AsgxAODNTupleMakerAlg.h:205
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
EL::AnaAlgorithm::AnaAlgorithm
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
Definition: AnaAlgorithm.cxx:40
SUSY_SimplifiedModel_PostInclude.process
string process
Definition: SUSY_SimplifiedModel_PostInclude.py:42
SG::AuxVectorBase
Manage index tracking and synchronization of auxiliary data.
Definition: AuxVectorBase.h:98
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
CP::AsgxAODNTupleMakerAlg::ElementProcessor::BranchProcessor
Class writing one variable from an xAOD object into a branch.
Definition: AsgxAODNTupleMakerAlg.h:162
CP::AsgxAODNTupleMakerAlg::ContainerProcessor::m_branches
std::list< BranchProcessor > m_branches
List of branch processors set up for this xAOD object.
Definition: AsgxAODNTupleMakerAlg.h:336
IAuxTypeVector.h
Abstract interface for manipulating vectors of arbitrary types.
LArG4FSStartPointFilterLegacy.execute
execute
Definition: LArG4FSStartPointFilterLegacy.py:20
AsgMessaging.h
AnaAlgorithm.h
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor::m_branchName
std::string m_branchName
Name of the branch being written.
Definition: AsgxAODNTupleMakerAlg.h:315
EL::AnaAlgorithm
the (new) base class for EventLoop algorithms
Definition: AnaAlgorithm.h:73
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::IAuxTypeVectorFactory
Interface for factory objects that create vectors.
Definition: IAuxTypeVectorFactory.h:50
CP::AsgxAODNTupleMakerAlg::m_containers
std::unordered_map< std::string, ContainerProcessor > m_containers
Containers to write branches from.
Definition: AsgxAODNTupleMakerAlg.h:353
CP::AsgxAODNTupleMakerAlg::ElementProcessor::BranchProcessor::m_branchName
std::string m_branchName
Name of the branch being written.
Definition: AsgxAODNTupleMakerAlg.h:199
asg::AsgMessaging
Class mimicking the AthMessaging class from the offline software.
Definition: AsgMessaging.h:40
CP::AsgxAODNTupleMakerAlg::ElementProcessor::BranchProcessor::m_acc
std::unique_ptr< SG::AuxElement::TypelessConstAccessor > m_acc
Object accessing the variable in question.
Definition: AsgxAODNTupleMakerAlg.h:201
ServiceHandle.h
CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor::m_data
std::unique_ptr< SG::IAuxTypeVector > m_data
The object managing the memory of the written variable.
Definition: AsgxAODNTupleMakerAlg.h:321
CP::AsgxAODNTupleMakerAlg::ElementProcessor
Class writing all variables from one standalone object.
Definition: AsgxAODNTupleMakerAlg.h:103
setup
bool setup(asg::AnaToolHandle< Interface > &tool, const std::string &type)
mostly useful for athena, which will otherwise re-use the previous tool
Definition: fbtTestBasics.cxx:193
checker_macros.h
Define macros for attributes used to control the static checker.
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
CP::AsgxAODNTupleMakerAlg::m_elements
std::unordered_map< std::string, ElementProcessor > m_elements
Objects to write branches from.
Definition: AsgxAODNTupleMakerAlg.h:351
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
AuxElement.h
Base class for elements of a container that can have aux data.
ServiceHandle
Definition: ClusterMakerTool.h:37