BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
MpdHypYPtGenerator.cxx
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- CbmAnaHypYPtGenerator source file -----
3// ----- Created 03/10/04 by E. Kryshen -----
4// ----- Updated 10/02/10 by A. Zinchenko for MPD (with name change) -----
5// -------------------------------------------------------------------------
6
8
9#include "FairPrimaryGenerator.h"
10#include "TDatabasePDG.h"
11#include "TF1.h"
12#include "TMath.h"
13#include "TParticlePDG.h"
14#include "TRandom.h"
15
16// ------------------------------------------------------------------------
19{
20 // Default constructor
21
22 fPDGType = -1;
23 fMult = 0;
24}
25
26// ------------------------------------------------------------------------
29 , fPDGType(pdgid)
30 , fMult(mult)
31 , fYield(yield)
32{
33 // Constructor. Set default distributions
34
37 SetRangePt();
38}
39// ------------------------------------------------------------------------
41{
42 // Initialize generator
43
44 // Check for particle type
46 TParticlePDG* particle = pdgBase->GetParticle(fPDGType);
47 if (!particle) {
48 Fatal("CbmAnaHypYPtGenerator", "PDG code %d not defined.", fPDGType);
49 return kFALSE;
50 }
51 fPDGMass = particle->Mass();
52 // gRandom->SetSeed(0);
53 fDistPt = new TF1("distPt", "x*exp(-sqrt(x*x+[1]*[1])/[0])", fPtMin, fPtMax);
54 fDistPt->SetParameters(fT, fPDGMass, fY0, fSigma);
55 Info("Init", "pdg=%i y0=%4.2f sigma_y=%4.2f T_pt=%6.4f", fPDGType, fY0, fSigma, fT);
56 return kTRUE;
57}
58
59// ------------------------------------------------------------------------
60Bool_t MpdHypYPtGenerator::ReadEvent(FairPrimaryGenerator* primGen)
61{
62
63 Double_t phi, pt, y, mt, px, py, pz;
64 gRandom->Rndm();
65 if (fYield > 0 && gRandom->Rndm() > fYield)
66 return kTRUE;
67
68 // Generate particles
69
70 for (Int_t k = 0; k < fMult; k++) {
71
72 phi = gRandom->Uniform(0, TMath::TwoPi());
73 pt = fDistPt->GetRandom(fPtMin, fPtMax);
74 px = pt * TMath::Cos(phi);
75 py = pt * TMath::Sin(phi);
76 y = gRandom->Gaus(fY0, fSigma);
77 mt = TMath::Sqrt(fPDGMass * fPDGMass + pt * pt);
78 pz = mt * TMath::SinH(y);
79 Info("ReadEvent", "Particle generated: pdg=%i pt=%f y=%f\n", fPDGType, pt, y);
80 primGen->AddTrack(fPDGType, px, py, pz, 0, 0, 0);
81 }
82 return kTRUE;
83}
84// ------------------------------------------------------------------------
bool Bool_t
int Int_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
void Info(const char *location, const char *msgfmt,...)
void Fatal(const char *location, const char *msgfmt,...)
R__EXTERN TRandom * gRandom
Int_t fPDGType
Particle type (PDG encoding).
Double_t fYield
Pointer to the Pt function.
Double_t fPDGMass
Particle mass [GeV].
Double_t fT
Temperature in the Pt distribution.
Double_t fY0
Mean rapidity.
Double_t fSigma
Simga in the rapidity distribution.
MpdHypYPtGenerator()
Default constructor.
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)
Creates an event with given type and multiplicity.
void SetDistributionPt(Double_t T=0.223)
void SetRangePt(Double_t ptMin=0, Double_t ptMax=3)
Int_t fMult
Multiplicity.
Double_t fPtMax
Min value of Pt.
Double_t fPtMin
Max value of Pt.
void SetDistributionY(Double_t y0=0, Double_t sigma=0.72)
Bool_t Init()
Initializer.
static TDatabasePDG * Instance()
TParticlePDG * GetParticle(const char *name) const
Double_t Mass() const
Double_t Sqrt(Double_t x)
Double_t Cos(Double_t)
Double_t Sin(Double_t)
constexpr Double_t TwoPi()
Double_t SinH(Double_t)