CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
edm::HadronizerFilter< HAD, DEC > Class Template Reference

#include <HadronizerFilter.h>

Inheritance diagram for edm::HadronizerFilter< HAD, DEC >:
edm::one::EDFilter< EndRunProducer, BeginLuminosityBlockProducer, EndLuminosityBlockProducer, one::WatchRuns, one::WatchLuminosityBlocks, one::SharedResources > edm::one::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef DEC Decayer
 
typedef HAD Hadronizer
 
- Public Types inherited from edm::one::EDFilterBase
typedef EDFilterBase 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
 

Public Member Functions

void beginLuminosityBlock (LuminosityBlock const &, EventSetup const &) override
 
void beginLuminosityBlockProduce (LuminosityBlock &, EventSetup const &) override
 
void beginRun (Run const &, EventSetup const &) override
 
void endLuminosityBlock (LuminosityBlock const &, EventSetup const &) override
 
void endLuminosityBlockProduce (LuminosityBlock &, EventSetup const &) override
 
void endRun (Run const &, EventSetup const &) override
 
void endRunProduce (Run &, EventSetup const &) override
 
bool filter (Event &e, EventSetup const &es) override
 
 HadronizerFilter (ParameterSet const &ps)
 
 ~HadronizerFilter () override
 
- Public Member Functions inherited from edm::one::EDFilter< EndRunProducer, BeginLuminosityBlockProducer, EndLuminosityBlockProducer, one::WatchRuns, one::WatchLuminosityBlocks, one::SharedResources >
 EDFilter ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDFilterBase () 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)
 

Private Attributes

unsigned int counterRunInfoProducts_
 
Decayerdecayer_
 
EDGetTokenT< LHEEventProducteventProductToken_
 
HepMCFilterDriverfilter_
 
Hadronizer hadronizer_
 
unsigned int nAttempts_
 
InputTag runInfoProductTag_
 
EDGetTokenT< LHERunInfoProductrunInfoProductToken_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::one::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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

template<class HAD, class DEC>
class edm::HadronizerFilter< HAD, DEC >

Definition at line 55 of file HadronizerFilter.h.

Member Typedef Documentation

template<class HAD , class DEC >
typedef DEC edm::HadronizerFilter< HAD, DEC >::Decayer

Definition at line 64 of file HadronizerFilter.h.

template<class HAD , class DEC >
typedef HAD edm::HadronizerFilter< HAD, DEC >::Hadronizer

Definition at line 63 of file HadronizerFilter.h.

Constructor & Destructor Documentation

template<class HAD , class DEC >
edm::HadronizerFilter< HAD, DEC >::HadronizerFilter ( ParameterSet const &  ps)
explicit

Definition at line 98 of file HadronizerFilter.h.

References edm::BranchDescription::branchType(), edm::ProducerBase::callWhenNewProductsRegistered(), edm::HadronizerFilter< HAD, DEC >::counterRunInfoProducts_, edm::HadronizerFilter< HAD, DEC >::decayer_, edm::HadronizerFilter< HAD, DEC >::eventProductToken_, edm::ParameterSet::exists(), edm::HadronizerFilter< HAD, DEC >::filter_, edm::ParameterSet::getParameter(), edm::HadronizerFilter< HAD, DEC >::hadronizer_, edm::InRun, edm::BranchDescription::moduleLabel(), edm::HadronizerFilter< HAD, DEC >::nAttempts_, edm::BranchDescription::processName(), edm::BranchDescription::productInstanceName(), edm::HadronizerFilter< HAD, DEC >::runInfoProductTag_, edm::HadronizerFilter< HAD, DEC >::runInfoProductToken_, edm::uniqueSharedResourceName(), and edm::BranchDescription::unwrappedTypeID().

