]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCAnalysisTaskcalib.cxx
Temporary solution to set RecoParam for the reconstruction
[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 // 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
32 ClassImp(AliTPCAnalysisTaskcalib)
33
34 AliTPCAnalysisTaskcalib::AliTPCAnalysisTaskcalib(const char *name) 
35   :AliAnalysisTask(name,""),
36    fCalibJobs(0),
37    fESD(0),
38    fESDfriend(0)
39 {
40   //
41   // Constructor
42   //
43   DefineInput(0, TChain::Class());
44   DefineOutput(0, TObjArray::Class());
45   fCalibJobs.SetOwner(kTRUE);
46 }
47
48 AliTPCAnalysisTaskcalib::~AliTPCAnalysisTaskcalib() {
49   //
50   // destructor
51   //
52   fCalibJobs.Delete();
53 }
54
55 void 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);
71     TObject *calibObject=0;
72     AliTPCseed *seed=0;
73     for (Int_t j=0;(calibObject=friendTrack->GetCalibObject(j));++j)
74       if ((seed=dynamic_cast<AliTPCseed*>(calibObject)))
75         break;
76     if (seed)
77       Process(seed);
78   }
79   PostData(0,&fCalibJobs);
80 }
81
82 void 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
102 void AliTPCAnalysisTaskcalib::CreateOutputObjects() {
103   //
104   //
105   //
106 }
107 void AliTPCAnalysisTaskcalib::Terminate(Option_t */*option*/) {
108   //
109   // Terminate
110   //
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();
116   }
117 }
118
119 void AliTPCAnalysisTaskcalib::Process(AliESDEvent *event) {
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   }
129 }
130
131 void AliTPCAnalysisTaskcalib::Process(AliTPCseed *track) {
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   }
141 }
142
143 Long64_t AliTPCAnalysisTaskcalib::Merge(TCollection *li) {
144   TIterator *i=fCalibJobs.MakeIterator();
145   AliTPCcalibBase *job;
146   Long64_t n=0;
147   while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
148     n+=job->Merge(li);
149   return n;
150 }
151
152 void AliTPCAnalysisTaskcalib::Analyze() {
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   }
162 }