]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCAnalysisTaskcalib.cxx
- Small fix for CAF that messed-up user tasks after filters
[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());
08825fb4 45 fCalibJobs.SetOwner(kTRUE);
73d51118 46}
47
48AliTPCAnalysisTaskcalib::~AliTPCAnalysisTaskcalib() {
49 //
50 // destructor
51 //
08825fb4 52 fCalibJobs.Delete();
73d51118 53}
54
55void AliTPCAnalysisTaskcalib::Exec(Option_t *) {
56 //
57 // Exec function
58 // Loop over tracks and call Process function
59 if (!fESD) {
60 Printf("ERROR: fESD not available");
61 return;
62 }
63 fESDfriend=static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));
64 if (!fESDfriend) {
65 Printf("ERROR: fESDfriend not available");
66 return;
67 }
68 Int_t n=fESD->GetNumberOfTracks();
69 for (Int_t i=0;i<n;++i) {
70 AliESDfriendTrack *friendTrack=fESDfriend->GetTrack(i);
0db06ea6 71 TObject *calibObject=0;
73d51118 72 AliTPCseed *seed=0;
0db06ea6 73 for (Int_t j=0;(calibObject=friendTrack->GetCalibObject(j));++j)
74 if ((seed=dynamic_cast<AliTPCseed*>(calibObject)))
73d51118 75 break;
76 if (seed)
77 Process(seed);
78 }
79 PostData(0,&fCalibJobs);
80}
81
82void AliTPCAnalysisTaskcalib::ConnectInputData(Option_t *) {
83 //
84 //
85 //
86 TTree* tree=dynamic_cast<TTree*>(GetInputData(0));
87 if (!tree) {
88 Printf("ERROR: Could not read chain from input slot 0");
89 }
90 else {
91 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
92 if (!esdH) {
93 Printf("ERROR: Could not get ESDInputHandler");
94 }
95 else {
96 fESD = esdH->GetEvent();
97 Printf("*** CONNECTED NEW EVENT ****");
98 }
99 }
100}
101
102void AliTPCAnalysisTaskcalib::CreateOutputObjects() {
103 //
104 //
105 //
106}
0db06ea6 107void AliTPCAnalysisTaskcalib::Terminate(Option_t */*option*/) {
7eaa723e 108 //
08825fb4 109 // Terminate
7eaa723e 110 //
08825fb4 111 AliTPCcalibBase *job=0;
112 Int_t njobs = fCalibJobs.GetEntriesFast();
113 for (Int_t i=0;i<njobs;i++){
114 job = (AliTPCcalibBase*)fCalibJobs.UncheckedAt(i);
115 if (job) job->Terminate();
7eaa723e 116 }
73d51118 117}
118
73d51118 119void AliTPCAnalysisTaskcalib::Process(AliESDEvent *event) {
08825fb4 120 //
121 // Process ESD event
122 //
123 AliTPCcalibBase *job=0;
124 Int_t njobs = fCalibJobs.GetEntriesFast();
125 for (Int_t i=0;i<njobs;i++){
126 job = (AliTPCcalibBase*)fCalibJobs.UncheckedAt(i);
127 if (job) job->Process(event);
128 }
73d51118 129}
130
131void AliTPCAnalysisTaskcalib::Process(AliTPCseed *track) {
08825fb4 132 //
133 // Process TPC track
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->Process(track);
140 }
73d51118 141}
142
143Long64_t AliTPCAnalysisTaskcalib::Merge(TCollection *li) {
144 TIterator *i=fCalibJobs.MakeIterator();
145 AliTPCcalibBase *job;
146 Long64_t n=0;
0db06ea6 147 while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
73d51118 148 n+=job->Merge(li);
149 return n;
150}
151
152void AliTPCAnalysisTaskcalib::Analyze() {
08825fb4 153 //
154 // Analyze the content of the task
155 //
156 AliTPCcalibBase *job=0;
157 Int_t njobs = fCalibJobs.GetEntriesFast();
158 for (Int_t i=0;i<njobs;i++){
159 job = (AliTPCcalibBase*)fCalibJobs.UncheckedAt(i);
160 if (job) job->Analyze();
161 }
73d51118 162}