CbmRoot
CbmLitFindMvdTracks.cxx
Go to the documentation of this file.
1 
7 #include "CbmLitFindMvdTracks.h"
10 #include "data/CbmLitHit.h"
11 #include "data/CbmLitPixelHit.h"
12 #include "data/CbmLitTrack.h"
13 #include "data/CbmLitTrackParam.h"
15 #include "utils/CbmLitConverter.h"
18 
19 #include "CbmStsTrack.h"
20 #include "FairHit.h"
21 #include "FairLogger.h"
22 #include "FairRunAna.h"
23 #include "FairRuntimeDb.h"
24 
25 #include "TClonesArray.h"
26 
27 #include <algorithm>
28 #include <iostream>
29 
31  : fStsTracks(NULL)
32  , fMvdHits(NULL)
33  , fEvents(NULL)
34  , fLitStsTracks()
35  , fLitMvdHits()
36  , fLitOutputTracks()
37  , fFinder()
38  , fEventNo(0) {}
39 
41 
44 
46 
47  return kSUCCESS;
48 }
49 
50 void CbmLitFindMvdTracks::Exec(Option_t* opt) {
51  if (fStsTracks != NULL && fMvdHits != NULL) {
52  if (fEvents) {
53  Int_t nEvents = fEvents->GetEntriesFast();
54  LOG(debug) << GetName() << ": reading time slice with " << nEvents
55  << " events ";
56 
57  for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
58  CbmEvent* event = static_cast<CbmEvent*>(fEvents->At(iEvent));
59  ConvertInputData(event);
60  } //# events
61  } //? event branch present
62  else { // Old event-by-event simulation without event branch
64  }
65 
68  ClearArrays();
69  } else {
70  LOG(warn) << "CbmLitFindMvdTracks::Exec: MVD tracking is not executed NO "
71  "StsTrack or MvdHit arrays.";
72  }
73  LOG(info) << "-I- Event: " << fEventNo++;
74 }
75 
77  FairRunAna* ana = FairRunAna::Instance();
78  FairRuntimeDb* rtdb = ana->GetRuntimeDb();
79  rtdb->getContainer("FairBaseParSet");
80 }
81 
83 
85  FairRootManager* ioman = FairRootManager::Instance();
86  if (NULL == ioman) {
87  LOG(fatal) << "CbmLitFindMvdTracks::ReadAndCreateDataBranches "
88  "FairRootManager is not instantiated";
89  }
90  fMvdHits = (TClonesArray*) ioman->GetObject("MvdHit");
91  fStsTracks = (TClonesArray*) ioman->GetObject("StsTrack");
92  fEvents = dynamic_cast<TClonesArray*>(ioman->GetObject("Event"));
93 }
94 
97  // Change last and first parameters of the track seeds
98  for (Int_t iTrack = 0; iTrack < fLitStsTracks.size(); iTrack++) {
99  CbmLitTrack* track = fLitStsTracks[iTrack];
100  const CbmLitTrackParam* parFirst = track->GetParamFirst();
101  track->SetParamLast(parFirst);
102  }
103  LOG(info) << "-I- Number of STS tracks: " << fLitStsTracks.size();
104 
106  // Make reverse order of the hits
107  Int_t nofStations =
109  for (Int_t iHit = 0; iHit < fLitMvdHits.size(); iHit++) {
110  CbmLitHit* hit = fLitMvdHits[iHit];
111  hit->SetDetectorId(kLITMVD, nofStations - hit->GetStation() - 1);
112  }
113  LOG(info) << "-I- Number of MVD hits: " << fLitMvdHits.size();
114 }
115 
117  for (Int_t iTrack = 0; iTrack < fLitOutputTracks.size(); iTrack++) {
118  CbmLitTrack* litTrack = fLitOutputTracks[iTrack];
119  Int_t trackId = litTrack->GetPreviousTrackId();
120  CbmStsTrack* track = static_cast<CbmStsTrack*>(fStsTracks->At(trackId));
121  for (Int_t iHit = 0; iHit < litTrack->GetNofHits(); iHit++) {
122  const CbmLitHit* litHit = litTrack->GetHit(iHit);
123  Int_t refId = litHit->GetRefId();
124  FairHit* hit = static_cast<FairHit*>(fMvdHits->At(refId));
125  track->AddMvdHit(refId);
126  }
127  //track->SortMvdHits();
128 
129  FairTrackParam parFirst;
131  litTrack->GetParamLast(), &parFirst);
132  track->SetParamFirst(&parFirst);
133  }
134 }
135 
137  // Free memory
138  for_each(fLitStsTracks.begin(), fLitStsTracks.end(), DeleteObject());
139  for_each(fLitMvdHits.begin(), fLitMvdHits.end(), DeleteObject());
140  for_each(fLitOutputTracks.begin(), fLitOutputTracks.end(), DeleteObject());
141  fLitStsTracks.clear();
142  fLitMvdHits.clear();
143  fLitOutputTracks.clear();
144 }
145 
148 }
CbmLitTrackParam.h
Data class for track parameters.
CbmLitMemoryManagment.h
CbmLitFindMvdTracks::fStsTracks
TClonesArray * fStsTracks
Definition: CbmLitFindMvdTracks.h:87
CbmLitFindMvdTracks::ReadAndCreateDataBranches
void ReadAndCreateDataBranches()
Read necessary data branches from the input data files.
Definition: CbmLitFindMvdTracks.cxx:84
CbmLitTrackParam
Data class for track parameters.
Definition: CbmLitTrackParam.h:29
CbmLitFindMvdTracks::SetParContainers
virtual void SetParContainers()
Inherited from FairTask.
Definition: CbmLitFindMvdTracks.cxx:76
CbmLitFindMvdTracks::fMvdHits
TClonesArray * fMvdHits
Definition: CbmLitFindMvdTracks.h:88
CbmLitTrackingGeometryConstructor.h
Tracking geometry constructor.
CbmLitTrackingGeometryConstructor::GetNofMvdStations
Int_t GetNofMvdStations()
Return number of stations in MVD.
Definition: CbmLitTrackingGeometryConstructor.cxx:419
CbmLitToolFactory.h
Tool factory for creation of littrack algorithms.
CbmLitFindMvdTracks::fLitStsTracks
TrackPtrVector fLitStsTracks
Definition: CbmLitFindMvdTracks.h:92
CbmLitHit::GetRefId
Int_t GetRefId() const
Definition: CbmLitHit.h:46
CbmLitPixelHit.h
Base data class for pixel hits.
CbmLitHit::SetDetectorId
void SetDetectorId(LitSystemId sysId, Int_t station)
Definition: CbmLitHit.h:66
CbmLitTrack::SetParamLast
void SetParamLast(const CbmLitTrackParam *par)
Definition: CbmLitTrack.h:82
CbmLitFindMvdTracks::Exec
virtual void Exec(Option_t *opt)
Inherited from FairTask.
Definition: CbmLitFindMvdTracks.cxx:50
CbmLitConverterFairTrackParam::CbmLitTrackParamToFairTrackParam
static void CbmLitTrackParamToFairTrackParam(const CbmLitTrackParam *litPar, FairTrackParam *par)
Definition: CbmLitConverterFairTrackParam.h:110
DeleteObject
Definition: CbmLitMemoryManagment.h:5
CbmLitFindMvdTracks::fEvents
TClonesArray * fEvents
Definition: CbmLitFindMvdTracks.h:89
CbmLitFindMvdTracks::ConvertOutputData
void ConvertOutputData()
Convert output littrack data classes to CBMROOT data classes.
Definition: CbmLitFindMvdTracks.cxx:116
CbmLitFindMvdTracks::ConvertInputData
void ConvertInputData(CbmEvent *event)
Convert input data from CBMROOT data classes to littrack data classes.
Definition: CbmLitFindMvdTracks.cxx:95
CbmStsTrack.h
Data class for STS tracks.
CbmLitTrack::GetPreviousTrackId
Int_t GetPreviousTrackId() const
Definition: CbmLitTrack.h:60
CbmLitHit
Base data class for hits.
Definition: CbmLitHit.h:26
CbmLitToolFactory::CreateTrackFinder
static TrackFinderPtr CreateTrackFinder(const string &name)
Create track selection tool by name.
Definition: CbmLitToolFactory.cxx:121
CbmLitConverter::MvdHitArrayToHitVector
static void MvdHitArrayToHitVector(const TClonesArray *hits, HitPtrVector &litHits)
Definition: CbmLitConverter.h:332
CbmLitConverterFairTrackParam.h
CbmLitFindMvdTracks::ClearArrays
void ClearArrays()
Clear arrays and free memory.
Definition: CbmLitFindMvdTracks.cxx:136
CbmLitTrack
Base data class for track.
Definition: CbmLitTrack.h:30
CbmLitFindMvdTracks::fFinder
TrackFinderPtr fFinder
Definition: CbmLitFindMvdTracks.h:97
CbmLitFindMvdTracks::fLitMvdHits
HitPtrVector fLitMvdHits
Definition: CbmLitFindMvdTracks.h:93
CbmLitTrack::GetParamLast
const CbmLitTrackParam * GetParamLast() const
Definition: CbmLitTrack.h:63
CbmLitHit::GetStation
Int_t GetStation() const
Definition: CbmLitHit.h:55
CbmLitFindMvdTracks::fEventNo
Int_t fEventNo
Definition: CbmLitFindMvdTracks.h:99
CbmLitFindMvdTracks::~CbmLitFindMvdTracks
virtual ~CbmLitFindMvdTracks()
Destructor.
Definition: CbmLitFindMvdTracks.cxx:40
CbmLitFindMvdTracks::CbmLitFindMvdTracks
CbmLitFindMvdTracks()
Constructor.
Definition: CbmLitFindMvdTracks.cxx:30
CbmLitTrack::GetParamFirst
const CbmLitTrackParam * GetParamFirst() const
Definition: CbmLitTrack.h:62
CbmLitFindMvdTracks.h
MVD tracking based on littrack package.
CbmLitConverter::StsTrackArrayToTrackVector
static void StsTrackArrayToTrackVector(CbmEvent *event, const TClonesArray *tracks, TrackPtrVector &litTracks)
Definition: CbmLitConverter.h:344
CbmLitConverter.h
CbmLitTrack.h
Base data class for track.
CbmTrack::SetParamFirst
void SetParamFirst(const FairTrackParam *par)
Definition: CbmTrack.h:75
CbmEvent
Class characterising one event by a collection of links (indices) to data objects,...
Definition: CbmEvent.h:30
kLITMVD
@ kLITMVD
Definition: CbmLitEnums.h:44
CbmStsTrack
Definition: CbmStsTrack.h:37
CbmLitFindMvdTracks::Finish
virtual void Finish()
Inherited from FairTask.
Definition: CbmLitFindMvdTracks.cxx:82
CbmLitTrackingGeometryConstructor::Instance
static CbmLitTrackingGeometryConstructor * Instance()
Return pointer to singleton object.
Definition: CbmLitTrackingGeometryConstructor.cxx:55
CbmLitTrack::GetHit
const CbmLitHit * GetHit(Int_t index) const
Definition: CbmLitTrack.h:65
CbmLitFindMvdTracks::Init
virtual InitStatus Init()
Inherited from FairTask.
Definition: CbmLitFindMvdTracks.cxx:42
CbmLitHit.h
Base data class for hits.
CbmLitFindMvdTracks::RunTrackReconstruction
void RunTrackReconstruction()
Run track reconstruction.
Definition: CbmLitFindMvdTracks.cxx:146
CbmLitTrack::GetNofHits
Int_t GetNofHits() const
Definition: CbmLitTrack.h:56
CbmLitTrackFinderNN.h
Implementation of nearest neighbor tracking algorithm.
CbmLitFindMvdTracks::fLitOutputTracks
TrackPtrVector fLitOutputTracks
Definition: CbmLitFindMvdTracks.h:94
CbmStsTrack::AddMvdHit
void AddMvdHit(Int_t hitIndex)
Definition: CbmStsTrack.h:50