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 const Int_t nbins = AliTRDCalPID::kNMom;
86 Float_t xbins[nbins+1] = {.5, .7, .9, 1.3, 1.7, 2.4, 3.5, 4.5, 5.5, 7., 9., 11.};
89 fContainer = new TObjArray();
90 for(Int_t is=0; is<AliPID::kSPECIES; is++){
91 fContainer->Add(h = new TProfile(Form("h%s", AliTRDCalPID::GetPartSymb(is)), AliPID::ParticleShortName(is), nbins, xbins));
92 h->SetLineColor(AliTRDCalPID::GetPartColor(is));
93 h->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
94 h->SetMarkerStyle(24);
96 fContainer->Add(h = new TProfile("h", "", nbins, xbins));
98 PostData(1, fContainer);
101 //____________________________________________________________________
102 void AliTRDefficiency::UserExec(Option_t *)
108 Int_t labelsacc[10000];
109 memset(labelsacc, 0, sizeof(Int_t) * 10000);
111 fTracks = dynamic_cast<TObjArray *>(GetInputData(1));
113 if(!fTracks->GetEntriesFast()) return;
114 else AliDebug(2, Form("Tracks[%d] for %s", fTracks->GetEntriesFast(), GetName()));
116 fMissed = new TClonesArray("AliTRDtrackInfo", 10);
121 Int_t selection[10000], nselect = 0;
122 ULong_t status; Int_t pidx;
123 Int_t nTRD = 0, nTPC = 0, nMiss = 0;
124 AliTRDtrackInfo *track = NULL;
125 AliTrackReference *ref = NULL;
126 AliExternalTrackParam *esd = NULL;
127 for(Int_t itrk=0; itrk<fTracks->GetEntriesFast(); itrk++){
128 track = (AliTRDtrackInfo*)fTracks->UncheckedAt(itrk);
130 if(!track->HasESDtrack()) continue;
131 status = track->GetStatus();
133 // missing TPC propagation - interesting for SA
134 if(!(status&AliESDtrack::kTPCout)) continue;
137 if(HasMCdata() && track->GetNTrackRefs() <= 1) continue;
140 selection[nselect++]=itrk;
141 ref = track->GetTrackRef(0);
142 esd = track->GetESDinfo()->GetOuterParam();
143 mom = ref ? ref->P(): esd->P();
144 pidx = AliTRDCalPID::GetPartIndex(track->GetPDG());
145 pidx = TMath::Max(pidx, 0);
146 AliDebug(4, Form("PID: %d", pidx));
148 //Int_t n = track->GetNumberOfClusters();
149 // where are this tracklets ???
150 //if(ncls0 > ncls1) printf("%3d ESD[%3d] TRD[%3d|%3d]\n", itrk, ncls0, ncls1, n);
151 if(track->GetNumberOfClustersRefit()){
152 ((TProfile*)fContainer->At(pidx))->Fill(mom, 1.);
153 labelsacc[nTRD] = track->GetLabel();
161 Int_t iref = 1; Bool_t found = kFALSE;
162 while((ref = track->GetTrackRef(iref))){
163 xmed = .5*(ref->LocalX() + track->GetTrackRef(iref-1)->LocalX());
164 xleng= (ref->LocalX() - track->GetTrackRef(iref-1)->LocalX());
165 if(TMath::Abs(xmed - 298.5) < .5 &&
166 TMath::Abs(xleng - 3.7) < .1){
174 // track missing first layer. Maybe interesting for SA.
178 new ((*fMissed)[nMiss]) AliTRDtrackInfo(*track);
181 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()));
184 // Find double tracks
185 Float_t threshold = 10.;
186 AliTrackReference *refMiss = NULL;
187 AliExternalTrackParam *op = NULL;
188 AliTRDtrackInfo *tt = NULL;
189 for(Int_t imiss=0; imiss<nMiss; imiss++){
190 //printf("Searching missing %d ...\n", imiss);
192 // get outer param of missed
193 tt = (AliTRDtrackInfo*)fMissed->UncheckedAt(imiss);
194 op = tt->GetESDinfo()->GetOuterParam();
195 Double_t alpha = op->GetAlpha(), cosa = TMath::Cos(alpha), sina = TMath::Sin(alpha);
197 Double_t xyz[3], x0, y0, z0, x, y, z, dx, dy, dz, d;
199 Bool_t bFOUND = kFALSE;
200 for(Int_t iselect=0; iselect<nselect; iselect++){
201 track = (AliTRDtrackInfo*)fTracks->UncheckedAt(selection[iselect]);
203 // check first MC ... if available
205 for(Int_t iref=0; iref<track->GetNTrackRefs(); iref++){
206 if(!(ref = track->GetTrackRef(iref))) continue;
207 if((refMiss = tt->GetTrackRef(iref))){
208 dy = ref->LocalY() - refMiss->LocalY();
209 dz = ref->Z() - refMiss->Z();
211 // compare missOP with refTrackRef in LTC
213 op->GetYAt(x0, AliTracker::GetBz(), y0);
214 op->GetZAt(x0, AliTracker::GetBz(), z0);
215 dy = y0 - ref->LocalY();
218 d += (dy*dy + dz*dz);
220 //printf("\td[%d] = %f N[%d]\n", selection[iselect], d, track->GetNTrackRefs());
221 if((track->GetNTrackRefs())){
222 d /= track->GetNTrackRefs();
224 //printf("\t\tFound %2d in ref[%3d] : d[%f]\n", imiss, selection[iselect], d/track->GetNTrackRefs());
225 bFOUND = kTRUE; break;
229 // process outer param ... always available
230 // compare missOP with OP in GTC
231 esd = track->GetESDinfo()->GetOuterParam();
234 op->GetYAt(x0, AliTracker::GetBz(), y0);
235 op->GetZAt(x0, AliTracker::GetBz(), z0);
236 x = x0*cosa - y0*sina;
237 y = x0*sina + y0*cosa;
242 d = dx*dx+dy*dy+dz*dz;
243 //printf("\td[%d] = %f op\n", selection[iselect], d);
245 //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);
246 bFOUND = kTRUE; break;
251 ref = tt->GetTrackRef(0);
252 mom = ref ? ref->P(): op->P();
253 pidx = AliTRDCalPID::GetPartIndex(tt->GetPDG());
254 pidx = TMath::Max(pidx, 0);
255 ((TProfile*)fContainer->At(pidx))->Fill(mom, 0.);
256 AliDebug(2, Form(" NOT bFOUND Id[%d] Mom[%f]\n", tt->GetTrackId(), mom));
260 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()));
263 // check for double countings
264 Int_t indices[10000]; memset(indices, 0, sizeof(Int_t) * 10000);
265 TMath::Sort(nTRD, labelsacc, indices);
266 if(DebugLevel() > 2){
267 for(Int_t itk = 0; itk < nTRD - 1; itk++)
268 if(labelsacc[indices[itk]] ==labelsacc[indices[itk + 1]]) printf("Double counted MC track: %d\n", labelsacc[indices[itk]]);
273 //____________________________________________________________________
274 Bool_t AliTRDefficiency::GetRefFigure(Int_t ifig)
276 // Steer reference figures
279 AliWarning("Please provide a canvas to draw results.");
285 Bool_t bFIRST(kTRUE);
289 h = (TProfile*)fContainer->At(AliPID::kSPECIES);
290 for(Int_t is=0; is<AliPID::kSPECIES; is++){
291 h->Add((TProfile*)fContainer->At(is));
293 h->SetMarkerStyle(24);
294 h->SetMarkerColor(kBlack);
295 h->SetLineColor(kBlack);
296 h->SetTitle("TRD Efficiency integrated");
297 h->SetXTitle("p [GeV/c]");
298 h->GetXaxis()->SetMoreLogLabels();
299 h->SetYTitle("Efficiency");
300 h->GetYaxis()->CenterTitle();
305 for(Int_t is=0; is<AliPID::kSPECIES; is++){
306 if(!(h = (TProfile*)fContainer->At(is))) continue;
307 h->SetMarkerStyle(24);
310 h->SetXTitle("p [GeV/c]");
311 h->GetXaxis()->SetMoreLogLabels();
312 h->SetYTitle("Efficiency");
313 h->GetYaxis()->CenterTitle();
314 h->GetYaxis()->SetRangeUser(0.8, 1.05);
315 leg=new TLegend(.7, .2, .98, .6);
316 leg->SetHeader("Species");
317 leg->SetBorderSize(0);
318 leg->SetFillStyle(0);
319 leg->AddEntry(h, h->GetTitle(), "pl");
321 leg->AddEntry(h, h->GetTitle(), "pl");
333 //____________________________________________________________________
334 Bool_t AliTRDefficiency::PostProcess()
336 fNRefFigures = HasMCdata() ? 2 : 1;