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

 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

Id:
ThePEGInterface.h,v 1.11 2009/11/04 18:28:40 stober Exp

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

Id:
ThePEGInterface.cc,v 1.16 2009/05/19 17:38:54 stober Exp

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 27 of file ThePEGInterface.h.

Constructor & Destructor Documentation

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

Definition at line 47 of file ThePEGInterface.cc.

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

47  :
49  dataLocation_(ParameterCollector::resolve(pset.getParameter<string>("dataLocation"))),
50  generator_(pset.getParameter<string>("generatorModule")),
51  run_(pset.getParameter<string>("run")),
52  dumpConfig_(pset.getUntrackedParameter<string>("dumpConfig", "")),
53  skipEvents_(pset.getUntrackedParameter<unsigned int>("skipEvents", 0))
54 {
55  // Write events in hepmc ascii format for debugging purposes
56  string dumpEvents = pset.getUntrackedParameter<string>("dumpEvents", "");
57  if (!dumpEvents.empty()) {
58  iobc_.reset(new HepMC::IO_GenEvent(dumpEvents.c_str(), ios::out));
59  edm::LogInfo("ThePEGSource") << "Event logging switched on (=> " << dumpEvents << ")";
60  }
61  // Clear dumpConfig target
62  if (!dumpConfig_.empty())
63  ofstream cfgDump(dumpConfig_.c_str(), ios_base::trunc);
64 }
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 66 of file ThePEGInterface.cc.

References eg_.

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

Member Function Documentation

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

Definition at line 215 of file ThePEGInterface.cc.

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

217 {
218  if (hepmc) {
219  hepmc->set_event_scale(-1.0);
220  hepmc->set_alphaQCD(-1.0);
221  hepmc->set_alphaQED(-1.0);
222  }
223  if (pdf) {
224  pdf->set_id1(-100);
225  pdf->set_id2(-100);
226  pdf->set_x1(-1.0);
227  pdf->set_x2(-1.0);
228  pdf->set_scalePDF(-1.0);
229  pdf->set_pdf1(-1.0);
230  pdf->set_pdf2(-1.0);
231  }
232 }
auto_ptr< HepMC::GenEvent > ThePEGInterface::convert ( const ThePEG::EventPtr &  event)
staticprotected

Definition at line 208 of file ThePEGInterface.cc.

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

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

210 {
211  return std::auto_ptr<HepMC::GenEvent>(
213 }
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 234 of file ThePEGInterface.cc.

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

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

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

Definition at line 197 of file ThePEGInterface.cc.

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

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

198 {
199  ThePEG::RandomEngineGlue *rnd = randomEngineGlueProxy_->getInstance();
200 
201  if (!rnd)
202  edm::LogWarning("ProxyMissing")
203  << "ThePEG not initialised with RandomEngineGlue.";
204  else
205  rnd->flush();
206 }
boost::shared_ptr< ThePEG::RandomEngineGlue::Proxy > randomEngineGlueProxy_
void ThePEGInterface::initGenerator ( )
protected

Definition at line 176 of file ThePEGInterface.cc.

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

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

177 {
178  // Get generator from the repository and initialize it
179  ThePEG::BaseRepository::CheckObjectDirectory(generator_);
180  ThePEG::EGPtr tmp = ThePEG::BaseRepository::GetObject<ThePEG::EGPtr>(generator_);
181  if (tmp) {
182  eg_ = ThePEG::Repository::makeRun(tmp, run_);
183  eg_->initialize();
184  edm::LogInfo("ThePEGInterface") << "EventGenerator initialized";
185  } else
186  throw cms::Exception("ThePEGInterface")
187  << "EventGenerator could not be initialized!" << endl;
188 
189  // Skip events
190  for (unsigned int i = 0; i < skipEvents_; i++) {
192  eg_->shoot();
193  edm::LogInfo("ThePEGInterface") << "Event discarded";
194  }
195 }
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 91 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().

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

References min, and tmp.

Referenced by ThePEGHadronizer::finalizeEvent().

313 {
314  using namespace ThePEG;
315 
316  if (!event->primaryCollision())
317  return -1.0;
318 
319  tSubProPtr sub = event->primaryCollision()->primarySubProcess();
320  TmpTransform<tSubProPtr> tmp(sub, Utilities::getBoostToCM(
321  sub->incoming()));
322 
323  double pthat = (*sub->outgoing().begin())->momentum().perp();
324  for(PVector::const_iterator it = sub->outgoing().begin();
325  it != sub->outgoing().end(); ++it)
326  pthat = std::min(pthat, (*it)->momentum().perp());
327 
328  return pthat / ThePEG::GeV;
329 }
#define min(a, b)
Definition: mlp_lapack.h:161
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

Member Data Documentation

const std::string ThePEGInterface::dataLocation_
private

Definition at line 58 of file ThePEGInterface.h.

const std::string ThePEGInterface::dumpConfig_
private

Definition at line 61 of file ThePEGInterface.h.

Referenced by initRepository(), and ThePEGInterface().

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

Definition at line 59 of file ThePEGInterface.h.

Referenced by initGenerator(), and initRepository().

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

Definition at line 52 of file ThePEGInterface.h.

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

boost::shared_ptr<ThePEG::RandomEngineGlue::Proxy> ThePEGInterface::randomEngineGlueProxy_
private

Definition at line 56 of file ThePEGInterface.h.

Referenced by flushRandomNumberGenerator(), and initRepository().

const std::string ThePEGInterface::run_
private

Definition at line 60 of file ThePEGInterface.h.

Referenced by initGenerator(), and initRepository().

const unsigned int ThePEGInterface::skipEvents_
private

Definition at line 62 of file ThePEGInterface.h.

Referenced by initGenerator().