CbmRoot
Loading...
Searching...
No Matches
CbmLitFitTracks.cxx
Go to the documentation of this file.
1/* Copyright (C) 2013-2020 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer] */
4
11#include "CbmLitFitTracks.h"
12
13#include "CbmStsTrack.h"
14#include "CbmTrack.h"
15#include "FairRootManager.h"
16#include "FairTrackParam.h"
17#include "TClonesArray.h"
18#include "base/CbmLitPtrTypes.h"
20#include "base/CbmLitTypes.h"
25
26#include <algorithm>
27#include <cassert>
28#include <iostream>
29#include <vector>
30
31using std::cout;
32using std::endl;
33using std::for_each;
34using std::vector;
35
37 : FairTask()
38 , fGlobalTracks(NULL)
39 , fStsTracks(NULL)
40 , fMuchTracks(NULL)
41 , fTrdTracks(NULL)
42 , fMuchPixelHits(NULL)
43 , fMuchStrawHits(NULL)
44 , fTrdHits(NULL)
45{
46}
47
49
51{
53
54 fFitWatch.Reset();
55 fFitWithIOWatch.Reset();
56
57 return kSUCCESS;
58}
59
60void CbmLitFitTracks::Exec(Option_t* opt)
61{
62 static Int_t eventNo = 0;
63 std::cout << "CbmLitFitTracks::Exec: eventNo=" << eventNo++ << std::endl;
64
65 DoFit();
66}
67
69
71{
72 FairRootManager* ioman = FairRootManager::Instance();
73 assert(ioman != NULL);
74
75 fGlobalTracks = (TClonesArray*) ioman->GetObject("GlobalTrack");
76 fStsTracks = (TClonesArray*) ioman->GetObject("StsTrack");
77 fMuchTracks = (TClonesArray*) ioman->GetObject("MuchTrack");
78 fTrdTracks = (TClonesArray*) ioman->GetObject("TrdTrack");
79 fMuchPixelHits = (TClonesArray*) ioman->GetObject("MuchPixelHit");
80 fMuchStrawHits = (TClonesArray*) ioman->GetObject("MuchStrawHit");
81 fTrdHits = (TClonesArray*) ioman->GetObject("TrdHit");
82}
83
85{
86 static Bool_t firstTime = true;
87 static TrackFitterPtr fitter;
88 if (firstTime) {
89 fitter = CbmLitToolFactory::CreateTrackFitter("lit_kalman");
90 firstTime = false;
91 }
92
93 fFitWithIOWatch.Start(kFALSE);
94
95 // Convert input data
96 TrackPtrVector ltracks;
97 HitPtrVector lhits;
100
101 // Replace first track parameter of the converted tracks with the last STS track parameter
102 Int_t nofTracks = ltracks.size();
103 for (Int_t iTrack = 0; iTrack < nofTracks; iTrack++) {
104 CbmLitTrack* track = ltracks[iTrack];
105 Int_t stsTrackId = track->GetPreviousTrackId();
106 CbmStsTrack* stsTrack = static_cast<CbmStsTrack*>(fStsTracks->At(stsTrackId));
107 CbmTrackParam cbmLPar;
108 cbmLPar.Set(*stsTrack->GetParamLast(), stsTrack->GetLastHitTime(), stsTrack->GetLastHitTimeError());
109 CbmLitTrackParam lpar;
111 track->SetParamFirst(&lpar);
112 track->SetPDG(211);
113 }
114
115 fFitWatch.Start(kFALSE);
116 for (Int_t iTrack = 0; iTrack < nofTracks; iTrack++) {
117 CbmLitTrack* track = ltracks[iTrack];
118 fitter->Fit(track);
119 }
120 fFitWatch.Stop();
121
122 // Replace first and last track parameters for the fitted track
123 for (Int_t iTrack = 0; iTrack < nofTracks; iTrack++) {
124 CbmLitTrack* track = ltracks[iTrack];
125 CbmTrack* trdTrack = static_cast<CbmTrack*>(fTrdTracks->At(iTrack));
126 FairTrackParam firstParam, lastParam;
129 trdTrack->SetParamFirst(&firstParam);
130 trdTrack->SetParamLast(&lastParam);
131 }
132
133 // Clear memory
134 for_each(ltracks.begin(), ltracks.end(), DeleteObject());
135 for_each(lhits.begin(), lhits.end(), DeleteObject());
136 ltracks.clear();
137 lhits.clear();
138
139 fFitWithIOWatch.Stop();
140}
141
143{
144 cout << "CbmLitFitTracks::PrintStopwatchStatistics: " << endl;
145 cout << "fit without IO: counts=" << fFitWatch.Counter() << ", real=" << fFitWatch.RealTime() / fFitWatch.Counter()
146 << "/" << fFitWatch.RealTime() << " s, cpu=" << fFitWatch.CpuTime() / fFitWatch.Counter() << "/"
147 << fFitWatch.CpuTime() << endl;
148 cout << "fit with IO: counts=" << fFitWithIOWatch.Counter()
149 << ", real=" << fFitWithIOWatch.RealTime() / fFitWithIOWatch.Counter() << "/" << fFitWithIOWatch.RealTime()
150 << " s, cpu=" << fFitWithIOWatch.CpuTime() / fFitWithIOWatch.Counter() << "/" << fFitWithIOWatch.CpuTime()
151 << endl;
152}
ClassImp(CbmLitFitTracks)
Task for testing of standard track fit algorithms.
Typedefs for algorithm interfaces.
Tool factory for creation of littrack algorithms.
Base data class for track.
Typedefs for data structures used in littrack.
Data class for STS tracks.
boost::shared_ptr< CbmLitTrackFitter > TrackFitterPtr
std::vector< CbmTofTrack * > TrackPtrVector
Definition CbmTofTypes.h:26
std::vector< CbmTofHit * > HitPtrVector
Definition CbmTofTypes.h:20
static void FairTrackParamToCbmLitTrackParam(const FairTrackParam *par, CbmLitTrackParam *litPar)
static void CbmLitTrackParamToFairTrackParam(const CbmLitTrackParam *litPar, FairTrackParam *par)
static void HitArrayToHitVector(CbmEvent *event, ECbmDataType hitDataType, const TClonesArray *hits, HitPtrVector &litHits)
static void CbmTrackArrayToCbmLitTrackArray(const TClonesArray *tracks, const HitPtrVector &lhits, TrackPtrVector &ltracks)
TClonesArray * fTrdHits
CbmLitFitTracks()
Constructor.
virtual ~CbmLitFitTracks()
Destructor.
TClonesArray * fMuchTracks
TStopwatch fFitWatch
virtual InitStatus Init()
Derived from FairTask.
virtual void Finish()
Derived from FairTask.
TClonesArray * fGlobalTracks
TClonesArray * fStsTracks
virtual void Exec(Option_t *opt)
Derived from FairTask.
TStopwatch fFitWithIOWatch
TClonesArray * fMuchPixelHits
void ReadDataBranches()
Read data branches.
void PrintStopwatchStatistics()
Print stopwatch statistics.
TClonesArray * fTrdTracks
TClonesArray * fMuchStrawHits
void DoFit()
Performs track fit.
static TrackFitterPtr CreateTrackFitter(const string &name)
Create track fit tool by name.
Data class for track parameters.
Base data class for track.
Definition CbmLitTrack.h:34
Int_t GetPreviousTrackId() const
Definition CbmLitTrack.h:66
void SetParamFirst(const CbmLitTrackParam *par)
Definition CbmLitTrack.h:85
const CbmLitTrackParam * GetParamFirst() const
Definition CbmLitTrack.h:68
const CbmLitTrackParam * GetParamLast() const
Definition CbmLitTrack.h:69
void SetPDG(Int_t pdg)
Definition CbmLitTrack.h:84
void Set(const FairTrackParam &ftp, double time=0., double timeError=0.)
double GetLastHitTime() const
Definition CbmTrack.h:75
const FairTrackParam * GetParamLast() const
Definition CbmTrack.h:69
double GetLastHitTimeError() const
Definition CbmTrack.h:76
void SetParamFirst(const FairTrackParam *par)
Definition CbmTrack.h:86
void SetParamLast(const FairTrackParam *par)
Definition CbmTrack.h:87