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 if(!AliTracker::GetFieldMap()){
84 AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 2, 1., 10., AliMagFMaps::k5kG);
85 AliTracker::SetFieldMap(field, kTRUE);
87 TProfile *efficiency = (TProfile *)fContainer->At(0);
88 TProfile *contamination = (TProfile *)fContainer->At(1);
90 Int_t nTrackInfos = fTracks->GetEntriesFast();
92 AliTRDtrackV1 *TRDtrack = 0x0;
93 AliTRDtrackInfo *trkInf = 0x0;
94 AliTrackReference *trackRef = 0x0;
95 for(Int_t itinf = 0; itinf < nTrackInfos; itinf++){
97 trkInf = dynamic_cast<AliTRDtrackInfo *>(fTracks->UncheckedAt(itinf));
99 if((TRDtrack = trkInf->GetTRDtrack()) || trkInf->GetNumberOfClustersRefit()){
100 // check if allready found by the tracker
101 Bool_t found = kFALSE;
102 for(Int_t il = 0; il < naccepted; il++){
103 if(labelsacc[il] == trkInf->GetLabel()) found = kTRUE;
106 mom = trackRef ? trackRef->P() : TRDtrack->P();
107 contamination->Fill(mom, 1);
111 if(trkInf->GetNTrackRefs()){
113 while(!(trackRef = trkInf->GetTrackRef(iref++)));
115 if(!trackRef) printf("Error: Track Reference missing for Track %d\n", TRDtrack->GetLabel());
116 mom = trackRef ? trackRef->P() : TRDtrack->P();
118 if(fDebugLevel > 3)printf("Accept track\n");
119 momacc[naccepted] = mom;
120 labelsacc[naccepted++] = trkInf->GetLabel();
121 /* printf("Reconstructed: event %3d Tracks: MC[%d] ESD[%d] NRefs[%d]\n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), trkInf->GetLabel(), trkInf->GetTrackId(), trkInf->GetNTrackRefs());*/
123 if(fDebugLevel>10) printf("Analysing Track References\n");
124 // Check if track is findable
125 Float_t xmin = 10000.0, xmax = 0.0;
126 Float_t ymin = 0.0, ymax = 0.0;
127 Float_t zmin = 0.0, zmax = 0.0;
128 Float_t lastx = 0.0, x = 0.0;
130 /* trackRef = trkInf->GetTrackRef(0);*/
131 /* xmin = trackRef->LocalX(); xmax = trackRef->LocalX();
132 ymin = trackRef->LocalY(); ymax = trackRef->LocalY();
133 mom = trackRef->P();*/
134 Int_t *sector = new Int_t[trkInf->GetNTrackRefs()];
135 for(Int_t itr = 0; itr < trkInf->GetNTrackRefs(); itr++){
136 trackRef = trkInf->GetTrackRef(itr);
137 if(fDebugLevel>10) printf("%d. x[%f], y[%f], z[%f]\n", itr, trackRef->LocalX(), trackRef->LocalY(), trackRef->Z());
138 x = trackRef->LocalX();
139 if(x < 250. || x > 370.) continue; // Be Sure that we are inside TRD
140 sector[itr] = Int_t(trackRef->Alpha()/kAlpha);
142 xmin = trackRef->LocalX();
143 ymin = trackRef->LocalY();
144 zmin = trackRef->Z();
148 xmax = trackRef->LocalX();
149 ymax = trackRef->LocalY();
150 zmax = trackRef->Z();
153 Float_t dist = TMath::Abs(x - lastx);
154 if(fDebugLevel>10) printf("x = %f, lastx = %f, dist = %f\n", x, lastx, dist);
155 if(TMath::Abs(dist - 3.7) < 0.1) nLayers++; // ref(i+1) has to be larger than ref(i)
160 Bool_t findable = kTRUE;
161 if(trkInf->GetNTrackRefs() > 2 && xmax > xmin){
162 if(mom < 0.55) findable = kFALSE; // momentum cut at 0.6
163 Double_t yangle = (ymax -ymin)/(xmax - xmin);
164 Double_t zangle = (zmax -zmin)/(xmax - xmin);
165 if(fDebugLevel>10) printf("track: y-Angle = %f, z-Angle = %f\n", yangle, zangle);
166 if(fDebugLevel>10) printf("nLayers = %d\n", nLayers);
167 if(TMath::ATan(TMath::Abs(yangle)) > 45.) findable = kFALSE;
168 if(TMath::ATan(TMath::Abs(zangle)) > 45.) findable = kFALSE;
169 if(nLayers < 4) findable = kFALSE;
170 if(!trkInf->IsPrimary()) findable = kFALSE;
171 Bool_t samesec = kTRUE;
172 for(Int_t iref = 1; iref < trkInf->GetNTrackRefs(); iref++)
173 if(sector[iref] != sector[0]) samesec = kFALSE;
174 if(!samesec) findable = kFALSE; // Discard all tracks which are passing more than one sector
176 Double_t trackAngle = TMath::ATan(yangle);
177 Bool_t primary = trkInf->IsPrimary();
178 (*fDebugStream) << "NotFoundTrack"
179 << "Momentum=" << mom
180 << "trackAngle="<< trackAngle
181 << "NLayers=" << nLayers
182 << "Primary=" << primary
190 momrej[nrejected] = mom;
191 labelsrej[nrejected++] = trkInf->GetLabel();
192 /* printf("Not Reconstructed: event %3d Tracks: MC[%d] ESD[%d] NRefs[%d]\n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), trkInf->GetLabel(), trkInf->GetTrackId(), trkInf->GetNTrackRefs());*/
196 for(Int_t itk = 0; itk < naccepted; itk++){
197 if(fDebugLevel > 2)printf("Accepted MC track: %d\n", labelsacc[itk]);
198 efficiency->Fill(momacc[itk], 1);
199 contamination->Fill(momacc[itk], 0);
201 Int_t nall = naccepted;
202 for(Int_t imis = 0; imis < nrejected; imis++){
203 Bool_t found = kFALSE;
204 for(Int_t ifound = 0; ifound < naccepted; ifound++){
205 if(labelsacc[ifound] == labelsrej[imis]){
211 efficiency->Fill(momrej[imis], 0);
212 contamination->Fill(momrej[imis], 0);
213 if(fDebugLevel > 2)printf("Rejected MC track: %d\n", labelsrej[imis]);
218 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));
219 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));
221 PostData(0, fContainer);
224 //_____________________________________________________________________________
225 void AliTRDtrackingEfficiencyCombined::Terminate(Option_t *)
237 fContainer = dynamic_cast<TObjArray*>(GetOutputData(0));
239 Printf("ERROR: list not available");
243 /*TProfile *hEff = (TProfile*)fContainer->At(0);
244 TProfile *hEffCont = (TProfile*)fContainer->At(1);
245 Printf("Eff[%p] EffCont[%p]\n", (void*)hEff, (void*)hEffCont);
248 TCanvas *c2 = new TCanvas("c2","",800,400);
252 hEff->DrawCopy("e1");
254 hEffCont->DrawCopy("e1");*/