CbmRoot
Loading...
Searching...
No Matches
CbmFindGlobalTracks.cxx
Go to the documentation of this file.
1/* Copyright (C) 2005-2016 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese, Denis Bertini [committer], Florian Uhlig */
4
5// -------------------------------------------------------------------------
6// ----- CbmFindGlobalTracks source file -----
7// ----- Created 01/12/05 by V. Friese -----
8// -------------------------------------------------------------------------
10
11#include "CbmRichMerger.h"
12#include "CbmTofMerger.h"
13#include "CbmTrackMerger.h"
14#include "FairRootManager.h"
15#include "TClonesArray.h"
16
17#include <iostream>
18
19using std::cout;
20using std::endl;
21
22
23// ----- Default constructor -------------------------------------------
25 : FairTask("Global Tracker")
26 , fTrackMerger(NULL)
27 , fRichMerger(NULL)
28 , fTofMerger(NULL)
29 , fStsTracks(NULL)
30 , fTrdTracks(NULL)
31 , fRichRings(NULL)
32 , fTofHits(NULL)
33 , fGlobalTracks(NULL)
34 , fVerbose(1)
35 , fNAll(0)
36 , fNStsOnly(0)
37 , fNTrdOnly(0)
38 , fNWithRich(0)
39 , fNWithTof(0)
40{
41}
42// -------------------------------------------------------------------------
43
44
45// ----- Standard constructor ------------------------------------------
47 CbmTofMerger* tofMerger, Int_t iVerbose)
48 : FairTask("Global Tracker")
49 , fTrackMerger(trackMerger)
50 , fRichMerger(richMerger)
51 , fTofMerger(tofMerger)
52 , fStsTracks(NULL)
53 , fTrdTracks(NULL)
54 , fRichRings(NULL)
55 , fTofHits(NULL)
56 , fGlobalTracks(NULL)
57 , fVerbose(iVerbose)
58 , fNAll(0)
59 , fNStsOnly(0)
60 , fNTrdOnly(0)
61 , fNWithRich(0)
62 , fNWithTof(0)
63{
64}
65// -------------------------------------------------------------------------
66
67
68// ----- Constructor with name and title -------------------------------
69CbmFindGlobalTracks::CbmFindGlobalTracks(const char* name, const char*, CbmTrackMerger* trackMerger,
70 CbmRichMerger* richMerger, CbmTofMerger* tofMerger, Int_t iVerbose)
71 : FairTask(name)
72 , fTrackMerger(trackMerger)
73 , fRichMerger(richMerger)
74 , fTofMerger(tofMerger)
75 , fStsTracks(NULL)
76 , fTrdTracks(NULL)
77 , fRichRings(NULL)
78 , fTofHits(NULL)
79 , fGlobalTracks(NULL)
80 , fVerbose(iVerbose)
81 , fNAll(0)
82 , fNStsOnly(0)
83 , fNTrdOnly(0)
84 , fNWithRich(0)
85 , fNWithTof(0)
86{
87}
88// -------------------------------------------------------------------------
89
90
91// ----- Destructor ----------------------------------------------------
99// -------------------------------------------------------------------------
100
101
102// ----- Public method Init --------------------------------------------
104{
105
106 // Check for Track merger
107 if (!fTrackMerger) {
108 cout << "-W- CbmFindGlobalTracks::Init: No track merger selected!" << endl;
109 return kERROR;
110 }
111
112 // Check for Rich merger
113 if (!fRichMerger) {
114 cout << "-W- CbmFindGlobalTracks::Init: No RICH merger selected!" << endl;
115 }
116
117 // Check for Tof merger
118 if (!fTofMerger) {
119 cout << "-W- CbmFindGlobalTracks::Init: No TOF merger selected!" << endl;
120 }
121
122 // Get and check FairRootManager
123 FairRootManager* ioman = FairRootManager::Instance();
124 if (!ioman) {
125 cout << "-E- CbmFindGlobalTracks::Init: "
126 << "RootManager not instantised!" << endl;
127 return kFATAL;
128 }
129
130 // Get StsTrack array
131 fStsTracks = (TClonesArray*) ioman->GetObject("StsTrack");
132 if (!fStsTracks) {
133 cout << "-W- CbmStsFindTracks::Init: No StsTrack array!" << endl;
134 }
135
136 // Get TrdTrack array
137 fTrdTracks = (TClonesArray*) ioman->GetObject("TrdTrack");
138 if (!fTrdTracks) {
139 cout << "-W- CbmStsFindTracks::Init: No TrdTrack array!" << endl;
140 }
141
142 // Get RichRing array
143 fRichRings = (TClonesArray*) ioman->GetObject("RICHRing");
144 if (!fRichRings) {
145 cout << "-W- CbmStsFindTracks::Init: No RichRing array!" << endl;
146 }
147
148 // Get TofHit array
149 fTofHits = (TClonesArray*) ioman->GetObject("TofHit");
150 if (!fTofHits) {
151 cout << "-W- CbmFindGlobalTracks::Init: No TofHit array!" << endl;
152 }
153
154 // Create and register GlobalTrack array
155 fGlobalTracks = new TClonesArray("CbmGlobalTrack", 100);
156 ioman->Register("GlobalTrack", "Global", fGlobalTracks, IsOutputBranchPersistent("GlobalTrack"));
157
158
159 // Set verbosities of mergers
163
164
165 // Call Init method of the mergers
168 if (fTofMerger) fTofMerger->Init();
169
170 return kSUCCESS;
171}
172// -------------------------------------------------------------------------
173
174
175// ----- Public method Exec --------------------------------------------
177{
178 fGlobalTracks->Clear();
179 Int_t nSts = 0;
180 Int_t nTrd = 0;
181 Int_t nRich = 0;
182 // Int_t nTof = 0;
183 if (fStsTracks) nSts = fStsTracks->GetEntriesFast();
184 if (fTrdTracks) nTrd = fTrdTracks->GetEntriesFast();
185 if (fRichRings) nRich = fRichRings->GetEntriesFast();
186 // if ( fTofHits ) nTof = fTofHits->GetEntriesFast();
187 Int_t nMergedTracks = 0;
189 Int_t nMergedRings = 0;
191 Int_t nMergedTofHits = 0;
192 if (fTofMerger) nMergedTofHits = fTofMerger->DoMerge(fGlobalTracks, fTofHits);
193 Int_t nAll = fGlobalTracks->GetEntriesFast();
194 if (fVerbose) {
195 cout << endl;
196 cout << "-------------------------------------------------------" << endl;
197 cout << "-I- Global Track Finding -I-" << endl;
198 cout << "Reconstructed STSTracks : " << nSts << endl;
199 cout << "Reconstructed TrdTracks : " << nTrd << endl;
200 cout << "STS and TRD merged : " << nMergedTracks << endl;
201 cout << "Reconstructed RICHrings : " << nRich << endl;
202 cout << "RICH rings attached : " << nMergedRings << endl
203 << "TOF hits attached : " << nMergedTofHits << endl;
204 cout << "--------------------------------------------------------" << endl;
205 }
206 else
207 cout << "-I- CbmFindGlobalTracks: " << nAll << " global tracks, " << nMergedTracks << " merged, " << nMergedRings
208 << " with RICH ring, " << nMergedTofHits << " with TOF hit" << endl;
209}
210// -------------------------------------------------------------------------
211
212
ClassImp(CbmConverterManager)
TClonesArray * fGlobalTracks
virtual InitStatus Init()
virtual void Exec(Option_t *opt)
CbmRichMerger * fRichMerger
CbmTrackMerger * fTrackMerger
void SetVerbose(Int_t verbose)
virtual Int_t DoMerge(TClonesArray *glbTracks, TClonesArray *richRings)=0
virtual void Init()
virtual void Init()
void SetVerbose(Int_t verbose)
virtual Int_t DoMerge(TClonesArray *glbTracks, TClonesArray *tofHits)=0
virtual Int_t DoMerge(TClonesArray *stsTracks, TClonesArray *trdTracks, TClonesArray *glbTracks)=0
virtual void Init()
void SetVerbose(Int_t verbose)