Adding stream level and debug streamer to the base class
[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*/) {
ae28e92e 106 TIterator *i=fCalibJobs.MakeIterator();
107 AliTPCcalibBase *job;
108 while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
109 job->Terminate();
73d51118 110}
111
112// we could have been living inside a master class...
113void AliTPCAnalysisTaskcalib::Process(AliESDEvent *event) {
114 TIterator *i=fCalibJobs.MakeIterator();
115 AliTPCcalibBase *job;
0db06ea6 116 while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
73d51118 117 job->Process(event);
118}
119
120void AliTPCAnalysisTaskcalib::Process(AliTPCseed *track) {
121 TIterator *i=fCalibJobs.MakeIterator();
122 AliTPCcalibBase *job;
0db06ea6 123 while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
73d51118 124 job->Process(track);
125}
126
127Long64_t AliTPCAnalysisTaskcalib::Merge(TCollection *li) {
128 TIterator *i=fCalibJobs.MakeIterator();
129 AliTPCcalibBase *job;
130 Long64_t n=0;
0db06ea6 131 while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
73d51118 132 n+=job->Merge(li);
133 return n;
134}
135
136void AliTPCAnalysisTaskcalib::Analyze() {
137 TIterator *i=fCalibJobs.MakeIterator();
138 AliTPCcalibBase *job;
0db06ea6 139 while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
73d51118 140 job->Analyze();
141}