98  :
99  EDFilter(),
100  hadronizer_(ps),
101  decayer_(nullptr),
102  filter_(nullptr),
107  nAttempts_(1)
108  {
109  callWhenNewProductsRegistered([this]( BranchDescription const& iBD) {
110  //this is called each time a module registers that it will produce a LHERunInfoProduct
111  if (iBD.unwrappedTypeID() == edm::TypeID(typeid(LHERunInfoProduct)) &&
112  iBD.branchType() == InRun) {
113  ++(this->counterRunInfoProducts_);
114  this->eventProductToken_ = consumes<LHEEventProduct>(InputTag((iBD.moduleLabel()=="externalLHEProducer") ? "externalLHEProducer" : "source"));
115  this->runInfoProductTag_ = InputTag(iBD.moduleLabel(), iBD.productInstanceName(), iBD.processName());
116  this->runInfoProductToken_ = consumes<LHERunInfoProduct,InRun>(InputTag(iBD.moduleLabel(), iBD.productInstanceName(), iBD.processName()));
117  }
118  });
119 
120  // TODO:
121  // Put the list of types produced by the filters here.
122  // The current design calls for:
123  // * LHEGeneratorInfo
124  // * LHEEvent
125  // * HepMCProduct
126  // But I can not find the LHEGeneratorInfo class; it might need to
127  // be invented.
128 
129  std::vector<std::string> const& sharedResources = hadronizer_.sharedResources();
130  for(auto const& resource : sharedResources) {
131  usesResource(resource);
132  }
133 
134  if ( ps.exists("ExternalDecays") )
135  {
136  //decayer_ = new gen::ExternalDecayDriver(ps.getParameter<ParameterSet>("ExternalDecays"));
137  ParameterSet ps1 = ps.getParameter<ParameterSet>("ExternalDecays");
138  decayer_ = new Decayer(ps1);
139 
140  std::vector<std::string> const& sharedResourcesDec = decayer_->sharedResources();
141  for(auto const& resource : sharedResourcesDec) {
142  usesResource(resource);
143  }
144  }
145 
146  if ( ps.exists("HepMCFilter") ) {
147  ParameterSet psfilter = ps.getParameter<ParameterSet>("HepMCFilter");
148  filter_ = new HepMCFilterDriver(psfilter);
149  }
150 
151  //initialize setting for multiple hadronization attempts
152  if (ps.exists("nAttempts")) {
153  nAttempts_ = ps.getParameter<unsigned int>("nAttempts");
154  }
155 
156  // This handles the case where there are no shared resources, because you
157  // have to declare something when the SharedResources template parameter was used.
158  if(sharedResources.empty() && (!decayer_ || decayer_->sharedResources().empty())) {
159  usesResource(edm::uniqueSharedResourceName());
160  }
161 
162  produces<edm::HepMCProduct>("unsmeared");
163  produces<GenEventInfoProduct>();
164  produces<GenLumiInfoHeader, edm::Transition::BeginLuminosityBlock>();
165  produces<GenLumiInfoProduct, edm::Transition::EndLuminosityBlock>();
166  produces<GenRunInfoProduct, edm::Transition::EndRun>();
167  if(filter_)
168  produces<GenFilterInfo, edm::Transition::EndLuminosityBlock>();
169  }
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
Definition: ProducerBase.h:79
unsigned int counterRunInfoProducts_
EDGetTokenT< LHEEventProduct > eventProductToken_
EDGetTokenT< LHERunInfoProduct > runInfoProductToken_
std::string uniqueSharedResourceName()
HepMCFilterDriver * filter_
template<class HAD , class DEC >
edm::HadronizerFilter< HAD, DEC >::~HadronizerFilter ( )
override

Definition at line 172 of file HadronizerFilter.h.

References edm::HadronizerFilter< HAD, DEC >::decayer_, and edm::HadronizerFilter< HAD, DEC >::filter_.

173  {
174  if (decayer_) delete decayer_;
175  if (filter_) delete filter_;
176  }
HepMCFilterDriver * filter_

Member Function Documentation

template<class HAD , class DEC >
void edm::HadronizerFilter< HAD, DEC >::beginLuminosityBlock ( LuminosityBlock const &  lumi,
EventSetup const &  es 
)
override

