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