11#include "DbgMcEvent.h"
12#include "DbgRecoEvent.h"
15#include "DataManager.h"
21#include <TDatabasePDG.h>
22#include <TLorentzVector.h>
25#include <TParticlePDG.h>
36 fSpectras =
new TH2D(
"spec",
"spec", 1, 0, 1, 1, -1, 1);
37 fSpectras->SetBinContent(1, 1, 1);
40 if (mng->GetObject(
"Dbg::McEvent.")) {
41 fMcEvent = (
Dbg::McEvent*) mng->GetObject(
"Dbg::McEvent.");
45 mng->
Register(
"Dbg::McEvent.",
"HalEvents", fMcEvent, fRegister);
46 mng->
Register(
"Dbg::RecoEvent.",
"HalEvents", fRecoEvent, fRegister);
48 return Hal::Task::EInitFlag::kSUCCESS;
52 TH2D* copy = (TH2D*) h.Clone();
53 TDatabasePDG* pdg = TDatabasePDG::Instance();
54 TParticlePDG* part = pdg->GetParticle(pid);
55 if (part ==
nullptr) {
59 copy->SetDirectory(
nullptr);
64 fCharge = part->Charge() * 3;
67 void Reader::Exec(Option_t* ) {
72 Int_t runId = fCount % fModuloCount;
73 fRecoEvent->SetEventId(runId);
74 fMcEvent->SetEventId(runId);
77 Int_t shift = fMcEvent->GetNTracks();
78 for (
int i = 0; i < fMultiplicity; i++) {
80 fSpectras->GetRandom2(y, pt);
81 Double_t mt = TMath::Sqrt(pt * pt + fMass * fMass);
82 Double_t phi = gRandom->Uniform(-TMath::Pi(), TMath::Pi());
83 Double_t px = pt * TMath::Cos(phi);
84 Double_t py = pt * TMath::Sin(phi);
85 Double_t pz = mt * TMath::SinH(y);
89 p.SetXYZM(px, py, pz, fMass);
92 TLorentzVector xr(gRandom->Gaus(0, 1), gRandom->Gaus(0, 1), gRandom->Gaus(0), 0);
94 fMcEvent->AddTrack(tr);
97 px = px + gRandom->Gaus(0, fSmear) * px;
98 py = py + gRandom->Gaus(0, fSmear) * py;
99 pz = pz + gRandom->Gaus(0, fSmear) * pz;
100 Double_t e = TMath::Sqrt(px * px + py * py + pz * pz + fMass * fMass);
101 rtr.SetMom(px, py, pz, e);
103 rtr.SetCharge(fCharge);
104 rtr.SetMcIndex(i + shift);
105 fRecoEvent->AddTrack(rtr);
110 if (fSpectras)
delete fSpectras;
111 if (fOwner && !fRegister) {
112 if (fMcEvent)
delete fMcEvent;
113 if (fRecoEvent)
delete fRecoEvent;
void SetSpiecies(const TH2D &h, Int_t pid, Double_t multiplicity)
virtual Hal::Task::EInitFlag Init()
static void PrintInfo(TString text, Hal::EInfo status)
void Register(const char *name, const char *folderName, TNamed *obj, Bool_t toFile)