#pragma link C++ class AliD0toKpi+;
#pragma link C++ class AliD0toKpiAnalysis+;
+#pragma link C++ class AliRunAnalysis+;
+#pragma link C++ class AliAnalysis+;
+
+#pragma link C++ class AliFlowAnalysis+;
+
+#pragma link C++ class AliEventCut+;
#endif
--- /dev/null
+#include "AliAnalysis.h"
+//________________________________
+///////////////////////////////////////////////////////////
+//
+// class AliAnalysis
+//
+// Base class for analysis
+//
+//
+// Piotr.Skowronski@cern.ch
+//
+///////////////////////////////////////////////////////////
+
+
+ClassImp(AliAnalysis)
+
+Int_t AliAnalysis::fgkDebug = 0;
+
+AliAnalysis::AliAnalysis()
+{
+
+}
+/*********************************************************/
+
+AliAnalysis::AliAnalysis(const char* name,const char* title)
+{
+}
+/*********************************************************/
+
+AliAnalysis::~AliAnalysis()
+{
+}
+/*********************************************************/
+
--- /dev/null
+#ifndef ALIANALYSIS_H
+#define ALIANALYSIS_H
+//________________________________
+///////////////////////////////////////////////////////////
+//
+// class AliAnalysis
+//
+// Base class for analysis
+//
+//
+// Piotr.Skowronski@cern.ch
+//
+///////////////////////////////////////////////////////////
+
+#include <TTask.h>
+
+class AliESD;
+class AliStack;
+
+class AliAnalysis: public TTask
+{
+ public:
+ AliAnalysis();
+ AliAnalysis(const char* name,const char* title);
+ virtual ~AliAnalysis();
+
+ virtual Int_t Init() = 0;
+ virtual Int_t ProcessEvent(AliESD* esd, AliStack* stack = 0x0) = 0;
+ virtual Int_t Finish() = 0;
+
+
+ static Int_t GetDebug() {return fgkDebug;}
+ static void SetDebug(Int_t level) {fgkDebug = level;}
+
+ protected:
+
+ private:
+ static Int_t fgkDebug;//! debug level
+ ClassDef(AliAnalysis,1)
+};
+
+#endif
--- /dev/null
+#include "AliBaseEventCut.h"
+//________________________________
+///////////////////////////////////////////////////////////
+//
+// class AliBaseEventCut
+//
+//
+//
+//
+///////////////////////////////////////////////////////////
+
+#include <AliESDtrack.h>
+#include <AliESD.h>
+ClassImp(AliBaseEventCut)
+
+AliBaseEventCut::AliBaseEventCut():
+ fMin(0.0),
+ fMax(0.0),
+{
+
+}
+/**********************************************************/
+
+Bool_t AliBaseEventCut::Pass(AliESD* esd) const
+{
+ if ( (GetValue() < fMin) || (GetValue() > fMax) ) return kTRUE;
+ return kFALSE;
+{
+/**********************************************************/
--- /dev/null
+#ifndef ALIBASEEVENTCUT_H
+#define ALIBASEEVENTCUT_H
+//________________________________
+///////////////////////////////////////////////////////////
+//
+// class AliBaseEventCut
+//
+// Base class for cauts that checks only one event property
+//
+// Piotr.Skowronski@cern.ch
+//
+///////////////////////////////////////////////////////////
+
+#include "TObject.h"
+
+class AliESD;
+
+class AliBaseEventCut: public TObject
+{
+ public:
+ AliBaseEventCut();
+ virtual ~AliBaseEventCut(){}
+
+ virtual Bool_t Pass(AliESD* esd) const;//returns kTRUE if rejected
+ protected:
+ virtual Double_t GetValue(AliESD* esd) const = 0;
+
+ Double_t fMin;//Minimum value
+ Double_t fMax;//Maximum value
+ private:
+ ClassDef(AliBaseEventCut,1)
+};
+
+#endif
--- /dev/null
+#include "AliEventCut.h"
+//________________________________
+///////////////////////////////////////////////////////////
+//
+// class AliRunAnalysis
+//
+//
+//
+//
+///////////////////////////////////////////////////////////
+
+#include <TObjArray.h>
+//#include <TIter.h>
+
+#include "AliBaseEventCut.h"
+
+AliEventCut::AliEventCut():
+ fBaseCuts(0x0)
+{
+//costructor
+
+}
+/*********************************************************/
+
+AliEventCut::~AliEventCut()
+{
+//costructor
+ delete fBaseCuts;
+}
+
+/*********************************************************/
+
+Bool_t AliEventCut::Pass(AliESD* esd) const
+{
+ //returns kTRUE if rejected
+ TIter iter(fBaseCuts);
+ AliBaseEventCut* becut;
+ while (( becut = (AliBaseEventCut*)iter() ))
+ {
+ if (becut->Pass(esd)) return kTRUE;
+ }
+ return kFALSE;
+}
--- /dev/null
+#ifndef ALIEVENTCUT_H
+#define ALIEVENTCUT_H
+//________________________________
+///////////////////////////////////////////////////////////
+//
+// class AliRunAnalysis
+//
+//
+//
+//
+///////////////////////////////////////////////////////////
+
+#include "TObject.h"
+
+class AliESD;
+class TObjArray;
+
+class AliEventCut: public TObject
+{
+ public:
+ AliEventCut();
+ virtual ~AliEventCut();
+
+ virtual Bool_t Pass(AliESD* esd) const;//returns kTRUE if rejected
+
+ protected:
+ TObjArray* fBaseCuts;
+ private:
+ ClassDef(AliEventCut,1)
+};
+
+#endif
--- /dev/null
+#include "AliFlowAnalysis.h"
+//________________________________
+///////////////////////////////////////////////////////////
+//
+// class AliFlowAnalysis
+//
+// Flow Analysis
+//
+//
+// S.Radomski@gsi.de
+// Piotr.Skowronski@cern.ch
+//
+///////////////////////////////////////////////////////////
+/*********************************************************/
+
+#include <TString.h>
+#include <TParticle.h>
+
+#include <AliStack.h>
+#include <AliESDtrack.h>
+#include <AliESD.h>
+
+ClassImp(AliFlowAnalysis)
+
+Int_t AliFlowAnalysis::Init()
+{
+ //Initilizes anaysis
+ Info("Init","");
+ return 0;
+}
+
+/*********************************************************/
+
+Int_t AliFlowAnalysis::ProcessEvent(AliESD* esd, AliStack* stack)
+{
+
+ Info("ProcessEvent","Stack address %#x",stack);
+ Double_t psi = GetEventPlane(esd);
+ Info("ProcessEvent","Event plane is %f",psi);
+ return 0;
+
+}
+/*********************************************************/
+
+Int_t AliFlowAnalysis::Finish()
+{
+ //Finish analysis and writes results
+ Info("Init","Finish");
+ return 0;
+}
+/*********************************************************/
+
+Double_t AliFlowAnalysis::GetEventPlane(AliESD* esd)
+{
+ //returns event plane
+ Double_t psi;
+ Int_t mult = esd->GetNumberOfTracks();
+
+ Double_t ssin = 0, scos = 0;
+
+ for (Int_t i=0; i<mult; i++)
+ {
+ AliESDtrack* esdtrack = esd->GetTrack(i);
+ if (esdtrack == 0x0)
+ {
+ ::Error("GetEventPlane","Can not get track %d", i);
+ continue;
+ }
+
+ Double_t mom[3];//momentum
+ esdtrack->GetPxPyPz(mom);
+ Double_t phi = TMath::Pi()+TMath::ATan2(-mom[1],-mom[0]);
+
+ ssin += TMath::Sin( 2.0 * phi );
+ scos += TMath::Cos( 2.0 * phi );
+ }
+
+ psi = atan2 (ssin, scos) / 2.0;
+ psi = psi * 180. / TMath::Pi();
+
+ return psi;
+
+}
--- /dev/null
+#ifndef ALIFLOWANALYSIS_H
+#define ALIFLOWANALYSIS_H
+//________________________________
+///////////////////////////////////////////////////////////
+//
+// class AliFlowAnalysis
+//
+// Flow Analysis
+//
+//
+// S.Radomski@gsi.de
+// Piotr.Skowronski@cern.ch
+//
+///////////////////////////////////////////////////////////
+
+#include "AliAnalysis.h"
+
+class AliESD;
+class AliStack;
+
+class AliFlowAnalysis: public AliAnalysis
+{
+ public:
+ AliFlowAnalysis(){}
+ ~AliFlowAnalysis(){}
+
+ Int_t Init();
+ Int_t ProcessEvent(AliESD* esd, AliStack* stack = 0x0);
+ Int_t Finish();
+
+ static Double_t GetEventPlane(AliESD* esd);
+
+ protected:
+
+ private:
+
+ ClassDef(AliFlowAnalysis,1)
+};
+
+#endif
--- /dev/null
+#include "AliRunAnalysis.h"
+//________________________________
+///////////////////////////////////////////////////////////
+//
+// class AliRunAnalysis
+//
+//
+//
+// Piotr.Skowronski@cern.ch
+//
+///////////////////////////////////////////////////////////
+
+#include <stdlib.h>
+
+#include <TString.h>
+#include <TObjString.h>
+#include <TClass.h>
+#include <TFile.h>
+#include <TKey.h>
+#include <TObjArray.h>
+
+#include <AliRun.h>
+#include <AliRunLoader.h>
+#include <AliStack.h>
+#include <AliESDtrack.h>
+#include <AliESD.h>
+
+#include "AliEventCut.h"
+
+const TString AliRunAnalysis::fgkDefaultRunAnalysisName("RunAnalysis");
+
+ClassImp(AliRunAnalysis)
+AliRunAnalysis::AliRunAnalysis():
+ TTask(fgkDefaultRunAnalysisName,"Alice Analysis Manager") ,
+ fDirs(),
+ fEventCut(0x0),
+ fFileName("AliESDs.root"),
+ fReadKinematics(kFALSE)
+{
+ //ctor
+}
+/*********************************************************/
+
+AliRunAnalysis::~AliRunAnalysis()
+{
+ //dtor
+ delete fDirs;
+ delete fAnalysies;
+ delete fEventCut;
+}
+/*********************************************************/
+
+Int_t AliRunAnalysis::Run()
+{
+ //makes analysis
+
+ Int_t currentdir = 0;
+ Int_t ndirs;
+ if (fDirs) //if array with directories is supplied by user
+ {
+ ndirs = fDirs->GetEntries(); //get the number if directories
+ }
+ else
+ {
+ ndirs = 0; //if the array is not supplied read only from current directory
+ }
+
+ /******************************/
+ /* Init Event */
+ /******************************/
+ if (fAnalysies == 0x0)
+ {
+ Info("Run","No analysis present");
+ return 0;
+ }
+
+ for (Int_t an = 0; an < fAnalysies->GetEntries(); an++)
+ {
+ AliAnalysis* analysis = (AliAnalysis*)fAnalysies->At(an);
+ analysis->Init();
+ }
+
+ do
+ {
+ TFile* file = OpenFile(currentdir);
+ if (file == 0x0)
+ {
+ Error("Run","Cannot get File for dir no. %d",currentdir);
+ currentdir++;
+ continue;
+ }
+ AliStack* stack = 0x0;
+ AliRunLoader* rl = 0x0;
+ if (fReadKinematics)
+ {
+ const TString& dirname = GetDirName(currentdir);
+ if (dirname == "")
+ {
+ Error("Run","Can not get directory name");
+ return 0x0;
+ }
+ TString filename = dirname +"/galice.root";
+
+ rl = AliRunLoader::Open(filename);
+ if ( rl == 0x0 )
+ {
+ Error("Run","Can't get Run Loader from dir %s",filename.Data());
+ delete file;
+ currentdir++;
+ continue;
+ }
+ if( rl->LoadHeader() )
+ {
+ Error("Run","Error while loading Header from dir %s",filename.Data());
+ delete file;
+ delete rl;
+ currentdir++;
+ continue;
+ }
+ if( rl->LoadKinematics() )
+ {
+ Error("Run","Error while loading Kinematics from dir %s",filename.Data());
+ delete file;
+ delete rl;
+ currentdir++;
+ continue;
+ }
+ }
+
+ file->cd();
+ TIter keyiter(file->GetListOfKeys());
+ TKey* key;
+ while (( key = (TKey*)keyiter.Next() ))
+ {
+ if (key == 0x0)
+ {
+ if (GetDebug() > 2 )
+ {
+ Info("Run","No more keys.");
+ }
+ break;
+ }
+
+ TObject* esdobj = key->ReadObj();
+ if (esdobj == 0x0)
+ {
+ if (GetDebug() > 2 )
+ {
+ Info("ReadNext","Key read NULL. Key Name is %s",key->GetName());
+ key->Dump();
+ }
+ continue;
+ }
+ if (GetDebug() > 9 ) esdobj->Dump();
+ AliESD* esd = dynamic_cast<AliESD*>(esdobj);
+
+ if (esd == 0x0)
+ {
+ if (GetDebug() > 7 )
+ {
+ Info("ReadNext","It is not an ESD object");
+ }
+ delete esdobj;
+ continue;
+ }
+
+ if (fReadKinematics)
+ {
+ TString esdname(esd->GetName());
+ esdname.ReplaceAll("ESD","");
+ Int_t nev = atoi(esdname);
+ Info("Run","ESD name is %s, Event Number is %d",esd->GetName(),nev);
+ if (rl->GetEvent(nev))
+ {
+ Error("Run","Error occured while RunLoader GetEvent %d",nev);
+ delete esd;
+ continue;
+ }
+ stack = rl->Stack();
+ if (stack == 0x0)
+ {
+ Error("Run","Can not get stack");
+ delete esd;
+ continue;
+ }
+ }
+ /******************************/
+ /* Event Cut */
+ /******************************/
+ if (fEventCut)
+ {
+ if (fEventCut->Pass(esd))
+ {
+ if (GetDebug()) Info("Run","Event rejected by Event Cut");
+ delete esd;
+ continue; //Did not pass the
+ }
+ }
+ /******************************/
+ /* Process Event */
+ /******************************/
+ for (Int_t an = 0; an < fAnalysies->GetEntries(); an++)
+ {
+ AliAnalysis* analysis = (AliAnalysis*)fAnalysies->At(an);
+ analysis->ProcessEvent(esd,stack);
+ }
+ delete esd;
+ }//end of loop over keys in file
+
+ delete file;
+ delete rl;
+ currentdir++;
+
+ }while (currentdir < ndirs);//end of loop over directories
+
+ /******************************/
+ /* Finish Event */
+ /******************************/
+ for (Int_t an = 0; an < fAnalysies->GetEntries(); an++)
+ {
+ AliAnalysis* analysis = (AliAnalysis*)fAnalysies->At(an);
+ analysis->Init();
+ }
+
+ return 0;
+}
+/*********************************************************/
+
+TFile* AliRunAnalysis::OpenFile(Int_t n)
+{
+//opens file with kine tree
+
+ const TString& dirname = GetDirName(n);
+ if (dirname == "")
+ {
+ Error("OpenFiles","Can not get directory name");
+ return 0x0;
+ }
+ TString filename = dirname +"/"+ fFileName;
+ TFile *ret = TFile::Open(filename.Data());
+
+ if ( ret == 0x0)
+ {
+ Error("OpenFiles","Can't open file %s",filename.Data());
+ return 0x0;
+ }
+ if (!ret->IsOpen())
+ {
+ Error("OpenFiles","Can't open file %s",filename.Data());
+ return 0x0;
+ }
+
+ return ret;
+}
+/*********************************************************/
+
+TString& AliRunAnalysis::GetDirName(Int_t entry)
+{
+//returns directory name of next one to read
+ TString* retval;//return value
+ if (fDirs == 0x0)
+ {
+ retval = new TString(".");
+ return *retval;
+ }
+
+ if ( (entry>fDirs->GetEntries()) || (entry<0))//if out of bounds return empty string
+ { //note that entry==0 is accepted even if array is empty (size=0)
+ Error("GetDirName","Name out of bounds");
+ retval = new TString();
+ return *retval;
+ }
+
+ if (fDirs->GetEntries() == 0)
+ {
+ retval = new TString(".");
+ return *retval;
+ }
+
+ TClass *objclass = fDirs->At(entry)->IsA();
+ TClass *stringclass = TObjString::Class();
+
+ TObjString *dir = (TObjString*)objclass->DynamicCast(stringclass,fDirs->At(entry));
+
+ if(dir == 0x0)
+ {
+ Error("GetDirName","Object in TObjArray is not a TObjString or its descendant");
+ retval = new TString();
+ return *retval;
+ }
+ if (gDebug > 0) Info("GetDirName","Returned ok %s",dir->String().Data());
+ return dir->String();
+}
+/*********************************************************/
+
+void AliRunAnalysis::Add(AliAnalysis* a)
+{
+ //adds a to the list of analysis
+ if (fAnalysies == 0x0) fAnalysies = new TObjArray();
+ fAnalysies->Add(a);
+}
--- /dev/null
+#ifndef ALIRUNANALYSIS_H
+#define ALIRUNANALYSIS_H
+//________________________________
+///////////////////////////////////////////////////////////
+//
+// class AliRunAnalysis
+//
+// Analysis manager
+//
+//
+// Piotr.Skowronski@cern.ch
+//
+///////////////////////////////////////////////////////////
+
+class AliEventCut;
+class TObjArray;
+class TFile;
+
+#include <TString.h>
+#include <TTask.h>
+
+#include "AliAnalysis.h"
+
+class AliRunAnalysis: public TTask
+{
+ public:
+ AliRunAnalysis();
+ virtual ~AliRunAnalysis();
+
+ Int_t Run();
+ void Add(AliAnalysis* a);
+ void ReadKinematics(Bool_t flag){fReadKinematics = flag;}
+
+ Int_t GetDebug() {return AliAnalysis::GetDebug();}
+ void SetDirs(TObjArray* dirs){fDirs = dirs;} //sets array directories names;
+ const char* GetName(){return fgkDefaultRunAnalysisName;}
+ protected:
+ TObjArray* fAnalysies;//arry with analysies
+ TObjArray* fDirs;//arry with directories to read data from
+
+ AliEventCut* fEventCut;//event cut
+
+ TString fFileName;//name of the file with ESDs
+ Bool_t fReadKinematics;
+
+ TString& GetDirName(Int_t entry);
+ TFile* OpenFile(Int_t n);
+
+ private:
+ TNamed::SetName;//change SetName to be private
+
+ static const TString fgkDefaultRunAnalysisName;
+ ClassDef(AliRunAnalysis,1)
+};
+
+#endif
-SRCS= AliD0toKpi.cxx AliD0toKpiAnalysis.cxx
+SRCS= AliRunAnalysis.cxx AliAnalysis.cxx AliEventCut.cxx \
+ AliD0toKpi.cxx AliD0toKpiAnalysis.cxx AliFlowAnalysis.cxx
HDRS= $(SRCS:.cxx=.h)