21#include "FairRootManager.h"
22#include "KFParticleDatabase.h"
27#include "TClonesArray.h"
28#include "TDatabasePDG.h"
35template<cbm::algo::kf::DoFitTime FlagFitTime>
40template<cbm::algo::kf::DoFitTime FlagFitTime>
45template<cbm::algo::kf::DoFitTime FlagFitTime>
48 FairRootManager* ioman = FairRootManager::Instance();
56 fInputMvdHits =
dynamic_cast<const TClonesArray*
>(ioman->GetObject(
"MvdHit"));
57 fInputStsHits =
dynamic_cast<const TClonesArray*
>(ioman->GetObject(
"StsHit"));
58 fInputTrdHits =
dynamic_cast<const TClonesArray*
>(ioman->GetObject(
"TrdHit"));
59 fInputMuchHits =
dynamic_cast<const TClonesArray*
>(ioman->GetObject(
"MuchHit"));
60 fInputTofHits =
dynamic_cast<const TClonesArray*
>(ioman->GetObject(
"TofHit"));
63 fInputGlobalTracks =
dynamic_cast<const TClonesArray*
>(ioman->GetObject(
"GlobalTrack"));
66 fInputStsTracks =
dynamic_cast<const TClonesArray*
>(ioman->GetObject(
"StsTrack"));
67 fInputMuchTracks =
dynamic_cast<const TClonesArray*
>(ioman->GetObject(
"MuchTrack"));
68 fInputTrdTracks =
dynamic_cast<const TClonesArray*
>(ioman->GetObject(
"TrdTrack"));
69 fInputTofTracks =
dynamic_cast<const TClonesArray*
>(ioman->GetObject(
"TofTrack"));
75 LOG(fatal) <<
"cbm::RecoSetupManager not initialized";
80 LOG(fatal) <<
"RecoSetupUnit for MVD was not provided";
82 if (fInputStsHits && !recoSetup.GetSts()) {
83 LOG(fatal) <<
"RecoSetupUnit for STS was not provided";
85 if (fInputMuchHits && !recoSetup.GetMuch()) {
86 LOG(fatal) <<
"RecoSetupUnit for MUCH was not provided";
88 if (fInputTrdHits && !recoSetup.GetTrd()) {
89 LOG(fatal) <<
"RecoSetupUnit for TRD was not provided";
91 if (fInputTofHits && !recoSetup.GetTof()) {
92 LOG(fatal) <<
"RecoSetupUnit for TOF was not provided";
112template<cbm::algo::kf::DoFitTime FlagFitTime>
115 TParticlePDG* particlePDG = TDatabasePDG::Instance()->GetParticle(pdg);
117 LOG(fatal) <<
fDebugPrefix <<
"particle PDG " << pdg <<
" is not in the data base, please set the mass manually";
120 fMass = particlePDG->Mass();
124template<cbm::algo::kf::DoFitTime FlagFitTime>
131template<cbm::algo::kf::DoFitTime FlagFitTime>
137template<cbm::algo::kf::DoFitTime FlagFitTime>
139 int stsTrackIndex,
bool addMaterialNodesOutsideHitRange)
144 LOG(error) <<
fDebugPrefix <<
"CbmKfTrackFitter is not initialized!";
149 LOG(error) <<
fDebugPrefix <<
"Sts track array not found!";
153 LOG(error) <<
fDebugPrefix <<
"Sts track index " << stsTrackIndex <<
" is out of range!";
164 globalTrack.
SetParamFirst(*
dynamic_cast<const FairTrackParam*
>(stsTrack->GetParamFirst()));
169template<cbm::algo::kf::DoFitTime FlagFitTime>
171 int globalTrackIndex,
bool addMaterialNodesOutsideHitRange)
175 if (!fIsInitialized) {
176 LOG(error) << fDebugPrefix <<
"CbmKfTrackFitter is not initialized!";
180 if (!fInputGlobalTracks) {
181 LOG(error) << fDebugPrefix <<
"Global track array not found!";
185 if (globalTrackIndex >= fInputGlobalTracks->GetEntriesFast()) {
186 LOG(error) << fDebugPrefix <<
"Global track index " << globalTrackIndex <<
" is out of range!";
190 auto* globalTrack =
dynamic_cast<const CbmGlobalTrack*
>(fInputGlobalTracks->At(globalTrackIndex));
192 LOG(error) << fDebugPrefix <<
"Global track is null!";
196 return CreateFromGlobalTrack(trajectory, *globalTrack, addMaterialNodesOutsideHitRange);
199template<cbm::algo::kf::DoFitTime FlagFitTime>
201 bool addMaterialNodesOutsideHitRange)
205 LOG(error) <<
fDebugPrefix <<
"CbmKfTrackFitter is not initialized!";
212 for (
int i = 0; i <
fKfSetup->GetNofLayers(); i++) {
216 n.z =
fKfSetup->GetMaterial(i).GetZref();
229 int iLayer =
fKfSetup->GetIndexMap().LocalToGlobal(detId, stIdx);
233 assert(iLayer >= 0 && iLayer < fKfSetup->GetNofLayers());
234 auto& n = t.
fNodes[iLayer];
236 n.measurementXY.SetX(
h.GetX());
237 n.measurementXY.SetY(
h.GetY());
238 n.measurementXY.SetDx2(
h.GetDx() *
h.GetDx());
239 n.measurementXY.SetDy2(
h.GetDy() *
h.GetDy());
240 n.measurementXY.SetDxy(
h.GetDxy());
241 n.measurementXY.SetNdfX(1);
242 n.measurementXY.SetNdfY(1);
244 n.measurementTime.SetT(
h.GetTime());
245 n.measurementTime.SetDt2(
h.GetTimeError() *
h.GetTimeError());
246 n.measurementTime.SetNdfT(1);
262 LOG(error) <<
fDebugPrefix <<
"Sts track array not found!";
266 LOG(error) <<
fDebugPrefix <<
"Sts track index " << stsTrackIndex <<
" is out of range!";
280 LOG(error) <<
fDebugPrefix <<
" Mvd hit array not found!";
284 for (
int ih = 0; ih < nMvdHits; ih++) {
285 int hitIndex = stsTrack->GetMvdHitIndex(ih);
287 LOG(error) <<
fDebugPrefix <<
" Mvd hit index " << hitIndex <<
" is out of range!";
297 int nStsHits = stsTrack->GetNofStsHits();
300 LOG(error) <<
fDebugPrefix <<
" Sts hit array not found!";
304 for (
int ih = 0; ih <
nStsHits; ih++) {
305 int hitIndex = stsTrack->GetStsHitIndex(ih);
307 LOG(error) <<
fDebugPrefix <<
" Sts hit index " << hitIndex <<
" is out of range!";
322 LOG(error) <<
fDebugPrefix <<
"Much track array not found!";
326 LOG(error) <<
fDebugPrefix <<
"Much track index " << muchTrackIndex <<
" is out of range!";
337 LOG(error) <<
fDebugPrefix <<
"Much hit array not found!";
341 for (
int ih = 0; ih < nHits; ih++) {
342 int hitIndex = track->GetHitIndex(ih);
344 LOG(error) <<
fDebugPrefix <<
"Much hit index " << hitIndex <<
" is out of range!";
358 LOG(error) <<
fDebugPrefix <<
"Trd track array not found!";
362 LOG(error) <<
fDebugPrefix <<
"Trd track index " << trdTrackIndex <<
" is out of range!";
373 LOG(error) <<
fDebugPrefix <<
"Trd hit array not found!";
377 for (
int ih = 0; ih < nHits; ih++) {
378 int hitIndex = track->GetHitIndex(ih);
380 LOG(error) <<
fDebugPrefix <<
"Trd hit index " << hitIndex <<
" is out of range!";
384 auto* node = setNode(hit, pRecoUnit->GetTrackingStationId(hit.GetAddress()), hitIndex,
ca::EDetectorID::kTrd);
386 if (node !=
nullptr && hit.GetClassType() == 1) {
399 LOG(error) <<
fDebugPrefix <<
"Tof track array not found!";
403 LOG(error) <<
fDebugPrefix <<
"Tof track index " << tofTrackIndex <<
" is out of range!";
415 LOG(error) <<
fDebugPrefix <<
"Tof hit array not found!";
419 for (
int ih = 0; ih < nHits; ih++) {
420 int hitIndex = track->GetHitIndex(ih);
422 LOG(error) <<
fDebugPrefix <<
"Tof hit index " << hitIndex <<
" is out of range!";
433 if (!addMaterialNodesOutsideHitRange) {
436 assert(firstHitNode >= 0 && lastHitNode >= 0);
447template<cbm::algo::kf::DoFitTime FlagFitTime>
458 auto& tr =
fFit.Tr();
460 if (fabs(tr.GetZ() - n.
z) > 1.e-15) {
461 LOG(fatal) <<
fDebugPrefix <<
"Z mismatch: fitted track " << tr.GetZ() <<
" != node " << n.
z;
464 tr.ResetErrors(mxy.Dx2(), mxy.Dy2(), 100., 100., 10., 1.e4, 1.e2);
465 tr.SetC10(mxy.Dxy());
471 if (mxy.NdfX() == 0) {
475 if (mxy.NdfY() == 0) {
484 tr.SetNdf(-5. + mxy.NdfX() + mxy.NdfY());
488 tr.SetNdfTime(-2 + 1);
494 tr.InitVelocityRange(0.5);
497template<cbm::algo::kf::DoFitTime FlagFitTime>
528template<cbm::algo::kf::DoFitTime FlagFitTime>
535 LOG(info) <<
fDebugPrefix <<
"-------- FitTrajectory ... ";
542 LOG(error) <<
fDebugPrefix <<
"CbmKfTrackFitter is not initialized!";
549 const auto& n = t.
fNodes[in];
551 LOG(fatal) <<
fDebugPrefix <<
"the input trajectory is marked as fitted, but its node " << in
552 <<
" in the measured region is not fitted!";
554 if (n.materialLayer >= 0 && n.radThick < 0.) {
555 LOG(fatal) <<
fDebugPrefix <<
"the input trajectory is marked as fitted, but its node " << in
556 <<
" with material layer " << n.materialLayer
557 <<
" in the measured region does not have material budget set!";
564 LOG(fatal) <<
fDebugPrefix <<
"the input trajectory is marked as fully extrapolated, but it is not fitted!";
566 for (
unsigned int in = 0; in < t.
fNodes.size(); in++) {
567 const auto& n = t.
fNodes[in];
569 LOG(fatal) <<
fDebugPrefix <<
"the input trajectory is marked as fully extrapolated, but its node " << in
570 <<
" is not fitted!";
572 if (n.materialLayer >= 0 && n.radThick < 0.) {
573 LOG(fatal) <<
fDebugPrefix <<
"the input trajectory is marked as fully extrapolated, but its node " << in
574 <<
" with material layer " << n.materialLayer <<
" does not have material budget set!";
581 LOG(fatal) <<
fDebugPrefix <<
"Material fixed flag is set, but the input trajectory is not fitted.";
584 LOG(fatal) <<
fDebugPrefix <<
"Material fixed flag is set, but the input trajectory is not extrapolated.";
598 int nNodes = t.
fNodes.size();
606 LOG(warning) <<
fDebugPrefix <<
"no nodes with measurements found!";
614 std::vector<LinearizationAtNode> linearization(nNodes);
622 for (
int i = firstHitNode; i <= lastHitNode; i++) {
623 linearization[i].linearizationDn = t.
fNodes[i].paramDn;
624 linearization[i].linearizationUp = t.
fNodes[i].paramUp;
625 linearization[i].radThick = t.
fNodes[i].radThick;
629 for (
int i1 = firstHitNode, i2 = firstHitNode + 1; i2 <= lastHitNode; i2++) {
635 double dz = n2.z - n1.z;
636 double dzi = (fabs(dz) > 1.e-4) ? 1. / dz : 0.;
639 l.
x = n1.measurementXY.X();
640 l.
y = n1.measurementXY.Y();
641 l.
tx = (n2.measurementXY.X() - n1.measurementXY.X()) * dzi;
642 l.
ty = (n2.measurementXY.Y() - n1.measurementXY.Y()) * dzi;
647 for (
int i = i1; i <= i2; i++) {
649 auto& nl = linearization[i];
650 l.
x += l.
tx * (n.z - lz);
651 l.
y += l.
ty * (n.z - lz);
653 if (i < i2 || i == lastHitNode) {
654 nl.linearizationDn = l;
656 if (i > i1 || i == firstHitNode) {
657 nl.linearizationUp = l;
663 for (
int in = firstHitNode; in <= lastHitNode; in++) {
665 auto& l = linearization[in];
666 if (n.materialLayer >= 0) {
668 l.radThick = map.
GetThicknessX0(l.linearizationDn.x, l.linearizationDn.y);
678 auto printNode = [&](std::string str,
int node) {
680 LOG(info) <<
fDebugPrefix << str <<
": node " << node <<
" chi2 " <<
fFit.Tr().GetChiSq() <<
" x "
681 <<
fFit.Tr().GetX() <<
" y " <<
fFit.Tr().GetY() <<
" z " <<
fFit.Tr().GetZ() <<
" tx "
682 <<
fFit.Tr().GetTx() <<
" ty " <<
fFit.Tr().GetTy() <<
" qp " <<
fFit.Tr().GetQp() <<
" time "
683 <<
fFit.Tr().GetTime();
692 LOG(info) <<
fDebugPrefix <<
"---- Fit iteration " << iter <<
" ----";
698 auto& n = t.
fNodes[firstHitNode];
700 fFit.SetTrack(n.z, linearization[firstHitNode].linearizationDn);
702 printNode(
"fit downstream", firstHitNode);
705 for (
int iNode = firstHitNode + 1; iNode <= lastHitNode && ok; iNode++) {
707 auto& n = t.
fNodes[iNode];
710 fFit.SetLinearization(linearization[iNode - 1].linearizationDn);
711 fFit.Extrapolate(n.z, field);
718 fFit.FilterTime(n.measurementTime);
720 printNode(
"fit downstream", iNode);
723 n.paramUp =
fFit.Tr();
726 if (n.materialLayer >= 0) {
731 n.paramDn =
fFit.Tr();
745 auto& n = t.
fNodes[lastHitNode];
748 fFit.SetTrack(n.z, linearization[lastHitNode].linearizationUp);
750 printNode(
"fit upstream", lastHitNode);
753 for (
int iNode = lastHitNode - 1; ok && (iNode > firstHitNode); iNode--) {
755 auto& n = t.
fNodes[iNode];
758 fFit.SetLinearization(linearization[iNode + 1].linearizationUp);
759 fFit.Extrapolate(n.z, field);
764 if (n.materialLayer >= 0) {
779 fFit.FilterTime(n.measurementTime);
781 printNode(
"fit upstream", iNode);
789 int iNode = firstHitNode;
791 auto& n = t.
fNodes[iNode];
794 fFit.SetLinearization(linearization[iNode + 1].linearizationUp);
795 fFit.Extrapolate(n.z, field);
802 fFit.FilterTime(n.measurementTime);
804 printNode(
"fit upstream", iNode);
805 n.paramDn =
fFit.Tr();
807 if (n.materialLayer >= 0) {
810 n.paramUp =
fFit.Tr();
817 for (
auto& n : t.
fNodes) {
826 for (
int in = firstHitNode; in <= lastHitNode; in++) {
828 if (n.materialLayer >= 0) {
830 n.radThick = map.
GetThicknessX0(n.paramDn.GetX(), n.paramDn.GetY());
842 for (
int i = lastHitNode + 1; i < nNodes; i++) {
844 fFit.Extrapolate(n.z, field);
845 if (n.materialLayer >= 0) {
846 n.radThick =
fKfSetup->GetMaterial(n.materialLayer).GetThicknessX0(
fFit.Tr().GetX(),
fFit.Tr().GetY());
848 n.paramUp =
fFit.Tr();
849 if (n.materialLayer >= 0) {
856 n.paramDn =
fFit.Tr();
864 fFit.SetTrack(t.
fNodes[firstHitNode].paramUp);
865 for (
int i = firstHitNode - 1; i >= 0; i--) {
867 fFit.Extrapolate(n.z, field);
868 n.paramDn =
fFit.Tr();
869 if (n.materialLayer >= 0) {
870 n.radThick =
fKfSetup->GetMaterial(n.materialLayer).GetThicknessX0(
fFit.Tr().GetX(),
fFit.Tr().GetY());
877 n.paramUp =
fFit.Tr();
884 const auto& tt =
fFit.Tr();
886 for (
int iNode = 0; iNode < nNodes; iNode++) {
887 auto& n = t.
fNodes[iNode];
888 n.paramDn.SetNdf(tt.GetNdf());
889 n.paramDn.SetNdfTime(tt.GetNdfTime());
890 n.paramDn.SetChiSq(tt.GetChiSq());
891 n.paramDn.SetChiSqTime(tt.GetChiSqTime());
892 n.paramUp.SetNdf(tt.GetNdf());
893 n.paramUp.SetNdfTime(tt.GetNdfTime());
894 n.paramUp.SetChiSq(tt.GetChiSq());
895 n.paramUp.SetChiSqTime(tt.GetChiSqTime());
904template<cbm::algo::kf::DoFitTime FlagFitTime>
914 LOG(info) <<
fDebugPrefix <<
"-------- FitTrajectoryUpstream ... ";
920 LOG(error) <<
fDebugPrefix <<
"CbmKfTrackFitter is not initialized!";
925 LOG(fatal) <<
fDebugPrefix <<
"the input trajectory is not fitted!";
929 LOG(fatal) <<
fDebugPrefix <<
"the input trajectory is not fully extrapolated!";
932 for (
unsigned int in = 0; in < t.
fNodes.size(); in++) {
933 const auto& n = t.
fNodes[in];
935 LOG(fatal) <<
fDebugPrefix <<
"the input trajectory is marked as fully extrapolated, but its node " << in
936 <<
" is not fitted!";
938 if (n.materialLayer >= 0 && n.radThick < 0.) {
939 LOG(fatal) <<
fDebugPrefix <<
"the input trajectory is marked as fully extrapolated, but its node " << in
940 <<
" with material layer " << n.materialLayer <<
" does not have material budget set!";
947 int nNodes = t.
fNodes.size();
955 LOG(warning) <<
fDebugPrefix <<
"no nodes with measurements found!";
963 std::vector<LinearizationAtNode> linearization(nNodes);
968 for (
int i = 0; i <= lastHitNode; i++) {
969 linearization[i].linearizationDn = t.
fNodes[i].paramDn;
970 linearization[i].linearizationUp = t.
fNodes[i].paramUp;
971 linearization[i].radThick = t.
fNodes[i].radThick;
974 auto printNode = [&](std::string str,
int node) {
976 LOG(info) <<
fDebugPrefix << str <<
": node " << node <<
" chi2 " <<
fFit.Tr().GetChiSq() <<
" x "
977 <<
fFit.Tr().GetX() <<
" y " <<
fFit.Tr().GetY() <<
" z " <<
fFit.Tr().GetZ() <<
" tx "
978 <<
fFit.Tr().GetTx() <<
" ty " <<
fFit.Tr().GetTy() <<
" qp " <<
fFit.Tr().GetQp() <<
" time "
979 <<
fFit.Tr().GetTime();
986 const auto& n = t.
fNodes[lastHitNode];
988 fFit.SetTrack(n.paramUp);
990 printNode(
"fit upstream", lastHitNode);
993 for (
int iNode = lastHitNode - 1; ok && (iNode >= 0); iNode--) {
995 const auto& n = t.
fNodes[iNode];
998 fFit.SetLinearization(linearization[iNode + 1].linearizationUp);
999 fFit.Extrapolate(n.z, field);
1001 if (n.materialLayer >= 0) {
1010 fFit.FilterTime(n.measurementTime);
1012 printNode(
"fit upstream", iNode);
1016 outputParam =
fFit.Tr();
1022template<cbm::algo::kf::DoFitTime FlagFitTime>
1032 LOG(info) <<
fDebugPrefix <<
"-------- FitTrajectoryDownstream ... ";
1038 LOG(error) <<
fDebugPrefix <<
"CbmKfTrackFitter is not initialized!";
1043 LOG(fatal) <<
fDebugPrefix <<
"the input trajectory is not fitted!";
1047 LOG(fatal) <<
fDebugPrefix <<
"the input trajectory is not fully extrapolated!";
1050 for (
unsigned int in = 0; in < t.
fNodes.size(); in++) {
1051 const auto& n = t.
fNodes[in];
1053 LOG(fatal) <<
fDebugPrefix <<
"the input trajectory is marked as fully extrapolated, but its node " << in
1054 <<
" is not fitted!";
1056 if (n.materialLayer >= 0 && n.radThick < 0.) {
1057 LOG(fatal) <<
fDebugPrefix <<
"the input trajectory is marked as fully extrapolated, but its node " << in
1058 <<
" with material layer " << n.materialLayer <<
" does not have material budget set!";
1065 int nNodes = t.
fNodes.size();
1073 LOG(warning) <<
fVerbosityLevel <<
"no nodes with measurements found!";
1081 std::vector<LinearizationAtNode> linearization(nNodes);
1086 for (
int i = firstHitNode; i < nNodes; i++) {
1087 linearization[i].linearizationDn = t.
fNodes[i].paramDn;
1088 linearization[i].linearizationUp = t.
fNodes[i].paramUp;
1089 linearization[i].radThick = t.
fNodes[i].radThick;
1092 auto printNode = [&](std::string str,
int node) {
1094 LOG(info) <<
fDebugPrefix << str <<
": node " << node <<
" chi2 " <<
fFit.Tr().GetChiSq() <<
" x "
1095 <<
fFit.Tr().GetX() <<
" y " <<
fFit.Tr().GetY() <<
" z " <<
fFit.Tr().GetZ() <<
" tx "
1096 <<
fFit.Tr().GetTx() <<
" ty " <<
fFit.Tr().GetTy() <<
" qp " <<
fFit.Tr().GetQp() <<
" time "
1097 <<
fFit.Tr().GetTime();
1104 const auto& n = t.
fNodes[firstHitNode];
1106 fFit.SetTrack(n.paramDn);
1108 printNode(
"fit downstream", firstHitNode);
1111 for (
int iNode = firstHitNode + 1; ok && (iNode < nNodes); iNode++) {
1113 const auto& n = t.
fNodes[iNode];
1116 fFit.SetLinearization(linearization[iNode - 1].linearizationDn);
1117 fFit.Extrapolate(n.z, field);
1119 if (n.materialLayer >= 0) {
1128 fFit.FilterTime(n.measurementTime);
1130 printNode(
"fit downstream", iNode);
1134 outputParam =
fFit.Tr();
1140template<cbm::algo::kf::DoFitTime FlagFitTime>
1148 double r[nPar] = {t1.
X(), t1.
Y(), t1.
Tx(), t1.
Ty(), t1.
Qp(), t1.
Time(), t1.
Vi()};
1149 double m[nPar] = {t2.
X(), t2.
Y(), t2.
Tx(), t2.
Ty(), t2.
Qp(), t2.
Time(), t2.
Vi()};
1151 double S[nCov], S1[nCov], Tmp[nCov];
1152 for (
int i = 0; i < nCov; i++) {
1162 LOG(error) <<
fDebugPrefix <<
"matrix inversion failed! ifault " << ifault <<
" nullty " << nullty;
1163 for (
int i = 0; i < nCov; i++) {
1167 for (
int i = 0; i < nCov; i++) {
1168 LOG(error) <<
fDebugPrefix <<
"S[" << i <<
"] = " << S[i] <<
" S1[" << i <<
"] = " << S1[i];
1176 for (
int i = 0; i < nPar; i++) {
1177 dzeta[i] = m[i] - r[i];
1180 double C[nPar][nPar];
1181 double Si[nPar][nPar];
1182 for (
int i = 0, k = 0; i < nPar; i++) {
1183 for (
int j = 0; j <= i; j++, k++) {
1187 Si[j][i] = Si[i][j];
1192 double K[nPar][nPar];
1193 for (
int i = 0; i < nPar; i++) {
1194 for (
int j = 0; j < nPar; j++) {
1196 for (
int k = 0; k < nPar; k++) {
1197 K[i][j] +=
C[i][k] * Si[k][j];
1202 for (
int i = 0, k = 0; i < nPar; i++) {
1203 for (
int j = 0; j <= i; j++, k++) {
1205 for (
int l = 0; l < nPar; l++) {
1206 kc += K[i][l] *
C[l][j];
1212 for (
int i = 0; i < nPar; i++) {
1214 for (
int j = 0; j < nPar; j++) {
1215 kd += K[i][j] * dzeta[j];
1228 double chi2Time = 0.;
1229 for (
int i = 0; i < nPar; i++) {
1230 double SiDzeta = 0.;
1231 for (
int j = 0; j < nPar; j++) {
1232 SiDzeta += Si[i][j] * dzeta[j];
1235 chi2 += dzeta[i] * SiDzeta;
1238 chi2Time += dzeta[i] * SiDzeta;
1248template<cbm::algo::kf::DoFitTime FlagFitTime>
1254 LOG(error) <<
fDebugPrefix <<
"CbmKfTrackFitter is not initialized!";
1259 fFit.SetTrack(track);
1260 auto& tr =
fFit.Tr();
1264 auto processMaterialLayer = [&](
int i) {
1265 double zMaterial =
fKfSetup->GetMaterial(i).GetZref();
1267 fFit.Extrapolate(zMaterial, field);
1269 double radThick =
fKfSetup->GetMaterial(i).GetThicknessX0(tr.GetX(), tr.GetY());
1270 double msQp = tr.GetQp();
1275 fFit.MultipleScattering(radThick, tr.GetTx(), tr.GetTy(), msQp);
1278 fFit.EnergyLossCorrection(radThick, direction);
1283 for (
int i = 0; i <
fKfSetup->GetNofLayers(); i++) {
1284 double zMaterial =
fKfSetup->GetMaterial(i).GetZref();
1285 if (zMaterial <= tr.GetZ()) {
1288 processMaterialLayer(i);
1289 if (zMaterial > z) {
1295 for (
int i =
fKfSetup->GetNofLayers() - 1; i >= 0; i--) {
1296 double zMaterial =
fKfSetup->GetMaterial(i).GetZref();
1297 if (zMaterial >= tr.GetZ()) {
1300 if (zMaterial < z) {
1303 processMaterialLayer(i);
1307 fFit.Extrapolate(z, field);
@ kTrd2d
TRD-FASP Detector (FIXME)
A container for shared tracking geo setup.
Class for pixel hits in MUCH detector.
A manager for setup representation in CBM reconstruction.
Data class for a reconstructed hit in the STS.
Data class for STS tracks.
Class for hits in TRD detector.
Common constant definitions for the Kalman Filter library.
Track fit utilities for the CA tracking based on the Kalman filter.
Generates beam ions for transport simulation.
int32_t GetStsTrackIndex() const
int32_t GetTofTrackIndex() const
int32_t GetMuchTrackIndex() const
void SetParamFirst(const FairTrackParam *parFirst)
int32_t GetTrdTrackIndex() const
void SetStsTrackIndex(int32_t iSts)
Trajectory with hit information stored in node user references.
static void SetHitAddress(Node &node, int address)
static void SetHitSystemId(Node &node, ECbmModuleId sysId)
static void SetHitIndex(Node &node, int index)
bool PropagateToZ(cbm::algo::kf::TrackParamD &track, double z)
propagate the track in the magnetic field taking material effects into account
bool fEnforceDefaultMomentumForMs
bool CreateFromMvdStsTrack(Trajectory &trajectory, int stsTrackIndex, bool addMaterialNodesOutsideHitRange)
void AddMaterialEffects(const LinearizationAtNode &l, cbm::algo::kf::FitDirection direction)
const TClonesArray * fInputMuchTracks
bool FitTrajectoryUpstream(const cbm::algo::kf::Trajectory< double > &t, cbm::algo::kf::TrackParamD &parUp)
fit the trajectory upstream and return the track parameters at the first measurement node
bool Smooth(cbm::algo::kf::TrackParamD &t1, const cbm::algo::kf::TrackParamD &t2)
bool fIgnoreMultipleScattering
ignore the multiple scattering effects in the fit
bool FitTrajectoryDownstream(const cbm::algo::kf::Trajectory< double > &t, cbm::algo::kf::TrackParamD &parDn)
fit the trajectory downstream and return the track parameters at the last measurement node
bool fIsMaterialFixed
true if the radiation thickness is fixed to the nodes fRadThick value and should not be recalculated ...
void SetParticleHypothesis(int pid)
set particle hypothesis (mass and electron flag) via particle PDG
void FilterFirstMeasurement(const cbm::algo::kf::Trajectory< double >::Node &n)
std::shared_ptr< const cbm::algo::kf::Setup< double > > fKfSetup
bool fIgnoreEnergyLosses
ignore the energy loss effects in the fit
const TClonesArray * fInputTrdTracks
bool FitTrajectory(cbm::algo::kf::Trajectory< double > &t)
fit the trajectory
void SetMassHypothesis(double mass)
set particle mass
cbm::algo::kf::TrackKalmanFilter< double, cbm::algo::kf::FilterSettings< cbm::algo::kf::LinearizationFull, FlagFitTime > > fFit
const TClonesArray * fInputTrdHits
const TClonesArray * fInputStsTracks
const TClonesArray * fInputTofHits
void SetElectronFlag(bool isElectron)
set electron flag (bremmstrallung will be applied)
const TClonesArray * fInputStsHits
const TClonesArray * fInputTofTracks
bool CreateFromGlobalTrack(Trajectory &trajectory, int globalTrackIndex, bool addMaterialNodesOutsideHitRange)
const TClonesArray * fInputMvdHits
bool fIgnorePoorCoordinates
const TClonesArray * fInputMuchHits
const TClonesArray * fInputGlobalTracks
data class for a reconstructed 3-d hit in the STS
int32_t GetNofMvdHits() const
virtual int32_t GetNofHits() const
data class for a reconstructed Energy-4D measurement in the TRD
const algo::RecoSetup & GetSetup() const
Setup accessor.
static RecoSetupManager * Instance()
Instance access.
const sts::RecoSetupUnit * GetSts() const
Access to STS reconstruction setup unit.
const mvd::RecoSetupUnit * GetMvd() const
Access to MVD reconstruction setup unit.
const trd::RecoSetupUnit * GetTrd() const
Access to TRD reconstruction setup unit.
const much::RecoSetupUnit * GetMuch() const
Access to MuCh reconstruction setup unit.
const tof::RecoSetupUnit * GetTof() const
Access to TOF reconstruction setup unit.
Magnetic field region, corresponding to a hit triplet.
static EFieldType fgOriginalFieldType
Global field type.
static FieldFn_t fgOriginalField
Global variable to store the field function (x,y,z)->(Bx,By,Bz)
A map of station thickness in units of radiation length (X0) to the specific point in XY plane.
I GetThicknessX0(const I &x, const I &y) const
Gets material thickness in units of radiational length X0.
void SetChiSqTime(T v)
Sets Chi-square of time measurements.
T Vi() const
Gets inverse velocity [ns/cm].
const CovMatrix_t & GetCovMatrix() const
Gets covariance matrix.
static constexpr int kNcovParam
static constexpr int kNtrackParam
T Tx() const
Gets slope along x-axis.
void SetChiSq(T v)
Sets Chi-square of track fit model.
T X() const
Gets x position [cm].
void SetNdf(T v)
Sets NDF of track fit model.
T GetNdfTime() const
Gets NDF of time measurements.
T Y() const
Gets y position [cm].
T GetChiSqTime() const
Gets Chi-square of time measurements.
T Qp() const
Gets charge over momentum [ec/GeV].
T GetNdf() const
Gets NDF of track fit model.
T Time() const
Gets time [ns].
void SetNdfTime(T v)
Sets NDF of time measurements.
CovMatrix_t & CovMatrix()
Reference to covariance matrix.
T GetChiSq() const
Gets Chi-square of track fit model.
T Ty() const
Gets slope along y-axis.
The class describes the particle's trajectory along its entire length.
void Clear()
Clear the trajectory.
T fQaChi2Downstream
chi2 from the downstream fit iteration, needed for QA
bool fIsFitted
true if the trajectory at all the nodes between the first and the last measurements are fitted
bool IsFullyExtrapolated() const
Check if the trajectory is extrapolated beyond the first and last measurements.
int fFirstMeasurementNodeId
index of the first node with measurement
int GetNofMeasurements() const
Get number of nodes with measurements.
void MakeConsistent()
sort the nodes in Z, add missing material layers and set fFirstMeasureNode and fLastMeasureNode
bool IsFitted() const
Check if the trajectory is fitted.
std::vector< Node > fNodes
nodes on the trajectory
int GetLastMeasurementNodeId() const
Get index of the last node with measurement.
bool fIsFullyExtrapolated
true if the trajectory is successfully extrapolated beyond the first and last measurements
int fLastMeasurementNodeId
index of the last node with measurement
int GetFirstMeasurementNodeId() const
Get index of the first node with measurement.
static TrackingGeoSetupContainer & Instance()
Instance access.
std::shared_ptr< const algo::kf::Setup< double > > GetSetup() const
Accessor to the geometry setup.
EDetectorID
Enumeration for the tracking detector subsystems in CBM-CA.
constexpr ECbmModuleId ToCbmModuleId(EDetectorID detID)
Conversion map from EDetectorID to ECbmModuleId.
constexpr auto SpeedOfLightInv
Inverse speed of light [ns/cm].
void SymInv(const double a[], const int n, double c[], double w[], int *nullty, int *ifault)
TrackParam< double > TrackParamD
double radThick
radiation thickness of the material associated with the node
cbm::algo::kf::LinearizationFull< double > linearizationDn
fitted track parameters downstream the node
cbm::algo::kf::LinearizationFull< double > linearizationUp
fitted track parameters upstream the node
T y
y coordinate at the linearization point
T ty
ty = py/pz at the linearization point
T x
x coordinate at the linearization point
T qp
qp = q/pz at the linearization point
T vi
inverse speed at the linearization point
T time
time at the linearization point
T tx
tx = px/pz at the linearization point
The class represent a node on the trajectory.
MeasurementXy< T > measurementXY
== Measurement information ( if present )
T z
Z coordinate of the node.
TrackParam< T > paramDn
fitted track parameters downstream the node
bool isTimeSet
true if the time measurement is set
MeasurementTime< T > measurementTime
time measurement at z