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::EDFilter edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 LHEProducer (const edm::ParameterSet &params)
 
virtual ~LHEProducer ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Protected Member Functions

virtual void beginJob ()
 
virtual bool beginRun (edm::Run &run, const edm::EventSetup &es)
 
virtual void endJob ()
 
virtual bool endRun (edm::Run &run, const edm::EventSetup &es)
 
virtual bool filter (edm::Event &event, const edm::EventSetup &es)
 
- Protected Member Functions inherited from edm::EDFilter
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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::EDFilter
typedef EDFilter ModuleType
 
typedef WorkerT< EDFilterWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (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 69 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().

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

Definition at line 124 of file LHEProducer.cc.

125 {
126 }

Member Function Documentation

void LHEProducer::beginJob ( void  )
protectedvirtual

Reimplemented from edm::EDFilter.

Definition at line 128 of file LHEProducer.cc.

References hadronisation.

129 {
130  hadronisation->init();
131 }
std::auto_ptr< Hadronisation > hadronisation
Definition: LHEProducer.cc:54
bool LHEProducer::beginRun ( edm::Run run,
const edm::EventSetup es 
)
protectedvirtual

Reimplemented from edm::EDFilter.

Definition at line 139 of file LHEProducer.cc.

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

140 {
142  run.getByLabel("source", product);
143 
144  runInfo.reset(new LHERunInfo(*product));
145  index = 0;
146 
147  return true;
148 }
bool getByLabel(std::string const &label, Handle< PROD > &result) const
Definition: Run.h:175
unsigned int index
Definition: LHEProducer.cc:63
boost::shared_ptr< LHERunInfo > runInfo
Definition: LHEProducer.cc:62
void LHEProducer::endJob ( void  )
protectedvirtual

Reimplemented from edm::EDFilter.

Definition at line 133 of file LHEProducer.cc.

References hadronisation, and jetMatching.

134 {
135  hadronisation.reset();
136  jetMatching.reset();
137 }
std::auto_ptr< JetMatching > jetMatching
Definition: LHEProducer.cc:55
std::auto_ptr< Hadronisation > hadronisation
Definition: LHEProducer.cc:54
bool LHEProducer::endRun ( edm::Run run,
const edm::EventSetup es 
)
protectedvirtual

Reimplemented from edm::EDFilter.

Definition at line 150 of file LHEProducer.cc.

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

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

Implements edm::EDFilter.

Definition at line 175 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.

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

Definition at line 274 of file LHEProducer.cc.

References event(), jetMatching, and partonLevel.

Referenced by filter(), and showeredEvent().

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

Definition at line 295 of file LHEProducer.cc.

References jetMatching, and partonLevel.

Referenced by LHEProducer().

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

Definition at line 290 of file LHEProducer.cc.

References jetMatching, and runInfo.

Referenced by LHEProducer().

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

Definition at line 283 of file LHEProducer.cc.

References matching(), matchingDone, and weight.

Referenced by LHEProducer().

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

Member Data Documentation

BranchingRatios LHEProducer::branchingRatios
private

Definition at line 66 of file LHEProducer.cc.

Referenced by filter(), and LHEProducer().

unsigned int LHEProducer::eventsToPrint
private

Definition at line 52 of file LHEProducer.cc.

Referenced by filter().

double LHEProducer::extCrossSect
private

Definition at line 57 of file LHEProducer.cc.

Referenced by endRun().

double LHEProducer::extFilterEff
private

Definition at line 58 of file LHEProducer.cc.

Referenced by endRun().

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

Definition at line 54 of file LHEProducer.cc.

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

unsigned int LHEProducer::index
private

Definition at line 63 of file LHEProducer.cc.

Referenced by beginRun(), and filter().

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

Definition at line 55 of file LHEProducer.cc.

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

bool LHEProducer::matchingDone
private

Definition at line 64 of file LHEProducer.cc.

Referenced by filter(), and showeredEvent().

bool LHEProducer::matchSummary
private

Definition at line 59 of file LHEProducer.cc.

Referenced by filter(), and LHEProducer().

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

Definition at line 61 of file LHEProducer.cc.

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

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

Definition at line 53 of file LHEProducer.cc.

Referenced by filter(), and LHEProducer().

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

Definition at line 62 of file LHEProducer.cc.

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

double LHEProducer::weight
private

Definition at line 65 of file LHEProducer.cc.

Referenced by filter(), and showeredEvent().