9 #ifndef gen_HadronizerFilter_h 10 #define gen_HadronizerFilter_h 31 #include "CLHEP/Random/RandomEngine.h" 56 BeginLuminosityBlockProducer,
57 EndLuminosityBlockProducer,
59 one::WatchLuminosityBlocks,
97 template <
class HAD,
class DEC>
129 std::vector<std::string>
const& sharedResources =
hadronizer_.sharedResources();
130 for(
auto const& resource : sharedResources) {
131 usesResource(resource);
134 if ( ps.
exists(
"ExternalDecays") )
140 std::vector<std::string>
const& sharedResourcesDec = decayer_->sharedResources();
141 for(
auto const& resource : sharedResourcesDec) {
142 usesResource(resource);
146 if ( ps.
exists(
"HepMCFilter") ) {
152 if (ps.
exists(
"nAttempts")) {
158 if(sharedResources.empty() && (!
decayer_ ||
decayer_->sharedResources().empty())) {
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>();
168 produces<GenFilterInfo, edm::Transition::EndLuminosityBlock>();
171 template <
class HAD,
class DEC>
178 template <
class HAD,
class DEC>
192 std::unique_ptr<HepMC::GenEvent> finalEvent;
193 std::unique_ptr<GenEventInfoProduct> finalGenEventInfo;
198 unsigned int naccept = 0;
200 for (
unsigned int itry = 0; itry<
nAttempts_; ++itry) {
216 if( !
event.get() )
continue;
231 if ( !
event.get() )
continue;
242 if ( !
event.get() )
continue;
244 event->set_event_number( ev.
id().
event() );
265 if (!naccept)
return false;
271 double multihadweight = double(naccept)/double(nAttempts_);
274 finalGenEventInfo->weights()[0] *= multihadweight;
277 finalEvent->weights()[0] *= multihadweight;
282 std::unique_ptr<HepMCProduct> bare_product(
new HepMCProduct());
283 bare_product->addHepMCData( finalEvent.release() );
289 template <
class HAD,
class DEC>
300 <<
"More than one LHERunInfoProduct present";
304 <<
"No LHERunInfoProduct present";
311 hadronizer_.setLHERunInfo( std::make_unique<lhef::LHERunInfo>(*lheRunInfoProduct) );
317 template <
class HAD,
class DEC>
321 template <
class HAD,
class DEC>
344 std::unique_ptr<GenRunInfoProduct> griproduct(
new GenRunInfoProduct(genRunInfo) );
348 template <
class HAD,
class DEC>
353 template <
class HAD,
class DEC>
363 hadronizer_.randomizeIndex(lumi,randomEngineSentry.randomEngine());
367 <<
"Failed to read settings for the hadronizer " 375 <<
"Failed to declare stable particles in hadronizer " 377 <<
" for internal parton generation\n";
380 <<
"Failed to declare special settings in hadronizer " 391 <<
"Failed to initialize hadronizer " 393 <<
" for external parton generation\n";
400 template <
class HAD,
class DEC>
405 template <
class HAD,
class DEC>
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++){
429 GenLumiProcess.push_back(temp);
433 genLumiInfo->setProcessInfo( GenLumiProcess );
441 std::unique_ptr<GenFilterInfo> thisProduct(
new GenFilterInfo(
460 #endif // gen_HadronizerFilter_h void setNPassNeg(unsigned int n)
T getParameter(std::string const &) const
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
EventNumber_t event() const
unsigned int nTotalPos() const
bool getByLabel(std::string const &label, Handle< PROD > &result) const
void beginRun(Run const &, EventSetup const &) override
void setTried(unsigned int n, double sum, double sum2)
void setNTotalNeg(unsigned int n)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
BranchType const & branchType() const
void setSelected(unsigned int n, double sum, double sum2)
LuminosityBlockIndex index() const
unsigned int numEventsPassNeg() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
unsigned int numEventsTotalPos() const
void setKilled(unsigned int n, double sum, double sum2)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::string const & processName() const
double sumtotal_w2() const
HadronizerFilter(ParameterSet const &ps)
void endLuminosityBlockProduce(LuminosityBlock &, EventSetup const &) override
void setInternalXSec(const XSec &xsec)
const std::vector< Process > & getLumiProcesses() const
void setAccepted(unsigned int n, double sum, double sum2)
std::string const & moduleLabel() const
void beginLuminosityBlockProduce(LuminosityBlock &, EventSetup const &) override
void setAcceptedBr(unsigned int n, double sum, double sum2)
std::string const & productInstanceName() const
void put(std::unique_ptr< PROD > product)
Put a new product.
TypeID unwrappedTypeID() const
double sumtotal_w() const
unsigned int counterRunInfoProducts_
void endRun(Run const &, EventSetup const &) override
void setNTotalPos(unsigned int n)
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 nTotalNeg() const
InputTag runInfoProductTag_
EDGetTokenT< LHEEventProduct > eventProductToken_
unsigned int nPassPos() const
const HEPRUP * getHEPRUP() const
bool filter(Event &e, EventSetup const &es) override
EDGetTokenT< LHERunInfoProduct > runInfoProductToken_
unsigned int numEventsPassPos() const
void put(std::unique_ptr< PROD > product)
Put a new product.
void setLheXSec(double value, double err)
void endRunProduce(Run &, EventSetup const &) override
unsigned int numEventsTotalNeg() const
StreamID streamID() const
Counter acceptedBr() const
double sumpass_w2() const
void endLuminosityBlock(LuminosityBlock const &, EventSetup const &) override
void setNPassPos(unsigned int n)
std::string uniqueSharedResourceName()
unsigned int nPassNeg() const
bool filter(const HepMC::GenEvent *evt, double weight=1.)
void beginLuminosityBlock(LuminosityBlock const &, EventSetup const &) override
HepMCFilterDriver * filter_
~HadronizerFilter() override