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" 34 LHAProcess(
int idProcIn,
double xSecIn,
double xErrIn,
double xMaxIn) :
35 idProc(idProcIn), xSecProc(xSecIn), xErrProc(xErrIn),
40 double xSecProc, xErrProc, xMaxProc;
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,
91 virtual bool fileFound() {
return true;}
92 virtual bool useExternal() {
return false;}
97 virtual bool setInit() = 0;
101 int idBeamB()
const {
return idBeamBSave;}
102 double eBeamA()
const {
return eBeamASave;}
103 double eBeamB()
const {
return eBeamBSave;}
104 int pdfGroupBeamA()
const {
return pdfGroupBeamASave;}
105 int pdfGroupBeamB()
const {
return pdfGroupBeamBSave;}
106 int pdfSetBeamA()
const {
return pdfSetBeamASave;}
107 int pdfSetBeamB()
const {
return pdfSetBeamBSave;}
114 int idProcess(
int proc)
const {
return processes[proc].idProc;}
115 double xSec(
int proc)
const {
return processes[proc].xSecProc;}
116 double xErr(
int proc)
const {
return processes[proc].xErrProc;}
117 double xMax(
int proc)
const {
return processes[proc].xMaxProc;}
118 double xSecSum()
const {
return xSecSumSave;}
119 double xErrSum()
const {
return xErrSumSave;}
131 virtual bool setEvent(
int idProcIn = 0) = 0;
135 double weight()
const {
return weightProc;}
136 double scale()
const {
return scaleProc;}
137 double alphaQED()
const {
return alphaQEDProc;}
138 double alphaQCD()
const {
return alphaQCDProc;}
142 int id(
int part)
const {
return particles[part].idPart;}
143 int status(
int part)
const {
return particles[part].statusPart;}
144 int mother1(
int part)
const {
return particles[part].mother1Part;}
145 int mother2(
int part)
const {
return particles[part].mother2Part;}
146 int col1(
int part)
const {
return particles[part].col1Part;}
147 int col2(
int part)
const {
return particles[part].col2Part;}
148 double px(
int part)
const {
return particles[part].pxPart;}
149 double py(
int part)
const {
return particles[part].pyPart;}
150 double pz(
int part)
const {
return particles[part].pzPart;}
151 double e(
int part)
const {
return particles[part].ePart;}
152 double m(
int part)
const {
return particles[part].mPart;}
153 double tau(
int part)
const {
return particles[part].tauPart;}
154 double spin(
int part)
const {
return particles[part].spinPart;}
155 double scale(
int part)
const {
return particles[part].scalePart;}
158 int id1()
const {
return id1Save;}
159 int id2()
const {
return id2Save;}
160 double x1()
const {
return x1Save;}
161 double x2()
const {
return x2Save;}
165 int id1pdf()
const {
return id1pdfSave;}
166 int id2pdf()
const {
return id2pdfSave;}
167 double x1pdf()
const {
return x1pdfSave;}
168 double x2pdf()
const {
return x2pdfSave;}
169 double scalePDF()
const {
return scalePDFSave;}
170 double pdf1()
const {
return pdf1Save;}
171 double pdf2()
const {
return pdf2Save;}
175 double scaleShowers(
int i)
const {
return scaleShowersSave[i];}
183 for (
int iSkip = 0; iSkip < nSkip; ++iSkip)
if (!setEvent())
return false;
187 virtual bool openLHEF(
string fileNameIn);
188 virtual bool closeLHEF(
bool updateInit =
false);
190 bool eventLHEF(
bool verbose =
true);
198 LHAup(
int strategyIn = 3) : infoPtr(), nupSave(), idprupSave(),
199 xwgtupSave(), scalupSave(), aqedupSave(), aqcdupSave(), xSecSumSave(),
200 xErrSumSave(), getPDFSave(), getScale(), getScaleShowers(),
201 id1InSave(), id2InSave(), id1pdfInSave(), id2pdfInSave(), x1InSave(),
202 x2InSave(), x1pdfInSave(), x2pdfInSave(), scalePDFInSave(),
203 pdf1InSave(), pdf2InSave(), scaleShowersInSave(), fileName(
"void"),
204 dateNow(), timeNow(), strategySave(strategyIn), idBeamASave(),
205 idBeamBSave(), eBeamASave(), eBeamBSave(), pdfGroupBeamASave(),
206 pdfGroupBeamBSave(), pdfSetBeamASave(), pdfSetBeamBSave(),
idProc(),
207 weightProc(), scaleProc(), alphaQEDProc(), alphaQCDProc(),
208 pdfIsSetSave(), scaleShowersIsSetSave(false), id1Save(),
209 id2Save(), id1pdfSave(), id2pdfSave(), x1Save(), x2Save(), x1pdfSave(),
210 x2pdfSave(), scalePDFSave(), pdf1Save(), pdf2Save(), scaleShowersSave() {
211 processes.reserve(10); particles.reserve(20);
212 setBeamA( 0, 0., 0, 0); setBeamB( 0, 0., 0, 0); }
222 void setBeamA(
int idIn,
double eIn,
int pdfGroupIn = 0,
int pdfSetIn = 0)
223 { idBeamASave = idIn; eBeamASave = eIn; pdfGroupBeamASave = pdfGroupIn;
224 pdfSetBeamASave = pdfSetIn;}
225 void setBeamB(
int idIn,
double eIn,
int pdfGroupIn = 0,
int pdfSetIn = 0)
226 { idBeamBSave = idIn; eBeamBSave = eIn; pdfGroupBeamBSave = pdfGroupIn;
227 pdfSetBeamBSave = pdfSetIn;}
233 void addProcess(
int idProcIn,
double xSecIn = 1.,
double xErrIn = 0.,
234 double xMaxIn = 1.) { processes.push_back(
LHAProcess( idProcIn,
235 xSecIn, xErrIn, xMaxIn)); }
238 void setXSec(
int iP,
double xSecIn) {processes[iP].xSecProc = xSecIn;}
239 void setXErr(
int iP,
double xErrIn) {processes[iP].xErrProc = xErrIn;}
240 void setXMax(
int iP,
double xMaxIn) {processes[iP].xMaxProc = xMaxIn;}
243 void setProcess(
int idProcIn = 0,
double weightIn = 1.,
double 244 scaleIn = 0.,
double alphaQEDIn = 0.0073,
double alphaQCDIn = 0.12) {
245 idProc = idProcIn; weightProc = weightIn; scaleProc = scaleIn;
246 alphaQEDProc = alphaQEDIn; alphaQCDProc = alphaQCDIn;
248 particles.clear(); addParticle(0); pdfIsSetSave =
false;
249 scaleShowersIsSetSave =
false;}
253 particles.push_back(particleIn);}
254 void addParticle(
int idIn,
int statusIn = 0,
int mother1In = 0,
255 int mother2In = 0,
int col1In = 0,
int col2In = 0,
double pxIn = 0.,
256 double pyIn = 0.,
double pzIn = 0.,
double eIn = 0.,
double mIn = 0.,
257 double tauIn = 0.,
double spinIn = 9.,
double scaleIn = -1.) {
258 particles.push_back(
LHAParticle( idIn, statusIn, mother1In, mother2In,
259 col1In, col2In, pxIn, pyIn, pzIn, eIn, mIn, tauIn, spinIn,
263 void setIdX(
int id1In,
int id2In,
double x1In,
double x2In)
264 { id1Save = id1In; id2Save = id2In; x1Save = x1In; x2Save = x2In;}
267 void setPdf(
int id1pdfIn,
int id2pdfIn,
double x1pdfIn,
double x2pdfIn,
268 double scalePDFIn,
double pdf1In,
double pdf2In,
bool pdfIsSetIn)
269 { id1pdfSave = id1pdfIn; id2pdfSave = id2pdfIn; x1pdfSave = x1pdfIn;
270 x2pdfSave = x2pdfIn; scalePDFSave = scalePDFIn; pdf1Save = pdf1In;
271 pdf2Save = pdf2In; pdfIsSetSave = pdfIsSetIn;}
275 { scaleShowersSave[0] = scaleIn1; scaleShowersSave[1] = scaleIn2;
276 scaleShowersIsSetSave =
true;}
279 bool setInitLHEF(istream& is,
bool readHeaders =
false);
280 bool setNewEventLHEF(istream& is);
281 bool setOldEventLHEF();
288 istream* openFile(
const char *fn, ifstream &ifs);
289 void closeFile(istream *&is, ifstream &ifs);
299 double xwgtupSave, scalupSave, aqedupSave, aqcdupSave, xSecSumSave,
301 vector<LHAParticle> particlesSave;
302 bool getPDFSave, getScale, getScaleShowers;
303 int id1InSave, id2InSave, id1pdfInSave, id2pdfInSave;
304 double x1InSave, x2InSave, x1pdfInSave, x2pdfInSave, scalePDFInSave,
305 pdf1InSave, pdf2InSave, scaleShowersInSave[2];
319 int idBeamASave, idBeamBSave;
320 double eBeamASave, eBeamBSave;
321 int pdfGroupBeamASave, pdfGroupBeamBSave, pdfSetBeamASave,
325 vector<LHAProcess> processes;
329 double weightProc, scaleProc, alphaQEDProc, alphaQCDProc;
332 vector<LHAParticle> particles;
335 bool pdfIsSetSave, scaleShowersIsSetSave;
336 int id1Save, id2Save, id1pdfSave, id2pdfSave;
337 double x1Save, x2Save, x1pdfSave, x2pdfSave, scalePDFSave, pdf1Save,
338 pdf2Save, scaleShowersSave[2];
352 bool readHeadersIn =
false,
bool setScalesFromLHEFIn =
false ) :
353 filename(
""), headerfile(
""),
354 is(isIn), is_gz(nullptr), isHead(isHeadIn), isHead_gz(nullptr),
355 readHeaders(readHeadersIn), reader(is),
356 setScalesFromLHEF(setScalesFromLHEFIn), hasExtFileStream(true),
357 hasExtHeaderStream(true) {setPtr(infoPtrIn);}
360 const char* headerIn =
nullptr,
bool readHeadersIn =
false,
361 bool setScalesFromLHEFIn =
false ) :
362 filename(filenameIn), headerfile(headerIn),
363 is(
nullptr), is_gz(
nullptr), isHead(
nullptr), isHead_gz(
nullptr),
364 readHeaders(readHeadersIn), reader(filenameIn),
365 setScalesFromLHEF(setScalesFromLHEFIn), hasExtFileStream(
false),
366 hasExtHeaderStream(
false) {
368 is = (openFile(filenameIn, ifs));
369 isHead = (headerfile ==
nullptr) ? is : openFile(headerfile, ifsHead);
370 is_gz =
new igzstream(filename);
371 isHead_gz = (headerfile ==
nullptr) ? is_gz :
new igzstream(headerfile);
383 if (!hasExtHeaderStream && isHead_gz != is_gz) isHead_gz->close();
384 if (isHead_gz != is_gz)
delete isHead_gz;
385 if (is_gz) is_gz->close();
386 if (is_gz)
delete is_gz;
389 if (!hasExtHeaderStream && isHead != is) closeFile(isHead, ifsHead);
390 if (!hasExtFileStream) closeFile(is, ifs);
397 is = (openFile(filenameIn, ifs));
398 is_gz =
new igzstream(filenameIn);
400 reader.setup(filenameIn);
408 bool fileFound() {
return (useExternal() || (isHead->good() && is->good()));}
409 bool useExternal() {
return (hasExtHeaderStream && hasExtFileStream);}
413 return setInitLHEF(*isHead, readHeaders);
417 bool setInitLHEF( istream & isIn,
bool readHead);
421 if (!setNewEventLHEF())
return false;
422 return setOldEventLHEF();
427 for (
int iSkip = 0; iSkip < nSkip; ++iSkip)
428 if (!setNewEventLHEF())
return false;
433 bool setNewEventLHEF();
441 bool getLine(
string & line,
bool header =
true) {
443 if ( isHead_gz && header && !getline(*isHead_gz, line))
return false;
444 else if ( is_gz && !header && !getline(*is_gz, line))
return false;
445 if (header && !getline(*isHead, line))
return false;
446 else if (!header && !getline(*is, line))
return false;
448 if (header && !getline(*isHead, line))
return false;
449 else if (!header && !getline(*is, line))
return false;
452 replace(line.begin(),line.end(),
'\'',
'\"');
458 const char* filename;
459 const char* headerfile;
467 igzstream *isHead_gz;
476 bool setScalesFromLHEF, hasExtFileStream, hasExtHeaderStream;
490 processPtr = processPtrIn; infoPtr = infoPtrIn;}
499 bool setEvent(
int = 0);
525 int pDigitsIn = 15,
bool writeToFileIn =
true) :
526 eventPtr(eventPtrIn),infoPtr(infoPtrIn),
527 particleDataPtr(infoPtrIn->particleDataPtr),
528 settingsPtr(infoPtrIn->settingsPtr), writer(osLHEF),
529 pDigits(pDigitsIn), writeToFile(writeToFileIn) {}
536 bool setEvent(
int = 0);
537 string getEventString() {
return writer.getEventString(&hepeup); }
540 bool openLHEF(
string fileNameIn);
543 bool closeLHEF(
bool updateInit =
false);
string getFileName() const
Get access to the Les Houches Event file name.
Definition: LesHouches.h:193
void setBeamA(int idIn, double eIn, int pdfGroupIn=0, int pdfSetIn=0)
Input beam info.
Definition: LesHouches.h:222
void addProcess(int idProcIn, double xSecIn=1., double xErrIn=0., double xMaxIn=1.)
Input process info.
Definition: LesHouches.h:233
static const double CONVERTMB2PB
Allow conversion from mb to pb.
Definition: LesHouches.h:215
void setPtr(Info *infoPtrIn)
Set pointers.
Definition: LesHouches.h:86
LHAProcess()
Constructors.
Definition: LesHouches.h:33
bool fileFound()
Confirm that file was found and opened as expected.
Definition: LesHouches.h:408
void setStrategy(int strategyIn)
Input process weight strategy.
Definition: LesHouches.h:230
~LHAupFromPYTHIA8()
Destructor.
Definition: LesHouches.h:493
The Event class holds all info on the generated event.
Definition: Event.h:453
Logger * loggerPtr
Pointer to the logger.
Definition: Info.h:86
LHAup(int strategyIn=3)
Constructor. Sets default to be that events come with unit weight.
Definition: LesHouches.h:198
void setIdX(int id1In, int id2In, double x1In, double x2In)
Input info on flavour and x values of hard-process initiators.
Definition: LesHouches.h:263
A class for the particles stored in LHAup.
Definition: LesHouches.h:48
A class for the processes stored in LHAup.
Definition: LesHouches.h:28
A derived class with information read from PYTHIA 8 itself, for output.
Definition: LesHouches.h:484
HEPRUP heprup
Some init and event block objects for convenience.
Definition: LesHouches.h:546
void setScaleShowers(double scaleIn1, double scaleIn2=0.)
Optionally input info on parton shower starting scale; two for DPS.
Definition: LesHouches.h:274
bool scaleShowersIsSet() const
Optional: give back info on parton shower scales.
Definition: LesHouches.h:174
int id1() const
Give back info on flavour and x values of hard-process initiators.
Definition: LesHouches.h:158
virtual ~LHAup()
Destructor.
Definition: LesHouches.h:83
const Info * infoPtr
Constant info pointer, explicitly overwrites member from LHAup base class.
Definition: LesHouches.h:553
bool updateSigma()
Update cross-section information at the end of the run.
Definition: LesHouches.h:436
virtual bool skipEvent(int nSkip)
Definition: LesHouches.h:182
LHAupFromPYTHIA8(Event *processPtrIn, const Info *infoPtrIn)
Constructor.
Definition: LesHouches.h:489
void setEventPtr(Event *evPtr)
Routine for reading, setting and printing the next event.
Definition: LesHouches.h:535
Definition: LesHouches.h:78
int idBeamA() const
Give back info on beams.
Definition: LesHouches.h:100
void addParticle(LHAParticle particleIn)
Input particle info, one particle at the time.
Definition: LesHouches.h:252
void setProcess(int idProcIn=0, double weightIn=1., double scaleIn=0., double alphaQEDIn=0.0073, double alphaQCDIn=0.12)
Input info on the selected process.
Definition: LesHouches.h:243
Definition: LesHouches.h:519
virtual void newEventFile(const char *)
Method to be used for LHAupLHEF derived class.
Definition: LesHouches.h:90
A derived class with information read from a Les Houches Event File.
Definition: LesHouches.h:346
int idPart
Particle properties.
Definition: LesHouches.h:67
Event * eventPtr
Pointer to event that should be printed.
Definition: LesHouches.h:550
void setPdf(int id1pdfIn, int id2pdfIn, double x1pdfIn, double x2pdfIn, double scalePDFIn, double pdf1In, double pdf2In, bool pdfIsSetIn)
Optionally input info on parton density values of event.
Definition: LesHouches.h:267
bool getLine(string &line, bool header=true)
Used internally to read a single line from the stream.
Definition: LesHouches.h:441
int nupSave
Event properties from LHEF files, for repeated use.
Definition: LesHouches.h:298
int sizePart() const
Give back info on separate particle.
Definition: LesHouches.h:141
int idProc
Process properties.
Definition: LesHouches.h:39
string fileName
File to which to write Les Houches Event File information.
Definition: LesHouches.h:308
LHAupLHEF(Pythia8::Info *infoPtrIn, istream *isIn, istream *isHeadIn, bool readHeadersIn=false, bool setScalesFromLHEFIn=false)
Constructor.
Definition: LesHouches.h:351
LHAParticle()
Constructors.
Definition: LesHouches.h:53
bool skipEvent(int nSkip)
Skip ahead a number of events, which are not considered further.
Definition: LesHouches.h:426
int sizeProc() const
Give back info on processes.
Definition: LesHouches.h:113
bool pdfIsSet() const
Optional: give back info on parton density values of event.
Definition: LesHouches.h:164
void newEventFile(const char *filenameIn)
Want to use new file with events, but without reinitialization.
Definition: LesHouches.h:394
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
double m(const Vec4 &v1)
Invariant mass and its square.
Definition: Basics.cc:595
bool setEvent(int=0)
Routine for doing the job of reading and setting info on next event.
Definition: LesHouches.h:420
void setInfoHeader(const string &key, const string &val)
Definition: LesHouches.h:294
bool setInit()
Routine for doing the job of reading and setting initialization info.
Definition: LesHouches.h:412
Info * infoPtr
Pointer to various information on the generation.
Definition: LesHouches.h:218
int strategy() const
Give back weight strategy.
Definition: LesHouches.h:110
~LHAupLHEF()
Destructor.
Definition: LesHouches.h:375
LHEF3FromPythia8(Event *eventPtrIn, const Info *infoPtrIn, int pDigitsIn=15, bool writeToFileIn=true)
Constructor.
Definition: LesHouches.h:524
This class holds a map of all ParticleDataEntries.
Definition: ParticleData.h:422
void setHeader(const string &key, const string &val)
Set LHEF headers.
Definition: Info.h:476
int idProcess() const
Give back process number, weight, scale, alpha_em, alpha_s.
Definition: LesHouches.h:134
void setXSec(int iP, double xSecIn)
Possibility to update some cross section info at end of run.
Definition: LesHouches.h:238
Definition: Settings.h:195
void closeAllFiles()
Helper routine to correctly close files.
Definition: LesHouches.h:381