]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG1/TRD/AliTRDefficiency.cxx
coding convention fixed (Markus H)
[u/mrichter/AliRoot.git] / PWG1 / TRD / AliTRDefficiency.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: AliTRDefficiency.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 <TClonesArray.h>
28#include <TObjArray.h>
29#include <TProfile.h>
e2e3cec2 30#include <TPad.h>
a310e49b 31#include <TLegend.h>
1ee39b3a 32#include "TTreeStream.h"
33
34#include "AliPID.h"
35#include "AliESDtrack.h"
36#include "AliTrackReference.h"
37#include "AliExternalTrackParam.h"
38#include "AliTracker.h"
39#include "AliAnalysisManager.h"
40
41#include "Cal/AliTRDCalPID.h"
42#include "AliTRDefficiency.h"
43#include "info/AliTRDtrackInfo.h"
44
45ClassImp(AliTRDefficiency)
46
47//____________________________________________________________________
48AliTRDefficiency::AliTRDefficiency()
f2e89a4c 49 :AliTRDrecoTask()
db99a57a 50 ,fMissed(NULL)
f8f46e4d 51{
52 //
53 // Default constructor
54 //
f2e89a4c 55 SetNameTitle("TRDefficiency", "TRD barrel tracking efficiency checker");
f8f46e4d 56}
57
f2e89a4c 58//____________________________________________________________________
f8f46e4d 59AliTRDefficiency::AliTRDefficiency(char* name)
60 :AliTRDrecoTask(name, "TRD barrel tracking efficiency checker")
db99a57a 61 ,fMissed(NULL)
1ee39b3a 62{
63 //
64 // Default constructor
65 //
66}
67
68//____________________________________________________________________
69AliTRDefficiency::~AliTRDefficiency()
70{
71 // Destructor
72 if(fMissed){
73 fMissed->Delete();
74 delete fMissed;
75 }
76}
77
78//____________________________________________________________________
f8f46e4d 79void AliTRDefficiency::UserCreateOutputObjects()
1ee39b3a 80{
81 //
82 // Create output objects
83 //
84
1ee39b3a 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.};
87
db99a57a 88 TH1 *h = NULL;
1ee39b3a 89 fContainer = new TObjArray();
90 for(Int_t is=0; is<AliPID::kSPECIES; is++){
a310e49b 91 fContainer->Add(h = new TProfile(Form("h%s", AliTRDCalPID::GetPartSymb(is)), AliPID::ParticleShortName(is), nbins, xbins));
1ee39b3a 92 h->SetLineColor(AliTRDCalPID::GetPartColor(is));
93 h->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
a310e49b 94 h->SetMarkerStyle(24);
1ee39b3a 95 }
96 fContainer->Add(h = new TProfile("h", "", nbins, xbins));
97 h->SetMarkerStyle(7);
98}
99
100//____________________________________________________________________
f8f46e4d 101void AliTRDefficiency::UserExec(Option_t *)
1ee39b3a 102{
103 //
104 // Do it
105 //
106
107 Int_t labelsacc[10000];
108 memset(labelsacc, 0, sizeof(Int_t) * 10000);
109
5935a6da 110 fTracks = dynamic_cast<TObjArray *>(GetInputData(1));
111 if(!fTracks) return;
112 if(!fTracks->GetEntriesFast()) return;
113 else AliDebug(2, Form("Tracks[%d] for %s", fTracks->GetEntriesFast(), GetName()));
1ee39b3a 114 if(!fMissed){
115 fMissed = new TClonesArray("AliTRDtrackInfo", 10);
116 fMissed->SetOwner();
117 }
118
119 Float_t mom;
120 Int_t selection[10000], nselect = 0;
121 ULong_t status; Int_t pidx;
122 Int_t nTRD = 0, nTPC = 0, nMiss = 0;
db99a57a 123 AliTRDtrackInfo *track = NULL;
124 AliTrackReference *ref = NULL;
125 AliExternalTrackParam *esd = NULL;
1ee39b3a 126 for(Int_t itrk=0; itrk<fTracks->GetEntriesFast(); itrk++){
127 track = (AliTRDtrackInfo*)fTracks->UncheckedAt(itrk);
128
129 if(!track->HasESDtrack()) continue;
130 status = track->GetStatus();
131
132 // missing TPC propagation - interesting for SA
133 if(!(status&AliESDtrack::kTPCout)) continue;
134
135 // missing MC info.
136 if(HasMCdata() && track->GetNTrackRefs() <= 1) continue;
137
138 nTPC++;
139 selection[nselect++]=itrk;
140 ref = track->GetTrackRef(0);
141 esd = track->GetESDinfo()->GetOuterParam();
142 mom = ref ? ref->P(): esd->P();
143 pidx = AliTRDCalPID::GetPartIndex(track->GetPDG());
144 pidx = TMath::Max(pidx, 0);
8f7b1226 145 AliDebug(4, Form("PID: %d", pidx));
1ee39b3a 146
147 //Int_t n = track->GetNumberOfClusters();
148 // where are this tracklets ???
149 //if(ncls0 > ncls1) printf("%3d ESD[%3d] TRD[%3d|%3d]\n", itrk, ncls0, ncls1, n);
150 if(track->GetNumberOfClustersRefit()){
151 ((TProfile*)fContainer->At(pidx))->Fill(mom, 1.);
152 labelsacc[nTRD] = track->GetLabel();
153 nTRD++;
154 continue;
155 }
156
157
158
159 Float_t xmed, xleng;
160 Int_t iref = 1; Bool_t found = kFALSE;
161 while((ref = track->GetTrackRef(iref))){
162 xmed = .5*(ref->LocalX() + track->GetTrackRef(iref-1)->LocalX());
163 xleng= (ref->LocalX() - track->GetTrackRef(iref-1)->LocalX());
164 if(TMath::Abs(xmed - 298.5) < .5 &&
165 TMath::Abs(xleng - 3.7) < .1){
166 found = kTRUE;
167 break;
168 }
169 iref++;
170 }
171 if(!found){
172 nTPC--;
173 // track missing first layer. Maybe interesting for SA.
174 continue;
175 }
176 nselect--;
177 new ((*fMissed)[nMiss]) AliTRDtrackInfo(*track);
178 nMiss++;
179 }
180 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()));
181
182
183 // Find double tracks
184 Float_t threshold = 10.;
db99a57a 185 AliTrackReference *refMiss = NULL;
186 AliExternalTrackParam *op = NULL;
187 AliTRDtrackInfo *tt = NULL;
1ee39b3a 188 for(Int_t imiss=0; imiss<nMiss; imiss++){
189 //printf("Searching missing %d ...\n", imiss);
190
191 // get outer param of missed
192 tt = (AliTRDtrackInfo*)fMissed->UncheckedAt(imiss);
193 op = tt->GetESDinfo()->GetOuterParam();
194 Double_t alpha = op->GetAlpha(), cosa = TMath::Cos(alpha), sina = TMath::Sin(alpha);
195
196 Double_t xyz[3], x0, y0, z0, x, y, z, dx, dy, dz, d;
197
198 Bool_t bFOUND = kFALSE;
199 for(Int_t iselect=0; iselect<nselect; iselect++){
200 track = (AliTRDtrackInfo*)fTracks->UncheckedAt(selection[iselect]);
201
202 // check first MC ... if available
203 d = 0;
204 for(Int_t iref=0; iref<track->GetNTrackRefs(); iref++){
205 if(!(ref = track->GetTrackRef(iref))) continue;
206 if((refMiss = tt->GetTrackRef(iref))){
207 dy = ref->LocalY() - refMiss->LocalY();
208 dz = ref->Z() - refMiss->Z();
209 } else {
210 // compare missOP with refTrackRef in LTC
211 x0 = ref->LocalX();
212 op->GetYAt(x0, AliTracker::GetBz(), y0);
213 op->GetZAt(x0, AliTracker::GetBz(), z0);
214 dy = y0 - ref->LocalY();
215 dz = z0 - ref->Z();
216 }
217 d += (dy*dy + dz*dz);
218 }
219 //printf("\td[%d] = %f N[%d]\n", selection[iselect], d, track->GetNTrackRefs());
220 if((track->GetNTrackRefs())){
221 d /= track->GetNTrackRefs();
222 if(d < threshold){
223 //printf("\t\tFound %2d in ref[%3d] : d[%f]\n", imiss, selection[iselect], d/track->GetNTrackRefs());
224 bFOUND = kTRUE; break;
225 }
226 }
227
228 // process outer param ... always available
229 // compare missOP with OP in GTC
230 esd = track->GetESDinfo()->GetOuterParam();
231 esd->GetXYZ(xyz);
232 x0 = esd->GetX();
233 op->GetYAt(x0, AliTracker::GetBz(), y0);
234 op->GetZAt(x0, AliTracker::GetBz(), z0);
235 x = x0*cosa - y0*sina;
236 y = x0*sina + y0*cosa;
237 z = z0;
238 dx=xyz[0]-x;
239 dy=xyz[1]-y;
240 dz=xyz[2]-z;
241 d = dx*dx+dy*dy+dz*dz;
242 //printf("\td[%d] = %f op\n", selection[iselect], d);
243 if(d < threshold){
244 //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);
245 bFOUND = kTRUE; break;
246 }
247 }
248 if(bFOUND) nTPC--;
249 else{
250 ref = tt->GetTrackRef(0);
251 mom = ref ? ref->P(): op->P();
252 pidx = AliTRDCalPID::GetPartIndex(tt->GetPDG());
253 pidx = TMath::Max(pidx, 0);
254 ((TProfile*)fContainer->At(pidx))->Fill(mom, 0.);
255 AliDebug(2, Form(" NOT bFOUND Id[%d] Mom[%f]\n", tt->GetTrackId(), mom));
256 }
257 }
258
259 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()));
260
261 //fMissed->Delete();
262 // check for double countings
263 Int_t indices[10000]; memset(indices, 0, sizeof(Int_t) * 10000);
264 TMath::Sort(nTRD, labelsacc, indices);
265 if(DebugLevel() > 2){
266 for(Int_t itk = 0; itk < nTRD - 1; itk++)
267 if(labelsacc[indices[itk]] ==labelsacc[indices[itk + 1]]) printf("Double counted MC track: %d\n", labelsacc[indices[itk]]);
268 }
f8f46e4d 269 PostData(1, fContainer);
1ee39b3a 270}
271
272
273//____________________________________________________________________
274Bool_t AliTRDefficiency::GetRefFigure(Int_t ifig)
275{
276// Steer reference figures
277
e2e3cec2 278 if(!gPad){
279 AliWarning("Please provide a canvas to draw results.");
280 return kFALSE;
281 }
282 gPad->SetLogx();
283
a310e49b 284 TLegend *leg(NULL);
285 Bool_t bFIRST(kTRUE);
286 TProfile *h(NULL);
1ee39b3a 287 switch(ifig){
288 case 0:
289 h = (TProfile*)fContainer->At(AliPID::kSPECIES);
290 for(Int_t is=0; is<AliPID::kSPECIES; is++){
291 h->Add((TProfile*)fContainer->At(is));
292 }
a310e49b 293 h->SetMarkerStyle(24);
1ee39b3a 294 h->SetMarkerColor(kBlack);
295 h->SetLineColor(kBlack);
e2e3cec2 296 h->SetTitle("TRD Efficiency integrated");
a310e49b 297 h->SetXTitle("p [GeV/c]");
e2e3cec2 298 h->GetXaxis()->SetMoreLogLabels();
a310e49b 299 h->SetYTitle("Efficiency");
300 h->GetYaxis()->CenterTitle();
1ee39b3a 301 h->Draw("e1");
302 break;
303 case 1:
304 bFIRST = kTRUE;
305 for(Int_t is=0; is<AliPID::kSPECIES; is++){
306 if(!(h = (TProfile*)fContainer->At(is))) continue;
a310e49b 307 h->SetMarkerStyle(24);
1ee39b3a 308 if(bFIRST){
309 h->Draw("e1");
a310e49b 310 h->SetXTitle("p [GeV/c]");
e2e3cec2 311 h->GetXaxis()->SetMoreLogLabels();
a310e49b 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");
320 } else {
321 leg->AddEntry(h, h->GetTitle(), "pl");
322 h->Draw("same e1");
323 }
1ee39b3a 324 bFIRST = kFALSE;
325 }
a310e49b 326 leg->Draw();
1ee39b3a 327 break;
328 }
329 return kTRUE;
330}
331
332
333//____________________________________________________________________
334Bool_t AliTRDefficiency::PostProcess()
335{
336 fNRefFigures = HasMCdata() ? 2 : 1;
337 return kTRUE;
338}