8#include "OTFEventGeneratorDecay.h"
10#include <TDatabasePDG.h>
11#include <TLorentzVector.h>
13#include <TParticlePDG.h>
20#include "OTFEventGenerator.h"
26 EventGeneratorDecay::EventGeneratorDecay() {}
28 Bool_t EventGeneratorDecay::Init() {
29 auto init = HalOTF::EventGenerator::Init();
30 if (!init)
return init;
35 auto stat = fDecayer->
Init();
44 for (
int i = 0; i < 3; i++) {
50 void EventGeneratorDecay::SetDecay(
Hal::Decay decay) {
51 if (fDecayer)
delete fDecayer;
55 void EventGeneratorDecay::Decay() {
56 Int_t shift = fMcEvent->GetNTracks();
57 Int_t start = shift - fCurrrentMult;
58 TDatabasePDG* db = TDatabasePDG::Instance();
62 double px = tr.GetMomentum().Px();
63 double py = tr.GetMomentum().Py();
64 double pz = tr.GetMomentum().Pz();
65 px = px + gRandom->Gaus(0, fSmear) * px;
66 py = py + gRandom->Gaus(0, fSmear) * py;
67 pz = pz + gRandom->Gaus(0, fSmear) * pz;
68 Double_t e = TMath::Sqrt(px * px + py * py + pz * pz + fMass * fMass);
69 rtr.SetMom(px, py, pz, e);
72 auto pid = db->GetParticle(tr.GetPdgCode());
74 rtr.SetCharge(pid->Charge() / 3.0);
82 trx.SetMomentum(tr.GetMomentum());
83 trx.SetFreezout(tr.GetFreezoutPosition());
84 trx.SetPdgCode(tr.GetPdg());
85 trx.SetMotherId(tr.GetMotherIndex());
91 for (
int i = start; i < shift; i++) {
92 auto track = fMcEvent->GetTrack(i);
94 mommy.
SetMomentum(track->GetMomentum().X(), track->GetMomentum().Y(), track->GetMomentum().Z(), track->GetMomentum().T());
96 track->GetFreezout().X(), track->GetFreezout().Y(), track->GetFreezout().Z(), track->GetFreezout().T());
97 mommy.SetPdg(track->GetPdgCode());
98 int nDau = fDecayer->
DecayParticle(mommy, fDaughters, kFALSE);
100 for (
int j = 0; j < nDau; j++) {
101 auto dau = fDaughters[j];
102 dau->SetMotherIndex(i);
103 auto daughter = makeSim(*dau);
104 fMcEvent->AddTrack(daughter);
105 auto reco = makeReco(daughter);
106 reco.SetMcIndex(fMcEvent->GetNTracks() - 1);
107 fRecoEvent->AddTrack(reco);
112 EventGeneratorDecay::~EventGeneratorDecay() {
113 for (
auto i : fDaughters)
115 if (fDecayer)
delete fDecayer;
118 void EventGeneratorDecay::GenerateEvent() {
119 HalOTF::EventGenerator::GenerateEvent();
122 std::cout <<
"MC Tracks" << std::endl;
124 for (
int i = 0; i < fMcEvent->GetNTracks(); i++) {
125 auto mcTrack = fMcEvent->GetTrack(i);
127 Form(
"%4.2f", mcTrack->GetMomentum().Px()),
128 Form(
"%i", mcTrack->GetPdgCode()),
129 Form(
"%i", mcTrack->GetMotherId())});
131 std::cout <<
"Reco Tracks" << std::endl;
133 for (
int i = 0; i < fRecoEvent->GetNTracks(); i++) {
134 auto recoTrack = fRecoEvent->GetTrack(i);
136 auto simTrack = fMcEvent->GetTrack(recoTrack->GetMcIndex());
139 Form(
"%4.2f", recoTrack->GetMom().Px()),
140 Form(
"%4.2f", simTrack->GetMomentum().Px()),
141 Form(
"%i", simTrack->GetPdgCode()),
142 Form(
"%i", recoTrack->GetMcIndex())});
144 std::cout <<
"-----" << std::endl;
static void PrintInfo(TString text, Hal::EInfo status)
static void Database(Int_t no...)
virtual Int_t DecayParticle(McTrack &mother, std::vector< McTrack * > &daughters, Bool_t addToEvent=kFALSE) const
Int_t GetMotherPdg() const
void SetFreezoutPosition(Double_t x, Double_t y, Double_t z, Double_t t)
void SetMomentum(Double_t px, Double_t py, Double_t pz, Double_t e)