22#include "FairRootManager.h"
23#include "TClonesArray.h"
33 : FairTask(
"CbmKfFitTracksTask", iVerbose)
47 const char* env = std::getenv(
"OMP_NUM_THREADS");
50 LOG(info) <<
" found environment variable OMP_NUM_THREADS = \"" << env <<
"\", read as integer: " <<
fNthreads;
63 FairRootManager* ioman = FairRootManager::Instance();
66 LOG(error) <<
"Init: RootManager not instantiated!";
72 fGlobalTracks =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"GlobalTrack"));
75 fStsTracks =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"StsTrack"));
76 fMuchTracks =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"MuchTrack"));
77 fTrdTracks =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"TrdTrack"));
78 fTofTracks =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"TofTrack"));
81 LOG(error) <<
"Init: Global track array not found!";
86 LOG(error) <<
"Init: Sts track array not found!";
98 int statNfittedTracks = 0;
101 fFitter.SetDefaultMomentumForMs(0.1);
114 std::vector<int> statNfittedThreadTracks(
fNthreads, 0);
116 auto fitThread = [&](
int iThread) {
119 for (
int iTr = iThread; iTr < statNtracks; iTr +=
fNthreads) {
124 LOG(fatal) <<
"can not create the sts track for the fit! ";
130 LOG(fatal) <<
"can not create the global track for the fit! ";
135 LOG(fatal) <<
"unknown fit mode!";
140 LOG(fatal) <<
"the track has no nodes with measurements!";
160 statNfittedThreadTracks[iThread]++;
168 LOG(fatal) <<
"null pointer to the sts track!";
177 LOG(fatal) <<
"null pointer to the global track!";
186 std::vector<std::thread> threads(
fNthreads);
190 threads[i] = std::thread(fitThread, i);
194 for (
auto& th : threads) {
199 for (
auto& n : statNfittedThreadTracks) {
200 statNfittedTracks += n;
206 if (statNfittedTracks != statNtracks) {
207 LOG(error) <<
"can not fit " << 100. * (statNtracks - statNfittedTracks) / statNtracks <<
"\% of " << statNtracks
208 <<
" tracks! " << statNtracks - statNfittedTracks <<
" tracks are not fitted! ";
221 <<
" tracks! All tracks are fitted! ";
Task class for refitting global or sts tracks.
Data class for a reconstructed hit in the STS.
Data class for STS tracks.
void SetParamLast(const FairTrackParam *parLast)
void SetParamFirst(const FairTrackParam *parFirst)
virtual ~CbmKfFitTracksTask()
int fNthreads
number of threads for fitting
TClonesArray * fGlobalTracks
input data arrays
TClonesArray * fTrdTracks
trd tracks
TClonesArray * fMuchTracks
much tracks
CbmKfTrackFitter fFitter
track fitter
void Exec(Option_t *opt) override
Int_t fNeventsProcessed
number of processed events
Int_t fStatNfittedTracks
number of fitted tracks
TClonesArray * fStsTracks
sts tracks
Int_t fStatNtracks
number of tracks
TClonesArray * fTofTracks
tof tracks
InitStatus Init() override
CbmKfFitTracksTask(FitMode mode=FitMode::kSts, Int_t iVerbose=0)
Trajectory with hit information stored in node user references.
bool CreateFromMvdStsTrack(Trajectory &trajectory, int stsTrackIndex, bool addMaterialNodesOutsideHitRange)
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 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 FitTrajectory(cbm::algo::kf::Trajectory< double > &t)
fit the trajectory
void SetNofIterations(int nofIterations)
set number of iterations for the fit
bool CreateFromGlobalTrack(Trajectory &trajectory, int globalTrackIndex, bool addMaterialNodesOutsideHitRange)
void SetParamFirst(const FairTrackParam *par)
void SetParamLast(const FairTrackParam *par)
int GetNofMeasurements() const
Get number of nodes with measurements.
TrackParam< double > TrackParamD
cbm::algo::kf::TrackParamD ConvertTrackParam(const FairTrackParam &par)
copy fair track param to Ca track param