CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 46 of file LHE2HepMCConverter.cc.

Constructor & Destructor Documentation

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

Definition at line 83 of file LHE2HepMCConverter.cc.

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

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

Definition at line 95 of file LHE2HepMCConverter.cc.

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

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 151 of file LHE2HepMCConverter.cc.

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

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

Definition at line 176 of file LHE2HepMCConverter.cc.

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

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

Implements edm::EDProducer.

Definition at line 110 of file LHE2HepMCConverter.cc.

References _lheEventSrcTag, _lheRunSrc, lhef::HEPRUP::EBMUP, configurableAnalysis::GenParticle, edm::Event::getByLabel(), LHERunInfoProduct::heprup(), i, lhef::HEPRUP::IDBMUP, AlCaHLTBitMon_ParallelJobs::p, edm::Event::put(), and findQualityFiles::v.

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

Member Data Documentation

edm::InputTag LHE2HepMCConverter::_lheEventSrcTag
private

Definition at line 63 of file LHE2HepMCConverter.cc.

Referenced by LHE2HepMCConverter(), and produce().

const LHERunInfoProduct* LHE2HepMCConverter::_lheRunSrc
private

Definition at line 65 of file LHE2HepMCConverter.cc.

Referenced by beginRun(), and produce().

edm::InputTag LHE2HepMCConverter::_lheRunSrcTag
private

Definition at line 64 of file LHE2HepMCConverter.cc.

Referenced by beginRun(), and LHE2HepMCConverter().