CMS 3D CMS Logo

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

#include <GeneratorFilter.h>

Inheritance diagram for edm::GeneratorFilter< HAD, DEC >:
edm::one::EDFilter< EndRunProducer, BeginLuminosityBlockProducer, EndLuminosityBlockProducer, 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 endLuminosityBlock (LuminosityBlock const &, EventSetup const &) override
 
void endLuminosityBlockProduce (LuminosityBlock &, EventSetup const &) override
 
void endRunProduce (Run &, EventSetup const &) override
 
bool filter (Event &e, EventSetup const &es) override
 
 GeneratorFilter (ParameterSet const &ps)
 
void preallocThreads (unsigned int iThreads) override
 
 ~GeneratorFilter () override
 
- Public Member Functions inherited from edm::one::EDFilter< EndRunProducer, BeginLuminosityBlockProducer, EndLuminosityBlockProducer, 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

Decayerdecayer_
 
Hadronizer hadronizer_
 
bool initialized_ = false
 
unsigned int nEventsInLumiBlock_
 
unsigned int nThreads_ {1}
 

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::GeneratorFilter< HAD, DEC >

Definition at line 40 of file GeneratorFilter.h.

Member Typedef Documentation

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

Definition at line 48 of file GeneratorFilter.h.

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

Definition at line 47 of file GeneratorFilter.h.

Constructor & Destructor Documentation

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

Definition at line 78 of file GeneratorFilter.h.

References edm::GeneratorFilter< HAD, DEC >::decayer_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::GeneratorFilter< HAD, DEC >::hadronizer_, and edm::uniqueSharedResourceName().

78  :
79  EDFilter(),
80  hadronizer_(ps),
81  decayer_(nullptr),
83  {
84  // TODO:
85  // Put the list of types produced by the filters here.
86  // The current design calls for:
87  // * GenRunInfoProduct
88  // * HepMCProduct
89  //
90  // other maybe added as needs be
91  //
92 
93  std::vector<std::string> const& sharedResources = hadronizer_.sharedResources();
94  for(auto const& resource : sharedResources) {
95  usesResource(resource);
96  }
97 
98  if ( ps.exists("ExternalDecays") )
99  {
100  //decayer_ = new gen::ExternalDecayDriver(ps.getParameter<ParameterSet>("ExternalDecays"));
101  ParameterSet ps1 = ps.getParameter<ParameterSet>("ExternalDecays");
102  decayer_ = new Decayer(ps1);
103 
104  std::vector<std::string> const& sharedResourcesDec = decayer_->sharedResources();
105  for(auto const& resource : sharedResourcesDec) {
106  usesResource(resource);
107  }
108  }
109 
110  // This handles the case where there are no shared resources, because you
111  // have to declare something when the SharedResources template parameter was used.
112  if(sharedResources.empty() && (!decayer_ || decayer_->sharedResources().empty())) {
113  usesResource(edm::uniqueSharedResourceName());
114  }
115 
116  produces<edm::HepMCProduct>("unsmeared");
117  produces<GenEventInfoProduct>();
118  produces<GenLumiInfoHeader, edm::Transition::BeginLuminosityBlock>();
119  produces<GenLumiInfoProduct, edm::Transition::EndLuminosityBlock>();
120  produces<GenRunInfoProduct, edm::Transition::EndRun>();
121 
122  }
unsigned int nEventsInLumiBlock_
std::string uniqueSharedResourceName()
template<class HAD , class DEC >
edm::GeneratorFilter< HAD, DEC >::~GeneratorFilter ( )
override

Definition at line 125 of file GeneratorFilter.h.

References edm::GeneratorFilter< HAD, DEC >::decayer_.

126  { if ( decayer_ ) delete decayer_;}

Member Function Documentation

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

Definition at line 238 of file GeneratorFilter.h.

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

Definition at line 243 of file GeneratorFilter.h.

References edm::errors::Configuration, edm::GeneratorFilter< HAD, DEC >::decayer_, Exception, genWeightsTable_cfi::genLumiInfoHeader, edm::GeneratorFilter< HAD, DEC >::hadronizer_, edm::LuminosityBlock::index(), edm::GeneratorFilter< HAD, DEC >::initialized_, eostools::move(), edm::GeneratorFilter< HAD, DEC >::nEventsInLumiBlock_, edm::GeneratorFilter< HAD, DEC >::nThreads_, and edm::LuminosityBlock::put().

