ATLAS Offline Software
xAODtoHepMCTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*
6  * dual-use tool for converting xAOD truth events back to HepMC
7  * Principal Authors (responsible for the core conversion algorithm): Josh McFayden and James Catmore
8  * Tool Author: Jim Lacey (Carleton University)
9  * ... updated tool interface to be dual-use
10  * ... added missing PDF information and requirements to allow running on full sim (remove Geant4 secondaries)
11  * <james.lacey@cern.ch,jlacey@physics.carleton.ca>
12  * <dag.gillberg@cern.ch>
13  */
14 
15 #ifndef TRUTHCONVERTERS_XAODTOHEPMCTOOL_H
16 #define TRUTHCONVERTERS_XAODTOHEPMCTOOL_H 1
17 
18 #include "AsgTools/AsgTool.h"
20 
21 
22 class xAODtoHepMCTool: public asg::AsgTool, public virtual IxAODtoHepMCTool {
23 public:
25  xAODtoHepMCTool( const std::string& name );
26  virtual ~xAODtoHepMCTool () { };
27 
28  virtual StatusCode initialize() override;
29  StatusCode finalize () override;
30 
31 public:
32  std::vector<HepMC::GenEvent> getHepMCEvents(const xAOD::TruthEventContainer* xTruthEventContainer, const xAOD::EventInfo* eventInfo) const override;
33 
34 private:
35  HepMC::GenEvent createHepMCEvent(const xAOD::TruthEvent* xEvt, const xAOD::EventInfo* eventInfo) const;
36  HepMC::GenVertexPtr vertexHelper(const xAOD::TruthVertex*,std::map<const xAOD::TruthVertex*,HepMC::GenVertexPtr>&,bool&) const;
39  void printxAODEvent(const xAOD::TruthEvent* event, const xAOD::EventInfo* eventInfo) const;
40 
41 private:
43  Gaudi::Property<float> m_momFac {
44  this, "MomentFactor", 0.001,
45  "Scale factor to be applied to truth energy and momenta to convert from MeV, e.g. 0.001 to go to GeV"};
46  Gaudi::Property<float> m_lenFac {
47  this, "LengthFactor", 1.0,
48  "Scale factor to be applied to truth lengths to convert from mm, e.g. 0.01 to go to cm"};
49  Gaudi::Property<bool> m_signalOnly {
50  this, "SignalOnly", true,
51  "Convert only the signal event (true), or all events found"};
52  Gaudi::Property<int> m_maxCount {
53  this, "PrintNevents", 0,
54  "Maximum number of events to print out"};
56  //not sure if these need to be atomic but just in case this will run in MT
57  mutable std::atomic<int> m_evtCount;
58  mutable std::atomic<int> m_badSuggest;
61 
62 };
63 
64 #endif //> !XAODTOHEPMC_XAODTOHEPMCTOOL_H
HepMC::GenVertexPtr
HepMC::GenVertex * GenVertexPtr
Definition: GenVertex.h:59
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
xAODtoHepMCTool::m_signalOnly
Gaudi::Property< bool > m_signalOnly
Definition: xAODtoHepMCTool.h:49
xAODtoHepMCTool::xAODtoHepMCTool
xAODtoHepMCTool(const std::string &name)
Definition: xAODtoHepMCTool.cxx:11
IxAODtoHepMCTool.h
HepMC::GenParticlePtr
GenParticle * GenParticlePtr
Definition: GenParticle.h:37
xAODtoHepMCTool::m_badBeams
int m_badBeams
Definition: xAODtoHepMCTool.h:60
xAODtoHepMCTool::printxAODEvent
void printxAODEvent(const xAOD::TruthEvent *event, const xAOD::EventInfo *eventInfo) const
Definition: xAODtoHepMCTool.cxx:321
xAODtoHepMCTool::m_evtCount
std::atomic< int > m_evtCount
Counters.
Definition: xAODtoHepMCTool.h:57
xAODtoHepMCTool::m_noProdVtx
int m_noProdVtx
Definition: xAODtoHepMCTool.h:59
xAODtoHepMCTool::m_maxCount
Gaudi::Property< int > m_maxCount
Definition: xAODtoHepMCTool.h:52
xAODtoHepMCTool::createHepMCEvent
HepMC::GenEvent createHepMCEvent(const xAOD::TruthEvent *xEvt, const xAOD::EventInfo *eventInfo) const
Definition: xAODtoHepMCTool.cxx:102
xAODtoHepMCTool
Definition: xAODtoHepMCTool.h:22
xAODtoHepMCTool::~xAODtoHepMCTool
virtual ~xAODtoHepMCTool()
Definition: xAODtoHepMCTool.h:26
xAODtoHepMCTool::finalize
StatusCode finalize() override
Definition: xAODtoHepMCTool.cxx:27
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:41
xAODtoHepMCTool::m_lenFac
Gaudi::Property< float > m_lenFac
Definition: xAODtoHepMCTool.h:46
xAOD::TruthEvent_v1
Class describing a signal truth event in the MC record.
Definition: TruthEvent_v1.h:35
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::TruthVertex_v1
Class describing a truth vertex in the MC record.
Definition: TruthVertex_v1.h:41
xAODtoHepMCTool::createHepMCParticle
HepMC::GenParticlePtr createHepMCParticle(const xAOD::TruthParticle *) const
Definition: xAODtoHepMCTool.cxx:300
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
IxAODtoHepMCTool
Definition: IxAODtoHepMCTool.h:34
xAODtoHepMCTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: xAODtoHepMCTool.cxx:16
xAODtoHepMCTool::vertexHelper
HepMC::GenVertexPtr vertexHelper(const xAOD::TruthVertex *, std::map< const xAOD::TruthVertex *, HepMC::GenVertexPtr > &, bool &) const
Definition: xAODtoHepMCTool.cxx:275
ASG_TOOL_CLASS
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Definition: AsgToolMacros.h:68
xAODtoHepMCTool::createHepMCVertex
HepMC::GenVertexPtr createHepMCVertex(const xAOD::TruthVertex *) const
Definition: xAODtoHepMCTool.cxx:311
xAODtoHepMCTool::getHepMCEvents
std::vector< HepMC::GenEvent > getHepMCEvents(const xAOD::TruthEventContainer *xTruthEventContainer, const xAOD::EventInfo *eventInfo) const override
Definition: xAODtoHepMCTool.cxx:65
xAODtoHepMCTool::m_momFac
Gaudi::Property< float > m_momFac
Input container key (job property)
Definition: xAODtoHepMCTool.h:43
AsgTool.h
xAODtoHepMCTool::m_badSuggest
std::atomic< int > m_badSuggest
Definition: xAODtoHepMCTool.h:58