ATLAS Offline Software
HepMcTupleWriterTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // HepMcTupleWriterTool.h
6 // Header file for class HepMcTupleWriterTool
7 // Author: S.Binet<binet@cern.ch>
9 #ifndef MCPARTICLETOOLS_HEPMCTUPLEWRITERTOOL_H
10 #define MCPARTICLETOOLS_HEPMCTUPLEWRITERTOOL_H
11 
12 // STL includes
13 #include <string>
14 
15 
16 #include <array>
17 
18 // FrameWork includes
19 #include "GaudiKernel/ServiceHandle.h"
21 
22 // McParticleKernel includes
23 #include "TruthIO/IIOHepMcTool.h"
24 
25 // Forward declaration
26 class ITHistSvc;
27 class TTree;
29 
30 class HepMcTupleWriterTool : virtual public IIOHepMcTool, public AthAlgTool
31 {
32 
34  // Public methods:
36  public:
37 
38  // Copy constructor:
39 
41  HepMcTupleWriterTool( const std::string& type, const std::string& name, const IInterface* parent );
42 
44  virtual ~HepMcTupleWriterTool();
45 
46  // Athena algorithm's Hooks
50 
52  // Non-const methods:
54 
57  StatusCode write( const HepMC::GenEvent* evt );
58 
60  // Protected methods:
62  protected:
63 
67 
71  void setupBackend( Gaudi::Details::PropertyBase& outputFileName );
72 
76  void bookTuple();
77 
79  // Protected data:
81  protected:
82 
84  static const int s_nMax = 2000;
85 
87  struct HepMcParticles {
89  std::array<double, s_nMax> m_px;
90  std::array<double, s_nMax> m_py;
91  std::array<double, s_nMax> m_pz;
92  std::array<double, s_nMax> m_m;
93  std::array<double, s_nMax> m_ene;
94  std::array<int, s_nMax> m_pdgId;
95  std::array<int, s_nMax> m_status;
96  std::array<int, s_nMax> m_barcode;
97  };
100 
103 
108  StringProperty m_mcEventsName;
109 
111  StringProperty m_outputFileName;
112 
114  StringProperty m_outputStreamName;
115 
117  TTree* m_tuple;
118 };
119 
120 #endif //> MCPARTICLETOOLS_HEPMCTUPLEWRITERTOOL_H
HepMcTupleWriterTool::m_outputStreamName
StringProperty m_outputStreamName
Name of the output tuple stream.
Definition: HepMcTupleWriterTool.h:114
HepMcTupleWriterTool::HepMcParticles::m_ene
std::array< double, s_nMax > m_ene
Definition: HepMcTupleWriterTool.h:93
HepMcTupleWriterTool::m_outputFileName
StringProperty m_outputFileName
Name of the output tuple file.
Definition: HepMcTupleWriterTool.h:111
HepMcTupleWriterTool::HepMcParticles::m_pdgId
std::array< int, s_nMax > m_pdgId
Definition: HepMcTupleWriterTool.h:94
HepMcTupleWriterTool::m_particles
HepMcParticles m_particles
our cached particles
Definition: HepMcTupleWriterTool.h:99
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
HepMcTupleWriterTool::HepMcTupleWriterTool
HepMcTupleWriterTool()
Default constructor:
HepMcTupleWriterTool::bookTuple
void bookTuple()
book the tuple
Definition: HepMcTupleWriterTool.cxx:181
HepMcTupleWriterTool::m_tupleSvc
ServiceHandle< ITHistSvc > m_tupleSvc
Pointer to @ ITHistSvc.
Definition: HepMcTupleWriterTool.h:102
HepMcTupleWriterTool::s_nMax
static const int s_nMax
maximum number of particles per event
Definition: HepMcTupleWriterTool.h:84
HepMcTupleWriterTool::HepMcParticles::m_py
std::array< double, s_nMax > m_py
Definition: HepMcTupleWriterTool.h:90
IIOHepMcTool
Definition: IIOHepMcTool.h:25
HepMcTupleWriterTool::execute
StatusCode execute()
Definition: HepMcTupleWriterTool.cxx:97
HepMcTupleWriterTool::HepMcParticles::m_nParticles
int m_nParticles
Definition: HepMcTupleWriterTool.h:88
HepMcTupleWriterTool::setupBackend
void setupBackend(Gaudi::Details::PropertyBase &outputFileName)
Method to configure the back-end to write out the HepMC::GenEvent.
Definition: HepMcTupleWriterTool.cxx:153
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthAlgTool.h
GenEvent_fwd.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
IIOHepMcTool.h
HepMcTupleWriterTool::m_mcEventsName
StringProperty m_mcEventsName
Location of the McEventCollection to be written out If there is more than 1 HepMC::GenEvent in the Mc...
Definition: HepMcTupleWriterTool.h:108
HepMcTupleWriterTool::HepMcParticles::m_m
std::array< double, s_nMax > m_m
Definition: HepMcTupleWriterTool.h:92
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
HepMcTupleWriterTool::finalize
StatusCode finalize()
Definition: HepMcTupleWriterTool.cxx:91
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
HepMcTupleWriterTool
Definition: HepMcTupleWriterTool.h:31
HepMcTupleWriterTool::HepMcParticles::m_pz
std::array< double, s_nMax > m_pz
Definition: HepMcTupleWriterTool.h:91
HepMcTupleWriterTool::m_tuple
TTree * m_tuple
cached pointer to the tuple
Definition: HepMcTupleWriterTool.h:117
HepMcTupleWriterTool::write
StatusCode write(const HepMC::GenEvent *evt)
Process the HepMC::GenEvent through the I/O backend.
Definition: HepMcTupleWriterTool.cxx:124
HepMcTupleWriterTool::HepMcParticles::m_barcode
std::array< int, s_nMax > m_barcode
Definition: HepMcTupleWriterTool.h:96
AthAlgTool
Definition: AthAlgTool.h:26
HepMcTupleWriterTool::HepMcParticles::m_px
std::array< double, s_nMax > m_px
Definition: HepMcTupleWriterTool.h:89
HepMcTupleWriterTool::~HepMcTupleWriterTool
virtual ~HepMcTupleWriterTool()
Destructor:
Definition: HepMcTupleWriterTool.cxx:59
AthenaPoolExample_Copy.outputFileName
string outputFileName
Definition: AthenaPoolExample_Copy.py:40
HepMcTupleWriterTool::HepMcParticles::m_status
std::array< int, s_nMax > m_status
Definition: HepMcTupleWriterTool.h:95
HepMcTupleWriterTool::HepMcParticles
A simple representation of a HepMc particle.
Definition: HepMcTupleWriterTool.h:87
ServiceHandle< ITHistSvc >
HepMcTupleWriterTool::initialize
StatusCode initialize()
Athena Algorithm's Hooks.
Definition: HepMcTupleWriterTool.cxx:66