1 #include "StarPythia8.h"
4 #include "TDatabasePDG.h"
5 #include "TParticlePDG.h"
7 #include "StarGenerator/UTIL/StarRandom.h"
8 #include "StarGenerator/EVENT/StarGenPPEvent.h"
9 #include "StarGenerator/EVENT/StarGenEPEvent.h"
13 #ifndef Pythia8_version
14 #error "Pythia8_version is not defined"
26 StarPythia8::StarPythia8(
const char *name) :
StarGenerator(name)
33 TString path =
"StRoot/StarGenerator/"; path+= Pythia8_version; path+=
"/share/Pythia8/xmldoc/";
36 if (!in.good()) { path =
"$(STAR)/"+path; }
37 path = gSystem->ExpandPathName(path.Data());
41 Info(
GetName(),Form(
"MC version is %s data at %s",Pythia8_version,path.Data()));
42 Info(
GetName(),Form(
"Configuration files at %s",path.Data()));
45 mPythia -> setRndmEnginePtr(
new PyRand() );
57 map<TString,TString> particles;
58 particles[
"electron"]=
"e-";
59 particles[
"proton"]=
"proton";
61 TString myBlue = particles[
mBlue];
if ( myBlue ==
"" ) myBlue=
mBlue;
62 TString myYell = particles[
mYell];
if ( myYell ==
"" ) myYell=
mYell;
68 TDatabasePDG &pdg = (*TDatabasePDG::Instance());
69 TParticlePDG *blue = pdg.GetParticle(myBlue); assert(blue);
70 TParticlePDG *yell = pdg.GetParticle(myYell); assert(yell);
72 if (
mFrame ==
"CMS" ) InitCMS ( blue->PdgCode(), yell->PdgCode() );
73 if (
mFrame ==
"FIXT" ) InitFIXT( blue->PdgCode(), yell->PdgCode() );
74 if (
mFrame ==
"3MOM" ) Init3MOM( blue->PdgCode(), yell->PdgCode() );
75 if (
mFrame ==
"4MOM" ) Init4MOM( blue->PdgCode(), yell->PdgCode() );
76 if (
mFrame ==
"5MOM" ) Init5MOM( blue->PdgCode(), yell->PdgCode() );
101 return StMaker::Init();
123 mNumberOfParticles =
event.size() - 1;
130 for (
int idx=1; idx <= mNumberOfParticles; idx++ )
133 int id =
event[idx].id();
135 int stat =
event[idx].statusHepMC();
136 int mother1 =
event[idx].mother1();
137 int mother2 =
event[idx].mother2();
138 int daughter1 =
event[idx].daughter1();
139 int daughter2 =
event[idx].daughter2();
140 double px =
event[idx].px();
141 double py =
event[idx].py();
142 double pz =
event[idx].pz();
143 double energy =
event[idx].e();
144 double mass =
event[idx].m();
145 double vx =
event[idx].xProd();
146 double vy =
event[idx].yProd();
147 double vz =
event[idx].zProd();
148 double vt =
event[idx].tProd();
150 mEvent -> AddParticle( stat,
id, mother1, mother2, daughter1, daughter2, px, py, pz, energy, mass, vx, vy, vz, vt );
167 event -> idBlue = info.idA();
168 event -> idYell = info.idB();
169 event -> process = info.code();
170 event -> subprocess = (info.hasSub())? 0 : info.codeSub();
173 double x = info.x1();
174 double xPdf = info.pdf1();
175 int valence = info.isValence1();
176 if ( TMath::Abs(
id)>6 )
181 valence = info.isValence2();
184 event -> idParton = id;
185 event -> xParton = x;
186 event -> xPdf = xPdf;
188 event -> Q2 = info.Q2Fac();
189 event -> valence = valence;
198 event -> weight = info.weight();
212 event -> idBlue = info.idA();
213 event -> idYell = info.idB();
214 event -> process = info.code();
215 event -> subprocess = (info.hasSub())? 0 : info.codeSub();
217 event -> idParton1 = info.id1();
218 event -> idParton2 = info.id2();
219 event -> xParton1 = info.x1();
220 event -> xParton2 = info.x2();
221 event -> xPdf1 = info.pdf1();
222 event -> xPdf2 = info.pdf2();
223 event -> Q2fac = info.Q2Fac();
224 event -> Q2ren = info.Q2Ren();
225 event -> valence1 = info.isValence1();
226 event -> valence2 = info.isValence2();
228 event -> sHat = info.sHat();
229 event -> tHat = info.tHat();
230 event -> uHat = info.uHat();
231 event -> ptHat = info.pTHat();
232 event -> thetaHat = info.thetaHat();
233 event -> phiHat = info.phiHat();
235 event -> weight = info.weight();
250 stats.nTried = info.nTried();
251 stats.nSelected = info.nSelected();
252 stats.nAccepted = info.nAccepted();
253 stats.sigmaGen = info.sigmaGen();
254 stats.sigmaErr = info.sigmaErr();
255 stats.sumWeightGen = info.weightSum();
257 stats.nFilterSeen = stats.nAccepted;
258 stats.nFilterAccept = stats.nAccepted;
269 int StarPythia8::InitCMS(
int blue,
int yell )
271 Set( Form(
"Beams:idA=%i",blue) );
272 Set( Form(
"Beams:idB=%i",yell) );
273 Set(
"Beams:frameType=1");
280 int StarPythia8::InitFIXT(
int blue,
int yell )
282 Set( Form(
"Beams:idA=%i",blue) );
283 Set( Form(
"Beams:idB=%i",yell) );
284 Set(
"Beams:frameType=2");
287 Set( Form(
"Beams:eA=%f", eA) );
288 Set( Form(
"Beams:eB=%f", eB) );
293 int StarPythia8::Init3MOM(
int blue,
int yell )
295 LOG_INFO <<
"Init3/4/5MOM not implemented yet" << endm;
309 int StarPythia8::Init4MOM(
int blue,
int yell )
311 return Init3MOM( blue, yell );
314 int StarPythia8::Init5MOM(
int blue,
int yell )
316 return Init3MOM( blue, yell );
Double_t mRootS
CMS energy or incident beam momentum for fixed target collisions.
int Generate()
Generate one event.
static StarRandom & Instance()
Obtain the single instance of the random number generator.
TString mYell
Name of the yellow beam particle (-z)
Event record class tailored to PP kinematics.
ABC for defining event generator interfaces.
StarGenEvent * mEvent
Generated event.
void FillEP(StarGenEvent *event)
(Optional) Method to fill a DIS event
Double_t flat() const
Return a random number uniformly distributed between 0 and 1.
End of run statistics for event generators.
Base class for event records.
virtual const char * GetName() const
special overload
Event record class tailored to DIS kinemaics.
TString mFrame
Frame of the collision, i.e. CMS, FIXT, 3MOM, 4MOM, 5MOM.
TString mBlue
Name of the blue beam particle (+z)
void FillPP(StarGenEvent *event)
(Optional) Method to fill a PP event
int Init()
Initialize the event generator.
StarGenStats Stats()
Return end-of-run statistics.
void Set(const char *s)
Pass a string to Pythia8::Pythia::readString(), for user configuration.