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 ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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)
 

Private Member Functions

virtual void beginRun (edm::Run const &, edm::EventSetup const &) override
 
virtual 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
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 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 45 of file LHE2HepMCConverter.cc.

Constructor & Destructor Documentation

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

Definition at line 82 of file LHE2HepMCConverter.cc.

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

82  :
83 _lheRunSrc(0)
84 {
85  //register your products
86  produces<edm::HepMCProduct>("unsmeared");
87 
88  _lheEventSrcTag = iConfig.getParameter<edm::InputTag>("LHEEventProduct");
89  _lheRunSrcTag = iConfig.getParameter<edm::InputTag>("LHERunInfoProduct");
90 
91 }
T getParameter(std::string const &) const
edm::InputTag _lheRunSrcTag
edm::InputTag _lheEventSrcTag
const LHERunInfoProduct * _lheRunSrc
LHE2HepMCConverter::~LHE2HepMCConverter ( )

Definition at line 94 of file LHE2HepMCConverter.cc.

95 {
96 
97  // do anything here that needs to be done at desctruction time
98  // (e.g. close files, deallocate resources etc.)
99 
100 }

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 150 of file LHE2HepMCConverter.cc.

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

151 {
152 
153  edm::Handle<LHERunInfoProduct> lheRunSrcHandle;
154  iRun.getByLabel(_lheRunSrcTag, lheRunSrcHandle);
155  if (lheRunSrcHandle.isValid()) {
156  _lheRunSrc = lheRunSrcHandle.product();
157  }
158  else {
159  if (_lheRunSrcTag.label() != "source" ) {
160  iRun.getByLabel("source", lheRunSrcHandle);
161  if (lheRunSrcHandle.isValid()) {
162  _lheRunSrc = lheRunSrcHandle.product();
163  edm::LogInfo("LHE2HepMCConverter") << "Taking LHERunInfoproduct from source";
164  }
165  else
166  edm::LogWarning("LHE2HepMCConverter") << "No LHERunInfoProduct from source";
167  }
168 
169  }
170 
171 }
edm::InputTag _lheRunSrcTag
const LHERunInfoProduct * _lheRunSrc
bool isValid() const
Definition: HandleBase.h:74
T const * product() const
Definition: Handle.h:81
std::string const & label() const
Definition: InputTag.h:36
void LHE2HepMCConverter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 175 of file LHE2HepMCConverter.cc.

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

175  {
176  //The following says we do not know what parameters are allowed so do no validation
177  // Please change this to state exactly what you do use, even if it is no parameters
179  desc.setUnknown();
180  descriptions.addDefault(desc);
181 }
void addDefault(ParameterSetDescription const &psetDescription)
void LHE2HepMCConverter::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Definition at line 109 of file LHE2HepMCConverter.cc.

References _lheEventSrcTag, _lheRunSrc, lhef::HEPRUP::EBMUP, GenParticle::GenParticle, edm::Event::getByLabel(), runTauDisplay::gp, LHEEventProduct::hepeup(), 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.

110 {
111  using namespace edm;
112  Handle<LHEEventProduct> lheEventSrc;
113  iEvent.getByLabel(_lheEventSrcTag, lheEventSrc);
114 
115  HepMC::GenEvent *evt = new HepMC::GenEvent();
116  HepMC::GenVertex* v = new HepMC::GenVertex();
117  evt->add_vertex(v);
118  if (_lheRunSrc){
119  HepMC::FourVector beam1(0, 0, _lheRunSrc->heprup().EBMUP.first, _lheRunSrc->heprup().EBMUP.first);
120  HepMC::GenParticle* gp1 = new HepMC::GenParticle(beam1, _lheRunSrc->heprup().IDBMUP.first, 4);
121  v->add_particle_in(gp1);
122  HepMC::FourVector beam2(0, 0, _lheRunSrc->heprup().EBMUP.second, _lheRunSrc->heprup().EBMUP.second);
123  HepMC::GenParticle* gp2 = new HepMC::GenParticle(beam2, _lheRunSrc->heprup().IDBMUP.second, 4);
124  v->add_particle_in(gp2);
125  evt->set_beam_particles(gp1, gp2);
126  } else {
127  LogWarning("LHE2HepMCConverter") << "Could not retrieve the LHERunInfoProduct for this event. You'll miss the beam particles in your HepMC product." ;
128  }
129 
130 
131  for (int i = 0; i < lheEventSrc->hepeup().NUP; ++i) {
132  if (lheEventSrc->hepeup().ISTUP[i] != 1) {
133  //cout << reader->hepeup.ISTUP[i] << ", " << reader->hepeup.IDUP[i] << endl;
134  continue;
135  }
136  HepMC::FourVector p(lheEventSrc->hepeup().PUP[i][0], lheEventSrc->hepeup().PUP[i][1],
137  lheEventSrc->hepeup().PUP[i][2], lheEventSrc->hepeup().PUP[i][3]);
138  HepMC::GenParticle* gp = new HepMC::GenParticle(p, lheEventSrc->hepeup().IDUP[i], 1);
139  gp->set_generated_mass(lheEventSrc->hepeup().PUP[i][4]);
140  v->add_particle_out(gp);
141  }
142 
143  std::unique_ptr<HepMCProduct> pOut(new HepMCProduct(evt));
144  iEvent.put(std::move(pOut), "unsmeared");
145 
146 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
const lhef::HEPEUP & hepeup() const
std::pair< double, double > EBMUP
Definition: LesHouches.h:78
std::pair< int, int > IDBMUP
Definition: LesHouches.h:73
const lhef::HEPRUP & heprup() const
std::vector< FiveVector > PUP
Definition: LesHouches.h:248
edm::InputTag _lheEventSrcTag
const LHERunInfoProduct * _lheRunSrc
std::vector< int > ISTUP
Definition: LesHouches.h:230
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:416
std::vector< int > IDUP
Definition: LesHouches.h:225
HLT enums.
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

edm::InputTag LHE2HepMCConverter::_lheEventSrcTag
private

Definition at line 62 of file LHE2HepMCConverter.cc.

Referenced by LHE2HepMCConverter(), and produce().

const LHERunInfoProduct* LHE2HepMCConverter::_lheRunSrc
private

Definition at line 64 of file LHE2HepMCConverter.cc.

Referenced by beginRun(), and produce().

edm::InputTag LHE2HepMCConverter::_lheRunSrcTag
private

Definition at line 63 of file LHE2HepMCConverter.cc.

Referenced by beginRun(), and LHE2HepMCConverter().