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 | Static Protected Member Functions | Protected Attributes | Private Attributes
ThePEGInterface Class Reference

#include <ThePEGInterface.h>

Inheritance diagram for ThePEGInterface:
lhef::ThePEGHadronisation ThePEGHadronizer

Public Member Functions

void setPEGRandomEngine (CLHEP::HepRandomEngine *)
 
 ThePEGInterface (const edm::ParameterSet &params)
 
virtual ~ThePEGInterface ()
 

Protected Member Functions

std::string dataFile (const std::string &fileName) const
 
std::string dataFile (const edm::ParameterSet &pset, const std::string &paramName) const
 
void flushRandomNumberGenerator ()
 
void initGenerator ()
 
void initRepository (const edm::ParameterSet &params) const
 

Static Protected Member Functions

static void clearAuxiliary (HepMC::GenEvent *hepmc, HepMC::PdfInfo *pdf)
 
static std::auto_ptr
< HepMC::GenEvent > 
convert (const ThePEG::EventPtr &event)
 
static void fillAuxiliary (HepMC::GenEvent *hepmc, HepMC::PdfInfo *pdf, const ThePEG::EventPtr &event)
 
static double pthat (const ThePEG::EventPtr &event)
 

Protected Attributes

ThePEG::EGPtr eg_
 
std::auto_ptr
< HepMC::IO_BaseClass > 
iobc_
 

Private Attributes

const std::string dataLocation_
 
const std::string dumpConfig_
 
const std::string generator_
 
boost::shared_ptr
< ThePEG::RandomEngineGlue::Proxy
randomEngineGlueProxy_
 
const std::string run_
 
const unsigned int skipEvents_
 

Detailed Description

Oliver Oberst obers.nosp@m.t@ek.nosp@m.p.uni.nosp@m.-kar.nosp@m.lsruh.nosp@m.e.de Fred-Markus Stober stobe.nosp@m.r@ek.nosp@m.p.uni.nosp@m.-kar.nosp@m.lsruh.nosp@m.e.de

Definition at line 30 of file ThePEGInterface.h.

Constructor & Destructor Documentation

ThePEGInterface::ThePEGInterface ( const edm::ParameterSet params)

Definition at line 46 of file ThePEGInterface.cc.

References dumpConfig_, edm::ParameterSet::getUntrackedParameter(), iobc_, dbtoconf::out, and estimatePileup_makeJSON::trunc.

46  :
48  dataLocation_(ParameterCollector::resolve(pset.getParameter<string>("dataLocation"))),
49  generator_(pset.getParameter<string>("generatorModule")),
50  run_(pset.getParameter<string>("run")),
51  dumpConfig_(pset.getUntrackedParameter<string>("dumpConfig", "")),
52  skipEvents_(pset.getUntrackedParameter<unsigned int>("skipEvents", 0))
53 {
54  // Write events in hepmc ascii format for debugging purposes
55  string dumpEvents = pset.getUntrackedParameter<string>("dumpEvents", "");
56  if (!dumpEvents.empty()) {
57  iobc_.reset(new HepMC::IO_GenEvent(dumpEvents.c_str(), ios::out));
58  edm::LogInfo("ThePEGSource") << "Event logging switched on (=> " << dumpEvents << ")";
59  }
60  // Clear dumpConfig target
61  if (!dumpConfig_.empty())
62  ofstream cfgDump(dumpConfig_.c_str(), ios_base::trunc);
63 }
static boost::shared_ptr< Proxy > create()
Definition: Proxy.h:44
const std::string run_
std::auto_ptr< HepMC::IO_BaseClass > iobc_
const std::string dumpConfig_
tuple out
Definition: dbtoconf.py:99
const std::string generator_
const unsigned int skipEvents_
const std::string dataLocation_
boost::shared_ptr< ThePEG::RandomEngineGlue::Proxy > randomEngineGlueProxy_
ThePEGInterface::~ThePEGInterface ( )
virtual

Definition at line 65 of file ThePEGInterface.cc.

References eg_.

66 {
67  if (eg_)
68  eg_->finalize();
69  edm::LogInfo("ThePEGInterface") << "Event generator finalized";
70 }
ThePEG::EGPtr eg_

Member Function Documentation

void ThePEGInterface::clearAuxiliary ( HepMC::GenEvent *  hepmc,
HepMC::PdfInfo *  pdf 
)
staticprotected

Definition at line 222 of file ThePEGInterface.cc.

Referenced by lhef::ThePEGHadronisation::doHadronisation(), and ThePEGHadronizer::finalizeEvent().

