2 /**************************************************************************
3 * This file is property of and copyright by the ALICE HLT Project *
4 * ALICE Experiment at CERN, All rights reserved. *
6 * Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> *
7 * for The ALICE HLT Project. *
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 **************************************************************************/
18 /** @file AliHLTTPCAnalysisTaskcalib.cxx
19 @author Kalliopi Kanaki
24 // see header file for class documentation
26 // refer to README to build package
28 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
34 #include "AliHLTTPCAnalysisTaskcalib.h"
35 #include "AliTPCcalibBase.h"
36 #include "AliESDEvent.h"
37 #include "AliESDfriend.h"
38 #include "AliESDtrack.h"
39 #include "AliESDfriendTrack.h"
40 #include "AliTPCseed.h"
42 #include "AliESDInputHandler.h"
43 #include "AliAnalysisManager.h"
47 #include "TTimeStamp.h"
50 ClassImp(AliHLTTPCAnalysisTaskcalib)
52 AliHLTTPCAnalysisTaskcalib::AliHLTTPCAnalysisTaskcalib()
54 AliTPCAnalysisTaskcalib(),
61 // default constructor
66 AliHLTTPCAnalysisTaskcalib::AliHLTTPCAnalysisTaskcalib(const char *name)
68 AliTPCAnalysisTaskcalib(name),
77 DefineInput(0, TChain::Class());
78 DefineOutput(0, TObjArray::Class());
79 fCalibJobs = new TObjArray(0);
80 fCalibJobs->SetOwner(kTRUE);
83 AliHLTTPCAnalysisTaskcalib::~AliHLTTPCAnalysisTaskcalib() {
87 printf("AliHLTTPCAnalysisTaskcalib::~AliHLTTPCAnalysisTaskcalib");
91 void AliHLTTPCAnalysisTaskcalib::Exec(Option_t *) {
94 // Loop over tracks and call Process function
96 //Printf("ERROR: fESD not available");
99 fESDfriend=static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));
101 //Printf("ERROR: fESDfriend not available");
104 Int_t n=fESD->GetNumberOfTracks();
106 Int_t run = fESD->GetRunNumber();
107 for (Int_t i=0;i<n;++i) {
108 AliESDfriendTrack *friendTrack=fESDfriend->GetTrack(i);
109 AliESDtrack *track=fESD->GetTrack(i);
110 TObject *calibObject=0;
112 if (!friendTrack) continue;
113 for (Int_t j=0;(calibObject=friendTrack->GetCalibObject(j));++j)
114 if ((seed=dynamic_cast<AliTPCseed*>(calibObject)))
116 if (track) Process(track, run);
120 PostData(0,fCalibJobs);
123 void AliHLTTPCAnalysisTaskcalib::ConnectInputData(Option_t *) {
127 TTree* tree=dynamic_cast<TTree*>(GetInputData(0));
129 //Printf("ERROR: Could not read chain from input slot 0");
132 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
134 //Printf("ERROR: Could not get ESDInputHandler");
137 fESD = esdH->GetEvent();
138 //Printf("*** CONNECTED NEW EVENT ****");
143 void AliHLTTPCAnalysisTaskcalib::CreateOutputObjects() {
147 OpenFile(0, "RECREATE");
149 void AliHLTTPCAnalysisTaskcalib::Terminate(Option_t */*option*/) {
153 AliTPCcalibBase *job=0;
154 Int_t njobs = fCalibJobs->GetEntriesFast();
155 for (Int_t i=0;i<njobs;i++){
156 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
157 if (job) job->Terminate();
162 void AliHLTTPCAnalysisTaskcalib::FinishTaskOutput()
165 // According description in AliAnalisysTask this method is call
166 // on the slaves before sending data
169 RegisterDebugOutput();
174 void AliHLTTPCAnalysisTaskcalib::Process(AliESDEvent *event) {
178 AliTPCcalibBase *job=0;
180 Int_t njobs = fCalibJobs->GetEntriesFast();
181 for(Int_t i=0;i<njobs;i++){
182 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
184 job->UpdateEventInfo(event);
185 if(job->AcceptTrigger()) job->Process(event);
190 void AliHLTTPCAnalysisTaskcalib::Process(AliTPCseed *track) {
194 AliTPCcalibBase *job=0;
195 Int_t njobs = fCalibJobs->GetEntriesFast();
196 for (Int_t i=0;i<njobs;i++){
197 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
199 if (job->AcceptTrigger())
204 void AliHLTTPCAnalysisTaskcalib::Process(AliESDtrack *track, Int_t run) {
208 AliTPCcalibBase *job=0;
209 Int_t njobs = fCalibJobs->GetEntriesFast();
210 for (Int_t i=0;i<njobs;i++){
211 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
213 if (job->AcceptTrigger())
214 job->Process(track,run);
218 Long64_t AliHLTTPCAnalysisTaskcalib::Merge(TCollection *li) {
219 TIterator *i=fCalibJobs->MakeIterator();
220 AliTPCcalibBase *job;
222 while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
227 void AliHLTTPCAnalysisTaskcalib::Analyze() {
229 // Analyze the content of the task
231 AliTPCcalibBase *job=0;
232 Int_t njobs = fCalibJobs->GetEntriesFast();
233 for (Int_t i=0;i<njobs;i++){
234 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
235 if (job) job->Analyze();
240 void AliHLTTPCAnalysisTaskcalib::RegisterDebugOutput(){
244 AliTPCcalibBase *job=0;
245 Int_t njobs = fCalibJobs->GetEntriesFast();
246 for (Int_t i=0;i<njobs;i++){
247 job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i);
248 if (job) job->RegisterDebugOutput(fDebugOutputPath.Data());
250 TFile fff("CalibObjects.root","recreate");
251 fCalibJobs->Write("TPCCalib",TObject::kSingleKey);
254 // store - copy debug output to the destination position
255 // currently ONLY for local copy
256 TString dsName="CalibObjects.root";
257 TString dsName2=fDebugOutputPath.Data();
258 gSystem->MakeDirectory(dsName2.Data());
259 dsName2+=gSystem->HostName();
260 gSystem->MakeDirectory(dsName2.Data());
263 dsName2+=Int_t(s.GetNanoSec());
265 gSystem->MakeDirectory(dsName2.Data());
267 AliInfo(Form("copy %s\t%s\n",dsName.Data(),dsName2.Data()));
268 printf("copy %s\t%s\n",dsName.Data(),dsName2.Data());
269 TFile::Cp(dsName.Data(),dsName2.Data());