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";
82 if (fileName.empty() || fileName[0] ==
'/')
89 const string ¶mName)
const
105 stringstream logstream;
108 string repository =
dataFile(pset,
"repository");
109 if (!repository.empty()) {
110 edm::LogInfo(
"ThePEGInterface") <<
"Loading repository (" << repository <<
")";
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] !=
'/')
120 if (boost::filesystem::exists(*libdir +
121 "/../../share/ThePEG/PDFsets.index")) {
122 setenv(
"ThePEG_INSTALL_PATH",
130 vector<string> configFiles = pset.
getParameter<vector<string> >(
"configFiles");
133 for(vector<string>::const_iterator
iter = configFiles.begin();
134 iter != configFiles.end(); ++
iter) {
147 iter = collector.
begin(cfgDump);
149 iter = collector.
begin();
151 for(; iter != collector.
end(); ++
iter) {
152 string out = ThePEG::Repository::exec(*iter, logstream);
155 cerr <<
"Error in ThePEG configuration!\n"
156 "\tLine: " << *iter <<
"\n" << out << endl;
168 ThePEG::Repository::exec(
"set " +
generator_ +
169 ":RandomNumberGenerator:ProxyID " + ss.str(),
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;
179 ThePEG::Repository::stats(logstream);
186 ThePEG::BaseRepository::CheckObjectDirectory(
generator_);
187 ThePEG::EGPtr
tmp = ThePEG::BaseRepository::GetObject<ThePEG::EGPtr>(
generator_);
189 eg_ = ThePEG::Repository::makeRun(tmp,
run_);
191 edm::LogInfo(
"ThePEGInterface") <<
"EventGenerator initialized";
194 <<
"EventGenerator could not be initialized!" << endl;
210 <<
"ThePEG not initialised with RandomEngineGlue.";
216 const ThePEG::EventPtr &
event)
218 return std::auto_ptr<HepMC::GenEvent>(
226 hepmc->set_event_scale(-1.0);
227 hepmc->set_alphaQCD(-1.0);
228 hepmc->set_alphaQED(-1.0);
235 pdf->set_scalePDF(-1.0);
243 const ThePEG::EventPtr &
event)
245 if (!event->primaryCollision())
248 ThePEG::tcEHPtr eh = ThePEG::dynamic_ptr_cast<ThePEG::tcEHPtr>(
249 event->primaryCollision()->handler());
250 double scale = eh->lastScale();
253 if (hepmc->event_scale() < 0 && scale > 0)
256 if (hepmc->alphaQCD() < 0)
257 hepmc->set_alphaQCD(eh->lastAlphaS());
258 if (hepmc->alphaQED() < 0)
259 hepmc->set_alphaQED(eh->lastAlphaEM());
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());
271 if (pdf->id1() == -100) {
272 int id = partons.first->id();
273 pdf->set_id1(
id == 21 ? 0 :
id);
275 if (pdf->id2() == -100) {
276 int id = partons.second->id();
277 pdf->set_id2(
id == 21 ? 0 :
id);
280 if (pdf->scalePDF() < 0)
297 if (pdf1 && pdf->pdf1() < 0) {
298 double v = pdf1->xfx(beams.first->dataPtr(),
299 partons.first->dataPtr(),
302 pdf->set_pdf1(v / x1);
306 if (pdf2 && pdf->pdf2() < 0) {
307 double v = pdf2->xfx(beams.first->dataPtr(),
308 partons.first->dataPtr(),
311 pdf->set_pdf2(v / x2);
321 using namespace ThePEG;
323 if (!event->primaryCollision())
326 tSubProPtr sub =
event->primaryCollision()->primarySubProcess();
327 TmpTransform<tSubProPtr>
tmp(sub, Utilities::getBoostToCM(
330 double pthat = (*sub->outgoing().begin())->momentum().perp();
331 for(PVector::const_iterator it = sub->outgoing().begin();
332 it != sub->outgoing().end(); ++it)
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
void setPEGRandomEngine(CLHEP::HepRandomEngine *)
const_iterator begin() const
void setRandomEngine(CLHEP::HepRandomEngine *v)
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)