244  {
246  RandomEngineSentry<HAD> randomEngineSentry(&hadronizer_, lumi.index());
247  RandomEngineSentry<DEC> randomEngineSentryDecay(decayer_, lumi.index());
248 
249  hadronizer_.randomizeIndex(lumi,randomEngineSentry.randomEngine());
250  hadronizer_.generateLHE(lumi,randomEngineSentry.randomEngine(), nThreads_);
251 
252  if ( !hadronizer_.readSettings(0) )
254  << "Failed to read settings for the hadronizer "
255  << hadronizer_.classname() << " \n";
256 
257  if ( decayer_ )
258  {
259  decayer_->init(es);
260  if ( !hadronizer_.declareStableParticles( decayer_->operatesOnParticles() ) )
262  << "Failed to declare stable particles in hadronizer "
263  << hadronizer_.classname()
264  << "\n";
265  if ( !hadronizer_.declareSpecialSettings( decayer_->specialSettings() ) )
267  << "Failed to declare special settings in hadronizer "
268  << hadronizer_.classname()
269  << "\n";
270  }
271 
272  if ( !hadronizer_.initializeForInternalPartons() )
274  << "Failed to initialize hadronizer "
275  << hadronizer_.classname()
276  << " for internal parton generation\n";
277 
278  std::unique_ptr<GenLumiInfoHeader> genLumiInfoHeader(hadronizer_.getGenLumiInfoHeader());
279  lumi.put(std::move(genLumiInfoHeader));
280  initialized_ = true;
281  }
unsigned int nThreads_
unsigned int nEventsInLumiBlock_
def move(src, dest)
Definition: eostools.py:511
template<class HAD , class DEC >
void edm::GeneratorFilter< HAD, DEC >::endLuminosityBlock ( LuminosityBlock const &  ,
EventSetup const &   
)
override

Definition at line 285 of file GeneratorFilter.h.

References edm::GeneratorFilter< HAD, DEC >::hadronizer_.

286  {
287  hadronizer_.cleanLHE();
288  }
template<class HAD , class DEC >
void edm::GeneratorFilter< HAD, DEC >::endLuminosityBlockProduce ( LuminosityBlock lumi,
EventSetup const &   
)
override

Definition at line 292 of file GeneratorFilter.h.

References edm::GeneratorFilter< HAD, DEC >::decayer_, GenRunInfoProduct::XSec::error(), edm::GeneratorFilter< HAD, DEC >::hadronizer_, GenRunInfoProduct::internalXSec(), eostools::move(), edm::GeneratorFilter< HAD, DEC >::nEventsInLumiBlock_, edm::LuminosityBlock::put(), 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(), groupFilesInBlocks::temp, and GenRunInfoProduct::XSec::value().

293  {
294  hadronizer_.statistics();
295  if ( decayer_ ) decayer_->statistics();
296 
297  GenRunInfoProduct genRunInfo = GenRunInfoProduct(hadronizer_.getGenRunInfo());
298  std::vector<GenLumiInfoProduct::ProcessInfo> GenLumiProcess;
299  const GenRunInfoProduct::XSec& xsec = genRunInfo.internalXSec();
301  temp.setProcess(0);
302  temp.setLheXSec(xsec.value(), xsec.error()); // Pythia gives error of -1
304  temp.setNPassNeg(0);
306  temp.setNTotalNeg(0);
310  temp.setAccepted(0,-1,-1);
311  temp.setAcceptedBr(0,-1,-1);
312  GenLumiProcess.push_back(temp);
313 
314  std::unique_ptr<GenLumiInfoProduct> genLumiInfo(new GenLumiInfoProduct());
315  genLumiInfo->setHEPIDWTUP(-1);
316  genLumiInfo->setProcessInfo( GenLumiProcess );
317 
318  lumi.put(std::move(genLumiInfo));
319 
321 
322  }
void setTried(unsigned int n, double sum, double sum2)
void setSelected(unsigned int n, double sum, double sum2)
void setKilled(unsigned int n, double sum, double sum2)
void setAccepted(unsigned int n, double sum, double sum2)
void setAcceptedBr(unsigned int n, double sum, double sum2)
unsigned int nEventsInLumiBlock_
void setLheXSec(double value, double err)
const XSec & internalXSec() const
def move(src, dest)
Definition: eostools.py:511
template<class HAD , class DEC >
void edm::GeneratorFilter< HAD, DEC >::endRunProduce ( Run r,
EventSetup const &   
)
override

Definition at line 219 of file GeneratorFilter.h.

References edm::GeneratorFilter< HAD, DEC >::decayer_, edm::GeneratorFilter< HAD, DEC >::hadronizer_, edm::GeneratorFilter< HAD, DEC >::initialized_, eostools::move(), and edm::Run::put().

