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",
"");
73 sim_particles_branch.AddFields<
int>({
"n_hits_mvd",
"n_hits_sts",
"n_hits_trd"},
"Number of hits in the detector");
80 sim_particles_branch.AddFields<
float>({
"start_x",
"start_y",
"start_z"},
"Start position, cm");
81 sim_particles_branch.AddField<
float>(
"start_t",
"t freezout coordinate fm/c");
83 imother_id_ = sim_particles_branch.GetFieldId(
"mother_id");
84 igeant_id_ = sim_particles_branch.GetFieldId(
"geant_process_id");
85 in_hits_ = sim_particles_branch.GetFieldId(
"n_hits_mvd");
86 icbm_id_ = sim_particles_branch.GetFieldId(
"cbmroot_id");
87 istart_x_ = sim_particles_branch.GetFieldId(
"start_x");
89 auto* man = AnalysisTree::TaskManager::GetInstance();
98 float delta_phi {0.f};
103 delta_phi = mc_phi - unigen_phi;
107 auto* out_config_ = AnalysisTree::TaskManager::GetInstance()->GetConfig();
108 const auto& branch = out_config_->GetBranchConfig(
out_branch_);
110 int file_id {0}, event_id {0};
112 file_id =
event->GetMatch()->GetMatchedLink().GetFile();
113 event_id =
event->GetMatch()->GetMatchedLink().GetEntry();
116 event_id = FairRootManager::Instance()->GetEntryNr();
119 LOG(info) <<
"Writing MC-tracks from event # " << event_id <<
" file " << file_id;
123 if (nMcTracks <= 0) {
124 LOG(warn) <<
"No MC tracks!";
130 const Double_t nsTofmc = 1. / (0.3356 * 1E-15);
132 for (
int iMcTrack = 0; iMcTrack < nMcTracks; ++iMcTrack) {
133 const auto trackIndex = iMcTrack;
135 if (mctrack->GetPdgCode() == 50000050) {
142 track.SetMomentum(mctrack->GetPx(), mctrack->GetPy(), mctrack->GetPz());
143 track.SetMass(
float(mctrack->GetMass()));
144 track.SetPid(
int(mctrack->GetPdgCode()));
145 track.SetField(
int(mctrack->GetGeantProcessId()),
igeant_id_);
149 track.SetField(
int(mctrack->GetUniqueID()),
icbm_id_);
151 if (mctrack->GetMotherId() >= 0) {
158 if (
use_unigen_ && trackIndex < unigen_event_->GetNpa()) {
162 boostedX.RotateZ(delta_phi);
163 track.SetField(
float(boostedX.X() * 1e-13),
istart_x_);
164 track.SetField(
float(boostedX.Y() * 1e-13),
istart_x_ + 1);
165 track.SetField(
float(boostedX.Z() * 1e-13),
istart_x_ + 2);
166 track.SetField(
float(boostedX.T()),
istart_x_ + 3);
177 if (mctrack->GetMotherId() == -1) { track.SetField(
int(-1),
imother_id_); }
TLorentzVector GetPosition() const