30 auto* ioman = FairRootManager::Instance();
42 AnalysisTree::BranchConfig tof_branch(
out_branch_, AnalysisTree::DetType::kHit);
43 tof_branch.AddField<
float>(
"mass2",
"Mass squared");
44 tof_branch.AddField<
float>(
"l",
"Track lenght");
45 tof_branch.AddField<
float>(
"t",
"ps(?), Measured time ");
46 tof_branch.AddField<
float>(
"qp_tof",
"charge * momentum extrapoleted to TOF");
47 tof_branch.AddFields<
float>({
"dx",
"dy",
"dz"},
"Distance between TOF hit and extrapolated global track, cm");
49 i_mass2_ = tof_branch.GetFieldId(
"mass2");
50 i_qp_ = tof_branch.GetFieldId(
"qp_tof");
51 i_dx_ = tof_branch.GetFieldId(
"dx");
52 i_t_ = tof_branch.GetFieldId(
"t");
53 i_l_ = tof_branch.GetFieldId(
"l");
55 auto* man = AnalysisTree::TaskManager::GetInstance();
81 auto* out_config_ = AnalysisTree::TaskManager::GetInstance()->GetConfig();
82 const auto& branch = out_config_->GetBranchConfig(
out_branch_);
87 int file_id {0}, event_id {0};
89 file_id =
event->GetMatch()->GetMatchedLink().GetFile();
90 event_id =
event->GetMatch()->GetMatchedLink().GetEntry();
93 event_id = FairRootManager::Instance()->GetEntryNr();
100 LOG(warn) <<
"No global tracks!";
105 for (Int_t igt = 0; igt < n_tracks; igt++) {
109 if (tofHitIndex < 0)
continue;
113 FairTrackParam param_last = *(globalTrack->GetParamLast());
115 param_last.Momentum(p_tof);
117 const Float_t p = p_tof.Mag();
118 const Int_t q = param_last.GetQp() > 0 ? 1 : -1;
119 const Float_t l = globalTrack->GetLength();
120 const Float_t time = tofHit->GetTime();
121 const Float_t beta =
event ? l / ((time -
event->GetTzero()) * 29.9792458) : 0;
122 const Float_t m2 =
event ? p * p * (1. / (beta * beta) - 1.) : -1.;
124 const Float_t hitX = tofHit->GetX();
125 const Float_t hitY = tofHit->GetY();
126 const Float_t hitZ = tofHit->GetZ();
130 auto& hit =
tof_hits_->AddChannel(branch);
131 hit.SetPosition(hitX, hitY, hitZ);
134 hit.SetField(
float(q * p_tof.Mag()),
i_qp_);
135 hit.SetField(
float(param_last.GetX() - hitX),
i_dx_);
136 hit.SetField(
float(param_last.GetY() - hitY),
i_dx_ + 1);
137 hit.SetField(
float(param_last.GetZ() - hitZ),
i_dx_ + 2);
138 hit.SetField(l,
i_l_);
139 hit.SetField(time,
i_t_);
141 if (rec_tracks_map.empty()) {
continue; }
142 const Int_t stsTrackIndex = globalTrack->GetStsTrackIndex();
143 if (rec_tracks_map.find(stsTrackIndex) != rec_tracks_map.end()) {
144 vtx_tracks_2_tof_->AddMatch(rec_tracks_map.find(stsTrackIndex)->second, hit.GetId());
148 if (tofMatch && tofMatch->GetNofLinks() > 0) {
149 const auto& link = tofMatch->GetMatchedLink();
150 if (link.GetFile() != file_id || link.GetEntry() != event_id) {
151 LOG(warn) <<
"match from different event";
157 if (!tofPoint) {
throw std::runtime_error(
"no TOF point"); }
159 Int_t mc_track_id = tofPoint->GetTrackID();
160 if (mc_track_id >= 0) {
161 auto it = sim_tracks_map.find(mc_track_id);
162 if (it != sim_tracks_map.end()) {