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::one::EDProducer< edm::one::WatchRuns > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 LHE2HepMCConverter (const edm::ParameterSet &)
 
 ~LHE2HepMCConverter () override=default
 
- Public Member Functions inherited from edm::one::EDProducer< edm::one::WatchRuns >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

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

Private Attributes

const edm::InputTag _lheEventSrcTag
 
const LHERunInfoProduct_lheRunSrc
 
const edm::InputTag _lheRunSrcTag
 
const edm::EDGetTokenT< LHEEventProducteventProductToken_
 
const edm::EDGetTokenT< LHERunInfoProductrunInfoProductToken_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase 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<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
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<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

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 77 of file LHE2HepMCConverter.cc.

78  : _lheRunSrc(nullptr),
79  _lheEventSrcTag(iConfig.getParameter<edm::InputTag>("LHEEventProduct")),
80  _lheRunSrcTag(iConfig.getParameter<edm::InputTag>("LHERunInfoProduct")),
81  eventProductToken_(consumes<LHEEventProduct>(_lheEventSrcTag)),
82  runInfoProductToken_(consumes<LHERunInfoProduct, edm::InRun>(_lheRunSrcTag)) {
83  //register your products
84  produces<edm::HepMCProduct>("unsmeared");
85 }
const edm::EDGetTokenT< LHERunInfoProduct > runInfoProductToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::InputTag _lheRunSrcTag
const LHERunInfoProduct * _lheRunSrc
const edm::InputTag _lheEventSrcTag
const edm::EDGetTokenT< LHEEventProduct > eventProductToken_

◆ ~LHE2HepMCConverter()

LHE2HepMCConverter::~LHE2HepMCConverter ( )
overridedefault

Member Function Documentation

◆ beginRun()

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

Definition at line 131 of file LHE2HepMCConverter.cc.

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

131  {
132  edm::Handle<LHERunInfoProduct> lheRunSrcHandle = iRun.getHandle(runInfoProductToken_);
133  if (lheRunSrcHandle.isValid()) {
134  _lheRunSrc = lheRunSrcHandle.product();
135  } else {
136  if (_lheRunSrcTag.label() != "source") {
137  iRun.getByLabel("source", lheRunSrcHandle);
138  if (lheRunSrcHandle.isValid()) {
139  _lheRunSrc = lheRunSrcHandle.product();
140  edm::LogInfo("LHE2HepMCConverter") << "Taking LHERunInfoproduct from source";
141  } else
142  edm::LogWarning("LHE2HepMCConverter") << "No LHERunInfoProduct from source";
143  }
144  }
145 }
const edm::EDGetTokenT< LHERunInfoProduct > runInfoProductToken_
T const * product() const
Definition: Handle.h:70
std::string const & label() const
Definition: InputTag.h:36
const edm::InputTag _lheRunSrcTag
const LHERunInfoProduct * _lheRunSrc
Log< level::Info, false > LogInfo
bool isValid() const
Definition: HandleBase.h:70
Log< level::Warning, false > LogWarning

◆ endRun()

void LHE2HepMCConverter::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverrideprivate

Definition at line 55 of file LHE2HepMCConverter.cc.

55 {}

◆ fillDescriptions()

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

Definition at line 148 of file LHE2HepMCConverter.cc.

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

