15 #include <boost/shared_ptr.hpp>
16 #include <boost/filesystem.hpp>
18 #include <HepMC/GenEvent.h>
19 #include <HepMC/PdfInfo.h>
20 #include <HepMC/IO_GenEvent.h>
22 #include <ThePEG/Utilities/DynamicLoader.h>
23 #include <ThePEG/Repository/Repository.h>
24 #include <ThePEG/Handlers/EventHandler.h>
25 #include <ThePEG/Handlers/XComb.h>
26 #include <ThePEG/EventRecord/Event.h>
27 #include <ThePEG/EventRecord/Particle.h>
28 #include <ThePEG/EventRecord/Collision.h>
29 #include <ThePEG/EventRecord/TmpTransform.h>
30 #include <ThePEG/Config/ThePEG.h>
31 #include <ThePEG/PDF/PartonExtractor.h>
32 #include <ThePEG/PDF/PDFBase.h>
33 #include <ThePEG/Utilities/UtilityBase.h>
48 randomEngineGlueProxy_(ThePEG::RandomEngineGlue::Proxy::
create()),
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))
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 <<
")";
70 edm::LogInfo(
"ThePEGInterface") <<
"Event generator finalized";
75 if (fileName.empty() || fileName[0] ==
'/')
82 const string ¶mName)
const
98 stringstream logstream;
101 string repository =
dataFile(pset,
"repository");
102 if (!repository.empty()) {
103 edm::LogInfo(
"ThePEGInterface") <<
"Loading repository (" << repository <<
")";
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] !=
'/')
113 if (boost::filesystem::exists(*libdir +
114 "/../../share/ThePEG/PDFsets.index")) {
115 setenv(
"ThePEG_INSTALL_PATH",
123 vector<string> configFiles = pset.
getParameter<vector<string> >(
"configFiles");
126 for(vector<string>::const_iterator iter = configFiles.begin();
127 iter != configFiles.end(); ++iter) {
128 edm::LogInfo(
"ThePEGInterface") <<
"Reading config file (" << *iter <<
")";
140 iter = collector.
begin(cfgDump);
142 iter = collector.
begin();
144 for(; iter != collector.
end(); ++iter) {
145 string out = ThePEG::Repository::exec(*iter, logstream);
148 cerr <<
"Error in ThePEG configuration!\n"
149 "\tLine: " << *iter <<
"\n" << out << endl;
161 ThePEG::Repository::exec(
"set " +
generator_ +
162 ":RandomNumberGenerator:ProxyID " + ss.str(),
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;
172 ThePEG::Repository::stats(logstream);
179 ThePEG::BaseRepository::CheckObjectDirectory(
generator_);
180 ThePEG::EGPtr
tmp = ThePEG::BaseRepository::GetObject<ThePEG::EGPtr>(
generator_);
182 eg_ = ThePEG::Repository::makeRun(tmp,
run_);
184 edm::LogInfo(
"ThePEGInterface") <<
"EventGenerator initialized";
187 <<
"EventGenerator could not be initialized!" << endl;
203 <<
"ThePEG not initialised with RandomEngineGlue.";
211 return std::auto_ptr<HepMC::GenEvent>(
219 hepmc->set_event_scale(-1.0);
220 hepmc->set_alphaQCD(-1.0);
221 hepmc->set_alphaQED(-1.0);
228 pdf->set_scalePDF(-1.0);
238 if (!event->primaryCollision())
241 ThePEG::tcEHPtr eh = ThePEG::dynamic_ptr_cast<ThePEG::tcEHPtr>(
242 event->primaryCollision()->handler());
243 double scale = eh->lastScale();
246 if (hepmc->event_scale() < 0 && scale > 0)
247 hepmc->set_event_scale(
std::sqrt(scale) / ThePEG::GeV);
249 if (hepmc->alphaQCD() < 0)
250 hepmc->set_alphaQCD(eh->lastAlphaS());
251 if (hepmc->alphaQED() < 0)
252 hepmc->set_alphaQED(eh->lastAlphaEM());
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());
264 if (pdf->id1() == -100) {
265 int id = partons.first->id();
266 pdf->set_id1(
id == 21 ? 0 :
id);
268 if (pdf->id2() == -100) {
269 int id = partons.second->id();
270 pdf->set_id2(
id == 21 ? 0 :
id);
273 if (pdf->scalePDF() < 0)
274 pdf->set_scalePDF(
std::sqrt(scale) / ThePEG::GeV);
276 scale =
ThePEG::sqr(pdf->scalePDF()) * ThePEG::GeV;
290 if (pdf1 && pdf->pdf1() < 0) {
291 double v = pdf1->xfx(beams.first->dataPtr(),
292 partons.first->dataPtr(),
295 pdf->set_pdf1(v / x1);
299 if (pdf2 && pdf->pdf2() < 0) {
300 double v = pdf2->xfx(beams.first->dataPtr(),
301 partons.first->dataPtr(),
304 pdf->set_pdf2(v / x2);
314 using namespace ThePEG;
316 if (!event->primaryCollision())
319 tSubProPtr sub =
event->primaryCollision()->primarySubProcess();
320 TmpTransform<tSubProPtr>
tmp(sub, Utilities::getBoostToCM(
323 double pthat = (*sub->outgoing().begin())->momentum().perp();
324 for(PVector::const_iterator it = sub->outgoing().begin();
325 it != sub->outgoing().end(); ++it)
328 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)
Double_t pdf1(double mHstar, double mHreq)
boost::shared_ptr< boost::statechart::event_base > EventPtr
static double pthat(const ThePEG::EventPtr &event)
std::string dataFile(const std::string &fileName) const
std::pair< std::string, MonitorElement * > entry
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)