ATLAS Offline Software
Loading...
Searching...
No Matches
HepMCWeightSvc.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef EVGENPRODTOOLS_HEPMCWEIGHTSVC_H
6#define EVGENPRODTOOLS_HEPMCWEIGHTSVC_H
7
12#include <string>
13
15
16#include "GaudiKernel/ToolHandle.h"
17#include <vector>
18#include <mutex>
19
24class HepMCWeightSvc : public extends<AthService, IHepMCWeightSvc>
25{
26public:
27 using base_class::base_class;
28
29
33 virtual StatusCode initialize() override;
34
35
43 virtual StatusCode
44 setWeightNames (const WeightMap& weightNames,
45 const EventContext& ctx = Gaudi::Hive::currentContext()) override;
46
47
51 virtual WeightMap
52 weightNames (const EventContext& ctx = Gaudi::Hive::currentContext()) override;
53
54
58 virtual std::vector<std::string>
59 weightNameVec (const EventContext& ctx = Gaudi::Hive::currentContext()) override;
60
61
62private:
69 unsigned long getChanNum (const EventContext& ctx) const;
70
71
78 unsigned int loadWeights (unsigned long chanNum);
79
80
87 unsigned int getWeightIndex (const EventContext& ctx);
88
89
91 PublicToolHandle<IIOVDbMetaDataTool> m_metaDataTool
92 { this, "IOVDbMetaDataTool", "IOVDbMetaDataTool" };
93
94
95 // Property: Allow disabling reading from metadata.
96 Gaudi::Property<bool> m_enabled
97 { this, "Enable", true, "If false, will return failure on loadWeights" };
98
99
104 {
106 unsigned long m_chanNum = 0;
107
109 WeightMap m_weightNames;
110
112 std::vector<std::string> m_weightNameVec;
113
115 void fillVec();
116 };
117
119 static const unsigned int NWEIGHTS = 8;
121
123 size_t m_nextWeight = 0;
124
127 { this, "EventInfoKey", "EventInfo", "SG key for EventInfo object." };
128
130 std::mutex m_mutex;
131};
132
133#endif
This is an interface to a tool used to manage the IOV Meta Data for a given object in the MetaData St...
Property holding a SG store/key/clid from which a ReadHandle is made.
Service to read/write HepMC's WeightContainer key names from/to IOVMetaDataContainers author: will bu...
virtual StatusCode initialize() override
Standard Gaudi initialize.
static const unsigned int NWEIGHTS
Array of weights.
WeightInfo m_weights[NWEIGHTS]
unsigned long getChanNum(const EventContext &ctx) const
Return the ‘channel number’ for the current event.
virtual StatusCode setWeightNames(const WeightMap &weightNames, const EventContext &ctx=Gaudi::Hive::currentContext()) override
Record weight names to metadata if none have yet been set.
Gaudi::Property< bool > m_enabled
unsigned int loadWeights(unsigned long chanNum)
Try to load weight names from metadata.
size_t m_nextWeight
Index of next set of weights to overwrite.
virtual std::vector< std::string > weightNameVec(const EventContext &ctx=Gaudi::Hive::currentContext()) override
Return the current weight names.
unsigned int getWeightIndex(const EventContext &ctx)
Return the index in m_weights for the current event.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Used to get MC channel for the current event.
virtual WeightMap weightNames(const EventContext &ctx=Gaudi::Hive::currentContext()) override
Return the current weight names.
std::mutex m_mutex
Serialize access to this service.
PublicToolHandle< IIOVDbMetaDataTool > m_metaDataTool
Handle to metadata tool.
Property holding a SG store/key/clid from which a ReadHandle is made.
Cached sets of weights.
unsigned long m_chanNum
Channel number for this set of weights.
WeightMap m_weightNames
Map of weight names.
void fillVec()
Initialize sorted vector from map.
std::vector< std::string > m_weightNameVec
Sorted vector of weight names.