Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
OTFEventGenerator.cxx
1/*
2 * OTFGenerator.cxx
3 *
4 * Created on: 3 lip 2024
5 * Author: daniel
6 */
7
8#include "OTFEventGenerator.h"
9
10#include <TDatabasePDG.h>
11#include <TH1.h>
12#include <TLorentzVector.h>
13#include <TMath.h>
14#include <TParticlePDG.h>
15#include <TRandom.h>
16
17#include "Cout.h"
18#include "DataManager.h"
19#include "OTFData.h"
20#include "Std.h"
21#include "Task.h"
22
23
24namespace HalOTF { /* namespace Hal */
25
26 void EventGenerator::GenerateEvent() {
27 Int_t shift = fMcEvent->GetNTracks();
28 fCurrrentMult = fFixedMultiplicity;
29 if (fMultiplicity) fCurrrentMult = fMultiplicity->GetRandom();
30 for (int i = 0; i < fCurrrentMult; i++) {
31 Double_t pt, y;
32 fSpectras->GetRandom2(y, pt);
33 Double_t mt = TMath::Sqrt(pt * pt + fMass * fMass);
34 Double_t phi = gRandom->Uniform(-TMath::Pi(), TMath::Pi());
35 Double_t px = pt * TMath::Cos(phi);
36 Double_t py = pt * TMath::Sin(phi);
37 Double_t pz = mt * TMath::SinH(y);
38
39 OTF::McTrack tr;
40 TLorentzVector p;
41 p.SetXYZM(px, py, pz, fMass);
42 tr.SetMomentum(p);
43 tr.SetPdgCode(fPids);
44 TLorentzVector xr(gRandom->Gaus(0, 1), gRandom->Gaus(0, 1), gRandom->Gaus(0), 0);
45 tr.SetFreezout(xr);
46 fMcEvent->AddTrack(tr);
47
49 px = px + gRandom->Gaus(0, fSmear) * px;
50 py = py + gRandom->Gaus(0, fSmear) * py;
51 pz = pz + gRandom->Gaus(0, fSmear) * pz;
52 Double_t e = TMath::Sqrt(px * px + py * py + pz * pz + fMass * fMass);
53 rtr.SetMom(px, py, pz, e);
54 rtr.SetNHits(5);
55 rtr.SetCharge(fCharge);
56 rtr.SetMcIndex(i + shift);
57 fRecoEvent->AddTrack(rtr);
58 }
59 }
60
61 EventGenerator::EventGenerator() {}
62
63 void EventGenerator::SetSpiecies(const TH2D& h, Int_t pid) {
64 TH2D* copy = (TH2D*) h.Clone();
65 TDatabasePDG* pdg = TDatabasePDG::Instance();
66 TParticlePDG* part = pdg->GetParticle(pid);
67 if (part == nullptr) {
68 Hal::Cout::PrintInfo(Form("Cannot add particle with PID = %i", pid), Hal::EInfo::kWarning);
69 return;
70 }
71 copy->SetDirectory(nullptr);
72 fSpectras = copy;
73 fPids = pid;
74 fMass = part->Mass();
75 fCharge = part->Charge() * 3;
76 }
77
79 if (fMultiplicity) delete fMultiplicity;
80 fMultiplicity = (TH1D*) h.Clone();
81 fMultiplicity->SetDirectory(nullptr);
82 }
83
84 void EventGenerator::SetFixMult(Int_t mult) {
85 fFixedMultiplicity = mult;
86 if (fMultiplicity) delete fMultiplicity;
87 fMultiplicity = nullptr;
88 }
89
90 Bool_t EventGenerator::Init() {
91 if (fSpectras == nullptr) return kFALSE;
92 return kTRUE;
93 }
94
95 EventGenerator::~EventGenerator() {
96 if (fSpectras) delete fSpectras;
97 if (fMultiplicity) delete fMultiplicity;
98 }
99} // namespace HalOTF
void SetSpiecies(const TH2D &h, Int_t pid)
static void PrintInfo(TString text, Hal::EInfo status)
Definition Cout.cxx:370