Definition at line 350 of file HadronizerFilter.h.

351  {}
template<class HAD , class DEC >
void edm::HadronizerFilter< HAD, DEC >::beginLuminosityBlockProduce ( LuminosityBlock lumi,
EventSetup const &  es 
)
override

Definition at line 355 of file HadronizerFilter.h.

References edm::errors::Configuration, edm::HadronizerFilter< HAD, DEC >::decayer_, Exception, edm::HadronizerFilter< HAD, DEC >::filter_, genWeightsTable_cfi::genLumiInfoHeader, edm::HadronizerFilter< HAD, DEC >::hadronizer_, edm::LuminosityBlock::index(), lhef::LHERunInfo::initLumi(), eostools::move(), edm::LuminosityBlock::put(), and HepMCFilterDriver::resetStatistics().

356  {
357  lhef::LHERunInfo* lheRunInfo = hadronizer_.getLHERunInfo().get();
358  lheRunInfo->initLumi();
359 
360  RandomEngineSentry<HAD> randomEngineSentry(&hadronizer_, lumi.index());
361  RandomEngineSentry<DEC> randomEngineSentryDecay(decayer_, lumi.index());
362 
363  hadronizer_.randomizeIndex(lumi,randomEngineSentry.randomEngine());
364 
365  if ( !hadronizer_.readSettings(1) )
367  << "Failed to read settings for the hadronizer "
368  << hadronizer_.classname() << " \n";
369 
370  if ( decayer_ )
371  {
372  decayer_->init(es);
373  if ( !hadronizer_.declareStableParticles( decayer_->operatesOnParticles() ) )
375  << "Failed to declare stable particles in hadronizer "
376  << hadronizer_.classname()
377  << " for internal parton generation\n";
378  if ( !hadronizer_.declareSpecialSettings( decayer_->specialSettings() ) )
380  << "Failed to declare special settings in hadronizer "
381  << hadronizer_.classname()
382  << "\n";
383  }
384 
385  if (filter_) {
387  }
388 
389  if (! hadronizer_.initializeForExternalPartons())
391  << "Failed to initialize hadronizer "
392  << hadronizer_.classname()
393  << " for external parton generation\n";
394 
395  std::unique_ptr<GenLumiInfoHeader> genLumiInfoHeader(hadronizer_.getGenLumiInfoHeader());
396  lumi.put(std::move(genLumiInfoHeader));
397 
398  }
def move(src, dest)
Definition: eostools.py:511
HepMCFilterDriver * filter_
template<class HAD , class DEC >
void edm::HadronizerFilter< HAD, DEC >::beginRun ( Run const &  run,
EventSetup const &  es 
)
override

Definition at line 291 of file HadronizerFilter.h.

References edm::HadronizerFilter< HAD, DEC >::counterRunInfoProducts_, edm::errors::EventCorruption, Exception, edm::Run::getByLabel(), edm::HadronizerFilter< HAD, DEC >::hadronizer_, lhef::LHERunInfo::initLumi(), and edm::HadronizerFilter< HAD, DEC >::runInfoProductTag_.

292  {
293 
294  // this is run-specific
295 
296  // get LHE stuff and pass to hadronizer!
297 
300  << "More than one LHERunInfoProduct present";
301 
302  if(counterRunInfoProducts_ == 0)
304  << "No LHERunInfoProduct present";
305 
306  edm::Handle<LHERunInfoProduct> lheRunInfoProduct;
307  run.getByLabel(runInfoProductTag_, lheRunInfoProduct);
308  //TODO: fix so that this actually works with getByToken commented below...
309  //run.getByToken(runInfoProductToken_, lheRunInfoProduct);
310 
311  hadronizer_.setLHERunInfo( std::make_unique<lhef::LHERunInfo>(*lheRunInfoProduct) );
312  lhef::LHERunInfo* lheRunInfo = hadronizer_.getLHERunInfo().get();
313  lheRunInfo->initLumi();
314 
315  }
unsigned int counterRunInfoProducts_
template<class HAD , class DEC >
void edm::HadronizerFilter< HAD, DEC >::endLuminosityBlock ( LuminosityBlock const &  ,
EventSetup const &   
)
override

