CbmRoot
CbmLitFitTracksParallel.cxx
Go to the documentation of this file.
1 
8 #include "CbmStsTrack.h"
9 #include "CbmTrack.h"
10 #include "FairRootManager.h"
11 #include "FairTrackParam.h"
16 #include "parallel/LitScalTrack.h"
19 
20 #include "TClonesArray.h"
21 
22 #include <algorithm>
23 #include <cassert>
24 #include <iostream>
25 #include <vector>
26 
27 using std::cout;
28 using std::endl;
29 using std::for_each;
30 using std::vector;
31 
33  : FairTask()
34  , fGlobalTracks(NULL)
35  , fStsTracks(NULL)
36  , fMuchTracks(NULL)
37  , fTrdTracks(NULL)
38  , fMuchPixelHits(NULL)
39  , fMuchStrawHits(NULL)
40  , fTrdHits(NULL) {}
41 
43 
46 
47  fFitWatch.Reset();
48  fFitWithIOWatch.Reset();
49 
50  return kSUCCESS;
51 }
52 
53 void CbmLitFitTracksParallel::Exec(Option_t* opt) {
54  static Int_t eventNo = 0;
55  std::cout << "CbmLitFitTracksParallel::Exec: eventNo=" << eventNo++
56  << std::endl;
57 
58  DoFit();
59 }
60 
62 
64  FairRootManager* ioman = FairRootManager::Instance();
65  assert(ioman != NULL);
66 
67  fGlobalTracks = (TClonesArray*) ioman->GetObject("GlobalTrack");
68  fStsTracks = (TClonesArray*) ioman->GetObject("StsTrack");
69  fMuchTracks = (TClonesArray*) ioman->GetObject("MuchTrack");
70  fTrdTracks = (TClonesArray*) ioman->GetObject("TrdTrack");
71  fMuchPixelHits = (TClonesArray*) ioman->GetObject("MuchPixelHit");
72  fMuchStrawHits = (TClonesArray*) ioman->GetObject("MuchStrawHit");
73  fTrdHits = (TClonesArray*) ioman->GetObject("TrdHit");
74 }
75 
77  static Bool_t isTrd = fTrdTracks != NULL;
78  static Bool_t isMuch = fMuchTracks != NULL;
79 
80  static Bool_t firstTime = true;
82  if (firstTime) {
83  if (isTrd) {
85  } else if (isMuch) {
87  }
88  firstTime = false;
89  }
90 
91  fFitWithIOWatch.Start(kFALSE);
92 
93  // Convert input data
94  vector<lit::parallel::LitScalTrack*> ltracks;
95  vector<lit::parallel::LitScalPixelHit*> lhits;
96  if (isTrd) {
98  lhits);
100  fTrdTracks, lhits, ltracks);
101  } else if (isMuch) {
103  fMuchPixelHits, lhits);
105  fMuchTracks, lhits, ltracks);
106  }
107 
108  // Replace first track parameter of the converted tracks with the last STS track parameter
109  Int_t nofTracks = ltracks.size();
110  for (Int_t iTrack = 0; iTrack < nofTracks; iTrack++) {
111  lit::parallel::LitScalTrack& track = *ltracks[iTrack];
112  Int_t stsTrackId = track.GetPreviousTrackId();
113  CbmStsTrack* stsTrack =
114  static_cast<CbmStsTrack*>(fStsTracks->At(stsTrackId));
117  stsTrack->GetParamLast(), &lpar);
118  track.SetParamFirst(lpar);
119  }
120 
121  fFitWatch.Start(kFALSE);
122  // Int_t nofTracks = ltracks.size();
123  for (Int_t iTrack = 0; iTrack < nofTracks; iTrack++) {
124  lit::parallel::LitScalTrack& track = *ltracks[iTrack];
125  LitTrackFitter(track, layout);
126  }
127  fFitWatch.Stop();
128 
129  // Replace first and last track parameters for the fitted track
130  for (Int_t iTrack = 0; iTrack < nofTracks; iTrack++) {
131  lit::parallel::LitScalTrack& track = *ltracks[iTrack];
132  CbmTrack* cbmTrack = (isTrd)
133  ? static_cast<CbmTrack*>(fTrdTracks->At(iTrack))
134  : static_cast<CbmTrack*>(fMuchTracks->At(iTrack));
135  FairTrackParam firstParam, lastParam;
137  &track.GetParamFirst(), &firstParam);
139  &track.GetParamLast(), &lastParam);
140  cbmTrack->SetParamFirst(&firstParam);
141  cbmTrack->SetParamLast(&lastParam);
142  }
143 
144  // Clear memory
145  for_each(ltracks.begin(), ltracks.end(), DeleteObject());
146  for_each(lhits.begin(), lhits.end(), DeleteObject());
147  ltracks.clear();
148  lhits.clear();
149 
150  fFitWithIOWatch.Stop();
151 }
152 
154  cout << "CbmLitFitTracksParallel::PrintStopwatchStatistics: " << endl;
155  cout << "fit without IO: counts=" << fFitWatch.Counter()
156  << ", real=" << fFitWatch.RealTime() / fFitWatch.Counter() << "/"
157  << fFitWatch.RealTime()
158  << " s, cpu=" << fFitWatch.CpuTime() / fFitWatch.Counter() << "/"
159  << fFitWatch.CpuTime() << endl;
160  cout << "fit with IO: counts=" << fFitWithIOWatch.Counter()
161  << ", real=" << fFitWithIOWatch.RealTime() / fFitWithIOWatch.Counter()
162  << "/" << fFitWithIOWatch.RealTime()
163  << " s, cpu=" << fFitWithIOWatch.CpuTime() / fFitWithIOWatch.Counter()
164  << "/" << fFitWithIOWatch.CpuTime() << endl;
165 }
CbmTrack::GetParamLast
const FairTrackParam * GetParamLast() const
Definition: CbmTrack.h:62
CbmLitFitTracksParallel::Exec
virtual void Exec(Option_t *opt)
Derived from FairTask.
Definition: CbmLitFitTracksParallel.cxx:53
CbmLitMemoryManagment.h
CbmLitFitTracksParallel::fStsTracks
TClonesArray * fStsTracks
Definition: CbmLitFitTracksParallel.h:59
CbmLitFitTracksParallel::DoFit
void DoFit()
Performs track fit.
Definition: CbmLitFitTracksParallel.cxx:76
CbmLitFitTracksParallel::fMuchPixelHits
TClonesArray * fMuchPixelHits
Definition: CbmLitFitTracksParallel.h:63
CbmLitTrackingGeometryConstructor.h
Tracking geometry constructor.
LitTrackFitter.h
Kalman filter based track fit.
CbmTrack::SetParamLast
void SetParamLast(const FairTrackParam *par)
Definition: CbmTrack.h:76
lit::parallel::LitScalTrack
Scalar track data class.
Definition: LitScalTrack.h:33
lit::parallel::LitTrackFitter
void LitTrackFitter(LitScalTrack &track, const LitDetectorLayoutScal &layout)
Fast scalar track fit.
Definition: LitTrackFitter.h:25
DeleteObject
Definition: CbmLitMemoryManagment.h:5
CbmLitTrackingGeometryConstructor::GetTrdLayoutScal
void GetTrdLayoutScal(lit::parallel::LitDetectorLayoutScal &layout)
Return TRD detector layout for TRD parallel tracking in scalar format.
Definition: CbmLitTrackingGeometryConstructor.cxx:158
lit::parallel::LitDetectorLayout< fscal >
lit::parallel::LitTrackParam< fscal >
CbmLitFitTracksParallel::Init
virtual InitStatus Init()
Derived from FairTask.
Definition: CbmLitFitTracksParallel.cxx:44
CbmTrack
Definition: CbmTrack.h:32
CbmStsTrack.h
Data class for STS tracks.
CbmLitFitTracksParallel::Finish
virtual void Finish()
Derived from FairTask.
Definition: CbmLitFitTracksParallel.cxx:61
CbmLitConverterParallel::FairTrackParamToLitTrackParamScal
static void FairTrackParamToLitTrackParamScal(const FairTrackParam *par, lit::parallel::LitTrackParamScal *lpar)
Convert FairTrackParam to LitTrackParamScal.
Definition: CbmLitConverterParallel.cxx:27
lit::parallel::LitScalTrack::SetParamFirst
void SetParamFirst(const LitTrackParamScal &param)
Sets first track parameter.
Definition: LitScalTrack.h:96
CbmLitFitTracksParallel::fTrdTracks
TClonesArray * fTrdTracks
Definition: CbmLitFitTracksParallel.h:60
CbmLitFitTracksParallel::fFitWatch
TStopwatch fFitWatch
Definition: CbmLitFitTracksParallel.h:67
CbmTrack.h
LitScalTrack.h
Scalar track data class.
CbmLitFitTracksParallel::PrintStopwatchStatistics
void PrintStopwatchStatistics()
Print stopwatch statistics.
Definition: CbmLitFitTracksParallel.cxx:153
CbmLitFitTracksParallel.h
Task to fit TRD and MUCH tracks using parallel track fit algorithms.
LitScalPixelHit.h
Base class for scalar pixel hits.
lit::parallel::LitScalTrack::GetPreviousTrackId
unsigned short GetPreviousTrackId() const
Return Previous track index.
Definition: LitScalTrack.h:182
CbmLitFitTracksParallel::fFitWithIOWatch
TStopwatch fFitWithIOWatch
Definition: CbmLitFitTracksParallel.h:68
CbmLitTrackingGeometryConstructor::GetMuchLayoutScal
void GetMuchLayoutScal(lit::parallel::LitDetectorLayoutScal &layout)
Return MUCH detector layout for parallel MUCH tracking in scalar format.
Definition: CbmLitTrackingGeometryConstructor.cxx:65
CbmLitConverterParallel::CbmPixelHitArrayToLitScalPixelHitArray
static void CbmPixelHitArrayToLitScalPixelHitArray(const TClonesArray *hits, vector< lit::parallel::LitScalPixelHit * > &lhits)
Convert CbmPixelHit array to LitScalPixelHit arra.
Definition: CbmLitConverterParallel.cxx:106
CbmLitFitTracksParallel::fMuchTracks
TClonesArray * fMuchTracks
Definition: CbmLitFitTracksParallel.h:61
CbmLitFitTracksParallel::~CbmLitFitTracksParallel
virtual ~CbmLitFitTracksParallel()
Destructor.
Definition: CbmLitFitTracksParallel.cxx:42
CbmLitConverterParallel.h
Class for conversion between CBMROOT data classes and littrack parallel data classes.
CbmLitFitTracksParallel::CbmLitFitTracksParallel
CbmLitFitTracksParallel()
Constructor.
Definition: CbmLitFitTracksParallel.cxx:32
LitDetectorLayout.h
Detector layout class.
CbmLitFitTracksParallel::ReadDataBranches
void ReadDataBranches()
Read data branches.
Definition: CbmLitFitTracksParallel.cxx:63
lit::parallel::LitScalTrack::GetParamFirst
const LitTrackParamScal & GetParamFirst() const
Returns first parameter of the track.
Definition: LitScalTrack.h:90
CbmLitFitTracksParallel::fMuchStrawHits
TClonesArray * fMuchStrawHits
Definition: CbmLitFitTracksParallel.h:64
CbmLitConverterParallel::CbmTrackArrayToLitScalTrackArray
static void CbmTrackArrayToLitScalTrackArray(const TClonesArray *tracks, const vector< lit::parallel::LitScalPixelHit * > &lhits, vector< lit::parallel::LitScalTrack * > &ltracks)
Convert array of CbmTrack to array of LitScalTrack.
Definition: CbmLitConverterParallel.cxx:147
CbmLitConverterParallel::LitTrackParamScalToFairTrackParam
static void LitTrackParamScalToFairTrackParam(const lit::parallel::LitTrackParamScal *lpar, FairTrackParam *par)
Convert LitTrackParamScal to FairTrackParam.
Definition: CbmLitConverterParallel.cxx:55
lit::parallel::LitScalTrack::GetParamLast
const LitTrackParamScal & GetParamLast() const
Returns last parameter of the track.
Definition: LitScalTrack.h:104
CbmTrack::SetParamFirst
void SetParamFirst(const FairTrackParam *par)
Definition: CbmTrack.h:75
CbmLitFitTracksParallel::fGlobalTracks
TClonesArray * fGlobalTracks
Definition: CbmLitFitTracksParallel.h:58
CbmStsTrack
Definition: CbmStsTrack.h:37
CbmLitTrackingGeometryConstructor::Instance
static CbmLitTrackingGeometryConstructor * Instance()
Return pointer to singleton object.
Definition: CbmLitTrackingGeometryConstructor.cxx:55
CbmLitFitTracksParallel
Definition: CbmLitFitTracksParallel.h:14
ClassImp
ClassImp(CbmLitFitTracksParallel)
CbmLitFitTracksParallel::fTrdHits
TClonesArray * fTrdHits
Definition: CbmLitFitTracksParallel.h:62