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