148  {
149  //The following says we do not know what parameters are allowed so do no validation
150  // Please change this to state exactly what you do use, even if it is no parameters
152  desc.setUnknown();
153  descriptions.addDefault(desc);
154 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ produce()

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

Implements edm::one::EDProducerBase.

Definition at line 92 of file LHE2HepMCConverter.cc.

References _lheRunSrc, lhef::HEPRUP::EBMUP, eventProductToken_, 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.

92  {
93  using namespace edm;
94  const edm::Handle<LHEEventProduct>& lheEventSrc = iEvent.getHandle(eventProductToken_);
95 
96  HepMC::GenEvent* evt = new HepMC::GenEvent();
97  HepMC::GenVertex* v = new HepMC::GenVertex();
98  evt->add_vertex(v);
99  if (_lheRunSrc) {
100  HepMC::FourVector beam1(0, 0, _lheRunSrc->heprup().EBMUP.first, _lheRunSrc->heprup().EBMUP.first);
101  HepMC::GenParticle* gp1 = new HepMC::GenParticle(beam1, _lheRunSrc->heprup().IDBMUP.first, 4);
102  v->add_particle_in(gp1);
103  HepMC::FourVector beam2(0, 0, _lheRunSrc->heprup().EBMUP.second, _lheRunSrc->heprup().EBMUP.second);
104  HepMC::GenParticle* gp2 = new HepMC::GenParticle(beam2, _lheRunSrc->heprup().IDBMUP.second, 4);
105  v->add_particle_in(gp2);
106  evt->set_beam_particles(gp1, gp2);
107  } else {
108  LogWarning("LHE2HepMCConverter") << "Could not retrieve the LHERunInfoProduct for this event. You'll miss the beam "
109  "particles in your HepMC product.";
110  }
111 
112  for (int i = 0; i < lheEventSrc->hepeup().NUP; ++i) {
113  if (lheEventSrc->hepeup().ISTUP[i] != 1) {
114  //cout << reader->hepeup.ISTUP[i] << ", " << reader->hepeup.IDUP[i] << endl;
115  continue;
116  }
117  HepMC::FourVector p(lheEventSrc->hepeup().PUP[i][0],
118  lheEventSrc->hepeup().PUP[i][1],
119  lheEventSrc->hepeup().PUP[i][2],
120  lheEventSrc->hepeup().PUP[i][3]);
121  HepMC::GenParticle* gp = new HepMC::GenParticle(p, lheEventSrc->hepeup().IDUP[i], 1);
122  gp->set_generated_mass(lheEventSrc->hepeup().PUP[i][4]);
123  v->add_particle_out(gp);
124  }
125 
126  std::unique_ptr<HepMCProduct> pOut(new HepMCProduct(evt));
127  iEvent.put(std::move(pOut), "unsmeared");
128 }
std::pair< double, double > EBMUP
Definition: LesHouches.h:82
std::pair< int, int > IDBMUP
Definition: LesHouches.h:77
int iEvent
Definition: GenABIO.cc:224
const lhef::HEPRUP & heprup() const
std::vector< FiveVector > PUP
Definition: LesHouches.h:246
const LHERunInfoProduct * _lheRunSrc
std::vector< int > ISTUP
Definition: LesHouches.h:228
std::vector< int > IDUP
Definition: LesHouches.h:223
HLT enums.
Log< level::Warning, false > LogWarning
const edm::EDGetTokenT< LHEEventProduct > eventProductToken_
def move(src, dest)
Definition: eostools.py:511
const lhef::HEPEUP & hepeup() const

Member Data Documentation

◆ _lheEventSrcTag

const edm::InputTag LHE2HepMCConverter::_lheEventSrcTag
private

Definition at line 59 of file LHE2HepMCConverter.cc.

◆ _lheRunSrc

const LHERunInfoProduct* LHE2HepMCConverter::_lheRunSrc
private

Definition at line 58 of file LHE2HepMCConverter.cc.

Referenced by beginRun(), and produce().

◆ _lheRunSrcTag

const edm::InputTag LHE2HepMCConverter::_lheRunSrcTag
private

Definition at line 60 of file LHE2HepMCConverter.cc.

Referenced by beginRun().

◆ eventProductToken_

const edm::EDGetTokenT<LHEEventProduct> LHE2HepMCConverter::eventProductToken_
private

Definition at line 61 of file LHE2HepMCConverter.cc.

Referenced by produce().

◆ runInfoProductToken_

const edm::EDGetTokenT<LHERunInfoProduct> LHE2HepMCConverter::runInfoProductToken_
private

Definition at line 62 of file LHE2HepMCConverter.cc.

Referenced by beginRun().