ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Generators
HepMCWeightSvc
src
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
8
#include "
AthenaBaseComps/AthService.h
"
9
#include "
xAODEventInfo/EventInfo.h
"
10
#include "
GenInterfaces/IHepMCWeightSvc.h
"
11
#include "
StoreGate/ReadHandleKey.h
"
12
#include <string>
13
14
#include "
IOVDbMetaDataTools/IIOVDbMetaDataTool.h
"
15
16
#include "GaudiKernel/ToolHandle.h"
17
#include <vector>
18
#include <mutex>
19
24
class
HepMCWeightSvc
:
public
extends<AthService, IHepMCWeightSvc>
25
{
26
public
:
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
62
private
:
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
103
struct
WeightInfo
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;
120
WeightInfo
m_weights
[
NWEIGHTS
];
121
123
size_t
m_nextWeight
= 0;
124
126
SG::ReadHandleKey<xAOD::EventInfo>
m_eventInfoKey
127
{
this
,
"EventInfoKey"
,
"EventInfo"
,
"SG key for EventInfo object."
};
128
130
std::mutex
m_mutex
;
131
};
132
133
#endif
AthService.h
IHepMCWeightSvc.h
IIOVDbMetaDataTool.h
This is an interface to a tool used to manage the IOV Meta Data for a given object in the MetaData St...
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
HepMCWeightSvc
Service to read/write HepMC's WeightContainer key names from/to IOVMetaDataContainers author: will bu...
Definition
HepMCWeightSvc.h:25
HepMCWeightSvc::initialize
virtual StatusCode initialize() override
Standard Gaudi initialize.
Definition
HepMCWeightSvc.cxx:18
HepMCWeightSvc::NWEIGHTS
static const unsigned int NWEIGHTS
Array of weights.
Definition
HepMCWeightSvc.h:119
HepMCWeightSvc::m_weights
WeightInfo m_weights[NWEIGHTS]
Definition
HepMCWeightSvc.h:120
HepMCWeightSvc::setWeightNames
virtual StatusCode setWeightNames(const WeightMap &weightNames, const EventContext &ctx=Gaudi::Hive::currentContext()) override
Record weight names to metadata if none have yet been set.
Definition
HepMCWeightSvc.cxx:33
HepMCWeightSvc::m_enabled
Gaudi::Property< bool > m_enabled
Definition
HepMCWeightSvc.h:97
HepMCWeightSvc::loadWeights
unsigned int loadWeights(unsigned long chanNum)
Return the `channel number' for the current event.
Definition
HepMCWeightSvc.cxx:153
HepMCWeightSvc::m_nextWeight
size_t m_nextWeight
Index of next set of weights to overwrite.
Definition
HepMCWeightSvc.h:123
HepMCWeightSvc::weightNameVec
virtual std::vector< std::string > weightNameVec(const EventContext &ctx=Gaudi::Hive::currentContext()) override
Return the current weight names.
Definition
HepMCWeightSvc.cxx:115
HepMCWeightSvc::getWeightIndex
unsigned int getWeightIndex(const EventContext &ctx)
Return the index in m_weights for the current event.
Definition
HepMCWeightSvc.cxx:225
HepMCWeightSvc::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Used to get MC channel for the current event.
Definition
HepMCWeightSvc.h:127
HepMCWeightSvc::weightNames
virtual WeightMap weightNames(const EventContext &ctx=Gaudi::Hive::currentContext()) override
Return the current weight names.
Definition
HepMCWeightSvc.cxx:98
HepMCWeightSvc::m_mutex
std::mutex m_mutex
Serialize access to this service.
Definition
HepMCWeightSvc.h:130
HepMCWeightSvc::m_metaDataTool
PublicToolHandle< IIOVDbMetaDataTool > m_metaDataTool
Handle to metadata tool.
Definition
HepMCWeightSvc.h:92
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition
StoreGate/StoreGate/ReadHandleKey.h:40
HepMCWeightSvc::WeightInfo
Cached sets of weights. We retain NWEIGHTS sets of weights. They are overwritten in a round-robin fas...
Definition
HepMCWeightSvc.h:104
HepMCWeightSvc::WeightInfo::m_chanNum
unsigned long m_chanNum
Channel number for this set of weights.
Definition
HepMCWeightSvc.h:106
HepMCWeightSvc::WeightInfo::m_weightNames
WeightMap m_weightNames
Map of weight names.
Definition
HepMCWeightSvc.h:109
HepMCWeightSvc::WeightInfo::fillVec
void fillVec()
Initialize sorted vector from map.
Definition
HepMCWeightSvc.cxx:243
HepMCWeightSvc::WeightInfo::m_weightNameVec
std::vector< std::string > m_weightNameVec
Sorted vector of weight names.
Definition
HepMCWeightSvc.h:112
EventInfo.h
Generated on
for ATLAS Offline Software by
1.17.0