Definition at line 402 of file HadronizerFilter.h.

403  {}
template<class HAD , class DEC >
void edm::HadronizerFilter< HAD, DEC >::endLuminosityBlockProduce ( LuminosityBlock lumi,
EventSetup const &   
)
override

Definition at line 407 of file HadronizerFilter.h.

References lhef::LHERunInfo::Process::accepted(), lhef::LHERunInfo::Process::acceptedBr(), lhef::LHERunInfo::XSec::error(), edm::HadronizerFilter< HAD, DEC >::filter_, lhef::LHERunInfo::getHEPRUP(), lhef::LHERunInfo::Process::getLHEXSec(), lhef::LHERunInfo::getLumiProcesses(), edm::HadronizerFilter< HAD, DEC >::hadronizer_, mps_fire::i, lhef::HEPRUP::IDWTUP, lhef::LHERunInfo::Process::killed(), eostools::move(), lhef::LHERunInfo::Counter::n(), lhef::LHERunInfo::Process::nPassNeg(), lhef::LHERunInfo::Process::nPassPos(), lhef::LHERunInfo::Process::nTotalNeg(), lhef::LHERunInfo::Process::nTotalPos(), HepMCFilterDriver::numEventsPassNeg(), HepMCFilterDriver::numEventsPassPos(), HepMCFilterDriver::numEventsTotalNeg(), HepMCFilterDriver::numEventsTotalPos(), lhef::LHERunInfo::Process::process(), edm::LuminosityBlock::put(), lhef::LHERunInfo::Process::selected(), GenLumiInfoProduct::ProcessInfo::setAccepted(), GenLumiInfoProduct::ProcessInfo::setAcceptedBr(), GenLumiInfoProduct::ProcessInfo::setKilled(), GenLumiInfoProduct::ProcessInfo::setLheXSec(), GenLumiInfoProduct::ProcessInfo::setNPassNeg(), GenLumiInfoProduct::ProcessInfo::setNPassPos(), GenLumiInfoProduct::ProcessInfo::setNTotalNeg(), GenLumiInfoProduct::ProcessInfo::setNTotalPos(), GenLumiInfoProduct::ProcessInfo::setProcess(), GenLumiInfoProduct::ProcessInfo::setSelected(), GenLumiInfoProduct::ProcessInfo::setTried(), lhef::LHERunInfo::Counter::sum(), lhef::LHERunInfo::Counter::sum2(), HepMCFilterDriver::sumpass_w(), HepMCFilterDriver::sumpass_w2(), HepMCFilterDriver::sumtotal_w(), HepMCFilterDriver::sumtotal_w2(), groupFilesInBlocks::temp, lhef::LHERunInfo::Process::tried(), and lhef::LHERunInfo::XSec::value().

