]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCAnalysisTaskcalib.cxx
Updated flags for low flux case (A. Dainese)
[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"
679480d0 33#include "TFile.h"
34#include "TSystem.h"
35#include "TTimeStamp.h"
73d51118 36
37ClassImp(AliTPCAnalysisTaskcalib)
38
f7f33dec 39
40AliTPCAnalysisTaskcalib::AliTPCAnalysisTaskcalib()
41 :AliAnalysisTask(),
42 fCalibJobs(0),
43 fESD(0),
44 fESDfriend(0),
45 fDebugOutputPath()
46{
47 //
48 // default constructor
49 //
50
51}
52
53
73d51118 54AliTPCAnalysisTaskcalib::AliTPCAnalysisTaskcalib(const char *name)
55 :AliAnalysisTask(name,""),
56 fCalibJobs(0),
0db06ea6 57 fESD(0),
f7f33dec 58 fESDfriend(0),
59 fDebugOutputPath()
73d51118 60{
61 //
62 // Constructor
63 //
64 DefineInput(0, TChain::Class());
65 DefineOutput(0, TObjArray::Class());
f7f33dec 66 fCalibJobs = new TObjArray(0);
42a48f93 67 fCalibJobs->SetOwner(kTRUE);
73d51118 68}
69
70AliTPCAnalysisTaskcalib::~AliTPCAnalysisTaskcalib() {
71 //
72 // destructor
73 //
f7f33dec 74 printf("AliTPCAnalysisTaskcalib::~AliTPCAnalysisTaskcalib");
edb92719 75 fCalibJobs->Delete();
73d51118 76}
77
78void AliTPCAnalysisTaskcalib::Exec(Option_t *) {
79 //
80 // Exec function
81 // Loop over tracks and call Process function
82 if (!fESD) {
2acad464 83 //Printf("ERROR: fESD not available");
73d51118 84 return;
85 }
86 fESDfriend=static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));
87 if (!fESDfriend) {
2acad464 88 //Printf("ERROR: fESDfriend not available");
73d51118 89 return;
90 }
91 Int_t n=fESD->GetNumberOfTracks();
f7f33dec 92 Process(fESD);
5822e507 93 Int_t run = fESD->GetRunNumber();
73d51118 94 for (Int_t i=0;i<n;++i) {
95 AliESDfriendTrack *friendTrack=fESDfriend->GetTrack(i);
f7f33dec 96 AliESDtrack *track=fESD->GetTrack(i);
0db06ea6 97 TObject *calibObject=0;
73d51118 98 AliTPCseed *seed=0;
0db06ea6 99 for (Int_t j=0;(calibObject=friendTrack->GetCalibObject(j));++j)
100 if ((seed=dynamic_cast<AliTPCseed*>(calibObject)))
73d51118 101 break;
5822e507 102 if (track) Process(track, run);
73d51118 103 if (seed)
104 Process(seed);
105 }
c51653e8 106 PostData(0,fCalibJobs);
73d51118 107}
108
109void AliTPCAnalysisTaskcalib::ConnectInputData(Option_t *) {
110 //
111 //
112 //
113 TTree* tree=dynamic_cast<TTree*>(GetInputData(0));
114 if (!tree) {
2acad464 115 //Printf("ERROR: Could not read chain from input slot 0");
73d51118 116 }
117 else {
118 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
119 if (!esdH) {
2acad464 120 //Printf("ERROR: Could not get ESDInputHandler");
73d51118 121 }
122 else {
123 fESD = esdH->GetEvent();
684602c8 124 //Printf("*** CONNECTED NEW EVENT ****");
73d51118 125 }
126 }
127}
128
129void AliTPCAnalysisTaskcalib::CreateOutputObjects() {
130 //
131 //
132 //
c51653e8 133 OpenFile(0, "RECREATE");
73d51118 134}
0db06ea6 135void AliTPCAnalysisTaskcalib::Terminate(Option_t */*option*/) {
7eaa723e 136 //
08825fb4 137 // Terminate
7eaa723e 138 //
08825fb4 139 AliTPCcalibBase *job=0;
f7f33dec 140 Int_t njobs = fCalibJobs->GetEntriesFast();
08825fb4 141 for (Int_t i=0;i<njobs;i++){
f7f33dec 142 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
08825fb4 143 if (job) job->Terminate();
7eaa723e 144 }
42a48f93 145
73d51118 146}
147
f7f33dec 148void AliTPCAnalysisTaskcalib::FinishTaskOutput()
149{
150 //
151 // According description in AliAnalisysTask this method is call
152 // on the slaves before sending data
153 //
154 Terminate("slave");
155 RegisterDebugOutput();
679480d0 156
f7f33dec 157}
158
159
73d51118 160void AliTPCAnalysisTaskcalib::Process(AliESDEvent *event) {
08825fb4 161 //
162 // Process ESD event
163 //
164 AliTPCcalibBase *job=0;
f7f33dec 165 Int_t njobs = fCalibJobs->GetEntriesFast();
08825fb4 166 for (Int_t i=0;i<njobs;i++){
f7f33dec 167 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
42a48f93 168 if (job) {
169 job->UpdateEventInfo(event);
c51653e8 170 if (job->AcceptTrigger())
171 job->Process(event);
42a48f93 172 }
08825fb4 173 }
73d51118 174}
175
176void AliTPCAnalysisTaskcalib::Process(AliTPCseed *track) {
08825fb4 177 //
178 // Process TPC track
179 //
180 AliTPCcalibBase *job=0;
f7f33dec 181 Int_t njobs = fCalibJobs->GetEntriesFast();
08825fb4 182 for (Int_t i=0;i<njobs;i++){
f7f33dec 183 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
c51653e8 184 if (job)
185 if (job->AcceptTrigger())
186 job->Process(track);
f7f33dec 187 }
188}
189
5822e507 190void AliTPCAnalysisTaskcalib::Process(AliESDtrack *track, Int_t run) {
f7f33dec 191 //
192 // Process ESD track
193 //
194 AliTPCcalibBase *job=0;
195 Int_t njobs = fCalibJobs->GetEntriesFast();
196 for (Int_t i=0;i<njobs;i++){
197 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
c51653e8 198 if (job)
199 if (job->AcceptTrigger())
200 job->Process(track,run);
08825fb4 201 }
73d51118 202}
203
204Long64_t AliTPCAnalysisTaskcalib::Merge(TCollection *li) {
f7f33dec 205 TIterator *i=fCalibJobs->MakeIterator();
73d51118 206 AliTPCcalibBase *job;
207 Long64_t n=0;
0db06ea6 208 while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
73d51118 209 n+=job->Merge(li);
210 return n;
211}
212
213void AliTPCAnalysisTaskcalib::Analyze() {
08825fb4 214 //
215 // Analyze the content of the task
216 //
217 AliTPCcalibBase *job=0;
f7f33dec 218 Int_t njobs = fCalibJobs->GetEntriesFast();
08825fb4 219 for (Int_t i=0;i<njobs;i++){
f7f33dec 220 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
08825fb4 221 if (job) job->Analyze();
222 }
73d51118 223}
f7f33dec 224
225
226void AliTPCAnalysisTaskcalib::RegisterDebugOutput(){
227 //
228 //
229 //
230 AliTPCcalibBase *job=0;
231 Int_t njobs = fCalibJobs->GetEntriesFast();
232 for (Int_t i=0;i<njobs;i++){
233 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
234 if (job) job->RegisterDebugOutput(fDebugOutputPath.Data());
235 }
679480d0 236 TFile fff("CalibObjects.root","recreate");
c51653e8 237 fCalibJobs->Write("TPCCalib",TObject::kSingleKey);
679480d0 238 fff.Close();
239 //
240 // store - copy debug output to the destination position
241 // currently ONLY for local copy
242 TString dsName="CalibObjects.root";
243 TString dsName2=fDebugOutputPath.Data();
244 gSystem->MakeDirectory(dsName2.Data());
245 dsName2+=gSystem->HostName();
246 gSystem->MakeDirectory(dsName2.Data());
247 dsName2+="/";
248 TTimeStamp s;
249 dsName2+=Int_t(s.GetNanoSec());
250 dsName2+="/";
251 gSystem->MakeDirectory(dsName2.Data());
252 dsName2+=dsName;
253 AliInfo(Form("copy %s\t%s\n",dsName.Data(),dsName2.Data()));
254 printf("copy %s\t%s\n",dsName.Data(),dsName2.Data());
255 TFile::Cp(dsName.Data(),dsName2.Data());
256
f7f33dec 257}