14 #include <boost/shared_ptr.hpp>
15 #include <boost/filesystem.hpp>
17 #include <HepMC/GenEvent.h>
18 #include <HepMC/PdfInfo.h>
19 #include <HepMC/IO_GenEvent.h>
21 #include <ThePEG/Utilities/DynamicLoader.h>
22 #include <ThePEG/Repository/Repository.h>
23 #include <ThePEG/Handlers/EventHandler.h>
24 #include <ThePEG/Handlers/XComb.h>
25 #include <ThePEG/EventRecord/Event.h>
26 #include <ThePEG/EventRecord/Particle.h>
27 #include <ThePEG/EventRecord/Collision.h>
28 #include <ThePEG/EventRecord/TmpTransform.h>
29 #include <ThePEG/Config/ThePEG.h>
30 #include <ThePEG/PDF/PartonExtractor.h>
31 #include <ThePEG/PDF/PDFBase.h>
32 #include <ThePEG/Utilities/UtilityBase.h>
47 randomEngineGlueProxy_(ThePEG::RandomEngineGlue::Proxy::
create()),
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))
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 <<
")";
69 edm::LogInfo(
"ThePEGInterface") <<
"Event generator finalized";
74 if (fileName.empty() || fileName[0] ==
'/')
81 const string ¶mName)
const
97 stringstream logstream;
100 string repository =
dataFile(pset,
"repository");
101 if (!repository.empty()) {
102 edm::LogInfo(
"ThePEGInterface") <<
"Loading repository (" << repository <<
")";
106 if (!getenv(
"ThePEG_INSTALL_PATH")) {
107 vector<string> libdirlist = ThePEG::DynamicLoader::allPaths();
108 for(vector<string>::const_iterator libdir = libdirlist.begin();
109 libdir < libdirlist.end(); ++libdir) {
110 if (libdir->empty() || (*libdir)[0] !=
'/')
112 if (boost::filesystem::exists(*libdir +
113 "/../../share/ThePEG/PDFsets.index")) {
114 setenv(
"ThePEG_INSTALL_PATH",
122 vector<string> configFiles = pset.
getParameter<vector<string> >(
"configFiles");
125 for(vector<string>::const_iterator iter = configFiles.begin();
126 iter != configFiles.end(); ++iter) {
127 edm::LogInfo(
"ThePEGInterface") <<
"Reading config file (" << *iter <<
")";
139 iter = collector.
begin(cfgDump);
141 iter = collector.
begin();
143 for(; iter != collector.
end(); ++iter) {
144 string out = ThePEG::Repository::exec(*iter, logstream);
147 cerr <<
"Error in ThePEG configuration!\n"
148 "\tLine: " << *iter <<
"\n" << out << endl;
160 ThePEG::Repository::exec(
"set " +
generator_ +
161 ":RandomNumberGenerator:ProxyID " + ss.str(),
165 vector<string> libdirlist = ThePEG::DynamicLoader::allPaths();
166 for(vector<string>::const_iterator libdir = libdirlist.begin();
167 libdir < libdirlist.end(); ++libdir)
168 edm::LogInfo(
"ThePEGInterface") <<
"DynamicLoader path = " << *libdir << endl;
171 ThePEG::Repository::stats(logstream);
178 ThePEG::BaseRepository::CheckObjectDirectory(
generator_);
179 ThePEG::EGPtr
tmp = ThePEG::BaseRepository::GetObject<ThePEG::EGPtr>(
generator_);
181 eg_ = ThePEG::Repository::makeRun(tmp,
run_);
183 edm::LogInfo(
"ThePEGInterface") <<
"EventGenerator initialized";
186 <<
"EventGenerator could not be initialized!" << endl;
202 <<
"ThePEG not initialised with RandomEngineGlue.";
208 const ThePEG::EventPtr &
event)
210 return std::auto_ptr<HepMC::GenEvent>(
218 hepmc->set_event_scale(-1.0);
219 hepmc->set_alphaQCD(-1.0);
220 hepmc->set_alphaQED(-1.0);
227 pdf->set_scalePDF(-1.0);
235 const ThePEG::EventPtr &
event)
237 if (!event->primaryCollision())
240 ThePEG::tcEHPtr eh = ThePEG::dynamic_ptr_cast<ThePEG::tcEHPtr>(
241 event->primaryCollision()->handler());
242 double scale = eh->lastScale();
245 if (hepmc->event_scale() < 0 && scale > 0)
246 hepmc->set_event_scale(
std::sqrt(scale) / ThePEG::GeV);
248 if (hepmc->alphaQCD() < 0)
249 hepmc->set_alphaQCD(eh->lastAlphaS());
250 if (hepmc->alphaQED() < 0)
251 hepmc->set_alphaQED(eh->lastAlphaEM());
255 const ThePEG::PPair &beams = eh->lastParticles();
256 const ThePEG::PPair &partons = eh->lastPartons();
257 ThePEG::tcPDFPtr pdf1 = eh->lastExtractor()->getPDF(
258 beams.first->dataPtr());
259 ThePEG::tcPDFPtr pdf2 = eh->lastExtractor()->getPDF(
260 beams.second->dataPtr());
263 if (pdf->id1() == -100) {
264 int id = partons.first->id();
265 pdf->set_id1(
id == 21 ? 0 :
id);
267 if (pdf->id2() == -100) {
268 int id = partons.second->id();
269 pdf->set_id2(
id == 21 ? 0 :
id);
272 if (pdf->scalePDF() < 0)
273 pdf->set_scalePDF(
std::sqrt(scale) / ThePEG::GeV);
275 scale =
ThePEG::sqr(pdf->scalePDF()) * ThePEG::GeV;
289 if (pdf1 && pdf->pdf1() < 0) {
290 double v = pdf1->xfx(beams.first->dataPtr(),
291 partons.first->dataPtr(),
294 pdf->set_pdf1(v / x1);
298 if (pdf2 && pdf->pdf2() < 0) {
299 double v = pdf2->xfx(beams.first->dataPtr(),
300 partons.first->dataPtr(),
303 pdf->set_pdf2(v / x2);
313 using namespace ThePEG;
315 if (!event->primaryCollision())
318 tSubProPtr sub =
event->primaryCollision()->primarySubProcess();
319 TmpTransform<tSubProPtr>
tmp(sub, Utilities::getBoostToCM(
322 double pthat = (*sub->outgoing().begin())->momentum().perp();
323 for(PVector::const_iterator it = sub->outgoing().begin();
324 it != sub->outgoing().end(); ++it)
327 return pthat / ThePEG::GeV;
T getParameter(std::string const &) const
Entry const & retrieve(char const *) const
T getUntrackedParameter(std::string const &, T const &) const
void initRepository(const edm::ParameterSet ¶ms) const
ThePEGInterface(const edm::ParameterSet ¶ms)
static double pthat(const ThePEG::EventPtr &event)
std::string dataFile(const std::string &fileName) const
void flushRandomNumberGenerator()
std::auto_ptr< HepMC::IO_BaseClass > iobc_
const std::string dumpConfig_
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 std::auto_ptr< HepMC::GenEvent > convert(const ThePEG::EventPtr &event)
static GenEvent * convert(const Event &ev, bool nocopies=false, Energy eunit=Traits::defaultEnergyUnit(), Length lunit=Traits::defaultLengthUnit())
const std::string generator_
FileInPath getFileInPath() const
virtual ~ThePEGInterface()
std::vector< std::vector< double > > tmp
const unsigned int skipEvents_
const std::string dataLocation_
Square< F >::type sqr(const F &f)
const_iterator end() const
const_iterator begin() const
std::string fullPath() const
boost::shared_ptr< ThePEG::RandomEngineGlue::Proxy > randomEngineGlueProxy_
static void clearAuxiliary(HepMC::GenEvent *hepmc, HepMC::PdfInfo *pdf)
std::string getString() const
static void fillAuxiliary(HepMC::GenEvent *hepmc, HepMC::PdfInfo *pdf, const ThePEG::EventPtr &event)