11#include <Pythia8/Pythia.h>
21#include <TVirtualMC.h>
23using namespace Pythia8;
53 fPythia8->Pythia8()->readString(
"SoftQCD:elastic = on");
56 fPythia8->Pythia8()->readString(
"ParticleDecays:limitRadius = on");
57 fPythia8->Pythia8()->readString(
"ParticleDecays:rMax = 0.");
59 fPythia8->Pythia8()->particleData.readString(
"59:m0 = 100.1396");
61 fPythia8->Pythia8()->particleData.list(223);
67#if PYTHIA_VERSION_INTEGER < 8310
70 auto rndm = make_shared<MyRandomClass>();
72 fPythia8->Pythia8()->setRndmEnginePtr(rndm);
93 fPythia8->Pythia8()->particleData.list(3122);
96 DecayChannel& channel =
fLambda->channel(0);
104 fPythia8->Pythia8()->particleData.list(113);
125 TParticle* part = gMC->GetStack()->GetCurrentTrack();
151 DecayChannel& channel =
fLambda->channel(0);
164 DecayChannel& channel =
fLambda->channel(0);
184 for (
Int_t j = 0; j < npart; ++j) {
193 for (
Int_t j = 0; j < npart; ++j)
206 printf(
"SetForceDecay not yet implemented !\n");
226 return (
fPythia8->Pythia8()->particleData.tau0(pdg) * 3.3333e-12);
239 fPythia8->Pythia8()->event.append(pdg, 11, 0, 0, p->
Px(), p->
Py(), p->
Pz(), p->
E(), p->
M());
260 Gdeca2(xm0, xm1, xm2, pcm);
265 daughter1.
SetPxPyPzE(pcm[0][0], pcm[0][1], pcm[0][2], pcm[0][3]);
266 daughter2.
SetPxPyPzE(pcm[1][0], pcm[1][1], pcm[1][2], pcm[1][3]);
271 daughter1.
Boost(boost);
272 daughter2.
Boost(boost);
277 gMC->TrackPosition(pos);
281 new ((*fParticles)[npart++])
TParticle(2212, 1, 1, -1, 0, 0, daughter1, pos);
282 new ((*fParticles)[npart])
TParticle(-211, 1, 1, -1, 0, 0, daughter2, pos);
301 Double_t random[2], pvert[3], costh = 0.0, sinth = 0.0, phi = 0.0;
303 Double_t e1 = (xm0 * xm0 + xm1 * xm1 - xm2 * xm2) / (2. * xm0);
306 static TRandom* myRandom = NULL;
317 TParticle* part = gMC->GetStack()->GetCurrentTrack();
319 cout <<
" ??? Not Lambda - exit " << part->
GetPdgCode() << endl;
333 costh = 2. * random[0] - 1.0;
350 pcm[0][2] = p1 * costh;
355 pcm[1][0] = -pcm[0][0];
356 pcm[1][1] = -pcm[0][1];
357 pcm[1][2] = -pcm[0][2];
358 pcm[1][3] =
TMath::Sqrt(pcm[1][0] * pcm[1][0] + pcm[1][1] * pcm[1][1] + pcm[1][2] * pcm[1][2] + xm2 * xm2);
377 polar = polar3.
Mag();
383 static TF1 f(
"f",
"1+0.732*[0]*x", -1, 1);
384 f.SetParameter(0, polar);
400 TVector3 lambda(pvert[0], pvert[1], pvert[2]);
403 norm = polar3.
Unit();
412 TVector3 lambU = lambda.
Unit(), lambZ(0, 0, 1), lambX(1, 0, 0), lambY(0, 1, 0);
413 lambZ.RotateUz(lambU);
414 lambX.RotateUz(lambU);
415 lambY.RotateUz(lambU);
448 gMC->SetUserDecay(pdg);
511 path +=
"/gconfig/MpdDecayConfig.txt";
512 ifstream fin(path.Data());
521 cout << chline << endl;
554 Int_t ndecays = part->sizeChannels();
557 Double_t changedBrs = 0.0, unchangedBrs = 1.0;
558 vector<Int_t> decayInds;
559 vector<Double_t> bRatios;
562 for (
Int_t ich = 0; ich < nchan; ++ich) {
564 cout << chline << endl;
573 for (
Int_t id = 0;
id < nprongs; ++id) {
581 for (
Int_t idecay = 0; idecay < ndecays; ++idecay) {
582 DecayChannel& channel = part->channel(idecay);
583 if (channel.multiplicity() != nprongs)
587 for (
Int_t id = 0;
id < nprongs; ++id) {
588 if (channel.product(
id) != pdgs[
id])
594 changedBrs += channel.bRatio() * scaleBr;
595 unchangedBrs -= channel.bRatio();
596 decayInds.push_back(idecay);
597 bRatios.push_back(channel.bRatio() * scaleBr);
598 activeChan.insert(idecay);
610 part->rescaleBR((1.0 - changedBrs) / unchangedBrs);
614 for (
Int_t ich = 0; ich < nchan; ++ich) {
615 DecayChannel& channel = part->channel(decayInds[ich]);
616 channel.bRatio(bRatios[ich]);
622 for (
Int_t idecay = 0; idecay < ndecays; ++idecay) {
623 if (activeChan.find(idecay) == activeChan.end()) {
624 DecayChannel& channel = part->channel(idecay);
632 for (
Int_t idecay = 0; idecay < ndecays; ++idecay) {
633 DecayChannel& channel = part->channel(idecay);
634 totalBr += channel.bRatio();
636 cout <<
" Total branching after rescaling: " << totalBr << endl;
R__EXTERN TRandom * gRandom
R__EXTERN TSystem * gSystem
void ClearEvent()
Clear the event stack.
void AppendParticle(Int_t pdg, TLorentzVector *p)
Append a particle to the stack.
ParticleDataEntryPtr fLambda
static MpdDecayerPyt8 * Instance()
Get the singleton object.
virtual void SetForceDecay(Int_t type)
Set forced decay mode.
virtual Float_t GetPartialBranchingRatio(Int_t ipart)
virtual void Init()
Initialize the decayer.
void Gdecay(Int_t idpart, TLorentzVector *p)
Simulate two-body decay process of Lambda-hyperon to p+\pi-.
TClonesArray * fParticles
static MpdDecayerPyt8 * fgInstance
void ChangeParticleBr(TObjArray *tokens, Bool_t exclusive)
MpdDecayerPyt8()
constructor
virtual void ReadDecayTable()
to read a decay table (not yet implemented)
std::set< Int_t > fMothersPdg
virtual Float_t GetLifetime(Int_t kf)
return lifetime in seconds of teh particle with PDG number pdg
void Anisotropy(Double_t *pvert, Double_t *rndm, TVector3 &polar, Double_t &phi, Double_t &costh)
Simulate anisotropic (due to polarization) decay of lambda.
virtual void ForceDecay()
ForceDecay not yet implemented.
virtual Int_t ImportParticles(TClonesArray *particles)
import the decay products into particles array
virtual void Decay(Int_t pdg, TLorentzVector *p)
Decay a single particle.
void Gdeca2(Double_t xm0, Double_t xm1, Double_t xm2, Double_t pcm[2][4])
Simulate two-body decay process with anisotropic angular distribution in CMS.
void AddMotherPdg(Int_t pdg)
Add PDG of particle to be decayed by this package.
static TDatabasePDG * Instance()
TParticlePDG * GetParticle(const char *name) const
void Boost(const TVector3 &)
TLorentzVector & Transform(const TLorentzRotation &)
void SetPxPyPzE(Double_t px, Double_t py, Double_t pz, Double_t e)
Int_t GetEntriesFast() const
TObject * Last() const override
void Delete(Option_t *option="") override
TObject * UncheckedAt(Int_t i) const
friend friend class TClonesArray
void ProductionVertex(TLorentzVector &v) const
Float_t GetWeight() const
void SetLastDaughter(int code)
void SetProductionVertex(const TLorentzVector &v)
Int_t GetFirstMother() const
void SetFirstDaughter(int code)
void SetStatusCode(int status)
void SetLastMother(int code)
void GetPolarisation(Double_t &theta, Double_t &phi) const
void SetFirstMother(int code)
void Momentum(TLorentzVector &v) const
virtual void SetSeed(ULong_t seed=0)
TRotation & RotateAxes(const TVector3 &newX, const TVector3 &newY, const TVector3 &newZ)
TObjArray * Tokenize(const TString &delim) const
TString & Remove(EStripType s, char c)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
std::istream & ReadLine(std::istream &str, Bool_t skipWhite=kTRUE)
void GetXYZ(Double_t *carray) const
TVector3 & Transform(const TRotation &)
TVector3 Cross(const TVector3 &) const
void RotateUz(const TVector3 &)
Pythia8::ParticleDataEntry * ParticleDataEntryPtr
Double_t Sign(Double_t a, Double_t b)
Double_t Sqrt(Double_t x)
constexpr Double_t TwoPi()