ATLAS Offline Software
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
HepMcTupleWriterTool Class Reference

#include <HepMcTupleWriterTool.h>

Inheritance diagram for HepMcTupleWriterTool:
Collaboration diagram for HepMcTupleWriterTool:

Classes

struct  HepMcParticles
 A simple representation of a HepMc particle. More...
 

Public Member Functions

 HepMcTupleWriterTool (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor with parameters: More...
 
virtual ~HepMcTupleWriterTool ()
 Destructor: More...
 
StatusCode initialize ()
 Athena Algorithm's Hooks. More...
 
StatusCode execute ()
 
StatusCode finalize ()
 
StatusCode write (const HepMC::GenEvent *evt)
 Process the HepMC::GenEvent through the I/O backend. More...
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 I/O operators. More...
 

Protected Member Functions

 HepMcTupleWriterTool ()
 Default constructor: More...
 
void setupBackend (Gaudi::Details::PropertyBase &outputFileName)
 Method to configure the back-end to write out the HepMC::GenEvent. More...
 
void bookTuple ()
 book the tuple More...
 
void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
 
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed. More...
 

Protected Attributes

HepMcParticles m_particles {}
 our cached particles More...
 
ServiceHandle< ITHistSvc > m_tupleSvc
 Pointer to @ ITHistSvc. More...
 
StringProperty m_mcEventsName
 Location of the McEventCollection to be written out If there is more than 1 HepMC::GenEvent in the McEventCollection we will send warning messages, and just write the first one. More...
 
StringProperty m_outputFileName
 Name of the output tuple file. More...
 
StringProperty m_outputStreamName
 Name of the output tuple stream. More...
 
TTree * m_tuple
 cached pointer to the tuple More...
 

Static Protected Attributes

static const int s_nMax = 2000
 maximum number of particles per event More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

Definition at line 30 of file HepMcTupleWriterTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ HepMcTupleWriterTool() [1/2]

HepMcTupleWriterTool::HepMcTupleWriterTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Constructor with parameters:

Constructors.

Definition at line 28 of file HepMcTupleWriterTool.cxx.

30  :
32  m_tupleSvc ( "THistSvc", name ),
33  m_tuple ( nullptr )
34 {
35  //
36  // Property declaration
37  //
38 
39  declareProperty( "Output",
40  m_outputFileName = "hepmc.root",
41  "Name of the output file which will contain the HepMC tuple"
42  "\nEx: hepmc.root" );
43  m_outputFileName.declareUpdateHandler( &HepMcTupleWriterTool::setupBackend, this );
44 
45  declareProperty( "OutputStream",
46  m_outputStreamName = "hepmc",
47  "Name of the stream which will contain the HepMC tuple"
48  "\nEx: hepmc" );
49 
50  declareProperty( "McEvents",
51  m_mcEventsName = "GEN_EVENT",
52  "Input location of the McEventCollection to write out" );
53 
54  declareInterface<IIOHepMcTool>(this);
55 }

◆ ~HepMcTupleWriterTool()

HepMcTupleWriterTool::~HepMcTupleWriterTool ( )
virtual

Destructor:

Destructor.

Definition at line 59 of file HepMcTupleWriterTool.cxx.

60 {
61  ATH_MSG_DEBUG("Calling destructor");
62 }

◆ HepMcTupleWriterTool() [2/2]

HepMcTupleWriterTool::HepMcTupleWriterTool ( )
protected

Default constructor:

Member Function Documentation

◆ bookTuple()

void HepMcTupleWriterTool::bookTuple ( )
protected

book the tuple

Definition at line 180 of file HepMcTupleWriterTool.cxx.

181 {
182  const std::string streamName = m_outputStreamName.value();
183  TTree* t = new TTree("hepmc","HepMC validation tuple");
184  if ( !m_tupleSvc->regTree( "/" + streamName + "/hepmc", t ).isSuccess() ) {
185  ATH_MSG_ERROR("Could not register HepMC validation tuple !!");
186  delete t; t = nullptr;
187  throw GaudiException( "Could not register HepMC validation tuple !!", name(), StatusCode::FAILURE );
188  }
189 
190  // booking branches
191  t->Branch( "nParts", &m_particles.m_nParticles, "nParts/I" );
192 
193  t->Branch( "px", m_particles.m_px.data(), "px[nParts]/D" );
194  t->Branch( "py", m_particles.m_py.data(), "py[nParts]/D" );
195  t->Branch( "pz", m_particles.m_pz.data(), "pz[nParts]/D" );
196  t->Branch( "m", m_particles.m_m.data(), "m[nParts]/D" );
197  t->Branch( "e", m_particles.m_ene.data(), "e[nParts]/D" );
198 
199  t->Branch( "pdgId", m_particles.m_pdgId.data(), "pdgId[nParts]/I" );
200  t->Branch( "sc", m_particles.m_status.data(), "sc[nParts]/I" );
201  t->Branch( "bc", m_particles.m_barcode.data(), "bc[nParts]/I" );
202 
203  m_tuple = t;
204 }

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKeyArray>

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleBase>

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( ) const
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ execute()

StatusCode HepMcTupleWriterTool::execute ( )
virtual

Implements IIOHepMcTool.

Definition at line 97 of file HepMcTupleWriterTool.cxx.

98 {
99  // retrieve the McEventCollection
100  const McEventCollection * mcEvts = nullptr;
101  if ( evtStore()->retrieve( mcEvts, m_mcEventsName ).isFailure() || nullptr == mcEvts ) {
102  ATH_MSG_ERROR("Could not retrieve a McEventCollection at [" << m_mcEventsName << "] !!");
103  return StatusCode::FAILURE;
104  }
105 
106  if ( mcEvts->empty() ) {
107  ATH_MSG_WARNING("McEventCollection at ["<<m_mcEventsName<<"] is EMPTY !!");
108  return StatusCode::FAILURE;
109  }
110 
111  const HepMC::GenEvent * evt = mcEvts->front();
112  if ( !evt ) {
113  ATH_MSG_ERROR("Retrieved NULL pointer to HepMC::GenEvent !!");
114  return StatusCode::FAILURE;
115  }
116 
117  return write(evt);
118 }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase &  ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode HepMcTupleWriterTool::finalize ( )
virtual

Implements IIOHepMcTool.

Definition at line 91 of file HepMcTupleWriterTool.cxx.

92 {
93  ATH_MSG_INFO("Finalizing " << name() << "...");
94  return StatusCode::SUCCESS;
95 }

◆ initialize()

StatusCode HepMcTupleWriterTool::initialize ( )
virtual

Athena Algorithm's Hooks.

Implements IIOHepMcTool.

Definition at line 66 of file HepMcTupleWriterTool.cxx.

67 {
68  ATH_MSG_INFO("Initializing " << name() << "...");
69 
70  // Get pointer to StoreGateSvc and cache it :
71  if ( !evtStore().retrieve().isSuccess() ) {
72  ATH_MSG_ERROR("Unable to retrieve pointer to StoreGateSvc");
73  return StatusCode::FAILURE;
74  }
75 
76  // Get pointer to ITHistSvc and cache it :
77  if ( !m_tupleSvc.retrieve().isSuccess() ) {
78  ATH_MSG_ERROR("Unable to retrieve pointer to ITHistSvc");
79  return StatusCode::FAILURE;
80  }
81 
82  // setup backend
84 
85  // book tuple
86  bookTuple();
87 
88  return StatusCode::SUCCESS;
89 }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & IIOHepMcTool::interfaceID ( )
inlinestaticinherited

I/O operators.

Inline methods:

Definition at line 64 of file IIOHepMcTool.h.

65 {
66  return IID_IIOHepMcTool;
67 }

◆ msg() [1/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ outputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t<std::is_void_v<std::result_of_t<decltype(&T::renounce)(T)> > && !std::is_base_of_v<SG::VarHandleKeyArray, T> && std::is_base_of_v<Gaudi::DataHandle, T>, void> AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ setupBackend()

void HepMcTupleWriterTool::setupBackend ( Gaudi::Details::PropertyBase &  outputFileName)
protected

Method to configure the back-end to write out the HepMC::GenEvent.

Non-const methods:

Definition at line 153 of file HepMcTupleWriterTool.cxx.

154 {
155  SmartIF<IProperty> tSvc{m_tupleSvc.get()};
156  if ( !tSvc ) {
157  ATH_MSG_ERROR("Could not retrieve THistSvc handle !!");
158  throw GaudiException( "Could not retrieve THistSvc", name(), StatusCode::FAILURE );
159  }
160 
161  const std::string streamName = m_outputStreamName.value();
162 
163  const std::string propName = "Output";
164  StringArrayProperty outputFileName;
165  outputFileName.assign( tSvc->getProperty( propName ) );
166  std::vector<std::string> updatedProp( outputFileName.value() );
167  updatedProp.push_back
168  ( streamName+" DATAFILE='"+m_outputFileName.value()+"' "
169  "TYP='ROOT' "
170  "OPT='RECREATE'" );
171  outputFileName.set( updatedProp );
172  outputFileName.setName( propName );
173  if ( !tSvc->setProperty( outputFileName ).isSuccess() ) {
174  ATH_MSG_ERROR("Could not configure the THistSvc's output filename ["<< m_outputFileName.value() << "] !!");
175  throw GaudiException( "Could not configure THistSvc output file !!", name(), StatusCode::FAILURE );
176  }
177 
178  }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase &  )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

◆ write()

StatusCode HepMcTupleWriterTool::write ( const HepMC::GenEvent *  evt)

Process the HepMC::GenEvent through the I/O backend.

Non-const methods:

Definition at line 124 of file HepMcTupleWriterTool.cxx.

125 {
126  m_particles.m_nParticles = std::min<std::size_t>( s_nMax, evt->particles_size() );
127  std::size_t i = 0;
128  for (const auto& p: *evt)
129  {
130  if (i == static_cast<std::size_t>(m_particles.m_nParticles)) break;
131  i++;
132  const HepMC::FourVector mom = p->momentum();
133  m_particles.m_px [i] = mom.px();
134  m_particles.m_py [i] = mom.py();
135  m_particles.m_pz [i] = mom.pz();
136  m_particles.m_m [i] = mom.m();
137  m_particles.m_ene[i] = mom.e();
138 
139  m_particles.m_pdgId[i] = p->pdg_id();
140  m_particles.m_status[i] = p->status();
142  }
143  // commit event
144  m_tuple->Fill();
145 
146  return StatusCode::SUCCESS;
147 }

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_mcEventsName

StringProperty HepMcTupleWriterTool::m_mcEventsName
protected

Location of the McEventCollection to be written out If there is more than 1 HepMC::GenEvent in the McEventCollection we will send warning messages, and just write the first one.

Definition at line 108 of file HepMcTupleWriterTool.h.

◆ m_outputFileName

StringProperty HepMcTupleWriterTool::m_outputFileName
protected

Name of the output tuple file.

Definition at line 111 of file HepMcTupleWriterTool.h.

◆ m_outputStreamName

StringProperty HepMcTupleWriterTool::m_outputStreamName
protected

Name of the output tuple stream.

Definition at line 114 of file HepMcTupleWriterTool.h.

◆ m_particles

HepMcParticles HepMcTupleWriterTool::m_particles {}
protected

our cached particles

Definition at line 99 of file HepMcTupleWriterTool.h.

◆ m_tuple

TTree* HepMcTupleWriterTool::m_tuple
protected

cached pointer to the tuple

Definition at line 117 of file HepMcTupleWriterTool.h.

◆ m_tupleSvc

ServiceHandle<ITHistSvc> HepMcTupleWriterTool::m_tupleSvc
protected

Pointer to @ ITHistSvc.

Definition at line 102 of file HepMcTupleWriterTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ s_nMax

const int HepMcTupleWriterTool::s_nMax = 2000
staticprotected

maximum number of particles per event

Definition at line 84 of file HepMcTupleWriterTool.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
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
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
HepMcTupleWriterTool::m_outputFileName
StringProperty m_outputFileName
Name of the output tuple file.
Definition: HepMcTupleWriterTool.h:111
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
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
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
HepMcTupleWriterTool::bookTuple
void bookTuple()
book the tuple
Definition: HepMcTupleWriterTool.cxx:180
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
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:27
HepMcTupleWriterTool::HepMcParticles::m_py
std::array< double, s_nMax > m_py
Definition: HepMcTupleWriterTool.h:90
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
HepMcTupleWriterTool::HepMcParticles::m_nParticles
int m_nParticles
Definition: HepMcTupleWriterTool.h:88
lumiFormat.i
int i
Definition: lumiFormat.py:85
HepMcTupleWriterTool::setupBackend
void setupBackend(Gaudi::Details::PropertyBase &outputFileName)
Method to configure the back-end to write out the HepMC::GenEvent.
Definition: HepMcTupleWriterTool.cxx:153
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
DataVector::front
const T * front() const
Access the first element in the collection as an rvalue.
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
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
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
L1CaloPhase1Monitoring.propName
propName
Definition: L1CaloPhase1Monitoring.py:451
AthenaPoolExample_Copy.streamName
string streamName
Definition: AthenaPoolExample_Copy.py:39
a
TList * a
Definition: liststreamerinfos.cxx:10
h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
HepMcTupleWriterTool::HepMcParticles::m_pz
std::array< double, s_nMax > m_pz
Definition: HepMcTupleWriterTool.h:91
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:623
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
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
HepMcTupleWriterTool::HepMcParticles::m_barcode
std::array< int, s_nMax > m_barcode
Definition: HepMcTupleWriterTool.h:96
HepMcTupleWriterTool::HepMcParticles::m_px
std::array< double, s_nMax > m_px
Definition: HepMcTupleWriterTool.h:89
AthenaPoolExample_Copy.outputFileName
string outputFileName
Definition: AthenaPoolExample_Copy.py:40
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
HepMcTupleWriterTool::HepMcParticles::m_status
std::array< int, s_nMax > m_status
Definition: HepMcTupleWriterTool.h:95
fitman.k
k
Definition: fitman.py:528