]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/calibration/AliHLTTPCAnalysisTaskcalib.cxx
Update master to aliroot
[u/mrichter/AliRoot.git] / HLT / TPCLib / calibration / AliHLTTPCAnalysisTaskcalib.cxx
CommitLineData
9b99ccf1 1// $Id$
2/**************************************************************************
3 * This file is property of and copyright by the ALICE HLT Project *
4 * ALICE Experiment at CERN, All rights reserved. *
5 * *
6 * Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> *
7 * for The ALICE HLT Project. *
8 * *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
17
18/** @file AliHLTTPCAnalysisTaskcalib.cxx
19 @author Kalliopi Kanaki
20 @date
21 @brief
22*/
23
24// see header file for class documentation
25// or
26// refer to README to build package
27// or
28// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
29
9b99ccf1 30#include "AliHLTTPCAnalysisTaskcalib.h"
31#include "AliTPCcalibBase.h"
32#include "AliESDEvent.h"
33#include "AliESDfriend.h"
34#include "AliESDtrack.h"
35#include "AliESDfriendTrack.h"
36#include "AliTPCseed.h"
37
38#include "AliESDInputHandler.h"
39#include "AliAnalysisManager.h"
40
41#include "TFile.h"
42#include "TSystem.h"
43#include "TTimeStamp.h"
44#include "TChain.h"
45
d5cf9283 46using namespace std;
47
9b99ccf1 48ClassImp(AliHLTTPCAnalysisTaskcalib)
49
50AliHLTTPCAnalysisTaskcalib::AliHLTTPCAnalysisTaskcalib()
51 :
52 AliTPCAnalysisTaskcalib(),
53 fCalibJobs(0),
54 fESD(0),
55 fESDfriend(0),
56 fDebugOutputPath()
57{
58 //
59 // default constructor
60 //
61}
62
63
64AliHLTTPCAnalysisTaskcalib::AliHLTTPCAnalysisTaskcalib(const char *name)
65 :
66 AliTPCAnalysisTaskcalib(name),
67 fCalibJobs(0),
68 fESD(0),
69 fESDfriend(0),
70 fDebugOutputPath()
71{
72 //
73 // Constructor
74 //
75 DefineInput(0, TChain::Class());
76 DefineOutput(0, TObjArray::Class());
77 fCalibJobs = new TObjArray(0);
78 fCalibJobs->SetOwner(kTRUE);
79}
80
81AliHLTTPCAnalysisTaskcalib::~AliHLTTPCAnalysisTaskcalib() {
82 //
83 // destructor
84 //
85 printf("AliHLTTPCAnalysisTaskcalib::~AliHLTTPCAnalysisTaskcalib");
86 fCalibJobs->Delete();
87}
88
89void AliHLTTPCAnalysisTaskcalib::Exec(Option_t *) {
90 //
91 // Exec function
92 // Loop over tracks and call Process function
93 if (!fESD) {
94 //Printf("ERROR: fESD not available");
95 return;
96 }
97 fESDfriend=static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));
98 if (!fESDfriend) {
99 //Printf("ERROR: fESDfriend not available");
100 return;
101 }
102 Int_t n=fESD->GetNumberOfTracks();
103 Process(fESD);
104 Int_t run = fESD->GetRunNumber();
105 for (Int_t i=0;i<n;++i) {
106 AliESDfriendTrack *friendTrack=fESDfriend->GetTrack(i);
107 AliESDtrack *track=fESD->GetTrack(i);
108 TObject *calibObject=0;
109 AliTPCseed *seed=0;
110 if (!friendTrack) continue;
111 for (Int_t j=0;(calibObject=friendTrack->GetCalibObject(j));++j)
112 if ((seed=dynamic_cast<AliTPCseed*>(calibObject)))
113 break;
114 if (track) Process(track, run);
115 if (seed)
116 Process(seed);
117 }
118 PostData(0,fCalibJobs);
119}
120
121void AliHLTTPCAnalysisTaskcalib::ConnectInputData(Option_t *) {
122 //
123 //
124 //
125 TTree* tree=dynamic_cast<TTree*>(GetInputData(0));
126 if (!tree) {
127 //Printf("ERROR: Could not read chain from input slot 0");
128 }
129 else {
130 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
131 if (!esdH) {
132 //Printf("ERROR: Could not get ESDInputHandler");
133 }
134 else {
135 fESD = esdH->GetEvent();
136 //Printf("*** CONNECTED NEW EVENT ****");
137 }
138 }
139}
140
141void AliHLTTPCAnalysisTaskcalib::CreateOutputObjects() {
142 //
143 //
144 //
145 OpenFile(0, "RECREATE");
146}
147void AliHLTTPCAnalysisTaskcalib::Terminate(Option_t */*option*/) {
148 //
149 // Terminate
150 //
151 AliTPCcalibBase *job=0;
152 Int_t njobs = fCalibJobs->GetEntriesFast();
153 for (Int_t i=0;i<njobs;i++){
154 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
155 if (job) job->Terminate();
156 }
157
158}
159
160void AliHLTTPCAnalysisTaskcalib::FinishTaskOutput()
161{
162 //
163 // According description in AliAnalisysTask this method is call
164 // on the slaves before sending data
165 //
166 Terminate("slave");
167 RegisterDebugOutput();
168
169}
170
171
172void AliHLTTPCAnalysisTaskcalib::Process(AliESDEvent *event) {
173 //
174 // Process ESD event
175 //
176 AliTPCcalibBase *job=0;
177
178 Int_t njobs = fCalibJobs->GetEntriesFast();
179 for(Int_t i=0;i<njobs;i++){
180 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
181 if(job){
182 job->UpdateEventInfo(event);
183 if(job->AcceptTrigger()) job->Process(event);
184 }
185 }
186}
187
188void AliHLTTPCAnalysisTaskcalib::Process(AliTPCseed *track) {
189 //
190 // Process TPC track
191 //
192 AliTPCcalibBase *job=0;
193 Int_t njobs = fCalibJobs->GetEntriesFast();
194 for (Int_t i=0;i<njobs;i++){
195 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
196 if (job)
197 if (job->AcceptTrigger())
198 job->Process(track);
199 }
200}
201
202void AliHLTTPCAnalysisTaskcalib::Process(AliESDtrack *track, Int_t run) {
203 //
204 // Process ESD track
205 //
206 AliTPCcalibBase *job=0;
207 Int_t njobs = fCalibJobs->GetEntriesFast();
208 for (Int_t i=0;i<njobs;i++){
209 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
210 if (job)
211 if (job->AcceptTrigger())
212 job->Process(track,run);
213 }
214}
215
216Long64_t AliHLTTPCAnalysisTaskcalib::Merge(TCollection *li) {
217 TIterator *i=fCalibJobs->MakeIterator();
218 AliTPCcalibBase *job;
219 Long64_t n=0;
220 while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
221 n+=job->Merge(li);
222 return n;
223}
224
225void AliHLTTPCAnalysisTaskcalib::Analyze() {
226 //
227 // Analyze the content of the task
228 //
229 AliTPCcalibBase *job=0;
230 Int_t njobs = fCalibJobs->GetEntriesFast();
231 for (Int_t i=0;i<njobs;i++){
232 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
233 if (job) job->Analyze();
234 }
235}
236
237
238void AliHLTTPCAnalysisTaskcalib::RegisterDebugOutput(){
239 //
240 //
241 //
242 AliTPCcalibBase *job=0;
243 Int_t njobs = fCalibJobs->GetEntriesFast();
244 for (Int_t i=0;i<njobs;i++){
245 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
246 if (job) job->RegisterDebugOutput(fDebugOutputPath.Data());
247 }
248 TFile fff("CalibObjects.root","recreate");
249 fCalibJobs->Write("TPCCalib",TObject::kSingleKey);
250 fff.Close();
251 //
252 // store - copy debug output to the destination position
253 // currently ONLY for local copy
254 TString dsName="CalibObjects.root";
255 TString dsName2=fDebugOutputPath.Data();
256 gSystem->MakeDirectory(dsName2.Data());
257 dsName2+=gSystem->HostName();
258 gSystem->MakeDirectory(dsName2.Data());
259 dsName2+="/";
260 TTimeStamp s;
261 dsName2+=Int_t(s.GetNanoSec());
262 dsName2+="/";
263 gSystem->MakeDirectory(dsName2.Data());
264 dsName2+=dsName;
265 AliInfo(Form("copy %s\t%s\n",dsName.Data(),dsName2.Data()));
266 printf("copy %s\t%s\n",dsName.Data(),dsName2.Data());
267 TFile::Cp(dsName.Data(),dsName2.Data());
268
269}