408  {
409  const lhef::LHERunInfo* lheRunInfo = hadronizer_.getLHERunInfo().get();
410 
411 
412  std::vector<lhef::LHERunInfo::Process> LHELumiProcess = lheRunInfo->getLumiProcesses();
413  std::vector<GenLumiInfoProduct::ProcessInfo> GenLumiProcess;
414  for(unsigned int i=0; i < LHELumiProcess.size(); i++){
415  lhef::LHERunInfo::Process thisProcess=LHELumiProcess[i];
416 
418  temp.setProcess(thisProcess.process());
419  temp.setLheXSec(thisProcess.getLHEXSec().value(),thisProcess.getLHEXSec().error());
420  temp.setNPassPos(thisProcess.nPassPos());
421  temp.setNPassNeg(thisProcess.nPassNeg());
422  temp.setNTotalPos(thisProcess.nTotalPos());
423  temp.setNTotalNeg(thisProcess.nTotalNeg());
424  temp.setTried(thisProcess.tried().n(), thisProcess.tried().sum(), thisProcess.tried().sum2());
425  temp.setSelected(thisProcess.selected().n(), thisProcess.selected().sum(), thisProcess.selected().sum2());
426  temp.setKilled(thisProcess.killed().n(), thisProcess.killed().sum(), thisProcess.killed().sum2());
427  temp.setAccepted(thisProcess.accepted().n(), thisProcess.accepted().sum(), thisProcess.accepted().sum2());
428  temp.setAcceptedBr(thisProcess.acceptedBr().n(), thisProcess.acceptedBr().sum(), thisProcess.acceptedBr().sum2());
429  GenLumiProcess.push_back(temp);
430  }
431  std::unique_ptr<GenLumiInfoProduct> genLumiInfo(new GenLumiInfoProduct());
432  genLumiInfo->setHEPIDWTUP(lheRunInfo->getHEPRUP()->IDWTUP);
433  genLumiInfo->setProcessInfo( GenLumiProcess );
434 
435  lumi.put(std::move(genLumiInfo));
436 
437 
438  // produce GenFilterInfo if HepMCFilter is called
439  if (filter_) {
440 
441  std::unique_ptr<GenFilterInfo> thisProduct(new GenFilterInfo(
446  filter_->sumpass_w(),
447  filter_->sumpass_w2(),
448  filter_->sumtotal_w(),
450  ));
451  lumi.put(std::move(thisProduct));
452  }
453 
454 
455  }
unsigned int nTotalPos() const
Definition: LHERunInfo.h:122
void setTried(unsigned int n, double sum, double sum2)
unsigned int n() const
Definition: LHERunInfo.h:102
void setSelected(unsigned int n, double sum, double sum2)
unsigned int numEventsPassNeg() const
unsigned int numEventsTotalPos() const
void setKilled(unsigned int n, double sum, double sum2)
double sumtotal_w2() const
const std::vector< Process > & getLumiProcesses() const
Definition: LHERunInfo.h:171
XSec getLHEXSec() const
Definition: LHERunInfo.h:118
void setAccepted(unsigned int n, double sum, double sum2)
void setAcceptedBr(unsigned int n, double sum, double sum2)
double sumpass_w() const
double sumtotal_w() const
unsigned int nTotalNeg() const
Definition: LHERunInfo.h:123
double sum2() const
Definition: LHERunInfo.h:104
unsigned int nPassPos() const
Definition: LHERunInfo.h:120
const HEPRUP * getHEPRUP() const
Definition: LHERunInfo.h:52
unsigned int numEventsPassPos() const
Counter killed() const
Definition: LHERunInfo.h:127
void setLheXSec(double value, double err)
double sum() const
Definition: LHERunInfo.h:103
unsigned int numEventsTotalNeg() const
Counter acceptedBr() const
Definition: LHERunInfo.h:129
Counter accepted() const
Definition: LHERunInfo.h:128
double sumpass_w2() const
Counter selected() const
Definition: LHERunInfo.h:126
Counter tried() const
Definition: LHERunInfo.h:125
unsigned int nPassNeg() const
Definition: LHERunInfo.h:121
def move(src, dest)
Definition: eostools.py:511
HepMCFilterDriver * filter_
template<class HAD , class DEC >
void edm::HadronizerFilter< HAD, DEC >::endRun ( Run const &  r,
EventSetup const &   
)
override

Definition at line 319 of file HadronizerFilter.h.

319 {}
template<class HAD , class DEC >
void edm::HadronizerFilter< HAD, DEC >::endRunProduce ( Run r,
EventSetup const &   
)
override

Definition at line 323 of file HadronizerFilter.h.