224 {
225  if (hepmc) {
226  hepmc->set_event_scale(-1.0);
227  hepmc->set_alphaQCD(-1.0);
228  hepmc->set_alphaQED(-1.0);
229  }
230  if (pdf) {
231  pdf->set_id1(-100);
232  pdf->set_id2(-100);
233  pdf->set_x1(-1.0);
234  pdf->set_x2(-1.0);
235  pdf->set_scalePDF(-1.0);
236  pdf->set_pdf1(-1.0);
237  pdf->set_pdf2(-1.0);
238  }
239 }
auto_ptr< HepMC::GenEvent > ThePEGInterface::convert ( const ThePEG::EventPtr &  event)
staticprotected

Definition at line 215 of file ThePEGInterface.cc.

References ThePEG::HepMCConverter< HepMCEventT, Traits >::convert().

Referenced by lhef::ThePEGHadronisation::doHadronisation(), and ThePEGHadronizer::generatePartonsAndHadronize().

217 {
218  return std::auto_ptr<HepMC::GenEvent>(
220 }
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
static GenEvent * convert(const Event &ev, bool nocopies=false, Energy eunit=Traits::defaultEnergyUnit(), Length lunit=Traits::defaultLengthUnit())
std::string ThePEGInterface::dataFile ( const std::string &  fileName) const
protected

Referenced by initRepository().

std::string ThePEGInterface::dataFile ( const edm::ParameterSet pset,
const std::string &  paramName 
) const
protected
void ThePEGInterface::fillAuxiliary ( HepMC::GenEvent *  hepmc,
HepMC::PdfInfo *  pdf,
const ThePEG::EventPtr &  event 
)
staticprotected

Definition at line 241 of file ThePEGInterface.cc.

References pileupReCalc_HLTpaths::scale, funct::sqr(), mathSSE::sqrt(), and findQualityFiles::v.

Referenced by lhef::ThePEGHadronisation::doHadronisation(), and ThePEGHadronizer::finalizeEvent().

244 {
245  if (!event->primaryCollision())
246  return;
247 
248  ThePEG::tcEHPtr eh = ThePEG::dynamic_ptr_cast<ThePEG::tcEHPtr>(
249  event->primaryCollision()->handler());
250  double scale = eh->lastScale();
251 
252  if (hepmc) {
253  if (hepmc->event_scale() < 0 && scale > 0)
254  hepmc->set_event_scale(std::sqrt(scale) / ThePEG::GeV);
255 
256  if (hepmc->alphaQCD() < 0)
257  hepmc->set_alphaQCD(eh->lastAlphaS());
258  if (hepmc->alphaQED() < 0)
259  hepmc->set_alphaQED(eh->lastAlphaEM());
260  }
261 
262  if (pdf) {
263  const ThePEG::PPair &beams = eh->lastParticles();
264  const ThePEG::PPair &partons = eh->lastPartons();
265  ThePEG::tcPDFPtr pdf1 = eh->lastExtractor()->getPDF(
266  beams.first->dataPtr());
267  ThePEG::tcPDFPtr pdf2 = eh->lastExtractor()->getPDF(
268  beams.second->dataPtr());
269  double x1, x2;
270 
271  if (pdf->id1() == -100) {
272  int id = partons.first->id();
273  pdf->set_id1(id == 21 ? 0 : id);
274  }
275  if (pdf->id2() == -100) {
276  int id = partons.second->id();
277  pdf->set_id2(id == 21 ? 0 : id);
278  }
279 
280  if (pdf->scalePDF() < 0)
281  pdf->set_scalePDF(std::sqrt(scale) / ThePEG::GeV);
282  else
283  scale = ThePEG::sqr(pdf->scalePDF()) * ThePEG::GeV;
284 
285  if (pdf->x1() < 0) {
286  x1 = eh->lastX1();
287  pdf->set_x1(x1);
288  } else
289  x1 = pdf->x1();
290 
291  if (pdf->x2() < 0) {
292  x2 = eh->lastX2();
293  pdf->set_x2(x2);
294  } else
295  x2 = pdf->x2();
296 
297  if (pdf1 && pdf->pdf1() < 0) {
298  double v = pdf1->xfx(beams.first->dataPtr(),
299  partons.first->dataPtr(),
300  scale, x1);
301  if (v > 0 && x1 > 0)
302  pdf->set_pdf1(v / x1);
303  else
304  pdf->set_pdf2(-1.0);
305  }
306  if (pdf2 && pdf->pdf2() < 0) {
307  double v = pdf2->xfx(beams.first->dataPtr(),
308  partons.first->dataPtr(),
309  scale, x2);
310  if (v > 0 && x2 > 0)
311  pdf->set_pdf2(v / x2);
312  else
313  pdf->set_pdf2(-1.0);
314  }
315  }
316 
317 }
T sqrt(T t)
Definition: SSEVec.h:48
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
Square< F >::type sqr(const F &f)
Definition: Square.h:13
void ThePEGInterface::flushRandomNumberGenerator ( )
protected

Definition at line 204 of file ThePEGInterface.cc.

References ThePEG::RandomEngineGlue::flush(), and randomEngineGlueProxy_.

Referenced by lhef::ThePEGHadronisation::doHadronisation(), ThePEGHadronizer::generatePartonsAndHadronize(), and initGenerator().

205 {
206  ThePEG::RandomEngineGlue *rnd = randomEngineGlueProxy_->getInstance();
207 
208  if (!rnd)
209  edm::LogWarning("ProxyMissing")
210  << "ThePEG not initialised with RandomEngineGlue.";
211  else
212  rnd->flush();
213 }
boost::shared_ptr< ThePEG::RandomEngineGlue::Proxy > randomEngineGlueProxy_
void ThePEGInterface::initGenerator ( )
protected

Definition at line 183 of file ThePEGInterface.cc.

References eg_, edm::hlt::Exception, flushRandomNumberGenerator(), generator_, i, run_, skipEvents_, and tmp.

Referenced by ThePEGHadronizer::initializeForInternalPartons(), and lhef::ThePEGHadronisation::newRunInfo().

184 {
185  // Get generator from the repository and initialize it
186  ThePEG::BaseRepository::CheckObjectDirectory(generator_);
187  ThePEG::EGPtr tmp = ThePEG::BaseRepository::GetObject<ThePEG::EGPtr>(generator_);
188  if (tmp) {
189  eg_ = ThePEG::Repository::makeRun(tmp, run_);
190  eg_->initialize();
191  edm::LogInfo("ThePEGInterface") << "EventGenerator initialized";
192  } else
193  throw cms::Exception("ThePEGInterface")
194  << "EventGenerator could not be initialized!" << endl;
195 
196  // Skip events
197  for (unsigned int i = 0; i < skipEvents_; i++) {
199  eg_->shoot();
200  edm::LogInfo("ThePEGInterface") << "Event discarded";
201  }
202 }
int i
Definition: DBlmapReader.cc:9
const std::string run_
void flushRandomNumberGenerator()
ThePEG::EGPtr eg_
const std::string generator_
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
const unsigned int skipEvents_
void ThePEGInterface::initRepository ( const edm::ParameterSet params) const
protected

Definition at line 98 of file ThePEGInterface.cc.

References gen::ParameterCollector::begin(), dtNoiseDBValidation_cfg::cerr, dataFile(), dumpConfig_, gen::ParameterCollector::end(), generator_, edm::ParameterSet::getParameter(), svgfig::load(), dbtoconf::out, randomEngineGlueProxy_, SiPixelLorentzAngle_cfi::read, and run_.

Referenced by lhef::ThePEGHadronisation::ThePEGHadronisation(), and ThePEGHadronizer::ThePEGHadronizer().

99 {
100  /* Initialize the repository from
101  * 1. the repository file (default values)
102  * 2. the ThePEG config files
103  * 3. the CMSSW config blocks
104  */
105  stringstream logstream;
106 
107  // Read the repository of serialized default values
108  string repository = dataFile(pset, "repository");
109  if (!repository.empty()) {
110  edm::LogInfo("ThePEGInterface") << "Loading repository (" << repository << ")";
111  ThePEG::Repository::load(repository);
112  }
113 
114  if (!getenv("ThePEG_INSTALL_PATH")) {
115  vector<string> libdirlist = ThePEG::DynamicLoader::allPaths();
116  for(vector<string>::const_iterator libdir = libdirlist.begin();
117  libdir < libdirlist.end(); ++libdir) {
118  if (libdir->empty() || (*libdir)[0] != '/')
119  continue;
120  if (boost::filesystem::exists(*libdir +
121  "/../../share/ThePEG/PDFsets.index")) {
122  setenv("ThePEG_INSTALL_PATH",
123  libdir->c_str(), 0);
124  break;
125  }
126  }
127  }
128 
129  // Read ThePEG config files to read
130  vector<string> configFiles = pset.getParameter<vector<string> >("configFiles");
131 
132  // Loop over the config files
133  for(vector<string>::const_iterator iter = configFiles.begin();
134  iter != configFiles.end(); ++iter) {
135  edm::LogInfo("ThePEGInterface") << "Reading config file (" << *iter << ")";
136  ThePEG::Repository::read(dataFile(*iter), logstream);
137  edm::LogInfo("ThePEGSource") << logstream.str();
138  }
139 
140  // Read CMSSW config file parameter sets starting from "parameterSets"
141 
142  ofstream cfgDump;
143  ParameterCollector collector(pset);
145  if (!dumpConfig_.empty()) {
146  cfgDump.open(dumpConfig_.c_str(), ios_base::app);
147  iter = collector.begin(cfgDump);
148  } else
149  iter = collector.begin();
150 
151  for(; iter != collector.end(); ++iter) {
152  string out = ThePEG::Repository::exec(*iter, logstream);
153  if (!out.empty()) {
154  edm::LogInfo("ThePEGInterface") << *iter << " => " << out;
155  cerr << "Error in ThePEG configuration!\n"
156  "\tLine: " << *iter << "\n" << out << endl;
157  }
158  }
159 
160  if (!dumpConfig_.empty()) {
161  cfgDump << "saverun " << run_ << " " << generator_ << endl;
162  cfgDump.close();
163  }
164 
165  // write the ProxyID for the RandomEngineGlue to fill its pointer in
166  ostringstream ss;
167  ss << randomEngineGlueProxy_->getID();
168  ThePEG::Repository::exec("set " + generator_ +
169  ":RandomNumberGenerator:ProxyID " + ss.str(),
170  logstream);
171 
172  // Print the directories where ThePEG looks for libs
173  vector<string> libdirlist = ThePEG::DynamicLoader::allPaths();
174  for(vector<string>::const_iterator libdir = libdirlist.begin();
175  libdir < libdirlist.end(); ++libdir)
176  edm::LogInfo("ThePEGInterface") << "DynamicLoader path = " << *libdir << endl;
177 
178  // Output status information about the repository
179  ThePEG::Repository::stats(logstream);
180  edm::LogInfo("ThePEGInterface") << logstream.str();
181 }
std::string dataFile(const std::string &fileName) const
const std::string run_
def load
Definition: svgfig.py:546
const std::string dumpConfig_
tuple out
Definition: dbtoconf.py:99
const std::string generator_
boost::shared_ptr< ThePEG::RandomEngineGlue::Proxy > randomEngineGlueProxy_
double ThePEGInterface::pthat ( const ThePEG::EventPtr &  event)
staticprotected

Definition at line 319 of file ThePEGInterface.cc.

References bookConverter::min, and tmp.

Referenced by ThePEGHadronizer::finalizeEvent().

320 {
321  using namespace ThePEG;
322 
323  if (!event->primaryCollision())
324  return -1.0;
325 
326  tSubProPtr sub = event->primaryCollision()->primarySubProcess();
327  TmpTransform<tSubProPtr> tmp(sub, Utilities::getBoostToCM(
328  sub->incoming()));
329 
330  double pthat = (*sub->outgoing().begin())->momentum().perp();
331  for(PVector::const_iterator it = sub->outgoing().begin();
332  it != sub->outgoing().end(); ++it)
333  pthat = std::min(pthat, (*it)->momentum().perp());
334 
335  return pthat / ThePEG::GeV;
336 }
static double pthat(const ThePEG::EventPtr &event)
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
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void ThePEGInterface::setPEGRandomEngine ( CLHEP::HepRandomEngine *  v)

Definition at line 72 of file ThePEGInterface.cc.

References randomEngineGlueProxy_, and ThePEG::RandomEngineGlue::setRandomEngine().

Referenced by ThePEGHadronizer::doSetRandomEngine().

72  {
73  randomEngineGlueProxy_->setRandomEngine(v);
75  if(rnd) {
76  rnd->setRandomEngine(v);
77  }
78 }
void setRandomEngine(CLHEP::HepRandomEngine *v)
boost::shared_ptr< ThePEG::RandomEngineGlue::Proxy > randomEngineGlueProxy_

Member Data Documentation

const std::string ThePEGInterface::dataLocation_
private

Definition at line 63 of file ThePEGInterface.h.

const std::string ThePEGInterface::dumpConfig_
private

Definition at line 66 of file ThePEGInterface.h.

Referenced by initRepository(), and ThePEGInterface().

ThePEG::EGPtr ThePEGInterface::eg_
protected
const std::string ThePEGInterface::generator_
private

Definition at line 64 of file ThePEGInterface.h.

Referenced by initGenerator(), and initRepository().

std::auto_ptr<HepMC::IO_BaseClass> ThePEGInterface::iobc_
protected

Definition at line 57 of file ThePEGInterface.h.

Referenced by ThePEGHadronizer::finalizeEvent(), and ThePEGInterface().

boost::shared_ptr<ThePEG::RandomEngineGlue::Proxy> ThePEGInterface::randomEngineGlueProxy_
private
const std::string ThePEGInterface::run_
private

Definition at line 65 of file ThePEGInterface.h.

Referenced by initGenerator(), and initRepository().

const unsigned int ThePEGInterface::skipEvents_
private

Definition at line 67 of file ThePEGInterface.h.

Referenced by initGenerator().