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