220  {
221  // If relevant, record the integrated luminosity for this run
222  // here. To do so, we would need a standard function to invoke on
223  // the contained hadronizer that would report the integrated
224  // luminosity.
225 
226  if(initialized_) {
227  hadronizer_.statistics();
228 
229  if ( decayer_ ) decayer_->statistics();
230  }
231 
232  std::unique_ptr<GenRunInfoProduct> griproduct(new GenRunInfoProduct(hadronizer_.getGenRunInfo()));
233  r.put(std::move(griproduct));
234  }
def move(src, dest)
Definition: eostools.py:511
template<class HAD , class DEC >
bool edm::GeneratorFilter< HAD, DEC >::filter ( Event e,
EventSetup const &  es 
)
overridevirtual

Implements edm::one::EDFilterBase.

Definition at line 136 of file GeneratorFilter.h.

References edm::GeneratorFilter< HAD, DEC >::decayer_, edm::EventID::event(), event(), particlelevel_cff::genEventInfo, edm::GeneratorFilter< HAD, DEC >::hadronizer_, edm::EventBase::id(), eostools::move(), edm::GeneratorFilter< HAD, DEC >::nEventsInLumiBlock_, edm::Event::put(), edm::Event::streamID(), and protons_cff::t.

137  {
138  RandomEngineSentry<HAD> randomEngineSentry(&hadronizer_, ev.streamID());
139  RandomEngineSentry<DEC> randomEngineSentryDecay(decayer_, ev.streamID());
140 
141  //added for selecting/filtering gen events, in the case of hadronizer+externalDecayer
142 
143  bool passEvtGenSelector = false;
144  std::unique_ptr<HepMC::GenEvent> event(nullptr);
145 
146  while(!passEvtGenSelector)
147  {
148  event.reset();
149  hadronizer_.setEDMEvent(ev);
150 
151  if ( !hadronizer_.generatePartonsAndHadronize() ) return false;
152 
153  // this is "fake" stuff
154  // in principle, decays are done as part of full event generation,
155  // except for particles that are marked as to be kept stable
156  // but we currently keep in it the design, because we might want
157  // to use such feature for other applications
158  //
159  if ( !hadronizer_.decay() ) return false;
160 
161  event = hadronizer_.getGenEvent();
162  if ( !event.get() ) return false;
163 
164  // The external decay driver is being added to the system,
165  // it should be called here
166  //
167  if ( decayer_ )
168  {
169  auto t = decayer_->decay( event.get() );
170  if(t != event.get()) {
171  event.reset(t);
172  }
173  }
174  if ( !event.get() ) return false;
175 
176  passEvtGenSelector = hadronizer_.select( event.get() );
177 
178  }
179  // check and perform if there're any unstable particles after
180  // running external decay packages
181  //
182  // fisrt of all, put back modified event tree (after external decay)
183  //
184  hadronizer_.resetEvent( std::move(event) );
185 
186  //
187  // now run residual decays
188  //
189  if ( !hadronizer_.residualDecay() ) return false;
190 
191  hadronizer_.finalizeEvent();
192 
193  event = hadronizer_.getGenEvent();
194  if ( !event.get() ) return false;
195 
196  event->set_event_number( ev.id().event() );
197 
198  //
199  // tutto bene - finally, form up EDM products !
200  //
201  auto genEventInfo = hadronizer_.getGenEventInfo();
202  if (!genEventInfo.get())
203  {
204  // create GenEventInfoProduct from HepMC event in case hadronizer didn't provide one
205  genEventInfo.reset(new GenEventInfoProduct(event.get()));
206  }
207 
208  ev.put(std::move(genEventInfo));
209 
210  std::unique_ptr<HepMCProduct> bare_product(new HepMCProduct());
211  bare_product->addHepMCData( event.release() );
212  ev.put(std::move(bare_product), "unsmeared");
214  return true;
215  }
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
unsigned int nEventsInLumiBlock_
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
template<class HAD , class DEC >
void edm::GeneratorFilter< HAD, DEC >::preallocThreads ( unsigned int  iThreads)
overridevirtual

Reimplemented from edm::one::EDFilterBase.

Definition at line 130 of file GeneratorFilter.h.

References edm::GeneratorFilter< HAD, DEC >::nThreads_.

130  {
131  nThreads_ = iThreads;
132  }
unsigned int nThreads_

Member Data Documentation

template<class HAD , class DEC >
Decayer* edm::GeneratorFilter< HAD, DEC >::decayer_
private
template<class HAD , class DEC >
Hadronizer edm::GeneratorFilter< HAD, DEC >::hadronizer_
private
template<class HAD , class DEC >
bool edm::GeneratorFilter< HAD, DEC >::initialized_ = false
private
template<class HAD , class DEC >
unsigned int edm::GeneratorFilter< HAD, DEC >::nEventsInLumiBlock_
private
template<class HAD , class DEC >
unsigned int edm::GeneratorFilter< HAD, DEC >::nThreads_ {1}
private