FairRoot/PandaRoot
PndSttFindTracks.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndSttFindTracks source file -----
3 // -------------------------------------------------------------------------
4 
5 #include "PndSttFindTracks.h"
6 
7 #include "PndSttTrackFinder.h"
8 #include "PndTrackCand.h"
9 #include "PndTrack.h"
10 #include "PndSttHelixHit.h"
11 #include "PndSttTube.h"
12 #include "PndSttMapCreator.h"
13 
14 #include "FairHit.h"
15 #include "FairRootManager.h"
16 #include "FairRunAna.h"
17 #include "FairRuntimeDb.h"
18 
19 #include "TClonesArray.h"
20 
21 #include <iostream>
22 
23 using std::cout;
24 using std::endl;
25 using std::string;
26 
27 // ----- Default constructor -------------------------------------------
29  : PndPersistencyTask("STT Find Tracks")
30 {
31  fFinder = NULL;
32  fTrackCandArray = NULL;
33  fHelixHitArray = NULL;
34  fNofTracks = 0;
35  fVerbose = 1;
36  fCollectionsComplete = kFALSE;
37  SetPersistency(kTRUE);
38 }
39 // -------------------------------------------------------------------------
40 
41 
42 
43 // ----- Standard constructor ------------------------------------------
45  Int_t verbose)
46  : PndPersistencyTask("STT Find Tracks")
47 {
48  fFinder = finder;
49  fTrackCandArray = NULL;
50  fHelixHitArray = NULL;
51  fNofTracks = 0;
52  fVerbose = verbose;
53  fCollectionsComplete = kFALSE;
54  SetPersistency(kTRUE);
55  fHelixHitProduction = kFALSE;
56 }
57 // -------------------------------------------------------------------------
58 
59 
60 
61 // ----- Constructor with name and title -------------------------------
62 PndSttFindTracks::PndSttFindTracks(const char* name, const char* title,
64  Int_t verbose)
65  : PndPersistencyTask(name)
66 {
67  fFinder = finder;
68  fTrackCandArray = NULL;
69  fHelixHitArray = NULL;
70  fNofTracks = 0;
71  fVerbose = verbose;
72  fCollectionsComplete = kFALSE;
73  SetPersistency(kTRUE);
74  fHelixHitProduction = kFALSE;
75  SetTitle(title);
76 }
77 // -------------------------------------------------------------------------
78 
79 
80 
81 // ----- Destructor ----------------------------------------------------
83 {
84  fTrackCandArray->Delete();
85  fHelixHitArray ->Delete();
86  fHitCollectionNames.clear();
87  fPointCollectionNames.clear();
88 }
89 // -------------------------------------------------------------------------
90 
91 
92 
93 // ----- Public method Init (abstract in base class) --------------------
95 {
96  fEventCounter = 0;
97 
98  // Check for Track finder
99  if (! fFinder) {
100  cout << "-E- PndSttFindTracks::Init: No track finder selected!" << endl;
101  return kERROR;
102  }
103 
104  FairRootManager
105  *ioman = FairRootManager::Instance();
106 
107  if (!ioman)
108  {
109  cout << "-E- PndSttFindTracks::AddHitCollection: "
110  << "RootManager not instantised!" << endl;
111  return kFATAL;
112  }
113 
114  fTrackCandArray = new TClonesArray("PndTrackCand",100);
115  ioman->Register("STTTrackCand", "STT", fTrackCandArray, GetPersistency());
116 
117  fTrackArray = new TClonesArray("PndTrack",100);
118  ioman->Register("STTFoundTrack", "STT", fTrackArray, GetPersistency());
119 
120  fHelixHitArray = new TClonesArray("PndSttHelixHit",100);
121  ioman->Register("STTPRHelixHit", "STT", fHelixHitArray, fHelixHitProduction);
122 
123 
124  // Set verbosity of track finder
126 
127  // helix hits?
129 
130  // CHECK added
132  fTubeArray = mapper.FillTubeArray();
133 
134  // Call the Init method of the track finder
135  fFinder->Init();
137 
138 
139  return kSUCCESS;
140 }
141 
142 // CHECK added
144  FairRuntimeDb* rtdb = FairRunAna::Instance()->GetRuntimeDb();
145  fSttParameters = (PndGeoSttPar*) rtdb->getContainer("PndGeoSttPar");
146 
147 
148 }
149 
150 // -------------------------------------------------------------------------
151 void PndSttFindTracks::AddHitCollectionName(char *hitCollectionName, char *pointCollectionName)
152 {
153 // string
154 // newPointName(pointCollectionName),
155 // newHitName(hitCollectionName);
156 
157 // fHitCollectionNames.push_back(newHitName);
158 // fPointCollectionNames.push_back(newPointName);
159  fHitCollectionNames.push_back(hitCollectionName);
160  fPointCollectionNames.push_back(pointCollectionName);
161 
162  fFinder->SetInputBranchName(hitCollectionName); // this passes the HitBranch Name to
163  // PndSttTrackFinderReal.
164 
165 }
166 
167 void PndSttFindTracks::AddHitCollection(char const *hitCollectionName, char const *pointCollectionName)
168 {
169  // Get and check FairRootManager
170  FairRootManager
171  *ioman = FairRootManager::Instance();
172 
173  if (!ioman)
174  {
175  cout << "-E- PndSttFindTracks::AddHitCollection: "
176  << "RootManager not instantised!" << endl;
177  }
178 
179  // Get hit Array
180  TClonesArray
181  *fHitArray = (TClonesArray*) ioman->GetObject(hitCollectionName);
182 
183  if (!fHitArray)
184  {
185  cout << "-W- PndSttFindTracks::AddHitCollection: No " << hitCollectionName << " STT hit array!"
186  << endl;
187  }
188 
189  // Get point Array
190  TClonesArray
191  *fPointArray = (TClonesArray*) ioman->GetObject(pointCollectionName);
192 
193  if (!fPointArray)
194  {
195  cout << "-W- PndSttFindTracks::AddHitCollection: No " << pointCollectionName << " STT hit array!"
196  << endl;
197  }
198 
199  fFinder->AddHitCollection(fHitArray, fPointArray);
200 }
201 
203 {
205  {
206  for (size_t counter = 0; counter < fHitCollectionNames.size(); counter++)
207  {
209  }
210  fCollectionsComplete = kTRUE;
211  }
212 }
213 
214 // ----- Public method Exec --------------------------------------------
215 void PndSttFindTracks::Exec(Option_t*)
216 {
217  // CHECK !!! IMPORTANT: event 0 (the first)
218 
219  if(fVerbose) cout << "******* event # " << fEventCounter << "*******" << endl;
220  fEventCounter++;
221 
223 
224  fTrackCandArray->Delete();
225  fTrackArray->Delete();
226  fHelixHitArray->Delete();
227 
229 
230 
231  for (Int_t iTrack=0; iTrack < fTrackCandArray->GetEntriesFast(); iTrack++)
232  {
233  PndTrackCand* trackCand = (PndTrackCand*) fTrackCandArray->At(iTrack);
234  trackCand->Sort();
235  }
236 }
237 // -------------------------------------------------------------------------
238 
239 
240 
241 // ----- Public method Finish ------------------------------------------
243 {
244  fFinder->Finish();
245 }
246 // -------------------------------------------------------------------------
247 
248 
249 
250 
virtual Int_t DoFind(TClonesArray *trackArray, TClonesArray *helixHitArray)=0
void AddHitCollection(char const *collectionName, char const *pointCollectionName)
TClonesArray * fHelixHitArray
virtual void Exec(Option_t *opt)
std::vector< std::string > fPointCollectionNames
#define verbose
void SetPersistency(Bool_t val=kTRUE)
virtual void SetTubeArray(TClonesArray *tubeArray)=0
virtual void Finish()
PndStraightLineTrackFinderTask * finder
h_MC_angle SetTitle("MC truth: opening angle of #pi^{0}")
virtual void SetInputBranchName(char *string1)=0
void SetVerbose(Int_t verbose)
virtual void AddHitCollection(TClonesArray *mHitArray, TClonesArray *mPointArray)=0
int counter
Definition: ZeeAnalysis.C:59
TClonesArray * fTubeArray
virtual ~PndSttFindTracks()
PndSttTrackFinder * fFinder
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
TClonesArray * FillTubeArray()
virtual InitStatus Init()
TClonesArray * fTrackCandArray
TString name
virtual void Init()
virtual void Finish()=0
TClonesArray * fTrackArray
ClassImp(PndAnaContFact)
PndGeoSttPar * fSttParameters
void AddHitCollectionName(char *hitCollectionName, char *pointCollectionName)
std::vector< std::string > fHitCollectionNames
void SetHelixHitProduction(Bool_t hhprod)