]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG1/TRD/AliTRDefficiencyMC.cxx
prepare infrastructure for fixing bug 60872
[u/mrichter/AliRoot.git] / PWG1 / TRD / AliTRDefficiencyMC.cxx
CommitLineData
1ee39b3a 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
7* Permission to use, copy, modify and distribute this software and its *
8* documentation strictly for non-commercial purposes is hereby granted *
9* without fee, provided that the above copyright notice appears in all *
10* copies and that both the copyright notice and this permission notice *
11* appear in the supporting documentation. The authors make no claims *
12* about the suitability of this software for any purpose. It is *
13* provided "as is" without express or implied warranty. *
14**************************************************************************/
15
16/* $Id: AliTRDefficiencyMC.cxx 27496 2008-07-22 08:35:45Z cblume $ */
17
18////////////////////////////////////////////////////////////////////////////
19// //
20// Reconstruction QA //
21// //
22// Authors: //
23// Markus Fasel <M.Fasel@gsi.de> //
24// //
25////////////////////////////////////////////////////////////////////////////
26
27#include <TObjArray.h>
28#include <TClonesArray.h>
770382d9 29#include <TPad.h>
1ee39b3a 30#include <TProfile.h>
31#include <TMath.h>
770382d9 32#include <TDatabasePDG.h>
1ee39b3a 33#include "TTreeStream.h"
34
35#include "AliMagF.h"
36#include "AliPID.h"
770382d9 37#include "AliESDtrack.h"
1ee39b3a 38#include "AliMathBase.h"
39#include "AliTrackReference.h"
40#include "AliAnalysisManager.h"
41
42#include "AliTRDcluster.h"
43#include "AliTRDseedV1.h"
44#include "AliTRDtrackV1.h"
45#include "Cal/AliTRDCalPID.h"
46#include "info/AliTRDtrackInfo.h"
47#include "AliTRDinfoGen.h"
48#include "AliTRDefficiencyMC.h"
49
50ClassImp(AliTRDefficiencyMC)
770382d9 51Float_t AliTRDefficiencyMC::fgPCut = 0.2; //[GeV/c]
52Float_t AliTRDefficiencyMC::fgPhiCut = 50.; //[deg]
53Float_t AliTRDefficiencyMC::fgThtCut = 50.; //[deg]
1ee39b3a 54//_____________________________________________________________________________
55AliTRDefficiencyMC::AliTRDefficiencyMC()
56 :AliTRDrecoTask("EfficiencyMC", "Combined Tracking Efficiency")
57{
58 //
59 // Default constructor
60 //
61}
62
63
64//_____________________________________________________________________________
65void AliTRDefficiencyMC::CreateOutputObjects(){
66 //
67 // Create output objects
68 //
69
70 OpenFile(0, "RECREATE");
71 fContainer = Histos();
72
73}
74
75//_____________________________________________________________________________
76void AliTRDefficiencyMC::Exec(Option_t *){
77 //
78 // Execute the task:
79 //
80 // Loop over TrackInfos
81 // 1st: check if there is a trackTRD
82 // 2nd: put conditions on the track:
83 // - check if we did not register it before
84 // - check if we have Track References for the track
85 // 3rd: Register track:
86 // - accepted if both conditions are fulfilled
87 // - contamination if at least one condition is not fulfilled
88 // 4th: check Monte-Carlo Track wheter findable or not if there is no TRD track in this track info
89 // 5th: register MC track as rejected if findable and not jet registered
90 // Match the registers accepted and rejected and clean register rejected
91 // Fill the histograms
92 //
93 const Int_t kArraySize = 10000; // Store indices of track references in an array
770382d9 94 Int_t indexAccept[kArraySize],
95 indexReject[kArraySize],
96 indexContam[kArraySize];
97 memset(indexAccept, 0, sizeof(Int_t) * kArraySize);
98 memset(indexReject, 0, sizeof(Int_t) * kArraySize);
99 memset(indexContam, 0, sizeof(Int_t) * kArraySize);
100 Int_t naccept(0),
101 nreject(0),
102 nfindnt(0),
103 nkink(0),
104 ncontam(0);
1ee39b3a 105 Bool_t isContamination = kFALSE;
106
107 Int_t nTrackInfos = fTracks->GetEntriesFast();
770382d9 108 AliDebug(2, Form(" CANDIDATE TRACKS[%d]", nTrackInfos));
109
110 AliTRDtrackV1 *trackTRD(NULL);
111 AliTRDtrackInfo *trkInf(NULL);
1ee39b3a 112 for(Int_t itinf = 0; itinf < nTrackInfos; itinf++){
113 trkInf = dynamic_cast<AliTRDtrackInfo *>(fTracks->UncheckedAt(itinf));
114 if(!trkInf) continue;
770382d9 115
1ee39b3a 116 if(trkInf->GetTrack() || trkInf->GetNumberOfClustersRefit()){
770382d9 117 isContamination = (IsRegistered(trkInf,indexAccept,naccept)>=0);
1ee39b3a 118 if(!trkInf->GetNTrackRefs()){
119 // We reject the track since the Monte Carlo Information is missing
770382d9 120 AliDebug(2, Form("MC(Track Reference) missing @ label[%d]", trkInf->GetLabel()));
1ee39b3a 121 isContamination = kTRUE;
122 // Debugging
770382d9 123 if(trackTRD && DebugLevel()>5) FillStreamTrackWOMC(trkInf);
124 }
1ee39b3a 125 if(isContamination){
126 // reject kink (we count these only once)
770382d9 127 if(trkInf->GetKinkIndex()){
128 AliDebug(4, Form(" track @ idx[%d] MC[%d] is kink.", itinf, trkInf->GetLabel()));
129 nkink++;
130 continue;
131 }
1ee39b3a 132 // Register track as contamination
770382d9 133 AliDebug(4, Form(" track @ idx[%d] MC[%d] is contamination.", itinf, trkInf->GetLabel()));
134 indexContam[ncontam++]=itinf;
1ee39b3a 135 continue;
136 }
137 // Accept track
770382d9 138 AliDebug(4, Form(" track @ idx[%d] is ACCEPTED.", itinf));
1ee39b3a 139 // Register track as accepted
770382d9 140 indexAccept[naccept++] = itinf;
1ee39b3a 141 }else{
770382d9 142 Int_t code(0);
143 if((code=IsFindableNot(trkInf))){
144 AliDebug(4, Form(" track @ idx[%d] MC[%d] not findable [%d].", itinf, trkInf->GetLabel(), code));
145 nfindnt++;
146 } else {
1ee39b3a 147 // register track as rejected if not already registered there
148 // Attention:
149 // These track infos are not!!! registered as contamination
770382d9 150 if(IsRegistered(trkInf, indexReject, nreject)<0){
151 AliDebug(4, Form(" track @ idx[%d] MC[%d] is missed.", itinf, trkInf->GetLabel()));
152 indexReject[nreject++] = itinf;
153 }
1ee39b3a 154 }
155 }
156 }
770382d9 157 AliDebug(2, Form("TRACKS STATISTICS naccept[%d] ncontam[%d] nkink[%d] nmissed[%d] nfindnt[%d] ALL[%d] LOST[%d]", naccept, ncontam, nkink, nreject, nfindnt, naccept+ncontam+nkink, nTrackInfos-(naccept+nreject+ncontam+nkink+nfindnt)));
158
1ee39b3a 159 // we have to check if the rejected tracks are registered as found
160 // a possible source for this:
161 // first the track is not found by the barrel tracking but it is later found
162 // by the stand alone tracking, then two track info objects with the same
163 // label would be created
164 // Attention:
165 // these tracks are not! registered as contamination
770382d9 166 Int_t tmprejected[kArraySize]; Int_t nrej = nreject;
167 memcpy(tmprejected, indexReject, sizeof(Int_t) * nreject);
168 nreject = 0;
1ee39b3a 169 for(Int_t irej = 0; irej < nrej; irej++){
170 trkInf = dynamic_cast<AliTRDtrackInfo *>(fTracks->At(tmprejected[irej]));
770382d9 171 Int_t idx(-1);
172 if((idx = IsRegistered(trkInf,indexAccept,naccept))<0){
173 indexReject[nreject++] = tmprejected[irej];
174 }else{
175 //printf("tracks @ accept[%d] missed[%d] are the same.\n", indexAccept[idx], tmprejected[irej]);
176 }
1ee39b3a 177 }
770382d9 178
1ee39b3a 179 // Fill Histograms
770382d9 180 FillHistograms(naccept, &indexAccept[0], kAccept);
181 FillHistograms(nreject, &indexReject[0], kMiss);
182 FillHistograms(ncontam, &indexContam[0], kFake);
183
184 Int_t nall(naccept + nreject);
185 AliInfo(Form("%3d Tracks: MC[%3d] TRD[%3d | %5.2f%%] Fake[%3d | %5.2f%%]",
186 (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(),
187 nall,
188 naccept,
189 (nall ? 1.E2*Float_t(naccept)/Float_t(nall) : 0.),
190 ncontam,
191 (nall ? 1.E2*Float_t(ncontam)/Float_t(nall) : 0.)));
1ee39b3a 192
193 PostData(0, fContainer);
194}
195
196
197//_____________________________________________________________________________
198Bool_t AliTRDefficiencyMC::PostProcess()
199{
200 //
201 // Post Process
202 //
203 // Change the histogram style
204 // For species histograms apply the colors connected with the given particle species
770382d9 205 fNRefFigures = 8;
1ee39b3a 206 return kTRUE;
207}
208
209//_____________________________________________________________________________
210Bool_t AliTRDefficiencyMC::GetRefFigure(Int_t ifig){
211 //
212 // Plot the histograms
213 //
214 if(ifig >= fNRefFigures) return kFALSE;
770382d9 215 if(!gPad) return kFALSE;
216 gPad->SetLogx(kTRUE);
1ee39b3a 217 if(ifig < 2){
218 (dynamic_cast<TH1 *>(fContainer->At(ifig)))->Draw("e1");
219 return kTRUE;
220 }
221 switch(ifig){
222 case 2:
223 (dynamic_cast<TH1 *>(fContainer->At(kEfficiencySpeciesHistogram)))->Draw("e1");
770382d9 224 (dynamic_cast<TH1 *>(fContainer->At(kEfficiencySpeciesHistogram+1)))->Draw("e1same");
1ee39b3a 225 break;
226 case 3:
770382d9 227 (dynamic_cast<TH1 *>(fContainer->At(kEfficiencySpeciesHistogram+2)))->Draw("e1");
228 (dynamic_cast<TH1 *>(fContainer->At(kEfficiencySpeciesHistogram+3)))->Draw("e1same");
1ee39b3a 229 break;
230 case 4:
770382d9 231 (dynamic_cast<TH1 *>(fContainer->At(kEfficiencySpeciesHistogram+4)))->Draw("e1");
232 (dynamic_cast<TH1 *>(fContainer->At(kEfficiencySpeciesHistogram+5)))->Draw("e1same");
1ee39b3a 233 break;
234 case 5:
770382d9 235 (dynamic_cast<TH1 *>(fContainer->At(kEfficiencySpeciesHistogram+6)))->Draw("e1");
236 (dynamic_cast<TH1 *>(fContainer->At(kEfficiencySpeciesHistogram+7)))->Draw("e1same");
237 break;
238 case 6:
239 (dynamic_cast<TH1 *>(fContainer->At(kEfficiencySpeciesHistogram+8)))->Draw("e1");
240 (dynamic_cast<TH1 *>(fContainer->At(kEfficiencySpeciesHistogram+9)))->Draw("e1same");
241 break;
242 case 7:
243 (dynamic_cast<TH1 *>(fContainer->At(kEfficiencySpeciesHistogram+10)))->Draw("e1");
244 (dynamic_cast<TH1 *>(fContainer->At(kEfficiencySpeciesHistogram+11)))->Draw("e1same");
245 break;
246 case 8:
247 (dynamic_cast<TH1 *>(fContainer->At(kEfficiencySpeciesHistogram+12)))->Draw("e1");
248 (dynamic_cast<TH1 *>(fContainer->At(kEfficiencySpeciesHistogram+13)))->Draw("e1same");
1ee39b3a 249 break;
250 }
251 return kTRUE;
252}
253
254//_____________________________________________________________________________
255TObjArray *AliTRDefficiencyMC::Histos(){
256 //
257 // Create the histograms
258 //
1ee39b3a 259
260 if(fContainer) return fContainer;
770382d9 261 const Int_t nbins = AliTRDCalPID::kNMom;
262 Float_t xbins[nbins+1] = {fgPCut, .7, .9, 1.3, 1.7, 2.4, 3.5, 4.5, 5.5, 7., 9., 11.};
263 const Int_t marker[2][AliPID::kSPECIES+1] = {
264 {20, 21, 22, 23, 29, 2},
265 {24, 25, 26, 27, 30, 5}
266 };
267
268 fContainer = new TObjArray();fContainer->Expand(14);
269
270 TH1 *h(NULL);
271 fContainer->AddAt(h=new TProfile("hEff", "Tracking Efficiency ALL", nbins, xbins), kEfficiencyHistogram);
272 h->SetMarkerStyle(22);
273 h->SetMarkerColor(kBlue);
274 h->GetXaxis()->SetTitle("p [GeV/c]");
275 h->GetXaxis()->SetMoreLogLabels();
276 h->GetYaxis()->SetTitle("Efficiency");
277 h->GetYaxis()->SetRangeUser(0.2, 1.1);
278 fContainer->AddAt(h=new TProfile("hFake", "Fake Tracks", nbins, xbins), kContaminationHistogram);
279 h->SetMarkerStyle(22);
280 h->SetMarkerColor(kBlue);
281 h->GetXaxis()->SetTitle("p [GeV/c]");
282 h->GetXaxis()->SetMoreLogLabels();
283 h->GetYaxis()->SetTitle("Contamination");
284
285 Char_t sign[]={'+', '-'};
286 for(Int_t isign = 0; isign < 2; isign++){
287 for(Int_t ispec = 0; ispec < AliPID::kSPECIES; ispec++){
288 fContainer->AddAt(h=new TProfile(
289 Form("hEff_%s%c", AliPID::ParticleShortName(ispec), sign[isign]),
290 Form("Tracking Efficiency for %s%c", AliPID::ParticleName(ispec), sign[isign]), nbins, xbins),
291 kEfficiencySpeciesHistogram+ispec*2+isign);
292 h->SetMarkerStyle(marker[isign][ispec]);
293 h->SetLineColor(AliTRDCalPID::GetPartColor(ispec));
294 h->SetMarkerColor(kBlack);
295 h->GetXaxis()->SetTitle("p [GeV/c]");
296 h->GetXaxis()->SetMoreLogLabels();
297 h->GetYaxis()->SetTitle("Efficiency");
298 h->GetYaxis()->SetRangeUser(0.2, 1.1);
299 }
300
301 fContainer->AddAt(h=new TProfile(Form("hEff_PID%c", sign[isign]), Form("Tracking Efficiency no PID %c", sign[isign]), nbins, xbins), kEfficiencySpeciesHistogram+AliPID::kSPECIES*2+isign);
302 h->SetMarkerStyle(marker[isign][AliPID::kSPECIES]);
303 h->SetMarkerColor(kBlack);h->SetLineColor(kBlack);
304 h->GetXaxis()->SetTitle("p [GeV/c]");
305 h->GetXaxis()->SetMoreLogLabels();
306 h->GetYaxis()->SetTitle("Efficiency");
307 h->GetYaxis()->SetRangeUser(0.2, 1.1);
308 }
1ee39b3a 309 return fContainer;
310}
311
312//_____________________________________________________________________________
770382d9 313Int_t AliTRDefficiencyMC::IsFindableNot(AliTRDtrackInfo * const trkInf){
1ee39b3a 314 //
315 // Apply Cuts on the Monte Carlo track references
316 // return whether track is findable or not
317 //
1ee39b3a 318
770382d9 319
320 const Float_t chmbHght = AliTRDgeometry::CamHght()+AliTRDgeometry::CdrHght();
321 const Float_t eps(1.E-3);
322 Int_t ntr(trkInf->GetNTrackRefs());
323
324 AliDebug(10, Form(" CANDIDATE TrackRefs[%d]", ntr));
1ee39b3a 325 // Check if track is findable
770382d9 326 Double_t mom(0.), phi(0.), tht(0.);
1ee39b3a 327 Float_t xmin = 10000.0, xmax = 0.0;
328 Float_t ymin = 0.0, ymax = 0.0;
329 Float_t zmin = 0.0, zmax = 0.0;
330 Float_t lastx = 0.0, x = 0.0;
770382d9 331 Int_t nLayers(0), ntrTRD(0);
1ee39b3a 332 Int_t sector[20];
770382d9 333 AliTrackReference *trackRef(NULL);
334 for(Int_t itr(0); itr<ntr; itr++){
335 if(!(trackRef = trkInf->GetTrackRef(itr))) continue;
1ee39b3a 336 x = trackRef->LocalX();
1ee39b3a 337 // Be Sure that we are inside TRD
338 if(x < AliTRDinfoGen::GetTPCx() || x > AliTRDinfoGen::GetTOFx()) continue;
770382d9 339 sector[ntrTRD] = Int_t(trackRef->Alpha()/AliTRDgeometry::GetAlpha());
340 AliDebug(10, Form(" [%2d] x[%7.2f] y[%7.2f] z[%7.2f] Sec[%2d]", itr, trackRef->LocalX(), trackRef->LocalY(), trackRef->Z(), sector[ntrTRD]));
1ee39b3a 341 if(x < xmin){
342 xmin = trackRef->LocalX();
343 ymin = trackRef->LocalY();
344 zmin = trackRef->Z();
770382d9 345 mom = trackRef->P();
1ee39b3a 346 } else if(x > xmax){
347 xmax = trackRef->LocalX();
348 ymax = trackRef->LocalY();
349 zmax = trackRef->Z();
350 }
351 if(itr > 0){
352 Float_t dist = TMath::Abs(x - lastx);
770382d9 353 if(TMath::Abs(dist - chmbHght) < eps && sector[ntrTRD]==sector[0]){
354 AliDebug(10, Form(" dx = %7.2f", dist));
355 nLayers++;
356 }
1ee39b3a 357 }
358 lastx = x;
770382d9 359 ntrTRD++; if(ntrTRD>=20) break;
360 }
361 Double_t dx(xmax - xmin);
362 if(TMath::Abs(dx)<eps) return kNoChmb;
363
364 phi = (ymax -ymin)/dx;
365 tht = (zmax -zmin)/dx;
366 phi=TMath::ATan(phi)*TMath::RadToDeg();
367 tht=TMath::ATan(tht)*TMath::RadToDeg();
368 Bool_t primary = trkInf->IsPrimary();
369 const AliTRDtrackInfo::AliESDinfo *esd(trkInf->GetESDinfo());
370 AliDebug(10, Form(" p=%6.3f[GeV/c] phi=%6.2f[deg] theta=%6.2f[deg] nLy[%d]",
371 mom, phi, tht, nLayers));
372 if(DebugLevel()){
373 (*DebugStream()) << "IsFindable"
374 << "P=" << mom
375 << "Phi=" << phi
376 << "Tht=" << tht
377 << "Ntr=" << ntrTRD
378 << "NLy=" << nLayers
379 << "Primary=" << primary
380 << "\n";
1ee39b3a 381 }
382
383 // Apply cuts
770382d9 384 if(!nLayers) return kNoChmb;
385 if(xmax < xmin) return kCurved;
386 if(mom < fgPCut) return kPCut;
387
388
389 if(TMath::Abs(phi) > fgPhiCut) return kPhiCut;
390 if(TMath::Abs(tht) > fgThtCut) return kThtCut;
391
392 if(nLayers < 4){
393 if(!esd)return kLayer;
394 if(!(esd->GetStatus() & AliESDtrack::kTPCout)) return kLayer;
1ee39b3a 395 }
770382d9 396
397 //if(!trkInf->IsPrimary()) {failCode=kPrimary; return kFALSE;}
398
399 return kFindable;
1ee39b3a 400}
401
402//_____________________________________________________________________________
770382d9 403void AliTRDefficiencyMC::FillHistograms(Int_t nTracks, Int_t *indices, ETRDefficiencyMCstatus mode){
1ee39b3a 404 //
405 // Fill Histograms in three different modes:
406 // 1st tracks which are found and accepted
407 // 2nd tracks which are not found and not already counted
408 // 3rd contaminating tracks: either double counts (kinks!) or tracks with no MC hit inside TRD
409 //
770382d9 410
411 TDatabasePDG *dbPDG(TDatabasePDG::Instance());
412 Double_t trkmom(0.); // the track momentum
413 Int_t trkpdg(-1); // particle PDG code
414 AliTRDtrackInfo *trkInf(NULL);
1ee39b3a 415 for(Int_t itk = 0; itk < nTracks; itk++){
416 trkInf = dynamic_cast<AliTRDtrackInfo *>(fTracks->At(indices[itk]));
1ee39b3a 417 if(trkInf->GetNTrackRefs()){
418 // use Monte-Carlo Information for Momentum and PID
419 trkmom = trkInf->GetTrackRef(0)->P();
770382d9 420 trkpdg = trkInf->GetPDG();
1ee39b3a 421 }else{
422 // Use TPC Momentum
423 trkmom = trkInf->GetTrack()->P();
424 }
770382d9 425
426 const Char_t *cmode(NULL);
1ee39b3a 427 switch(mode){
770382d9 428 case kAccept:
1ee39b3a 429 (dynamic_cast<TProfile *>(fContainer->At(kEfficiencyHistogram)))->Fill(trkmom, 1);
430 (dynamic_cast<TProfile *>(fContainer->At(kContaminationHistogram)))->Fill(trkmom, 0);
770382d9 431 cmode="ACCEPT";
1ee39b3a 432 break;
770382d9 433 case kMiss:
1ee39b3a 434 (dynamic_cast<TProfile *>(fContainer->At(kEfficiencyHistogram)))->Fill(trkmom, 0);
435 (dynamic_cast<TProfile *>(fContainer->At(kContaminationHistogram)))->Fill(trkmom, 0);
770382d9 436 cmode="MISS";
1ee39b3a 437 break;
770382d9 438 case kFake:
1ee39b3a 439 (dynamic_cast<TProfile *>(fContainer->At(kContaminationHistogram)))->Fill(trkmom, 1);
770382d9 440 cmode="FAKE";
1ee39b3a 441 break;
442 }
770382d9 443 AliDebug(3, Form(" track[%d] MC[%d] Mode[%s]", indices[itk], trkInf->GetLabel(), cmode));
444
1ee39b3a 445 // Fill species histogram
770382d9 446 Int_t idxSpec = AliTRDpidUtil::Pdg2Pid(TMath::Abs(trkpdg));
447 Int_t sign = dbPDG->GetParticle(trkpdg)->Charge() > 0. ? 1 : 0;
448 //printf("[%d]%s pdg[%d] sign[%d]\n", idxSpec, AliPID::ParticleName(idxSpec), trkpdg, sign);
449 if(idxSpec < 0) idxSpec = AliPID::kSPECIES;
450 (dynamic_cast<TProfile *>(fContainer->At(kEfficiencySpeciesHistogram + idxSpec*2+sign)))->Fill(trkmom, mode==kAccept?1:0);
1ee39b3a 451 }
452}
453
454//_____________________________________________________________________________
455void AliTRDefficiencyMC::FillStreamTrackWOMC(AliTRDtrackInfo * const trkInf){
456 // fill debug stream
457 // we want to know:
458 // 1. The event number
459 // 2. The track label
460 // 3. The TRD track label
461 // 4. The frequency of the TRD Label
462 // 5. Momentum from TPC (NO STAND ALONE TRACK)
463 // 6. TPC Phi angle
464 // 7. the TRD track
465 // 8. Monte Carlo PID
466 // 9. We check the Labels of the TRD track according to them we search the maching Monte-Carlo track.
467 // From the matching Monte-Carlo track we store trackRefs, phi and momentum
468 // 10. We may also want to keep the kink index
469 Double_t mom = trkInf->GetESDinfo()->GetOuterParam()->P();
470 Int_t event = (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry();
471 Int_t label = trkInf->GetLabel();
472 Int_t kinkIndex = trkInf->GetKinkIndex();
473 Int_t pdg = trkInf->GetPDG();
474 Double_t phiTPC = trkInf->GetESDinfo()->GetOuterParam()->Phi();
475 Int_t labelsTRD[180]; // Container for the cluster labels
476 Int_t sortlabels[360]; // Cluster Labels sorted according their occurancy
770382d9 477 AliTRDseedV1 *tracklet(NULL);
478 AliTRDcluster *c(NULL);
479 Int_t nclusters(0);
1ee39b3a 480 AliTRDtrackV1 *trackTRD = trkInf->GetTrack();
481 for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++){
482 tracklet = trackTRD->GetTracklet(il);
483 if(!tracklet) continue;
484 tracklet->ResetClusterIter();
770382d9 485 c = NULL;
1ee39b3a 486 while((c = tracklet->NextCluster())) labelsTRD[nclusters++] = c->GetLabel(0);
487 }
488 // Determine Label and Frequency
489 AliMathBase::Freq(nclusters, const_cast<const Int_t *>(&labelsTRD[0]), &sortlabels[0], kTRUE);
490 Int_t labelTRD = sortlabels[0];
491 Int_t freqTRD = sortlabels[1];
492 // find the track info object matching to the TRD track
493 AliTRDtrackInfo *realtrack = 0;
494 TObjArrayIter rtiter(fTracks);
495 while((realtrack = (AliTRDtrackInfo *)rtiter())){
496 if(realtrack->GetLabel() != labelTRD) continue;
497 break;
498 }
499 TClonesArray trackRefs("AliTrackReference");
500 Int_t realPdg = -1;
501 Double_t realP = 0.;
502 Double_t realPhi = 0.;
503 if(realtrack){
504 // pack the track references into the trackRefsContainer
505 for(Int_t iref = 0; iref < realtrack->GetNTrackRefs(); iref++){
506 new(trackRefs[iref])AliTrackReference(*(realtrack->GetTrackRef(iref)));
507 }
508 realPdg = realtrack->GetPDG();
509 if(realtrack->GetNTrackRefs()){
510 realP = realtrack->GetTrackRef(0)->P();
511 realPhi = realtrack->GetTrackRef(0)->Phi();
512 }
513 }
770382d9 514 (*DebugStream()) << "EffMCfake"
1ee39b3a 515 << "Event=" << event
516 << "Label=" << label
517 << "labelTRD=" << labelTRD
518 << "FreqTRDlabel=" << freqTRD
519 << "TPCp=" << mom
520 << "phiTPC=" << phiTPC
521 << "trackTRD=" << trackTRD
522 << "PDG=" << pdg
523 << "TrackRefs=" << &trackRefs
524 << "RealPDG=" << realPdg
525 << "RealP=" << realP
526 << "RealPhi" << realPhi
527 << "KinkIndex=" << kinkIndex
528 << "\n";
529}
530
531//_____________________________________________________________________________
770382d9 532Int_t AliTRDefficiencyMC::IsRegistered(AliTRDtrackInfo * const trkInf, Int_t *indices, Int_t nTracks){
1ee39b3a 533 //
534 // Checks if track is registered in a given mode
535 //
770382d9 536
537 Int_t label(trkInf->GetLabel());
538 for(Int_t il(nTracks); il--;){
539 if((dynamic_cast<AliTRDtrackInfo *>(fTracks->At(indices[il])))->GetLabel() == label) return il;
1ee39b3a 540 }
770382d9 541 return -1;
1ee39b3a 542}
543