StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFtpcTrackEvaluator.hh
1 // $Id: StFtpcTrackEvaluator.hh,v 1.12 2004/02/12 19:37:11 oldi Exp $
2 // $Log: StFtpcTrackEvaluator.hh,v $
3 // Revision 1.12 2004/02/12 19:37:11 oldi
4 // *** empty log message ***
5 //
6 // Revision 1.11 2003/09/16 15:27:02 jcs
7 // removed inline as it would leave a few undefined reference
8 //
9 // Revision 1.10 2003/01/16 18:04:34 oldi
10 // Bugs eliminated. Now it compiles on Solaris again.
11 // Split residuals for global and primary fit.
12 //
13 // Revision 1.9 2002/11/06 13:46:29 oldi
14 // Code clean ups.
15 //
16 // Revision 1.8 2002/10/11 15:45:26 oldi
17 // Get FTPC geometry and dimensions from database.
18 // No field fit activated: Returns momentum = 0 but fits a helix.
19 // Bug in TrackMaker fixed (events with z_vertex > outer_ftpc_radius were cut).
20 // QA histograms corrected (0 was supressed).
21 // Code cleanup (several lines of code changed due to *params -> Instance()).
22 // cout -> gMessMgr.
23 //
24 // Revision 1.7 2001/07/12 08:34:31 oldi
25 // Many new things were developed eg. histograms for time consumption and
26 // momentum resolution.
27 // File handling was debugged.
28 // New constructor to evaluate tracks of good evaluated clusters of a
29 // previous run.
30 //
31 // Revision 1.6 2001/01/25 15:22:19 oldi
32 // Review of the complete code.
33 // Fix of several bugs which caused memory leaks:
34 // - Tracks were not allocated properly.
35 // - Tracks (especially split tracks) were not deleted properly.
36 // - TClonesArray seems to have a problem (it could be that I used it in a
37 // wrong way). I changed all occurences to TObjArray which makes the
38 // program slightly slower but much more save (in terms of memory usage).
39 // Speed up of HandleSplitTracks() which is now 12.5 times faster than before.
40 // Cleanup.
41 //
42 // Revision 1.5 2000/11/29 08:37:46 jcs
43 // remove obsolete include statement
44 //
45 // Revision 1.4 2000/11/10 18:38:24 oldi
46 // Short tracks are treated now.
47 //
48 // Revision 1.3 2000/07/18 21:22:17 oldi
49 // Changes due to be able to find laser tracks.
50 // Cleanup: - new functions in StFtpcConfMapper, StFtpcTrack, and StFtpcPoint
51 // to bundle often called functions
52 // - short functions inlined
53 // - formulas of StFormulary made static
54 // - avoid streaming of objects of unknown size
55 // (removes the bunch of CINT warnings during compile time)
56 // - two or three minor bugs cured
57 //
58 // Revision 1.2 2000/06/07 11:58:57 oldi
59 // Added new histos and Int_t's to count things. :)
60 // Cleanup.
61 //
62 // Revision 1.1 2000/05/10 13:39:27 oldi
63 // Initial version of StFtpcTrackMaker
64 //
65 
67 // //
68 // StFtpcTrackEvaluator class - evaluates found tracks by comparison to the input //
69 // GEANT clusters and tracks. //
70 // //
72 
73 #ifndef STAR_StFtpcTrackEvaluator
74 #define STAR_StFtpcTrackEvaluator
75 
76 #include "TObject.h"
77 #include "TObjArray.h"
78 #include "TH1.h"
79 #include "TH2.h"
80 #include "TH3.h"
81 #include "TProfile2D.h"
82 #include "MIntArray.h"
83 #include "TFile.h"
84 
85 #include "StFtpcVertex.hh"
86 #include "StFtpcTrack.hh"
87 #include "StFtpcTracker.hh"
88 #include "StFtpcDisplay.hh"
89 
90 #include "tables/St_ffs_gepoint_Table.h"
91 #include "tables/St_g2t_track_Table.h"
92 #include "tables/St_g2t_ftp_hit_Table.h"
93 
94 #include "St_DataSet.h"
95 
96 class StFtpcTrackEvaluator : public TObject {
97 
98 private:
99  Bool_t mObjArraysCreated; // flag to know which destructor to be called
100 
101  TObjArray *mGeantHits; // ObjArray of geant hits
102  TObjArray *mFastSimHits; // ObjArray of fast simulated hits
103  TObjArray *mFoundHits; // ObjArray of found hits
104  TObjArray *mGeantTracks; // ObjArray of geant tracks
105  TObjArray *mFoundTracks; // ObjArray of found tracks
106 
107  MIntArray *mFtpcTrackNum; // array of numbers of found Ftpc tracks, [geant track]
108 
109  Int_t mFoundVertexTracks; // number of found main vertex tracks
110  Int_t mFoundNonVertexTracks; // number of found non main vertex tracks
111 
112  Int_t mGoodGeantPoints; // number of points on good geant tracks
113  Int_t mGoodFoundPoints; // number of points on good found tracks
114 
115  Int_t mLookLikeGoodTracks; // number of tracks which look like good tracks but aren't
116  Int_t mElectronTracks; // number of electrons
117  Int_t mNonVertexTracks; // number of non main vertex tracks
118  Int_t mGoodGTracks; // number of good geant tracks (all tracks - - short tracks - electrons - non vertex tracks)
119  Int_t mGoodFTracks; // number of good found tracks (all tracks - - short tracks - electrons - non vertex tracks)
120  Int_t mSplitTracks; // number of split tracks
121  Int_t mSplitGoodTracks; // number of split good tracks
122  Int_t mSplitLoliGoodTracks; // number of split look-like good tracks
123  Int_t mUncleanTracks; // number of tracks which have picked up wrong clusters
124  Int_t mUncleanGoodTracks; // number of tracks which have picked up wrong clusters and have a good parent track
125  Int_t mLongTracks; // number of tracks with more than 10 points
126  Int_t mLongTrackClusters; // number of clusters on long tracks
127  Int_t mShortTracks; // number of tracks with less than 5 points
128  Int_t mShortTrackClusters; // number of clusters on short tracks
129  Int_t mTooShortTracks; // number of tracks which should be longer
130  Int_t mMaxClusters; // Max. number of clusters on a track
131 
132  StFtpcVertex *mVertex; // pointer ro the main vertex
133 
134  TH1F *mNumGeantHits; // number of geant hits per event
135  TH1F *mNumFoundHits; // number of found hits per event
136  TH1F *mNumGeantTracks; // number of geant tracks per event
137  TH1F *mNumFoundTracks; // number of found tracks per event
138 
139  TH1F *mNumFoundVertexTracks; // number of found main vertex tracks per event
140  TH1F *mNumFoundNonVertexTracks; // number of found non main vertex tracks per event
141 
142  TH1F *mNumElectronTracks; // number of electrons per event
143  TH1F *mNumNonVertexTracks; // number of non main vertex tracks per event
144  TH1F *mNumLookLikeGoodTracks; // number of tracks which look good but aren't
145  TH1F *mNumGoodGTracks; // number of good geant tracks per event
146  TH1F *mNumGoodFTracks; // number of good found tracks per event
147  TH1F *mNumSplitTracks; // number of split tracks per event
148  TH1F *mNumSplitGoodTracks; // number of split good tracks per event
149  TH1F *mNumSplitLoliGoodTracks; // number of split good tracks per event
150 
151  TH1F *mNumUncleanTracks; // number of unclean tracks per event
152  TH1F *mNumUncleanGoodTracks; // number of unclean tracks which have a good parent track per event
153  TH1F *mNumLongTracks; // number of tracks with more than 10 points per event
154  TH1F *mNumLongTrackClusters; // number of hits belonging to long tracks per event
155  TH1F *mNumShortTracks; // number of tracks with less than 5 points per event
156  TH1F *mNumShortTrackClusters; // number of hits belonging to short tracks per event
157  TH1F *mNumTooShortTracks; // number of tracks which should be longer
158 
159  TH1F *mGHitsOnTrack; // number of geant hits per track
160  TH1F *mFHitsOnTrack; // number of found hits per track
161 
162  TH1F *mNumParents; // number of parent tracks per track
163  TH1F *mNumWrongHitsAll; // number of wrong clusters per track
164  TH2F *mNumWrongHits; // number of wrong clusters per track
165 
166  TH1F *mGoodRatio; // number of good found tracks divided by the number of good geant tracks
167  TH1F *mContamination; // number of found tracks looking good divided by the number of found main vertex tracks
168  TH1F *mContaWoSplit; // number of found tracks looking good minus split tracks divided by the number of found main vertex tracks
169 
170  TH1F *mNumGoodGeantPoints; // number of points on good geant tracks
171  TH1F *mNumGoodFoundPoints; // number of points on good found tracks
172  TH1F *mGoodPointRatio; // ration of points on good geant tracks to points on good found tracks
173 
174  TH2F *mPtot; // found total momentum vs. geant total momentum
175  TH2F *mPt; // found transverse momentum vs. geant transverse momentum
176  TH2F *mPx; // found x momentum vs. geant x momentum
177  TH2F *mPy; // found y momentum vs. geant y momentum
178  TH2F *mPz; // found z momentum vs. geant z momentum
179 
180  TH1F *mPtotDiff; // relative difference of total momentum
181  TH1F *mPtDiff; // relative difference of transverse momentum
182  TH1F *mPxDiff; // relative difference of momentum in x direction
183  TH1F *mPyDiff; // relative difference of momentum in y direction
184  TH1F *mPzDiff; // relative difference of momentum in z direction
185 
186  TH1F *mPtotAcc; // relative accuracy of total momentum
187  TH1F *mPtAcc; // relative accuracy of transverse momentum
188  TH1F *mPxAcc; // relative accuracy of momentum in x direction
189  TH1F *mPyAcc; // relative accuracy of momentum in y direction
190  TH1F *mPzAcc; // relative accuracy of momentum in z direction
191 
192  TH3F *mPRelErr; // relative error of momentum in pt/eta bins
193  TH3F *mPRelErrqok; // relative error of momentum in pt/eta bins where the charge sign was measured alright
194  TH3F *mPRelDiff; // relative difference of momentum in pt/eta bins
195 
196  TH2F *mEtaNghits; // pseudorapidity vs. number of geant clusters on track
197  TH2F *mEtaNfhits; // pseudorapidity vs. number of found clusters on track
198 
199  TH2F *mPtEtaF; // transverse momentum vs. pseudorapidity of found tracks
200  TH2F *mPtEtaFMes; // measured transverse momentum vs. pseudorapidity of found tracks
201  TH2F *mPtEtaGood; // transverse momentum vs. pseudorapidity of good found tracks divided by all found tracks
202  TH2F *mPtEtaBad; // transverse momentum vs. pseudorapidity of bad found tracks divided by all found tracks
203  TH2F *mPtEtaUnclean; // transverse momentum vs. pseudorapidity of unclean (found) tracks
204  TH2F *mPtEtaMesUnclean; // measured transverse momentum vs. measured pseudorapidity of unclean (found) tracks
205  TH2F *mPtEtaUncleanGood; // transverse momentum vs. pseudorapidity of unclean good (found) tracks
206  TH2F *mPtEtaMesUncleanGood; // measured transverse momentum vs. measured pseudorapidity of unclean good (found) tracks
207  TH2F *mPtEtaSplit; // ransverse momentum vs. pseudorapidity of split tracks
208  TH2F *mPtEtaSplitGood; // ransverse momentum vs. pseudorapidity of split good tracks
209  TH2F *mPtEtaSplitLoliGood; // ransverse momentum vs. pseudorapidity of split look-like good tracks
210 
211  TH2F *mPtEtaGoodG; // transverse momentum vs. pseudorapidity of good geant tracks
212  TH2F *mPtEtaGoodF; // transverse momentum vs. pseudorapidity of good found tracks
213  TH2F *mPtEtaGoodRatio; // transverse momentum vs. pseudorapidity of good found tracks divided by good geant tracks
214  TH2F *mPtEtaBadG; // transverse momentum vs. pseudorapidity of bad geant tracks
215  TH2F *mPtEtaBadF; // transverse momentum vs. pseudorapidity of bad found tracks
216  TH2F *mPtEtaBadRatio; // transverse momentum vs. pseudorapidity of bad found tracks divided by bad geant tracks
217 
218  TH2F *mPtEtaFVtx; // transverse momentum vs. pseudorapidity of found tracks with main vertex tag
219  TH2F *mPtEtaLookLikeGood; // transverse momentum vs. pseudorapidity of found tracks which look like good tracks but aren't
220  TH2F *mPtEtaContamination; // transverse momentum vs. pseudorapidity of found tracks which look like good tracks but aren't divided by found tracks with main vertex tag
221  TH2F *mPtEtaContaWoSplits; // transverse momentum vs. pseudorapidity of found tracks which look like good tracks but aren't minus double counted splits divided by found tracks with main vertex tag
222 
223  TH2F *mPtEta10PointTracks; // transverse momentum vs. pseudorapidity of 10 point Geant tracks
224  TH2F *mPtEtaWrongCharge; // transverse momentum vs. pseudorapidity of tracks with wrong charge assigned
225  TH2F *mPtEtaWrongPosCharge; // transverse momentum vs. pseudorapidity of tracks with wrong positive charge assigned
226 
227  TH2F *mGLengthDistTrackAng; // length distance vs. track angle of geant tracks
228  TH2F *mGCircleDistTrackAng; // circle distance vs. track angle of geant tracks
229  TH2F *mFLengthDistTrackAng; // length distance vs. track angle of found tracks
230  TH2F *mFCircleDistTrackAng; // circle distance vs. track angle of found tracks
231 
232  TH1F *mGTracklAngAll; // tracklet angle of geant tracks
233  TH1F *mGTrackAngAll; // track angle of geant tracks
234  TH1F *mGCircleDistAll; // circle distance of geant tracks
235  TH1F *mGLengthDistAll; // length distance of geant tracks
236 
237  TH2F *mGTrackAng; // track angle of geant tracks
238  TH2F *mGCircleDist; // circle distance of geant tracks
239  TH2F *mGLengthDist; // length distance of geant tracks
240 
241  TH2F *mGCircleLength; // circle distance vs. length distance of geant tracks
242 
243  TH1F *mFTracklAngAll; // tracklet angle of found tracks
244  TH1F *mFTrackAngAll; // track angle of found tracks
245  TH1F *mFCircleDistAll; // circle distance of found tracks
246  TH1F *mFLengthDistAll; // length distance of found tracks
247 
248  TH1F *mDcaFMainVertex; // distance of closest approach for found main vertex tracks
249  TH1F *mDcaFNonVertex; // distance of closest approach for found non vertex tracks
250  TH1F *mDcaGMainVertex; // distance of closest approach for geant main vertex tracks
251  TH1F *mDcaGNonVertex; // distance of closest approach for geant non vertex tracks
252 
253  TH2F *mFTrackAng; // track angle of found tracks
254  TH2F *mFCircleDist; // circle distance of found tracks
255  TH2F *mFLengthDist; // length distance of found tracks
256 
257  TH2F *mFCircleLength; // circle distance vs. length distance of found tracks
258 
259  TH2F *mPRatioDist; // point ratio vs. distance of track pairs
260  TH2F *mPRatioDistSplit; // point ratio vs. distance of split track pairs
261 
262  TH1F *mSetupTime; // time consumption for initialisation and setup
263  TH1F *mTrackingTime; // time consumption for main vertex tracking
264  TH1F *mExtensionTime; // time consumption for track extension
265  TH1F *mSplitTime; // time consumption for handling split tracks
266  TH1F *mFitTime; // time consumption for fitting, dE/dx, and writing
267  TH1F *mTotalTime; // total time consumption
268 
269  MIntArray *mParentTrack; // array of numbers of parent tracks for each cluster, [found track # * 10 + # of cluster on track]
270  MIntArray *mParentTracks; // array of numbers of different parent tracks, [found track # * 10 + # of cluster on track]
271  MIntArray *mNumParentTracks; // array of number of different parent tracks, [found track # * 10 + # of cluster on track]
272  MIntArray *mParent; // array of number of the actual parent track for each found track
273 
274  MIntArray *mClusterArr; // array to specify the quality of the found clusters (0 = unused, 1 = used, -1 = used wrong)
275  MIntArray *mUncleanTracksArr; // array of numbers of unclean tracks
276  MIntArray *mSplitTracksArr; // array of numbers of split tracks
277  MIntArray *mSplitGoodTracksArr; // array of numbers of split good tracks
278  MIntArray *mGoodFastSimHitsArr; // array of goodness of ffs hits (1 = good, 0 = bad)
279 
280  Bool_t *mUnclean;
281 
282  void Setup(St_DataSet *geant, St_DataSet *ftpc_data); // Does the setup.
283  void SetupFile(Char_t *filename, Char_t *write_permission); // Opens the data file.
284  void SetupHistos(); // Does the setup of the histograms.
285  void CreateHistos(); // Creates the histograms.
286  void DeleteHistos(); // Deletes the histograms.
287  void GeantHitInit(St_g2t_ftp_hit *g2t_ftp_hit); // Initializes Geant hits
288  void GeantTrackInit(St_g2t_track *g2t_track, St_g2t_ftp_hit *g2t_ftp_hit); // Initializes Geant tracks
289  void FastSimHitInit(St_ffs_gepoint *ffs_hit); // Initializes fast simulated hits
290  void ParentTrackInit(); // Initializes parent tracks
291  void CalcSplitTracks(); // Calculates the number of split tracks
292  void EvaluateGoodness(Int_t t_Counter); // Evaluates if track "t_counter" origins from a good parent
293 
294 public:
295 
296  Char_t *mFilename;
298  TFile *mFile; // Pointer to the data file.
299 
300  StFtpcTrackEvaluator(); // default constructor
301  StFtpcTrackEvaluator(St_DataSet *geant, St_DataSet *ftpc_data, StFtpcTracker *tracker,
302  Char_t *filename = 0, Char_t *write_permission = 0); // real constructor
303  virtual ~StFtpcTrackEvaluator(); // destructor
304 
305  TObjArray *GetGeantHits() { return mGeantHits; }
306  TObjArray *GetGeantTracks() { return mGeantTracks; }
307  TObjArray *GetFastSimHits() { return mFastSimHits; }
308  TObjArray *GetFoundHits() { return mFoundHits; }
309  TObjArray *GetFoundTracks() { return mFoundTracks; }
310 
311  MIntArray *GetClusterArr() { return mClusterArr; }
312  MIntArray *GetSplitTracksArr() { return mSplitTracksArr; }
313  MIntArray *GetSplitGoodTracksArr() { return mSplitGoodTracksArr; }
314  MIntArray *GetUncleanTracksArr() { return mUncleanTracksArr; }
315  MIntArray *GetGoodFastSimHitsArr() { return mGoodFastSimHitsArr; }
316 
317  Int_t GetNumFoundVertexTracks() { return mFoundVertexTracks; } // returns the number of found main vertex tracks
318  Int_t GetNumFoundNonVertexTracks(){ return mFoundNonVertexTracks; } // returns the number of found non main vertex tracks
319  Int_t GetNumLookLikeGoodTracks() { return mLookLikeGoodTracks; } // returns the number of tracks which look good but aren't
320  Int_t GetNumElectronTracks() { return mElectronTracks; } // returns the number of electron tracks
321  Int_t GetNumNonVertexTracks() { return mNonVertexTracks; } // returns the number of non vertex tracks
322  Int_t GetNumGoodGeantTracks() { return mGoodGTracks; } // returns the number of good geant tracks
323  Int_t GetNumGoodFoundTracks() { return mGoodFTracks; } // returns the number of good found tracks
324  Int_t GetNumSplitTracks() { return mSplitTracks; } // returns the number of split tracks
325  Int_t GetNumSplitGoodTracks() { return mSplitGoodTracks; } // returns the number of split good tracks
326  Int_t GetNumSplitLookLikeGoodTracks() { return mSplitLoliGoodTracks; } // returns the number of split good tracks
327  Int_t GetNumUncleanTracks() { return mUncleanTracks; } // returns the number of tracks which have picked up wrong clusters
328  Int_t GetNumUncleanGoodTracks() { return mUncleanGoodTracks; } // returns the number of tracks which have picked up wrong clusters and have a good parent track
329  Int_t GetNumLongTracks() { return mLongTracks; } // returns number of tracks with more than 10 points in the Ftpc
330  Int_t GetNumLongTrackClusters() { return mLongTrackClusters; } // returns number of clusters on long tracks
331  Int_t GetNumShortTracks() { return mShortTracks; } // returns number of tracks with less than 5 points in the Ftpc
332  Int_t GetNumShortTrackClusters() { return mShortTrackClusters; } // returns number of clusters on short tracks
333  Int_t GetNumTooShortTracks() { return mTooShortTracks; } // returns number of tracks which should be longer
334  Int_t GetMaxClusters() { return mMaxClusters; } // returns max. number of clusters on a track
335 
336  Int_t GetNumGoodGeantPoints() { return mGoodGeantPoints; }
337  Int_t GetNumGoodFoundPoints() { return mGoodFoundPoints; }
338 
339  Int_t GetNumFoundTracks() { return mFoundTracks->GetEntriesFast(); } // returns number of found tracks in the Ftpc
340  Int_t GetNumGeantTracks() { return mGeantTracks->GetEntriesFast(); } // returns number of geant tracks in the Ftpc
341  Int_t GetNumFoundHits() { return mFoundHits->GetEntriesFast(); } // returns number of found hits in the Ftpc
342  Int_t GetNumFastSimHits() { return mFastSimHits->GetEntriesFast(); } // returns number of fast simulated hits in the Ftpc
343  Int_t GetNumGeantHits() { return mGeantHits->GetEntriesFast(); } // returns number of geant hits in the Ftpc
344 
345 
346  Bool_t IsGoodTrack(StFtpcTrack* track); // Evaluates if track is a good track.
347  Bool_t IsGoodMainVertexTrack(StFtpcTrack* track); // Evaluates if track is a good main vertex track.
348  Bool_t IsGoodNonVertexTrack(StFtpcTrack* track); // Evaluates if track is a good non vertex track.
349  Bool_t IsUncleanTrack(Int_t track_num) { return mUnclean[track_num]; } // returns true if track is unclean
350  Bool_t IsCleanTrack(Int_t track_num) { return !mUnclean[track_num]; } // returns true if track is clean
351 
352  void Loop();
353  void FillEventHistos(); // Fills histograms which are filled only once per event.
354  void FillTimeHistos(StFtpcTracker* tracker); // Fills histogramms of time consumption
355  void FillParentHistos(); // Fills histogram of number of parents
356  void FillParentHistos(Int_t t_counter); // Fills histogram of number of parents
357  void FillMomentumHistos(); // Fills histograms of rel. momentum difference
358  void FillMomentumHistos(Int_t t_counter); // Fills histograms of rel. momentum difference
359  void FillHitsOnTrack(TObjArray *trackarray, Char_t c); // Fills histogram of hits on tracks
360  void FillHitsOnTrack(); // Fills all hits on all tracks
361  void FillFoundHitsOnTrack(); // Fills found hits on tracks
362  void FillCutHistos(); // Fills cut histograms (geant and found tracks)
363  void FillGCutHistos(); // Fills cut histograms (geant tracks)
364  void FillFCutHistos(); // Fills cut histograms (found tracks)
365  void DivideHistos(); // Divides histograms
366  void WriteHistos(); // Writes histograms to file
367 
368  void GetGoodHits(TObjArray *good_clusters); // Fills all good hits in given array
369 
370  void ShowTracks(); // Displays geant and/or found tracks
371  void GeantInfo(); // Shows information about GEANT output.
372  void ClusterInfo(); // Shows information about geant clusters.
373  void TrackerInfo(); // Shows information about tracker output.
374  void ProblemsInfo(); // Shows information about problems.
375  void InfoAll(); // Shows all information.
376 
377  ClassDef(StFtpcTrackEvaluator, 1) //Ftpc track evaluation class
378 };
379 
380 
381 
382 
383 
384 #endif
Char_t * mWritePermission
Name of the data file.
TFile * mFile
Write permission of the data file.