29 ~ToyMC()
override =
default;
31 void Init()
override {
35 BranchConfig sim_eh(
"SimEventHeader", DetType::kEventHeader);
36 sim_eh.AddField<
float>(
"psi_RP",
"Reaction Plane angle");
38 BranchConfig sim_part(
"SimParticles", DetType::kParticle);
39 sim_part.AddField<
float>(
"float",
"test field");
40 sim_part.AddField<
bool>(
"bool",
"test field");
41 sim_part.AddField<
int>(
"int",
"test field");
43 man->AddBranch(sim_event_header_, sim_eh);
44 man->AddBranch(particles_, sim_part);
45 man->AddBranch(track_detector_,
BranchConfig{
"RecTracks", DetType::kTrack});
46 man->AddMatching(
"RecTracks",
"SimParticles", rec_tracks_to_sim_);
48 sim_event_header_->Init(sim_eh);
51 void Exec()
override {
57 void Finish()
override {
60 void FillEventInfo() {
61 sim_event_header_->SetVertexPosition3({0, 0, 0});
62 sim_event_header_->SetField(psi_RP_(generator_), 0);
65 void FillMcParticles() {
67 particles_->ClearChannels();
69 const auto& branch = config_->GetBranchConfig(particles_->GetId());
70 const int multiplicity = multiplicity_(generator_);
71 particles_->Reserve(multiplicity);
73 for (
int i = 0; i < multiplicity; ++i) {
75 const float phi = GetPhi(generator_, sim_event_header_->GetField<
float>(0));
76 const float pT = pT_dist_(generator_);
77 const float eta = y_dist_(generator_);
81 mom.SetPtEtaPhi(pT, eta, phi);
83 auto& particle = particles_->AddChannel(branch);
85 particle.SetMomentum3(mom);
90 void FillRecoTracks() {
94 track_detector_->ClearChannels();
95 rec_tracks_to_sim_->Clear();
97 track_detector_->Reserve(particles_->GetNumberOfChannels());
98 const auto& branch = config_->GetBranchConfig(track_detector_->GetId());
100 for (
const auto& particle : *particles_) {
101 auto& track = track_detector_->AddChannel(branch);
103 rec_tracks_to_sim_->AddMatch(track.GetId(), particle.GetId());
108 RandomEngine generator_;
112 std::poisson_distribution<int> multiplicity_{100};
113 std::uniform_real_distribution<float> psi_RP_{-M_PI, M_PI};
114 std::vector<float> vn_{0.2, 0.1};
115 float cm_rapidity_{0.f};
119 std::exponential_distribution<float> pT_dist_{1.};
120 std::normal_distribution<float> y_dist_{cm_rapidity_, 1.};
121 std::piecewise_linear_distribution<> phi_distr_{1000, 0, 2 * M_PI,
122 [&](
const double phi) {
124 for (
unsigned int n = 1; n < vn_.size() + 1; ++n) {
125 value += 2 * vn_[n - 1] * std::cos(n * (phi - 0.));
132 Matching* rec_tracks_to_sim_{
nullptr};
134 TH2* efficiency_map_{
nullptr};
136 float GetPhi(RandomEngine& engine,
float psi) {
137 return phi_distr_(engine) + psi;