CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
LHEProducer Class Reference
Inheritance diagram for LHEProducer:
edm::one::EDFilter< edm::EndRunProducer, edm::one::WatchRuns > edm::one::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 LHEProducer (const edm::ParameterSet &params)
 
virtual ~LHEProducer ()
 
- Public Member Functions inherited from edm::one::EDFilter< edm::EndRunProducer, edm::one::WatchRuns >
 EDFilter ()=default
 
- Public Member Functions inherited from edm::one::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilterBase ()
 
- 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 ()
 
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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Member Functions

virtual void beginJob () override
 
virtual void beginRun (edm::Run const &run, const edm::EventSetup &es) override
 
virtual void endJob () override
 
virtual void endRun (edm::Run const &run, const edm::EventSetup &es) override
 
virtual void endRunProduce (edm::Run &run, const edm::EventSetup &es) override
 
virtual bool filter (edm::Event &event, const edm::EventSetup &es) override
 
- 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)
 

Private Member Functions

double matching (const HepMC::GenEvent *event, bool shower) const
 
void onBeforeHadronisation ()
 
void onInit ()
 
bool showeredEvent (const boost::shared_ptr< HepMC::GenEvent > &event)
 

Private Attributes

BranchingRatios branchingRatios
 
unsigned int eventsToPrint
 
double extCrossSect
 
double extFilterEff
 
std::auto_ptr< Hadronisationhadronisation
 
unsigned int index
 
std::auto_ptr< JetMatchingjetMatching
 
bool matchingDone
 
bool matchSummary
 
boost::shared_ptr< LHEEventpartonLevel
 
std::vector< int > removeResonances
 
boost::shared_ptr< LHERunInforunInfo
 
double weight
 

Additional Inherited Members

- Public Types inherited from edm::one::EDFilterBase
typedef EDFilterBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::one::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Detailed Description

Definition at line 34 of file LHEProducer.cc.

Constructor & Destructor Documentation

LHEProducer::LHEProducer ( const edm::ParameterSet params)
explicit

Definition at line 72 of file LHEProducer.cc.

