From e73baf29c8f65fa4225eae19b31d8bf01ad64f84 Mon Sep 17 00:00:00 2001 From: abercuci Date: Wed, 14 Mar 2012 13:02:43 +0000 Subject: [PATCH] extend CookLabel for performance studies --- TRD/AliTRDtrackV1.cxx | 83 +++++++++++++++++++++++-------------------- TRD/AliTRDtrackV1.h | 2 +- 2 files changed, 46 insertions(+), 39 deletions(-) diff --git a/TRD/AliTRDtrackV1.cxx b/TRD/AliTRDtrackV1.cxx index 13481814c0d..a19939a2e29 100644 --- a/TRD/AliTRDtrackV1.cxx +++ b/TRD/AliTRDtrackV1.cxx @@ -283,55 +283,62 @@ void AliTRDtrackV1::Copy(TObject &t) const } //_______________________________________________________________ -Bool_t AliTRDtrackV1::CookLabel(Float_t wrong) +Int_t AliTRDtrackV1::CookLabel(Float_t wrong, Int_t *labs, Float_t *freq) { - // set MC label for this track - if(!GetNumberOfClusters()) return kFALSE; +// Set MC label for this track +// On demand i.e. if arrays "labs" and "freq" are allocated by user returns : +// nlabs = the no of distinct labels +// labs = array of distinct labels in decreasing order of frequency +// freq = frequency of each label in decreasing order - Int_t s[kMAXCLUSTERSPERTRACK][2]; + Int_t ncl(0); + if(!(ncl = GetNumberOfClusters())) return 0; + + Int_t s[2][kMAXCLUSTERSPERTRACK]; for (Int_t i = 0; i < kMAXCLUSTERSPERTRACK; i++) { - s[i][0] = -1; - s[i][1] = 0; + s[0][i] = -1; + s[1][i] = 0; } - - Bool_t labelAdded; - Int_t label; - AliTRDcluster *c = NULL; - for (Int_t ip = 0; ip < kNplane; ip++) { + + Int_t label(-123456789), nlabels(0); + AliTRDcluster *c(NULL); + for (Int_t ip(0); ip < AliTRDgeometry::kNlayer; ip++) { if(fTrackletIndex[ip]<0 || !fTracklet[ip]) continue; - for (Int_t ic = 0; ic < AliTRDseedV1::kNclusters; ic++) { + for (Int_t ic(0); ic < AliTRDseedV1::kNclusters; ic++) { if(!(c = fTracklet[ip]->GetClusters(ic))) continue; - for (Int_t k = 0; k < 3; k++) { - label = c->GetLabel(k); - labelAdded = kFALSE; - Int_t j = 0; - if (label >= 0) { - while ((!labelAdded) && (j < kMAXCLUSTERSPERTRACK)) { - if ((s[j][0] == label) || - (s[j][1] == 0)) { - s[j][0] = label; - s[j][1]++; - labelAdded = kTRUE; - } - j++; - } + for (Int_t k(0); k < 3; k++) { + if ((label = c->GetLabel(k)) < 0) continue; + Int_t j(0); + while(j < kMAXCLUSTERSPERTRACK){ + if(s[0][j]!=label && s[1][j]!=0){j++; continue;} + if(!s[1][j]) nlabels++; + s[0][j] = label; s[1][j]++; + break; } } } } - - Int_t max = 0; - label = -123456789; - for (Int_t i = 0; i < kMAXCLUSTERSPERTRACK; i++) { - if (s[i][1] <= max) continue; - max = s[i][1]; - label = s[i][0]; + //printf(" Found %4d labels\n", nlabels); + Float_t prob(1.); + if(!nlabels){ + AliError(Form("No MC labels found for track %d.", fESDid)); + return 0; + } else if(nlabels==1) { + label = s[0][0]; + if(labs && freq){labs[0]=label; freq[0]=1.;} + } else { + Int_t idx[kMAXCLUSTERSPERTRACK]; + TMath::Sort(nlabels, s[1], idx); + label = s[0][idx[0]]; prob = s[1][idx[0]]/Float_t(ncl); + if(labs && freq){ + for (Int_t i(0); i wrong) label = -label; - - SetLabel(label); - - return kTRUE; + SetLabel((1.-prob > wrong)?-label:label); + return nlabels; } //_______________________________________________________________ diff --git a/TRD/AliTRDtrackV1.h b/TRD/AliTRDtrackV1.h index 88db8c3ddce..4f2b1548071 100644 --- a/TRD/AliTRDtrackV1.h +++ b/TRD/AliTRDtrackV1.h @@ -76,7 +76,7 @@ public: virtual void Copy(TObject &ref) const; Bool_t CookPID(); - Bool_t CookLabel(Float_t wrong); + Int_t CookLabel(Float_t wrong, Int_t *labs=NULL, Float_t *freq=NULL); AliTRDtrackV1* GetBackupTrack() const {return fBackupTrack;} Double_t GetBudget(Int_t i) const { return fBudget[i];} AliTRDcluster* GetCluster(Int_t id); -- 2.43.0