CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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, 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
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

virtual void beginLuminosityBlock (LuminosityBlock const &, EventSetup const &) override
 
virtual void endLuminosityBlock (LuminosityBlock const &, EventSetup const &) override
 
virtual void endLuminosityBlockProduce (LuminosityBlock &, EventSetup const &) override
 
virtual void endRunProduce (Run &, EventSetup const &) override
 
virtual bool filter (Event &e, EventSetup const &es) override
 
 GeneratorFilter (ParameterSet const &ps)
 
virtual ~GeneratorFilter ()
 
- Public Member Functions inherited from edm::one::EDFilter< EndRunProducer, EndLuminosityBlockProducer, one::WatchLuminosityBlocks, one::SharedResources >
 EDFilter ()=default
 
- Public Member Functions inherited from edm::one::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilterBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

Decayerdecayer_
 
Hadronizer hadronizer_
 
unsigned int nEventsInLumiBlock_
 

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 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 38 of file GeneratorFilter.h.

Member Typedef Documentation

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

Definition at line 45 of file GeneratorFilter.h.

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

Definition at line 44 of file GeneratorFilter.h.

Constructor & Destructor Documentation

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

Definition at line 71 of file GeneratorFilter.h.

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

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

Definition at line 116 of file GeneratorFilter.h.

117  { if ( decayer_ ) delete decayer_;}

Member Function Documentation

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

Definition at line 217 of file GeneratorFilter.h.

References edm::errors::Configuration, Exception, and edm::LuminosityBlock::index().

218  {
220  RandomEngineSentry<HAD> randomEngineSentry(&hadronizer_, lumi.index());
221  RandomEngineSentry<DEC> randomEngineSentryDecay(decayer_, lumi.index());
222 
223  if ( !hadronizer_.readSettings(0) )
225  << "Failed to read settings for the hadronizer "
226  << hadronizer_.classname() << " \n";
227 
228  if ( decayer_ )
229  {
230  decayer_->init(es);
231  if ( !hadronizer_.declareStableParticles( decayer_->operatesOnParticles() ) )
233  << "Failed to declare stable particles in hadronizer "
234  << hadronizer_.classname()
235  << "\n";
236  if ( !hadronizer_.declareSpecialSettings( decayer_->specialSettings() ) )
238  << "Failed to declare special settings in hadronizer "
239  << hadronizer_.classname()
240  << "\n";
241  }
242 
243  if ( !hadronizer_.initializeForInternalPartons() )
245  << "Failed to initialize hadronizer "
246  << hadronizer_.classname()
247  << " for internal parton generation\n";
248  }
tuple lumi
Definition: fjr2json.py:35
unsigned int nEventsInLumiBlock_
template<class HAD , class DEC >
void edm::GeneratorFilter< HAD, DEC >::endLuminosityBlock ( LuminosityBlock const &  ,
EventSetup const &   
)
overridevirtual

Definition at line 252 of file GeneratorFilter.h.

253  {}
template<class HAD , class DEC >
void edm::GeneratorFilter< HAD, DEC >::endLuminosityBlockProduce ( LuminosityBlock lumi,
EventSetup const &   
)
overridevirtual

Definition at line 257 of file GeneratorFilter.h.

References GenRunInfoProduct::XSec::error(), GenRunInfoProduct::internalXSec(), 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().

258  {
259  hadronizer_.statistics();
260  if ( decayer_ ) decayer_->statistics();
261 
262  GenRunInfoProduct genRunInfo = GenRunInfoProduct(hadronizer_.getGenRunInfo());
263  std::vector<GenLumiInfoProduct::ProcessInfo> GenLumiProcess;
264  GenRunInfoProduct::XSec xsec = genRunInfo.internalXSec();
266  temp.setProcess(0);
267  temp.setLheXSec(xsec.value(), xsec.error()); // Pythia gives error of -1
269  temp.setNPassNeg(0);
271  temp.setNTotalNeg(0);
275  temp.setAccepted(0,-1,-1);
276  temp.setAcceptedBr(0,-1,-1);
277  GenLumiProcess.push_back(temp);
278 
279  std::auto_ptr<GenLumiInfoProduct> genLumiInfo(new GenLumiInfoProduct());
280  genLumiInfo->setHEPIDWTUP(-1);
281  genLumiInfo->setProcessInfo( GenLumiProcess );
282  lumi.put(genLumiInfo);
283 
285 
286  }
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
template<class HAD , class DEC >
void edm::GeneratorFilter< HAD, DEC >::endRunProduce ( Run r,
EventSetup const &   
)
overridevirtual

