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
10#ifdef HEPMC3
11// This form of ifdef is kept for convenience
12#else
13// The lines below I don't like. We should fix them when we update the
14// the metadata to handles (ATLASRECTS-4162).
15// Needs changes in HepMC to resolve.
16#ifdef __clang__
17#pragma clang diagnostic push
18#pragma clang diagnostic ignored "-Wkeyword-macro"
19#endif
20#define private public
22#undef private
23#ifdef __clang__
24#pragma clang diagnostic pop
25#endif
26#endif
27
30
42#include "GaudiKernel/IIncidentListener.h"
43
44#include <unordered_set>
45
46
51
53
54namespace xAODMaker {
55
66 , virtual public IIncidentListener
67{
68 public:
69
71 xAODTruthCnvAlg( const std::string& name, ISvcLocator* svcLoc );
72
74 virtual StatusCode initialize() override;
76 virtual StatusCode execute (const EventContext& ctx) const override;
77
79 virtual void handle(const Incident& incident) override;
80
81 private:
82 // Truth metadata fields retrieved from TagInfo
84 std::string lhefGenerator;
85 std::string generators;
86 std::string evgenProcess;
87 std::string evgenTune;
88 std::string hardPDF;
89 std::string softPDF;
90 };
91
95 {
96 public:
97 StatusCode initialize (ServiceHandle<StoreGateSvc>& metaStore,
98 const std::string& metaName);
99 StatusCode maybeWrite (uint32_t mcChannelNumber,
100 const HepMC::GenEvent& genEvt,
101 const MetadataFields& metaFields);
102
103 private:
105 std::mutex m_mutex;
106 typedef std::lock_guard<std::mutex> lock_t;
107
110
112 std::unordered_set<uint32_t> m_existingMetaDataChan;
113 };
114
117 std::vector<xAOD::TruthParticle*> incoming;
118 std::vector<ElementLink<xAOD::TruthParticleContainer> > incomingEL;
119 std::vector<xAOD::TruthParticle*> outgoing;
120 std::vector<ElementLink<xAOD::TruthParticleContainer> > outgoingEL;
121 };
122
123 typedef std::map<HepMC::ConstGenVertexPtr, VertexParticles> VertexMap;
124
126 static void fillVertex(xAOD::TruthVertex *tv, const HepMC::ConstGenVertexPtr& gv);
128
131 this, "AODContainerName", "GEN_AOD", "The input McEvenCollection"};
132
135 this, "xAODTruthEventContainerName", "TruthEvents", "Output TruthEvents container"};
137 this, "xAODTruthPileupEventContainerName", "TruthPileupEvents", "Output TruthPileupEvents container"};
139 this, "xAODTruthParticleContainerName", "TruthParticles", "Output TruthParticles container"};
141 this, "xAODTruthVertexContainerName", "TruthVertices", "Output TruthVertices container"};
143 this, "TruthLinks", "xAODTruthLinks", "Output xAODTruthLinks container"};
145 this, "xAODTruthLHEParticleContainerName", "", "Output TruthLHEParticles container"};
146
148 Gaudi::Property<bool> m_doAllPileUp{this, "WriteAllPileUpTruth", false};
149 Gaudi::Property<bool> m_doInTimePileUp{this, "WriteInTimePileUpTruth", false};
150
155
159 std::string m_metaName;
160
162 Gaudi::Property<bool> m_writeMetaData{this, "WriteTruthMetaData", true};
163
165 SG::ReadHandleKey<xAOD::EventInfo> m_evtInfo {this, "EventInfo", "EventInfo", "" };
166
170 }; // class xAODTruthCnvAlg
171
172
173} // namespace xAODMaker
174
175#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.
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.
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38
const HepMC::GenVertex * ConstGenVertexPtr
Definition GenVertex.h:60
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