|
ATLAS Offline Software
|
Go to the documentation of this file.
8 #include "CoralBase/AttributeListException.h"
21 return StatusCode::SUCCESS;
34 const EventContext& ctx )
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;
97 HepMCWeightSvc::WeightMap
100 std::scoped_lock lock (
m_mutex);
106 ATH_MSG_WARNING(
"Unable to load weightnames from metadata ... do not trust the weightnames!");
114 std::vector<std::string>
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>();
139 unsigned long chanNum = ei->mcChannelNumber();
143 return ctx.eventID().run_number();
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;
246 using WPair = std::pair<std::string, unsigned long int>;
247 std::vector<WPair>
sorted;
252 [](
const WPair&
a,
const WPair&
b) {return a.second < b.second; });
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)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
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.
virtual StatusCode initialize() override
Standard Gaudi initialize.
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]
::StatusCode StatusCode
StatusCode definition for legacy code.
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.
virtual StatusCode setWeightNames(const WeightMap &weightNames, const EventContext &ctx=Gaudi::Hive::currentContext()) override
Record weight names to metadata if none have yet been set.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
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.
virtual std::vector< std::string > weightNameVec(const EventContext &ctx=Gaudi::Hive::currentContext()) override
Return the current weight names.
std::mutex m_mutex
Serialize access to this service.
coral::AttributeList AttributeList
Handle class for reading from StoreGate.
void fillVec()
Initialize sorted vector from map.