CbmRoot
Loading...
Searching...
No Matches
CbmKfFitTracksTask.cxx
Go to the documentation of this file.
1/* Copyright (C) 2023-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: S.Gorbunov[committer] */
4
9
10
11#include "CbmKfFitTracksTask.h"
12
13#include "CbmGlobalTrack.h"
14#include "CbmKfUtil.h"
15#include "CbmMuchTrack.h"
17#include "CbmMvdHit.h"
19#include "CbmStsHit.h"
20#include "CbmStsSetup.h"
21#include "CbmStsTrack.h"
23#include "CbmTofTrack.h"
25#include "CbmTrdTrack.h"
27#include "FairRootManager.h"
28#include "TClonesArray.h"
29
30#include <cmath>
31#include <iostream>
32
33
34// ClassImp(CbmKfFitTracksTask);
35
36namespace
37{
38 using namespace cbm::algo;
39}
40
41
43 : FairTask("CbmKfFitTracksTask", iVerbose)
44 , fFitMode(mode)
45{
46}
47
49
50
52{
53
54 fFitter.Init();
55
56 //Get ROOT Manager
57 FairRootManager* ioman = FairRootManager::Instance();
58
59 if (!ioman) {
60 LOG(error) << "CbmKfFitTracksTask::Init :: RootManager not instantiated!";
61 return kERROR;
62 }
63
64 // Get global tracks
65
66 fGlobalTracks = dynamic_cast<TClonesArray*>(ioman->GetObject("GlobalTrack"));
67
68 // Get detector tracks
69 fStsTracks = dynamic_cast<TClonesArray*>(ioman->GetObject("StsTrack"));
70 fMuchTracks = dynamic_cast<TClonesArray*>(ioman->GetObject("MuchTrack"));
71 fTrdTracks = dynamic_cast<TClonesArray*>(ioman->GetObject("TrdTrack"));
72 fTofTracks = dynamic_cast<TClonesArray*>(ioman->GetObject("TofTrack"));
73
75 LOG(error) << "CbmKfFitTracksTask::Init: Global track array not found!";
76 return kERROR;
77 }
78
80 LOG(error) << "CbmKfFitTracksTask::Init: Sts track array not found!";
81 return kERROR;
82 }
83
84 return kSUCCESS;
85}
86
87void CbmKfFitTracksTask::Exec(Option_t* /*opt*/)
88{
89
90 LOG(info) << "CbmKfFitTracksTask: exec event N " << fNeventsProcessed++;
91
92 // select tracks for alignment and store them
94
95 for (int iTr = 0; iTr < fStsTracks->GetEntriesFast(); iTr++) {
96 CbmStsTrack* stsTrack = dynamic_cast<CbmStsTrack*>(fStsTracks->At(iTr));
97 if (!stsTrack) {
98 LOG(fatal) << "CbmKfFitTracksTask: null pointer to the sts track!";
99 return;
100 }
102 if (!fFitter.CreateMvdStsTrack(t, iTr)) {
103 LOG(fatal) << "CbmKfFitTracksTask: can not create the sts track for the fit! ";
104 return;
105 }
107 {
108 const auto& parV = t.fNodes.front().fParamUp;
110 parD.Set(parV, 0);
111 FairTrackParam trackFirst = cbm::kf::ConvertTrackParam(parD);
112 stsTrack->SetParamFirst(&trackFirst);
113 }
114 {
115 const auto& parV = t.fNodes.back().fParamDn;
117 parD.Set(parV, 0);
118 FairTrackParam trackLast = cbm::kf::ConvertTrackParam(parD);
119 stsTrack->SetParamLast(&trackLast);
120 }
121 }
122 }
123
125
126 fFitter.SetDefaultMomentumForMs(0.1); // 0.1 GeV/c
127 fFitter.FixMomentumForMs(true); // fix the momentum for the Multiple Scattering calculation
128
129 for (int iTr = 0; iTr < fGlobalTracks->GetEntriesFast(); iTr++) {
130 CbmGlobalTrack* globalTrack = dynamic_cast<CbmGlobalTrack*>(fGlobalTracks->At(iTr));
131 if (!globalTrack) {
132 LOG(fatal) << "CbmKfFitTracksTask: null pointer to the global track!";
133 return;
134 }
136 if (!fFitter.CreateGlobalTrack(t, *globalTrack)) {
137 LOG(fatal) << "CbmKfFitTracksTask: can not create the global track for the fit! ";
138 return;
139 }
141 {
142 const auto& parV = t.fNodes.front().fParamUp;
144 parD.Set(parV, 0);
145 FairTrackParam trackFirst = cbm::kf::ConvertTrackParam(parD);
146 globalTrack->SetParamFirst(&trackFirst);
147 }
148 {
149 const auto& parV = t.fNodes.back().fParamDn;
151 parD.Set(parV, 0);
152 FairTrackParam trackLast = cbm::kf::ConvertTrackParam(parD);
153 globalTrack->SetParamLast(&trackLast);
154 }
155 }
156 }
157}
158
159
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)
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
TClonesArray * fStsTracks
sts tracks
TClonesArray * fTofTracks
tof tracks
InitStatus Init() override
CbmKfFitTracksTask(FitMode mode=FitMode::kSts, Int_t iVerbose=0)
bool CreateMvdStsTrack(Trajectory &kfTrack, int stsTrackIndex)
set the input data arrays
bool CreateGlobalTrack(Trajectory &kfTrack, int globalTrackIndex)
void FixMomentumForMs(bool fix=true)
fix the inverse momentum for the Multiple Scattering calculation
void SetDefaultMomentumForMs(double p)
set the default inverse momentum for the Multiple Scattering calculation
bool FitTrajectory(CbmKfTrackFitter::Trajectory &t)
fit the track
void SetParamFirst(const FairTrackParam *par)
Definition CbmTrack.h:86
void SetParamLast(const FairTrackParam *par)
Definition CbmTrack.h:87
void Set(const TrackParamBase< T1 > &Tb)
cbm::algo::kf::TrackParamD ConvertTrackParam(const FairTrackParam &par)
copy fair track param to Ca track param
Definition CbmKfUtil.cxx:12
A trajectory to be fitted.
std::vector< TrajectoryNode > fNodes
nodes on the trajectory