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:
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 31 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 223 of file ThePEGInterface.cc.

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

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

Definition at line 216 of file ThePEGInterface.cc.

References fileCollector::convert().

Referenced by ThePEGHadronizer::generatePartonsAndHadronize(), and ThePEGHadronizer::hadronize().

218 {
219  return std::auto_ptr<HepMC::GenEvent>(
221 }
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::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 242 of file ThePEGInterface.cc.

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

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

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

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

Referenced by ThePEGHadronizer::generatePartonsAndHadronize(), ThePEGHadronizer::hadronize(), and initGenerator().

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

Definition at line 184 of file ThePEGInterface.cc.

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

Referenced by ThePEGHadronizer::initializeForExternalPartons(), and ThePEGHadronizer::initializeForInternalPartons().

185 {
186  // Get generator from the repository and initialize it
187  ThePEG::BaseRepository::CheckObjectDirectory(generator_);
188  ThePEG::EGPtr tmp = ThePEG::BaseRepository::GetObject<ThePEG::EGPtr>(generator_);
189  if (tmp) {
190  eg_ = ThePEG::Repository::makeRun(tmp, run_);
191  eg_->initialize();
192  edm::LogInfo("ThePEGInterface") << "EventGenerator initialized";
193  } else
194  throw cms::Exception("ThePEGInterface")
195  << "EventGenerator could not be initialized!" << endl;
196 
197  // Skip events
198  for (unsigned int i = 0; i < skipEvents_; i++) {
200  eg_->shoot();
201  edm::LogInfo("ThePEGInterface") << "Event discarded";
202  }
203 }
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 99 of file ThePEGInterface.cc.

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

Referenced by ThePEGHadronizer::ThePEGHadronizer().

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

References GeV, min(), and tmp.

Referenced by ThePEGHadronizer::finalizeEvent().

321 {
322  using namespace ThePEG;
323 
324  if (!event->primaryCollision())
325  return -1.0;
326 
327  tSubProPtr sub = event->primaryCollision()->primarySubProcess();
328  TmpTransform<tSubProPtr> tmp(sub, Utilities::getBoostToCM(
329  sub->incoming()));
330 
331  double pthat = (*sub->outgoing().begin())->momentum().perp();
332  for(PVector::const_iterator it = sub->outgoing().begin();
333  it != sub->outgoing().end(); ++it)
334  pthat = std::min(pthat, (*it)->momentum().perp());
335 
336  return pthat / ThePEG::GeV;
337 }
const double GeV
Definition: MathUtil.h:16
static double pthat(const ThePEG::EventPtr &event)
T min(T a, T b)
Definition: MathUtil.h:58
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 73 of file ThePEGInterface.cc.

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

Referenced by ThePEGHadronizer::doSetRandomEngine().

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

Member Data Documentation

const std::string ThePEGInterface::dataLocation_
private

Definition at line 64 of file ThePEGInterface.h.

const std::string ThePEGInterface::dumpConfig_
private

Definition at line 67 of file ThePEGInterface.h.

Referenced by initRepository(), and ThePEGInterface().

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

Definition at line 65 of file ThePEGInterface.h.

Referenced by initGenerator(), and initRepository().

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

Definition at line 58 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 66 of file ThePEGInterface.h.

Referenced by initGenerator(), and initRepository().

const unsigned int ThePEGInterface::skipEvents_
private

Definition at line 68 of file ThePEGInterface.h.

Referenced by initGenerator().