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