BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
CbmStsFitTracks.cxx
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- CbmStsFitTracks source file -----
3// ----- Created 18/02/05 by V. Friese -----
4// -------------------------------------------------------------------------
5#include "CbmStsFitTracks.h"
6
7#include "CbmStsTrackFitter.h"
8#include "FairRootManager.h"
9#include "TClonesArray.h"
10
11#include <iomanip>
12#include <iostream>
13
14using std::cout;
15using std::endl;
16using std::fixed;
17using std::left;
18using std::right;
19using std::setprecision;
20using std::setw;
21
22// ----- Default constructor -------------------------------------------
24 : FairTask("STSFitTracks")
25 , fFitter(NULL)
26 , fTracks(NULL)
27 , fTimer()
28 , fNEvents(0)
29 , fNFailed(0)
30 , fTime(0.)
31 , fNTracks(0)
32{}
33
34// ----- Standard constructor ------------------------------------------
36 : FairTask("STSFitTracks")
37 , fFitter(fitter)
38 , fTracks(NULL)
39 , fTimer()
40 , fNEvents(0)
41 , fNFailed(0)
42 , fTime(0.)
43 , fNTracks(0)
44{}
45
46// ----- Constructor with name -----------------------------------------
47CbmStsFitTracks::CbmStsFitTracks(const char* name, CbmStsTrackFitter* fitter, Int_t iVerbose)
48 : FairTask(name, iVerbose)
49 , fFitter(fitter)
50 , fTracks(NULL)
51 , fTimer()
52 , fNEvents(0)
53 , fNFailed(0)
54 , fTime(0.)
55 , fNTracks(0)
56{}
57
58// ----- Destructor ----------------------------------------------------
60// -------------------------------------------------------------------------
61
62// ----- Virtual public method Exec ------------------------------------
64{
65 fTimer.Start();
66
67 if (!fTracks) {
68 cout << "-E- " << fName << "::Exec: No StsTrack array! " << endl;
69 fNFailed++;
70 return;
71 }
72
73 Int_t nTracks = fTracks->GetEntriesFast();
74 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
75 CbmStsTrack* pTrack = (CbmStsTrack*)fTracks->At(iTrack);
76 fFitter->DoFit(pTrack);
77 }
78
79 fTimer.Stop();
80 if (fVerbose)
81 cout << "+ " << setw(15) << left << fName << ": " << setprecision(4) << setw(8) << fixed << right
82 << fTimer.RealTime() << " s, tracks fitted " << nTracks << endl;
83
84 fNEvents++;
85 fTime += fTimer.RealTime();
86 fNTracks += Double_t(nTracks);
87}
88// -------------------------------------------------------------------------
89
90// ----- Virtual private method Init -------------- --------------------
92{
93
94 // Check for Track fitter
95 if (!fFitter) {
96 cout << "-E- CbmStsFitTracks: No track fitter selected!" << endl;
97 return kERROR;
98 }
99
100 // Get and check FairRootManager
101 FairRootManager* ioman = FairRootManager::Instance();
102 if (!ioman) {
103 cout << "-E- CbmStsFitTracks::Init: "
104 << "RootManager not instantised!" << endl;
105 return kFATAL;
106 }
107
108 // Get StsTrack array
109 fTracks = (TClonesArray*)ioman->GetObject("StsTrack"); //=>SG
110 if (!fTracks) {
111 cout << "-E- CbmStsFitTracks::Init: No StsTrack array!" << endl;
112 return kERROR;
113 }
114
115 // Call the Init method of the track fitter
116 fFitter->Init();
117
118 return kSUCCESS;
119}
120// -------------------------------------------------------------------------
121
122// ----- Virtual private method Finish ---------------------------------
124{
125
126 cout << endl;
127 cout << "============================================================" << endl;
128 cout << "===== " << GetName() << ": Run summary " << endl;
129 cout << "===== " << endl;
130 cout << "===== Good events : " << setw(6) << fNEvents << endl;
131 cout << "===== Failed events : " << setw(6) << fNFailed << endl;
132 cout << "===== Average time : " << setprecision(4) << setw(8) << right << fTime / Double_t(fNEvents) << " s"
133 << endl;
134 cout << "===== " << endl;
135 cout << "===== Fitted tracks per event : " << fixed << setprecision(0) << fNTracks / Double_t(fNEvents) << endl;
136 cout << "============================================================" << endl;
137}
138// -------------------------------------------------------------------------
int Int_t
double Double_t
const char Option_t
CbmStsTrackFitter * fFitter
CbmStsFitTracks()
Default constructor.
TClonesArray * fTracks
virtual void Finish()
Finish at the end of each event.
virtual InitStatus Init()
Initialisation at beginning of each event.
virtual void Exec(Option_t *opt)
Task execution.
virtual ~CbmStsFitTracks()
Destructor.