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>
30 #include "TTreeStream.h"
33 #include "AliESDtrack.h"
34 #include "AliTrackReference.h"
35 #include "AliExternalTrackParam.h"
36 #include "AliTracker.h"
38 #include "AliAnalysisManager.h"
40 #include "Cal/AliTRDCalPID.h"
41 #include "AliTRDefficiency.h"
42 #include "info/AliTRDtrackInfo.h"
44 ClassImp(AliTRDefficiency)
46 //____________________________________________________________________
47 AliTRDefficiency::AliTRDefficiency()
48 :AliTRDrecoTask("efficiency", "TRD barrel tracking efficiency checker")
52 // Default constructor
56 //____________________________________________________________________
57 AliTRDefficiency::~AliTRDefficiency()
65 //____________________________________________________________________
66 void AliTRDefficiency::CreateOutputObjects()
69 // Create output objects
72 OpenFile(0, "RECREATE");
73 const Int_t nbins = AliTRDCalPID::kNMom;
74 Float_t xbins[nbins+1] = {.5, .7, .9, 1.3, 1.7, 2.4, 3.5, 4.5, 5.5, 7., 9., 11.};
77 fContainer = new TObjArray();
78 for(Int_t is=0; is<AliPID::kSPECIES; is++){
79 fContainer->Add(h = new TProfile(Form("h%s", AliTRDCalPID::GetPartSymb(is)), "", nbins, xbins));
80 h->SetLineColor(AliTRDCalPID::GetPartColor(is));
81 h->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
84 fContainer->Add(h = new TProfile("h", "", nbins, xbins));
88 //____________________________________________________________________
89 void AliTRDefficiency::Exec(Option_t *)
95 Int_t labelsacc[10000];
96 memset(labelsacc, 0, sizeof(Int_t) * 10000);
99 fMissed = new TClonesArray("AliTRDtrackInfo", 10);
104 Int_t selection[10000], nselect = 0;
105 ULong_t status; Int_t pidx;
106 Int_t nTRD = 0, nTPC = 0, nMiss = 0;
107 AliTRDtrackInfo *track = 0x0;
108 AliTrackReference *ref = 0x0;
109 AliExternalTrackParam *esd = 0x0;
110 for(Int_t itrk=0; itrk<fTracks->GetEntriesFast(); itrk++){
111 track = (AliTRDtrackInfo*)fTracks->UncheckedAt(itrk);
113 if(!track->HasESDtrack()) continue;
114 status = track->GetStatus();
116 // missing TPC propagation - interesting for SA
117 if(!(status&AliESDtrack::kTPCout)) continue;
120 if(HasMCdata() && track->GetNTrackRefs() <= 1) continue;
123 selection[nselect++]=itrk;
124 ref = track->GetTrackRef(0);
125 esd = track->GetESDinfo()->GetOuterParam();
126 mom = ref ? ref->P(): esd->P();
127 pidx = AliTRDCalPID::GetPartIndex(track->GetPDG());
128 pidx = TMath::Max(pidx, 0);
130 //Int_t n = track->GetNumberOfClusters();
131 // where are this tracklets ???
132 //if(ncls0 > ncls1) printf("%3d ESD[%3d] TRD[%3d|%3d]\n", itrk, ncls0, ncls1, n);
133 if(track->GetNumberOfClustersRefit()){
134 ((TProfile*)fContainer->At(pidx))->Fill(mom, 1.);
135 labelsacc[nTRD] = track->GetLabel();
143 Int_t iref = 1; Bool_t found = kFALSE;
144 while((ref = track->GetTrackRef(iref))){
145 xmed = .5*(ref->LocalX() + track->GetTrackRef(iref-1)->LocalX());
146 xleng= (ref->LocalX() - track->GetTrackRef(iref-1)->LocalX());
147 if(TMath::Abs(xmed - 298.5) < .5 &&
148 TMath::Abs(xleng - 3.7) < .1){
156 // track missing first layer. Maybe interesting for SA.
160 new ((*fMissed)[nMiss]) AliTRDtrackInfo(*track);
163 if(fDebugLevel>=2) printf("%3d Tracks: ESD[%3d] TPC[%3d] TRD[%3d | %5.2f%%] Off[%d]\n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), fTracks->GetEntriesFast(), nTPC, nTRD, nTPC ? 1.E2*nTRD/float(nTPC) : 0., fMissed->GetEntriesFast());
166 // Find double tracks
167 Float_t threshold = 10.;
168 AliTrackReference *refMiss = 0x0;
169 AliExternalTrackParam *op = 0x0;
170 AliTRDtrackInfo *tt = 0x0;
171 for(Int_t imiss=0; imiss<nMiss; imiss++){
172 //printf("Searching missing %d ...\n", imiss);
174 // get outer param of missed
175 tt = (AliTRDtrackInfo*)fMissed->UncheckedAt(imiss);
176 op = tt->GetESDinfo()->GetOuterParam();
177 Double_t alpha = op->GetAlpha(), cosa = TMath::Cos(alpha), sina = TMath::Sin(alpha);
179 Double_t xyz[3], x0, y0, z0, x, y, z, dx, dy, dz, d;
181 Bool_t FOUND = kFALSE;
182 for(Int_t iselect=0; iselect<nselect; iselect++){
183 track = (AliTRDtrackInfo*)fTracks->UncheckedAt(selection[iselect]);
185 // check first MC ... if available
187 for(Int_t iref=0; iref<track->GetNTrackRefs(); iref++){
188 if(!(ref = track->GetTrackRef(iref))) continue;
189 if((refMiss = tt->GetTrackRef(iref))){
190 dy = ref->LocalY() - refMiss->LocalY();
191 dz = ref->Z() - refMiss->Z();
193 // compare missOP with refTrackRef in LTC
195 op->GetYAt(x0, AliTracker::GetBz(), y0);
196 op->GetZAt(x0, AliTracker::GetBz(), z0);
197 dy = y0 - ref->LocalY();
200 d += (dy*dy + dz*dz);
202 //printf("\td[%d] = %f N[%d]\n", selection[iselect], d, track->GetNTrackRefs());
203 if((track->GetNTrackRefs())){
204 d /= track->GetNTrackRefs();
206 //printf("\t\tFound %2d in ref[%3d] : d[%f]\n", imiss, selection[iselect], d/track->GetNTrackRefs());
207 FOUND = kTRUE; break;
211 // process outer param ... always available
212 // compare missOP with OP in GTC
213 esd = track->GetESDinfo()->GetOuterParam();
216 op->GetYAt(x0, AliTracker::GetBz(), y0);
217 op->GetZAt(x0, AliTracker::GetBz(), z0);
218 x = x0*cosa - y0*sina;
219 y = x0*sina + y0*cosa;
224 d = dx*dx+dy*dy+dz*dz;
225 //printf("\td[%d] = %f op\n", selection[iselect], d);
227 //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);
228 FOUND = kTRUE; break;
233 ref = tt->GetTrackRef(0);
234 mom = ref ? ref->P(): op->P();
235 pidx = AliTRDCalPID::GetPartIndex(tt->GetPDG());
236 pidx = TMath::Max(pidx, 0);
237 ((TProfile*)fContainer->At(pidx))->Fill(mom, 0.);
238 if(fDebugLevel>=2) printf("\tNOT FOUND Id[%d] Mom[%f]\n", tt->GetTrackId(), mom);
242 if(fDebugLevel>=2) printf("%3d Tracks: ESD[%3d] TPC[%3d] TRD[%3d | %5.2f%%] Off[%d]\n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), fTracks->GetEntriesFast(), nTPC, nTRD, nTPC ? 1.E2*nTRD/float(nTPC) : 0., fMissed->GetEntriesFast());
245 // check for double countings
246 Int_t indices[10000]; memset(indices, 0, sizeof(Int_t) * 10000);
247 TMath::Sort(nTRD, labelsacc, indices);
249 for(Int_t itk = 0; itk < nTRD - 1; itk++)
250 if(labelsacc[indices[itk]] ==labelsacc[indices[itk + 1]]) printf("Double counted MC track: %d\n", labelsacc[indices[itk]]);
252 PostData(0, fContainer);
255 //____________________________________________________________________
256 void AliTRDefficiency::Terminate(Option_t *)
268 fContainer = dynamic_cast<TObjArray*>(GetOutputData(0));
270 Printf("ERROR: list not available");
278 //____________________________________________________________________
279 Bool_t AliTRDefficiency::GetRefFigure(Int_t ifig)
281 Bool_t FIRST = 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->SetMarkerColor(kBlack);
290 h->SetLineColor(kBlack);
291 h->GetXaxis()->SetTitle("p [GeV/c]");
296 for(Int_t is=0; is<AliPID::kSPECIES; is++){
297 if(!(h = (TProfile*)fContainer->At(is))) continue;
300 h->GetXaxis()->SetTitle("p [GeV/c]");
301 } else h->Draw("same e1");
310 //____________________________________________________________________
311 Bool_t AliTRDefficiency::PostProcess()
313 fNRefFigures = HasMCdata() ? 2 : 1;