References branchingRatios, SurfaceDeformationFactory::create(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hadronisation, i, jetMatching, runGlobalFakeInputProducer::jetParams, matchSummary, onBeforeHadronisation(), onInit(), removeResonances, lhef::BranchingRatios::set(), and showeredEvent().

72  :
73  eventsToPrint(params.getUntrackedParameter<unsigned int>("eventsToPrint", 0)),
74  extCrossSect(params.getUntrackedParameter<double>("crossSection", -1.0)),
75  extFilterEff(params.getUntrackedParameter<double>("filterEfficiency", -1.0)),
76  matchSummary(false)
77 {
79  params.getParameter<edm::ParameterSet>("hadronisation"));
80 
81  if (params.exists("removeResonances"))
83  params.getParameter<std::vector<int> >(
84  "removeResonances");
85 
86  std::set<std::string> matchingCapabilities;
87  if (params.exists("jetMatching")) {
90  "jetMatching");
91  jetMatching = JetMatching::create(jetParams);
92 
93  matchingCapabilities = jetMatching->capabilities();
94  hadronisation->matchingCapabilities(matchingCapabilities);
95  }
96 
97  produces<edm::HepMCProduct>();
98  produces<GenEventInfoProduct>();
99  produces<GenRunInfoProduct, edm::InRun>();
100 
101  if (jetMatching.get()) {
102  if (params.getUntrackedParameter<bool>(
103  "preferShowerVetoCallback", true))
104  hadronisation->onShoweredEvent().connect(
105  sigc::mem_fun(*this,
107  hadronisation->onInit().connect(
108  sigc::mem_fun(*this, &LHEProducer::onInit));
109  hadronisation->onBeforeHadronisation().connect(
110  sigc::mem_fun(*this,
112 
113  matchSummary = matchingCapabilities.count("matchSummary");
114  if (matchSummary) {
115  produces< std::vector<double> >("matchDeltaR");
116  produces< std::vector<double> >("matchDeltaPRel");
117  }
118  }
119 
120  // force total branching ratio for QCD/QED to 1
121  for(int i = 0; i < 6; i++)
123  for(int i = 9; i < 23; i++)
125 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void set(int pdgId, bool both=true, double value=1.0)
double extFilterEff
Definition: LHEProducer.cc:61
double extCrossSect
Definition: LHEProducer.cc:60
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< int > removeResonances
Definition: LHEProducer.cc:56
BranchingRatios branchingRatios
Definition: LHEProducer.cc:69
void onBeforeHadronisation()
Definition: LHEProducer.cc:299
bool matchSummary
Definition: LHEProducer.cc:62
void onInit()
Definition: LHEProducer.cc:294
std::auto_ptr< JetMatching > jetMatching
Definition: LHEProducer.cc:58
unsigned int eventsToPrint
Definition: LHEProducer.cc:55
std::auto_ptr< Hadronisation > hadronisation
Definition: LHEProducer.cc:57
SurfaceDeformation * create(int type, const std::vector< double > &params)
bool showeredEvent(const boost::shared_ptr< HepMC::GenEvent > &event)
Definition: LHEProducer.cc:287
LHEProducer::~LHEProducer ( )
virtual

Definition at line 127 of file LHEProducer.cc.

128 {
129 }

Member Function Documentation

void LHEProducer::beginJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::one::EDFilterBase.

Definition at line 131 of file LHEProducer.cc.

References hadronisation.

132 {
133  hadronisation->init();
134 }
std::auto_ptr< Hadronisation > hadronisation
Definition: LHEProducer.cc:57
void LHEProducer::beginRun ( edm::Run const &  run,
const edm::EventSetup es 
)
overrideprotectedvirtual

Definition at line 142 of file LHEProducer.cc.

References edm::Run::getByLabel(), index, and runInfo.

143 {
145  run.getByLabel("source", product);
146 
147  runInfo.reset(new LHERunInfo(*product));
148  index = 0;
149 }
unsigned int index
Definition: LHEProducer.cc:66
boost::shared_ptr< LHERunInfo > runInfo
Definition: LHEProducer.cc:65
void LHEProducer::endJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::one::EDFilterBase.

Definition at line 136 of file LHEProducer.cc.

References hadronisation, and jetMatching.

137 {
138  hadronisation.reset();
139  jetMatching.reset();
140 }
std::auto_ptr< JetMatching > jetMatching
Definition: LHEProducer.cc:58
std::auto_ptr< Hadronisation > hadronisation
Definition: LHEProducer.cc:57
void LHEProducer::endRun ( edm::Run const &  run,
const edm::EventSetup es 
)
overrideprotectedvirtual

Definition at line 150 of file LHEProducer.cc.

151 {
152 }
void LHEProducer::endRunProduce ( edm::Run run,
const edm::EventSetup es 
)
overrideprotectedvirtual

Definition at line 154 of file LHEProducer.cc.

References lhef::LHERunInfo::XSec::error, extCrossSect, extFilterEff, hadronisation, edm::Run::put(), runInfo, and lhef::LHERunInfo::XSec::value.

155 {
156  hadronisation->statistics();
157 
158  LHERunInfo::XSec crossSection;
159  if (runInfo) {
160  crossSection = runInfo->xsec();
161  runInfo->statistics();
162  }
163 
164  std::auto_ptr<GenRunInfoProduct> runInfo(new GenRunInfoProduct);
165 
166  runInfo->setInternalXSec(
167  GenRunInfoProduct::XSec(crossSection.value,
168  crossSection.error));
169  runInfo->setExternalXSecLO(extCrossSect);
170  runInfo->setFilterEfficiency(extFilterEff);
171 
172  run.put(runInfo);
173 
174  runInfo.reset();
175 }
double extFilterEff
Definition: LHEProducer.cc:61
double extCrossSect
Definition: LHEProducer.cc:60
void put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Run.h:107
boost::shared_ptr< LHERunInfo > runInfo
Definition: LHEProducer.cc:65
std::auto_ptr< Hadronisation > hadronisation
Definition: LHEProducer.cc:57
bool LHEProducer::filter ( edm::Event event,
const edm::EventSetup es 
)
overrideprotectedvirtual

Implements edm::one::EDFilterBase.

Definition at line 177 of file LHEProducer.cc.

References beamvalidation::br, branchingRatios, eventsToPrint, lhef::BranchingRatios::getFactor(), hadronisation, index, info(), getDQMSummary::iter, jetMatching, matching(), matchingDone, matchSummary, partonLevel, removeResonances, query::result, runInfo, and weight.

178 {
179  edm::RandomEngineSentry<Hadronisation> randomEngineSentry(hadronisation.get(), event.streamID());
180 
181  std::auto_ptr<edm::HepMCProduct> result(new edm::HepMCProduct);
182 
184  event.getByLabel("source", product);
185 
186  partonLevel.reset(new LHEEvent(runInfo, *product));
187  if (!removeResonances.empty())
188  partonLevel->removeResonances(removeResonances);
189 
190  if (product->pdf())
191  partonLevel->setPDF(
192  std::auto_ptr<LHEEvent::PDF>(
193  new LHEEvent::PDF(*product->pdf())));
194 
195  hadronisation->setEvent(partonLevel);
196 
197  double br = branchingRatios.getFactor(hadronisation.get(),
198  partonLevel);
199 
200  matchingDone = false;
201  weight = 1.0;
202  std::auto_ptr<HepMC::GenEvent> hadronLevel(hadronisation->hadronize());
203 
204  if (!hadronLevel.get()) {
205  if (matchingDone) {
206  if (weight == 0.0)
207  partonLevel->count(LHERunInfo::kSelected, br);
208  else
209  partonLevel->count(LHERunInfo::kKilled,
210  br, weight);
211  } else
212  partonLevel->count(LHERunInfo::kTried, br);
213  }
214 
215  if (!matchingDone && jetMatching.get() && hadronLevel.get())
216  weight = matching(hadronLevel.get(), false);
217 
218  if (weight == 0.0) {
219  edm::LogInfo("Generator|LHEInterface")
220  << "Event got rejected by the "
221  "jet matching." << std::endl;
222 
223  if (hadronLevel.get()) {
224  partonLevel->count(LHERunInfo::kSelected);
225  hadronLevel.reset();
226  }
227  }
228 
229  if (!hadronLevel.get()) {
230  event.put(result);
231  std::auto_ptr<GenEventInfoProduct> info(
232  new GenEventInfoProduct);
233  event.put(info);
234  return false;
235  }
236 
237  partonLevel->count(LHERunInfo::kAccepted, br, weight);
238 
239  hadronLevel->set_event_number(++index);
240 
241  if (eventsToPrint) {
242  eventsToPrint--;
243  hadronLevel->print();
244  }
245 
246  std::auto_ptr<GenEventInfoProduct> info(
247  new GenEventInfoProduct(hadronLevel.get()));
248  result->addHepMCData(hadronLevel.release());
249  event.put(result);
250  event.put(info);
251 
252  if (jetMatching.get() && matchSummary) {
253  std::auto_ptr< std::vector<double> > matchDeltaR(
254  new std::vector<double>);
255  std::auto_ptr< std::vector<double> > matchDeltaPRel(
256  new std::vector<double>);
257 
258  typedef std::vector<JetMatching::JetPartonMatch> Matches;
259  Matches matches = jetMatching->getMatchSummary();
260 
261  for(Matches::const_iterator iter = matches.begin();
262  iter != matches.end(); ++iter) {
263  if (!iter->isMatch())
264  continue;
265 
266  matchDeltaR->push_back(iter->delta);
267  matchDeltaPRel->push_back(iter->jet.rho() /
268  iter->parton.rho() - 1.0);
269  }
270 
271  event.put(matchDeltaR, "matchDeltaR");
272  event.put(matchDeltaPRel, "matchDeltaPRel");
273  }
274 
275  return true;
276 }
static const TGPicture * info(bool iBackgroundIsBlack)
double getFactor(const Hadronisation *hadronisation, const boost::shared_ptr< LHEEvent > &event) const
std::vector< int > removeResonances
Definition: LHEProducer.cc:56
double weight
Definition: LHEProducer.cc:68
BranchingRatios branchingRatios
Definition: LHEProducer.cc:69
tuple result
Definition: query.py:137
double matching(const HepMC::GenEvent *event, bool shower) const
Definition: LHEProducer.cc:278
bool matchingDone
Definition: LHEProducer.cc:67
boost::shared_ptr< LHEEvent > partonLevel
Definition: LHEProducer.cc:64
bool matchSummary
Definition: LHEProducer.cc:62
std::auto_ptr< JetMatching > jetMatching
Definition: LHEProducer.cc:58
unsigned int index
Definition: LHEProducer.cc:66
boost::shared_ptr< LHERunInfo > runInfo
Definition: LHEProducer.cc:65
unsigned int eventsToPrint
Definition: LHEProducer.cc:55
std::auto_ptr< Hadronisation > hadronisation
Definition: LHEProducer.cc:57
double LHEProducer::matching ( const HepMC::GenEvent *  event,
bool  shower 
) const
private

Definition at line 278 of file LHEProducer.cc.

References event(), jetMatching, and partonLevel.

Referenced by filter(), and showeredEvent().

279 {
280  if (!jetMatching.get())
281  return 1.0;
282 
283  return jetMatching->match(partonLevel->asHepMCEvent().get(),
284  event, shower);
285 }
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
boost::shared_ptr< LHEEvent > partonLevel
Definition: LHEProducer.cc:64
std::auto_ptr< JetMatching > jetMatching
Definition: LHEProducer.cc:58
void LHEProducer::onBeforeHadronisation ( )
private

Definition at line 299 of file LHEProducer.cc.

References jetMatching, and partonLevel.

Referenced by LHEProducer().

300 {
301  jetMatching->beforeHadronisation(partonLevel);
302 }
boost::shared_ptr< LHEEvent > partonLevel
Definition: LHEProducer.cc:64
std::auto_ptr< JetMatching > jetMatching
Definition: LHEProducer.cc:58
void LHEProducer::onInit ( )
private

Definition at line 294 of file LHEProducer.cc.

References jetMatching, and runInfo.

Referenced by LHEProducer().

295 {
296  jetMatching->init(runInfo);
297 }
std::auto_ptr< JetMatching > jetMatching
Definition: LHEProducer.cc:58
boost::shared_ptr< LHERunInfo > runInfo
Definition: LHEProducer.cc:65
bool LHEProducer::showeredEvent ( const boost::shared_ptr< HepMC::GenEvent > &  event)
private

Definition at line 287 of file LHEProducer.cc.

References matching(), matchingDone, and weight.

Referenced by LHEProducer().

288 {
289  weight = matching(event.get(), true);
290  matchingDone = true;
291  return weight == 0.0;
292 }
double weight
Definition: LHEProducer.cc:68
double matching(const HepMC::GenEvent *event, bool shower) const
Definition: LHEProducer.cc:278
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
bool matchingDone
Definition: LHEProducer.cc:67

Member Data Documentation

BranchingRatios LHEProducer::branchingRatios
private

Definition at line 69 of file LHEProducer.cc.

Referenced by filter(), and LHEProducer().

unsigned int LHEProducer::eventsToPrint
private

Definition at line 55 of file LHEProducer.cc.

Referenced by filter().

double LHEProducer::extCrossSect
private

Definition at line 60 of file LHEProducer.cc.

Referenced by endRunProduce().

double LHEProducer::extFilterEff
private

Definition at line 61 of file LHEProducer.cc.

Referenced by endRunProduce().

std::auto_ptr<Hadronisation> LHEProducer::hadronisation
private

Definition at line 57 of file LHEProducer.cc.

Referenced by beginJob(), endJob(), endRunProduce(), filter(), and LHEProducer().

unsigned int LHEProducer::index
private

Definition at line 66 of file LHEProducer.cc.

Referenced by BeautifulSoup.PageElement::_invert(), beginRun(), and filter().

std::auto_ptr<JetMatching> LHEProducer::jetMatching
private

Definition at line 58 of file LHEProducer.cc.

Referenced by endJob(), filter(), LHEProducer(), matching(), onBeforeHadronisation(), and onInit().

bool LHEProducer::matchingDone
private

Definition at line 67 of file LHEProducer.cc.

Referenced by filter(), and showeredEvent().

bool LHEProducer::matchSummary
private

Definition at line 62 of file LHEProducer.cc.

Referenced by filter(), and LHEProducer().

boost::shared_ptr<LHEEvent> LHEProducer::partonLevel
private

Definition at line 64 of file LHEProducer.cc.

Referenced by filter(), matching(), and onBeforeHadronisation().

std::vector<int> LHEProducer::removeResonances
private

Definition at line 56 of file LHEProducer.cc.

Referenced by filter(), and LHEProducer().

boost::shared_ptr<LHERunInfo> LHEProducer::runInfo
private

Definition at line 65 of file LHEProducer.cc.

Referenced by beginRun(), endRunProduce(), filter(), and onInit().

double LHEProducer::weight
private