From 73d5111818310f20b67d41dad87711271311d5de Mon Sep 17 00:00:00 2001 From: marian Date: Thu, 24 Apr 2008 14:56:12 +0000 Subject: [PATCH] Adding task encapsulated TPC calibration components using tracks (Marian) --- TPC/AliTPCAnalysisTaskcalib.cxx | 136 ++++++++++++++++++++++++++++++++ TPC/AliTPCAnalysisTaskcalib.h | 43 ++++++++++ 2 files changed, 179 insertions(+) create mode 100644 TPC/AliTPCAnalysisTaskcalib.cxx create mode 100644 TPC/AliTPCAnalysisTaskcalib.h diff --git a/TPC/AliTPCAnalysisTaskcalib.cxx b/TPC/AliTPCAnalysisTaskcalib.cxx new file mode 100644 index 00000000000..a7e89bf564f --- /dev/null +++ b/TPC/AliTPCAnalysisTaskcalib.cxx @@ -0,0 +1,136 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + + +/////////////////////////////////////////////////////////////////////////////// +// // +// blaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa // +// // +/////////////////////////////////////////////////////////////////////////////// +#include "AliTPCAnalysisTaskcalib.h" +#include "TChain.h" +#include "AliTPCcalibBase.h" +#include "AliESDEvent.h" +#include "AliESDfriend.h" +#include "AliESDfriendTrack.h" +#include "AliTPCseed.h" +#include "AliESDInputHandler.h" +#include "AliAnalysisManager.h" + +ClassImp(AliTPCAnalysisTaskcalib) + +AliTPCAnalysisTaskcalib::AliTPCAnalysisTaskcalib(const char *name) + :AliAnalysisTask(name,""), + fCalibJobs(0), + fESD(0) +{ + // + // Constructor + // + DefineInput(0, TChain::Class()); + DefineOutput(0, TObjArray::Class()); +} + +AliTPCAnalysisTaskcalib::~AliTPCAnalysisTaskcalib() { + // + // destructor + // +} + +void AliTPCAnalysisTaskcalib::Exec(Option_t *) { + // + // Exec function + // Loop over tracks and call Process function + if (!fESD) { + Printf("ERROR: fESD not available"); + return; + } + fESDfriend=static_cast(fESD->FindListObject("AliESDfriend")); + if (!fESDfriend) { + Printf("ERROR: fESDfriend not available"); + return; + } + Int_t n=fESD->GetNumberOfTracks(); + for (Int_t i=0;iGetTrack(i); + TObject *calibObject; + AliTPCseed *seed=0; + for (Int_t j=0;calibObject=friendTrack->GetCalibObject(j);++j) + if (seed=dynamic_cast(calibObject)) + break; + if (seed) + Process(seed); + } + PostData(0,&fCalibJobs); +} + +void AliTPCAnalysisTaskcalib::ConnectInputData(Option_t *) { + // + // + // + TTree* tree=dynamic_cast(GetInputData(0)); + if (!tree) { + Printf("ERROR: Could not read chain from input slot 0"); + } + else { + AliESDInputHandler *esdH = dynamic_cast (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); + if (!esdH) { + Printf("ERROR: Could not get ESDInputHandler"); + } + else { + fESD = esdH->GetEvent(); + Printf("*** CONNECTED NEW EVENT ****"); + } + } +} + +void AliTPCAnalysisTaskcalib::CreateOutputObjects() { + // + // + // +} +void AliTPCAnalysisTaskcalib::Terminate(Option_t *option) { +} + +// we could have been living inside a master class... +void AliTPCAnalysisTaskcalib::Process(AliESDEvent *event) { + TIterator *i=fCalibJobs.MakeIterator(); + AliTPCcalibBase *job; + while (job=dynamic_cast(i->Next())) + job->Process(event); +} + +void AliTPCAnalysisTaskcalib::Process(AliTPCseed *track) { + TIterator *i=fCalibJobs.MakeIterator(); + AliTPCcalibBase *job; + while (job=dynamic_cast(i->Next())) + job->Process(track); +} + +Long64_t AliTPCAnalysisTaskcalib::Merge(TCollection *li) { + TIterator *i=fCalibJobs.MakeIterator(); + AliTPCcalibBase *job; + Long64_t n=0; + while (job=dynamic_cast(i->Next())) + n+=job->Merge(li); + return n; +} + +void AliTPCAnalysisTaskcalib::Analyze() { + TIterator *i=fCalibJobs.MakeIterator(); + AliTPCcalibBase *job; + while (job=dynamic_cast(i->Next())) + job->Analyze(); +} diff --git a/TPC/AliTPCAnalysisTaskcalib.h b/TPC/AliTPCAnalysisTaskcalib.h new file mode 100644 index 00000000000..c81cc362176 --- /dev/null +++ b/TPC/AliTPCAnalysisTaskcalib.h @@ -0,0 +1,43 @@ +#ifndef ALIANALYSISTASKTPCCALIB_H +#define ALIANALYSISTASKTPCCALIB_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +//// +//// +//// + +#include "AliAnalysisTask.h" +#include "TObjArray.h" +#include "AliTPCcalibBase.h" +class AliESDEvent; +class AliESDfriend; +class AliTPCseed; + +class AliTPCAnalysisTaskcalib:public AliAnalysisTask { +public: + AliTPCAnalysisTaskcalib(const char *name); + virtual ~AliTPCAnalysisTaskcalib(); + void AddJob(AliTPCcalibBase *job) {fCalibJobs.Add(job);} + TObjArray* GetJobs() {return &fCalibJobs;} + + virtual void ConnectInputData(Option_t *option); + virtual void CreateOutputObjects(); + virtual void Exec(Option_t *option); + virtual void Terminate(Option_t *option); +protected: + virtual void Process(AliESDEvent *event); + virtual void Process(AliTPCseed *track); + virtual Long64_t Merge(TCollection *li); + virtual void Analyze(); +private: + TObjArray fCalibJobs; + AliESDEvent *fESD; + AliESDfriend *fESDfriend; + AliTPCAnalysisTaskcalib(const AliTPCAnalysisTaskcalib&); + AliTPCAnalysisTaskcalib& operator=(const AliTPCAnalysisTaskcalib&); + ClassDef(AliTPCAnalysisTaskcalib,1) +}; + +#endif -- 2.43.5