|
ATLAS Offline Software
|
Service to read/write HepMC's WeightContainer key names from/to IOVMetaDataContainers author: will buttinger , NLAA.
More...
#include <HepMCWeightSvc.h>
Service to read/write HepMC's WeightContainer key names from/to IOVMetaDataContainers author: will buttinger , NLAA.
Definition at line 24 of file HepMCWeightSvc.h.
◆ getChanNum()
unsigned long HepMCWeightSvc::getChanNum |
( |
const EventContext & |
ctx | ) |
const |
|
private |
Return the ‘channel number’ for the current event.
- Parameters
-
ctx | Current event context. |
Either the MC channel number or the run number if that hasn't been set.
Definition at line 134 of file HepMCWeightSvc.cxx.
139 unsigned long chanNum = ei->mcChannelNumber();
143 return ctx.eventID().run_number();
◆ getWeightIndex()
unsigned int HepMCWeightSvc::getWeightIndex |
( |
const EventContext & |
ctx | ) |
|
|
private |
Return the index in m_weights for the current event.
- Parameters
-
ctx | The current event context. |
Returns NWEIGHTS on failure.
Definition at line 225 of file HepMCWeightSvc.cxx.
◆ initialize()
StatusCode HepMCWeightSvc::initialize |
( |
| ) |
|
|
overridevirtual |
◆ loadWeights()
unsigned int HepMCWeightSvc::loadWeights |
( |
unsigned long |
chanNum | ) |
|
|
private |
Try to load weight names from metadata.
- Parameters
-
chanNum | Channel number for which to load weights. |
Returns the index in m_weights of the loaded weights.
Definition at line 153 of file HepMCWeightSvc.cxx.
159 std::map<std::string, int> in;
168 unsigned long chanNumRead =
chanNum;
179 }
catch(
const coral::AttributeListException&) {
183 std::string
weightNames = attr.data<std::string>();
208 w.m_weightNames.clear();
210 for(
const auto&
i : in) {
211 w.m_weightNames[
i.first] =
i.second;
◆ setWeightNames()
StatusCode HepMCWeightSvc::setWeightNames |
( |
const WeightMap & |
weightNames, |
|
|
const EventContext & |
ctx = Gaudi::Hive::currentContext() |
|
) |
| |
|
overridevirtual |
Record weight names to metadata if none have yet been set.
- Parameters
-
weightNames | Map of names to record. |
ctx | Current event context. |
Does nothing if weight names have already been set or read.
Definition at line 33 of file HepMCWeightSvc.cxx.
36 std::scoped_lock lock (
m_mutex);
42 return StatusCode::SUCCESS;
50 return StatusCode::SUCCESS;
53 unsigned int chanNum = ctx.eventID().run_number();
62 ATH_CHECK(
m_metaDataTool->registerFolder(
"/Generation/Parameters",
"Metadata created during Event Generation") );
65 auto cont = std::make_unique<CondAttrListCollection> (
true ) ;
71 myAttributes.extend(
"HepMCWeightNames",
"string");
72 myAttributes.extend(
"HepMCWeightSvcVersion",
"int");
73 myAttributes[
"HepMCWeightSvcVersion"].data<
int>() = 2;
77 myAttributes[
"HepMCWeightNames"].data<std::string>() = stringToStore;
80 bool add_status = cont->add(
chanNum, myAttributes);
82 ATH_MSG_INFO(
"Failed to add AttributeList for weight " << stringToStore);
85 ATH_MSG_INFO(
"Storing /Generation/Parameters :: WeightNames = " << stringToStore);
90 return StatusCode::SUCCESS;
◆ weightNames()
HepMCWeightSvc::WeightMap HepMCWeightSvc::weightNames |
( |
const EventContext & |
ctx = Gaudi::Hive::currentContext() | ) |
|
|
overridevirtual |
Return the current weight names.
Definition at line 98 of file HepMCWeightSvc.cxx.
100 std::scoped_lock lock (
m_mutex);
106 ATH_MSG_WARNING(
"Unable to load weightnames from metadata ... do not trust the weightnames!");
◆ weightNameVec()
std::vector< std::string > HepMCWeightSvc::weightNameVec |
( |
const EventContext & |
ctx = Gaudi::Hive::currentContext() | ) |
|
|
overridevirtual |
Return the current weight names.
Definition at line 115 of file HepMCWeightSvc.cxx.
117 std::scoped_lock lock (
m_mutex);
123 ATH_MSG_WARNING(
"Unable to load weightnames from metadata ... do not trust the weightnames!");
124 return std::vector<std::string>();
◆ m_enabled
Gaudi::Property<bool> HepMCWeightSvc::m_enabled { this, "Enable", true, "If false, will return failure on loadWeights" } |
|
private |
◆ m_eventInfoKey
◆ m_metaDataTool
◆ m_mutex
std::mutex HepMCWeightSvc::m_mutex |
|
private |
◆ m_nextWeight
size_t HepMCWeightSvc::m_nextWeight = 0 |
|
private |
◆ m_weights
◆ NWEIGHTS
const unsigned int HepMCWeightSvc::NWEIGHTS = 8 |
|
staticprivate |
The documentation for this class was generated from the following files:
CondAttrListCollection * at(unsigned int i) const
Element access.
size_t m_nextWeight
Index of next set of weights to overwrite.
StatusCode parse(std::tuple< Tup... > &tup, const Gaudi::Parsers::InputData &input)
static const unsigned int NWEIGHTS
Array of weights.
Gaudi::Property< bool > m_enabled
PublicToolHandle< IIOVDbMetaDataTool > m_metaDataTool
Handle to metadata tool.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Used to get MC channel for the current event.
size_type size() const
size of payload vector
unsigned int loadWeights(unsigned long chanNum)
Try to load weight names from metadata.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
WeightInfo m_weights[NWEIGHTS]
ChanNum chanNum(unsigned int index) const
channel number for index: (index = 0 to size-1)
std::vector< std::string > m_weightNameVec
Sorted vector of weight names.
const AttributeList & attributeList(ChanNum chanNum) const
attribute list for a given channel number
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
unsigned int getWeightIndex(const EventContext &ctx)
Return the index in m_weights for the current event.
WeightMap m_weightNames
Map of weight names.
size_type size() const
number of Chan/AttributeList pairs
#define ATH_MSG_WARNING(x)
unsigned long getChanNum(const EventContext &ctx) const
Return the ‘channel number’ 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.
coral::AttributeList AttributeList