]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCAPerformance.cxx
Fix coding convention violations.
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCAPerformance.cxx
CommitLineData
d54804bf 1// $Id$
ce565086 2// **************************************************************************
fbb9b71b 3// This file is property of and copyright by the ALICE HLT Project *
d54804bf 4// ALICE Experiment at CERN, All rights reserved. *
5// *
6// Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
7// Ivan Kisel <kisel@kip.uni-heidelberg.de> *
8// for The ALICE HLT Project. *
9// *
10// Permission to use, copy, modify and distribute this software and its *
11// documentation strictly for non-commercial purposes is hereby granted *
12// without fee, provided that the above copyright notice appears in all *
13// copies and that both the copyright notice and this permission notice *
14// appear in the supporting documentation. The authors make no claims *
15// about the suitability of this software for any purpose. It is *
16// provided "as is" without express or implied warranty. *
ce565086 17// *
d54804bf 18//***************************************************************************
19
ce565086 20
d54804bf 21#include "AliHLTTPCCAPerformance.h"
22#include "AliHLTTPCCAGBHit.h"
23#include "AliHLTTPCCAMCTrack.h"
eb30eb49 24#include "AliHLTTPCCAMCPoint.h"
d54804bf 25#include "AliHLTTPCCAOutTrack.h"
eb30eb49 26#include "AliHLTTPCCAGBTrack.h"
d54804bf 27#include "AliHLTTPCCAGBTracker.h"
28#include "AliHLTTPCCATracker.h"
ce565086 29#include "AliHLTTPCCATracklet.h"
d54804bf 30
eb30eb49 31
d54804bf 32#include "TMath.h"
33#include "TROOT.h"
4687b8fc 34#include "Riostream.h"
d54804bf 35#include "TFile.h"
36#include "TH1.h"
eb30eb49 37#include "TH2.h"
d54804bf 38#include "TProfile.h"
39
693d2443 40AliHLTTPCCAPerformance &AliHLTTPCCAPerformance::Instance()
41{
42 // reference to static object
43 static AliHLTTPCCAPerformance gAliHLTTPCCAPerformance;
44 return gAliHLTTPCCAPerformance;
45}
d54804bf 46
d54804bf 47AliHLTTPCCAPerformance::AliHLTTPCCAPerformance()
fbb9b71b 48 :
49 fTracker( 0 ),
50 fHitLabels( 0 ),
51 fNHits( 0 ),
52 fMCTracks( 0 ),
53 fNMCTracks( 0 ),
54 fMCPoints( 0 ),
55 fNMCPoints( 0 ),
56 fDoClusterPulls( 0 ),
57 fStatNEvents( 0 ),
58 fStatTime( 0 ),
59 fStatSeedNRecTot( 0 ),
60 fStatSeedNRecOut( 0 ),
61 fStatSeedNGhost( 0 ),
62 fStatSeedNMCAll( 0 ),
63 fStatSeedNRecAll( 0 ),
64 fStatSeedNClonesAll( 0 ),
65 fStatSeedNMCRef( 0 ),
66 fStatSeedNRecRef( 0 ),
67 fStatSeedNClonesRef( 0 ),
68 fStatCandNRecTot( 0 ),
69 fStatCandNRecOut( 0 ),
70 fStatCandNGhost( 0 ),
71 fStatCandNMCAll( 0 ),
72 fStatCandNRecAll( 0 ),
73 fStatCandNClonesAll( 0 ),
74 fStatCandNMCRef( 0 ),
75 fStatCandNRecRef( 0 ),
76 fStatCandNClonesRef( 0 ),
77 fStatNRecTot( 0 ),
78 fStatNRecOut( 0 ),
79 fStatNGhost( 0 ),
80 fStatNMCAll( 0 ),
81 fStatNRecAll( 0 ),
82 fStatNClonesAll( 0 ),
83 fStatNMCRef( 0 ),
84 fStatNRecRef( 0 ),
85 fStatNClonesRef( 0 ),
86 fStatGBNRecTot( 0 ),
87 fStatGBNRecOut( 0 ),
88 fStatGBNGhost( 0 ),
89 fStatGBNMCAll( 0 ),
90 fStatGBNRecAll( 0 ),
91 fStatGBNClonesAll( 0 ),
92 fStatGBNMCRef( 0 ),
93 fStatGBNRecRef( 0 ),
94 fStatGBNClonesRef( 0 ),
95 fHistoDir( 0 ),
96 fhResY( 0 ),
97 fhResZ( 0 ),
98 fhResSinPhi( 0 ),
99 fhResDzDs( 0 ),
100 fhResPt( 0 ),
101 fhPullY( 0 ),
102 fhPullZ( 0 ),
103 fhPullSinPhi( 0 ),
104 fhPullDzDs( 0 ),
105 fhPullQPt( 0 ),
106 fhPullYS( 0 ),
107 fhPullZT( 0 ),
4acc2401 108 fhHitErrY( 0 ),
109 fhHitErrZ( 0 ),
110 fhHitResY( 0 ),
111 fhHitResZ( 0 ),
112 fhHitPullY( 0 ),
113 fhHitPullZ( 0 ),
114 fhHitShared( 0 ),
115 fhHitResY1( 0 ),
116 fhHitResZ1( 0 ),
117 fhHitPullY1( 0 ),
118 fhHitPullZ1( 0 ),
fbb9b71b 119 fhCellPurity( 0 ),
120 fhCellNHits( 0 ),
121 fhCellPurityVsN( 0 ),
122 fhCellPurityVsPt( 0 ),
123 fhEffVsP( 0 ),
124 fhSeedEffVsP( 0 ),
125 fhCandEffVsP( 0 ),
126 fhGBEffVsP( 0 ),
127 fhGBEffVsPt( 0 ),
128 fhNeighQuality( 0 ),
129 fhNeighEff( 0 ),
130 fhNeighQualityVsPt( 0 ),
131 fhNeighEffVsPt( 0 ),
132 fhNeighDy( 0 ),
133 fhNeighDz( 0 ),
134 fhNeighChi( 0 ),
135 fhNeighDyVsPt( 0 ),
136 fhNeighDzVsPt( 0 ),
137 fhNeighChiVsPt( 0 ),
138 fhNeighNCombVsArea( 0 ),
139 fhNHitsPerSeed ( 0 ),
140 fhNHitsPerTrackCand( 0 ),
141 fhTrackLengthRef( 0 ),
142 fhRefRecoX( 0 ),
143 fhRefRecoY( 0 ),
144 fhRefRecoZ( 0 ),
145 fhRefRecoP( 0 ),
146 fhRefRecoPt( 0 ),
147 fhRefRecoAngleY( 0 ),
148 fhRefRecoAngleZ( 0 ),
149 fhRefRecoNHits( 0 ),
150 fhRefNotRecoX( 0 ),
151 fhRefNotRecoY( 0 ),
152 fhRefNotRecoZ( 0 ),
153 fhRefNotRecoP( 0 ),
154 fhRefNotRecoPt( 0 ),
155 fhRefNotRecoAngleY( 0 ),
156 fhRefNotRecoAngleZ( 0 ),
157 fhRefNotRecoNHits( 0 )
d54804bf 158{
159 //* constructor
160}
161
162
fbb9b71b 163AliHLTTPCCAPerformance::AliHLTTPCCAPerformance( const AliHLTTPCCAPerformance& )
164 :
165 fTracker( 0 ),
166 fHitLabels( 0 ),
167 fNHits( 0 ),
168 fMCTracks( 0 ),
169 fNMCTracks( 0 ),
170 fMCPoints( 0 ),
171 fNMCPoints( 0 ),
172 fDoClusterPulls( 0 ),
173 fStatNEvents( 0 ),
174 fStatTime( 0 ),
175 fStatSeedNRecTot( 0 ),
176 fStatSeedNRecOut( 0 ),
177 fStatSeedNGhost( 0 ),
178 fStatSeedNMCAll( 0 ),
179 fStatSeedNRecAll( 0 ),
180 fStatSeedNClonesAll( 0 ),
181 fStatSeedNMCRef( 0 ),
182 fStatSeedNRecRef( 0 ),
183 fStatSeedNClonesRef( 0 ),
184 fStatCandNRecTot( 0 ),
185 fStatCandNRecOut( 0 ),
186 fStatCandNGhost( 0 ),
187 fStatCandNMCAll( 0 ),
188 fStatCandNRecAll( 0 ),
189 fStatCandNClonesAll( 0 ),
190 fStatCandNMCRef( 0 ),
191 fStatCandNRecRef( 0 ),
192 fStatCandNClonesRef( 0 ),
193 fStatNRecTot( 0 ),
194 fStatNRecOut( 0 ),
195 fStatNGhost( 0 ),
196 fStatNMCAll( 0 ),
197 fStatNRecAll( 0 ),
198 fStatNClonesAll( 0 ),
199 fStatNMCRef( 0 ),
200 fStatNRecRef( 0 ),
201 fStatNClonesRef( 0 ),
202 fStatGBNRecTot( 0 ),
203 fStatGBNRecOut( 0 ),
204 fStatGBNGhost( 0 ),
205 fStatGBNMCAll( 0 ),
206 fStatGBNRecAll( 0 ),
207 fStatGBNClonesAll( 0 ),
208 fStatGBNMCRef( 0 ),
209 fStatGBNRecRef( 0 ),
210 fStatGBNClonesRef( 0 ),
211 fHistoDir( 0 ),
212 fhResY( 0 ),
213 fhResZ( 0 ),
214 fhResSinPhi( 0 ),
215 fhResDzDs( 0 ),
216 fhResPt( 0 ),
217 fhPullY( 0 ),
218 fhPullZ( 0 ),
219 fhPullSinPhi( 0 ),
220 fhPullDzDs( 0 ),
221 fhPullQPt( 0 ),
222 fhPullYS( 0 ),
223 fhPullZT( 0 ),
4acc2401 224 fhHitErrY( 0 ),
225 fhHitErrZ( 0 ),
226 fhHitResY( 0 ),
227 fhHitResZ( 0 ),
228 fhHitPullY( 0 ),
229 fhHitPullZ( 0 ),
230 fhHitShared( 0 ),
231 fhHitResY1( 0 ),
232 fhHitResZ1( 0 ),
233 fhHitPullY1( 0 ),
234 fhHitPullZ1( 0 ),
fbb9b71b 235 fhCellPurity( 0 ),
236 fhCellNHits( 0 ),
237 fhCellPurityVsN( 0 ),
238 fhCellPurityVsPt( 0 ),
239 fhEffVsP( 0 ),
240 fhSeedEffVsP( 0 ),
241 fhCandEffVsP( 0 ),
242 fhGBEffVsP( 0 ),
243 fhGBEffVsPt( 0 ),
244 fhNeighQuality( 0 ),
245 fhNeighEff( 0 ),
246 fhNeighQualityVsPt( 0 ),
247 fhNeighEffVsPt( 0 ),
248 fhNeighDy( 0 ),
249 fhNeighDz( 0 ),
250 fhNeighChi( 0 ),
251 fhNeighDyVsPt( 0 ),
252 fhNeighDzVsPt( 0 ),
253 fhNeighChiVsPt( 0 ),
254 fhNeighNCombVsArea( 0 ),
255 fhNHitsPerSeed ( 0 ),
256 fhNHitsPerTrackCand( 0 ),
257 fhTrackLengthRef( 0 ),
258 fhRefRecoX( 0 ),
259 fhRefRecoY( 0 ),
260 fhRefRecoZ( 0 ),
261 fhRefRecoP( 0 ),
262 fhRefRecoPt( 0 ),
263 fhRefRecoAngleY( 0 ),
264 fhRefRecoAngleZ( 0 ),
265 fhRefRecoNHits( 0 ),
266 fhRefNotRecoX( 0 ),
267 fhRefNotRecoY( 0 ),
268 fhRefNotRecoZ( 0 ),
269 fhRefNotRecoP( 0 ),
270 fhRefNotRecoPt( 0 ),
271 fhRefNotRecoAngleY( 0 ),
272 fhRefNotRecoAngleZ( 0 ),
273 fhRefNotRecoNHits( 0 )
d54804bf 274{
275 //* dummy
276}
277
fbb9b71b 278const AliHLTTPCCAPerformance &AliHLTTPCCAPerformance::operator=( const AliHLTTPCCAPerformance& ) const
d54804bf 279{
280 //* dummy
281 return *this;
282}
283
284AliHLTTPCCAPerformance::~AliHLTTPCCAPerformance()
285{
286 //* destructor
287 StartEvent();
288}
289
ce565086 290void AliHLTTPCCAPerformance::SetTracker( AliHLTTPCCAGBTracker * const Tracker )
d54804bf 291{
292 //* set pointer to HLT CA Global tracker
293 fTracker = Tracker;
294}
295
296void AliHLTTPCCAPerformance::StartEvent()
297{
298 //* clean up arrays
fbb9b71b 299 if ( !fHistoDir ) CreateHistos();
300 if ( fHitLabels ) delete[] fHitLabels;
d54804bf 301 fHitLabels = 0;
302 fNHits = 0;
fbb9b71b 303 if ( fMCTracks ) delete[] fMCTracks;
d54804bf 304 fMCTracks = 0;
305 fNMCTracks = 0;
fbb9b71b 306 if ( fMCPoints ) delete[] fMCPoints;
eb30eb49 307 fMCPoints = 0;
308 fNMCPoints = 0;
d54804bf 309}
310
fbb9b71b 311void AliHLTTPCCAPerformance::SetNHits( int NHits )
d54804bf 312{
313 //* set number of hits
fbb9b71b 314 if ( fHitLabels ) delete[] fHitLabels;
d54804bf 315 fHitLabels = 0;
316 fHitLabels = new AliHLTTPCCAHitLabel[ NHits ];
317 fNHits = NHits;
fbb9b71b 318}
d54804bf 319
fbb9b71b 320void AliHLTTPCCAPerformance::SetNMCTracks( int NumberOfMCTracks )
d54804bf 321{
322 //* set number of MC tracks
fbb9b71b 323 if ( fMCTracks ) delete[] fMCTracks;
d54804bf 324 fMCTracks = 0;
693d2443 325 fMCTracks = new AliHLTTPCCAMCTrack[ NumberOfMCTracks ];
326 fNMCTracks = NumberOfMCTracks;
fbb9b71b 327}
d54804bf 328
fbb9b71b 329void AliHLTTPCCAPerformance::SetNMCPoints( int NMCPoints )
eb30eb49 330{
331 //* set number of MC points
fbb9b71b 332 if ( fMCPoints ) delete[] fMCPoints;
eb30eb49 333 fMCPoints = 0;
334 fMCPoints = new AliHLTTPCCAMCPoint[ NMCPoints ];
335 fNMCPoints = 0;
fbb9b71b 336}
eb30eb49 337
fbb9b71b 338void AliHLTTPCCAPerformance::ReadHitLabel( int HitID,
339 int lab0, int lab1, int lab2 )
d54804bf 340{
341 //* read the hit labels
342 AliHLTTPCCAHitLabel hit;
343 hit.fLab[0] = lab0;
344 hit.fLab[1] = lab1;
345 hit.fLab[2] = lab2;
346 fHitLabels[HitID] = hit;
347}
348
fbb9b71b 349void AliHLTTPCCAPerformance::ReadMCTrack( int index, const TParticle *part )
d54804bf 350{
eb30eb49 351 //* read mc track to the local array
fbb9b71b 352 fMCTracks[index] = AliHLTTPCCAMCTrack( part );
d54804bf 353}
354
fbb9b71b 355void AliHLTTPCCAPerformance::ReadMCTPCTrack( int index, float X, float Y, float Z,
356 float Px, float Py, float Pz )
eb30eb49 357{
358 //* read mc track parameters at TPC
fbb9b71b 359 fMCTracks[index].SetTPCPar( X, Y, Z, Px, Py, Pz );
eb30eb49 360}
361
fbb9b71b 362void AliHLTTPCCAPerformance::ReadMCPoint( int TrackID, float X, float Y, float Z, float Time, int iSlice )
eb30eb49 363{
364 //* read mc point to the local array
365 AliHLTTPCCAMCPoint &p = fMCPoints[fNMCPoints];
693d2443 366 p.SetTrackID( TrackID );
367 p.SetX( X );
368 p.SetY( Y );
369 p.SetZ( Z );
370 p.SetTime( Time );
371 p.SetISlice( iSlice );
fbb9b71b 372 float sx, sy, sz;
4acc2401 373 fTracker->Slice( iSlice ).Param().Global2Slice( X, Y, Z, &sx, &sy, &sz );
fbb9b71b 374 p.SetSx( sx );
375 p.SetSy( sy );
376 p.SetSz( sz );
377 if ( X*X + Y*Y > 10. ) fNMCPoints++;
eb30eb49 378}
379
d54804bf 380void AliHLTTPCCAPerformance::CreateHistos()
381{
382 //* create performance histogramms
383 TDirectory *curdir = gDirectory;
fbb9b71b 384 fHistoDir = gROOT->mkdir( "HLTTPCCATrackerPerformance" );
d54804bf 385 fHistoDir->cd();
00d07bcd 386
fbb9b71b 387 gDirectory->mkdir( "Links" );
388 gDirectory->cd( "Links" );
389
390 fhLinkEff[0] = new TProfile( "fhLinkEffPrimRef", "fhLinkEffPrimRef vs row", 156, 2., 158. );
391 fhLinkEff[1] = new TProfile( "fhLinkEffPrimExt", "fhLinkEffPrimExt vs row", 156, 2., 158. );
392 fhLinkEff[2] = new TProfile( "fhLinkEffSecRef", "fhLinkEffSecRef vs row", 156, 2., 158. );
393 fhLinkEff[3] = new TProfile( "fhLinkEffSecExt", "fhLinkEffSecExt vs row", 156, 2., 158. );
394 fhLinkAreaY[0] = new TH1D( "fhLinkAreaYPrimRef", "fhLinkAreaYPrimRef", 100, 0, 10 );
395 fhLinkAreaZ[0] = new TH1D( "fhLinkAreaZPrimRef", "fhLinkAreaZPrimRef", 100, 0, 10 );
396 fhLinkAreaY[1] = new TH1D( "fhLinkAreaYPrimExt", "fhLinkAreaYPrimExt", 100, 0, 10 );
397 fhLinkAreaZ[1] = new TH1D( "fhLinkAreaZPrimExt", "fhLinkAreaZPrimExt", 100, 0, 10 );
398 fhLinkAreaY[2] = new TH1D( "fhLinkAreaYSecRef", "fhLinkAreaYSecRef", 100, 0, 10 );
399 fhLinkAreaZ[2] = new TH1D( "fhLinkAreaZSecRef", "fhLinkAreaZSecRef", 100, 0, 10 );
400 fhLinkAreaY[3] = new TH1D( "fhLinkAreaYSecExt", "fhLinkAreaYSecExt", 100, 0, 10 );
401 fhLinkAreaZ[3] = new TH1D( "fhLinkAreaZSecExt", "fhLinkAreaZSecExt", 100, 0, 10 );
402 fhLinkChiRight[0] = new TH1D( "fhLinkChiRightPrimRef", "fhLinkChiRightPrimRef", 100, 0, 10 );
403 fhLinkChiRight[1] = new TH1D( "fhLinkChiRightPrimExt", "fhLinkChiRightPrimExt", 100, 0, 10 );
404 fhLinkChiRight[2] = new TH1D( "fhLinkChiRightSecRef", "fhLinkChiRightSecRef", 100, 0, 10 );
405 fhLinkChiRight[3] = new TH1D( "fhLinkChiRightSecExt", "fhLinkChiRightSecExt", 100, 0, 10 );
406 fhLinkChiWrong[0] = new TH1D( "fhLinkChiWrongPrimRef", "fhLinkChiWrongPrimRef", 100, 0, 10 );
407 fhLinkChiWrong[1] = new TH1D( "fhLinkChiWrongPrimExt", "fhLinkChiWrongPrimExt", 100, 0, 10 );
408 fhLinkChiWrong[2] = new TH1D( "fhLinkChiWrongSecRef", "fhLinkChiWrongSecRef", 100, 0, 10 );
409 fhLinkChiWrong[3] = new TH1D( "fhLinkChiWrongSecExt", "fhLinkChiWrongSecExt", 100, 0, 10 );
410
411 gDirectory->cd( ".." );
412
413 gDirectory->mkdir( "Neighbours" );
414 gDirectory->cd( "Neighbours" );
415
416 fhNeighQuality = new TProfile( "NeighQuality", "Neighbours Quality vs row", 160, 0., 160. );
417 fhNeighEff = new TProfile( "NeighEff", "Neighbours Efficiency vs row", 160, 0., 160. );
418 fhNeighQualityVsPt = new TProfile( "NeighQualityVsPt", "Neighbours Quality vs Pt", 100, 0., 5. );
419 fhNeighEffVsPt = new TProfile( "NeighEffVsPt", "Neighbours Efficiency vs Pt", 100, 0., 5. );
420 fhNeighDy = new TH1D( "NeighDy", "Neighbours dy", 100, -10, 10 );
421 fhNeighDz = new TH1D( "NeighDz", "Neighbours dz", 100, -10, 10 );
422 fhNeighChi = new TH1D( "NeighChi", "Neighbours chi", 100, 0, 20 );
423
424 fhNeighDyVsPt = new TH2D( "NeighDyVsPt", "NeighDyVsPt", 100, 0, 5, 100, -20, 20 );
425 fhNeighDzVsPt = new TH2D( "NeighDzVsPt", "NeighDzVsPt", 100, 0, 5, 100, -20, 20 );
426 fhNeighChiVsPt = new TH2D( "NeighChiVsPt", "NeighChiVsPt", 100, 0, 5, 100, 0, 40 );
427 fhNeighNCombVsArea = new TH2D( "NeighNCombVsArea", "NeighNCombVsArea", 15, 0, 3, 40, 0, 40 );
428
429 gDirectory->cd( ".." );
430
431 gDirectory->mkdir( "Tracklets" );
432 gDirectory->cd( "Tracklets" );
433
434 fhNHitsPerSeed = new TH1D( "NHitsPerSeed", "NHitsPerSeed", 160, 0, 160 );
435 fhSeedEffVsP = new TProfile( "fhSeedEffVsP", "Track Seed Eff vs P", 100, 0., 5. );
436
437 gDirectory->cd( ".." );
438
439 gDirectory->mkdir( "TrackCandidates" );
440 gDirectory->cd( "TrackCandidates" );
441
442 fhNHitsPerTrackCand = new TH1D( "NHitsPerTrackCand", "NHitsPerTrackCand", 160, 0, 160 );
443 fhCandEffVsP = new TProfile( "fhCandEffVsP", "Track Candidate Eff vs P", 100, 0., 5. );
444
445 gDirectory->cd( ".." );
446
447 gDirectory->mkdir( "Tracks" );
448 gDirectory->cd( "Tracks" );
449
450 fhTrackLengthRef = new TH1D( "TrackLengthRef", "TrackLengthRef", 100, 0, 1 );
451
452 fhRefRecoX = new TH1D( "fhRefRecoX", "fhRefRecoX", 100, 0, 200. );
453 fhRefRecoY = new TH1D( "fhRefRecoY", "fhRefRecoY", 100, -200, 200. );
454 fhRefRecoZ = new TH1D( "fhRefRecoZ", "fhRefRecoZ", 100, -250, 250. );
455
456
457 fhRefRecoP = new TH1D( "fhRefRecoP", "fhRefRecoP", 100, 0, 10. );
458 fhRefRecoPt = new TH1D( "fhRefRecoPt", "fhRefRecoPt", 100, 0, 10. );
459 fhRefRecoAngleY = new TH1D( "fhRefRecoAngleY", "fhRefRecoAngleY", 100, -180., 180. );
460 fhRefRecoAngleZ = new TH1D( "fhRefRecoAngleZ", "fhRefRecoAngleZ", 100, -180., 180 );
461 fhRefRecoNHits = new TH1D( "fhRefRecoNHits", "fhRefRecoNHits", 100, 0., 200 );
462
463 fhRefNotRecoX = new TH1D( "fhRefNotRecoX", "fhRefNotRecoX", 100, 0, 200. );
464 fhRefNotRecoY = new TH1D( "fhRefNotRecoY", "fhRefNotRecoY", 100, -200, 200. );
465 fhRefNotRecoZ = new TH1D( "fhRefNotRecoZ", "fhRefNotRecoZ", 100, -250, 250. );
466
467
468 fhRefNotRecoP = new TH1D( "fhRefNotRecoP", "fhRefNotRecoP", 100, 0, 10. );
469 fhRefNotRecoPt = new TH1D( "fhRefNotRecoPt", "fhRefNotRecoPt", 100, 0, 10. );
470 fhRefNotRecoAngleY = new TH1D( "fhRefNotRecoAngleY", "fhRefNotRecoAngleY", 100, -180., 180. );
471 fhRefNotRecoAngleZ = new TH1D( "fhRefNotRecoAngleZ", "fhRefNotRecoAngleZ", 100, -180., 180 );
472 fhRefNotRecoNHits = new TH1D( "fhRefNotRecoNHits", "fhRefNotRecoNHits", 100, 0., 200 );
473
474 gDirectory->cd( ".." );
475
476 gDirectory->mkdir( "TrackFit" );
477 gDirectory->cd( "TrackFit" );
478
479 fhResY = new TH1D( "resY", "track Y resoltion [cm]", 30, -.5, .5 );
480 fhResZ = new TH1D( "resZ", "track Z resoltion [cm]", 30, -.5, .5 );
481 fhResSinPhi = new TH1D( "resSinPhi", "track SinPhi resoltion ", 30, -.03, .03 );
482 fhResDzDs = new TH1D( "resDzDs", "track DzDs resoltion ", 30, -.01, .01 );
483 fhResPt = new TH1D( "resPt", "track telative Pt resoltion", 30, -.2, .2 );
484 fhPullY = new TH1D( "pullY", "track Y pull", 30, -10., 10. );
485 fhPullZ = new TH1D( "pullZ", "track Z pull", 30, -10., 10. );
486 fhPullSinPhi = new TH1D( "pullSinPhi", "track SinPhi pull", 30, -10., 10. );
487 fhPullDzDs = new TH1D( "pullDzDs", "track DzDs pull", 30, -10., 10. );
488 fhPullQPt = new TH1D( "pullQPt", "track Q/Pt pull", 30, -10., 10. );
489 fhPullYS = new TH1D( "pullYS", "track Y+SinPhi chi deviation", 100, 0., 30. );
490 fhPullZT = new TH1D( "pullZT", "track Z+DzDs chi deviation ", 100, 0., 30. );
491
492 gDirectory->cd( ".." );
493
494 fhEffVsP = new TProfile( "EffVsP", "Eff vs P", 100, 0., 5. );
495 fhGBEffVsP = new TProfile( "GBEffVsP", "Global tracker: Eff vs P", 100, 0., 5. );
496 fhGBEffVsPt = new TProfile( "GBEffVsPt", "Global tracker: Eff vs Pt", 100, 0.2, 5. );
497
498 gDirectory->mkdir( "Clusters" );
499 gDirectory->cd( "Clusters" );
500
4acc2401 501 fhHitShared = new TProfile( "fhHitSharedf", "fhHitShared vs row", 160, 0., 160. );
502
503 fhHitResY = new TH1D( "resHitY", "Y cluster resoltion [cm]", 100, -2., 2. );
504 fhHitResZ = new TH1D( "resHitZ", "Z cluster resoltion [cm]", 100, -2., 2. );
505 fhHitPullY = new TH1D( "pullHitY", "Y cluster pull", 50, -10., 10. );
506 fhHitPullZ = new TH1D( "pullHitZ", "Z cluster pull", 50, -10., 10. );
507
508 fhHitResY1 = new TH1D( "resHitY1", "Y cluster resoltion [cm]", 100, -2., 2. );
509 fhHitResZ1 = new TH1D( "resHitZ1", "Z cluster resoltion [cm]", 100, -2., 2. );
510 fhHitPullY1 = new TH1D( "pullHitY1", "Y cluster pull", 50, -10., 10. );
511 fhHitPullZ1 = new TH1D( "pullHitZ1", "Z cluster pull", 50, -10., 10. );
512
513 fhHitErrY = new TH1D( "HitErrY", "Y cluster error [cm]", 100, 0., 1. );
514 fhHitErrZ = new TH1D( "HitErrZ", "Z cluster error [cm]", 100, 0., 1. );
d54804bf 515
fbb9b71b 516 gDirectory->cd( ".." );
517
518 gDirectory->mkdir( "Cells" );
519 gDirectory->cd( "Cells" );
520 fhCellPurity = new TH1D( "CellPurity", "Cell Purity", 100, -0.1, 1.1 );
521 fhCellNHits = new TH1D( "CellNHits", "Cell NHits", 40, 0., 40. );
522 fhCellPurityVsN = new TProfile( "CellPurityVsN", "Cell purity Vs N hits", 40, 2., 42. );
523 fhCellPurityVsPt = new TProfile( "CellPurityVsPt", "Cell purity Vs Pt", 100, 0., 5. );
524 gDirectory->cd( ".." );
525
526 curdir->cd();
d54804bf 527}
528
529void AliHLTTPCCAPerformance::WriteDir2Current( TObject *obj )
530{
531 //* recursive function to copy the directory 'obj' to the current one
fbb9b71b 532 if ( !obj->IsFolder() ) obj->Write();
533 else {
d54804bf 534 TDirectory *cur = gDirectory;
fbb9b71b 535 TDirectory *sub = cur->mkdir( obj->GetName() );
d54804bf 536 sub->cd();
fbb9b71b 537 TList *listSub = ( ( TDirectory* )obj )->GetList();
538 TIter it( listSub );
539 while ( TObject *obj1 = it() ) WriteDir2Current( obj1 );
d54804bf 540 cur->cd();
541 }
542}
543
544void AliHLTTPCCAPerformance::WriteHistos()
545{
546 //* write histograms to the file
547 TDirectory *curr = gDirectory;
548 // Open output file and write histograms
fbb9b71b 549 TFile* outfile = new TFile( "HLTTPCCATrackerPerformance.root", "RECREATE" );
d54804bf 550 outfile->cd();
fbb9b71b 551 WriteDir2Current( fHistoDir );
d54804bf 552 outfile->Close();
553 curr->cd();
554}
555
556
fbb9b71b 557void AliHLTTPCCAPerformance::LinkPerformance( int iSlice )
558{
ce565086 559 // Efficiency and quality of the found neighbours
fbb9b71b 560 std::cout << "Link performance..." << std::endl;
561 if ( !fTracker ) return;
4acc2401 562 const AliHLTTPCCATracker &slice = fTracker->Slice( iSlice );
ce565086 563
4acc2401 564 AliHLTResizableArray<int> mcType( fNMCTracks );
ce565086 565
fbb9b71b 566 for ( int imc = 0; imc < fNMCTracks; imc++ ) {
567 if ( fMCTracks[imc].P() < .2 ) { mcType[imc] = -1; continue; }
568 float x = fMCTracks[imc].Par()[0];
569 float y = fMCTracks[imc].Par()[1];
570 //float z = fMCTracks[imc].Par()[2];
571 if ( x*x + y*y < 100. ) {
572 if ( fMCTracks[imc].P() >= 1 ) mcType[imc] = 0;
ce565086 573 else mcType[imc] = 1;
574 } else {
fbb9b71b 575 if ( fMCTracks[imc].P() >= 1 ) mcType[imc] = 2;
ce565086 576 else mcType[imc] = 3;
577 }
578 }
579
fbb9b71b 580 struct AliHLTTPCCAMCHits {
581 int fNHits;
582 int fID[30];
583 };
ce565086 584 AliHLTTPCCAMCHits *mcGbHitsUp = new AliHLTTPCCAMCHits[fNMCTracks];
585 AliHLTTPCCAMCHits *mcGbHitsDn = new AliHLTTPCCAMCHits[fNMCTracks];
586
fbb9b71b 587 for ( int iRow = 2; iRow < slice.Param().NRows() - 2; iRow++ ) {
588
589 const AliHLTTPCCARow &row = slice.Row( iRow );
590 const AliHLTTPCCARow &rowUp = slice.Row( iRow + 2 );
591 const AliHLTTPCCARow &rowDn = slice.Row( iRow - 2 );
592
4acc2401 593 AliHLTResizableArray<int> gbHits ( row.NHits() );
594 AliHLTResizableArray<int> gbHitsUp( rowUp.NHits() );
595 AliHLTResizableArray<int> gbHitsDn( rowDn.NHits() );
fbb9b71b 596
4acc2401 597 for ( int ih = 0; ih < row.NHits() ; ih++ ) gbHits [ih] = fTracker->FirstSliceHit()[iSlice] + slice.HitInputID( row , ih );
598 for ( int ih = 0; ih < rowUp.NHits(); ih++ ) gbHitsUp[ih] = fTracker->FirstSliceHit()[iSlice] + slice.HitInputID( rowUp, ih );
599 for ( int ih = 0; ih < rowDn.NHits(); ih++ ) gbHitsDn[ih] = fTracker->FirstSliceHit()[iSlice] + slice.HitInputID( rowDn, ih );
fbb9b71b 600
601 for ( int imc = 0; imc < fNMCTracks; imc++ ) {
ce565086 602 mcGbHitsUp[imc].fNHits = 0;
603 mcGbHitsDn[imc].fNHits = 0;
604 }
fbb9b71b 605
606 for ( int ih = 0; ih < rowUp.NHits(); ih++ ) {
ce565086 607 AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hits()[gbHitsUp[ih]].ID()];
fbb9b71b 608 for ( int il = 0; il < 3; il++ ) {
609 int imc = l.fLab[il];
610 if ( imc < 0 ) break;
611 int &nmc = mcGbHitsUp[imc].fNHits;
612 if ( nmc >= 30 ) continue;
613 mcGbHitsUp[imc].fID[nmc] = gbHitsUp[ih];
614 nmc++;
ce565086 615 }
616 }
617
fbb9b71b 618 for ( int ih = 0; ih < rowDn.NHits(); ih++ ) {
619 AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hits()[gbHitsDn[ih]].ID()];
620 for ( int il = 0; il < 3; il++ ) {
621 int imc = l.fLab[il];
622 if ( imc < 0 ) break;
623 int &nmc = mcGbHitsDn[imc].fNHits;
624 if ( nmc >= 30 ) continue;
625 mcGbHitsDn[imc].fID[nmc] = gbHitsDn[ih];
626 nmc++;
ce565086 627 }
628 }
629
fbb9b71b 630 //float dxUp = rowUp.X() - row.X();
631 //float dxDn = row.X() - rowDn.X();
632 float tUp = rowUp.X() / row.X();
633 float tDn = rowDn.X() / row.X();
ce565086 634
fbb9b71b 635 for ( int ih = 0; ih < row.NHits(); ih++ ) {
636
4acc2401 637 int up = slice.HitLinkUpData( row, ih );
638 int dn = slice.HitLinkDownData( row, ih );
ce565086 639
4acc2401 640 const AliHLTTPCCAGBHit &h = fTracker->Hits()[gbHits[ih]];
fbb9b71b 641 AliHLTTPCCAHitLabel &l = fHitLabels[h.ID()];
642
643 int isMC = -1;
644 int mcFound = -1;
645
646 float yUp = h.Y() * tUp, zUp = h.Z() * tUp;
647 float yDn = h.Y() * tDn, zDn = h.Z() * tDn;
648
649 for ( int il = 0; il < 3; il++ ) {
650 int imc = l.fLab[il];
651 if ( imc < 0 ) break;
652
653 bool isMcUp = 0, isMcDn = 0;
654
655 float dyMin = 1.e8, dzMin = 1.e8;
656 for ( int i = 0; i < mcGbHitsUp[imc].fNHits; i++ ) {
4acc2401 657 const AliHLTTPCCAGBHit &h1 = fTracker->Hits()[mcGbHitsUp[imc].fID[i]];
fbb9b71b 658 float dy = TMath::Abs( h1.Y() - yUp );
659 float dz = TMath::Abs( h1.Z() - zUp );
660 if ( dy*dy + dz*dz < dyMin*dyMin + dzMin*dzMin ) {
661 dyMin = dy;
662 dzMin = dz;
663 }
664 }
665
666 if ( mcType[imc] >= 0 && mcGbHitsUp[imc].fNHits >= 0 ) {
667 fhLinkAreaY[mcType[imc]]->Fill( dyMin );
668 fhLinkAreaZ[mcType[imc]]->Fill( dzMin );
669 }
670 if ( dyMin*dyMin + dzMin*dzMin < 100. ) isMcUp = 1;
671
672 dyMin = 1.e8;
673 dzMin = 1.e8;
674 for ( int i = 0; i < mcGbHitsDn[imc].fNHits; i++ ) {
4acc2401 675 const AliHLTTPCCAGBHit &h1 = fTracker->Hits()[mcGbHitsDn[imc].fID[i]];
fbb9b71b 676 float dy = TMath::Abs( h1.Y() - yDn );
677 float dz = TMath::Abs( h1.Z() - zDn );
678 if ( dy*dy + dz*dz < dyMin*dyMin + dzMin*dzMin ) {
679 dyMin = dy;
680 dzMin = dz;
681 }
682 }
683
684 if ( mcType[imc] >= 0 && mcGbHitsDn[imc].fNHits >= 0 ) {
685 fhLinkAreaY[mcType[imc]]->Fill( dyMin );
686 fhLinkAreaZ[mcType[imc]]->Fill( dzMin );
687 }
688 if ( dyMin*dyMin + dzMin*dzMin < 100. ) isMcDn = 1;
689
690 if ( !isMcUp || !isMcDn ) continue;
691 isMC = imc;
692
693 bool found = 0;
694 if ( up >= 0 && dn >= 0 ) {
695 //std::cout<<"row, ih, mc, up, dn = "<<iRow<<" "<<ih<<" "<<imc<<" "<<up<<" "<<dn<<std::endl;
4acc2401 696 const AliHLTTPCCAGBHit &hUp = fTracker->Hits()[gbHitsUp[up]];
697 const AliHLTTPCCAGBHit &hDn = fTracker->Hits()[gbHitsDn[dn]];
fbb9b71b 698 AliHLTTPCCAHitLabel &lUp = fHitLabels[hUp.ID()];
699 AliHLTTPCCAHitLabel &lDn = fHitLabels[hDn.ID()];
700 bool foundUp = 0, foundDn = 0;
701 for ( int jl = 0; jl < 3; jl++ ) {
702 if ( lUp.fLab[jl] == imc ) foundUp = 1;
703 if ( lDn.fLab[jl] == imc ) foundDn = 1;
704 //std::cout<<"mc up, dn = "<<lUp.fLab[jl]<<" "<<lDn.fLab[jl]<<std::endl;
705 }
706 if ( foundUp && foundDn ) found = 1;
707 }
708 if ( found ) { mcFound = imc; break;}
ce565086 709 }
fbb9b71b 710
711 if ( mcFound >= 0 ) {
712 //std::cout<<" mc "<<mcFound<<" found"<<std::endl;
713 if ( mcType[mcFound] >= 0 ) fhLinkEff[mcType[mcFound]]->Fill( iRow, 1 );
714 } else if ( isMC >= 0 ) {
715 //std::cout<<" mc "<<isMC<<" not found"<<std::endl;
716 if ( mcType[isMC] >= 0 ) fhLinkEff[mcType[isMC]]->Fill( iRow, 0 );
ce565086 717 }
718
fbb9b71b 719 } // ih
ce565086 720 } // iRow
721 delete[] mcGbHitsUp;
722 delete[] mcGbHitsDn;
723}
724
725
fbb9b71b 726void AliHLTTPCCAPerformance::SliceTrackletPerformance( int iSlice, bool PrintFlag )
727{
d54804bf 728 //* calculate slice tracker performance
fbb9b71b 729 if ( !fTracker ) return;
730
731 int nRecTot = 0, nGhost = 0, nRecOut = 0;
732 int nMCAll = 0, nRecAll = 0, nClonesAll = 0;
733 int nMCRef = 0, nRecRef = 0, nClonesRef = 0;
4acc2401 734 const AliHLTTPCCATracker &slice = fTracker->Slice( iSlice );
d54804bf 735
fbb9b71b 736 int firstSliceHit = fTracker->FirstSliceHit()[iSlice];
737 int endSliceHit = fTracker->NHits();
738 if ( iSlice < fTracker->NSlices() - 1 ) endSliceHit = fTracker->FirstSliceHit()[iSlice+1];
d54804bf 739
ce565086 740 // Select reconstructable MC tracks
741
742 {
fbb9b71b 743 for ( int imc = 0; imc < fNMCTracks; imc++ ) fMCTracks[imc].SetNHits( 0 );
744
745 for ( int ih = firstSliceHit; ih < endSliceHit; ih++ ) {
746 int id = fTracker->Hits()[ih].ID();
747 if ( id < 0 || id >= fNHits ) break;
ce565086 748 AliHLTTPCCAHitLabel &l = fHitLabels[id];
fbb9b71b 749 if ( l.fLab[0] >= 0 ) fMCTracks[l.fLab[0]].SetNHits( fMCTracks[l.fLab[0]].NHits() + 1 );
750 if ( l.fLab[1] >= 0 ) fMCTracks[l.fLab[1]].SetNHits( fMCTracks[l.fLab[1]].NHits() + 1 );
751 if ( l.fLab[2] >= 0 ) fMCTracks[l.fLab[2]].SetNHits( fMCTracks[l.fLab[2]].NHits() + 1 );
ce565086 752 }
fbb9b71b 753
754 for ( int imc = 0; imc < fNMCTracks; imc++ ) {
ce565086 755 AliHLTTPCCAMCTrack &mc = fMCTracks[imc];
756 mc.SetSet( 0 );
757 mc.SetNReconstructed( 0 );
758 mc.SetNTurns( 1 );
fbb9b71b 759 if ( mc.NHits() >= 30 && mc.P() >= .05 ) {
760 mc.SetSet( 1 );
761 nMCAll++;
762 if ( mc.NHits() >= 30 && mc.P() >= 1. ) {
763 mc.SetSet( 2 );
764 nMCRef++;
765 }
00d07bcd 766 }
ce565086 767 }
768 }
00d07bcd 769
ce565086 770
4acc2401 771 int traN = slice.NTracklets();
fbb9b71b 772 int *traLabels = 0;
773 double *traPurity = 0;
ce565086 774
fbb9b71b 775 traLabels = new int[traN];
776 traPurity = new double[traN];
ce565086 777 {
fbb9b71b 778 for ( int itr = 0; itr < traN; itr++ ) {
779 traLabels[itr] = -1;
780 traPurity[itr] = 0;
781
782 int hits[1600];
783 int nHits = 0;
784
785 {
4acc2401 786 const AliHLTTPCCAHitId &id = slice.TrackletStartHit( itr );
787 int iRow = id.RowIndex();
788 int ih = id.HitIndex();
fbb9b71b 789
790 while ( ih >= 0 ) {
791 const AliHLTTPCCARow &row = slice.Row( iRow );
4acc2401 792 hits[nHits] = firstSliceHit + slice.HitInputID( row, ih );
fbb9b71b 793 nHits++;
4acc2401 794 ih = slice.HitLinkUpData( row, ih );
fbb9b71b 795 iRow++;
796 }
ce565086 797 }
798
fbb9b71b 799 if ( nHits < 5 ) continue;
800
801 int lb[1600*3];
802 int nla = 0;
ce565086 803
fbb9b71b 804 for ( int ih = 0; ih < nHits; ih++ ) {
805 AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hits()[hits[ih]].ID()];
806 if ( l.fLab[0] >= 0 ) lb[nla++] = l.fLab[0];
807 if ( l.fLab[1] >= 0 ) lb[nla++] = l.fLab[1];
808 if ( l.fLab[2] >= 0 ) lb[nla++] = l.fLab[2];
ce565086 809 }
fbb9b71b 810
811 sort( lb, lb + nla );
812 int labmax = -1, labcur = -1, lmax = 0, lcurr = 0;
813 for ( int i = 0; i < nla; i++ ) {
814 if ( lb[i] != labcur ) {
815 if ( labcur >= 0 && lmax < lcurr ) {
816 lmax = lcurr;
817 labmax = labcur;
818 }
819 labcur = lb[i];
820 lcurr = 0;
821 }
822 lcurr++;
00d07bcd 823 }
fbb9b71b 824 if ( labcur >= 0 && lmax < lcurr ) {
825 lmax = lcurr;
826 labmax = labcur;
00d07bcd 827 }
ce565086 828 lmax = 0;
fbb9b71b 829 for ( int ih = 0; ih < nHits; ih++ ) {
830 AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hits()[hits[ih]].ID()];
831 if ( l.fLab[0] == labmax || l.fLab[1] == labmax || l.fLab[2] == labmax
832 ) lmax++;
ce565086 833 }
834 traLabels[itr] = labmax;
fbb9b71b 835 traPurity[itr] = ( ( nHits > 0 ) ? double( lmax ) / double( nHits ) : 0 );
00d07bcd 836 }
ce565086 837 }
00d07bcd 838
fbb9b71b 839 nRecTot += traN;
840
841 for ( int itr = 0; itr < traN; itr++ ) {
842 if ( traPurity[itr] < .9 || traLabels[itr] < 0 || traLabels[itr] >= fNMCTracks ) {
ce565086 843 nGhost++;
844 continue;
845 }
fbb9b71b 846
847 AliHLTTPCCAMCTrack &mc = fMCTracks[traLabels[itr]];
848 mc.SetNReconstructed( mc.NReconstructed() + 1 );
849 if ( mc.Set() == 0 ) nRecOut++;
850 else {
851 if ( mc.NReconstructed() == 1 ) nRecAll++;
852 else if ( mc.NReconstructed() > mc.NTurns() ) nClonesAll++;
853 if ( mc.Set() == 2 ) {
854 if ( mc.NReconstructed() == 1 ) nRecRef++;
855 else if ( mc.NReconstructed() > mc.NTurns() ) nClonesRef++;
ce565086 856 }
fbb9b71b 857 }
ce565086 858 }
00d07bcd 859
fbb9b71b 860 for ( int ipart = 0; ipart < fNMCTracks; ipart++ ) {
ce565086 861 AliHLTTPCCAMCTrack &mc = fMCTracks[ipart];
fbb9b71b 862 if ( mc.Set() > 0 ) fhSeedEffVsP->Fill( mc.P(), ( mc.NReconstructed() > 0 ? 1 : 0 ) );
863 }
d54804bf 864
fbb9b71b 865 if ( traLabels ) delete[] traLabels;
866 if ( traPurity ) delete[] traPurity;
00d07bcd 867
ce565086 868 fStatSeedNRecTot += nRecTot;
869 fStatSeedNRecOut += nRecOut;
870 fStatSeedNGhost += nGhost;
871 fStatSeedNMCAll += nMCAll;
872 fStatSeedNRecAll += nRecAll;
873 fStatSeedNClonesAll += nClonesAll;
874 fStatSeedNMCRef += nMCRef;
875 fStatSeedNRecRef += nRecRef;
876 fStatSeedNClonesRef += nClonesRef;
877
fbb9b71b 878 if ( nMCAll == 0 ) return;
879
880 if ( PrintFlag ) {
881 cout << "Track seed performance for slice " << iSlice << " : " << endl;
882 cout << " N tracks : "
883 << nMCAll << " mc all, "
884 << nMCRef << " mc ref, "
885 << nRecTot << " rec total, "
886 << nRecAll << " rec all, "
887 << nClonesAll << " clones all, "
888 << nRecRef << " rec ref, "
889 << nClonesRef << " clones ref, "
890 << nRecOut << " out, "
891 << nGhost << " ghost" << endl;
892
893 int nRecExtr = nRecAll - nRecRef;
894 int nMCExtr = nMCAll - nMCRef;
895 int nClonesExtr = nClonesAll - nClonesRef;
896
897 double dRecTot = ( nRecTot > 0 ) ? nRecTot : 1;
898 double dMCAll = ( nMCAll > 0 ) ? nMCAll : 1;
899 double dMCRef = ( nMCRef > 0 ) ? nMCRef : 1;
900 double dMCExtr = ( nMCExtr > 0 ) ? nMCExtr : 1;
901 double dRecAll = ( nRecAll + nClonesAll > 0 ) ? nRecAll + nClonesAll : 1;
902 double dRecRef = ( nRecRef + nClonesRef > 0 ) ? nRecRef + nClonesRef : 1;
903 double dRecExtr = ( nRecExtr + nClonesExtr > 0 ) ? nRecExtr + nClonesExtr : 1;
904
905 cout << " EffRef = ";
906 if ( nMCRef > 0 ) cout << nRecRef / dMCRef; else cout << "_";
907 cout << ", CloneRef = ";
908 if ( nRecRef > 0 ) cout << nClonesRef / dRecRef; else cout << "_";
909 cout << endl;
910 cout << " EffExtra = ";
911 if ( nMCExtr > 0 ) cout << nRecExtr / dMCExtr; else cout << "_";
912 cout << ", CloneExtra = ";
913 if ( nRecExtr > 0 ) cout << nClonesExtr / dRecExtr; else cout << "_";
914 cout << endl;
915 cout << " EffAll = ";
916 if ( nMCAll > 0 ) cout << nRecAll / dMCAll; else cout << "_";
917 cout << ", CloneAll = ";
918 if ( nRecAll > 0 ) cout << nClonesAll / dRecAll; else cout << "_";
919 cout << endl;
920 cout << " Out = ";
921 if ( nRecTot > 0 ) cout << nRecOut / dRecTot; else cout << "_";
922 cout << ", Ghost = ";
923 if ( nRecTot > 0 ) cout << nGhost / dRecTot; else cout << "_";
924 cout << endl;
ce565086 925 }
926}
927
928
929
930
fbb9b71b 931void AliHLTTPCCAPerformance::SliceTrackCandPerformance( int iSlice, bool PrintFlag )
932{
ce565086 933 //* calculate slice tracker performance
fbb9b71b 934 if ( !fTracker ) return;
935
936 int nRecTot = 0, nGhost = 0, nRecOut = 0;
937 int nMCAll = 0, nRecAll = 0, nClonesAll = 0;
938 int nMCRef = 0, nRecRef = 0, nClonesRef = 0;
4acc2401 939 const AliHLTTPCCATracker &slice = fTracker->Slice( iSlice );
ce565086 940
fbb9b71b 941 int firstSliceHit = fTracker->FirstSliceHit()[iSlice];
942 int endSliceHit = fTracker->NHits();
943 if ( iSlice < fTracker->NSlices() - 1 ) endSliceHit = fTracker->FirstSliceHit()[iSlice+1];
ce565086 944
945 // Select reconstructable MC tracks
946
947 {
fbb9b71b 948 for ( int imc = 0; imc < fNMCTracks; imc++ ) fMCTracks[imc].SetNHits( 0 );
949
950 for ( int ih = firstSliceHit; ih < endSliceHit; ih++ ) {
951 int id = fTracker->Hits()[ih].ID();
952 if ( id < 0 || id >= fNHits ) break;
ce565086 953 AliHLTTPCCAHitLabel &l = fHitLabels[id];
fbb9b71b 954 if ( l.fLab[0] >= 0 ) fMCTracks[l.fLab[0]].SetNHits( fMCTracks[l.fLab[0]].NHits() + 1 );
955 if ( l.fLab[1] >= 0 ) fMCTracks[l.fLab[1]].SetNHits( fMCTracks[l.fLab[1]].NHits() + 1 );
956 if ( l.fLab[2] >= 0 ) fMCTracks[l.fLab[2]].SetNHits( fMCTracks[l.fLab[2]].NHits() + 1 );
ce565086 957 }
fbb9b71b 958
959 for ( int imc = 0; imc < fNMCTracks; imc++ ) {
ce565086 960 AliHLTTPCCAMCTrack &mc = fMCTracks[imc];
961 mc.SetSet( 0 );
962 mc.SetNReconstructed( 0 );
963 mc.SetNTurns( 1 );
fbb9b71b 964 if ( mc.NHits() >= 30 && mc.P() >= .05 ) {
965 mc.SetSet( 1 );
966 nMCAll++;
967 if ( mc.NHits() >= 30 && mc.P() >= 1. ) {
968 mc.SetSet( 2 );
969 nMCRef++;
970 }
ce565086 971 }
972 }
973 }
d54804bf 974
4acc2401 975 int traN = slice.NTracklets();
fbb9b71b 976 int *traLabels = 0;
977 double *traPurity = 0;
978 traLabels = new int[traN];
979 traPurity = new double[traN];
ce565086 980 {
fbb9b71b 981 for ( int itr = 0; itr < traN; itr++ ) {
982 traLabels[itr] = -1;
983 traPurity[itr] = 0;
ce565086 984
4acc2401 985 const AliHLTTPCCATracklet &t = slice.Tracklet( itr );
fbb9b71b 986
987 int nHits = t.NHits();
988 if ( nHits < 10 ) continue;
989 int firstRow = t.FirstRow();
990 int lastRow = t.LastRow();
991 nHits = 0;
992
993 int lb[1600*3];
994 int nla = 0;
995
996 for ( int irow = firstRow; irow <= lastRow; irow++ ) {
997 int ih = t.RowHit( irow );
998 if ( ih < 0 ) continue;
4acc2401 999 int index = firstSliceHit + slice.HitInputID( slice.Row( irow ), ih );
fbb9b71b 1000 AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hits()[index].ID()];
1001 if ( l.fLab[0] >= 0 ) lb[nla++] = l.fLab[0];
1002 if ( l.fLab[1] >= 0 ) lb[nla++] = l.fLab[1];
1003 if ( l.fLab[2] >= 0 ) lb[nla++] = l.fLab[2];
1004 nHits++;
ce565086 1005 }
fbb9b71b 1006 if ( nHits < 10 ) continue;
1007
1008 sort( lb, lb + nla );
1009 int labmax = -1, labcur = -1, lmax = 0, lcurr = 0;
1010 for ( int i = 0; i < nla; i++ ) {
1011 if ( lb[i] != labcur ) {
1012 if ( labcur >= 0 && lmax < lcurr ) {
1013 lmax = lcurr;
1014 labmax = labcur;
1015 }
1016 labcur = lb[i];
1017 lcurr = 0;
1018 }
1019 lcurr++;
ce565086 1020 }
fbb9b71b 1021 if ( labcur >= 0 && lmax < lcurr ) {
1022 lmax = lcurr;
1023 labmax = labcur;
ce565086 1024 }
1025 lmax = 0;
fbb9b71b 1026 for ( int irow = firstRow; irow <= lastRow; irow++ ) {
1027 int ih = t.RowHit( irow );
1028 if ( ih < 0 ) continue;
4acc2401 1029 int index = firstSliceHit + slice.HitInputID( slice.Row( irow ), ih );
fbb9b71b 1030 AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hits()[index].ID()];
1031 if ( l.fLab[0] == labmax || l.fLab[1] == labmax || l.fLab[2] == labmax
1032 ) lmax++;
d54804bf 1033 }
ce565086 1034 traLabels[itr] = labmax;
fbb9b71b 1035 traPurity[itr] = ( ( nHits > 0 ) ? double( lmax ) / double( nHits ) : 0 );
d54804bf 1036 }
1037 }
fbb9b71b 1038
1039 nRecTot += traN;
1040
1041 for ( int itr = 0; itr < traN; itr++ ) {
1042 if ( traPurity[itr] < .9 || traLabels[itr] < 0 || traLabels[itr] >= fNMCTracks ) {
ce565086 1043 nGhost++;
1044 continue;
1045 }
fbb9b71b 1046
1047 AliHLTTPCCAMCTrack &mc = fMCTracks[traLabels[itr]];
1048 mc.SetNReconstructed( mc.NReconstructed() + 1 );
1049 if ( mc.Set() == 0 ) nRecOut++;
1050 else {
1051 if ( mc.NReconstructed() == 1 ) nRecAll++;
1052 else if ( mc.NReconstructed() > mc.NTurns() ) nClonesAll++;
1053 if ( mc.Set() == 2 ) {
1054 if ( mc.NReconstructed() == 1 ) nRecRef++;
1055 else if ( mc.NReconstructed() > mc.NTurns() ) nClonesRef++;
ce565086 1056 }
fbb9b71b 1057 }
ce565086 1058 }
1059
fbb9b71b 1060 for ( int ipart = 0; ipart < fNMCTracks; ipart++ ) {
ce565086 1061 AliHLTTPCCAMCTrack &mc = fMCTracks[ipart];
fbb9b71b 1062 if ( mc.Set() > 0 ) fhCandEffVsP->Fill( mc.P(), ( mc.NReconstructed() > 0 ? 1 : 0 ) );
1063 }
ce565086 1064
fbb9b71b 1065 if ( traLabels ) delete[] traLabels;
1066 if ( traPurity ) delete[] traPurity;
ce565086 1067
1068 fStatCandNRecTot += nRecTot;
1069 fStatCandNRecOut += nRecOut;
1070 fStatCandNGhost += nGhost;
1071 fStatCandNMCAll += nMCAll;
1072 fStatCandNRecAll += nRecAll;
1073 fStatCandNClonesAll += nClonesAll;
1074 fStatCandNMCRef += nMCRef;
1075 fStatCandNRecRef += nRecRef;
1076 fStatCandNClonesRef += nClonesRef;
1077
fbb9b71b 1078 if ( nMCAll == 0 ) return;
1079
1080 if ( PrintFlag ) {
1081 cout << "Track candidate performance for slice " << iSlice << " : " << endl;
1082 cout << " N tracks : "
1083 << nMCAll << " mc all, "
1084 << nMCRef << " mc ref, "
1085 << nRecTot << " rec total, "
1086 << nRecAll << " rec all, "
1087 << nClonesAll << " clones all, "
1088 << nRecRef << " rec ref, "
1089 << nClonesRef << " clones ref, "
1090 << nRecOut << " out, "
1091 << nGhost << " ghost" << endl;
1092
1093 int nRecExtr = nRecAll - nRecRef;
1094 int nMCExtr = nMCAll - nMCRef;
1095 int nClonesExtr = nClonesAll - nClonesRef;
1096
1097 double dRecTot = ( nRecTot > 0 ) ? nRecTot : 1;
1098 double dMCAll = ( nMCAll > 0 ) ? nMCAll : 1;
1099 double dMCRef = ( nMCRef > 0 ) ? nMCRef : 1;
1100 double dMCExtr = ( nMCExtr > 0 ) ? nMCExtr : 1;
1101 double dRecAll = ( nRecAll + nClonesAll > 0 ) ? nRecAll + nClonesAll : 1;
1102 double dRecRef = ( nRecRef + nClonesRef > 0 ) ? nRecRef + nClonesRef : 1;
1103 double dRecExtr = ( nRecExtr + nClonesExtr > 0 ) ? nRecExtr + nClonesExtr : 1;
1104
1105 cout << " EffRef = ";
1106 if ( nMCRef > 0 ) cout << nRecRef / dMCRef; else cout << "_";
1107 cout << ", CloneRef = ";
1108 if ( nRecRef > 0 ) cout << nClonesRef / dRecRef; else cout << "_";
1109 cout << endl;
1110 cout << " EffExtra = ";
1111 if ( nMCExtr > 0 ) cout << nRecExtr / dMCExtr; else cout << "_";
1112 cout << ", CloneExtra = ";
1113 if ( nRecExtr > 0 ) cout << nClonesExtr / dRecExtr; else cout << "_";
1114 cout << endl;
1115 cout << " EffAll = ";
1116 if ( nMCAll > 0 ) cout << nRecAll / dMCAll; else cout << "_";
1117 cout << ", CloneAll = ";
1118 if ( nRecAll > 0 ) cout << nClonesAll / dRecAll; else cout << "_";
1119 cout << endl;
1120 cout << " Out = ";
1121 if ( nRecTot > 0 ) cout << nRecOut / dRecTot; else cout << "_";
1122 cout << ", Ghost = ";
1123 if ( nRecTot > 0 ) cout << nGhost / dRecTot; else cout << "_";
1124 cout << endl;
ce565086 1125 }
1126}
1127
1128
1129
fbb9b71b 1130void AliHLTTPCCAPerformance::SlicePerformance( int iSlice, bool PrintFlag )
1131{
ce565086 1132 //* calculate slice tracker performance
fbb9b71b 1133 if ( !fTracker ) return;
1134
1135 int nRecTot = 0, nGhost = 0, nRecOut = 0;
1136 int nMCAll = 0, nRecAll = 0, nClonesAll = 0;
1137 int nMCRef = 0, nRecRef = 0, nClonesRef = 0;
4acc2401 1138 const AliHLTTPCCATracker &slice = fTracker->Slice( iSlice );
ce565086 1139
fbb9b71b 1140 int firstSliceHit = 0;
1141 for ( ; firstSliceHit < fTracker->NHits(); firstSliceHit++ ) {
4acc2401 1142 if ( fTracker->Hit( firstSliceHit ).ISlice() == iSlice ) break;
ce565086 1143 }
fbb9b71b 1144 int endSliceHit = firstSliceHit;
ce565086 1145
fbb9b71b 1146 for ( ; endSliceHit < fTracker->NHits(); endSliceHit++ ) {
4acc2401 1147 if ( fTracker->Hit( endSliceHit ).ISlice() != iSlice ) break;
ce565086 1148 }
fbb9b71b 1149
00d07bcd 1150
d54804bf 1151 // Select reconstructable MC tracks
1152
1153 {
fbb9b71b 1154 for ( int imc = 0; imc < fNMCTracks; imc++ ) fMCTracks[imc].SetNHits( 0 );
1155
1156 for ( int ih = firstSliceHit; ih < endSliceHit; ih++ ) {
4acc2401 1157 int id = fTracker->Hit( ih ).ID();
fbb9b71b 1158 if ( id < 0 || id > fNHits ) break;
4687b8fc 1159 AliHLTTPCCAHitLabel &l = fHitLabels[id];
fbb9b71b 1160 if ( l.fLab[0] >= 0 ) fMCTracks[l.fLab[0]].SetNHits( fMCTracks[l.fLab[0]].NHits() + 1 );
1161 if ( l.fLab[1] >= 0 ) fMCTracks[l.fLab[1]].SetNHits( fMCTracks[l.fLab[1]].NHits() + 1 );
1162 if ( l.fLab[2] >= 0 ) fMCTracks[l.fLab[2]].SetNHits( fMCTracks[l.fLab[2]].NHits() + 1 );
d54804bf 1163 }
fbb9b71b 1164
1165 for ( int imc = 0; imc < fNMCTracks; imc++ ) {
d54804bf 1166 AliHLTTPCCAMCTrack &mc = fMCTracks[imc];
ce565086 1167 mc.SetSet( 0 );
1168 mc.SetNReconstructed( 0 );
1169 mc.SetNTurns( 1 );
fbb9b71b 1170 if ( mc.NHits() >= 30 && mc.P() >= .05 ) {
1171 mc.SetSet( 1 );
1172 nMCAll++;
1173 if ( mc.NHits() >= 30 && mc.P() >= 1. ) {
1174 mc.SetSet( 2 );
1175 nMCRef++;
1176 }
d54804bf 1177 }
1178 }
1179 }
1180
fbb9b71b 1181 int traN = *slice.NOutTracks();
1182 int *traLabels = 0;
1183 double *traPurity = 0;
1184 traLabels = new int[traN];
1185 traPurity = new double[traN];
d54804bf 1186 {
fbb9b71b 1187 for ( int itr = 0; itr < traN; itr++ ) {
1188 traLabels[itr] = -1;
1189 traPurity[itr] = 0;
4acc2401 1190 const AliHLTTPCCAOutTrack &tCA = slice.OutTrack( itr );
fbb9b71b 1191 int nhits = tCA.NHits();
1192 int *lb = new int[nhits*3];
1193 int nla = 0;
eb30eb49 1194 //cout<<"\nHit labels:"<<endl;
fbb9b71b 1195 for ( int ihit = 0; ihit < nhits; ihit++ ) {
4acc2401 1196 const int index = firstSliceHit + slice.OutTrackHit( tCA.FirstHitRef() + ihit );
1197 const AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hit( index ).ID()];
fbb9b71b 1198 //cout<<l.fLab[0]<<" "<<l.fLab[1]<<" "<<l.fLab[2]<<endl;
1199 if ( l.fLab[0] >= 0 ) lb[nla++] = l.fLab[0];
1200 if ( l.fLab[1] >= 0 ) lb[nla++] = l.fLab[1];
1201 if ( l.fLab[2] >= 0 ) lb[nla++] = l.fLab[2];
d54804bf 1202 }
fbb9b71b 1203 sort( lb, lb + nla );
1204 int labmax = -1, labcur = -1, lmax = 0, lcurr = 0;
1205 for ( int i = 0; i < nla; i++ ) {
1206 if ( lb[i] != labcur ) {
1207 if ( labcur >= 0 && lmax < lcurr ) {
1208 lmax = lcurr;
1209 labmax = labcur;
1210 }
1211 labcur = lb[i];
1212 lcurr = 0;
1213 }
1214 lcurr++;
d54804bf 1215 }
fbb9b71b 1216 if ( labcur >= 0 && lmax < lcurr ) {
1217 lmax = lcurr;
1218 labmax = labcur;
d54804bf 1219 }
1220 lmax = 0;
fbb9b71b 1221 for ( int ihit = 0; ihit < nhits; ihit++ ) {
4acc2401 1222 const int index = firstSliceHit + slice.OutTrackHit( tCA.FirstHitRef() + ihit );
1223 const AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hit( index ).ID()];
fbb9b71b 1224 if ( l.fLab[0] == labmax || l.fLab[1] == labmax || l.fLab[2] == labmax
1225 ) lmax++;
d54804bf 1226 }
1227 traLabels[itr] = labmax;
fbb9b71b 1228 traPurity[itr] = ( ( nhits > 0 ) ? double( lmax ) / double( nhits ) : 0 );
eb30eb49 1229 //cout<<"perf track "<<itr<<": "<<nhits<<" "<<labmax<<" "<<traPurity[itr]<<endl;
fbb9b71b 1230 if ( lb ) delete[] lb;
d54804bf 1231 }
1232 }
1233
fbb9b71b 1234 nRecTot += traN;
eb30eb49 1235
fbb9b71b 1236 for ( int itr = 0; itr < traN; itr++ ) {
1237 if ( traPurity[itr] < .9 || traLabels[itr] < 0 || traLabels[itr] >= fNMCTracks ) {
d54804bf 1238 nGhost++;
1239 continue;
1240 }
1241
fbb9b71b 1242 AliHLTTPCCAMCTrack &mc = fMCTracks[traLabels[itr]];
1243 mc.SetNReconstructed( mc.NReconstructed() + 1 );
1244 if ( mc.Set() == 0 ) nRecOut++;
1245 else {
1246 if ( mc.NReconstructed() == 1 ) nRecAll++;
1247 else if ( mc.NReconstructed() > mc.NTurns() ) nClonesAll++;
1248 if ( mc.Set() == 2 ) {
1249 if ( mc.NReconstructed() == 1 ) nRecRef++;
1250 else if ( mc.NReconstructed() > mc.NTurns() ) nClonesRef++;
d54804bf 1251 }
fbb9b71b 1252 }
d54804bf 1253 }
1254
fbb9b71b 1255 for ( int ipart = 0; ipart < fNMCTracks; ipart++ ) {
d54804bf 1256 AliHLTTPCCAMCTrack &mc = fMCTracks[ipart];
fbb9b71b 1257 if ( mc.Set() > 0 ) fhEffVsP->Fill( mc.P(), ( mc.NReconstructed() > 0 ? 1 : 0 ) );
1258 }
d54804bf 1259
fbb9b71b 1260 if ( traLabels ) delete[] traLabels;
1261 if ( traPurity ) delete[] traPurity;
d54804bf 1262
1263 fStatNRecTot += nRecTot;
1264 fStatNRecOut += nRecOut;
1265 fStatNGhost += nGhost;
1266 fStatNMCAll += nMCAll;
1267 fStatNRecAll += nRecAll;
1268 fStatNClonesAll += nClonesAll;
1269 fStatNMCRef += nMCRef;
1270 fStatNRecRef += nRecRef;
1271 fStatNClonesRef += nClonesRef;
1272
fbb9b71b 1273 if ( nMCAll == 0 ) return;
1274
1275 if ( PrintFlag ) {
1276 cout << "Performance for slice " << iSlice << " : " << endl;
1277 cout << " N tracks : "
1278 << nMCAll << " mc all, "
1279 << nMCRef << " mc ref, "
1280 << nRecTot << " rec total, "
1281 << nRecAll << " rec all, "
1282 << nClonesAll << " clones all, "
1283 << nRecRef << " rec ref, "
1284 << nClonesRef << " clones ref, "
1285 << nRecOut << " out, "
1286 << nGhost << " ghost" << endl;
1287
1288 int nRecExtr = nRecAll - nRecRef;
1289 int nMCExtr = nMCAll - nMCRef;
1290 int nClonesExtr = nClonesAll - nClonesRef;
1291
1292 double dRecTot = ( nRecTot > 0 ) ? nRecTot : 1;
1293 double dMCAll = ( nMCAll > 0 ) ? nMCAll : 1;
1294 double dMCRef = ( nMCRef > 0 ) ? nMCRef : 1;
1295 double dMCExtr = ( nMCExtr > 0 ) ? nMCExtr : 1;
1296 double dRecAll = ( nRecAll + nClonesAll > 0 ) ? nRecAll + nClonesAll : 1;
1297 double dRecRef = ( nRecRef + nClonesRef > 0 ) ? nRecRef + nClonesRef : 1;
1298 double dRecExtr = ( nRecExtr + nClonesExtr > 0 ) ? nRecExtr + nClonesExtr : 1;
1299
1300 cout << " EffRef = ";
1301 if ( nMCRef > 0 ) cout << nRecRef / dMCRef; else cout << "_";
1302 cout << ", CloneRef = ";
1303 if ( nRecRef > 0 ) cout << nClonesRef / dRecRef; else cout << "_";
1304 cout << endl;
1305 cout << " EffExtra = ";
1306 if ( nMCExtr > 0 ) cout << nRecExtr / dMCExtr; else cout << "_";
1307 cout << ", CloneExtra = ";
1308 if ( nRecExtr > 0 ) cout << nClonesExtr / dRecExtr; else cout << "_";
1309 cout << endl;
1310 cout << " EffAll = ";
1311 if ( nMCAll > 0 ) cout << nRecAll / dMCAll; else cout << "_";
1312 cout << ", CloneAll = ";
1313 if ( nRecAll > 0 ) cout << nClonesAll / dRecAll; else cout << "_";
1314 cout << endl;
1315 cout << " Out = ";
1316 if ( nRecTot > 0 ) cout << nRecOut / dRecTot; else cout << "_";
1317 cout << ", Ghost = ";
1318 if ( nRecTot > 0 ) cout << nGhost / dRecTot; else cout << "_";
1319 cout << endl;
d54804bf 1320 }
1321}
1322
1323
4687b8fc 1324void AliHLTTPCCAPerformance::Performance( fstream *StatFile )
fbb9b71b 1325{
1326 // main routine for performance calculation
eb30eb49 1327 //SG!!!
fbb9b71b 1328 /*
eb30eb49 1329 fStatNEvents=0;
1330 fStatNRecTot=0;
1331 fStatNRecOut=0;
1332 fStatNGhost=0;
1333 fStatNMCAll=0;
1334 fStatNRecAll=0;
1335 fStatNClonesAll=0;
1336 fStatNMCRef=0;
1337 fStatNRecRef=0;
1338 fStatNClonesRef=0;
1339 */
fbb9b71b 1340 fStatNEvents++;
1341 for ( int islice = 0; islice < fTracker->NSlices(); islice++ ) {
ce565086 1342 //SliceTrackletPerformance( islice,0 );
1343 SliceTrackCandPerformance( islice, 0 );
fbb9b71b 1344 SlicePerformance( islice, 0 );
d54804bf 1345 }
eb30eb49 1346
00d07bcd 1347
eb30eb49 1348 // global tracker performance
1349 {
fbb9b71b 1350 if ( !fTracker ) return;
eb30eb49 1351
fbb9b71b 1352 int nRecTot = 0, nGhost = 0, nRecOut = 0;
1353 int nMCAll = 0, nRecAll = 0, nClonesAll = 0;
1354 int nMCRef = 0, nRecRef = 0, nClonesRef = 0;
eb30eb49 1355
fbb9b71b 1356 // Select reconstructable MC tracks
1357
1358 {
1359 for ( int imc = 0; imc < fNMCTracks; imc++ ) fMCTracks[imc].SetNHits( 0 );
1360
1361 for ( int ih = 0; ih < fNHits; ih++ ) {
1362 AliHLTTPCCAHitLabel &l = fHitLabels[ih];
1363 if ( l.fLab[0] >= 0 ) fMCTracks[l.fLab[0]].SetNHits( fMCTracks[l.fLab[0]].NHits() + 1 );
1364 if ( l.fLab[1] >= 0 ) fMCTracks[l.fLab[1]].SetNHits( fMCTracks[l.fLab[1]].NHits() + 1 );
1365 if ( l.fLab[2] >= 0 ) fMCTracks[l.fLab[2]].SetNHits( fMCTracks[l.fLab[2]].NHits() + 1 );
eb30eb49 1366 }
1367
fbb9b71b 1368 for ( int imc = 0; imc < fNMCTracks; imc++ ) {
1369 AliHLTTPCCAMCTrack &mc = fMCTracks[imc];
1370 mc.SetSet( 0 );
1371 mc.SetNReconstructed( 0 );
1372 mc.SetNTurns( 1 );
1373 if ( mc.NHits() >= 50 && mc.P() >= .05 ) {
1374 mc.SetSet( 1 );
1375 nMCAll++;
1376 if ( mc.P() >= 1. ) {
1377 mc.SetSet( 2 );
1378 nMCRef++;
1379 }
1380 }
eb30eb49 1381 }
fbb9b71b 1382 }
1383
1384 int traN = fTracker->NTracks();
1385 int *traLabels = 0;
1386 double *traPurity = 0;
1387 traLabels = new int[traN];
1388 traPurity = new double[traN];
1389 {
1390 for ( int itr = 0; itr < traN; itr++ ) {
1391 traLabels[itr] = -1;
1392 traPurity[itr] = 0;
4acc2401 1393 const AliHLTTPCCAGBTrack &tCA = fTracker->Track( itr );
1394 const int nhits = tCA.NHits();
fbb9b71b 1395 int *lb = new int[nhits*3];
1396 int nla = 0;
1397 for ( int ihit = 0; ihit < nhits; ihit++ ) {
4acc2401 1398 const int index = fTracker->TrackHit( tCA.FirstHitRef() + ihit );
1399 const AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hit( index ).ID()];
fbb9b71b 1400 if ( l.fLab[0] >= 0 ) lb[nla++] = l.fLab[0];
1401 if ( l.fLab[1] >= 0 ) lb[nla++] = l.fLab[1];
1402 if ( l.fLab[2] >= 0 ) lb[nla++] = l.fLab[2];
1403 }
1404 sort( lb, lb + nla );
1405 int labmax = -1, labcur = -1, lmax = 0, lcurr = 0;
1406 for ( int i = 0; i < nla; i++ ) {
1407 if ( lb[i] != labcur ) {
1408 if ( labcur >= 0 && lmax < lcurr ) {
1409 lmax = lcurr;
1410 labmax = labcur;
1411 }
1412 labcur = lb[i];
1413 lcurr = 0;
1414 }
1415 lcurr++;
1416 }
1417 if ( labcur >= 0 && lmax < lcurr ) {
1418 lmax = lcurr;
1419 labmax = labcur;
1420 }
1421 lmax = 0;
1422 for ( int ihit = 0; ihit < nhits; ihit++ ) {
4acc2401 1423 const int index = fTracker->TrackHit( tCA.FirstHitRef() + ihit );
1424 const AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hit( index ).ID()];
fbb9b71b 1425 if ( l.fLab[0] == labmax || l.fLab[1] == labmax || l.fLab[2] == labmax
1426 ) lmax++;
1427 }
1428 traLabels[itr] = labmax;
1429 traPurity[itr] = ( ( nhits > 0 ) ? double( lmax ) / double( nhits ) : 0 );
1430 if ( lb ) delete[] lb;
1431 }
1432 }
eb30eb49 1433
fbb9b71b 1434 nRecTot += traN;
1435 for ( int itr = 0; itr < traN; itr++ ) {
1436 if ( traPurity[itr] < .9 || traLabels[itr] < 0 || traLabels[itr] >= fNMCTracks ) {
1437 nGhost++;
1438 continue;
eb30eb49 1439 }
4acc2401 1440 const AliHLTTPCCAGBTrack &tCA = fTracker->Track( itr );
fbb9b71b 1441 AliHLTTPCCAMCTrack &mc = fMCTracks[traLabels[itr]];
1442
1443 mc.SetNReconstructed( mc.NReconstructed() + 1 );
1444 if ( mc.Set() == 0 ) nRecOut++;
1445 else {
1446 if ( mc.NReconstructed() == 1 ) nRecAll++;
1447 else if ( mc.NReconstructed() > mc.NTurns() ) nClonesAll++;
1448 if ( mc.Set() == 2 ) {
1449 if ( mc.NReconstructed() == 1 ) nRecRef++;
1450 else if ( mc.NReconstructed() > mc.NTurns() ) nClonesRef++;
1451 fhTrackLengthRef->Fill( tCA.NHits() / ( ( double ) mc.NHits() ) );
1452 }
1453 }
1454
1455 // track resolutions
1456 while ( mc.Set() == 2 && TMath::Abs( mc.TPCPar()[0] ) + TMath::Abs( mc.TPCPar()[1] ) > 1 ) {
1457 if ( traPurity[itr] < .90 ) break;
4acc2401 1458 const AliHLTTPCCAGBTrack &t = fTracker->Track( itr );
fbb9b71b 1459 AliHLTTPCCATrackParam p = t.Param();
1460 double cosA = TMath::Cos( t.Alpha() );
1461 double sinA = TMath::Sin( t.Alpha() );
1462 double mcX = mc.TPCPar()[0] * cosA + mc.TPCPar()[1] * sinA;
1463 double mcY = -mc.TPCPar()[0] * sinA + mc.TPCPar()[1] * cosA;
1464 double mcZ = mc.TPCPar()[2];
1465 double mcEx = mc.TPCPar()[3] * cosA + mc.TPCPar()[4] * sinA;
1466 double mcEy = -mc.TPCPar()[3] * sinA + mc.TPCPar()[4] * cosA;
1467 double mcEz = mc.TPCPar()[5];
1468 double mcEt = TMath::Sqrt( mcEx * mcEx + mcEy * mcEy );
1469 if ( TMath::Abs( mcEt ) < 1.e-4 ) break;
1470 double mcSinPhi = mcEy / mcEt;
1471 double mcDzDs = mcEz / mcEt;
1472 double mcQPt = mc.TPCPar()[6] / mcEt;
1473 if ( TMath::Abs( mcQPt ) < 1.e-4 ) break;
1474 double mcPt = 1. / TMath::Abs( mcQPt );
1475 if ( mcPt < 1. ) break;
1476 if ( t.NHits() < 50 ) break;
4acc2401 1477 double bz = fTracker->Slice( 0 ).Param().Bz();
fbb9b71b 1478 if ( !p.TransportToXWithMaterial( mcX, bz ) ) break;
1479 if ( p.GetCosPhi()*mcEx < 0 ) { // change direction
1480 mcSinPhi = -mcSinPhi;
1481 mcDzDs = -mcDzDs;
1482 mcQPt = -mcQPt;
1483 }
1484 const double kCLight = 0.000299792458;
1485 double k2QPt = 100;
1486 if ( TMath::Abs( bz ) > 1.e-4 ) k2QPt = 1. / ( bz * kCLight );
1487 double qPt = p.GetKappa( bz ) * k2QPt;
1488 double pt = 100;
1489 if ( TMath::Abs( qPt ) > 1.e-4 ) pt = 1. / TMath::Abs( qPt );
1490
1491 fhResY->Fill( p.GetY() - mcY );
1492 fhResZ->Fill( p.GetZ() - mcZ );
1493 fhResSinPhi->Fill( p.GetSinPhi() - mcSinPhi );
1494 fhResDzDs->Fill( p.GetDzDs() - mcDzDs );
1495 fhResPt->Fill( ( pt - mcPt ) / mcPt );
1496
1497 if ( p.GetErr2Y() > 0 ) fhPullY->Fill( ( p.GetY() - mcY ) / TMath::Sqrt( p.GetErr2Y() ) );
1498 if ( p.GetErr2Z() > 0 ) fhPullZ->Fill( ( p.GetZ() - mcZ ) / TMath::Sqrt( p.GetErr2Z() ) );
1499
1500 if ( p.GetErr2SinPhi() > 0 ) fhPullSinPhi->Fill( ( p.GetSinPhi() - mcSinPhi ) / TMath::Sqrt( p.GetErr2SinPhi() ) );
1501 if ( p.GetErr2DzDs() > 0 ) fhPullDzDs->Fill( ( p.DzDs() - mcDzDs ) / TMath::Sqrt( p.GetErr2DzDs() ) );
1502 //if( p.GetErr2Kappa()>0 ) fhPullQPt->Fill( (qPt - mcQPt)/TMath::Sqrt(p.GetErr2Kappa()*k2QPt*k2QPt) );
1503 //fhPullYS->Fill( TMath::Sqrt(fTracker->GetChi2( p.GetY(), p.GetSinPhi(), p.GetCov()[0], p.GetCov()[3], p.GetCov()[5],
1504 // mcY, mcSinPhi, 0,0,0 )));
1505 //fhPullZT->Fill( TMath::Sqrt(fTracker->GetChi2( p.GetZ(), p.GetDzDs(), p.GetCov()[2], p.GetCov()[7], p.GetCov()[9],
1506 // mcZ, mcDzDs, 0,0,0 ) ));
1507
1508 break;
1509 }
1510 }
eb30eb49 1511
fbb9b71b 1512 for ( int ipart = 0; ipart < fNMCTracks; ipart++ ) {
1513 AliHLTTPCCAMCTrack &mc = fMCTracks[ipart];
1514 if ( mc.Set() > 0 ) fhGBEffVsP->Fill( mc.P(), ( mc.NReconstructed() > 0 ? 1 : 0 ) );
1515 if ( mc.Set() > 0 ) fhGBEffVsPt->Fill( mc.Pt(), ( mc.NReconstructed() > 0 ? 1 : 0 ) );
1516 if ( mc.Set() == 2 ) {
1517 const double *p = mc.TPCPar();
1518 double r = TMath::Sqrt( p[0] * p[0] + p[1] * p[1] );
1519 double cosA = p[0] / r;
1520 double sinA = p[1] / r;
1521
1522
1523 double phipos = TMath::Pi() + TMath::ATan2( -p[1], -p[0] );
1524 double alpha = TMath::Pi() * ( 20 * ( ( ( ( int )( phipos * 180 / TMath::Pi() ) ) / 20 ) ) + 10 ) / 180.;
1525 cosA = TMath::Cos( alpha );
1526 sinA = TMath::Sin( alpha );
1527
1528 double mcX = p[0] * cosA + p[1] * sinA;
1529 double mcY = -p[0] * sinA + p[1] * cosA;
1530 double mcZ = p[2];
1531 double mcEx = p[3] * cosA + p[4] * sinA;
1532 double mcEy = -p[3] * sinA + p[4] * cosA;
1533 double mcEz = p[5];
1534 //double mcEt = TMath::Sqrt(mcEx*mcEx + mcEy*mcEy);
1535 double angleY = TMath::ATan2( mcEy, mcEx ) * 180. / TMath::Pi();
1536 double angleZ = TMath::ATan2( mcEz, mcEx ) * 180. / TMath::Pi();
1537
1538 if ( mc.NReconstructed() > 0 ) {
1539 fhRefRecoX->Fill( mcX );
1540 fhRefRecoY->Fill( mcY );
1541 fhRefRecoZ->Fill( mcZ );
1542 fhRefRecoP->Fill( mc.P() );
1543 fhRefRecoPt->Fill( mc.Pt() );
1544 fhRefRecoAngleY->Fill( angleY );
1545 fhRefRecoAngleZ->Fill( angleZ );
1546 fhRefRecoNHits->Fill( mc.NHits() );
1547 } else {
1548 fhRefNotRecoX->Fill( mcX );
1549 fhRefNotRecoY->Fill( mcY );
1550 fhRefNotRecoZ->Fill( mcZ );
1551 fhRefNotRecoP->Fill( mc.P() );
1552 fhRefNotRecoPt->Fill( mc.Pt() );
1553 fhRefNotRecoAngleY->Fill( angleY );
1554 fhRefNotRecoAngleZ->Fill( angleZ );
1555 fhRefNotRecoNHits->Fill( mc.NHits() );
1556 }
eb30eb49 1557 }
fbb9b71b 1558 }
eb30eb49 1559
fbb9b71b 1560 if ( traLabels ) delete[] traLabels;
1561 if ( traPurity ) delete[] traPurity;
1562
1563 fStatGBNRecTot += nRecTot;
1564 fStatGBNRecOut += nRecOut;
1565 fStatGBNGhost += nGhost;
1566 fStatGBNMCAll += nMCAll;
1567 fStatGBNRecAll += nRecAll;
1568 fStatGBNClonesAll += nClonesAll;
1569 fStatGBNMCRef += nMCRef;
1570 fStatGBNRecRef += nRecRef;
1571 fStatGBNClonesRef += nClonesRef;
eb30eb49 1572 }
1573
fbb9b71b 1574
d54804bf 1575 // distribution of cluster errors
1576
fbb9b71b 1577 {
1578 int nHits = fTracker->NHits();
1579 for ( int ih = 0; ih < nHits; ih++ ) {
4acc2401 1580 const AliHLTTPCCAGBHit &hit = fTracker->Hit( ih );
ce565086 1581 AliHLTTPCCAHitLabel &l = fHitLabels[hit.ID()];
4acc2401 1582 fhHitErrY->Fill( hit.ErrY() );
1583 fhHitErrZ->Fill( hit.ErrZ() );
fbb9b71b 1584 int nmc = 0;
1585 for ( int il = 0; il < 3; il++ ) if ( l.fLab[il] >= 0 ) nmc++;
4acc2401 1586 if ( nmc == 1 ) fhHitShared->Fill( hit.IRow(), 0 );
1587 else if ( nmc > 1 ) fhHitShared->Fill( hit.IRow(), 1 );
d54804bf 1588 }
1589 }
eb30eb49 1590
1591 // cluster pulls
1592
fbb9b71b 1593 if ( fDoClusterPulls && fNMCPoints > 0 ) {
eb30eb49 1594
1595 {
fbb9b71b 1596 for ( int ipart = 0; ipart < fNMCTracks; ipart++ ) {
1597 AliHLTTPCCAMCTrack &mc = fMCTracks[ipart];
1598 mc.SetNMCPoints( 0 );
eb30eb49 1599 }
fbb9b71b 1600 sort( fMCPoints, fMCPoints + fNMCPoints, AliHLTTPCCAMCPoint::Compare );
1601
1602 for ( int ip = 0; ip < fNMCPoints; ip++ ) {
1603 AliHLTTPCCAMCPoint &p = fMCPoints[ip];
1604 AliHLTTPCCAMCTrack &t = fMCTracks[p.TrackID()];
1605 if ( t.NMCPoints() == 0 ) t.SetFirstMCPointID( ip );
1606 t.SetNMCPoints( t.NMCPoints() + 1 );
eb30eb49 1607 }
1608 }
1609
fbb9b71b 1610 for ( int ih = 0; ih < fNHits; ih++ ) {
eb30eb49 1611
4acc2401 1612 const AliHLTTPCCAGBHit &hit = fTracker->Hit( ih );
1613 const AliHLTTPCCAHitLabel &l = fHitLabels[ih];
eb30eb49 1614
fbb9b71b 1615 if ( l.fLab[0] < 0 || l.fLab[0] >= fNMCTracks
1616 || l.fLab[1] >= 0 || l.fLab[2] >= 0 ) continue;
eb30eb49 1617
fbb9b71b 1618 int lab = l.fLab[0];
eb30eb49 1619
1620 AliHLTTPCCAMCTrack &track = fMCTracks[lab];
1621 //if( track.Pt()<1. ) continue;
fbb9b71b 1622 int ip1 = -1, ip2 = -1;
1623 double d1 = 1.e20, d2 = 1.e20;
1624 for ( int ip = 0; ip < track.NMCPoints(); ip++ ) {
eb30eb49 1625 AliHLTTPCCAMCPoint &p = fMCPoints[track.FirstMCPointID() + ip];
fbb9b71b 1626 if ( p.ISlice() != hit.ISlice() ) continue;
1627 double dx = p.Sx() - hit.X();
1628 double dy = p.Sy() - hit.Y();
1629 double dz = p.Sz() - hit.Z();
1630 double d = dx * dx + dy * dy + dz * dz;
1631 if ( p.Sx() < hit.X() ) {
1632 if ( d < d1 ) {
1633 d1 = d;
1634 ip1 = ip;
1635 }
1636 } else {
1637 if ( d < d2 ) {
1638 d2 = d;
1639 ip2 = ip;
1640 }
1641 }
eb30eb49 1642 }
1643
fbb9b71b 1644 if ( ip1 < 0 || ip2 < 0 ) continue;
eb30eb49 1645
1646 AliHLTTPCCAMCPoint &p1 = fMCPoints[track.FirstMCPointID() + ip1];
1647 AliHLTTPCCAMCPoint &p2 = fMCPoints[track.FirstMCPointID() + ip2];
fbb9b71b 1648 double dx = p2.Sx() - p1.Sx();
1649 double dy = p2.Sy() - p1.Sy();
1650 double dz = p2.Sz() - p1.Sz();
1651 if ( TMath::Abs( dx ) > 1.e-8 && TMath::Abs( p1.Sx() - hit.X() ) < 2. && TMath::Abs( p2.Sx() - hit.X() ) < 2. ) {
1652 double sx = hit.X();
4acc2401 1653 //double sy = p1.Sy() + dy/dx*(sx-p1.Sx());
fbb9b71b 1654 double sz = p1.Sz() + dz / dx * ( sx - p1.Sx() );
1655
4acc2401 1656 //float errY, errZ;
fbb9b71b 1657 {
4acc2401 1658 AliHLTTPCCATrackParam t;
1659 t.SetZ( sz );
1660 t.SetSinPhi( dy / TMath::Sqrt( dx*dx + dy*dy ) );
1661 t.SetSignCosPhi( dx );
1662 t.SetDzDs( dz / TMath::Sqrt( dx*dx + dy*dy ) );
1663 //fTracker->GetErrors2(hit,t,errY, errZ );
1664 //errY = TMath::Sqrt(errY);
1665 //errZ = TMath::Sqrt(errZ);
fbb9b71b 1666 }
4acc2401 1667 /*
1668 fhHitResY->Fill((hit.Y()-sy));
1669 fhHitResZ->Fill((hit.Z()-sz));
1670 fhHitPullY->Fill((hit.Y()-sy)/errY);
1671 fhHitPullZ->Fill((hit.Z()-sz)/errZ);
1672 if( track.Pt()>=1. ){
1673 fhHitResY1->Fill((hit.Y()-sy));
1674 fhHitResZ1->Fill((hit.Z()-sz));
1675 fhHitPullY1->Fill((hit.Y()-sy)/errY);
1676 fhHitPullZ1->Fill((hit.Z()-sz)/errZ);
fbb9b71b 1677 }
4acc2401 1678 */
eb30eb49 1679 }
fbb9b71b 1680 }
eb30eb49 1681 }
1682
ce565086 1683 {
fbb9b71b 1684 cout << "\nSlice Track Seed performance: \n" << endl;
1685 cout << " N tracks : "
1686 << fStatNMCAll / fStatNEvents << " mc all, "
1687 << fStatSeedNMCRef / fStatNEvents << " mc ref, "
1688 << fStatSeedNRecTot / fStatNEvents << " rec total, "
1689 << fStatSeedNRecAll / fStatNEvents << " rec all, "
1690 << fStatSeedNClonesAll / fStatNEvents << " clones all, "
1691 << fStatSeedNRecRef / fStatNEvents << " rec ref, "
1692 << fStatSeedNClonesRef / fStatNEvents << " clones ref, "
1693 << fStatSeedNRecOut / fStatNEvents << " out, "
1694 << fStatSeedNGhost / fStatNEvents << " ghost" << endl;
1695
1696 int nRecExtr = fStatSeedNRecAll - fStatSeedNRecRef;
1697 int nMCExtr = fStatNMCAll - fStatNMCRef;
1698 int nClonesExtr = fStatSeedNClonesAll - fStatSeedNClonesRef;
1699
1700 double dRecTot = ( fStatSeedNRecTot > 0 ) ? fStatSeedNRecTot : 1;
1701 double dMCAll = ( fStatNMCAll > 0 ) ? fStatNMCAll : 1;
1702 double dMCRef = ( fStatNMCRef > 0 ) ? fStatNMCRef : 1;
1703 double dMCExtr = ( nMCExtr > 0 ) ? nMCExtr : 1;
1704 double dRecAll = ( fStatSeedNRecAll + fStatSeedNClonesAll > 0 ) ? fStatSeedNRecAll + fStatSeedNClonesAll : 1;
1705 double dRecRef = ( fStatSeedNRecRef + fStatSeedNClonesRef > 0 ) ? fStatSeedNRecRef + fStatSeedNClonesRef : 1;
1706 double dRecExtr = ( nRecExtr + nClonesExtr > 0 ) ? nRecExtr + nClonesExtr : 1;
1707
1708 cout << " EffRef = " << fStatSeedNRecRef / dMCRef
1709 << ", CloneRef = " << fStatSeedNClonesRef / dRecRef << endl;
1710 cout << " EffExtra = " << nRecExtr / dMCExtr
1711 << ", CloneExtra = " << nClonesExtr / dRecExtr << endl;
1712 cout << " EffAll = " << fStatSeedNRecAll / dMCAll
1713 << ", CloneAll = " << fStatSeedNClonesAll / dRecAll << endl;
1714 cout << " Out = " << fStatSeedNRecOut / dRecTot
1715 << ", Ghost = " << fStatSeedNGhost / dRecTot << endl;
ce565086 1716 }
1717
1718 {
fbb9b71b 1719 cout << "\nSlice Track candidate performance: \n" << endl;
1720 cout << " N tracks : "
1721 << fStatNMCAll / fStatNEvents << " mc all, "
1722 << fStatCandNMCRef / fStatNEvents << " mc ref, "
1723 << fStatCandNRecTot / fStatNEvents << " rec total, "
1724 << fStatCandNRecAll / fStatNEvents << " rec all, "
1725 << fStatCandNClonesAll / fStatNEvents << " clones all, "
1726 << fStatCandNRecRef / fStatNEvents << " rec ref, "
1727 << fStatCandNClonesRef / fStatNEvents << " clones ref, "
1728 << fStatCandNRecOut / fStatNEvents << " out, "
1729 << fStatCandNGhost / fStatNEvents << " ghost" << endl;
1730
1731 int nRecExtr = fStatCandNRecAll - fStatCandNRecRef;
1732 int nMCExtr = fStatNMCAll - fStatNMCRef;
1733 int nClonesExtr = fStatCandNClonesAll - fStatCandNClonesRef;
1734
1735 double dRecTot = ( fStatCandNRecTot > 0 ) ? fStatCandNRecTot : 1;
1736 double dMCAll = ( fStatNMCAll > 0 ) ? fStatNMCAll : 1;
1737 double dMCRef = ( fStatNMCRef > 0 ) ? fStatNMCRef : 1;
1738 double dMCExtr = ( nMCExtr > 0 ) ? nMCExtr : 1;
1739 double dRecAll = ( fStatCandNRecAll + fStatCandNClonesAll > 0 ) ? fStatCandNRecAll + fStatCandNClonesAll : 1;
1740 double dRecRef = ( fStatCandNRecRef + fStatCandNClonesRef > 0 ) ? fStatCandNRecRef + fStatCandNClonesRef : 1;
1741 double dRecExtr = ( nRecExtr + nClonesExtr > 0 ) ? nRecExtr + nClonesExtr : 1;
1742
1743 cout << " EffRef = " << fStatCandNRecRef / dMCRef
1744 << ", CloneRef = " << fStatCandNClonesRef / dRecRef << endl;
1745 cout << " EffExtra = " << nRecExtr / dMCExtr
1746 << ", CloneExtra = " << nClonesExtr / dRecExtr << endl;
1747 cout << " EffAll = " << fStatCandNRecAll / dMCAll
1748 << ", CloneAll = " << fStatCandNClonesAll / dRecAll << endl;
1749 cout << " Out = " << fStatCandNRecOut / dRecTot
1750 << ", Ghost = " << fStatCandNGhost / dRecTot << endl;
ce565086 1751 }
1752
eb30eb49 1753 {
fbb9b71b 1754 cout << "\nSlice tracker performance: \n" << endl;
1755 cout << " N tracks : "
1756 << fStatNMCAll / fStatNEvents << " mc all, "
1757 << fStatNMCRef / fStatNEvents << " mc ref, "
1758 << fStatNRecTot / fStatNEvents << " rec total, "
1759 << fStatNRecAll / fStatNEvents << " rec all, "
1760 << fStatNClonesAll / fStatNEvents << " clones all, "
1761 << fStatNRecRef / fStatNEvents << " rec ref, "
1762 << fStatNClonesRef / fStatNEvents << " clones ref, "
1763 << fStatNRecOut / fStatNEvents << " out, "
1764 << fStatNGhost / fStatNEvents << " ghost" << endl;
1765
1766 int nRecExtr = fStatNRecAll - fStatNRecRef;
1767 int nMCExtr = fStatNMCAll - fStatNMCRef;
1768 int nClonesExtr = fStatNClonesAll - fStatNClonesRef;
1769
1770 double dRecTot = ( fStatNRecTot > 0 ) ? fStatNRecTot : 1;
1771 double dMCAll = ( fStatNMCAll > 0 ) ? fStatNMCAll : 1;
1772 double dMCRef = ( fStatNMCRef > 0 ) ? fStatNMCRef : 1;
1773 double dMCExtr = ( nMCExtr > 0 ) ? nMCExtr : 1;
1774 double dRecAll = ( fStatNRecAll + fStatNClonesAll > 0 ) ? fStatNRecAll + fStatNClonesAll : 1;
1775 double dRecRef = ( fStatNRecRef + fStatNClonesRef > 0 ) ? fStatNRecRef + fStatNClonesRef : 1;
1776 double dRecExtr = ( nRecExtr + nClonesExtr > 0 ) ? nRecExtr + nClonesExtr : 1;
1777
1778 cout << " EffRef = " << fStatNRecRef / dMCRef
1779 << ", CloneRef = " << fStatNClonesRef / dRecRef << endl;
1780 cout << " EffExtra = " << nRecExtr / dMCExtr
1781 << ", CloneExtra = " << nClonesExtr / dRecExtr << endl;
1782 cout << " EffAll = " << fStatNRecAll / dMCAll
1783 << ", CloneAll = " << fStatNClonesAll / dRecAll << endl;
1784 cout << " Out = " << fStatNRecOut / dRecTot
1785 << ", Ghost = " << fStatNGhost / dRecTot << endl;
1786 cout << " Time = " << fTracker->StatTime( 0 ) / fTracker->StatNEvents()*1.e3 << " msec/event " << endl;
1787 cout << " Local timers = "
1788 << fTracker->StatTime( 1 ) / fTracker->StatNEvents()*1.e3 << " "
1789 << fTracker->StatTime( 2 ) / fTracker->StatNEvents()*1.e3 << " "
1790 << fTracker->StatTime( 3 ) / fTracker->StatNEvents()*1.e3 << " "
1791 << fTracker->StatTime( 4 ) / fTracker->StatNEvents()*1.e3 << " "
1792 << fTracker->StatTime( 5 ) / fTracker->StatNEvents()*1.e3 << " "
1793 << fTracker->StatTime( 6 ) / fTracker->StatNEvents()*1.e3 << " "
1794 << fTracker->StatTime( 7 ) / fTracker->StatNEvents()*1.e3 << " "
1795 << fTracker->StatTime( 8 ) / fTracker->StatNEvents()*1.e3 << " "
1796 << " msec/event " << endl;
eb30eb49 1797 }
1798
ce565086 1799
eb30eb49 1800 {
fbb9b71b 1801 cout << "\nGlobal tracker performance for " << fStatNEvents << " events: \n" << endl;
1802 cout << " N tracks : "
1803 << fStatGBNMCAll << " mc all, "
1804 << fStatGBNMCRef << " mc ref, "
1805 << fStatGBNRecTot << " rec total, "
1806 << fStatGBNRecAll << " rec all, "
1807 << fStatGBNClonesAll << " clones all, "
1808 << fStatGBNRecRef << " rec ref, "
1809 << fStatGBNClonesRef << " clones ref, "
1810 << fStatGBNRecOut << " out, "
1811 << fStatGBNGhost << " ghost" << endl;
1812 cout << " N tracks average : "
1813 << fStatGBNMCAll / fStatNEvents << " mc all, "
1814 << fStatGBNMCRef / fStatNEvents << " mc ref, "
1815 << fStatGBNRecTot / fStatNEvents << " rec total, "
1816 << fStatGBNRecAll / fStatNEvents << " rec all, "
1817 << fStatGBNClonesAll / fStatNEvents << " clones all, "
1818 << fStatGBNRecRef / fStatNEvents << " rec ref, "
1819 << fStatGBNClonesRef / fStatNEvents << " clones ref, "
1820 << fStatGBNRecOut / fStatNEvents << " out, "
1821 << fStatGBNGhost / fStatNEvents << " ghost" << endl;
1822
1823 int nRecExtr = fStatGBNRecAll - fStatGBNRecRef;
1824 int nMCExtr = fStatGBNMCAll - fStatGBNMCRef;
1825 int nClonesExtr = fStatGBNClonesAll - fStatGBNClonesRef;
1826
1827 double dRecTot = ( fStatGBNRecTot > 0 ) ? fStatGBNRecTot : 1;
1828 double dMCAll = ( fStatGBNMCAll > 0 ) ? fStatGBNMCAll : 1;
1829 double dMCRef = ( fStatGBNMCRef > 0 ) ? fStatGBNMCRef : 1;
1830 double dMCExtr = ( nMCExtr > 0 ) ? nMCExtr : 1;
1831 double dRecAll = ( fStatGBNRecAll + fStatGBNClonesAll > 0 ) ? fStatGBNRecAll + fStatGBNClonesAll : 1;
1832 double dRecRef = ( fStatGBNRecRef + fStatGBNClonesRef > 0 ) ? fStatGBNRecRef + fStatGBNClonesRef : 1;
1833 double dRecExtr = ( nRecExtr + nClonesExtr > 0 ) ? nRecExtr + nClonesExtr : 1;
1834
1835 cout << " EffRef = " << fStatGBNRecRef / dMCRef
1836 << ", CloneRef = " << fStatGBNClonesRef / dRecRef << endl;
1837 cout << " EffExtra = " << nRecExtr / dMCExtr
1838 << ", CloneExtra = " << nClonesExtr / dRecExtr << endl;
1839 cout << " EffAll = " << fStatGBNRecAll / dMCAll
1840 << ", CloneAll = " << fStatGBNClonesAll / dRecAll << endl;
1841 cout << " Out = " << fStatGBNRecOut / dRecTot
1842 << ", Ghost = " << fStatGBNGhost / dRecTot << endl;
1843 cout << " Time = " << ( fTracker->StatTime( 0 ) + fTracker->StatTime( 9 ) ) / fTracker->StatNEvents()*1.e3 << " msec/event " << endl;
1844 cout << " Local timers: " << endl;
1845 cout << " slice tracker " << fTracker->StatTime( 0 ) / fTracker->StatNEvents()*1.e3 << ": "
1846 << fTracker->StatTime( 1 ) / fTracker->StatNEvents()*1.e3 << " "
1847 << fTracker->StatTime( 2 ) / fTracker->StatNEvents()*1.e3 << " "
1848 << fTracker->StatTime( 3 ) / fTracker->StatNEvents()*1.e3 << " "
1849 << fTracker->StatTime( 4 ) / fTracker->StatNEvents()*1.e3 << " "
1850 << fTracker->StatTime( 5 ) / fTracker->StatNEvents()*1.e3 << "["
1851 << fTracker->StatTime( 6 ) / fTracker->StatNEvents()*1.e3 << "/"
1852 << fTracker->StatTime( 7 ) / fTracker->StatNEvents()*1.e3 << "] "
1853 << fTracker->StatTime( 8 ) / fTracker->StatNEvents()*1.e3
1854 << " msec/event " << endl;
1855 cout << " GB merger " << fTracker->StatTime( 9 ) / fTracker->StatNEvents()*1.e3 << ": "
1856 << fTracker->StatTime( 10 ) / fTracker->StatNEvents()*1.e3 << ", "
1857 << fTracker->StatTime( 11 ) / fTracker->StatNEvents()*1.e3 << ", "
1858 << fTracker->StatTime( 12 ) / fTracker->StatNEvents()*1.e3 << " "
1859 << " msec/event " << endl;
1860
1861 if ( StatFile && StatFile->is_open() ) {
4687b8fc 1862 fstream &out = *StatFile;
1863
1864 //out<<"\nGlobal tracker performance for "<<fStatNEvents<<" events: \n"<<endl;
1865 //out<<" N tracks : "
1866 //<<fStatGBNMCAll/fStatNEvents<<" mc all, "
1867 //<<fStatGBNMCRef/fStatNEvents<<" mc ref, "
1868 // <<fStatGBNRecTot/fStatNEvents<<" rec total, "
1869 // <<fStatGBNRecAll/fStatNEvents<<" rec all, "
1870 // <<fStatGBNClonesAll/fStatNEvents<<" clones all, "
1871 // <<fStatGBNRecRef/fStatNEvents<<" rec ref, "
1872 // <<fStatGBNClonesRef/fStatNEvents<<" clones ref, "
1873 // <<fStatGBNRecOut/fStatNEvents<<" out, "
1874 // <<fStatGBNGhost/fStatNEvents<<" ghost"<<endl;
fbb9b71b 1875 fStatTime += fTracker->SliceTrackerTime();
1876 double timeHz = 0;
1877 if ( fStatTime > 1.e-4 ) timeHz = 1. / fStatTime * fStatNEvents;
1878
1879 out << "<table border>" << endl;
1880 out << "<tr>" << endl;
1881 out << "<td> </td> <td align=center> RefSet </td> <td align=center> AllSet </td> <td align=center> ExtraSet </td>" << endl;
1882 out << "</tr>" << endl;
1883 out << "<tr>" << endl;
1884 out << "<td>Efficiency</td> <td align=center>" << fStatGBNRecRef / dMCRef
1885 << "</td> <td align=center>" << fStatGBNRecAll / dMCAll
1886 << "</td> <td align=center>" << nRecExtr / dMCExtr
1887 << "</td>" << endl;
1888 out << "</tr>" << endl;
1889 out << "<tr> " << endl;
1890 out << "<td>Clone</td> <td align=center>" << fStatGBNClonesRef / dRecRef
1891 << "</td> <td align=center>" << fStatGBNClonesAll / dRecAll
1892 << "</td> <td align=center>" << nClonesExtr / dRecExtr
1893 << "</td>" << endl;
1894 out << "</tr>" << endl;
1895 out << "<tr> " << endl;
1896 out << "<td>Ghost</td> <td colspan=3 align=center>" << fStatGBNGhost / dRecTot
1897 << "</td>" << endl;
1898 out << "</tr>" << endl;
1899 out << "<tr> " << endl;
1900 out << "<td>Time</td> <td colspan=3 align=center>" << timeHz
1901 << " ev/s</td>" << endl;
1902 out << "</tr>" << endl;
1903 out << "<tr> " << endl;
1904 out << "<td>N Events</td> <td colspan=3 align=center>" << fStatNEvents
1905 << "</td>" << endl;
1906 out << "</tr>" << endl;
1907 out << "</table>" << endl;
4687b8fc 1908 }
1909
eb30eb49 1910 }
1911
d54804bf 1912 WriteHistos();
4687b8fc 1913
1914
d54804bf 1915}
eb30eb49 1916
00d07bcd 1917void AliHLTTPCCAPerformance::WriteMCEvent( ostream &out ) const
eb30eb49 1918{
00d07bcd 1919 // write MC information to the file
fbb9b71b 1920 out << fNMCTracks << endl;
1921 for ( int it = 0; it < fNMCTracks; it++ ) {
eb30eb49 1922 AliHLTTPCCAMCTrack &t = fMCTracks[it];
fbb9b71b 1923 out << it << " ";
1924 out << t.PDG() << endl;
1925 for ( int i = 0; i < 7; i++ ) out << t.Par()[i] << " ";
1926 out << endl << " ";
1927 for ( int i = 0; i < 7; i++ ) out << t.TPCPar()[i] << " ";
1928 out << endl << " ";
1929 out << t.P() << " ";
1930 out << t.Pt() << " ";
1931 out << t.NMCPoints() << " ";
1932 out << t.FirstMCPointID() << " ";
1933 out << t.NHits() << " ";
1934 out << t.NReconstructed() << " ";
1935 out << t.Set() << " ";
1936 out << t.NTurns() << endl;
eb30eb49 1937 }
1938
fbb9b71b 1939 out << fNHits << endl;
1940 for ( int ih = 0; ih < fNHits; ih++ ) {
eb30eb49 1941 AliHLTTPCCAHitLabel &l = fHitLabels[ih];
fbb9b71b 1942 out << l.fLab[0] << " " << l.fLab[1] << " " << l.fLab[2] << endl;
eb30eb49 1943 }
1944}
1945
00d07bcd 1946void AliHLTTPCCAPerformance::WriteMCPoints( ostream &out ) const
fbb9b71b 1947{
00d07bcd 1948 // write Mc points to the file
fbb9b71b 1949 out << fNMCPoints << endl;
1950 for ( int ip = 0; ip < fNMCPoints; ip++ ) {
eb30eb49 1951 AliHLTTPCCAMCPoint &p = fMCPoints[ip];
fbb9b71b 1952 out << p.X() << " ";
1953 out << p.Y() << " ";
1954 out << p.Z() << " ";
1955 out << p.Sx() << " ";
1956 out << p.Sy() << " ";
1957 out << p.Sz() << " ";
1958 out << p.Time() << " ";
1959 out << p.ISlice() << " ";
1960 out << p.TrackID() << endl;
eb30eb49 1961 }
1962}
1963
1964void AliHLTTPCCAPerformance::ReadMCEvent( istream &in )
1965{
00d07bcd 1966 // read mc info from the file
eb30eb49 1967 StartEvent();
fbb9b71b 1968 if ( fMCTracks ) delete[] fMCTracks;
eb30eb49 1969 fMCTracks = 0;
1970 fNMCTracks = 0;
fbb9b71b 1971 if ( fHitLabels ) delete[] fHitLabels;
eb30eb49 1972 fHitLabels = 0;
1973 fNHits = 0;
fbb9b71b 1974 if ( fMCPoints ) delete[] fMCPoints;
eb30eb49 1975 fMCPoints = 0;
1976 fNMCPoints = 0;
1977
fbb9b71b 1978 in >> fNMCTracks;
eb30eb49 1979 fMCTracks = new AliHLTTPCCAMCTrack[fNMCTracks];
fbb9b71b 1980 for ( int it = 0; it < fNMCTracks; it++ ) {
eb30eb49 1981 AliHLTTPCCAMCTrack &t = fMCTracks[it];
fbb9b71b 1982 int j;
1983 float f;
1984 in >> j;
1985 in >> j; t.SetPDG( j );
1986 for ( int i = 0; i < 7; i++ ) { in >> f; t.SetPar( i, f );}
1987 for ( int i = 0; i < 7; i++ ) { in >> f; t.SetTPCPar( i, f );}
1988 in >> f; t.SetP( f );
1989 in >> f; t.SetPt( f );
1990 in >> j; t.SetNHits( j );
1991 in >> j; t.SetNMCPoints( j );
1992 in >> j; t.SetFirstMCPointID( j );
1993 in >> j; t.SetNReconstructed( j );
1994 in >> j; t.SetSet( j );
1995 in >> j; t.SetNTurns( j );
eb30eb49 1996 }
fbb9b71b 1997
1998 in >> fNHits;
eb30eb49 1999 fHitLabels = new AliHLTTPCCAHitLabel[fNHits];
fbb9b71b 2000 for ( int ih = 0; ih < fNHits; ih++ ) {
eb30eb49 2001 AliHLTTPCCAHitLabel &l = fHitLabels[ih];
fbb9b71b 2002 in >> l.fLab[0] >> l.fLab[1] >> l.fLab[2];
eb30eb49 2003 }
2004}
2005
2006void AliHLTTPCCAPerformance::ReadMCPoints( istream &in )
2007{
00d07bcd 2008 // read mc points from the file
fbb9b71b 2009 if ( fMCPoints ) delete[] fMCPoints;
eb30eb49 2010 fMCPoints = 0;
2011 fNMCPoints = 0;
fbb9b71b 2012
2013 in >> fNMCPoints;
eb30eb49 2014 fMCPoints = new AliHLTTPCCAMCPoint[fNMCPoints];
fbb9b71b 2015 for ( int ip = 0; ip < fNMCPoints; ip++ ) {
eb30eb49 2016 AliHLTTPCCAMCPoint &p = fMCPoints[ip];
fbb9b71b 2017 float f;
2018 int i;
2019 in >> f;
693d2443 2020 p.SetX( f );
2021 in >> f;
2022 p.SetY( f );
2023 in >> f;
2024 p.SetZ( f );
2025 in >> f;
2026 p.SetSx( f );
2027 in >> f;
2028 p.SetSy( f );
2029 in >> f;
2030 p.SetSz( f );
2031 in >> f;
2032 p.SetTime( f );
2033 in >> i;
2034 p.SetISlice( i );
2035 in >> i;
2036 p.SetTrackID( i );
eb30eb49 2037 }
2038}