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: AliTRDtrackingEfficiencyCombined.cxx 27496 2008-07-22 08:35:45Z cblume $ */
18 ////////////////////////////////////////////////////////////////////////////
20 // Reconstruction QA //
23 // Markus Fasel <M.Fasel@gsi.de> //
25 ////////////////////////////////////////////////////////////////////////////
27 #include <TObjArray.h>
31 #include "TTreeStream.h"
33 #include "AliMagFMaps.h"
34 #include "AliTracker.h"
35 #include "AliTrackReference.h"
36 #include "AliAnalysisManager.h"
38 #include "AliTRDseedV1.h"
39 #include "AliTRDtrackV1.h"
40 #include "AliTRDtrackInfo/AliTRDtrackInfo.h"
41 #include "AliTRDtrackingEfficiencyCombined.h"
43 ClassImp(AliTRDtrackingEfficiencyCombined)
45 //_____________________________________________________________________________
46 AliTRDtrackingEfficiencyCombined::AliTRDtrackingEfficiencyCombined()
47 :AliTRDrecoTask("TrackingEffMC", "Combined Tracking Efficiency")
50 // Default constructor
55 //_____________________________________________________________________________
56 void AliTRDtrackingEfficiencyCombined::CreateOutputObjects(){
58 // Create output objects
61 OpenFile(0, "RECREATE");
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.};
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));
71 //_____________________________________________________________________________
72 void AliTRDtrackingEfficiencyCombined::Exec(Option_t *){
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];
83 TProfile *efficiency = (TProfile *)fContainer->At(0);
84 TProfile *contamination = (TProfile *)fContainer->At(1);
86 Int_t nTrackInfos = fTracks->GetEntriesFast();
88 AliTRDtrackV1 *TRDtrack = 0x0;
89 AliTRDtrackInfo *trkInf = 0x0;
90 AliTrackReference *trackRef = 0x0;
91 for(Int_t itinf = 0; itinf < nTrackInfos; itinf++){
93 trkInf = dynamic_cast<AliTRDtrackInfo *>(fTracks->UncheckedAt(itinf));
95 if((TRDtrack = trkInf->GetTrack()) || 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;
102 mom = trackRef ? trackRef->P() : TRDtrack->P();
103 contamination->Fill(mom, 1);
107 if(trkInf->GetNTrackRefs()){
109 while(!(trackRef = trkInf->GetTrackRef(iref++)));
111 if(!trackRef) printf("Error: Track Reference missing for Track %d\n", trkInf->GetLabel());
112 mom = trackRef ? trackRef->P() : trkInf->GetOuterParam()->P();
115 if(fDebugLevel > 3)printf("Accept track\n");
116 momacc[naccepted] = mom;
117 labelsacc[naccepted++] = trkInf->GetLabel();
118 /* printf("Reconstructed: event %3d Tracks: MC[%d] ESD[%d] NRefs[%d]\n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), trkInf->GetLabel(), trkInf->GetTrackId(), trkInf->GetNTrackRefs());*/
120 if(fDebugLevel>10) printf("Analysing Track References\n");
121 // Check if track is findable
122 Float_t xmin = 10000.0, xmax = 0.0;
123 Float_t ymin = 0.0, ymax = 0.0;
124 Float_t zmin = 0.0, zmax = 0.0;
125 Float_t lastx = 0.0, x = 0.0;
127 /* trackRef = trkInf->GetTrackRef(0);*/
128 /* xmin = trackRef->LocalX(); xmax = trackRef->LocalX();
129 ymin = trackRef->LocalY(); ymax = trackRef->LocalY();
130 mom = trackRef->P();*/
131 Int_t *sector = new Int_t[trkInf->GetNTrackRefs()];
132 for(Int_t itr = 0; itr < trkInf->GetNTrackRefs(); itr++){
133 trackRef = trkInf->GetTrackRef(itr);
134 if(fDebugLevel>10) printf("%d. x[%f], y[%f], z[%f]\n", itr, trackRef->LocalX(), trackRef->LocalY(), trackRef->Z());
135 x = trackRef->LocalX();
136 if(x < 250. || x > 370.) continue; // Be Sure that we are inside TRD
137 sector[itr] = Int_t(trackRef->Alpha()/kAlpha);
139 xmin = trackRef->LocalX();
140 ymin = trackRef->LocalY();
141 zmin = trackRef->Z();
145 xmax = trackRef->LocalX();
146 ymax = trackRef->LocalY();
147 zmax = trackRef->Z();
150 Float_t dist = TMath::Abs(x - lastx);
151 if(fDebugLevel>10) printf("x = %f, lastx = %f, dist = %f\n", x, lastx, dist);
152 if(TMath::Abs(dist - 3.7) < 0.1) nLayers++; // ref(i+1) has to be larger than ref(i)
157 Bool_t findable = kTRUE;
158 if(trkInf->GetNTrackRefs() > 2 && xmax > xmin){
159 if(mom < 0.55) findable = kFALSE; // momentum cut at 0.6
160 Double_t yangle = (ymax -ymin)/(xmax - xmin);
161 Double_t zangle = (zmax -zmin)/(xmax - xmin);
162 if(fDebugLevel>10) printf("track: y-Angle = %f, z-Angle = %f\n", yangle, zangle);
163 if(fDebugLevel>10) printf("nLayers = %d\n", nLayers);
164 if(TMath::ATan(TMath::Abs(yangle)) > 45.) findable = kFALSE;
165 if(TMath::ATan(TMath::Abs(zangle)) > 45.) findable = kFALSE;
166 if(nLayers < 4) findable = kFALSE;
167 if(!trkInf->IsPrimary()) findable = kFALSE;
168 Bool_t samesec = kTRUE;
169 for(Int_t iref = 1; iref < trkInf->GetNTrackRefs(); iref++)
170 if(sector[iref] != sector[0]) samesec = kFALSE;
171 if(!samesec) findable = kFALSE; // Discard all tracks which are passing more than one sector
173 Double_t trackAngle = TMath::ATan(yangle);
174 Bool_t primary = trkInf->IsPrimary();
175 (*fDebugStream) << "NotFoundTrack"
176 << "Momentum=" << mom
177 << "trackAngle="<< trackAngle
178 << "NLayers=" << nLayers
179 << "Primary=" << primary
187 momrej[nrejected] = mom;
188 labelsrej[nrejected++] = trkInf->GetLabel();
189 /* printf("Not Reconstructed: event %3d Tracks: MC[%d] ESD[%d] NRefs[%d]\n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), trkInf->GetLabel(), trkInf->GetTrackId(), trkInf->GetNTrackRefs());*/
193 for(Int_t itk = 0; itk < naccepted; itk++){
194 if(fDebugLevel > 2)printf("Accepted MC track: %d\n", labelsacc[itk]);
195 efficiency->Fill(momacc[itk], 1);
196 contamination->Fill(momacc[itk], 0);
198 Int_t nall = naccepted;
199 for(Int_t imis = 0; imis < nrejected; imis++){
200 Bool_t found = kFALSE;
201 for(Int_t ifound = 0; ifound < naccepted; ifound++){
202 if(labelsacc[ifound] == labelsrej[imis]){
208 efficiency->Fill(momrej[imis], 0);
209 contamination->Fill(momrej[imis], 0);
210 if(fDebugLevel > 2)printf("Rejected MC track: %d\n", labelsrej[imis]);
215 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));
216 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));
218 PostData(0, fContainer);
221 //_____________________________________________________________________________
222 void AliTRDtrackingEfficiencyCombined::Terminate(Option_t *)
234 fContainer = dynamic_cast<TObjArray*>(GetOutputData(0));
236 Printf("ERROR: list not available");
240 /*TProfile *hEff = (TProfile*)fContainer->At(0);
241 TProfile *hEffCont = (TProfile*)fContainer->At(1);
242 Printf("Eff[%p] EffCont[%p]\n", (void*)hEff, (void*)hEffCont);
245 TCanvas *c2 = new TCanvas("c2","",800,400);
249 hEff->DrawCopy("e1");
251 hEffCont->DrawCopy("e1");*/