CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
LHE2HepMCConverter Class Reference

#include <GeneratorInterface/LHE2HepMCConverter/src/LHE2HepMCConverter.cc>

Inheritance diagram for LHE2HepMCConverter:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 LHE2HepMCConverter (const edm::ParameterSet &)
 
 ~LHE2HepMCConverter () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 

Private Member Functions

void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::InputTag _lheEventSrcTag
 
const LHERunInfoProduct_lheRunSrc
 
edm::InputTag _lheRunSrcTag
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 42 of file LHE2HepMCConverter.cc.

Constructor & Destructor Documentation

◆ LHE2HepMCConverter()

LHE2HepMCConverter::LHE2HepMCConverter ( const edm::ParameterSet iConfig)
explicit

Definition at line 75 of file LHE2HepMCConverter.cc.

75  : _lheRunSrc(nullptr) {
76  //register your products
77  produces<edm::HepMCProduct>("unsmeared");
78 
79  _lheEventSrcTag = iConfig.getParameter<edm::InputTag>("LHEEventProduct");
80  _lheRunSrcTag = iConfig.getParameter<edm::InputTag>("LHERunInfoProduct");
81 }

References _lheEventSrcTag, _lheRunSrcTag, and edm::ParameterSet::getParameter().

◆ ~LHE2HepMCConverter()

LHE2HepMCConverter::~LHE2HepMCConverter ( )
override

Definition at line 83 of file LHE2HepMCConverter.cc.

83  {
84  // do anything here that needs to be done at desctruction time
85  // (e.g. close files, deallocate resources etc.)
86 }

Member Function Documentation

◆ beginRun()

