]> git.uio.no Git - u/mrichter/AliRoot.git/blame - CORRFW/test/AliCFSingleTrackTask.cxx
bugfix in calculation of tracklet <theta> for resolution scaling
[u/mrichter/AliRoot.git] / CORRFW / test / AliCFSingleTrackTask.cxx
CommitLineData
563113d0 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//-----------------------------------------------------------------------
3170dff4 17// Example of task (running locally, on AliEn and CAF),
563113d0 18// which provides standard way of calculating acceptance and efficiency
19// between different steps of the procedure.
20// The ouptut of the task is a AliCFContainer from which the efficiencies
21// can be calculated
22//-----------------------------------------------------------------------
23// Author : R. Vernet, Consorzio Cometa - Catania (it)
24//-----------------------------------------------------------------------
25
26
27#ifndef ALICFSINGLETRACKTASK_CXX
28#define ALICFSINGLETRACKTASK_CXX
563113d0 29
30#include "AliCFSingleTrackTask.h"
31#include "TCanvas.h"
32#include "AliStack.h"
33#include "TParticle.h"
34#include "TH1I.h"
563113d0 35#include "AliMCEvent.h"
36#include "AliAnalysisManager.h"
37#include "AliESDEvent.h"
d62f2321 38#include "AliAODEvent.h"
563113d0 39#include "AliCFManager.h"
40#include "AliCFCutBase.h"
41#include "AliCFContainer.h"
42#include "TChain.h"
43#include "AliESDtrack.h"
44#include "AliLog.h"
318a0e1f 45
563113d0 46ClassImp(AliCFSingleTrackTask)
318a0e1f 47
563113d0 48//__________________________________________________________________________
49AliCFSingleTrackTask::AliCFSingleTrackTask() :
d62f2321 50 fReadTPCTracks(0),
51 fReadAODData(0),
563113d0 52 fCFManager(0x0),
53 fQAHistList(0x0),
54 fHistEventsProcessed(0x0)
55{
318a0e1f 56 //
57 //Default ctor
58 //
563113d0 59}
60//___________________________________________________________________________
61AliCFSingleTrackTask::AliCFSingleTrackTask(const Char_t* name) :
318a0e1f 62 AliAnalysisTaskSE(name),
d62f2321 63 fReadTPCTracks(0),
64 fReadAODData(0),
563113d0 65 fCFManager(0x0),
66 fQAHistList(0x0),
67 fHistEventsProcessed(0x0)
68{
69 //
70 // Constructor. Initialization of Inputs and Outputs
71 //
72 Info("AliCFSingleTrackTask","Calling Constructor");
318a0e1f 73
74 /*
75 DefineInput(0) and DefineOutput(0)
76 are taken care of by AliAnalysisTaskSE constructor
77 */
78 DefineOutput(1,TH1I::Class());
79 DefineOutput(2,AliCFContainer::Class());
80 DefineOutput(3,TList::Class());
563113d0 81}
82
83//___________________________________________________________________________
84AliCFSingleTrackTask& AliCFSingleTrackTask::operator=(const AliCFSingleTrackTask& c)
85{
86 //
87 // Assignment operator
88 //
89 if (this!=&c) {
318a0e1f 90 AliAnalysisTaskSE::operator=(c) ;
d62f2321 91 fReadTPCTracks = c.fReadTPCTracks ;
92 fReadAODData = c.fReadAODData ;
563113d0 93 fCFManager = c.fCFManager;
94 fQAHistList = c.fQAHistList ;
95 fHistEventsProcessed = c.fHistEventsProcessed;
96 }
97 return *this;
98}
99
100//___________________________________________________________________________
101AliCFSingleTrackTask::AliCFSingleTrackTask(const AliCFSingleTrackTask& c) :
318a0e1f 102 AliAnalysisTaskSE(c),
d62f2321 103 fReadTPCTracks(c.fReadTPCTracks),
104 fReadAODData(c.fReadAODData),
563113d0 105 fCFManager(c.fCFManager),
106 fQAHistList(c.fQAHistList),
107 fHistEventsProcessed(c.fHistEventsProcessed)
108{
109 //
110 // Copy Constructor
111 //
112}
113
114//___________________________________________________________________________
115AliCFSingleTrackTask::~AliCFSingleTrackTask() {
116 //
117 //destructor
118 //
119 Info("~AliCFSingleTrackTask","Calling Destructor");
563113d0 120 if (fCFManager) delete fCFManager ;
121 if (fHistEventsProcessed) delete fHistEventsProcessed ;
122 if (fQAHistList) {fQAHistList->Clear(); delete fQAHistList;}
123}
124
563113d0 125//_________________________________________________
318a0e1f 126void AliCFSingleTrackTask::UserExec(Option_t *)
563113d0 127{
128 //
129 // Main loop function
130 //
318a0e1f 131 Info("UserExec","") ;
563113d0 132
d62f2321 133 AliVEvent* fEvent = fInputEvent ;
134 AliVParticle* track ;
135
136 if (!fEvent) {
137 Error("UserExec","NO EVENT FOUND!");
318a0e1f 138 return;
139 }
563113d0 140
0c01ae65 141 if (!fMCEvent) {
142 Error("UserExec","NO MC INFO FOUND");
143 return ;
144 }
d62f2321 145
0c01ae65 146 //pass the evt info to the cuts that need it
147 fCFManager->SetMCEventInfo (fMCEvent);
148 fCFManager->SetRecEventInfo(fEvent);
563113d0 149
150 // MC-event selection
1e9dad92 151 Double_t containerInput[2] ;
563113d0 152
153 //loop on the MC event
318a0e1f 154 for (Int_t ipart=0; ipart<fMCEvent->GetNumberOfTracks(); ipart++) {
0c01ae65 155 AliMCParticle *mcPart = (AliMCParticle*)fMCEvent->GetTrack(ipart);
563113d0 156
157 //check the MC-level cuts
158 if (!fCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,mcPart)) continue;
159
160 containerInput[0] = (Float_t)mcPart->Pt();
161 containerInput[1] = mcPart->Eta() ;
162 //fill the container for Gen-level selection
163 fCFManager->GetParticleContainer()->Fill(containerInput,kStepGenerated);
318a0e1f 164
563113d0 165 //check the Acceptance-level cuts
166 if (!fCFManager->CheckParticleCuts(AliCFManager::kPartAccCuts,mcPart)) continue;
167 //fill the container for Acceptance-level selection
168 fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructible);
169 }
170
171 //Now go to rec level
d62f2321 172 for (Int_t iTrack = 0; iTrack<fEvent->GetNumberOfTracks(); iTrack++) {
563113d0 173
d62f2321 174 track = fEvent->GetTrack(iTrack);
175
176 if (fReadTPCTracks) {
177 if (fReadAODData) {
178 Error("UserExec","TPC-only tracks are not supported with AOD");
179 return ;
180 }
181 AliESDtrack* esdTrack = (AliESDtrack*) track;
182 AliESDtrack* esdTrackTPC = new AliESDtrack();
183 if (!esdTrack->FillTPCOnlyTrack(*esdTrackTPC)) {
184 Error("UserExec","Could not retrieve TPC info");
185 continue;
186 }
187 track = esdTrackTPC ;
188 }
563113d0 189
d62f2321 190 if (!fCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,track)) continue;
191
563113d0 192 // is track associated to particle ?
d62f2321 193
194 Int_t label = track->GetLabel();
195
196 if (label<0) continue;
0c01ae65 197 AliMCParticle *mcPart = (AliMCParticle*)fMCEvent->GetTrack(label);
563113d0 198
199 // check if this track was part of the signal
200 if (!fCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,mcPart)) continue;
201
202 //fill the container
203 Double_t mom[3];
d62f2321 204 track->PxPyPz(mom);
563113d0 205 Double_t pt=TMath::Sqrt(mom[0]*mom[0]+mom[1]*mom[1]);
206 containerInput[0] = pt ;
207 containerInput[1] = track->Eta();
208 fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructed) ;
c3417e84 209
563113d0 210 if (!fCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,track)) continue ;
211 fCFManager->GetParticleContainer()->Fill(containerInput,kStepSelected);
d62f2321 212
213 if (fReadTPCTracks) delete track;
563113d0 214 }
215
216 fHistEventsProcessed->Fill(0);
318a0e1f 217
218 /* PostData(0) is taken care of by AliAnalysisTaskSE */
219 PostData(1,fHistEventsProcessed) ;
220 PostData(2,fCFManager->GetParticleContainer()) ;
221 PostData(3,fQAHistList) ;
563113d0 222}
223
224
225//___________________________________________________________________________
226void AliCFSingleTrackTask::Terminate(Option_t*)
227{
228 // The Terminate() function is the last function to be called during
229 // a query. It always runs on the client, it can be used to present
230 // the results graphically or save the results to file.
231
232 Info("Terminate","");
318a0e1f 233 AliAnalysisTaskSE::Terminate();
563113d0 234
3170dff4 235 //draw some example plots....
563113d0 236
318a0e1f 237 AliCFContainer *cont= dynamic_cast<AliCFContainer*> (GetOutputData(2));
238
239 TH1D* h00 = cont->ShowProjection(0,0) ;
240 TH1D* h01 = cont->ShowProjection(0,1) ;
241 TH1D* h02 = cont->ShowProjection(0,2) ;
242 TH1D* h03 = cont->ShowProjection(0,3) ;
563113d0 243
318a0e1f 244 TH1D* h10 = cont->ShowProjection(1,0) ;
245 TH1D* h11 = cont->ShowProjection(1,1) ;
246 TH1D* h12 = cont->ShowProjection(1,2) ;
247 TH1D* h13 = cont->ShowProjection(1,3) ;
563113d0 248
318a0e1f 249 Double_t max1 = h00->GetMaximum();
250 Double_t max2 = h10->GetMaximum();
563113d0 251
318a0e1f 252 h00->GetYaxis()->SetRangeUser(0,max1*1.2);
253 h01->GetYaxis()->SetRangeUser(0,max1*1.2);
254 h02->GetYaxis()->SetRangeUser(0,max1*1.2);
255 h03->GetYaxis()->SetRangeUser(0,max1*1.2);
563113d0 256
318a0e1f 257 h10->GetYaxis()->SetRangeUser(0,max2*1.2);
258 h11->GetYaxis()->SetRangeUser(0,max2*1.2);
259 h12->GetYaxis()->SetRangeUser(0,max2*1.2);
260 h13->GetYaxis()->SetRangeUser(0,max2*1.2);
3170dff4 261
318a0e1f 262 h00->SetMarkerStyle(23) ;
263 h01->SetMarkerStyle(24) ;
264 h02->SetMarkerStyle(25) ;
265 h03->SetMarkerStyle(26) ;
266
267 h10->SetMarkerStyle(23) ;
268 h11->SetMarkerStyle(24) ;
269 h12->SetMarkerStyle(25) ;
270 h13->SetMarkerStyle(26) ;
563113d0 271
272 TCanvas * c =new TCanvas("c","",1400,800);
273 c->Divide(4,2);
274
563113d0 275 c->cd(1);
318a0e1f 276 h00->Draw("p");
563113d0 277 c->cd(2);
318a0e1f 278 h01->Draw("p");
563113d0 279 c->cd(3);
318a0e1f 280 h02->Draw("p");
563113d0 281 c->cd(4);
318a0e1f 282 h03->Draw("p");
563113d0 283 c->cd(5);
318a0e1f 284 h10->Draw("p");
563113d0 285 c->cd(6);
318a0e1f 286 h11->Draw("p");
563113d0 287 c->cd(7);
318a0e1f 288 h12->Draw("p");
563113d0 289 c->cd(8);
318a0e1f 290 h13->Draw("p");
563113d0 291
292 c->SaveAs("plots.eps");
563113d0 293}
294
563113d0 295
296//___________________________________________________________________________
318a0e1f 297void AliCFSingleTrackTask::UserCreateOutputObjects() {
563113d0 298 //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED
299 //TO BE SET BEFORE THE EXECUTION OF THE TASK
300 //
318a0e1f 301 Info("CreateOutputObjects","CreateOutputObjects of task %s", GetName());
563113d0 302
318a0e1f 303 //slot #1
304 OpenFile(1);
563113d0 305 fHistEventsProcessed = new TH1I("fHistEventsProcessed","",1,0,1) ;
306
318a0e1f 307// OpenFile(2);
308// OpenFile(3);
563113d0 309}
310
311#endif