]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCAnalysisTaskcalib.cxx
Class for TPC dedx calibration using the selection with V0 topology.
[u/mrichter/AliRoot.git] / TPC / AliTPCAnalysisTaskcalib.cxx
CommitLineData
73d51118 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
17///////////////////////////////////////////////////////////////////////////////
18// //
fc492d0d 19// ANALYSIS task to perrorm TPC calibration //
20
73d51118 21// //
22///////////////////////////////////////////////////////////////////////////////
23#include "AliTPCAnalysisTaskcalib.h"
24#include "TChain.h"
25#include "AliTPCcalibBase.h"
26#include "AliESDEvent.h"
27#include "AliESDfriend.h"
f7f33dec 28#include "AliESDtrack.h"
73d51118 29#include "AliESDfriendTrack.h"
30#include "AliTPCseed.h"
31#include "AliESDInputHandler.h"
32#include "AliAnalysisManager.h"
33
34ClassImp(AliTPCAnalysisTaskcalib)
35
f7f33dec 36
37AliTPCAnalysisTaskcalib::AliTPCAnalysisTaskcalib()
38 :AliAnalysisTask(),
39 fCalibJobs(0),
40 fESD(0),
41 fESDfriend(0),
42 fDebugOutputPath()
43{
44 //
45 // default constructor
46 //
47
48}
49
50
73d51118 51AliTPCAnalysisTaskcalib::AliTPCAnalysisTaskcalib(const char *name)
52 :AliAnalysisTask(name,""),
53 fCalibJobs(0),
0db06ea6 54 fESD(0),
f7f33dec 55 fESDfriend(0),
56 fDebugOutputPath()
73d51118 57{
58 //
59 // Constructor
60 //
61 DefineInput(0, TChain::Class());
62 DefineOutput(0, TObjArray::Class());
f7f33dec 63 fCalibJobs = new TObjArray(0);
64 fCalibJobs->SetOwner(kFALSE);
73d51118 65}
66
67AliTPCAnalysisTaskcalib::~AliTPCAnalysisTaskcalib() {
68 //
69 // destructor
70 //
f7f33dec 71 printf("AliTPCAnalysisTaskcalib::~AliTPCAnalysisTaskcalib");
72 //fCalibJobs->Delete();
73d51118 73}
74
75void AliTPCAnalysisTaskcalib::Exec(Option_t *) {
76 //
77 // Exec function
78 // Loop over tracks and call Process function
79 if (!fESD) {
2acad464 80 //Printf("ERROR: fESD not available");
73d51118 81 return;
82 }
83 fESDfriend=static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));
84 if (!fESDfriend) {
2acad464 85 //Printf("ERROR: fESDfriend not available");
73d51118 86 return;
87 }
88 Int_t n=fESD->GetNumberOfTracks();
f7f33dec 89 Process(fESD);
5822e507 90 Int_t run = fESD->GetRunNumber();
73d51118 91 for (Int_t i=0;i<n;++i) {
92 AliESDfriendTrack *friendTrack=fESDfriend->GetTrack(i);
f7f33dec 93 AliESDtrack *track=fESD->GetTrack(i);
0db06ea6 94 TObject *calibObject=0;
73d51118 95 AliTPCseed *seed=0;
0db06ea6 96 for (Int_t j=0;(calibObject=friendTrack->GetCalibObject(j));++j)
97 if ((seed=dynamic_cast<AliTPCseed*>(calibObject)))
73d51118 98 break;
5822e507 99 if (track) Process(track, run);
73d51118 100 if (seed)
101 Process(seed);
102 }
f7f33dec 103 PostData(0,fCalibJobs);
73d51118 104}
105
106void AliTPCAnalysisTaskcalib::ConnectInputData(Option_t *) {
107 //
108 //
109 //
110 TTree* tree=dynamic_cast<TTree*>(GetInputData(0));
111 if (!tree) {
2acad464 112 //Printf("ERROR: Could not read chain from input slot 0");
73d51118 113 }
114 else {
115 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
116 if (!esdH) {
2acad464 117 //Printf("ERROR: Could not get ESDInputHandler");
73d51118 118 }
119 else {
120 fESD = esdH->GetEvent();
684602c8 121 //Printf("*** CONNECTED NEW EVENT ****");
73d51118 122 }
123 }
124}
125
126void AliTPCAnalysisTaskcalib::CreateOutputObjects() {
127 //
128 //
129 //
130}
0db06ea6 131void AliTPCAnalysisTaskcalib::Terminate(Option_t */*option*/) {
7eaa723e 132 //
08825fb4 133 // Terminate
7eaa723e 134 //
08825fb4 135 AliTPCcalibBase *job=0;
f7f33dec 136 Int_t njobs = fCalibJobs->GetEntriesFast();
08825fb4 137 for (Int_t i=0;i<njobs;i++){
f7f33dec 138 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
08825fb4 139 if (job) job->Terminate();
7eaa723e 140 }
73d51118 141}
142
f7f33dec 143void AliTPCAnalysisTaskcalib::FinishTaskOutput()
144{
145 //
146 // According description in AliAnalisysTask this method is call
147 // on the slaves before sending data
148 //
149 Terminate("slave");
150 RegisterDebugOutput();
151}
152
153
73d51118 154void AliTPCAnalysisTaskcalib::Process(AliESDEvent *event) {
08825fb4 155 //
156 // Process ESD event
157 //
158 AliTPCcalibBase *job=0;
f7f33dec 159 Int_t njobs = fCalibJobs->GetEntriesFast();
08825fb4 160 for (Int_t i=0;i<njobs;i++){
f7f33dec 161 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
08825fb4 162 if (job) job->Process(event);
163 }
73d51118 164}
165
166void AliTPCAnalysisTaskcalib::Process(AliTPCseed *track) {
08825fb4 167 //
168 // Process TPC track
169 //
170 AliTPCcalibBase *job=0;
f7f33dec 171 Int_t njobs = fCalibJobs->GetEntriesFast();
08825fb4 172 for (Int_t i=0;i<njobs;i++){
f7f33dec 173 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
174 if (job) job->Process(track);
175 }
176}
177
5822e507 178void AliTPCAnalysisTaskcalib::Process(AliESDtrack *track, Int_t run) {
f7f33dec 179 //
180 // Process ESD track
181 //
182 AliTPCcalibBase *job=0;
183 Int_t njobs = fCalibJobs->GetEntriesFast();
184 for (Int_t i=0;i<njobs;i++){
185 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
5822e507 186 if (job) job->Process(track,run);
08825fb4 187 }
73d51118 188}
189
190Long64_t AliTPCAnalysisTaskcalib::Merge(TCollection *li) {
f7f33dec 191 TIterator *i=fCalibJobs->MakeIterator();
73d51118 192 AliTPCcalibBase *job;
193 Long64_t n=0;
0db06ea6 194 while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
73d51118 195 n+=job->Merge(li);
196 return n;
197}
198
199void AliTPCAnalysisTaskcalib::Analyze() {
08825fb4 200 //
201 // Analyze the content of the task
202 //
203 AliTPCcalibBase *job=0;
f7f33dec 204 Int_t njobs = fCalibJobs->GetEntriesFast();
08825fb4 205 for (Int_t i=0;i<njobs;i++){
f7f33dec 206 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
08825fb4 207 if (job) job->Analyze();
208 }
73d51118 209}
f7f33dec 210
211
212void AliTPCAnalysisTaskcalib::RegisterDebugOutput(){
213 //
214 //
215 //
216 AliTPCcalibBase *job=0;
217 Int_t njobs = fCalibJobs->GetEntriesFast();
218 for (Int_t i=0;i<njobs;i++){
219 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
220 if (job) job->RegisterDebugOutput(fDebugOutputPath.Data());
221 }
222}