ATLAS Offline Software
Loading...
Searching...
No Matches
xAODMaker::xAODTruthCnvAlg::MetaDataWriter Class Reference

Factor out the pieces dealing with writing to meta data. More...

Collaboration diagram for xAODMaker::xAODTruthCnvAlg::MetaDataWriter:

Public Member Functions

StatusCode initialize (ServiceHandle< StoreGateSvc > &metaStore, const std::string &metaName)
StatusCode maybeWrite (uint32_t mcChannelNumber, const HepMC::GenEvent &genEvt, const MetadataFields &metaFields)

Private Types

typedef std::lock_guard< std::mutex > lock_t

Private Attributes

std::mutex m_mutex
 Mutex to control access to meta data writing.
xAOD::TruthMetaDataContainerm_tmd = nullptr
 The meta data container to be written out.
std::unordered_set< uint32_t > m_existingMetaDataChan
 Set for tracking the mc channels for which we already added meta data.

Detailed Description

Factor out the pieces dealing with writing to meta data.

This will be non-const, so need to protect with a mutex.

Definition at line 75 of file xAODTruthCnvAlg.h.

Member Typedef Documentation

◆ lock_t

typedef std::lock_guard<std::mutex> xAODMaker::xAODTruthCnvAlg::MetaDataWriter::lock_t
private

Definition at line 87 of file xAODTruthCnvAlg.h.

Member Function Documentation

◆ initialize()

StatusCode xAODMaker::xAODTruthCnvAlg::MetaDataWriter::initialize ( ServiceHandle< StoreGateSvc > & metaStore,
const std::string & metaName )

Definition at line 542 of file xAODTruthCnvAlg.cxx.

544 {
545 ATH_CHECK( metaStore.retrieve() );
546
547 auto md = std::make_unique<xAOD::TruthMetaDataContainer>();
548 m_tmd = md.get();
549
550 auto aux = std::make_unique<xAOD::TruthMetaDataAuxContainer>();
551 md->setStore( aux.get() );
552
553 // Record the trigger configuration metadata into it:
554 CHECK( metaStore->record( std::move (aux), metaName + "Aux." ) );
555 CHECK( metaStore->record( std::move (md), metaName ) );
556 return StatusCode::SUCCESS;
557 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define CHECK(...)
Evaluate an expression and check for errors.
xAOD::TruthMetaDataContainer * m_tmd
The meta data container to be written out.

◆ maybeWrite()

StatusCode xAODMaker::xAODTruthCnvAlg::MetaDataWriter::maybeWrite ( uint32_t mcChannelNumber,
const HepMC::GenEvent & genEvt,
const MetadataFields & metaFields )

Here comes the fix. Note that HepMC2.06.11 also contains the fix

Definition at line 561 of file xAODTruthCnvAlg.cxx.

564 {
565 // This bit needs to be serialized.
567
568 //Inserting in a (unordered_)set returns an <iterator, boolean> pair, where the boolean
569 //is used to check if the key already exists (returns false in the case it exists)
570 if( m_existingMetaDataChan.insert(mcChannelNumber).second ) {
571 m_tmd->push_back (std::make_unique <xAOD::TruthMetaData>());
572 xAOD::TruthMetaData* md = m_tmd->back();
573
575 md->setMcChannelNumber(mcChannelNumber);
576 std::vector<std::string> orderedWeightNameVec;
577 if (!genEvt.run_info()) {
578 for (size_t i=0; i<genEvt.weights().size();i++) orderedWeightNameVec.push_back(std::to_string(i));
579 } else {
580 if (!genEvt.run_info()->weight_names().empty()) {
581 orderedWeightNameVec = genEvt.weight_names();
582 } else {
583 //AV This to be decided. It is always a good idea to have a default weight 1.0.
584 //orderedWeightNameVec.push_back("0");
585 }
586 }
587 md->setWeightNames(orderedWeightNameVec);
588
589 if(!metaFields.lhefGenerator.empty()) {
590 md->setLhefGenerator(metaFields.lhefGenerator);
591 }
592 if(!metaFields.generators.empty()) {
593 md->setGenerators(metaFields.generators);
594 }
595 if(!metaFields.evgenProcess.empty()) {
596 md->setEvgenProcess(metaFields.evgenProcess);
597 }
598 if(!metaFields.evgenTune.empty()) {
599 md->setEvgenTune(metaFields.evgenTune);
600 }
601 if(!metaFields.hardPDF.empty()) {
602 md->setHardPDF(metaFields.hardPDF);
603 }
604 if(!metaFields.softPDF.empty()) {
605 md->setSoftPDF(metaFields.softPDF);
606 }
607 }
608
609 return StatusCode::SUCCESS;
610 }
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
size_t size() const
Number of registered mappings.
std::mutex m_mutex
Mutex to control access to meta data writing.
std::lock_guard< std::mutex > lock_t
std::unordered_set< uint32_t > m_existingMetaDataChan
Set for tracking the mc channels for which we already added meta data.
void setGenerators(const std::string &value)
void setLhefGenerator(const std::string &value)
void setEvgenTune(const std::string &value)
void setHardPDF(const std::string &value)
void setMcChannelNumber(uint32_t value)
void setSoftPDF(const std::string &value)
void setWeightNames(const std::vector< std::string > &value)
void setEvgenProcess(const std::string &value)
TruthMetaData_v1 TruthMetaData
Typedef to implementation.

Member Data Documentation

◆ m_existingMetaDataChan

std::unordered_set<uint32_t> xAODMaker::xAODTruthCnvAlg::MetaDataWriter::m_existingMetaDataChan
private

Set for tracking the mc channels for which we already added meta data.

Definition at line 93 of file xAODTruthCnvAlg.h.

◆ m_mutex

std::mutex xAODMaker::xAODTruthCnvAlg::MetaDataWriter::m_mutex
private

Mutex to control access to meta data writing.

Definition at line 86 of file xAODTruthCnvAlg.h.

◆ m_tmd

xAOD::TruthMetaDataContainer* xAODMaker::xAODTruthCnvAlg::MetaDataWriter::m_tmd = nullptr
private

The meta data container to be written out.

Definition at line 90 of file xAODTruthCnvAlg.h.


The documentation for this class was generated from the following files: