ATLAS Offline Software
Loading...
Searching...
No Matches
xAODTruthCnvAlg.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#ifndef XAODCREATORALGS_XAODTRUTHCNVALG_H
6#define XAODCREATORALGS_XAODTRUTHCNVALG_H
7
9
12
24#include "GaudiKernel/IIncidentListener.h"
25
26#include <unordered_set>
27
28
32
34
35namespace xAODMaker {
36
47 , virtual public IIncidentListener
48{
49 public:
50
52 xAODTruthCnvAlg( const std::string& name, ISvcLocator* svcLoc );
53
55 virtual StatusCode initialize() override;
57 virtual StatusCode execute (const EventContext& ctx) const override;
58
60 virtual void handle(const Incident& incident) override;
61
62 private:
63 // Truth metadata fields retrieved from TagInfo
65 std::string lhefGenerator;
66 std::string generators;
67 std::string evgenProcess;
68 std::string evgenTune;
69 std::string hardPDF;
70 std::string softPDF;
71 };
72
76 {
77 public:
78 StatusCode initialize (ServiceHandle<StoreGateSvc>& metaStore,
79 const std::string& metaName);
80 StatusCode maybeWrite (uint32_t mcChannelNumber,
81 const HepMC::GenEvent& genEvt,
82 const MetadataFields& metaFields);
83
84 private:
86 std::mutex m_mutex;
87 typedef std::lock_guard<std::mutex> lock_t;
88
91
93 std::unordered_set<uint32_t> m_existingMetaDataChan;
94 };
95
98 std::vector<xAOD::TruthParticle*> incoming;
99 std::vector<ElementLink<xAOD::TruthParticleContainer> > incomingEL;
100 std::vector<xAOD::TruthParticle*> outgoing;
101 std::vector<ElementLink<xAOD::TruthParticleContainer> > outgoingEL;
102 };
103
104 typedef std::map<HepMC::ConstGenVertexPtr, VertexParticles> VertexMap;
105
107 static void fillVertex(xAOD::TruthVertex *tv, const HepMC::ConstGenVertexPtr& gv);
109
112 this, "AODContainerName", "GEN_AOD", "The input McEvenCollection"};
113
116 this, "xAODTruthEventContainerName", "TruthEvents", "Output TruthEvents container"};
118 this, "xAODTruthPileupEventContainerName", "TruthPileupEvents", "Output TruthPileupEvents container"};
120 this, "xAODTruthParticleContainerName", "TruthParticles", "Output TruthParticles container"};
122 this, "xAODTruthVertexContainerName", "TruthVertices", "Output TruthVertices container"};
124 this, "TruthLinks", "xAODTruthLinks", "Output xAODTruthLinks container"};
126 this, "xAODTruthLHEParticleContainerName", "", "Output TruthLHEParticles container"};
127
129 Gaudi::Property<bool> m_doAllPileUp{this, "WriteAllPileUpTruth", false};
130 Gaudi::Property<bool> m_doInTimePileUp{this, "WriteInTimePileUpTruth", false};
131
136
140 std::string m_metaName;
141
143 Gaudi::Property<bool> m_writeMetaData{this, "WriteTruthMetaData", true};
144
146 SG::ReadHandleKey<xAOD::EventInfo> m_evtInfo {this, "EventInfo", "EventInfo", "" };
147
151 }; // class xAODTruthCnvAlg
152
153
154} // namespace xAODMaker
155
156#endif // XAODCREATORALGS_XAODTRUTHCNVALG_H
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
Define macros for attributes used to control the static checker.
An algorithm that can be simultaneously executed in multiple threads.
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
Factor out the pieces dealing with writing to meta data.
std::mutex m_mutex
Mutex to control access to meta data writing.
std::lock_guard< std::mutex > lock_t
StatusCode maybeWrite(uint32_t mcChannelNumber, const HepMC::GenEvent &genEvt, const MetadataFields &metaFields)
std::unordered_set< uint32_t > m_existingMetaDataChan
Set for tracking the mc channels for which we already added meta data.
xAOD::TruthMetaDataContainer * m_tmd
The meta data container to be written out.
SG::WriteHandleKey< xAOD::TruthVertexContainer > m_xaodTruthVertexContainerKey
Gaudi::Property< bool > m_doAllPileUp
Pile-up options.
SG::WriteHandleKey< xAOD::TruthParticleContainer > m_lheTruthParticleContainerKey
MetaDataWriter m_meta ATLAS_THREAD_SAFE
Helper for writing to the meta data store.
SG::WriteHandleKey< xAODTruthParticleLinkVector > m_truthLinkContainerKey
SG::ReadHandleKey< McEventCollection > m_aodContainerKey
The key of the input AOD truth container.
static void fillVertex(xAOD::TruthVertex *tv, const HepMC::ConstGenVertexPtr &gv)
These functions do not set up ELs, just the other variables.
xAODTruthCnvAlg(const std::string &name, ISvcLocator *svcLoc)
Regular algorithm constructor.
SG::WriteHandleKey< xAOD::TruthParticleContainer > m_xaodTruthParticleContainerKey
Gaudi::Property< bool > m_writeMetaData
option to disable writing of metadata (e.g. if running a filter on xAOD in generators)
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
std::map< HepMC::ConstGenVertexPtr, VertexParticles > VertexMap
Convenience handle for a map of vtx ptrs -> connected particles.
ServiceHandle< StoreGateSvc > m_metaStore
Connection to the metadata store.
SG::ReadHandleKey< xAOD::EventInfo > m_evtInfo
Event Info.
Gaudi::Property< bool > m_doInTimePileUp
virtual void handle(const Incident &incident) override
Incident handler.
static void fillParticle(xAOD::TruthParticle *tp, const HepMC::ConstGenParticlePtr &gp)
std::string m_metaName
SG key and name for meta data.
SG::WriteHandleKey< xAOD::TruthEventContainer > m_xaodTruthEventContainerKey
The key for the output xAOD truth containers.
SG::WriteHandleKey< xAOD::TruthPileupEventContainer > m_xaodTruthPUEventContainerKey
virtual StatusCode initialize() override
Function initialising the algorithm.
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
Definition GenParticle.h:20
HepMC3::ConstGenVertexPtr ConstGenVertexPtr
Definition GenVertex.h:24
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39
TruthMetaDataContainer_v1 TruthMetaDataContainer
Declare the latest version of the truth vertex container.
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition TruthVertex.h:15
TruthParticle_v1 TruthParticle
Typedef to implementation.
Type for tracking particles connected to a single vertex.
std::vector< xAOD::TruthParticle * > outgoing
std::vector< ElementLink< xAOD::TruthParticleContainer > > incomingEL
std::vector< xAOD::TruthParticle * > incoming
std::vector< ElementLink< xAOD::TruthParticleContainer > > outgoingEL