41 LOG(debug) <<
" THIS IS A TEST -> CbmFsdHitsConverter is being initialized LUKAS" << std::endl;
44 auto* ioman = FairRootManager::Instance();
57 LOG(error) <<
" No FsdDigiMatch input array present !!";
66 AnalysisTree::BranchConfig fsd_branch(
out_branch_, AnalysisTree::DetType::kHit);
68 fsd_branch.AddField<
float>(
"dEdx",
"Energy deposition of given FSD hit [GeV]");
69 fsd_branch.AddField<
float>(
"t",
"Reconstructed time of given FSD hit [ps]");
70 fsd_branch.AddField<
float>(
"mass2",
"Calculated mass squared from extrapolated global track (by CbmKFTrack) to FSD "
71 "plane and FSD hit time [GeV^2/c^4]");
72 fsd_branch.AddField<
float>(
"l",
"Lenght of the extrapolated global track (by CbmKFTrack) to FSD plane [cm]");
73 fsd_branch.AddField<
float>(
74 "qp",
"charge * momentum of the extrapoleted global track (by CbmKFTrack) to FSD plane [GeV/c]");
75 fsd_branch.AddFields<
float>(
77 "Component of a 3D distance between FSD hit and extrapolated global track (by CbmKFTrack) [cm]");
78 fsd_branch.AddField<
float>(
79 "chi2GtrackHit",
"chi2 between extrapolated global track (by CbmKFTrack) to FSD plane (?FIXED Z?) and FSD hit");
80 fsd_branch.AddField<
int>(
81 "bestMatchedGtrack2HitId",
82 "Index of best match between extrapolated global track (by CbmKFTrack) and FSD hit based on min chi2GtrackHit");
83 fsd_branch.AddField<
int>(
"multMCtracks",
"number of MC particles that cotributed by energy deposition to FSD hit");
84 fsd_branch.AddField<
float>(
"maxWeightMCtrack",
85 "weight of matched link from Hit to Point (?highest energy deposition?)");
86 fsd_branch.AddField<
float>(
"dtHitPoint",
"Time difference between FSD hit and matched MC point [ps]");
87 fsd_branch.AddFields<
float>({
"dxHitPoint",
"dyHitPoint",
"dzHitPoint"},
88 "Component of a 3D distance between FSD hit and matched MC point [cm]");
89 fsd_branch.AddFields<
float>({
"xPoint",
"yPoint",
"zPoint"},
"MC point distribution [cm]");
90 fsd_branch.AddFields<
float>({
"pxPoint",
"pyPoint",
"pzPoint"},
"MC point momentum");
91 fsd_branch.AddField<
float>({
"phiPoint"},
"Angle of the point");
92 fsd_branch.AddField<
float>({
"lengthPoint"},
"Lenght of the point");
93 fsd_branch.AddField<
float>({
"tPoint"},
"Time of the point");
94 fsd_branch.AddField<
float>({
"elossPoint"},
"Energy loss of the point");
95 fsd_branch.AddField<
float>({
"dist_middle_x"},
"Absolute value of the hit distance x from zero");
96 fsd_branch.AddField<
float>({
"dist_middle_y"},
"Absolute value of the hit distance y from zero");
99 i_edep_ = fsd_branch.GetFieldId(
"dEdx");
100 i_t_ = fsd_branch.GetFieldId(
"t");
101 i_mass2_ = fsd_branch.GetFieldId(
"mass2");
102 i_qp_ = fsd_branch.GetFieldId(
"qp");
103 i_dx_ = fsd_branch.GetFieldId(
"dx");
104 i_l_ = fsd_branch.GetFieldId(
"l");
105 i_dtHP_ = fsd_branch.GetFieldId(
"dtHitPoint");
106 i_dxHP_ = fsd_branch.GetFieldId(
"dxHitPoint");
107 i_chi2_ = fsd_branch.GetFieldId(
"chi2GtrackHit");
109 i_multMC_ = fsd_branch.GetFieldId(
"multMCtracks");
110 i_topW_ = fsd_branch.GetFieldId(
"maxWeightMCtrack");
111 i_xpoint_ = fsd_branch.GetFieldId(
"xPoint");
112 i_pxpoint_ = fsd_branch.GetFieldId(
"pxPoint");
115 i_tpoint_ = fsd_branch.GetFieldId(
"tPoint");
116 i_eloss_ = fsd_branch.GetFieldId(
"elossPoint");
124 auto* man = AnalysisTree::TaskManager::GetInstance();
164 auto* out_config_ = AnalysisTree::TaskManager::GetInstance()->GetConfig();
165 const auto& branch = out_config_->GetBranchConfig(
out_branch_);
170 int file_id{0}, event_id{0};
172 auto match =
event->GetMatch();
174 file_id =
event->GetMatch()->GetMatchedLink().GetFile();
175 event_id =
event->GetMatch()->GetMatchedLink().GetEntry();
178 event_id = FairRootManager::Instance()->GetEntryNr();
182 if (n_fsd_hits <= 0) {
183 LOG(warn) <<
"No FSD hits!";
189 LOG(warn) <<
"No Global Tracks!";
197 for (
Int_t ifh = 0; ifh < n_fsd_hits; ifh++) {
201 auto& hit =
fsd_hits_->AddChannel(branch);
203 const Float_t hitX = fsdHit->GetX();
204 const Float_t hitY = fsdHit->GetY();
205 const Float_t hitZ = fsdHit->GetZ();
206 const Float_t eLoss = fsdHit->GetEdep();
207 const Float_t time = fsdHit->GetTime();
209 const Float_t dist_x = std::fabs(fsdHit->GetX());
210 const Float_t dist_y = std::fabs(fsdHit->GetY());
215 hit.SetPosition(hitX, hitY, hitZ);
219 Float_t phi_hit = atan2(fsdHit->GetY(), fsdHit->GetX());
221 phi_hit = phi_hit + 2 * 3.1415;
228 if (fsdHitMatch && fsdHitMatch->GetNofLinks() > 0) {
229 highestWeight = fsdHitMatch->GetMatchedLink().GetWeight();
231 for (int32_t ilDigi = 0; ilDigi < fsdHitMatch->GetNofLinks(); ilDigi++) {
232 const auto& digiLink = fsdHitMatch->GetLink(ilDigi);
233 if (digiLink.GetFile() != file_id || digiLink.GetEntry() != event_id) {
238 if (fsdDigiMatch && fsdDigiMatch->GetNofLinks() > 0) {
239 for (int32_t ilPoint = 0; ilPoint < fsdDigiMatch->GetNofLinks(); ilPoint++) {
240 const auto& pointLink = fsdDigiMatch->GetLink(ilPoint);
241 if (pointLink.GetFile() != file_id || pointLink.GetEntry() != event_id) {
249 Int_t mc_track_id = fsdPoint->GetTrackID();
250 if (mc_track_id >= 0) {
251 auto it = sim_tracks_map.find(mc_track_id);
252 if (it != sim_tracks_map.end()) {
260 hit.SetField(
float(fsdPoint->GetTime() - time),
i_dtHP_);
261 hit.SetField(
float(fsdPoint->GetX() - hitX),
i_dxHP_);
262 hit.SetField(
float(fsdPoint->GetY() - hitY),
i_dxHP_ + 1);
263 hit.SetField(
float(fsdPoint->GetZ() - hitZ),
i_dxHP_ + 2);
264 hit.SetField(
float(fsdPoint->GetEnergyLoss()),
i_eloss_);
266 hit.SetField(
float(fsdPoint->GetX()),
i_xpoint_);
267 hit.SetField(
float(fsdPoint->GetY()),
i_xpoint_ + 1);
268 hit.SetField(
float(fsdPoint->GetZ()),
i_xpoint_ + 2);
270 hit.SetField(
float(fsdPoint->GetPx()),
i_pxpoint_);
271 hit.SetField(
float(fsdPoint->GetPy()),
i_pxpoint_ + 1);
272 hit.SetField(
float(fsdPoint->GetPz()),
i_pxpoint_ + 2);
274 Float_t phi_point = atan2(fsdPoint->GetY(), fsdPoint->GetX());
276 phi_point = phi_point + 2 * 3.1415;
279 hit.SetField(
float(fsdPoint->GetTime()),
i_tpoint_);
288 const Int_t hitMCmult = multMC;
289 const Float_t hitTopWeight = highestWeight;
291 hit.SetField(hitTopWeight,
i_topW_);
294 Int_t bestMatchedIndex = -1;
295 Double_t bestChi2 = 0.;
296 for (
Int_t igt = 0; igt < n_tracks; igt++) {
299 FairTrackParam param_last = *(globalTrack->GetParamLast());
303 if (bestChi2 > matchingChi2 || bestMatchedIndex < 0) {
304 bestChi2 = matchingChi2;
305 bestMatchedIndex = trackIndex;
314 FairTrackParam param_last = *(globalTrack->GetParamLast());
318 param_fsd.Momentum(p_fsd);
321 const Int_t q = param_fsd.GetQp() > 0 ? 1 : -1;
322 const Float_t l = globalTrack->GetLength();
323 const Float_t beta =
event ? l / ((time -
event->GetTzero()) * 29.9792458) : 0;
324 const Float_t m2 =
event ? p * p * (1. / (beta * beta) - 1.) : -1.;
327 hit.SetField(
float(q * p),
i_qp_);
328 hit.SetField(
float(param_fsd.GetX() - hitX),
i_dx_);
329 hit.SetField(
float(param_fsd.GetY() - hitY),
i_dx_ + 1);
330 hit.SetField(
float(param_fsd.GetZ() - hitZ),
i_dx_ + 2);
331 hit.SetField(l,
i_l_);
332 hit.SetField(time,
i_t_);
334 if (rec_tracks_map.empty()) {
337 const Int_t stsTrackIndex = globalTrack->GetStsTrackIndex();
338 if (rec_tracks_map.find(stsTrackIndex) != rec_tracks_map.end()) {
339 vtx_tracks_2_fsd_->AddMatch(rec_tracks_map.find(stsTrackIndex)->second, hit.GetId());