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