4 #include "TClonesArray.h"
6 #include <FairMCPoint.h>
7 #include <FairRootManager.h>
9 #include "AnalysisTree/Matching.hpp"
13 #include <CbmTofHit.h>
22 assert(!in_branches_.empty() && !out_branch_.empty() && out_config_
24 auto* ioman = FairRootManager::Instance();
33 AnalysisTree::BranchConfig tof_branch(
"TofHits", AnalysisTree::DetType::kHit);
34 tof_branch.AddField<
float>(
"mass2");
35 tof_branch.AddField<
float>(
"l");
36 tof_branch.AddField<
float>(
"t");
37 tof_branch.AddField<
float>(
"qp_tof");
38 tof_branch.AddFields<
float>({
"dx",
"dy",
"dz"});
39 tof_branch.AddField<
int>(
"mc_pdg");
40 tof_branch.AddField<
bool>(
"is_correct_match");
41 out_config_->AddBranchConfig(std::move(tof_branch));
42 tof_hits_ =
new AnalysisTree::HitDetector(out_config_->GetLastId());
45 out_config_->GetBranchConfig(
match_to_).GetId(), out_config_->GetLastId());
49 out_branch_.c_str(),
"AnalysisTree::HitDetector", &
tof_hits_);
50 out_tree_->Branch((
match_to_ +
"2" + out_branch_).c_str(),
51 "AnalysisTree::Matching",
58 const Float_t Tx = params->GetTx();
59 const Float_t Ty = params->GetTy();
60 const Float_t old_z = params->GetZ();
61 const Float_t dz = z - old_z;
63 const Float_t
x = params->GetX() + Tx * dz;
64 const Float_t
y = params->GetY() + Ty * dz;
66 params->SetPosition({
x,
y, z});
75 out_config_->GetBranchConfig(
tof_hits_->GetId()).GetFieldId(
"mass2");
77 out_config_->GetBranchConfig(
tof_hits_->GetId()).GetFieldId(
"qp_tof");
79 out_config_->GetBranchConfig(
tof_hits_->GetId()).GetFieldId(
"dx");
81 out_config_->GetBranchConfig(
tof_hits_->GetId()).GetFieldId(
"t");
83 out_config_->GetBranchConfig(
tof_hits_->GetId()).GetFieldId(
"l");
92 +
" is not found to match with TOF hits");
94 auto rec_tracks_map = it->second;
99 const auto* globalTrack =
102 if (tofHitIndex < 0)
continue;
107 FairTrackParam param_last = *(globalTrack->GetParamLast());
109 param_last.Momentum(p_tof);
111 const Float_t p = p_tof.Mag();
112 const Int_t q = param_last.GetQp() > 0 ? 1 : -1;
114 globalTrack->GetLength();
115 const Float_t time = tofHit->
GetTime();
116 const Float_t beta = l / (time * 29.9792458);
117 const Float_t m2 = p * p * (1. / (beta * beta) - 1.);
119 const Float_t hitX = tofHit->GetX();
120 const Float_t hitY = tofHit->GetY();
121 const Float_t hitZ = tofHit->GetZ();
126 Hit->Init(out_config_->GetBranchConfig(
tof_hits_->GetId()));
127 Hit->SetPosition(hitX, hitY, hitZ);
128 Hit->SetSignal(time);
129 Hit->SetField(m2, i_mass2);
130 Hit->SetField(
float(q * p_tof.Mag()), i_qp);
131 Hit->SetField(
float(param_last.GetX() - hitX), i_dx);
132 Hit->SetField(
float(param_last.GetY() - hitY), i_dx + 1);
133 Hit->SetField(
float(param_last.GetZ() - hitZ), i_dx + 2);
134 Hit->SetField(l, i_l);
135 Hit->SetField(time, i_t);
137 if (rec_tracks_map.empty()) {
return; }
138 const Int_t stsTrackIndex = globalTrack->GetStsTrackIndex();
139 if (rec_tracks_map.find(stsTrackIndex) != rec_tracks_map.end()) {