Bug fix - Teminate - as virtula function
[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"
27#include "AliESDfriendTrack.h"
28#include "AliTPCseed.h"
29#include "AliESDInputHandler.h"
30#include "AliAnalysisManager.h"
31
32ClassImp(AliTPCAnalysisTaskcalib)
33
34AliTPCAnalysisTaskcalib::AliTPCAnalysisTaskcalib(const char *name)
35 :AliAnalysisTask(name,""),
36 fCalibJobs(0),
0db06ea6 37 fESD(0),
38 fESDfriend(0)
73d51118 39{
40 //
41 // Constructor
42 //
43 DefineInput(0, TChain::Class());
44 DefineOutput(0, TObjArray::Class());
45}
46
47AliTPCAnalysisTaskcalib::~AliTPCAnalysisTaskcalib() {
48 //
49 // destructor
50 //
51}
52
53void AliTPCAnalysisTaskcalib::Exec(Option_t *) {
54 //
55 // Exec function
56 // Loop over tracks and call Process function
57 if (!fESD) {
58 Printf("ERROR: fESD not available");
59 return;
60 }
61 fESDfriend=static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));
62 if (!fESDfriend) {
63 Printf("ERROR: fESDfriend not available");
64 return;
65 }
66 Int_t n=fESD->GetNumberOfTracks();
67 for (Int_t i=0;i<n;++i) {
68 AliESDfriendTrack *friendTrack=fESDfriend->GetTrack(i);
0db06ea6 69 TObject *calibObject=0;
73d51118 70 AliTPCseed *seed=0;
0db06ea6 71 for (Int_t j=0;(calibObject=friendTrack->GetCalibObject(j));++j)
72 if ((seed=dynamic_cast<AliTPCseed*>(calibObject)))
73d51118 73 break;
74 if (seed)
75 Process(seed);
76 }
77 PostData(0,&fCalibJobs);
78}
79
80void AliTPCAnalysisTaskcalib::ConnectInputData(Option_t *) {
81 //
82 //
83 //
84 TTree* tree=dynamic_cast<TTree*>(GetInputData(0));
85 if (!tree) {
86 Printf("ERROR: Could not read chain from input slot 0");
87 }
88 else {
89 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
90 if (!esdH) {
91 Printf("ERROR: Could not get ESDInputHandler");
92 }
93 else {
94 fESD = esdH->GetEvent();
95 Printf("*** CONNECTED NEW EVENT ****");
96 }
97 }
98}
99
100void AliTPCAnalysisTaskcalib::CreateOutputObjects() {
101 //
102 //
103 //
104}
0db06ea6 105void AliTPCAnalysisTaskcalib::Terminate(Option_t */*option*/) {
7eaa723e 106 //
107 //
108 //
ae28e92e 109 TIterator *i=fCalibJobs.MakeIterator();
110 AliTPCcalibBase *job;
7eaa723e 111 while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next()))){
ae28e92e 112 job->Terminate();
7eaa723e 113 }
73d51118 114}
115
116// we could have been living inside a master class...
117void AliTPCAnalysisTaskcalib::Process(AliESDEvent *event) {
118 TIterator *i=fCalibJobs.MakeIterator();
119 AliTPCcalibBase *job;
0db06ea6 120 while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
73d51118 121 job->Process(event);
122}
123
124void AliTPCAnalysisTaskcalib::Process(AliTPCseed *track) {
125 TIterator *i=fCalibJobs.MakeIterator();
126 AliTPCcalibBase *job;
0db06ea6 127 while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
73d51118 128 job->Process(track);
129}
130
131Long64_t AliTPCAnalysisTaskcalib::Merge(TCollection *li) {
132 TIterator *i=fCalibJobs.MakeIterator();
133 AliTPCcalibBase *job;
134 Long64_t n=0;
0db06ea6 135 while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
73d51118 136 n+=job->Merge(li);
137 return n;
138}
139
140void AliTPCAnalysisTaskcalib::Analyze() {
141 TIterator *i=fCalibJobs.MakeIterator();
142 AliTPCcalibBase *job;
0db06ea6 143 while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
73d51118 144 job->Analyze();
145}