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: AliTRDtrackingEfficiency.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 "AliESDtrack.h"
33 #include "AliTrackReference.h"
34 #include "AliExternalTrackParam.h"
35 #include "AliTracker.h"
36 #include "AliMagFMaps.h"
37 #include "AliAnalysisManager.h"
39 #include "AliTRDtrackingEfficiency.h"
40 #include "AliTRDtrackInfo/AliTRDtrackInfo.h"
42 ClassImp(AliTRDtrackingEfficiency)
44 //____________________________________________________________________
45 AliTRDtrackingEfficiency::AliTRDtrackingEfficiency(const Char_t *name):
46 AliAnalysisTask(name, "")
47 ,fObjectContainer(0x0)
54 // Default constructor
57 DefineInput(0, TObjArray::Class());
58 DefineOutput(0, TList::Class());
61 //____________________________________________________________________
62 void AliTRDtrackingEfficiency::ConnectInputData(Option_t *)
68 fTracks = dynamic_cast<TObjArray*>(GetInputData(0));
71 //____________________________________________________________________
72 void AliTRDtrackingEfficiency::CreateOutputObjects()
75 // Create output objects
78 OpenFile(0, "RECREATE");
79 const Int_t nbins = 11;
80 Float_t xbins[nbins+1] = {.5, .7, .9, 1.3, 1.7, 2.4, 3.5, 4.5, 5.5, 7., 9., 11.};
81 fObjectContainer = new TList();
82 fObjectContainer->Add(new TProfile("h", "", nbins, xbins));
85 //____________________________________________________________________
86 void AliTRDtrackingEfficiency::Exec(Option_t *)
92 if(!AliTracker::GetFieldMap()){
93 AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 2, 1., 10., AliMagFMaps::k5kG);
94 AliTracker::SetFieldMap(field, kTRUE);
96 TProfile *h = (TProfile*)fObjectContainer->At(0);
97 Int_t labelsacc[10000]; memset(labelsacc, 0, sizeof(Int_t) * 10000);
100 fMissed = new TClonesArray("AliTRDtrackInfo", 10);
105 Int_t selection[10000], nselect = 0;
107 Int_t nTRD = 0, nTPC = 0, nMiss = 0;
108 AliTRDtrackInfo *track = 0x0;
109 AliTrackReference *ref = 0x0;
110 AliExternalTrackParam *esd = 0x0;
111 for(Int_t itrk=0; itrk<fTracks->GetEntriesFast(); itrk++){
112 track = (AliTRDtrackInfo*)fTracks->UncheckedAt(itrk);
113 if(!track->HasESDtrack()) continue;
114 status = track->GetStatus();
115 if(!(status&AliESDtrack::kTPCout)){
116 // missing TPC propagation - interesting for SA
121 selection[nselect++]=itrk;
123 //Int_t n = track->GetNumberOfClusters();
124 // where are this tracklets ???
125 //if(ncls0 > ncls1) printf("%3d ESD[%3d] TRD[%3d|%3d]\n", itrk, ncls0, ncls1, n);
126 if(track->GetNumberOfClustersRefit()){
127 ref = track->GetTrackRef(0);
128 esd = track->GetOuterParam();
129 mom = ref ? ref->P(): esd->P();
130 //printf("FOUND Id[%d] mom[%f]\n", itrk, mom);
132 labelsacc[nTRD] = track->GetLabel();
138 Int_t nrefs = track->GetNTrackRefs();
141 // we don't have MC info.
142 // we should discard this track
147 Int_t iref = 1; Bool_t found = kFALSE;
148 while((ref = track->GetTrackRef(iref))){
149 xmed = .5*(ref->LocalX() + track->GetTrackRef(iref-1)->LocalX());
150 xleng= (ref->LocalX() - track->GetTrackRef(iref-1)->LocalX());
151 if(TMath::Abs(xmed - 298.5) < .5 &&
152 TMath::Abs(xleng - 3.7) < .1){
160 // track missing first layer. Maybe interesting for SA.
164 new ((*fMissed)[nMiss]) AliTRDtrackInfo(*track);
167 if(fDebugLevel>=1) 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());
170 // Find double tracks
171 Float_t threshold = 10.;
172 AliTrackReference *refMiss = 0x0;
173 AliExternalTrackParam *op = 0x0;
174 AliTRDtrackInfo *tt = 0x0;
175 for(Int_t imiss=0; imiss<nMiss; imiss++){
176 //printf("Searching missing %d ...\n", imiss);
178 // get outer param of missed
179 tt = (AliTRDtrackInfo*)fMissed->UncheckedAt(imiss);
180 op = tt->GetOuterParam();
181 Double_t alpha = op->GetAlpha(), cosa = TMath::Cos(alpha), sina = TMath::Sin(alpha);
183 Double_t xyz[3], x0, y0, z0, x, y, z, dx, dy, dz, d;
185 Bool_t FOUND = kFALSE;
186 for(Int_t iselect=0; iselect<nselect; iselect++){
187 track = (AliTRDtrackInfo*)fTracks->UncheckedAt(selection[iselect]);
189 // check first MC ... if available
191 for(Int_t iref=0; iref<track->GetNTrackRefs(); iref++){
192 if(!(ref = track->GetTrackRef(iref))) continue;
193 if((refMiss = tt->GetTrackRef(iref))){
194 dy = ref->LocalY() - refMiss->LocalY();
195 dz = ref->Z() - refMiss->Z();
197 // compare missOP with refTrackRef in LTC
199 op->GetYAt(x0, AliTracker::GetBz(), y0);
200 op->GetZAt(x0, AliTracker::GetBz(), z0);
201 dy = y0 - ref->LocalY();
204 d += (dy*dy + dz*dz);
206 //printf("\td[%d] = %f N[%d]\n", selection[iselect], d, track->GetNTrackRefs());
207 if((track->GetNTrackRefs())){
208 d /= track->GetNTrackRefs();
210 //printf("\t\tFound %2d in ref[%3d] : d[%f]\n", imiss, selection[iselect], d/track->GetNTrackRefs());
211 FOUND = kTRUE; break;
215 // process outer param ... always available
216 // compare missOP with OP in GTC
217 esd = track->GetOuterParam();
220 op->GetYAt(x0, AliTracker::GetBz(), y0);
221 op->GetZAt(x0, AliTracker::GetBz(), z0);
222 x = x0*cosa - y0*sina;
223 y = x0*sina + y0*cosa;
228 d = dx*dx+dy*dy+dz*dz;
229 //printf("\td[%d] = %f op\n", selection[iselect], d);
231 //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);
232 FOUND = kTRUE; break;
237 ref = tt->GetTrackRef(0);
238 mom = ref ? ref->P(): op->P();
240 printf("\tNOT FOUND Id[%d] Mom[%f]\n", tt->GetTrackId(), mom);
245 printf("%3d Tracks: ESD[%3d] TPC[%3d] TRD[%3d | %5.2f%%] Off[%d]\n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), fTracks->GetEntriesFast(), nTPC, nTRD, 1.E2*nTRD/float(nTPC), fMissed->GetEntriesFast());
248 // check for double countings
249 Int_t indices[10000]; memset(indices, 0, sizeof(Int_t) * 10000);
250 TMath::Sort(nTRD, labelsacc, indices);
252 for(Int_t itk = 0; itk < nTRD - 1; itk++)
253 if(labelsacc[indices[itk]] ==labelsacc[indices[itk + 1]]) printf("Double counted MC track: %d\n", labelsacc[indices[itk]]);
255 PostData(0, fObjectContainer);
258 //____________________________________________________________________
259 void AliTRDtrackingEfficiency::Terminate(Option_t *)
265 fObjectContainer = dynamic_cast<TList*>(GetOutputData(0));
266 if (!fObjectContainer) {
267 Printf("ERROR: list not available");