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 ()
 
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 ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) 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::one::EDFilterBase
CurrentProcessingContext const * currentContext () const
 
- 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
 
typedef WorkerT< EDFilterBaseWorkerType
 
- 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 33 of file LHEProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 71 of file LHEProducer.cc.

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

71  :
72  eventsToPrint(params.getUntrackedParameter<unsigned int>("eventsToPrint", 0)),
73  extCrossSect(params.getUntrackedParameter<double>("crossSection", -1.0)),
74  extFilterEff(params.getUntrackedParameter<double>("filterEfficiency", -1.0)),
75  matchSummary(false)
76 {
78  params.getParameter<edm::ParameterSet>("hadronisation"));
79 
80  if (params.exists("removeResonances"))
82  params.getParameter<std::vector<int> >(
83  "removeResonances");
84 
85  std::set<std::string> matchingCapabilities;
86  if (params.exists("jetMatching")) {
87  edm::ParameterSet jetParams =
89  "jetMatching");
90  jetMatching = JetMatching::create(jetParams);
91 
92  matchingCapabilities = jetMatching->capabilities();
93  hadronisation->matchingCapabilities(matchingCapabilities);
94  }
95 
96  produces<edm::HepMCProduct>();
97  produces<GenEventInfoProduct>();
98  produces<GenRunInfoProduct, edm::InRun>();
99 
100  if (jetMatching.get()) {
101  if (params.getUntrackedParameter<bool>(
102  "preferShowerVetoCallback", true))
103  hadronisation->onShoweredEvent().connect(
104  sigc::mem_fun(*this,
106  hadronisation->onInit().connect(
107  sigc::mem_fun(*this, &LHEProducer::onInit));
108  hadronisation->onBeforeHadronisation().connect(
109  sigc::mem_fun(*this,
111 
112  matchSummary = matchingCapabilities.count("matchSummary");
113  if (matchSummary) {
114  produces< std::vector<double> >("matchDeltaR");
115  produces< std::vector<double> >("matchDeltaPRel");
116  }
117  }
118 
119  // force total branching ratio for QCD/QED to 1
120  for(int i = 0; i < 6; i++)
122  for(int i = 9; i < 23; i++)
124 }
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:60
double extCrossSect
Definition: LHEProducer.cc:59
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< int > removeResonances
Definition: LHEProducer.cc:55
BranchingRatios branchingRatios
Definition: LHEProducer.cc:68
void onBeforeHadronisation()
Definition: LHEProducer.cc:296
bool matchSummary
Definition: LHEProducer.cc:61
void onInit()
Definition: LHEProducer.cc:291
std::auto_ptr< JetMatching > jetMatching
Definition: LHEProducer.cc:57
unsigned int eventsToPrint
Definition: LHEProducer.cc:54
std::auto_ptr< Hadronisation > hadronisation
Definition: LHEProducer.cc:56
SurfaceDeformation * create(int type, const std::vector< double > &params)
bool showeredEvent(const boost::shared_ptr< HepMC::GenEvent > &event)
Definition: LHEProducer.cc:284
LHEProducer::~LHEProducer ( )
virtual

Definition at line 126 of file LHEProducer.cc.

127 {
128 }

Member Function Documentation

void LHEProducer::beginJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::one::EDFilterBase.

Definition at line 130 of file LHEProducer.cc.

References hadronisation.

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

Definition at line 141 of file LHEProducer.cc.

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

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

Reimplemented from edm::one::EDFilterBase.

Definition at line 135 of file LHEProducer.cc.

References hadronisation, and jetMatching.

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

Definition at line 149 of file LHEProducer.cc.

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

Definition at line 153 of file LHEProducer.cc.

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

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

Implements edm::one::EDFilterBase.

Definition at line 176 of file LHEProducer.cc.

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

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

Definition at line 275 of file LHEProducer.cc.

References event(), jetMatching, and partonLevel.

Referenced by filter(), and showeredEvent().

276 {
277  if (!jetMatching.get())
278  return 1.0;
279 
280  return jetMatching->match(partonLevel->asHepMCEvent().get(),
281  event, shower);
282 }
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:63
std::auto_ptr< JetMatching > jetMatching
Definition: LHEProducer.cc:57
void LHEProducer::onBeforeHadronisation ( )
private

Definition at line 296 of file LHEProducer.cc.

References jetMatching, and partonLevel.

Referenced by LHEProducer().

297 {
298  jetMatching->beforeHadronisation(partonLevel);
299 }
boost::shared_ptr< LHEEvent > partonLevel
Definition: LHEProducer.cc:63
std::auto_ptr< JetMatching > jetMatching
Definition: LHEProducer.cc:57
void LHEProducer::onInit ( )
private

Definition at line 291 of file LHEProducer.cc.

References jetMatching, and runInfo.

Referenced by LHEProducer().

292 {
293  jetMatching->init(runInfo);
294 }
std::auto_ptr< JetMatching > jetMatching
Definition: LHEProducer.cc:57
boost::shared_ptr< LHERunInfo > runInfo
Definition: LHEProducer.cc:64
bool LHEProducer::showeredEvent ( const boost::shared_ptr< HepMC::GenEvent > &  event)
private

Definition at line 284 of file LHEProducer.cc.

References matching(), matchingDone, and weight.

Referenced by LHEProducer().

285 {
286  weight = matching(event.get(), true);
287  matchingDone = true;
288  return weight == 0.0;
289 }
double weight
Definition: LHEProducer.cc:67
double matching(const HepMC::GenEvent *event, bool shower) const
Definition: LHEProducer.cc:275
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:66

Member Data Documentation

BranchingRatios LHEProducer::branchingRatios
private

Definition at line 68 of file LHEProducer.cc.

Referenced by filter(), and LHEProducer().

unsigned int LHEProducer::eventsToPrint
private

Definition at line 54 of file LHEProducer.cc.

Referenced by filter().

double LHEProducer::extCrossSect
private

Definition at line 59 of file LHEProducer.cc.

Referenced by endRunProduce().

double LHEProducer::extFilterEff
private

Definition at line 60 of file LHEProducer.cc.

Referenced by endRunProduce().

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

Definition at line 56 of file LHEProducer.cc.

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

unsigned int LHEProducer::index
private

Definition at line 65 of file LHEProducer.cc.

Referenced by beginRun(), and filter().

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

Definition at line 57 of file LHEProducer.cc.

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

bool LHEProducer::matchingDone
private

Definition at line 66 of file LHEProducer.cc.

Referenced by filter(), and showeredEvent().

bool LHEProducer::matchSummary
private

Definition at line 61 of file LHEProducer.cc.

Referenced by filter(), and LHEProducer().

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

Definition at line 63 of file LHEProducer.cc.

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

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

Definition at line 55 of file LHEProducer.cc.

Referenced by filter(), and LHEProducer().

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

Definition at line 64 of file LHEProducer.cc.

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

double LHEProducer::weight
private