62 AnalysisTree::BranchConfig vtx_tracks_config(
out_branch_, AnalysisTree::DetType::kTrack);
63 vtx_tracks_config.AddField<
float>(
"chi2",
"spatial chi2 of the track fit");
64 vtx_tracks_config.AddField<
float>(
"chi2_time",
"time chi2 of the track fit");
65 vtx_tracks_config.AddField<
float>(
"vtx_chi2",
"chi2 to to the primary vertex");
66 vtx_tracks_config.AddFields<
float>({
"dcax",
"dcay",
"dcaz"},
67 "not actuall Distance of Closest Approach, but extrapolated to z=z_vtx");
68 vtx_tracks_config.AddField<
int>(
"ndf",
"spatial number degrees of freedom");
69 vtx_tracks_config.AddField<
int>(
"ndf_time",
"time number degrees of freedom");
70 vtx_tracks_config.AddField<
int>(
"q",
"charge");
71 vtx_tracks_config.AddField<
int>(
"nhits",
"number of hits (total MVD+STS)");
72 vtx_tracks_config.AddField<
int>(
"nhits_mvd",
"number of hits in MVD");
73 vtx_tracks_config.AddField<
float>(
"match_weight",
"true over all hits ratio for a matched MC-track");
74 vtx_tracks_config.AddField<
float>(
"dE_over_dx");
76 iq_ = vtx_tracks_config.GetFieldId(
"q");
77 indf_ = vtx_tracks_config.GetFieldId(
"ndf");
78 indf_time_ = vtx_tracks_config.GetFieldId(
"ndf_time");
79 ichi2_ = vtx_tracks_config.GetFieldId(
"chi2");
80 ichi2_time_ = vtx_tracks_config.GetFieldId(
"chi2_time");
81 inhits_ = vtx_tracks_config.GetFieldId(
"nhits");
82 inhits_mvd_ = vtx_tracks_config.GetFieldId(
"nhits_mvd");
83 idcax_ = vtx_tracks_config.GetFieldId(
"dcax");
84 ivtx_chi2_ = vtx_tracks_config.GetFieldId(
"vtx_chi2");
85 ide_dx_ = vtx_tracks_config.GetFieldId(
"dE_over_dx");
89 vtx_tracks_config.AddFields<
float>({
"x",
"y",
"z",
"tx",
"ty",
"qp"},
"track parameters");
90 vtx_tracks_config.AddFields<
float>({
"cx0",
"cx1",
"cx2",
"cy0",
"cy1",
"cy2",
"cz0",
"cz1",
"cz2",
"z0"},
91 "magnetic field approximation");
92 vtx_tracks_config.AddFields<
float>({
"cov1",
"cov2",
"cov3",
"cov4",
"cov5",
"cov6",
"cov7",
"cov8",
"cov9",
"cov10",
93 "cov11",
"cov12",
"cov13",
"cov14",
"cov15"},
96 vtx_tracks_config.AddField<
int>(
"mother_pdg",
"PDG code of mother particle");
97 vtx_tracks_config.AddField<
bool>(
"pass_cuts",
"ask Oleksii");
99 ipar_ = vtx_tracks_config.GetFieldId(
"x");
100 imf_ = vtx_tracks_config.GetFieldId(
"cx0");
101 icov_ = vtx_tracks_config.GetFieldId(
"cov1");
102 imother_pdg_ = vtx_tracks_config.GetFieldId(
"mother_pdg");
103 ipasscuts_ = vtx_tracks_config.GetFieldId(
"pass_cuts");
105 auto* man = AnalysisTree::TaskManager::GetInstance();
113 std::vector<CbmStsTrack>
tracks = {*sts_track};
115 std::vector<float> chi2_to_vtx;
116 std::vector<CbmL1PFFitter::PFFieldRegion> field;
119 std::vector<int> pdgVector = {pdg};
126 for (
int i = 0; i < 10; i++) {
127 track.SetField(field[0].fP[i],
imf_ + i);
131 return chi2_to_vtx[0];
142 auto* out_config_ = AnalysisTree::TaskManager::GetInstance()->GetConfig();
143 const auto& branch = out_config_->GetBranchConfig(
out_branch_);
145 const int n_sts_tracks =
event ?
event->GetNofStsTracks() :
cbm_sts_tracks_->GetEntries();
146 if (n_sts_tracks <= 0) {
147 LOG(warn) <<
"No STS tracks!";
152 for (
short i_track = 0; i_track < n_sts_tracks; ++i_track) {
153 const int track_index =
event ?
event->GetStsTrackIndex(i_track) : i_track;
155 if (!sts_track) {
throw std::runtime_error(
"empty track!"); }
163 const FairTrackParam* trackParamFirst = sts_track->GetParamFirst();
165 trackParamFirst->Momentum(momRec);
166 const Int_t q = trackParamFirst->GetQp() > 0 ? 1 : -1;
168 track.SetMomentum3(momRec);
169 track.SetField(
int(q),
iq_);
170 track.SetField(
int(sts_track->GetNDF()),
indf_);
171 track.SetField(
int(sts_track->GetNdfTime()),
indf_time_);
172 track.SetField(
float(sts_track->GetChiSq()),
ichi2_);
173 track.SetField(
float(sts_track->GetChiSqTime()),
ichi2_time_);
174 track.SetField(
int(sts_track->GetTotalNofHits()),
inhits_);
178 track.SetField(
int(sts_track->GetNofMvdHits()),
inhits_mvd_);
179 track.SetField(
float(chi2_vertex),
ivtx_chi2_);
180 track.SetField(
float(sts_track->GetELoss()),
ide_dx_);
189 bool is_good_track)
const
192 const FairTrackParam* trackParamFirst = sts_track->
GetParamFirst();
194 track.SetField(
float(trackParamFirst->GetX()),
ipar_);
195 track.SetField(
float(trackParamFirst->GetY()),
ipar_ + 1);
196 track.SetField(
float(trackParamFirst->GetZ()),
ipar_ + 2);
197 track.SetField(
float(trackParamFirst->GetTx()),
ipar_ + 3);
198 track.SetField(
float(trackParamFirst->GetTy()),
ipar_ + 4);
199 track.SetField(
float(trackParamFirst->GetQp()),
ipar_ + 5);
201 for (Int_t i = 0, iCov = 0; i < 5; i++) {
202 for (Int_t j = 0; j <= i; j++, iCov++) {
203 track.SetField(
float(trackParamFirst->GetCovariance(i, j)),
icov_ + iCov);
214 const FairTrackParam* trackParamFirst = sts_track->
GetParamFirst();
216 Double_t cov_matrix[15] = {0.f};
217 for (Int_t i = 0, iCov = 0; i < 5; i++) {
218 for (Int_t j = 0; j <= i; j++, iCov++) {
219 cov_matrix[iCov] = trackParamFirst->GetCovariance(i, j);
224 ok = ok && std::isfinite(sts_track->
GetParamFirst()->GetX());
225 ok = ok && std::isfinite(sts_track->
GetParamFirst()->GetY());
226 ok = ok && std::isfinite(sts_track->
GetParamFirst()->GetZ());
227 ok = ok && std::isfinite(sts_track->
GetParamFirst()->GetTx());
228 ok = ok && std::isfinite(sts_track->
GetParamFirst()->GetTy());
229 ok = ok && std::isfinite(sts_track->
GetParamFirst()->GetQp());
231 for (
auto element : cov_matrix) {
232 ok = ok && std::isfinite(element);
234 ok = ok && (cov_matrix[0] < 1. && cov_matrix[0] > 0.) && (cov_matrix[2] < 1. && cov_matrix[2] > 0.)
235 && (cov_matrix[5] < 1. && cov_matrix[5] > 0.) && (cov_matrix[9] < 1. && cov_matrix[9] > 0.)
236 && (cov_matrix[14] < 1. && cov_matrix[14] > 0.);
246 if (it ==
indexes_map_->end()) {
throw std::runtime_error(
match_to_ +
" is not found to match with vertex tracks"); }
247 auto sim_tracks_map = it->second;
252 int file_id {0}, event_id {0};
254 file_id =
event->GetMatch()->GetMatchedLink().GetFile();
255 event_id =
event->GetMatch()->GetMatchedLink().GetEntry();
258 event_id = FairRootManager::Instance()->GetEntryNr();
262 const int cbm_id = track_id.first;
263 const int out_id = track_id.second;
267 if (match->GetNofLinks() > 0) {
269 const auto& link = match->GetMatchedLink();
271 if (link.GetFile() != file_id || link.GetEntry() != event_id) {
272 LOG(warn) <<
"MC track from different event";
276 const int mc_track_id = link.GetIndex();
278 auto p = sim_tracks_map.find(mc_track_id);
279 if (p == sim_tracks_map.end())
282 track.SetField(
float(match->GetTrueOverAllHitsRatio()),
imatch_weight_);