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
 
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)
 
 ~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
 
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::vector< ModuleDescription const * > &modules, 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
 
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 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
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<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)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 42 of file LHE2HepMCConverter.cc.

Constructor & Destructor Documentation

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

Definition at line 75 of file LHE2HepMCConverter.cc.

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

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 }
T getParameter(std::string const &) const
edm::InputTag _lheRunSrcTag
edm::InputTag _lheEventSrcTag
const LHERunInfoProduct * _lheRunSrc
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

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

Reimplemented from edm::EDProducer.

Definition at line 133 of file LHE2HepMCConverter.cc.

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

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 }
edm::InputTag _lheRunSrcTag
const LHERunInfoProduct * _lheRunSrc
bool isValid() const
Definition: HandleBase.h:70
T const * product() const
Definition: Handle.h:69
std::string const & label() const
Definition: InputTag.h:36
void LHE2HepMCConverter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 151 of file LHE2HepMCConverter.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

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 }
void addDefault(ParameterSetDescription const &psetDescription)
void LHE2HepMCConverter::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 93 of file LHE2HepMCConverter.cc.

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

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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
const lhef::HEPEUP & hepeup() const
std::pair< double, double > EBMUP
Definition: LesHouches.h:82
std::pair< int, int > IDBMUP
Definition: LesHouches.h:77
const lhef::HEPRUP & heprup() const
std::vector< FiveVector > PUP
Definition: LesHouches.h:246
edm::InputTag _lheEventSrcTag
const LHERunInfoProduct * _lheRunSrc
std::vector< int > ISTUP
Definition: LesHouches.h:228
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
std::vector< int > IDUP
Definition: LesHouches.h:223
HLT enums.
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::InputTag LHE2HepMCConverter::_lheEventSrcTag
private

Definition at line 57 of file LHE2HepMCConverter.cc.

Referenced by LHE2HepMCConverter(), and produce().

const LHERunInfoProduct* LHE2HepMCConverter::_lheRunSrc
private

Definition at line 59 of file LHE2HepMCConverter.cc.

Referenced by beginRun(), and produce().

edm::InputTag LHE2HepMCConverter::_lheRunSrcTag
private

Definition at line 58 of file LHE2HepMCConverter.cc.

Referenced by beginRun(), and LHE2HepMCConverter().