References edm::HadronizerFilter< HAD, DEC >::decayer_, lhef::LHERunInfo::XSec::error(), edm::HadronizerFilter< HAD, DEC >::filter_, edm::HadronizerFilter< HAD, DEC >::hadronizer_, eostools::move(), edm::Run::put(), GenRunInfoProduct::setInternalXSec(), HepMCFilterDriver::statistics(), lhef::LHERunInfo::statistics(), lhef::LHERunInfo::XSec::value(), and lhef::LHERunInfo::xsec().

324  {
325  // Retrieve the LHE run info summary and transfer determined
326  // cross-section into the generator run info
327 
328  const lhef::LHERunInfo* lheRunInfo = hadronizer_.getLHERunInfo().get();
329  lhef::LHERunInfo::XSec xsec = lheRunInfo->xsec();
330 
331  GenRunInfoProduct& genRunInfo = hadronizer_.getGenRunInfo();
332  genRunInfo.setInternalXSec( GenRunInfoProduct::XSec(xsec.value(), xsec.error()) );
333 
334  // If relevant, record the integrated luminosity for this run
335  // here. To do so, we would need a standard function to invoke on
336  // the contained hadronizer that would report the integrated
337  // luminosity.
338 
339  hadronizer_.statistics();
340  if ( decayer_ ) decayer_->statistics();
341  if ( filter_ ) filter_->statistics();
342  lheRunInfo->statistics();
343 
344  std::unique_ptr<GenRunInfoProduct> griproduct( new GenRunInfoProduct(genRunInfo) );
345  r.put(std::move(griproduct));
346  }
XSec xsec() const
Definition: LHERunInfo.cc:199
void setInternalXSec(const XSec &xsec)
void statistics() const
def move(src, dest)
Definition: eostools.py:511
HepMCFilterDriver * filter_
void statistics() const
Definition: LHERunInfo.cc:297
template<class HAD , class DEC >
bool edm::HadronizerFilter< HAD, DEC >::filter ( Event e,
EventSetup const &  es 
)
overridevirtual

Implements edm::one::EDFilterBase.

Definition at line 180 of file HadronizerFilter.h.

References edm::HadronizerFilter< HAD, DEC >::decayer_, edm::EventID::event(), event(), edm::HadronizerFilter< HAD, DEC >::eventProductToken_, HepMCFilterDriver::filter(), edm::HadronizerFilter< HAD, DEC >::filter_, particlelevel_cff::genEventInfo, edm::Event::getByToken(), edm::HadronizerFilter< HAD, DEC >::hadronizer_, edm::EventBase::id(), eostools::move(), edm::HadronizerFilter< HAD, DEC >::nAttempts_, edm::Event::put(), edm::Event::streamID(), and protons_cff::t.

