1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /* $Id: AliTRDefficiency.cxx 27496 2008-07-22 08:35:45Z cblume $ */
18 ////////////////////////////////////////////////////////////////////////////
20 // Reconstruction QA //
23 // Markus Fasel <M.Fasel@gsi.de> //
25 ////////////////////////////////////////////////////////////////////////////
27 #include <TClonesArray.h>
28 #include <TObjArray.h>
32 #include "TTreeStream.h"
35 #include "AliESDtrack.h"
36 #include "AliTrackReference.h"
37 #include "AliExternalTrackParam.h"
38 #include "AliTracker.h"
39 #include "AliAnalysisManager.h"
41 #include "Cal/AliTRDCalPID.h"
42 #include "AliTRDefficiency.h"
43 #include "info/AliTRDtrackInfo.h"
45 ClassImp(AliTRDefficiency)
47 //____________________________________________________________________
48 AliTRDefficiency::AliTRDefficiency()
53 // Default constructor
55 SetNameTitle("TRDefficiency", "TRD barrel tracking efficiency checker");
58 //____________________________________________________________________
59 AliTRDefficiency::AliTRDefficiency(char* name)
60 :AliTRDrecoTask(name, "TRD barrel tracking efficiency checker")
64 // Default constructor
68 //____________________________________________________________________
69 AliTRDefficiency::~AliTRDefficiency()
78 //____________________________________________________________________
79 void AliTRDefficiency::UserCreateOutputObjects()
82 // Create output objects
85 OpenFile(1, "RECREATE");
86 const Int_t nbins = AliTRDCalPID::kNMom;
87 Float_t xbins[nbins+1] = {.5, .7, .9, 1.3, 1.7, 2.4, 3.5, 4.5, 5.5, 7., 9., 11.};
90 fContainer = new TObjArray();
91 for(Int_t is=0; is<AliPID::kSPECIES; is++){
92 fContainer->Add(h = new TProfile(Form("h%s", AliTRDCalPID::GetPartSymb(is)), AliPID::ParticleShortName(is), nbins, xbins));
93 h->SetLineColor(AliTRDCalPID::GetPartColor(is));
94 h->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
95 h->SetMarkerStyle(24);
97 fContainer->Add(h = new TProfile("h", "", nbins, xbins));
101 //____________________________________________________________________
102 void AliTRDefficiency::UserExec(Option_t *)
108 Int_t labelsacc[10000];
109 memset(labelsacc, 0, sizeof(Int_t) * 10000);
112 fMissed = new TClonesArray("AliTRDtrackInfo", 10);
117 Int_t selection[10000], nselect = 0;
118 ULong_t status; Int_t pidx;
119 Int_t nTRD = 0, nTPC = 0, nMiss = 0;
120 AliTRDtrackInfo *track = NULL;
121 AliTrackReference *ref = NULL;
122 AliExternalTrackParam *esd = NULL;
123 for(Int_t itrk=0; itrk<fTracks->GetEntriesFast(); itrk++){
124 track = (AliTRDtrackInfo*)fTracks->UncheckedAt(itrk);
126 if(!track->HasESDtrack()) continue;
127 status = track->GetStatus();
129 // missing TPC propagation - interesting for SA
130 if(!(status&AliESDtrack::kTPCout)) continue;
133 if(HasMCdata() && track->GetNTrackRefs() <= 1) continue;
136 selection[nselect++]=itrk;
137 ref = track->GetTrackRef(0);
138 esd = track->GetESDinfo()->GetOuterParam();
139 mom = ref ? ref->P(): esd->P();
140 pidx = AliTRDCalPID::GetPartIndex(track->GetPDG());
141 pidx = TMath::Max(pidx, 0);
143 //Int_t n = track->GetNumberOfClusters();
144 // where are this tracklets ???
145 //if(ncls0 > ncls1) printf("%3d ESD[%3d] TRD[%3d|%3d]\n", itrk, ncls0, ncls1, n);
146 if(track->GetNumberOfClustersRefit()){
147 ((TProfile*)fContainer->At(pidx))->Fill(mom, 1.);
148 labelsacc[nTRD] = track->GetLabel();
156 Int_t iref = 1; Bool_t found = kFALSE;
157 while((ref = track->GetTrackRef(iref))){
158 xmed = .5*(ref->LocalX() + track->GetTrackRef(iref-1)->LocalX());
159 xleng= (ref->LocalX() - track->GetTrackRef(iref-1)->LocalX());
160 if(TMath::Abs(xmed - 298.5) < .5 &&
161 TMath::Abs(xleng - 3.7) < .1){
169 // track missing first layer. Maybe interesting for SA.
173 new ((*fMissed)[nMiss]) AliTRDtrackInfo(*track);
176 AliDebug(2, Form("%3d Tracks: ESD[%3d] TPC[%3d] TRD[%3d | %5.2f%%] Off[%d]", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), fTracks->GetEntriesFast(), nTPC, nTRD, nTPC ? 1.E2*nTRD/float(nTPC) : 0., fMissed->GetEntriesFast()));
179 // Find double tracks
180 Float_t threshold = 10.;
181 AliTrackReference *refMiss = NULL;
182 AliExternalTrackParam *op = NULL;
183 AliTRDtrackInfo *tt = NULL;
184 for(Int_t imiss=0; imiss<nMiss; imiss++){
185 //printf("Searching missing %d ...\n", imiss);
187 // get outer param of missed
188 tt = (AliTRDtrackInfo*)fMissed->UncheckedAt(imiss);
189 op = tt->GetESDinfo()->GetOuterParam();
190 Double_t alpha = op->GetAlpha(), cosa = TMath::Cos(alpha), sina = TMath::Sin(alpha);
192 Double_t xyz[3], x0, y0, z0, x, y, z, dx, dy, dz, d;
194 Bool_t bFOUND = kFALSE;
195 for(Int_t iselect=0; iselect<nselect; iselect++){
196 track = (AliTRDtrackInfo*)fTracks->UncheckedAt(selection[iselect]);
198 // check first MC ... if available
200 for(Int_t iref=0; iref<track->GetNTrackRefs(); iref++){
201 if(!(ref = track->GetTrackRef(iref))) continue;
202 if((refMiss = tt->GetTrackRef(iref))){
203 dy = ref->LocalY() - refMiss->LocalY();
204 dz = ref->Z() - refMiss->Z();
206 // compare missOP with refTrackRef in LTC
208 op->GetYAt(x0, AliTracker::GetBz(), y0);
209 op->GetZAt(x0, AliTracker::GetBz(), z0);
210 dy = y0 - ref->LocalY();
213 d += (dy*dy + dz*dz);
215 //printf("\td[%d] = %f N[%d]\n", selection[iselect], d, track->GetNTrackRefs());
216 if((track->GetNTrackRefs())){
217 d /= track->GetNTrackRefs();
219 //printf("\t\tFound %2d in ref[%3d] : d[%f]\n", imiss, selection[iselect], d/track->GetNTrackRefs());
220 bFOUND = kTRUE; break;
224 // process outer param ... always available
225 // compare missOP with OP in GTC
226 esd = track->GetESDinfo()->GetOuterParam();
229 op->GetYAt(x0, AliTracker::GetBz(), y0);
230 op->GetZAt(x0, AliTracker::GetBz(), z0);
231 x = x0*cosa - y0*sina;
232 y = x0*sina + y0*cosa;
237 d = dx*dx+dy*dy+dz*dz;
238 //printf("\td[%d] = %f op\n", selection[iselect], d);
240 //printf("\t\tFound %2d in op[%3d] : d[%f] dx[%5.2f] dy[%5.2f] dz[%5.2f]\n", imiss, selection[iselect], d, dx, dy, dz);
241 bFOUND = kTRUE; break;
246 ref = tt->GetTrackRef(0);
247 mom = ref ? ref->P(): op->P();
248 pidx = AliTRDCalPID::GetPartIndex(tt->GetPDG());
249 pidx = TMath::Max(pidx, 0);
250 ((TProfile*)fContainer->At(pidx))->Fill(mom, 0.);
251 AliDebug(2, Form(" NOT bFOUND Id[%d] Mom[%f]\n", tt->GetTrackId(), mom));
255 AliDebug(2, Form("%3d Tracks: ESD[%3d] TPC[%3d] TRD[%3d | %5.2f%%] Off[%d]", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), fTracks->GetEntriesFast(), nTPC, nTRD, nTPC ? 1.E2*nTRD/float(nTPC) : 0., fMissed->GetEntriesFast()));
258 // check for double countings
259 Int_t indices[10000]; memset(indices, 0, sizeof(Int_t) * 10000);
260 TMath::Sort(nTRD, labelsacc, indices);
261 if(DebugLevel() > 2){
262 for(Int_t itk = 0; itk < nTRD - 1; itk++)
263 if(labelsacc[indices[itk]] ==labelsacc[indices[itk + 1]]) printf("Double counted MC track: %d\n", labelsacc[indices[itk]]);
265 PostData(1, fContainer);
269 //____________________________________________________________________
270 Bool_t AliTRDefficiency::GetRefFigure(Int_t ifig)
272 // Steer reference figures
275 AliWarning("Please provide a canvas to draw results.");
281 Bool_t bFIRST(kTRUE);
285 h = (TProfile*)fContainer->At(AliPID::kSPECIES);
286 for(Int_t is=0; is<AliPID::kSPECIES; is++){
287 h->Add((TProfile*)fContainer->At(is));
289 h->SetMarkerStyle(24);
290 h->SetMarkerColor(kBlack);
291 h->SetLineColor(kBlack);
292 h->SetTitle("TRD Efficiency integrated");
293 h->SetXTitle("p [GeV/c]");
294 h->GetXaxis()->SetMoreLogLabels();
295 h->SetYTitle("Efficiency");
296 h->GetYaxis()->CenterTitle();
301 for(Int_t is=0; is<AliPID::kSPECIES; is++){
302 if(!(h = (TProfile*)fContainer->At(is))) continue;
303 h->SetMarkerStyle(24);
306 h->SetXTitle("p [GeV/c]");
307 h->GetXaxis()->SetMoreLogLabels();
308 h->SetYTitle("Efficiency");
309 h->GetYaxis()->CenterTitle();
310 h->GetYaxis()->SetRangeUser(0.8, 1.05);
311 leg=new TLegend(.7, .2, .98, .6);
312 leg->SetHeader("Species");
313 leg->SetBorderSize(0);
314 leg->SetFillStyle(0);
315 leg->AddEntry(h, h->GetTitle(), "pl");
317 leg->AddEntry(h, h->GetTitle(), "pl");
329 //____________________________________________________________________
330 Bool_t AliTRDefficiency::PostProcess()
332 fNRefFigures = HasMCdata() ? 2 : 1;