void LHE2HepMCConverter::beginRun ( edm::Run const &  iRun,
edm::EventSetup const &   
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 133 of file LHE2HepMCConverter.cc.

133  {
134  edm::Handle<LHERunInfoProduct> lheRunSrcHandle;
135  iRun.getByLabel(_lheRunSrcTag, lheRunSrcHandle);
136  if (lheRunSrcHandle.isValid()) {
137  _lheRunSrc = lheRunSrcHandle.product();
138  } else {
139  if (_lheRunSrcTag.label() != "source") {
140  iRun.getByLabel("source", lheRunSrcHandle);
141  if (lheRunSrcHandle.isValid()) {
142  _lheRunSrc = lheRunSrcHandle.product();
143  edm::LogInfo("LHE2HepMCConverter") << "Taking LHERunInfoproduct from source";
144  } else
145  edm::LogWarning("LHE2HepMCConverter") << "No LHERunInfoProduct from source";
146  }
147  }
148 }

References _lheRunSrc, _lheRunSrcTag, edm::Run::getByLabel(), edm::HandleBase::isValid(), edm::InputTag::label(), and edm::Handle< T >::product().

◆ fillDescriptions()

void LHE2HepMCConverter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 151 of file LHE2HepMCConverter.cc.

151  {
152  //The following says we do not know what parameters are allowed so do no validation
153  // Please change this to state exactly what you do use, even if it is no parameters
155  desc.setUnknown();
156  descriptions.addDefault(desc);
157 }

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

◆ produce()

void LHE2HepMCConverter::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 93 of file LHE2HepMCConverter.cc.

93  {
94  using namespace edm;
95  Handle<LHEEventProduct> lheEventSrc;
96  iEvent.getByLabel(_lheEventSrcTag, lheEventSrc);
97 
98  HepMC::GenEvent* evt = new HepMC::GenEvent();
99  HepMC::GenVertex* v = new HepMC::GenVertex();
100  evt->add_vertex(v);
101  if (_lheRunSrc) {
102  HepMC::FourVector beam1(0, 0, _lheRunSrc->heprup().EBMUP.first, _lheRunSrc->heprup().EBMUP.first);
103  HepMC::GenParticle* gp1 = new HepMC::GenParticle(beam1, _lheRunSrc->heprup().IDBMUP.first, 4);
104  v->add_particle_in(gp1);
105  HepMC::FourVector beam2(0, 0, _lheRunSrc->heprup().EBMUP.second, _lheRunSrc->heprup().EBMUP.second);
106  HepMC::GenParticle* gp2 = new HepMC::GenParticle(beam2, _lheRunSrc->heprup().IDBMUP.second, 4);
107  v->add_particle_in(gp2);
108  evt->set_beam_particles(gp1, gp2);
109  } else {
110  LogWarning("LHE2HepMCConverter") << "Could not retrieve the LHERunInfoProduct for this event. You'll miss the beam "
111  "particles in your HepMC product.";
112  }
113 
114  for (int i = 0; i < lheEventSrc->hepeup().NUP; ++i) {
115  if (lheEventSrc->hepeup().ISTUP[i] != 1) {
116  //cout << reader->hepeup.ISTUP[i] << ", " << reader->hepeup.IDUP[i] << endl;
117  continue;
118  }
119  HepMC::FourVector p(lheEventSrc->hepeup().PUP[i][0],
120  lheEventSrc->hepeup().PUP[i][1],
121  lheEventSrc->hepeup().PUP[i][2],
122  lheEventSrc->hepeup().PUP[i][3]);
123  HepMC::GenParticle* gp = new HepMC::GenParticle(p, lheEventSrc->hepeup().IDUP[i], 1);
124  gp->set_generated_mass(lheEventSrc->hepeup().PUP[i][4]);
125  v->add_particle_out(gp);
126  }
127 
128  std::unique_ptr<HepMCProduct> pOut(new HepMCProduct(evt));
129  iEvent.put(std::move(pOut), "unsmeared");
130 }

References _lheEventSrcTag, _lheRunSrc, lhef::HEPRUP::EBMUP, GenParticle::GenParticle, runTauDisplay::gp, LHEEventProduct::hepeup(), ZgammaFilter_cfi::HepMCProduct, LHERunInfoProduct::heprup(), mps_fire::i, lhef::HEPRUP::IDBMUP, lhef::HEPEUP::IDUP, iEvent, lhef::HEPEUP::ISTUP, eostools::move(), lhef::HEPEUP::NUP, AlCaHLTBitMon_ParallelJobs::p, lhef::HEPEUP::PUP, and findQualityFiles::v.

Member Data Documentation

◆ _lheEventSrcTag

edm::InputTag LHE2HepMCConverter::_lheEventSrcTag
private

Definition at line 57 of file LHE2HepMCConverter.cc.

Referenced by LHE2HepMCConverter(), and produce().

◆ _lheRunSrc

const LHERunInfoProduct* LHE2HepMCConverter::_lheRunSrc
private

Definition at line 59 of file LHE2HepMCConverter.cc.

Referenced by beginRun(), and produce().

◆ _lheRunSrcTag

edm::InputTag LHE2HepMCConverter::_lheRunSrcTag
private

Definition at line 58 of file LHE2HepMCConverter.cc.

Referenced by beginRun(), and LHE2HepMCConverter().

LHE2HepMCConverter::_lheEventSrcTag
edm::InputTag _lheEventSrcTag
Definition: LHE2HepMCConverter.cc:57
mps_fire.i
i
Definition: mps_fire.py:428
edm::Handle::product
T const * product() const
Definition: Handle.h:70
lhef::HEPEUP::ISTUP
std::vector< int > ISTUP
Definition: LesHouches.h:228
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
ZgammaFilter_cfi.HepMCProduct
HepMCProduct
Definition: ZgammaFilter_cfi.py:9
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
LHERunInfoProduct::heprup
const lhef::HEPRUP & heprup() const
Definition: LHERunInfoProduct.h:55
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
findQualityFiles.v
v
Definition: findQualityFiles.py:179
LHE2HepMCConverter::_lheRunSrc
const LHERunInfoProduct * _lheRunSrc
Definition: LHE2HepMCConverter.cc:59
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
lhef::HEPRUP::EBMUP
std::pair< double, double > EBMUP
Definition: LesHouches.h:82
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
lhef::HEPEUP::NUP
int NUP
Definition: LesHouches.h:184
runTauDisplay.gp
gp
Definition: runTauDisplay.py:431
iEvent
int iEvent
Definition: GenABIO.cc:224
LHE2HepMCConverter::_lheRunSrcTag
edm::InputTag _lheRunSrcTag
Definition: LHE2HepMCConverter.cc:58
LHEEventProduct::hepeup
const lhef::HEPEUP & hepeup() const
Definition: LHEEventProduct.h:46
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
eostools.move
def move(src, dest)
Definition: eostools.py:511
lhef::HEPEUP::IDUP
std::vector< int > IDUP
Definition: LesHouches.h:223
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
lhef::HEPEUP::PUP
std::vector< FiveVector > PUP
Definition: LesHouches.h:246
edm::InputTag
Definition: InputTag.h:15
lhef::HEPRUP::IDBMUP
std::pair< int, int > IDBMUP
Definition: LesHouches.h:77