181  {
182  RandomEngineSentry<HAD> randomEngineSentry(&hadronizer_, ev.streamID());
183  RandomEngineSentry<DEC> randomEngineSentryDecay(decayer_, ev.streamID());
184 
185  hadronizer_.setEDMEvent(ev);
186 
187  // get LHE stuff and pass to hadronizer!
188  //
190  ev.getByToken(eventProductToken_, product);
191 
192  std::unique_ptr<HepMC::GenEvent> finalEvent;
193  std::unique_ptr<GenEventInfoProduct> finalGenEventInfo;
194 
195  //sum of weights for events passing hadronization
196  double waccept = 0;
197  //number of accepted events
198  unsigned int naccept = 0;
199 
200  for (unsigned int itry = 0; itry<nAttempts_; ++itry) {
201 
202  hadronizer_.setLHEEvent(std::make_unique<lhef::LHEEvent>(hadronizer_.getLHERunInfo(), *product) );
203 
204  // hadronizer_.generatePartons();
205  if ( !hadronizer_.hadronize() ) continue ;
206 
207  // this is "fake" stuff
208  // in principle, decays are done as part of full event generation,
209  // except for particles that are marked as to be kept stable
210  // but we currently keep in it the design, because we might want
211  // to use such feature for other applications
212  //
213  if ( !hadronizer_.decay() ) continue;
214 
215  std::unique_ptr<HepMC::GenEvent> event (hadronizer_.getGenEvent());
216  if( !event.get() ) continue;
217 
218  // The external decay driver is being added to the system,
219  // it should be called here
220  //
221  if ( decayer_ )
222  {
223  auto lheEvent = hadronizer_.getLHEEvent();
224  auto t = decayer_->decay( event.get(),lheEvent.get() );
225  if(t != event.get()) {
226  event.reset(t);
227  }
228  hadronizer_.setLHEEvent(std::move(lheEvent));
229  }
230 
231  if ( !event.get() ) continue;
232 
233  // check and perform if there're any unstable particles after
234  // running external decay packges
235  //
236  hadronizer_.resetEvent( std::move(event) );
237  if ( !hadronizer_.residualDecay() ) continue;
238 
239  hadronizer_.finalizeEvent();
240 
241  event = hadronizer_.getGenEvent();
242  if ( !event.get() ) continue;
243 
244  event->set_event_number( ev.id().event() );
245 
246  std::unique_ptr<GenEventInfoProduct> genEventInfo(hadronizer_.getGenEventInfo());
247  if (!genEventInfo.get())
248  {
249  // create GenEventInfoProduct from HepMC event in case hadronizer didn't provide one
250  genEventInfo.reset(new GenEventInfoProduct(event.get()));
251  }
252 
253  //if HepMCFilter was specified, test event
254  if (filter_ && !filter_->filter(event.get(), genEventInfo->weight())) continue;
255 
256  waccept += genEventInfo->weight();
257  ++naccept;
258 
259  //keep the LAST accepted event (which is equivalent to choosing randomly from the accepted events)
260  finalEvent = std::move(event);
261  finalGenEventInfo = std::move(genEventInfo);
262 
263  }
264 
265  if (!naccept) return false;
266 
267 
268 
269  //adjust event weights if necessary (in case input event was attempted multiple times)
270  if (nAttempts_>1) {
271  double multihadweight = double(naccept)/double(nAttempts_);
272 
273  //adjust weight for GenEventInfoProduct
274  finalGenEventInfo->weights()[0] *= multihadweight;
275 
276  //adjust weight for HepMC GenEvent (used e.g for RIVET)
277  finalEvent->weights()[0] *= multihadweight;
278  }
279 
280  ev.put(std::move(finalGenEventInfo));
281 
282  std::unique_ptr<HepMCProduct> bare_product(new HepMCProduct());
283  bare_product->addHepMCData( finalEvent.release() );
284  ev.put(std::move(bare_product), "unsmeared");
285 
286  return true;
287  }
bool ev
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
EDGetTokenT< LHEEventProduct > eventProductToken_
bool filter(const HepMC::GenEvent *evt, double weight=1.)
def move(src, dest)
Definition: eostools.py:511
HepMCFilterDriver * filter_
Definition: event.py:1

Member Data Documentation

template<class HAD , class DEC >
unsigned int edm::HadronizerFilter< HAD, DEC >::counterRunInfoProducts_
private
template<class HAD , class DEC >
Decayer* edm::HadronizerFilter< HAD, DEC >::decayer_
private
template<class HAD , class DEC >
EDGetTokenT<LHEEventProduct> edm::HadronizerFilter< HAD, DEC >::eventProductToken_
private
template<class HAD , class DEC >
HepMCFilterDriver* edm::HadronizerFilter< HAD, DEC >::filter_
private
template<class HAD , class DEC >
Hadronizer edm::HadronizerFilter< HAD, DEC >::hadronizer_
private
template<class HAD , class DEC >
unsigned int edm::HadronizerFilter< HAD, DEC >::nAttempts_
private
template<class HAD , class DEC >
InputTag edm::HadronizerFilter< HAD, DEC >::runInfoProductTag_
private
template<class HAD , class DEC >
EDGetTokenT<LHERunInfoProduct> edm::HadronizerFilter< HAD, DEC >::runInfoProductToken_
private