BmnRoot 26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
MpdHistoGenerator.cxx
Go to the documentation of this file.
1/**
2 * MpdHistoGenerator.cxx
3 * *@author A.Zinchenko <Alexander.Zinchenko@jinr.ru>
4 * The MpdHistoGenerator produces particles according to their Eta-Pt histogram
5 **/
6
7#include "MpdHistoGenerator.h"
8
9#include "FairMCEventHeader.h"
10#include "FairPrimaryGenerator.h"
11#include "TDatabasePDG.h"
12#include "TFile.h"
13#include "TH2D.h"
14#include "TLorentzVector.h"
15#include "TMath.h"
16#include "TRandom.h"
17#include "TVirtualMC.h"
18
19#include <fstream>
20#include <iomanip>
21#include <iostream>
22// #define debug_hsd
23
24using namespace std;
25
26// ------------------------------------------------------------------------
29 , fPdgCode(-211)
30 , fMult(1)
31 , fHist(NULL)
32{
33 // Constructor
34
35 // gRandom->SetSeed(0); // change random seed
36
37 // Get histograms Pt vs Eta (He3)
38 TFile f("he3_eta_pt.root");
39 f.ReadAll();
40 fHist = (TH2D*)f.FindObject("hPtEta");
41 fHist->SetDirectory(0);
42}
43
44// ------------------------------------------------------------------------
47 , fPdgCode(pdgid)
48 , fMult(mult)
49 , fHist(NULL)
50{
51 // Constructor
52
53 // gRandom->SetSeed(0); // change random seed
54
55 // Get histograms Pt vs Eta (He3)
56 TFile f("he3_eta_pt.root");
57 f.ReadAll();
58 fHist = (TH2D*)f.FindObject("hPtEta");
59 fHist->SetDirectory(0);
60}
61
62// ------------------------------------------------------------------------
64{
65 // Destructor
66}
67
68//-------------------------------------------------------------------------
69Bool_t MpdHistoGenerator::ReadEvent(FairPrimaryGenerator* primGen)
70{
71 // Generate event
72
73 static Int_t first = 1;
74
75 if (first) {
76 first = 0;
77 // cout << " histo " << fHist << " " << fHist->GetNbinsX() << " " << fHist->GetNbinsY() << endl;
78 if (TDatabasePDG::Instance()->GetParticle(fPdgCode) == NULL) {
79 // Define particle with fPdgCode (take it from DCM-QGSM input file)
80 // To be done ...
81 }
82 }
83
84 Double_t pt, eta, phi;
85 TVector3 part;
86
87 for (Int_t i = 0; i < fMult; ++i) {
88 phi = gRandom->Uniform(TMath::TwoPi());
89 fHist->GetRandom2(eta, pt);
90
91 part.SetPtEtaPhi(pt, eta, phi);
92
93 // FairMCEventHeader* eventHeader = primGen->GetEvent();
94 /* Set event impact parameter in MCEvent if not yet done */
95 /*
96 if (eventHeader && (!eventHeader->IsSet()) ) {
97 eventHeader->SetB(fB);
98 eventHeader->MarkSet(kTRUE);
99 }
100 */
101
102 // primGen->AddTrack(1000020030, He3.Px(), He3.Py(), He3.Pz(), 0., 0., 0., -1);
103 primGen->AddTrack(fPdgCode, part.Px(), part.Py(), part.Pz(), 0., 0., 0., -1);
104 }
105
106 return kTRUE;
107}
108
109// ------------------------------------------------------------------------
int i
Definition P4_F32vec4.h:22
bool Bool_t
int Int_t
double Double_t
constexpr Bool_t kTRUE
R__EXTERN TRandom * gRandom
virtual ~MpdHistoGenerator()
Destructor.
MpdHistoGenerator()
Default constructor.
TH2D * fHist
particle multiplicity
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)
Creates an event with given type and multiplicity.
Int_t fMult
particle PDG code
static TDatabasePDG * Instance()
Double_t Px() const
Double_t Py() const
Double_t Pz() const
void SetPtEtaPhi(Double_t pt, Double_t eta, Double_t phi)
constexpr Double_t TwoPi()