42 LOG(debug) <<
" THIS IS A TEST -> CbmFsdHitsConverter is being initialized LUKAS" << std::endl;
45 auto* ioman = FairRootManager::Instance();
58 LOG(error) <<
" No FsdDigiMatch input array present !!";
67 AnalysisTree::BranchConfig fsd_branch(
out_branch_, AnalysisTree::DetType::kHit);
69 fsd_branch.AddField<
float>(
"dEdx",
"Energy deposition of given FSD hit [GeV]");
70 fsd_branch.AddField<
float>(
"t",
"Reconstructed time of given FSD hit [ps]");
71 fsd_branch.AddField<
float>(
"mass2",
"Calculated mass squared from extrapolated global track (by CbmKFTrack) to FSD "
72 "plane and FSD hit time [GeV^2/c^4]");
73 fsd_branch.AddField<
float>(
"l",
"Lenght of the extrapolated global track (by CbmKFTrack) to FSD plane [cm]");
74 fsd_branch.AddField<
float>(
75 "qp",
"charge * momentum of the extrapoleted global track (by CbmKFTrack) to FSD plane [GeV/c]");
76 fsd_branch.AddFields<
float>(
78 "Component of a 3D distance between FSD hit and extrapolated global track (by CbmKFTrack) [cm]");
79 fsd_branch.AddField<
float>(
80 "chi2GtrackHit",
"chi2 between extrapolated global track (by CbmKFTrack) to FSD plane (?FIXED Z?) and FSD hit");
81 fsd_branch.AddField<
int>(
82 "bestMatchedGtrack2HitId",
83 "Index of best match between extrapolated global track (by CbmKFTrack) and FSD hit based on min chi2GtrackHit");
84 fsd_branch.AddField<
int>(
"multMCtracks",
"number of MC particles that cotributed by energy deposition to FSD hit");
85 fsd_branch.AddField<
float>(
"maxWeightMCtrack",
86 "weight of matched link from Hit to Point (?highest energy deposition?)");
87 fsd_branch.AddField<
float>(
"dtHitPoint",
"Time difference between FSD hit and matched MC point [ps]");
88 fsd_branch.AddFields<
float>({
"dxHitPoint",
"dyHitPoint",
"dzHitPoint"},
89 "Component of a 3D distance between FSD hit and matched MC point [cm]");
90 fsd_branch.AddFields<
float>({
"xPoint",
"yPoint",
"zPoint"},
"MC point distribution [cm]");
91 fsd_branch.AddFields<
float>({
"pxPoint",
"pyPoint",
"pzPoint"},
"MC point momentum");
92 fsd_branch.AddField<
float>({
"phiPoint"},
"Angle of the point");
93 fsd_branch.AddField<
float>({
"lengthPoint"},
"Lenght of the point");
94 fsd_branch.AddField<
float>({
"tPoint"},
"Time of the point");
95 fsd_branch.AddField<
float>({
"elossPoint"},
"Energy loss of the point");
96 fsd_branch.AddField<
float>({
"dist_middle_x"},
"Absolute value of the hit distance x from zero");
97 fsd_branch.AddField<
float>({
"dist_middle_y"},
"Absolute value of the hit distance y from zero");
100 i_edep_ = fsd_branch.GetFieldId(
"dEdx");
101 i_t_ = fsd_branch.GetFieldId(
"t");
102 i_mass2_ = fsd_branch.GetFieldId(
"mass2");
103 i_qp_ = fsd_branch.GetFieldId(
"qp");
104 i_dx_ = fsd_branch.GetFieldId(
"dx");
105 i_l_ = fsd_branch.GetFieldId(
"l");
106 i_dtHP_ = fsd_branch.GetFieldId(
"dtHitPoint");
107 i_dxHP_ = fsd_branch.GetFieldId(
"dxHitPoint");
108 i_chi2_ = fsd_branch.GetFieldId(
"chi2GtrackHit");
110 i_multMC_ = fsd_branch.GetFieldId(
"multMCtracks");
111 i_topW_ = fsd_branch.GetFieldId(
"maxWeightMCtrack");
112 i_xpoint_ = fsd_branch.GetFieldId(
"xPoint");
113 i_pxpoint_ = fsd_branch.GetFieldId(
"pxPoint");
116 i_tpoint_ = fsd_branch.GetFieldId(
"tPoint");
117 i_eloss_ = fsd_branch.GetFieldId(
"elossPoint");
125 auto* man = AnalysisTree::TaskManager::GetInstance();
165 auto* out_config_ = AnalysisTree::TaskManager::GetInstance()->GetConfig();
166 const auto& branch = out_config_->GetBranchConfig(
out_branch_);
171 int file_id{0}, event_id{0};
173 auto match =
event->GetMatch();
175 file_id =
event->GetMatch()->GetMatchedLink().GetFile();
176 event_id =
event->GetMatch()->GetMatchedLink().GetEntry();
179 event_id = FairRootManager::Instance()->GetEntryNr();
183 if (n_fsd_hits <= 0) {
184 LOG(warn) <<
"No FSD hits!";
190 LOG(warn) <<
"No Global Tracks!";
198 for (Int_t ifh = 0; ifh < n_fsd_hits; ifh++) {
202 auto& hit =
fsd_hits_->AddChannel(branch);
204 const Float_t hitX = fsdHit->
GetX();
205 const Float_t hitY = fsdHit->GetY();
206 const Float_t hitZ = fsdHit->GetZ();
207 const Float_t eLoss = fsdHit->GetEdep();
208 const Float_t time = fsdHit->GetTime();
210 const Float_t dist_x = std::fabs(fsdHit->GetX());
211 const Float_t dist_y = std::fabs(fsdHit->GetY());
216 hit.SetPosition(hitX, hitY, hitZ);
220 Float_t phi_hit = atan2(fsdHit->GetY(), fsdHit->GetX());
222 phi_hit = phi_hit + 2 * 3.1415;
227 Float_t highestWeight = 0.;
229 if (fsdHitMatch && fsdHitMatch->GetNofLinks() > 0) {
230 highestWeight = fsdHitMatch->GetMatchedLink().GetWeight();
232 for (int32_t ilDigi = 0; ilDigi < fsdHitMatch->GetNofLinks(); ilDigi++) {
233 const auto& digiLink = fsdHitMatch->GetLink(ilDigi);
234 if (digiLink.GetFile() != file_id || digiLink.GetEntry() != event_id) {
239 if (fsdDigiMatch && fsdDigiMatch->GetNofLinks() > 0) {
240 for (int32_t ilPoint = 0; ilPoint < fsdDigiMatch->GetNofLinks(); ilPoint++) {
241 const auto& pointLink = fsdDigiMatch->GetLink(ilPoint);
242 if (pointLink.GetFile() != file_id || pointLink.GetEntry() != event_id) {
250 Int_t mc_track_id = fsdPoint->GetTrackID();
251 if (mc_track_id >= 0) {
252 auto it = sim_tracks_map.find(mc_track_id);
253 if (it != sim_tracks_map.end()) {
261 hit.SetField(
float(fsdPoint->GetTime() - time),
i_dtHP_);
262 hit.SetField(
float(fsdPoint->GetX() - hitX),
i_dxHP_);
263 hit.SetField(
float(fsdPoint->GetY() - hitY),
i_dxHP_ + 1);
264 hit.SetField(
float(fsdPoint->GetZ() - hitZ),
i_dxHP_ + 2);
265 hit.SetField(
float(fsdPoint->GetEnergyLoss()),
i_eloss_);
267 hit.SetField(
float(fsdPoint->GetX()),
i_xpoint_);
268 hit.SetField(
float(fsdPoint->GetY()),
i_xpoint_ + 1);
269 hit.SetField(
float(fsdPoint->GetZ()),
i_xpoint_ + 2);
271 hit.SetField(
float(fsdPoint->GetPx()),
i_pxpoint_);
272 hit.SetField(
float(fsdPoint->GetPy()),
i_pxpoint_ + 1);
273 hit.SetField(
float(fsdPoint->GetPz()),
i_pxpoint_ + 2);
275 Float_t phi_point = atan2(fsdPoint->GetY(), fsdPoint->GetX());
277 phi_point = phi_point + 2 * 3.1415;
280 hit.SetField(
float(fsdPoint->GetTime()),
i_tpoint_);
289 const Int_t hitMCmult = multMC;
290 const Float_t hitTopWeight = highestWeight;
292 hit.SetField(hitTopWeight,
i_topW_);
295 Int_t bestMatchedIndex = -1;
296 Double_t bestChi2 = 0.;
297 for (Int_t igt = 0; igt < n_tracks; igt++) {
300 FairTrackParam param_last = *(globalTrack->GetParamLast());
304 if (bestChi2 > matchingChi2 || bestMatchedIndex < 0) {
305 bestChi2 = matchingChi2;
306 bestMatchedIndex = trackIndex;
310 hit.SetField(
static_cast<Float_t
>(bestChi2),
i_chi2_);
315 FairTrackParam param_last = *(globalTrack->GetParamLast());
319 param_fsd.Momentum(p_fsd);
321 const Float_t p = p_fsd.Mag();
322 const Int_t q = param_fsd.GetQp() > 0 ? 1 : -1;
323 const Float_t l = globalTrack->GetLength();
324 const Float_t beta =
event ? l / ((time -
event->GetTzero()) * 29.9792458) : 0;
325 const Float_t m2 =
event ? p * p * (1. / (beta * beta) - 1.) : -1.;
328 hit.SetField(
float(q * p),
i_qp_);
329 hit.SetField(
float(param_fsd.GetX() - hitX),
i_dx_);
330 hit.SetField(
float(param_fsd.GetY() - hitY),
i_dx_ + 1);
331 hit.SetField(
float(param_fsd.GetZ() - hitZ),
i_dx_ + 2);
332 hit.SetField(l,
i_l_);
333 hit.SetField(time,
i_t_);
335 if (rec_tracks_map.empty()) {
338 const Int_t stsTrackIndex = globalTrack->GetStsTrackIndex();
339 if (rec_tracks_map.find(stsTrackIndex) != rec_tracks_map.end()) {
340 vtx_tracks_2_fsd_->AddMatch(rec_tracks_map.find(stsTrackIndex)->second, hit.GetId());