62 auto* ioman = FairRootManager::Instance();
64 cbm_header_ = (FairMCEventHeader*) ioman->GetObject(
"MCEventHeader.");
69 AnalysisTree::BranchConfig sim_particles_branch(
out_branch_, AnalysisTree::DetType::kParticle);
70 sim_particles_branch.AddField<
int>(
"mother_id",
"id of mother particle, -1 for primaries");
71 sim_particles_branch.AddField<
int>(
"cbmroot_id",
"track id in CbmRoot transport file");
72 sim_particles_branch.AddField<
int>(
"geant_process_id",
"process id within geant transport");
73 sim_particles_branch.AddField<
int>(
"gen_parent_id",
74 "parent id of mother particles already decayed by event generator (from Unigen)");
75 sim_particles_branch.AddField<
int>(
"gen_decay_id",
76 "decay id of particles already decayed by event generator (from Unigen)");
77 sim_particles_branch.AddFields<
int>({
"n_hits_mvd",
"n_hits_sts",
"n_hits_trd"},
"Number of hits in the detector");
84 sim_particles_branch.AddFields<
float>({
"start_x",
"start_y",
"start_z"},
"Start position, cm");
85 sim_particles_branch.AddField<
float>(
"start_t",
"t freezout coordinate fm/c");
87 imother_id_ = sim_particles_branch.GetFieldId(
"mother_id");
88 igeant_id_ = sim_particles_branch.GetFieldId(
"geant_process_id");
89 iparent_id_ = sim_particles_branch.GetFieldId(
"gen_parent_id");
90 idecay_id_ = sim_particles_branch.GetFieldId(
"gen_decay_id");
91 in_hits_ = sim_particles_branch.GetFieldId(
"n_hits_mvd");
92 icbm_id_ = sim_particles_branch.GetFieldId(
"cbmroot_id");
93 istart_x_ = sim_particles_branch.GetFieldId(
"start_x");
95 auto* man = AnalysisTree::TaskManager::GetInstance();
104 float delta_phi {0.f};
109 delta_phi = mc_phi - unigen_phi;
113 auto* out_config_ = AnalysisTree::TaskManager::GetInstance()->GetConfig();
114 const auto& branch = out_config_->GetBranchConfig(
out_branch_);
116 int file_id {0}, event_id {0};
118 file_id =
event->GetMatch()->GetMatchedLink().GetFile();
119 event_id =
event->GetMatch()->GetMatchedLink().GetEntry();
122 event_id = FairRootManager::Instance()->GetEntryNr();
125 LOG(info) <<
"Writing MC-tracks from event # " << event_id <<
" file " << file_id;
129 if (nMcTracks <= 0) {
130 LOG(warn) <<
"No MC tracks!";
136 const Double_t nsTofmc = 1. / (0.3356 * 1
E-15);
138 for (
int iMcTrack = 0; iMcTrack < nMcTracks; ++iMcTrack) {
139 const auto trackIndex = iMcTrack;
141 if (mctrack->GetPdgCode() == 50000050) {
148 track.SetMomentum(mctrack->GetPx(), mctrack->GetPy(), mctrack->GetPz());
149 track.SetMass(
float(mctrack->GetMass()));
150 track.SetPid(
int(mctrack->GetPdgCode()));
151 track.SetField(
int(mctrack->GetGeantProcessId()),
igeant_id_);
155 track.SetField(
int(mctrack->GetUniqueID()),
icbm_id_);
157 if (mctrack->GetMotherId() >= 0) {
166 if (
use_unigen_ && trackIndex < unigen_event_->GetNpa()) {
173 boostedX.RotateZ(delta_phi);
174 track.SetField(
float(boostedX.X() * 1e-13),
istart_x_);
175 track.SetField(
float(boostedX.Y() * 1e-13),
istart_x_ + 1);
176 track.SetField(
float(boostedX.Z() * 1e-13),
istart_x_ + 2);
177 track.SetField(
float(boostedX.T()),
istart_x_ + 3);
190 if (mctrack->GetMotherId() == -1) { track.SetField(
int(-1),
imother_id_); }
TLorentzVector GetPosition() const