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