]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/qaRec/AliTRDtrackingEfficiencyCombined.cxx
Adding FindObject methods to the event container class.
[u/mrichter/AliRoot.git] / TRD / qaRec / AliTRDtrackingEfficiencyCombined.cxx
CommitLineData
814ecea4 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: AliTRDtrackingEfficiencyCombined.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 <TObjArray.h>
28#include <TProfile.h>
29#include <TMath.h>
30#include <TCanvas.h>
3d86166d 31#include "TTreeStream.h"
814ecea4 32
33#include "AliMagFMaps.h"
34#include "AliTracker.h"
814ecea4 35#include "AliTrackReference.h"
814ecea4 36#include "AliAnalysisManager.h"
3d86166d 37
38#include "AliTRDseedV1.h"
39#include "AliTRDtrackV1.h"
814ecea4 40#include "AliTRDtrackInfo/AliTRDtrackInfo.h"
41#include "AliTRDtrackingEfficiencyCombined.h"
42
43ClassImp(AliTRDtrackingEfficiencyCombined)
44
45//_____________________________________________________________________________
3d86166d 46AliTRDtrackingEfficiencyCombined::AliTRDtrackingEfficiencyCombined()
47 :AliTRDrecoTask("TrackingEffMC", "Combined Tracking Efficiency")
814ecea4 48{
49 //
50 // Default constructor
51 //
ed383798 52}
53
814ecea4 54
55//_____________________________________________________________________________
56void AliTRDtrackingEfficiencyCombined::CreateOutputObjects(){
57 //
58 // Create output objects
59 //
60
61 OpenFile(0, "RECREATE");
62
63 const Int_t nbins = 11;
64 Float_t xbins[nbins+1] = {.5, .7, .9, 1.3, 1.7, 2.4, 3.5, 4.5, 5.5, 7., 9., 11.};
65
3d86166d 66 fContainer = new TObjArray();
67 fContainer->Add(new TProfile("trEffComb", "Combined Tracking Efficiency", nbins, xbins));
68 fContainer->Add(new TProfile("trContComb", "Combined Tracking Contamination", nbins, xbins));
814ecea4 69}
70
71//_____________________________________________________________________________
72void AliTRDtrackingEfficiencyCombined::Exec(Option_t *){
73 //
74 // Do it
75 //
76
77 const Float_t kAlpha = 0.349065850;
78 Int_t naccepted = 0, nrejected = 0, ndoublecounted = 0;
79 Int_t labelsacc[10000];
80 Int_t labelsrej[10000];
81 Float_t momacc[10000];
82 Float_t momrej[10000];
3d86166d 83 TProfile *efficiency = (TProfile *)fContainer->At(0);
84 TProfile *contamination = (TProfile *)fContainer->At(1);
814ecea4 85
3d86166d 86 Int_t nTrackInfos = fTracks->GetEntriesFast();
814ecea4 87 Double_t mom = 0;
88 AliTRDtrackV1 *TRDtrack = 0x0;
89 AliTRDtrackInfo *trkInf = 0x0;
90 AliTrackReference *trackRef = 0x0;
91 for(Int_t itinf = 0; itinf < nTrackInfos; itinf++){
92 mom = 0.;
3d86166d 93 trkInf = dynamic_cast<AliTRDtrackInfo *>(fTracks->UncheckedAt(itinf));
814ecea4 94 if(!trkInf) continue;
95 if((TRDtrack = trkInf->GetTRDtrack()) || trkInf->GetNumberOfClustersRefit()){
96 // check if allready found by the tracker
97 Bool_t found = kFALSE;
98 for(Int_t il = 0; il < naccepted; il++){
99 if(labelsacc[il] == trkInf->GetLabel()) found = kTRUE;
100 }
101 if(found){
102 mom = trackRef ? trackRef->P() : TRDtrack->P();
103 contamination->Fill(mom, 1);
104 ndoublecounted++;
105 continue;
106 }
107 if(trkInf->GetNTrackRefs()){
108 Int_t iref = 0;
109 while(!(trackRef = trkInf->GetTrackRef(iref++)));
110 }
158754f9 111 if(!trackRef) printf("Error: Track Reference missing for Track %d\n", trkInf->GetLabel());
814ecea4 112 mom = trackRef ? trackRef->P() : TRDtrack->P();
113// Accept track
114 if(fDebugLevel > 3)printf("Accept track\n");
115 momacc[naccepted] = mom;
116 labelsacc[naccepted++] = trkInf->GetLabel();
117/* printf("Reconstructed: event %3d Tracks: MC[%d] ESD[%d] NRefs[%d]\n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), trkInf->GetLabel(), trkInf->GetTrackId(), trkInf->GetNTrackRefs());*/
118 } else{
119 if(fDebugLevel>10) printf("Analysing Track References\n");
120 // Check if track is findable
121 Float_t xmin = 10000.0, xmax = 0.0;
122 Float_t ymin = 0.0, ymax = 0.0;
123 Float_t zmin = 0.0, zmax = 0.0;
124 Float_t lastx = 0.0, x = 0.0;
125 Int_t nLayers = 0;
126/* trackRef = trkInf->GetTrackRef(0);*/
127/* xmin = trackRef->LocalX(); xmax = trackRef->LocalX();
128 ymin = trackRef->LocalY(); ymax = trackRef->LocalY();
129 mom = trackRef->P();*/
130 Int_t *sector = new Int_t[trkInf->GetNTrackRefs()];
131 for(Int_t itr = 0; itr < trkInf->GetNTrackRefs(); itr++){
132 trackRef = trkInf->GetTrackRef(itr);
133 if(fDebugLevel>10) printf("%d. x[%f], y[%f], z[%f]\n", itr, trackRef->LocalX(), trackRef->LocalY(), trackRef->Z());
134 x = trackRef->LocalX();
135 if(x < 250. || x > 370.) continue; // Be Sure that we are inside TRD
136 sector[itr] = Int_t(trackRef->Alpha()/kAlpha);
137 if(x < xmin){
138 xmin = trackRef->LocalX();
139 ymin = trackRef->LocalY();
140 zmin = trackRef->Z();
141 mom = trackRef->P();
142 }
143 if(x > xmax){
144 xmax = trackRef->LocalX();
145 ymax = trackRef->LocalY();
146 zmax = trackRef->Z();
147 }
148 if(itr > 0){
149 Float_t dist = TMath::Abs(x - lastx);
150 if(fDebugLevel>10) printf("x = %f, lastx = %f, dist = %f\n", x, lastx, dist);
151 if(TMath::Abs(dist - 3.7) < 0.1) nLayers++; // ref(i+1) has to be larger than ref(i)
152 }
153 lastx = x;
154 }
155 // Apply cuts
156 Bool_t findable = kTRUE;
157 if(trkInf->GetNTrackRefs() > 2 && xmax > xmin){
158 if(mom < 0.55) findable = kFALSE; // momentum cut at 0.6
159 Double_t yangle = (ymax -ymin)/(xmax - xmin);
160 Double_t zangle = (zmax -zmin)/(xmax - xmin);
161 if(fDebugLevel>10) printf("track: y-Angle = %f, z-Angle = %f\n", yangle, zangle);
162 if(fDebugLevel>10) printf("nLayers = %d\n", nLayers);
163 if(TMath::ATan(TMath::Abs(yangle)) > 45.) findable = kFALSE;
164 if(TMath::ATan(TMath::Abs(zangle)) > 45.) findable = kFALSE;
165 if(nLayers < 4) findable = kFALSE;
166 if(!trkInf->IsPrimary()) findable = kFALSE;
167 Bool_t samesec = kTRUE;
168 for(Int_t iref = 1; iref < trkInf->GetNTrackRefs(); iref++)
169 if(sector[iref] != sector[0]) samesec = kFALSE;
170 if(!samesec) findable = kFALSE; // Discard all tracks which are passing more than one sector
171 if(fDebugLevel){
172 Double_t trackAngle = TMath::ATan(yangle);
173 Bool_t primary = trkInf->IsPrimary();
174 (*fDebugStream) << "NotFoundTrack"
175 << "Momentum=" << mom
176 << "trackAngle="<< trackAngle
177 << "NLayers=" << nLayers
178 << "Primary=" << primary
179 << "\n";
180 }
181 }
182 else
183 findable = kFALSE;
184 delete[] sector;
185 if(findable){
186 momrej[nrejected] = mom;
187 labelsrej[nrejected++] = trkInf->GetLabel();
188/* printf("Not Reconstructed: event %3d Tracks: MC[%d] ESD[%d] NRefs[%d]\n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), trkInf->GetLabel(), trkInf->GetTrackId(), trkInf->GetNTrackRefs());*/
189 }
190 }
191 }
192 for(Int_t itk = 0; itk < naccepted; itk++){
193 if(fDebugLevel > 2)printf("Accepted MC track: %d\n", labelsacc[itk]);
194 efficiency->Fill(momacc[itk], 1);
195 contamination->Fill(momacc[itk], 0);
196 }
197 Int_t nall = naccepted;
198 for(Int_t imis = 0; imis < nrejected; imis++){
199 Bool_t found = kFALSE;
200 for(Int_t ifound = 0; ifound < naccepted; ifound++){
201 if(labelsacc[ifound] == labelsrej[imis]){
202 found = kTRUE;
203 break;
204 }
205 }
206 if(!found){
207 efficiency->Fill(momrej[imis], 0);
208 contamination->Fill(momrej[imis], 0);
209 if(fDebugLevel > 2)printf("Rejected MC track: %d\n", labelsrej[imis]);
210 nall++;
211 }
212 }
213 //if(fDebugLevel>=1)
214 printf("%3d Tracks: MC[%3d] TRD[%3d | %5.2f%%] \n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), nall, naccepted, 1.E2*Float_t(naccepted)/Float_t(nall));
215 printf("%3d Tracks: ALL[%3d] DoubleCounted[%3d | %5.2f%%] \n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), nall + ndoublecounted, ndoublecounted, 1.E2*Float_t(ndoublecounted)/Float_t(nall + ndoublecounted));
216
3d86166d 217 PostData(0, fContainer);
814ecea4 218}
219
220//_____________________________________________________________________________
221void AliTRDtrackingEfficiencyCombined::Terminate(Option_t *)
222{
223 //
224 // Termination
225 //
226
3d86166d 227 if(fDebugStream){
228 delete fDebugStream;
229 fDebugStream = 0x0;
230 fDebugLevel = 0;
231 }
232
233 fContainer = dynamic_cast<TObjArray*>(GetOutputData(0));
234 if (!fContainer) {
814ecea4 235 Printf("ERROR: list not available");
236 return;
237 }
238
3d86166d 239 /*TProfile *hEff = (TProfile*)fContainer->At(0);
240 TProfile *hEffCont = (TProfile*)fContainer->At(1);
814ecea4 241 Printf("Eff[%p] EffCont[%p]\n", (void*)hEff, (void*)hEffCont);
242
243
244 TCanvas *c2 = new TCanvas("c2","",800,400);
245 c2->Divide(2,1);
246
247 c2->cd(1);
248 hEff->DrawCopy("e1");
249 c2->cd(2);
250 hEffCont->DrawCopy("e1");*/
814ecea4 251}