Definition at line 200 of file GeneratorFilter.h.

References edm::Run::put().

201  {
202  // If relevant, record the integrated luminosity for this run
203  // here. To do so, we would need a standard function to invoke on
204  // the contained hadronizer that would report the integrated
205  // luminosity.
206 
207  hadronizer_.statistics();
208 
209  if ( decayer_ ) decayer_->statistics();
210 
211  std::auto_ptr<GenRunInfoProduct> griproduct(new GenRunInfoProduct(hadronizer_.getGenRunInfo()));
212  r.put(griproduct);
213  }
template<class HAD , class DEC >
bool edm::GeneratorFilter< HAD, DEC >::filter ( Event e,
EventSetup const &  es 
)
overridevirtual

Implements edm::one::EDFilterBase.

Definition at line 121 of file GeneratorFilter.h.

References edm::EventID::event(), event(), edm::EventBase::id(), edm::Event::put(), and edm::Event::streamID().

122  {
123  RandomEngineSentry<HAD> randomEngineSentry(&hadronizer_, ev.streamID());
124  RandomEngineSentry<DEC> randomEngineSentryDecay(decayer_, ev.streamID());
125 
126  //added for selecting/filtering gen events, in the case of hadronizer+externalDecayer
127 
128  bool passEvtGenSelector = false;
129  std::auto_ptr<HepMC::GenEvent> event(0);
130 
131  while(!passEvtGenSelector)
132  {
133  event.reset();
134  hadronizer_.setEDMEvent(ev);
135 
136  if ( !hadronizer_.generatePartonsAndHadronize() ) return false;
137 
138  // this is "fake" stuff
139  // in principle, decays are done as part of full event generation,
140  // except for particles that are marked as to be kept stable
141  // but we currently keep in it the design, because we might want
142  // to use such feature for other applications
143  //
144  if ( !hadronizer_.decay() ) return false;
145 
146  event = std::auto_ptr<HepMC::GenEvent>(hadronizer_.getGenEvent());
147  if ( !event.get() ) return false;
148 
149  // The external decay driver is being added to the system,
150  // it should be called here
151  //
152  if ( decayer_ )
153  {
154  event.reset( decayer_->decay( event.get() ) );
155  }
156  if ( !event.get() ) return false;
157 
158  passEvtGenSelector = hadronizer_.select( event.get() );
159 
160  }
161  // check and perform if there're any unstable particles after
162  // running external decay packages
163  //
164  // fisrt of all, put back modified event tree (after external decay)
165  //
166  hadronizer_.resetEvent( event.release() );
167 
168  //
169  // now run residual decays
170  //
171  if ( !hadronizer_.residualDecay() ) return false;
172 
173  hadronizer_.finalizeEvent();
174 
175  event.reset( hadronizer_.getGenEvent() );
176  if ( !event.get() ) return false;
177 
178  event->set_event_number( ev.id().event() );
179 
180  //
181  // tutto bene - finally, form up EDM products !
182  //
183  std::auto_ptr<GenEventInfoProduct> genEventInfo(hadronizer_.getGenEventInfo());
184  if (!genEventInfo.get())
185  {
186  // create GenEventInfoProduct from HepMC event in case hadronizer didn't provide one
187  genEventInfo.reset(new GenEventInfoProduct(event.get()));
188  }
189  ev.put(genEventInfo);
190 
191  std::auto_ptr<HepMCProduct> bare_product(new HepMCProduct());
192  bare_product->addHepMCData( event.release() );
193  ev.put(bare_product, "unsmeared");
195  return true;
196  }
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_

Member Data Documentation

template<class HAD , class DEC >
Decayer* edm::GeneratorFilter< HAD, DEC >::decayer_
private

Definition at line 62 of file GeneratorFilter.h.

Referenced by edm::GeneratorFilter< HAD, DEC >::GeneratorFilter().

template<class HAD , class DEC >
Hadronizer edm::GeneratorFilter< HAD, DEC >::hadronizer_
private

Definition at line 60 of file GeneratorFilter.h.

Referenced by edm::GeneratorFilter< HAD, DEC >::GeneratorFilter().

template<class HAD , class DEC >
unsigned int edm::GeneratorFilter< HAD, DEC >::nEventsInLumiBlock_
private

Definition at line 63 of file GeneratorFilter.h.