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