13 #ifndef Pythia8_LesHouches_H
14 #define Pythia8_LesHouches_H
16 #include "Pythia8/Event.h"
17 #include "Pythia8/Info.h"
18 #include "Pythia8/PythiaStdlib.h"
19 #include "Pythia8/Settings.h"
20 #include "Pythia8/Streams.h"
33 LHAProcess() : idProc(0), xSecProc(0.), xErrProc(0.), xMaxProc(0.) { }
34 LHAProcess(
int idProcIn,
double xSecIn,
double xErrIn,
double xMaxIn) :
35 idProc(idProcIn), xSecProc(xSecIn), xErrProc(xErrIn),
40 double xSecProc, xErrProc, xMaxProc;
53 LHAParticle() : idPart(0), statusPart(0), mother1Part(0),
54 mother2Part(0), col1Part(0), col2Part(0), pxPart(0.), pyPart(0.),
55 pzPart(0.), ePart(0.), mPart(0.), tauPart(0.), spinPart(9.),
57 LHAParticle(
int idIn,
int statusIn,
int mother1In,
int mother2In,
58 int col1In,
int col2In,
double pxIn,
double pyIn,
double pzIn,
59 double eIn,
double mIn,
double tauIn,
double spinIn,
61 idPart(idIn), statusPart(statusIn), mother1Part(mother1In),
62 mother2Part(mother2In), col1Part(col1In), col2Part(col2In),
63 pxPart(pxIn), pyPart(pyIn), pzPart(pzIn), ePart(eIn), mPart(mIn),
64 tauPart(tauIn), spinPart(spinIn), scalePart(scaleIn) { }
67 int idPart, statusPart, mother1Part, mother2Part, col1Part, col2Part;
68 double pxPart, pyPart, pzPart, ePart, mPart, tauPart, spinPart,
86 void setPtr(Info* infoPtrIn) {infoPtr = infoPtrIn;}
89 virtual void newEventFile(
const char*) {}
90 virtual bool fileFound() {
return true;}
91 virtual bool useExternal() {
return false;}
96 virtual bool setInit() = 0;
99 int idBeamA()
const {
return idBeamASave;}
100 int idBeamB()
const {
return idBeamBSave;}
101 double eBeamA()
const {
return eBeamASave;}
102 double eBeamB()
const {
return eBeamBSave;}
103 int pdfGroupBeamA()
const {
return pdfGroupBeamASave;}
104 int pdfGroupBeamB()
const {
return pdfGroupBeamBSave;}
105 int pdfSetBeamA()
const {
return pdfSetBeamASave;}
106 int pdfSetBeamB()
const {
return pdfSetBeamBSave;}
109 int strategy()
const {
return strategySave;}
112 int sizeProc()
const {
return processes.size();}
113 int idProcess(
int proc)
const {
return processes[proc].idProc;}
114 double xSec(
int proc)
const {
return processes[proc].xSecProc;}
115 double xErr(
int proc)
const {
return processes[proc].xErrProc;}
116 double xMax(
int proc)
const {
return processes[proc].xMaxProc;}
117 double xSecSum()
const {
return xSecSumSave;}
118 double xErrSum()
const {
return xErrSumSave;}
130 virtual bool setEvent(
int idProcIn = 0) = 0;
133 int idProcess()
const {
return idProc;}
134 double weight()
const {
return weightProc;}
135 double scale()
const {
return scaleProc;}
136 double alphaQED()
const {
return alphaQEDProc;}
137 double alphaQCD()
const {
return alphaQCDProc;}
140 int sizePart()
const {
return particles.size();}
141 int id(
int part)
const {
return particles[part].idPart;}
142 int status(
int part)
const {
return particles[part].statusPart;}
143 int mother1(
int part)
const {
return particles[part].mother1Part;}
144 int mother2(
int part)
const {
return particles[part].mother2Part;}
145 int col1(
int part)
const {
return particles[part].col1Part;}
146 int col2(
int part)
const {
return particles[part].col2Part;}
147 double px(
int part)
const {
return particles[part].pxPart;}
148 double py(
int part)
const {
return particles[part].pyPart;}
149 double pz(
int part)
const {
return particles[part].pzPart;}
150 double e(
int part)
const {
return particles[part].ePart;}
151 double m(
int part)
const {
return particles[part].mPart;}
152 double tau(
int part)
const {
return particles[part].tauPart;}
153 double spin(
int part)
const {
return particles[part].spinPart;}
154 double scale(
int part)
const {
return particles[part].scalePart;}
157 int id1()
const {
return id1Save;}
158 int id2()
const {
return id2Save;}
159 double x1()
const {
return x1Save;}
160 double x2()
const {
return x2Save;}
163 bool pdfIsSet()
const {
return pdfIsSetSave;}
164 int id1pdf()
const {
return id1pdfSave;}
165 int id2pdf()
const {
return id2pdfSave;}
166 double x1pdf()
const {
return x1pdfSave;}
167 double x2pdf()
const {
return x2pdfSave;}
168 double scalePDF()
const {
return scalePDFSave;}
169 double pdf1()
const {
return pdf1Save;}
170 double pdf2()
const {
return pdf2Save;}
177 virtual bool skipEvent(
int nSkip) {
178 for (
int iSkip = 0; iSkip < nSkip; ++iSkip)
if (!setEvent())
return false;
182 virtual bool openLHEF(
string fileNameIn);
183 virtual bool closeLHEF(
bool updateInit =
false);
185 bool eventLHEF(
bool verbose =
true);
188 string getFileName()
const {
return fileName;}
193 LHAup(
int strategyIn = 3) : fileName(
"void"), strategySave(strategyIn)
194 { processes.reserve(10); particles.reserve(20);
195 setBeamA( 0, 0., 0, 0); setBeamB( 0, 0., 0, 0); }
198 static const double CONVERTMB2PB;
204 void setBeamA(
int idIn,
double eIn,
int pdfGroupIn = 0,
int pdfSetIn = 0)
205 { idBeamASave = idIn; eBeamASave = eIn; pdfGroupBeamASave = pdfGroupIn;
206 pdfSetBeamASave = pdfSetIn;}
207 void setBeamB(
int idIn,
double eIn,
int pdfGroupIn = 0,
int pdfSetIn = 0)
208 { idBeamBSave = idIn; eBeamBSave = eIn; pdfGroupBeamBSave = pdfGroupIn;
209 pdfSetBeamBSave = pdfSetIn;}
212 void setStrategy(
int strategyIn) {strategySave = strategyIn;}
215 void addProcess(
int idProcIn,
double xSecIn = 1.,
double xErrIn = 0.,
216 double xMaxIn = 1.) { processes.push_back( LHAProcess( idProcIn,
217 xSecIn, xErrIn, xMaxIn)); }
220 void setXSec(
int iP,
double xSecIn) {processes[iP].xSecProc = xSecIn;}
221 void setXErr(
int iP,
double xErrIn) {processes[iP].xErrProc = xErrIn;}
222 void setXMax(
int iP,
double xMaxIn) {processes[iP].xMaxProc = xMaxIn;}
225 void setProcess(
int idProcIn = 0,
double weightIn = 1.,
double
226 scaleIn = 0.,
double alphaQEDIn = 0.0073,
double alphaQCDIn = 0.12) {
227 idProc = idProcIn; weightProc = weightIn; scaleProc = scaleIn;
228 alphaQEDProc = alphaQEDIn; alphaQCDProc = alphaQCDIn;
230 particles.clear(); addParticle(0); pdfIsSetSave =
false;}
233 void addParticle(LHAParticle particleIn) {
234 particles.push_back(particleIn);}
235 void addParticle(
int idIn,
int statusIn = 0,
int mother1In = 0,
236 int mother2In = 0,
int col1In = 0,
int col2In = 0,
double pxIn = 0.,
237 double pyIn = 0.,
double pzIn = 0.,
double eIn = 0.,
double mIn = 0.,
238 double tauIn = 0.,
double spinIn = 9.,
double scaleIn = -1.) {
239 particles.push_back( LHAParticle( idIn, statusIn, mother1In, mother2In,
240 col1In, col2In, pxIn, pyIn, pzIn, eIn, mIn, tauIn, spinIn,
244 void setIdX(
int id1In,
int id2In,
double x1In,
double x2In)
245 { id1Save = id1In; id2Save = id2In; x1Save = x1In; x2Save = x2In;}
248 void setPdf(
int id1pdfIn,
int id2pdfIn,
double x1pdfIn,
double x2pdfIn,
249 double scalePDFIn,
double pdf1In,
double pdf2In,
bool pdfIsSetIn)
250 { id1pdfSave = id1pdfIn; id2pdfSave = id2pdfIn; x1pdfSave = x1pdfIn;
251 x2pdfSave = x2pdfIn; scalePDFSave = scalePDFIn; pdf1Save = pdf1In;
252 pdf2Save = pdf2In; pdfIsSetSave = pdfIsSetIn;}
255 bool setInitLHEF(istream& is,
bool readHeaders =
false);
256 bool setNewEventLHEF(istream& is);
257 bool setOldEventLHEF();
264 istream* openFile(
const char *fn, ifstream &ifs);
265 void closeFile(istream *&is, ifstream &ifs);
270 void setInfoHeader(
const string &key,
const string &val) {
271 infoPtr->setHeader(key, val); }
274 int nupSave, idprupSave;
275 double xwgtupSave, scalupSave, aqedupSave, aqcdupSave, xSecSumSave,
277 vector<LHAParticle> particlesSave;
278 bool getPDFSave, getScale;
279 int id1InSave, id2InSave, id1pdfInSave, id2pdfInSave;
280 double x1InSave, x2InSave, x1pdfInSave, x2pdfInSave, scalePDFInSave,
281 pdf1InSave, pdf2InSave;
295 int idBeamASave, idBeamBSave;
296 double eBeamASave, eBeamBSave;
297 int pdfGroupBeamASave, pdfGroupBeamBSave, pdfSetBeamASave,
301 vector<LHAProcess> processes;
305 double weightProc, scaleProc, alphaQEDProc, alphaQCDProc;
308 vector<LHAParticle> particles;
312 int id1Save, id2Save, id1pdfSave, id2pdfSave;
313 double x1Save, x2Save, x1pdfSave, x2pdfSave, scalePDFSave, pdf1Save,
322 class LHAupLHEF :
public LHAup {
327 LHAupLHEF(
Pythia8::Info* infoPtrIn, istream* isIn, istream* isHeadIn,
328 bool readHeadersIn =
false,
bool setScalesFromLHEFIn =
false ) :
329 infoPtr(infoPtrIn), filename(
""), headerfile(
""),
330 is(isIn), is_gz(NULL), isHead(isHeadIn), isHead_gz(NULL),
331 readHeaders(readHeadersIn), reader(is),
332 setScalesFromLHEF(setScalesFromLHEFIn), hasExtFileStream(true),
333 hasExtHeaderStream(true) {}
336 const char* headerIn = NULL,
bool readHeadersIn =
false,
337 bool setScalesFromLHEFIn =
false ) :
338 infoPtr(infoPtrIn), filename(filenameIn), headerfile(headerIn),
339 is(NULL), is_gz(NULL), isHead(NULL), isHead_gz(NULL),
340 readHeaders(readHeadersIn), reader(filenameIn),
341 setScalesFromLHEF(setScalesFromLHEFIn), hasExtFileStream(false),
342 hasExtHeaderStream(false) {
343 is = (openFile(filenameIn, ifs));
344 isHead = (headerfile == NULL) ? is : openFile(headerfile, ifsHead);
345 is_gz =
new igzstream(filename);
346 isHead_gz = (headerfile == NULL) ? is_gz :
new igzstream(headerfile);
357 void closeAllFiles() {
359 if (!hasExtHeaderStream && isHead_gz != is_gz) isHead_gz->close();
360 if (isHead_gz != is_gz)
delete isHead_gz;
361 if (is_gz) is_gz->close();
362 if (is_gz)
delete is_gz;
365 if (!hasExtHeaderStream && isHead != is) closeFile(isHead, ifsHead);
366 if (!hasExtFileStream) closeFile(is, ifs);
370 void newEventFile(
const char* filenameIn) {
373 is = (openFile(filenameIn, ifs));
374 is_gz =
new igzstream(filenameIn);
376 reader.setup(filenameIn);
384 bool fileFound() {
return (useExternal() || (isHead->good() && is->good()));}
385 bool useExternal() {
return (hasExtHeaderStream && hasExtFileStream);}
389 return setInitLHEF(*isHead, readHeaders);
393 bool setInitLHEF( istream & isIn,
bool readHead);
396 bool setEvent(
int = 0) {
397 if (!setNewEventLHEF())
return false;
398 return setOldEventLHEF();
402 bool skipEvent(
int nSkip) {
403 for (
int iSkip = 0; iSkip < nSkip; ++iSkip)
404 if (!setNewEventLHEF())
return false;
409 bool setNewEventLHEF();
412 bool updateSigma() {
return true;}
417 bool getLine(
string & line,
bool header =
true) {
419 if ( isHead_gz && header && !getline(*isHead_gz, line))
return false;
420 else if ( is_gz && !header && !getline(*is_gz, line))
return false;
421 if (header && !getline(*isHead, line))
return false;
422 else if (!header && !getline(*is, line))
return false;
424 if (header && !getline(*isHead, line))
return false;
425 else if (!header && !getline(*is, line))
return false;
428 replace(line.begin(),line.end(),
'\'',
'\"');
435 const char* filename;
436 const char* headerfile;
444 igzstream *isHead_gz;
453 bool setScalesFromLHEF, hasExtFileStream, hasExtHeaderStream;
461 class LHAupFromPYTHIA8 :
public LHAup {
466 LHAupFromPYTHIA8(
Event* processPtrIn, Info* infoPtrIn) {
467 processPtr = processPtrIn; infoPtr = infoPtrIn;}
470 ~LHAupFromPYTHIA8() {}
476 bool setEvent(
int = 0);
501 bool writeToFileIn =
true) :
502 eventPtr(eventPtrIn),settingsPtr(settingsPtrIn), infoPtr(infoPtrIn),
503 particleDataPtr(particleDataPtrIn), writer(osLHEF), pDigits(pDigitsIn),
504 writeToFile(writeToFileIn) {}
510 void setEventPtr(
Event* evPtr) { eventPtr = evPtr; }
511 bool setEvent(
int = 0);
512 string getEventString() {
return writer.getEventString(&hepeup); }
515 bool openLHEF(
string fileNameIn);
518 bool closeLHEF(
bool updateInit =
false);
547 #endif // Pythia8_LesHouches_H