Macros for Lee Yang Zeroes from Naomi van der Kolk
authorsnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 28 Sep 2007 14:16:50 +0000 (14:16 +0000)
committersnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 28 Sep 2007 14:16:50 +0000 (14:16 +0000)
12 files changed:
PWG2/FLOW/macros/AliAnalysisTaskRLLYZ.cxx [new file with mode: 0644]
PWG2/FLOW/macros/AliAnalysisTaskRLLYZ.h [new file with mode: 0644]
PWG2/FLOW/macros/AliAnalysisTaskRLLYZNewMethod.cxx [new file with mode: 0644]
PWG2/FLOW/macros/AliAnalysisTaskRLLYZNewMethod.h [new file with mode: 0644]
PWG2/FLOW/macros/AliSelectorLYZ.cxx [new file with mode: 0644]
PWG2/FLOW/macros/AliSelectorLYZ.h [new file with mode: 0644]
PWG2/FLOW/macros/AliSelectorLYZNewMethod.cxx [new file with mode: 0644]
PWG2/FLOW/macros/AliSelectorLYZNewMethod.h [new file with mode: 0644]
PWG2/FLOW/macros/makeSelectorLYZ.C [new file with mode: 0644]
PWG2/FLOW/macros/makeSelectorNMLYZ.C [new file with mode: 0644]
PWG2/FLOW/macros/makeTaskLYZ.C [new file with mode: 0644]
PWG2/FLOW/macros/makeTaskNMLYZ.C [new file with mode: 0644]

diff --git a/PWG2/FLOW/macros/AliAnalysisTaskRLLYZ.cxx b/PWG2/FLOW/macros/AliAnalysisTaskRLLYZ.cxx
new file mode 100644 (file)
index 0000000..bb3a0c1
--- /dev/null
@@ -0,0 +1,228 @@
+#define AliAnalysisTaskRLLYZ_cxx
+#include <iostream>
+
+
+#include "TChain.h"
+#include "TH1.h"
+#include "TList.h"
+#include "TFile.h"
+#include "TSystem.h"
+#include "TROOT.h"
+#include "TParticle.h"
+
+#include "AliESD.h"
+#include "AliESDtrack.h"
+#include "AliLog.h"
+#include "AliStack.h"
+#include <AliHeader.h>
+#include <AliGenEventHeader.h>
+
+#include "AliAnalysisTaskRL.h"
+#include "AliAnalysisTaskRLLYZ.h"
+#include "AliFlowConstants.h"
+#include "AliFlowLYZConstants.h"
+#include "AliFlowSelection.h"
+#include "AliFlowEvent.h"
+#include "AliFlowMaker.h"
+#include "AliFlowTrack.h"
+#include "AliFlowLeeYangZerosMaker.h"
+
+//#include "TObjectTable.h"
+
+
+
+ClassImp(AliAnalysisTaskRLLYZ)
+
+ //-----------------------------------------------------------------------
+ AliAnalysisTaskRLLYZ::AliAnalysisTaskRLLYZ(const char *name, Bool_t firstrun) :
+   AliAnalysisTaskRL(name,""),
+   fESD(0),
+   fFirstRunLYZ(firstrun), //set boolean for firstrun to initial value
+   fUseSumLYZ(kTRUE)    //set boolean for use sum to initial value
+{
+
+  // Constructor.
+  // Input slot #0 works with an Ntuple
+  DefineInput(0, TChain::Class());
+  if (!firstrun) DefineInput(1, TList::Class()); //for second loop 
+  // Output slot #0 writes into a TList container
+  DefineOutput(0, TList::Class());  
+}
+
+ //-----------------------------------------------------------------------
+
+
+ AliAnalysisTaskRLLYZ::~AliAnalysisTaskRLLYZ() 
+ {
+   //destructor
+   
+ }
+//-----------------------------------------------------------------------
+
+
+void AliAnalysisTaskRLLYZ::ConnectInputData(Option_t *) {
+  // Initialize branches.
+  printf("   ConnectInputData of task %s\n", GetName());
+  //cerr<<"fESD ("<<fESD<<")"<<endl;
+  if (!fESD) {
+    //cerr<<"no fESD"<<endl;
+    char ** address = (char **)GetBranchAddress(0, "ESD");
+    if (address) fESD = (AliESD*)(*address);
+    if (!fESD) {
+      //cerr<<"still no fESD"<<endl;
+      fESD = new AliESD();
+      SetBranchAddress(0, "ESD", &fESD);
+      cerr<<"new fESD"<<endl;
+    }
+  }
+}
+
+//-----------------------------------------------------------------------
+void AliAnalysisTaskRLLYZ::CreateOutputObjects() {
+
+  
+  fFlowMaker = new AliFlowMaker();
+  cerr<<"create fFlowMaker ("<<fFlowMaker<<")"<<endl;
+  fFlowMaker->SetNHitsCut(1);
+  fFlowMaker->SetECut(0.01,100.);
+  fFlowMaker->PrintCutList();
+
+  fFlowSelect = new AliFlowSelection();
+  cerr<<"create fFlowSelect ("<<fFlowSelect<<")"<<endl;
+  // Event Cuts
+  fFlowSelect->SetCentralityCut(-1) ;
+  fFlowSelect->SetRunIdCut(-1) ;
+  // R.P. calculation cuts
+  for(int j=0;j<AliFlowConstants::kHars;j++)
+    {
+      fFlowSelect->SetEtaCut(0., 2., j, 1) ;
+      fFlowSelect->SetPtCut(0.1, 10. , j, 1);  
+    }
+  fFlowSelect->SetConstrainCut(kTRUE) ;
+  fFlowSelect->SetDcaGlobalCut(0.,0.1);
+  // Correlation analysis cuts (not all of them)
+  fFlowSelect->SetEtaPart(-1.1,1.1);
+  fFlowSelect->SetPtPart(0.1,10.);   
+  fFlowSelect->SetConstrainablePart(kTRUE);
+  fFlowSelect->SetDcaGlobalPart(0.,0.1);
+  // V0 analysis cuts (not all of them ... they are useless anyway)
+  fFlowSelect->SetV0Mass(0.4875,0.5078) ;       // Mk0 = 0.49765
+  fFlowSelect->SetV0SideBands(0.1) ;
+  fFlowSelect->SetV0Pt(0.1,10.) ;
+  fFlowSelect->SetV0Eta(-2.1,2.1) ;
+  // print list :
+  //cout << " . Selection for R.P. calculation: " << endl ;
+  fFlowSelect->PrintSelectionList() ;
+  //cout << " . Selection for correlation analysis: " << endl ;
+  fFlowSelect->PrintList() ;
+  //cout << " . Selection for V0 analysis: " << endl ;
+  fFlowSelect->PrintV0List() ;
+
+  //AliFlowLYZAnalyser...
+  fFlowLYZ = new AliFlowLeeYangZerosMaker(fFlowSelect);
+  cerr<<"fFlowLYZ ("<<fFlowLYZ<<")"<<endl;
+  fFlowLYZ -> SetFirstRun(GetFirstRunLYZ());   //set first run true or false
+  fFlowLYZ -> SetUseSum(GetUseSumLYZ());     //set use sum true or false
+  //fFlowLYZ -> SetDebug(kTRUE) ;     //for debugging porposes
+  
+     
+  //output file
+  if (fFirstRunLYZ) fFlowLYZ->SetHistFileName("testTaskLYZ_firstrun.root");
+  else fFlowLYZ->SetHistFileName("testTaskLYZ_secondrun.root");
+
+
+  // Get data from input slot 1
+  if (GetNinputs() == 2) {                   //if there are two input slots
+    fFirstRunFile = (TFile*)GetInputData(1);
+    cerr<<"fFirstRunFile ("<<fFirstRunFile<<")"<<endl;
+    cerr<<"fFirstRunFile -> IsOpen() = "<<fFirstRunFile -> IsOpen()<<endl;
+
+    fFlowLYZ -> SetFirstRunFile(fFirstRunFile);
+  }
+  fFlowLYZ -> Init() ; cerr<<"fFlowLYZ->Init()"<<endl;
+      
+} 
+//-----------------------------------------------------------------------
+void AliAnalysisTaskRLLYZ::Exec(Option_t *) {
+
+  
+  // Get data from input slot 0
+  TTree *tinput = (TTree*)GetInputData(0);
+  Long64_t ientry = tinput->GetReadEntry();
+  if (AliAnalysisTaskRL::GetEntry(ientry) == kFALSE) {
+    printf("Couldn't get event from the runLoader\n");
+    return;
+  }
+  
+  if (!fESD) {
+    cout << "No ESD branch available" << endl;
+    return;
+  }
+  
+  cerr<<"fESD ("<<fESD <<") in begin Exec"<<endl;
+  cerr<<"number of tracks: "<<fESD->GetNumberOfTracks()<<endl;
+
+  AliStack* stack = GetStack();
+  if (!stack) {
+    AliDebug(AliLog::kError, "Stack not available");
+    // return kFALSE;
+  }
+
+  cerr<<"fFlowMaker ("<<fFlowMaker<<")"<<endl;
+  cerr<<"fFlowSelect ("<<fFlowSelect<<")"<<endl;
+  
+  fFlowEvent = new AliFlowEvent() ;
+  cerr<<"create fFlowEvent ("<<fFlowEvent<<")"<<endl;
+  
+  if (!fFlowMaker){cerr<<"no fFlowMaker: nullpointer"<<endl;}
+  else { 
+    if (!fESD) { cerr<<"no fESD: NULL pointer"<<endl;}
+    
+    else {
+      cerr<<"fFlowMaker ("<<fFlowMaker<<"), fFlowEvent ("<<fFlowEvent<<") and fESD ("<<fESD<<") available"<<endl;
+      fFlowEvent = fFlowMaker->FillFlowEvent(fESD);
+      
+      if (!fFlowEvent){ cerr<<"no fFlowEvent: NULL pointer"<<endl; }
+      else {
+       if(fFlowSelect->Select(fFlowEvent)){     // event selected 
+        
+         cerr<<"event selected"<<endl;
+         fFlowEvent->SetSelections(fFlowSelect) ;
+         cerr<<"fFlowLYZ ("<<fFlowLYZ<<")"<<endl;
+         fFlowLYZ->Make(fFlowEvent);
+       }
+      }
+    }
+  }
+  
+  delete fFlowEvent;
+  cerr<<"delete fFlowEvent ("<<fFlowEvent<<")"<<endl;
+  //post data
+  //PostData(0,fFlowLYZ->GetHistFile());
+
+}
+
+  //--------------------------------------------------------------------    
+void AliAnalysisTaskRLLYZ::Terminate(Option_t *) {
+   
+  if (GetNinputs() == 2) cerr<<"fFirstRunFile -> IsOpen() = "<<fFirstRunFile -> IsOpen()<<endl;
+  cerr<<"fFlowLYZ->GetHistFile() -> IsOpen() = "<<fFlowLYZ->GetHistFile() -> IsOpen()<<endl;
+  fFlowLYZ->Finish();
+  PostData(0,fFlowLYZ->GetHistFile());
+
+  delete fFlowLYZ;
+  delete fFlowMaker;
+  delete fFlowSelect;
+
+  cout<<".....finished"<<endl;
+ }
+
+
diff --git a/PWG2/FLOW/macros/AliAnalysisTaskRLLYZ.h b/PWG2/FLOW/macros/AliAnalysisTaskRLLYZ.h
new file mode 100644 (file)
index 0000000..10b4be7
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef AliAnalysisTaskRLLYZ_H
+#define AliAnalysisTaskRLLYZ_H
+
+#include "AliAnalysisTaskRL.h"
+#include "AliAnalysisTask.h"
+#include "AliAnalysisManager.h"
+#include "AliAnalysisDataContainer.h"
+#include "TObjArray.h"
+#include "TList.h"
+#include "AliESD.h"
+//#include "AliFlowConstants.h"
+//#include "AliFlowLYZConstants.h"
+#include "AliFlowSelection.h"
+#include "AliFlowMaker.h"
+#include "AliFlowLeeYangZerosMaker.h"
+#include "AliFlowEvent.h"
+
+
+class AliAnalysisTaskRLLYZ : public AliAnalysisTaskRL {
+ public:
+  AliAnalysisTaskRLLYZ(const char *name, Bool_t firstrun);
+  virtual ~AliAnalysisTaskRLLYZ();
+  
+  virtual void   ConnectInputData(Option_t *);
+  virtual void   CreateOutputObjects();
+  virtual void   Exec(Option_t *option);
+  virtual void   Terminate(Option_t *);
+
+  //lyz flags
+  void           SetFirstRunLYZ(Bool_t kt)    { this->fFirstRunLYZ = kt ;  }
+  Bool_t         GetFirstRunLYZ() const       { return this->fFirstRunLYZ ; }
+  void           SetUseSumLYZ(Bool_t kt)      { this->fUseSumLYZ = kt ;  }
+  Bool_t         GetUseSumLYZ() const         { return this->fUseSumLYZ ; }
+
+
+ private:
+
+  TFile*                    fFirstRunFile ;   //! pointer to file from first run
+  AliESD*                   fESD;             //! ESD object
+  AliFlowEvent*             fFlowEvent;       //! flowevent object
+  AliFlowSelection*         fFlowSelect;      //! flowselection object
+  AliFlowMaker*             fFlowMaker;       //! flowmaker object
+  AliFlowLeeYangZerosMaker* fFlowLYZ;         //! lyz maker object
+
+  //flags
+  Bool_t                    fFirstRunLYZ ;    //! flag for lyz analysis 
+  Bool_t                    fUseSumLYZ ;      //! flag for lyz analysis 
+  
+   
+  ClassDef(AliAnalysisTaskRLLYZ, 0);          // lyz analysis
+};
+
+ #endif
diff --git a/PWG2/FLOW/macros/AliAnalysisTaskRLLYZNewMethod.cxx b/PWG2/FLOW/macros/AliAnalysisTaskRLLYZNewMethod.cxx
new file mode 100644 (file)
index 0000000..7a13f64
--- /dev/null
@@ -0,0 +1,377 @@
+#define AliAnalysisTaskRLLYZNewMethod_cxx
+#include <iostream>
+
+
+#include "TChain.h"
+#include "TH1.h"
+#include "TList.h"
+#include "TFile.h"
+#include "TProfile.h"
+#include "TH1F.h"
+#include "TSystem.h"
+#include "TROOT.h"
+#include "TParticle.h"
+#include "TComplex.h"
+#include "TCanvas.h"
+
+#include "AliESD.h"
+#include "AliESDtrack.h"
+#include "AliLog.h"
+#include "AliStack.h"
+#include <AliHeader.h>
+#include <AliGenEventHeader.h>
+
+#include "AliAnalysisTaskRL.h"
+#include "AliAnalysisTaskRLLYZNewMethod.h"
+#include "AliFlowConstants.h"
+#include "AliFlowLYZConstants.h"
+#include "AliFlowSelection.h"
+#include "AliFlowEvent.h"
+#include "AliFlowMaker.h"
+#include "AliFlowTrack.h"
+//#include "AliFlowLeeYangZerosMaker.h"
+
+//#include "TObjectTable.h"
+
+
+
+ClassImp(AliAnalysisTaskRLLYZNewMethod)
+
+ //-----------------------------------------------------------------------
+ AliAnalysisTaskRLLYZNewMethod::AliAnalysisTaskRLLYZNewMethod(const char *name) :
+   AliAnalysisTaskRL(name,""),
+   fESD(0)
+   {
+
+  // Constructor.
+  // Input slot #0 works with an Ntuple
+  DefineInput(0, TChain::Class());
+  DefineInput(1, TList::Class()); 
+  DefineInput(2, TList::Class()); 
+  // Output slot #0 writes into a TList container
+  DefineOutput(0, TList::Class());  
+}
+
+ //-----------------------------------------------------------------------
+
+
+ AliAnalysisTaskRLLYZNewMethod::~AliAnalysisTaskRLLYZNewMethod() 
+ {
+   //destructor
+   
+ }
+//-----------------------------------------------------------------------
+
+
+void AliAnalysisTaskRLLYZNewMethod::ConnectInputData(Option_t *) {
+  // Initialize branches.
+  printf("   ConnectInputData of task %s\n", GetName());
+  //cerr<<"fESD ("<<fESD<<")"<<endl;
+  if (!fESD) {
+    //cerr<<"no fESD"<<endl;
+    char ** address = (char **)GetBranchAddress(0, "ESD");
+    if (address) fESD = (AliESD*)(*address);
+    if (!fESD) {
+      //cerr<<"still no fESD"<<endl;
+      fESD = new AliESD();
+      SetBranchAddress(0, "ESD", &fESD);
+      cerr<<"new fESD"<<endl;
+    }
+  }
+}
+
+//-----------------------------------------------------------------------
+void AliAnalysisTaskRLLYZNewMethod::CreateOutputObjects() {
+
+  
+  fFlowMaker = new AliFlowMaker();
+  cerr<<"create fFlowMaker ("<<fFlowMaker<<")"<<endl;
+  fFlowMaker->SetNHitsCut(1);
+  fFlowMaker->SetECut(0.01,100.);
+  fFlowMaker->PrintCutList();
+
+  fFlowSelect = new AliFlowSelection();
+  cerr<<"create fFlowSelect ("<<fFlowSelect<<")"<<endl;
+  // Event Cuts
+  fFlowSelect->SetCentralityCut(-1) ;
+  fFlowSelect->SetRunIdCut(-1) ;
+  // R.P. calculation cuts
+  for(int j=0;j<AliFlowConstants::kHars;j++)
+    {
+      fFlowSelect->SetEtaCut(0., 2., j, 1) ;
+      fFlowSelect->SetPtCut(0.1, 10. , j, 1);  
+    }
+  fFlowSelect->SetConstrainCut(kTRUE) ;
+  fFlowSelect->SetDcaGlobalCut(0.,0.1);
+  // Correlation analysis cuts (not all of them)
+  fFlowSelect->SetEtaPart(-1.1,1.1);
+  fFlowSelect->SetPtPart(0.1,10.);   
+  fFlowSelect->SetConstrainablePart(kTRUE);
+  fFlowSelect->SetDcaGlobalPart(0.,0.1);
+  // V0 analysis cuts (not all of them ... they are useless anyway)
+  fFlowSelect->SetV0Mass(0.4875,0.5078) ;       // Mk0 = 0.49765
+  fFlowSelect->SetV0SideBands(0.1) ;
+  fFlowSelect->SetV0Pt(0.1,10.) ;
+  fFlowSelect->SetV0Eta(-2.1,2.1) ;
+  // print list :
+  //cout << " . Selection for R.P. calculation: " << endl ;
+  fFlowSelect->PrintSelectionList() ;
+  //cout << " . Selection for correlation analysis: " << endl ;
+  fFlowSelect->PrintList() ;
+  //cout << " . Selection for V0 analysis: " << endl ;
+  fFlowSelect->PrintV0List() ;
+
+  // Get data from input slots 
+  fFirstRunFile = (TFile*)GetInputData(1);
+  cerr<<"fFirstRunFile ("<<fFirstRunFile<<")"<<endl;
+  cerr<<"fFirstRunFile -> IsOpen() = "<<fFirstRunFile -> IsOpen()<<endl;
+
+  fSecondRunFile = (TFile*)GetInputData(2);
+  cerr<<"fSecondRunFile ("<<fSecondRunFile<<")"<<endl;
+  cerr<<"fSecondRunFile -> IsOpen() = "<<fSecondRunFile -> IsOpen()<<endl;  
+     
+  //input histograms
+  h1 = ( TProfile*)fSecondRunFile->Get("Second_FlowProLYZ_ReDtheta_Har2");
+  h2 = ( TProfile*)fSecondRunFile->Get("Second_FlowProLYZ_ImDtheta_Har2");
+  h3 = ( TH1F*)fSecondRunFile->Get("Control_FlowLYZ_Qtheta"); //only for debugging
+  p1 = (TProfile*)fFirstRunFile->Get("First_FlowProLYZ_r0theta_Har2");
+  p2 = (TProfile*)fSecondRunFile->Get("Second_FlowProLYZ_VPt_Har2");
+  p3 = (TProfile*)fFirstRunFile->Get("First_FlowProLYZ_r0theta_Har2"); //double??
+  p4 = (TProfile*)fSecondRunFile->Get("Second_FlowProLYZ_ReDtheta_Har2");
+  p5 = (TProfile*)fSecondRunFile->Get("Second_FlowProLYZ_ImDtheta_Har2");
+
+
+  //output file
+  // ********make output file 
+  // analysis file (output)
+  fOutfile = new TFile("outtestNewMethodTask.root","RECREATE") ;
+  
+
+  // output histograms
+  fHistProFlow = new TProfile("NewSecond_FlowProLYZ_VPt_Har2","NewSecond_FlowProLYZ_VPt_Har2",100,0.,10.);
+  fHistProFlow->SetXTitle("Pt");
+  fHistProFlow->SetYTitle("v (%)");
+
+  fHistQtheta = new TH1F("NewControl_FlowLYZ_Qtheta","NewControl_FlowLYZ_Qtheta",50,-1000.,1000.);
+  fHistQtheta->SetXTitle("Qtheta");
+  fHistQtheta->SetYTitle("Counts");
+
+  fHistProR0thetaHar2  = new TProfile("NewFirst_FlowProLYZ_r0theta_Har2","NewFirst_FlowProLYZ_r0theta_Har2",5,-0.5,4.5);
+  fHistProR0thetaHar2->SetXTitle("#theta");
+  fHistProR0thetaHar2->SetYTitle("r_{0}^{#theta}");
+
+  fHistProReDtheta = new TProfile("NewSecond_FlowProLYZ_ReDtheta_Har2","NewSecond_FlowProLYZ_ReDtheta_Har2",5, -0.5, 4.5);
+  fHistProReDtheta->SetXTitle("#theta");
+  fHistProReDtheta->SetYTitle("Re(D^{#theta})");
+
+  fHistProImDtheta = new TProfile("NewSecond_FlowProLYZ_ImDtheta_Har2","NewSecond_FlowProLYZ_ImDtheta_Har2",5, -0.5, 4.5);
+  fHistProImDtheta->SetXTitle("#theta");
+  fHistProImDtheta->SetYTitle("Im(D^{#theta})");
+
+  // Needed otherwise pointer to fOutfile not available in Exec task
+  PostData(0, fOutfile);        
+} 
+//-----------------------------------------------------------------------
+void AliAnalysisTaskRLLYZNewMethod::Exec(Option_t *) {
+
+  
+  // Get data from input slot 0
+  TTree *tinput = (TTree*)GetInputData(0);
+  Long64_t ientry = tinput->GetReadEntry();
+  if (AliAnalysisTaskRL::GetEntry(ientry) == kFALSE) {
+    printf("Couldn't get event from the runLoader\n");
+    return;
+  }
+  
+  if (!fESD) {
+    cout << "No ESD branch available" << endl;
+    return;
+  }
+  
+  cerr<<"fESD ("<<fESD <<") in begin Exec"<<endl;
+  cerr<<"number of tracks: "<<fESD->GetNumberOfTracks()<<endl;
+
+  AliStack* stack = GetStack();
+  if (!stack) {
+    AliDebug(AliLog::kError, "Stack not available");
+    // return kFALSE;
+  }
+
+  cerr<<"fFlowMaker ("<<fFlowMaker<<")"<<endl;
+  cerr<<"fFlowSelect ("<<fFlowSelect<<")"<<endl;
+  
+  fFlowEvent = new AliFlowEvent() ;
+  cerr<<"create fFlowEvent ("<<fFlowEvent<<")"<<endl;
+  
+  if (!fFlowMaker){cerr<<"no fFlowMaker: nullpointer"<<endl;}
+  else { 
+    if (!fESD) { cerr<<"no fESD: NULL pointer"<<endl;}
+    else {
+      cerr<<"fFlowMaker ("<<fFlowMaker<<"), fFlowEvent ("<<fFlowEvent<<") and fESD ("<<fESD<<") available"<<endl;
+      fFlowEvent = fFlowMaker->FillFlowEvent(fESD);
+      
+      if (!fFlowEvent){ cerr<<"no fFlowEvent: NULL pointer"<<endl; }
+      else {
+
+       // Analysis
+       cout<<"---New Lee Yang Zeros Flow Analysis---"<<endl;
+
+       //declare variables
+       Float_t cosTerm, sinTerm;
+       TComplex fDtheta;
+       Int_t fNtheta = AliFlowLYZConstants::kTheta;
+      
+       fFlowSelect->SetSelection(1);
+       fFlowSelect->SetHarmonic(1); //second harmonic
+
+       if(fFlowSelect->Select(fFlowEvent)){     // event selected 
+        
+         cerr<<"event selected"<<endl;
+         fFlowEvent->SetSelections(fFlowSelect) ;
+         TObjArray* fFlowTracks = fFlowEvent->TrackCollection();
+         Int_t fNumberOfTracks = fFlowTracks->GetEntries();
+         cosTerm = 0.;
+         sinTerm = 0.;
+         
+         for (Int_t theta=0;theta<fNtheta;theta++)     {
+           Float_t fTheta = ((float)theta/fNtheta)*TMath::Pi()/2;  
+           //Calculate Qtheta 
+           Double_t fQtheta = 0.;
+           for (Int_t i=0;i<fNumberOfTracks;i++)  {    //loop over tracks in event
+             fFlowTrack = (AliFlowTrack*)fFlowTracks->At(i) ;   //get object at array position i
+             if(fFlowSelect->Select(fFlowTrack)) {
+               Float_t fPhi = fFlowTrack->Phi();
+               fQtheta += cos(2*(fPhi-fTheta));
+             }//track selected
+           }//loop over tracks
+
+           if (theta==0) fHistQtheta->Fill(fQtheta);  //is correct!
+           cerr<<"fQtheta = "<<fQtheta<<endl;
+
+           //get R0
+           Double_t fR0 = p1->GetBinContent(theta+1); 
+           fHistProR0thetaHar2->Fill(theta,fR0); //is correct!
+           cerr<<"fR0 = "<<fR0<<endl;
+
+           //get Dtheta
+           Double_t ReDtheta = h1->GetBinContent(theta+1);
+           Double_t ImDtheta = h2->GetBinContent(theta+1);
+           fDtheta(ReDtheta,ImDtheta);
+
+           fHistProReDtheta->Fill(theta,ReDtheta); //is correct!
+           fHistProImDtheta->Fill(theta,ImDtheta); //is correct!
+           cerr<<"Dtheta stored"<<endl;
+
+           TComplex fExpo(0.,fR0*fQtheta);                  //Complex number: 0 +(i r0 Qtheta)
+           TComplex ratio =(TComplex::Exp(fExpo))/fDtheta;  //(e^(i r0 Qtheta))/Dtheta
+
+           //sum over theta
+           cosTerm += ratio.Re() * TMath::Cos(2*fTheta);    //Re{(e^(i r0 Qtheta))/Dtheta } cos(2 theta)  
+           sinTerm += ratio.Re() * TMath::Sin(2*fTheta);    //Re{(e^(i r0 Qtheta))/Dtheta } sin(2 theta)
+
+         }//loop over theta
+
+         //average over theta
+         cosTerm /= fNtheta;  
+         sinTerm /= fNtheta;
+         cerr<<"cosTerm and sinTerm: "<<cosTerm<<" "<<sinTerm<<endl;
+
+         //calculate fWR
+         Float_t fWR = TMath::Sqrt(cosTerm*cosTerm + sinTerm*sinTerm);
+         cerr<<"fWR = "<<fWR<<endl;
+
+         //calculate fRP
+         Float_t fRP = 0.5*TMath::ATan2(sinTerm,cosTerm);
+         cerr<<"fRP = "<<fRP<<endl;
+
+         //loop over the tracks of the event
+         for (Int_t i=0;i<fNumberOfTracks;i++) 
+           {
+             fFlowTrack = (AliFlowTrack*)fFlowTracks->At(i) ;   //get object at array position i
+             if (fFlowSelect->SelectPart(fFlowTrack))           //if track is selected
+               {
+                 Float_t fPhi = fFlowTrack->Phi();
+                 if (fPhi<0.) fPhi+=2*TMath::Pi();
+                 //calculate flow v2:
+                 Float_t fv2 = fWR * TMath::Cos(2*(fPhi-fRP));
+                 Float_t fPt = fFlowTrack->Pt();
+                 //fill histogram
+                 fHistProFlow->Fill(fPt,2.405*100*fv2);   //2.405 = j01, was missing from method, do not know where
+               }//track selected
+           }//loop over tracks
+         
+       }//event selected
+
+      }
+    }
+  }
+  
+  
+  delete fFlowEvent;
+  cerr<<"delete fFlowEvent ("<<fFlowEvent<<")"<<endl;
+  
+  //PostData(0, fOutFile); 
+}
+
+  //--------------------------------------------------------------------    
+void AliAnalysisTaskRLLYZNewMethod::Terminate(Option_t *) {
+   
+  //*************make histograms etc. 
+  fOutfile->Write();
+  PostData(0, fOutfile); 
+  //save histograms in file //temp for testing selector
+  //fOutfile->cd();
+  //fOutfile->Write();
+  
+  TCanvas *canvas = new TCanvas("canvas","compare v2 vs pt",800,800);
+  //canvas->Divide(2,1);
+  canvas->cd(1); 
+  p2->SetLineColor(3);
+  p2->SetLineWidth(2);
+  p2->Draw();
+  fHistProFlow->Draw("SAME");
+
+  TCanvas *canvas2 = new TCanvas("canvas2","compare Qtheta",800,600);
+  canvas2->cd(); 
+  h3->SetLineColor(3);
+  h3->SetLineWidth(2);
+  h3->Draw();
+  fHistQtheta->Draw("SAME");
+
+
+  TCanvas *canvas3 = new TCanvas("canvas3","compare r0",800,600);
+  canvas3->cd(); 
+  p3->SetLineColor(3);
+  p3->SetLineWidth(2);
+  p3->Draw();
+  fHistProR0thetaHar2->Draw("SAME");
+
+  TCanvas *canvas4 = new TCanvas("canvas4","compare Dtheta",800,600);
+  canvas4->Divide(2,1);
+  canvas4->cd(1); 
+  h1->SetLineColor(3);
+  h1->SetLineWidth(2);
+  h1->Draw();
+  fHistProReDtheta->Draw("SAME");
+  canvas4->cd(2); 
+  h2->SetLineColor(3);
+  h2->SetLineWidth(2);
+  h2->Draw();
+  fHistProImDtheta->Draw("SAME");
+
+  delete fFlowMaker;
+  delete fFlowSelect;
+
+  cout<<".....finished"<<endl;
+ }
+
+
diff --git a/PWG2/FLOW/macros/AliAnalysisTaskRLLYZNewMethod.h b/PWG2/FLOW/macros/AliAnalysisTaskRLLYZNewMethod.h
new file mode 100644 (file)
index 0000000..34327be
--- /dev/null
@@ -0,0 +1,71 @@
+#ifndef AliAnalysisTaskRLLYZNEWMETHOD_H
+#define AliAnalysisTaskRLLYZNEWMETHOD_H
+
+#include "AliAnalysisTaskRL.h"
+#include "AliAnalysisTask.h"
+#include "AliAnalysisManager.h"
+#include "AliAnalysisDataContainer.h"
+#include "TObjArray.h"
+#include "TList.h"
+#include "TProfile.h"
+
+class AliFlowEvent;
+class AliFlowTrack;
+class AliFlowSelection;
+class AliFlowMaker;
+class AliESD;
+class AliESDtrack;
+class TFile;
+class TTree;
+class TObjArray;
+class TH1F;
+//class TProfile;
+
+
+class AliAnalysisTaskRLLYZNewMethod : public AliAnalysisTaskRL {
+ public:
+  AliAnalysisTaskRLLYZNewMethod(const char *name);
+  virtual ~AliAnalysisTaskRLLYZNewMethod();
+  
+  virtual void   ConnectInputData(Option_t *);
+  virtual void   CreateOutputObjects();
+  virtual void   Exec(Option_t *option);
+  virtual void   Terminate(Option_t *);
+
+  
+ private:
+
+  TFile*             fOutfile;         //! 
+  TFile*             fFirstRunFile ;   //! pointer to file from first run
+  TFile*             fSecondRunFile ;   //! pointer to file from second run
+  AliESD*            fESD;             //! ESD object
+  AliFlowEvent*      fFlowEvent;       //! flowevent object
+  AliFlowTrack*      fFlowTrack;       //! 
+  TObjArray*         fFlowTracks;      //! 
+  AliFlowSelection*  fFlowSelect;      //! flowselection object
+  AliFlowMaker*      fFlowMaker;       //! flowmaker object
+  
+  //histograms
+  //input
+  TProfile*  h1;    //!
+  TProfile*  h2;    //!
+  TH1F*      h3;    //!
+  TProfile*  p1;    //!
+  TProfile*  p2;    //!
+  TProfile*  p3;    //!
+  TProfile*  p4;    //!
+  TProfile*  p5;    //!
+  //output
+  TProfile*  fHistProFlow;         //!
+  TH1F*      fHistQtheta;          //!
+  TProfile*  fHistProR0thetaHar2;  //!
+  TProfile*  fHistProReDtheta;     //!
+  TProfile*  fHistProImDtheta;     //!
+  
+   
+  ClassDef(AliAnalysisTaskRLLYZNewMethod, 0);          // lyz analysis
+};
+
+ #endif
diff --git a/PWG2/FLOW/macros/AliSelectorLYZ.cxx b/PWG2/FLOW/macros/AliSelectorLYZ.cxx
new file mode 100644 (file)
index 0000000..6e33810
--- /dev/null
@@ -0,0 +1,482 @@
+/* AliSelectorLYZ.cxx, v1.0 30/07/2007 kolk Exp */
+/* derived from AliSelectorFoF.cxx, v1.1 01/02/2007 esimili Exp */
+/* derived from AliSelector.cxx,v 1.17 2006/08/31 jgrosseo Exp */
+
+// The class definition in esdV0.h has been generated automatically
+// by the ROOT utility TTree::MakeSelector(). This class is derived
+// from the ROOT class TSelector. For more information on the TSelector
+// framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.
+
+// The following methods are defined in this file:
+//    Begin():        called everytime a loop on the tree starts,
+//                    a convenient place to create your histograms.
+//    SlaveBegin():   called after Begin(), when on PROOF called only on the
+//                    slave servers.
+//    Process():      called for each event, in this function you decide what
+//                    to read and fill your histograms.
+//    SlaveTerminate: called at the end of the loop on the tree, when on PROOF
+//                    called only on the slave servers.
+//    Terminate():    called at the end of the loop on the tree,
+//                    a convenient place to draw/fit your histograms.
+//
+// To use this file, try the following session on your Tree T:
+//
+// Root > T->Process("AliSelector.C")
+// Root > T->Process("AliSelector.C","some options")
+// Root > T->Process("AliSelector.C+")
+//
+
+#include "AliSelectorLYZ.h"
+
+#include <TStyle.h>
+#include <TSystem.h>
+#include <TCanvas.h>
+#include <TRegexp.h>
+#include <TTime.h>
+#include <TFriendElement.h>
+#include <TTree.h>
+#include <TChain.h>
+#include <TFile.h>
+#include <TTimeStamp.h>
+#include <TMath.h>
+#include <TVector2.h>
+#include <TObject.h>
+#include <TObjArray.h>
+#include <TSelector.h>
+
+#include "AliLog.h"              
+#include "AliESD.h"              
+#include "AliESDtrack.h"  
+#include "AliESDv0.h"             
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+using namespace std; //required for resolving the 'cout' symbol
+
+#include "AliFlowEvent.h"
+#include "AliFlowTrack.h"
+#include "AliFlowV0.h"
+#include "AliFlowConstants.h"
+#include "AliFlowSelection.h"
+#include "AliFlowMaker.h"
+#include "AliFlowLYZConstants.h"
+#include "AliFlowLeeYangZerosMaker.h"
+#include "AliFlowTrack.h"
+
+
+ClassImp(AliSelectorLYZ)
+
+//-----------------------------------------------------------------------
+
+AliSelectorLYZ::AliSelectorLYZ() :
+  TSelector(),
+  fTree(0),
+  fESD(0),
+  fCountFiles(0),
+  fFirstRunLYZ(kTRUE), //set boolean for firstrun to initial value
+  fUseSumLYZ(kTRUE),   //set boolean for use sum to initial value
+  fKineFile(0)
+ {
+  //
+  // Constructor. Initialization of pointers
+  //
+  
+  fFlowEventFileName       = "fof_flowEvts.root" ;    
+  
+}
+
+//-----------------------------------------------------------------------
+
+AliSelectorLYZ::~AliSelectorLYZ()
+{
+  //
+  // Destructor
+  //
+
+ if (fTree) { fTree->ResetBranchAddresses() ; }
+
+ if (fESD)
+ {
+   delete fESD;
+   fESD = 0;
+ }
+}
+
+//-----------------------------------------------------------------------
+
+void AliSelectorLYZ::CheckOptions()
+{
+  // checks the option string for the debug flag
+  
+  AliLog::SetClassDebugLevel(ClassName(), AliLog::kInfo);
+
+  TString option = GetOption();
+
+  if (option.Contains("moredebug"))
+  {
+    printf("Enabling verbose debug mode for %s\n", ClassName());
+    AliLog::SetClassDebugLevel(ClassName(), AliLog::kDebug+1);
+    AliInfo(Form("Called with option %s.", option.Data()));
+  }
+  else if (option.Contains("debug"))
+  {
+    printf("Enabling debug mode for %s\n", ClassName());
+    AliLog::SetClassDebugLevel(ClassName(), AliLog::kDebug);
+    AliInfo(Form("Called with option %s.", option.Data()));
+  }
+}
+
+//-----------------------------------------------------------------------
+
+void AliSelectorLYZ::Begin(TTree*)
+{
+  // The Begin() function is called at the start of the query.
+  // When running with PROOF Begin() is only called on the client.
+  // The tree argument is deprecated (on PROOF 0 is passed).
+  
+  cerr << " HERE I begin !!! " << endl ; cout << endl ;
+  
+
+  CheckOptions();
+
+  AliDebug(AliLog::kDebug, "============BEGIN===========");
+
+ // flags
+ fDoNothing     = kFALSE ;
+ fOnFlyAnalysis = kTRUE ; 
+ fSaveFlowEvents= kFALSE ;
+
+// Maker part :
+ fFlowMaker = new AliFlowMaker() ;
+ // ESD Cuts
+ fFlowMaker->SetNHitsCut(1) ;
+ fFlowMaker->SetECut(0.01,100.) ; 
+ fFlowMaker->PrintCutList() ;
+
+// Opens flow event (output) file
+ if(fSaveFlowEvents)  
+ { 
+ // flow events file (output)
+  fFlowfile = new TFile(fFlowEventFileName.Data(),"RECREATE") ;
+  fFlowfile->cd() ; 
+  //cout << " . Writing AliFlowEvents on  : " << fFlowEventFileName.Data()   << "  . " << endl ;
+ }
+ // Analysis part :
+ if(fOnFlyAnalysis)  
+ { 
+   //cout << " . Here the flow selection ... " << endl ;
+  cout << endl ;
+
+ // AliFlowSelection...
+  fFlowSelect = new AliFlowSelection() ;
+  // Event Cuts
+  fFlowSelect->SetCentralityCut(-1) ;
+  fFlowSelect->SetRunIdCut(-1) ;
+  // R.P. calculation cuts
+  for(int j=0;j<AliFlowConstants::kHars;j++)
+    {
+      fFlowSelect->SetEtaCut(0., 2., j, 1) ;
+      fFlowSelect->SetPtCut(0.1, 10. , j, 1);  
+    }
+  fFlowSelect->SetConstrainCut(kTRUE) ;
+  fFlowSelect->SetDcaGlobalCut(0.,0.1);
+  // Correlation analysis cuts (not all of them)
+  fFlowSelect->SetEtaPart(-1.1,1.1);
+  fFlowSelect->SetPtPart(0.1,10.);   
+  fFlowSelect->SetConstrainablePart(kTRUE);
+  fFlowSelect->SetDcaGlobalPart(0.,0.1);
+  // V0 analysis cuts (not all of them ... they are useless anyway)
+  fFlowSelect->SetV0Mass(0.4875,0.5078) ;       // Mk0 = 0.49765
+  fFlowSelect->SetV0SideBands(0.1) ;
+  fFlowSelect->SetV0Pt(0.1,10.) ;
+  fFlowSelect->SetV0Eta(-2.1,2.1) ;
+  // print list :
+  //cout << " . Selection for R.P. calculation: " << endl ;
+  fFlowSelect->PrintSelectionList() ;
+  //cout << " . Selection for correlation analysis: " << endl ;
+  fFlowSelect->PrintList() ;
+  //cout << " . Selection for V0 analysis: " << endl ;
+  fFlowSelect->PrintV0List() ;
+
+  //cout << " . Here the flow analysis ... " << endl ;
+  //cout << endl ;
+  
+  //AliFlowLYZAnalyser...
+  fFlowLYZ = new AliFlowLeeYangZerosMaker(fFlowSelect) ;
+  //fFlowLYZ -> SetFirstRun(fFirstRunLYZ);   //kFALSE //kTRUE 
+  fFlowLYZ -> SetFirstRun(GetFirstRunLYZ()); //set first run true or false
+  fFlowLYZ -> SetUseSum(GetUseSumLYZ());     //set use sum true or false
+  fFlowLYZ -> SetDebug(kTRUE) ;              //for debugging porposes
+
+  // first run file (read)
+  if (!fFirstRunLYZ){
+    TString firstRunFileName = "fof_flowLYZAnal_firstrun.root" ;
+    fFirstRunFile = new TFile(firstRunFileName.Data(),"READ");
+    if(!fFirstRunFile || fFirstRunFile->IsZombie()) { cerr << " ERROR: NO first Run file... " << endl ; }
+    else { fFlowLYZ -> SetFirstRunFile(fFirstRunFile); }
+  }
+
+  // analysis file (output)
+  if (fFirstRunLYZ) {fFlowLYZAnalysisFileName = "fof_flowLYZAnal_firstrun.root" ;}
+  else {fFlowLYZAnalysisFileName = "fof_flowLYZAnal_secondrun.root" ;}
+  fFlowLYZ->SetHistFileName(fFlowLYZAnalysisFileName.Data()) ;
+  cout << " . Writing Analysis Histograms on  : " << fFlowLYZ->GetHistFileName()   << "  . " << endl ;
+
+  fFlowLYZ->Init() ;
+  cout << "fFlowLYZ->Init() ;"<<endl;
+ }
+ cout << "                ... init is done " << endl ; 
+}
+
+//-----------------------------------------------------------------------
+
+void AliSelectorLYZ::SlaveBegin(TTree* tree)
+{
+  // The SlaveBegin() function is called after the Begin() function.
+  // When running with PROOF SlaveBegin() is called on each slave server.
+  // The tree argument is deprecated (on PROOF 0 is passed).
+
+  CheckOptions();
+
+  AliDebug(AliLog::kDebug, "=======SLAVEBEGIN========");
+  AliDebug(AliLog::kDebug, Form("Hostname: %s", gSystem->HostName()));
+  AliDebug(AliLog::kDebug, Form("Time: %s", gSystem->Now().AsString()));
+
+  if (tree != 0) { Init(tree) ; }
+}
+
+//-----------------------------------------------------------------------
+
+void AliSelectorLYZ::Init(TTree *tree)
+{
+  // The Init() function is called when the selector needs to initialize
+  // a new tree or chain. Typically here the branch addresses of the tree
+  // will be set. It is normaly not necessary to make changes to the
+  // generated code, but the routine can be extended by the user if needed.
+  // Init() will be called many times when running with PROOF.
+
+  AliDebug(AliLog::kDebug, "=========Init==========");
+
+  fTree = tree;
+
+  if (fTree == 0)
+  {
+   AliDebug(AliLog::kError, "ERROR: tree argument is 0.");
+   return;
+  }
+
+  // Set branch address
+  fTree->SetBranchAddress("ESD", &fESD);
+  if (fESD != 0) { AliDebug(AliLog::kInfo, "INFO: Found ESD branch in chain.") ; }
+}
+
+//-----------------------------------------------------------------------
+
+Bool_t AliSelectorLYZ::Notify()
+{
+  // The Notify() function is called when a new file is opened. This
+  // can be either for a new TTree in a TChain or when when a new TTree
+  // is started when using PROOF. Typically here the branch pointers
+  // will be retrieved. It is normaly not necessary to make changes
+  // to the generated code, but the routine can be extended by the
+  // user if needed.
+
+  AliDebug(AliLog::kDebug, "=========NOTIFY==========");
+  AliDebug(AliLog::kDebug, Form("Hostname: %s", gSystem->HostName()));
+  AliDebug(AliLog::kDebug, Form("Time: %s", TTimeStamp(time(0)).AsString()));
+
+  ++fCountFiles;
+  if (fTree)
+  {
+    TFile *f = fTree->GetCurrentFile();
+    AliDebug(AliLog::kInfo, Form("Processing %d. file %s", fCountFiles, f->GetName()));
+  }
+  else
+  {
+    AliDebug(AliLog::kError, "fTree not available");
+  }
+
+  DeleteKinematicsFile();
+
+  return kTRUE;
+}
+
+//-----------------------------------------------------------------------
+
+Bool_t AliSelectorLYZ::Process(Long64_t entry)
+{
+  // The Process() function is called for each entry in the tree (or possibly
+  // keyed object in the case of PROOF) to be processed. The entry argument
+  // specifies which entry in the currently loaded tree is to be processed.
+  // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
+  // to read either all or the required parts of the data. When processing
+  // keyed objects with PROOF, the object is already loaded and is available
+  // via the fObject pointer.
+  //
+  // This function should contain the "body" of the analysis. It can contain
+  // simple or elaborate selection criteria, run algorithms on the data
+  // of the event and typically fill histograms.
+
+  // WARNING when a selector is used with a TChain, you must use
+  //  the pointer to the current TTree to call GetEntry(entry).
+  //  The entry is always the local entry number in the current tree.
+  //  Assuming that fTree is the pointer to the TChain being processed,
+  //  use fTree->GetTree()->GetEntry(entry).
+
+  AliDebug(AliLog::kDebug, Form("=========PROCESS========== Entry %lld", entry));
+
+  if(!fTree)
+  {
+   AliDebug(AliLog::kError, "ERROR: fTree is 0.") ;
+   return kFALSE ;
+  }
+
+  fEventNumber = entry ;
+  fTree->GetTree()->GetEntry(fEventNumber) ;
+
+  if(fESD) { AliDebug(AliLog::kDebug, Form("ESD: We have %d tracks.", fESD->GetNumberOfTracks())); }
+  cout << " event !!! " << entry << endl ;
+
+  fRunID = fESD->GetRunNumber() ;
+  //  fEventNumber = fESD->GetEventNumber() ;
+  fEventNumber = -1 ;
+  fNumberOfTracks = fESD->GetNumberOfTracks() ;
+  fNumberOfV0s = fESD->GetNumberOfV0s() ;
+
+  cout << " *evt n. " << fEventNumber << " (run " << fRunID << ") " << endl ;
+  cout << "  tracks: " << fNumberOfTracks << " ,   v0s " << fNumberOfV0s << endl ;
+
+ // Dummy Loop
+  if(fDoNothing)  { cout << " ... doing nothing ... " << endl ; return kTRUE; } 
+
+ // Instantiate a new AliFlowEvent
+  cout << " filling the flow event :| " << endl ;
+  fFlowEvent = fFlowMaker->FillFlowEvent(fESD) ;
+  if(!fFlowEvent) { cout << "! something bad occurred !" << endl ; return kFALSE ; }
+  else                   { cout << "# event done :) " << entry << "     # ok ! #" << endl ; }  
+     
+
+ // Saves the AliFlowEvent
+  if(fSaveFlowEvents)
+  { 
+   cout << " saving flow event :| " << endl ;
+   TString strID = "" ; strID += entry ; 
+   fFlowfile->cd() ; fFlowEvent->Write(strID.Data()) ;
+   cout << "# event saved :) " << strID.Data() << "     # ok ! #" << endl ; cout << endl ;  
+  }
+
+   
+  // On-Fly Analysis
+  if(fOnFlyAnalysis)  
+  {
+    Bool_t donelyz = fFlowLYZ->Make(fFlowEvent) ;
+    if(donelyz) { cout << "# LYZ analysis done :) " << entry << "         # ok ! #       " << endl ; 
+    delete fFlowEvent; }
+
+  }
+   
+  return kTRUE;
+}
+
+//-----------------------------------------------------------------------
+
+void AliSelectorLYZ::SlaveTerminate()
+{
+  // The SlaveTerminate() function is called after all entries or objects
+  // have been processed. When running with PROOF SlaveTerminate() is called
+  // on each slave server.
+
+  AliDebug(AliLog::kDebug, "=======SLAVETERMINATE=======");
+
+  DeleteKinematicsFile();
+}
+
+//-----------------------------------------------------------------------
+
+void AliSelectorLYZ::Terminate()
+{
+  // The Terminate() function is the last function to be called during
+  // a query. It always runs on the client, it can be used to present
+  // the results graphically or save the results to file.
+
+  AliDebug(AliLog::kDebug, "=========TERMINATE==========");
+
+  cout << " Finished ... " << endl ;
+
+  if(fDoNothing) { cout << "             ... & nothing was done ! " << endl ; cout << endl ; return ; }
+
+  cout << endl ;
+  cout << "  nTracks:  " << fFlowMaker->GetNgoodTracks() << endl ;   
+  cout << "  nV0s:  " << fFlowMaker->GetNgoodV0s()  << endl ;               
+  cout << "  nTracks (|eta|<0.5):  " << fFlowMaker->GetNgoodTracksEta() << endl ; 
+  cout << "  nTracks+:  " << fFlowMaker->GetNposiTracks() << endl ;         
+  cout << "  nTracks-:  " << fFlowMaker->GetNnegaTracks() << endl ;         
+  cout << "  nTracks unconstrained:  " << fFlowMaker->GetNunconstrained() << endl ;     
+  cout << "  Bayesian (e,mu,pi,k,p) :  " ; 
+  for(int ii=0;ii<5;ii++) { cout << fFlowMaker->GetBayesianNorm(ii) << "   " ; } 
+  cout << " . " << endl ; cout << endl ;
+  
+  if(fOnFlyAnalysis) 
+    { 
+      fFlowLYZ->Finish() ; cout << endl;
+      delete fFlowLYZ;
+    }
+     
+  if(fSaveFlowEvents) { fFlowfile->Close() ; cout << " file closed . " << endl ; }
+  delete fFlowMaker ;
+
+  delete fFlowSelect ;
+  
+  cout << endl ; 
+  return ;
+} 
+
+//-----------------------------------------------------------------------
+
+TTree* AliSelectorLYZ::GetKinematics()
+{
+  // Returns kinematics tree corresponding to current ESD active in fTree
+  // Loads the kinematics from the kinematics file, the file is identified by replacing "AliESDs" to
+  // "Kinematics" in the file path of the ESD file. This is a hack, to be changed!
+
+  if (!fKineFile)
+  {
+    if(!fTree->GetCurrentFile()) { return 0 ; }
+
+    TString fileName(fTree->GetCurrentFile()->GetName());
+    fileName.ReplaceAll("AliESDs", "Kinematics");
+
+    // temporary workaround for PROOF bug #18505
+    fileName.ReplaceAll("#Kinematics.root#Kinematics.root", "#Kinematics.root");
+
+    AliDebug(AliLog::kInfo, Form("Opening %s", fileName.Data()));
+
+    fKineFile = TFile::Open(fileName);
+    if(!fKineFile) { return 0 ; }
+  }
+
+  return dynamic_cast<TTree*> (fKineFile->Get(Form("Event%d/TreeK", fTree->GetTree()->GetReadEntry())));
+}
+
+//-----------------------------------------------------------------------
+
+void AliSelectorLYZ::DeleteKinematicsFile()
+{
+  //
+  // Closes the kinematics file and deletes the pointer.
+  //
+
+  if (fKineFile)
+  {
+    fKineFile->Close();
+    delete fKineFile;
+    fKineFile = 0;
+  }
+}
+
+//-----------------------------------------------------------------------
+
+
diff --git a/PWG2/FLOW/macros/AliSelectorLYZ.h b/PWG2/FLOW/macros/AliSelectorLYZ.h
new file mode 100644 (file)
index 0000000..d7e2a7a
--- /dev/null
@@ -0,0 +1,127 @@
+/* Id: AliSelectorLYZ.h, v1.0 30/07/2007 kolk Exp */
+/* derived from AliSelectorFoF.h, v1.1 01/02/2007 esimili Exp */
+/* derived from AliSelector.h,v 1.10 2006/08/15 jgrosseo Exp */
+
+// This selector is only dependent on the ESD library, if you need the whole of AliROOT use AliSelectorRL
+#ifndef ALISELECTORLYZ_H
+#define ALISELECTORLYZ_H
+
+#include <iostream>
+using namespace std;
+
+#include <TSelector.h>
+#include "AliFlowConstants.h"
+#include "AliFlowLYZConstants.h"
+
+class AliFlowEvent;
+class AliFlowTrack;
+class AliFlowSelection;
+class AliFlowMaker;
+class AliFlowAnalyser; 
+class AliFlowWeighter;
+class AliFlowLeeYangZerosMaker;
+class AliFlowLYZHist1;
+class AliFlowLYZHist2;
+
+class AliESD;
+class AliESDtrack;
+class AliESDv0;
+
+class TFile;
+class TTree;
+class TString;
+class TObjArray;
+
+class AliSelectorLYZ : public TSelector {
+
+
+  public:
+
+    AliSelectorLYZ();
+    virtual ~AliSelectorLYZ();
+
+   // default AliSelector things
+    virtual Int_t   Version() const {return 1;}
+    virtual void    Begin(TTree*);
+    virtual void    SlaveBegin(TTree* tree);
+    virtual void    Init(TTree *tree);
+    virtual Bool_t  Notify();
+    virtual Bool_t  Process(Long64_t entry);
+    virtual void    SlaveTerminate();
+    virtual void    Terminate();
+
+  // output file name
+    void            SetFlowEventFileName(TString name)          { this->fFlowEventFileName = name ; }
+    void            SetFlowLYZAnalysisFileName(TString name)    { this->fFlowLYZAnalysisFileName = name ; }
+    TString         GetFlowEventFileName() const               { return this->fFlowEventFileName ; }
+    TString         GetFlowLYZAnalysisFileName()const          { return this->fFlowLYZAnalysisFileName ; }
+    
+  // tasks
+    void            SetDoNothing(Bool_t kt = kTRUE)      { this->fDoNothing = kt ; }
+    void            SetSaveFlowEvents(Bool_t kt = kTRUE) { this->fSaveFlowEvents = kt ; }
+    void            SetOnFlyAnalysis(Bool_t kt = kTRUE)  { this->fOnFlyAnalysis = kt ; }
+    void            SetOnFlyWeight(Bool_t kt = kTRUE)    { this->fOnFlyWeight = kt ; }
+  //lyz flags
+    void            SetFirstRunLYZ(Bool_t kt)            { this->fFirstRunLYZ = kt ;  }
+    Bool_t          GetFirstRunLYZ() const               { return this->fFirstRunLYZ ; }
+    void            SetUseSumLYZ(Bool_t kt)              { this->fUseSumLYZ = kt ;  }
+    Bool_t          GetUseSumLYZ() const                 { return this->fUseSumLYZ ; }
+
+
+
+ protected:
+  
+    TTree*       fTree;                  //! pointer to the TTree containing the events
+    AliESD*       fESD;                          //! "ESD" branch in fChain
+    Int_t        fCountFiles ;           //! number of processed file
+
+  // output file names
+    TString      fFlowEventFileName;        //! AliFlowEvents file 
+    TString      fFlowLYZAnalysisFileName;  //! LYZ Analysis Histograms file
+
+  // default AliSelector things
+    TTree*       GetKinematics();
+    void         CheckOptions();
+
+
+ private:
+
+  // flow things
+    TFile*                    fFlowfile ;         //! pointer to flow event file
+    TFile*                    fFirstRunFile ;     //! pointer to file from first run
+    AliFlowEvent*             fFlowEvent ;        //! pointer to flow event
+    AliFlowTrack*             fFlowTrack;
+    TObjArray*                fFlowTracks;
+    AliFlowSelection*         fFlowSelect;       //! pointer to flow selection
+    AliFlowMaker*             fFlowMaker ;        //! flow evt maker
+    AliFlowLeeYangZerosMaker* fFlowLYZ;           //! flow LYZ analysis
+
+
+  // enumerators                                 
+    Int_t             fRunID;            //! last run ID
+    Int_t            fEventNumber ;      //! progressive enumeration of ESD events
+    Int_t             fNumberOfTracks ;   //! progressive enumeration of ESD tracks
+    Int_t             fNumberOfV0s ;      //! progressive enumeration of ESD V0
+    Int_t             fNumberOfEvents ;   //! total number of ESD events in file
+  // Flags
+    Bool_t            fDoNothing ;        //! flag for a dummy execution 
+    Bool_t            fSaveFlowEvents ;   //! flag for saving the flow events 
+    Bool_t            fOnFlyAnalysis ;    //! flag for on-fly analysis 
+    Bool_t            fOnFlyWeight ;      //! flag for on-fly analysis 
+    Bool_t            fFirstRunLYZ ;      //! flag for lyz analysis 
+    Bool_t            fUseSumLYZ ;        //! flag for lyz analysis 
+
+
+  // default AliSelector things
+    void             DeleteKinematicsFile();
+    TFile*            fKineFile;          //! pointer to Kinematics.root if the file was opened
+
+  // to make the code checker happy
+    AliSelectorLYZ(const AliSelectorLYZ&);
+    AliSelectorLYZ& operator=(const AliSelectorLYZ&);
+
+  ClassDef(AliSelectorLYZ,0);
+};
+
+#endif
diff --git a/PWG2/FLOW/macros/AliSelectorLYZNewMethod.cxx b/PWG2/FLOW/macros/AliSelectorLYZNewMethod.cxx
new file mode 100644 (file)
index 0000000..3c7a9ff
--- /dev/null
@@ -0,0 +1,585 @@
+/* AliSelectorLYZNewMethod.cxx, v1.0 30/07/2007 kolk Exp */
+/* derived from AliSelectorFoF.cxx, v1.1 01/02/2007 esimili Exp */
+/* derived from AliSelector.cxx,v 1.17 2006/08/31 jgrosseo Exp */
+
+// The class definition in esdV0.h has been generated automatically
+// by the ROOT utility TTree::MakeSelector(). This class is derived
+// from the ROOT class TSelector. For more information on the TSelector
+// framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.
+
+// The following methods are defined in this file:
+//    Begin():        called everytime a loop on the tree starts,
+//                    a convenient place to create your histograms.
+//    SlaveBegin():   called after Begin(), when on PROOF called only on the
+//                    slave servers.
+//    Process():      called for each event, in this function you decide what
+//                    to read and fill your histograms.
+//    SlaveTerminate: called at the end of the loop on the tree, when on PROOF
+//                    called only on the slave servers.
+//    Terminate():    called at the end of the loop on the tree,
+//                    a convenient place to draw/fit your histograms.
+//
+// To use this file, try the following session on your Tree T:
+//
+// Root > T->Process("AliSelector.C")
+// Root > T->Process("AliSelector.C","some options")
+// Root > T->Process("AliSelector.C+")
+//
+
+#include "AliSelectorLYZNewMethod.h"
+
+#include <TSystem.h>
+#include <TCanvas.h>
+#include <TTree.h>
+#include <TChain.h>
+#include <TFile.h>
+#include <TH1F.h>
+#include <TProfile.h>
+#include <TTimeStamp.h>
+#include <TMath.h>
+#include <TVector2.h>
+#include <TComplex.h>
+#include <TObject.h>
+#include <TObjArray.h>
+#include <TSelector.h>
+
+#include "AliLog.h"              
+#include "AliESD.h"              
+#include "AliESDtrack.h"  
+          
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+using namespace std; //required for resolving the 'cout' symbol
+
+#include "AliFlowConstants.h"
+#include "AliFlowLYZConstants.h"
+#include "AliFlowEvent.h"
+#include "AliFlowTrack.h"
+#include "AliFlowSelection.h"
+#include "AliFlowMaker.h"
+
+
+ClassImp(AliSelectorLYZNewMethod)
+
+//-----------------------------------------------------------------------
+
+AliSelectorLYZNewMethod::AliSelectorLYZNewMethod() :
+  TSelector(),
+  fTree(0),
+  fESD(0),
+  fCountFiles(0),
+  fKineFile(0)
+ {
+  //
+  // Constructor. Initialization of pointers
+  //
+     
+}
+
+//-----------------------------------------------------------------------
+
+AliSelectorLYZNewMethod::~AliSelectorLYZNewMethod()
+{
+  //
+  // Destructor
+  //
+
+ if (fTree) { fTree->ResetBranchAddresses() ; }
+
+ if (fESD)
+ {
+   delete fESD;
+   fESD = 0;
+ }
+}
+
+//-----------------------------------------------------------------------
+
+void AliSelectorLYZNewMethod::CheckOptions()
+{
+  // checks the option string for the debug flag
+  
+  AliLog::SetClassDebugLevel(ClassName(), AliLog::kInfo);
+
+  TString option = GetOption();
+
+  if (option.Contains("moredebug"))
+  {
+    printf("Enabling verbose debug mode for %s\n", ClassName());
+    AliLog::SetClassDebugLevel(ClassName(), AliLog::kDebug+1);
+    AliInfo(Form("Called with option %s.", option.Data()));
+  }
+  else if (option.Contains("debug"))
+  {
+    printf("Enabling debug mode for %s\n", ClassName());
+    AliLog::SetClassDebugLevel(ClassName(), AliLog::kDebug);
+    AliInfo(Form("Called with option %s.", option.Data()));
+  }
+}
+
+//-----------------------------------------------------------------------
+
+void AliSelectorLYZNewMethod::Begin(TTree*)
+{
+  // The Begin() function is called at the start of the query.
+  // When running with PROOF Begin() is only called on the client.
+  // The tree argument is deprecated (on PROOF 0 is passed).
+  
+  cerr << " HERE I begin !!! " << endl ; cout << endl ;
+  
+
+  CheckOptions();
+
+  AliDebug(AliLog::kDebug, "============BEGIN===========");
+
+  // Maker part :
+ fFlowMaker = new AliFlowMaker() ;
+ // ESD Cuts
+ fFlowMaker->SetNHitsCut(1) ;
+ fFlowMaker->SetECut(0.01,100.) ; 
+ fFlowMaker->PrintCutList() ;
+
+
+  // AliFlowSelection...
+  fFlowSelect = new AliFlowSelection() ;
+  // Event Cuts
+  fFlowSelect->SetCentralityCut(-1) ;
+  fFlowSelect->SetRunIdCut(-1) ;
+  // R.P. calculation cuts
+  for(int j=0;j<AliFlowConstants::kHars;j++)
+    {
+      fFlowSelect->SetEtaCut(0., 2., j, 1) ;
+      fFlowSelect->SetPtCut(0.1, 10. , j, 1);  
+    }
+  fFlowSelect->SetConstrainCut(kTRUE) ;
+  fFlowSelect->SetDcaGlobalCut(0.,0.1);
+  // Correlation analysis cuts (not all of them)
+  fFlowSelect->SetEtaPart(-1.1,1.1);
+  fFlowSelect->SetPtPart(0.1,10.);   
+  fFlowSelect->SetConstrainablePart(kTRUE);
+  fFlowSelect->SetDcaGlobalPart(0.,0.1);
+  // V0 analysis cuts (not all of them ... they are useless anyway)
+  fFlowSelect->SetV0Mass(0.4875,0.5078) ;       // Mk0 = 0.49765
+  fFlowSelect->SetV0SideBands(0.1) ;
+  fFlowSelect->SetV0Pt(0.1,10.) ;
+  fFlowSelect->SetV0Eta(-2.1,2.1) ;
+  // print list :
+  //cout << " . Selection for R.P. calculation: " << endl ;
+  fFlowSelect->PrintSelectionList() ;
+  //cout << " . Selection for correlation analysis: " << endl ;
+  fFlowSelect->PrintList() ;
+  //cout << " . Selection for V0 analysis: " << endl ;
+  fFlowSelect->PrintV0List() ;
+    
+  // read input files (read)
+  TString firstRunFileName  = "fof_flowLYZAnal_firstrun.root"  ;
+  TString secondRunFileName = "fof_flowLYZAnal_secondrun.root" ;
+
+  fFirstRunFile = new TFile(firstRunFileName.Data(),"READ");
+  if(!fFirstRunFile || fFirstRunFile->IsZombie()) { cerr << " ERROR: NO first Run file... " << endl ; }
+  fSecondRunFile = new TFile(secondRunFileName.Data(),"READ");
+  if(!fSecondRunFile || fSecondRunFile->IsZombie()) { cerr << " ERROR: NO Second Run file... " << endl ; }
+  cerr<<"....input files read"<<endl;
+  
+  //input histograms
+  h1 = ( TProfile*)fSecondRunFile->Get("Second_FlowProLYZ_ReDtheta_Har2");
+  h2 = ( TProfile*)fSecondRunFile->Get("Second_FlowProLYZ_ImDtheta_Har2");
+  h3 = ( TH1F*)fSecondRunFile->Get("Control_FlowLYZ_Qtheta"); //only for debugging
+  p1 = (TProfile*)fFirstRunFile->Get("First_FlowProLYZ_r0theta_Har2");
+  p2 = (TProfile*)fSecondRunFile->Get("Second_FlowProLYZ_VPt_Har2");
+  p3 = (TProfile*)fFirstRunFile->Get("First_FlowProLYZ_r0theta_Har2"); //double??
+  p4 = (TProfile*)fSecondRunFile->Get("Second_FlowProLYZ_ReDtheta_Har2");
+  p5 = (TProfile*)fSecondRunFile->Get("Second_FlowProLYZ_ImDtheta_Har2");
+
+  
+  // analysis file (output)
+  fOutfile = new TFile("outtestNewMethod.root","RECREATE") ;
+  fOutfile->cd() ; 
+  
+  // output histograms
+  fHistProFlow = new TProfile("NewSecond_FlowProLYZ_VPt_Har2","NewSecond_FlowProLYZ_VPt_Har2",100,0.,10.);
+  fHistProFlow->SetXTitle("Pt");
+  fHistProFlow->SetYTitle("v (%)");
+
+  fHistQtheta = new TH1F("NewControl_FlowLYZ_Qtheta","NewControl_FlowLYZ_Qtheta",50,-1000.,1000.);
+  fHistQtheta->SetXTitle("Qtheta");
+  fHistQtheta->SetYTitle("Counts");
+
+  fHistProR0thetaHar2  = new TProfile("NewFirst_FlowProLYZ_r0theta_Har2","NewFirst_FlowProLYZ_r0theta_Har2",5,-0.5,4.5);
+  fHistProR0thetaHar2->SetXTitle("#theta");
+  fHistProR0thetaHar2->SetYTitle("r_{0}^{#theta}");
+
+  fHistProReDtheta = new TProfile("NewSecond_FlowProLYZ_ReDtheta_Har2","NewSecond_FlowProLYZ_ReDtheta_Har2",5, -0.5, 4.5);
+  fHistProReDtheta->SetXTitle("#theta");
+  fHistProReDtheta->SetYTitle("Re(D^{#theta})");
+
+  fHistProImDtheta = new TProfile("NewSecond_FlowProLYZ_ImDtheta_Har2","NewSecond_FlowProLYZ_ImDtheta_Har2",5, -0.5, 4.5);
+  fHistProImDtheta->SetXTitle("#theta");
+  fHistProImDtheta->SetYTitle("Im(D^{#theta})");
+
+ cout << "                ... init is done " << endl ; 
+}
+
+//-----------------------------------------------------------------------
+
+void AliSelectorLYZNewMethod::SlaveBegin(TTree* tree)
+{
+  // The SlaveBegin() function is called after the Begin() function.
+  // When running with PROOF SlaveBegin() is called on each slave server.
+  // The tree argument is deprecated (on PROOF 0 is passed).
+
+  CheckOptions();
+
+  AliDebug(AliLog::kDebug, "=======SLAVEBEGIN========");
+  AliDebug(AliLog::kDebug, Form("Hostname: %s", gSystem->HostName()));
+  AliDebug(AliLog::kDebug, Form("Time: %s", gSystem->Now().AsString()));
+
+  if (tree != 0) { Init(tree) ; }
+}
+
+//-----------------------------------------------------------------------
+
+void AliSelectorLYZNewMethod::Init(TTree *tree)
+{
+  // The Init() function is called when the selector needs to initialize
+  // a new tree or chain. Typically here the branch addresses of the tree
+  // will be set. It is normaly not necessary to make changes to the
+  // generated code, but the routine can be extended by the user if needed.
+  // Init() will be called many times when running with PROOF.
+
+  AliDebug(AliLog::kDebug, "=========Init==========");
+
+  fTree = tree;
+
+  if (fTree == 0)
+  {
+   AliDebug(AliLog::kError, "ERROR: tree argument is 0.");
+   return;
+  }
+
+  // Set branch address
+  fTree->SetBranchAddress("ESD", &fESD);
+  if (fESD != 0) { AliDebug(AliLog::kInfo, "INFO: Found ESD branch in chain.") ; }
+}
+
+//-----------------------------------------------------------------------
+
+Bool_t AliSelectorLYZNewMethod::Notify()
+{
+  // The Notify() function is called when a new file is opened. This
+  // can be either for a new TTree in a TChain or when when a new TTree
+  // is started when using PROOF. Typically here the branch pointers
+  // will be retrieved. It is normaly not necessary to make changes
+  // to the generated code, but the routine can be extended by the
+  // user if needed.
+
+  AliDebug(AliLog::kDebug, "=========NOTIFY==========");
+  AliDebug(AliLog::kDebug, Form("Hostname: %s", gSystem->HostName()));
+  AliDebug(AliLog::kDebug, Form("Time: %s", TTimeStamp(time(0)).AsString()));
+
+  ++fCountFiles;
+  if (fTree)
+  {
+    TFile *f = fTree->GetCurrentFile();
+    AliDebug(AliLog::kInfo, Form("Processing %d. file %s", fCountFiles, f->GetName()));
+  }
+  else
+  {
+    AliDebug(AliLog::kError, "fTree not available");
+  }
+
+  DeleteKinematicsFile();
+
+  return kTRUE;
+}
+
+//-----------------------------------------------------------------------
+
+Bool_t AliSelectorLYZNewMethod::Process(Long64_t entry)
+{
+  // The Process() function is called for each entry in the tree (or possibly
+  // keyed object in the case of PROOF) to be processed. The entry argument
+  // specifies which entry in the currently loaded tree is to be processed.
+  // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
+  // to read either all or the required parts of the data. When processing
+  // keyed objects with PROOF, the object is already loaded and is available
+  // via the fObject pointer.
+  //
+  // This function should contain the "body" of the analysis. It can contain
+  // simple or elaborate selection criteria, run algorithms on the data
+  // of the event and typically fill histograms.
+
+  // WARNING when a selector is used with a TChain, you must use
+  //  the pointer to the current TTree to call GetEntry(entry).
+  //  The entry is always the local entry number in the current tree.
+  //  Assuming that fTree is the pointer to the TChain being processed,
+  //  use fTree->GetTree()->GetEntry(entry).
+
+  AliDebug(AliLog::kDebug, Form("=========PROCESS========== Entry %lld", entry));
+
+  if(!fTree)
+  {
+   AliDebug(AliLog::kError, "ERROR: fTree is 0.") ;
+   return kFALSE ;
+  }
+
+  fEventNumber = entry ;
+  fTree->GetTree()->GetEntry(fEventNumber) ;
+
+  if(fESD) { AliDebug(AliLog::kDebug, Form("ESD: We have %d tracks.", fESD->GetNumberOfTracks())); }
+  cout << " event !!! " << entry << endl ;
+
+  fRunID = fESD->GetRunNumber() ;
+  //  fEventNumber = fESD->GetEventNumber() ;
+  fEventNumber = -1 ;
+  fNumberOfTracks = fESD->GetNumberOfTracks() ;
+  fNumberOfV0s = fESD->GetNumberOfV0s() ;
+
+  cout << " *evt n. " << fEventNumber << " (run " << fRunID << ") " << endl ;
+  cout << "  tracks: " << fNumberOfTracks << " ,   v0s " << fNumberOfV0s << endl ;
+
+  // Instantiate a new AliFlowEvent
+  cout << " filling the flow event :| " << endl ;
+  fFlowEvent = fFlowMaker->FillFlowEvent(fESD) ;
+  if(!fFlowEvent) { cout << "! something bad occurred !" << endl ; return kFALSE ; }
+  else                   { cout << "# event done :) " << entry << "     # ok ! #" << endl ; }  
+     
+
+   
+  // Analysis
+  cout<<"---New Lee Yang Zeros Flow Analysis---"<<endl;
+
+  //declare variables
+  Float_t cosTerm, sinTerm;
+  TComplex fDtheta;
+  Int_t fNtheta = AliFlowLYZConstants::kTheta;
+      
+  fFlowSelect->SetSelection(1);
+  fFlowSelect->SetHarmonic(1); //second harmonic
+
+  if(fFlowSelect->Select(fFlowEvent))   // event selected 
+    {
+                 
+      fFlowEvent->SetSelections(fFlowSelect) ;             
+      TObjArray* fFlowTracks = fFlowEvent->TrackCollection();
+      Int_t fNumberOfTracks = fFlowTracks->GetEntries();
+      cosTerm = 0.;
+      sinTerm = 0.;
+
+      for (Int_t theta=0;theta<fNtheta;theta++)        {
+       Float_t fTheta = ((float)theta/fNtheta)*TMath::Pi()/2;  
+       //Calculate Qtheta 
+       Double_t fQtheta = 0.;
+       for (Int_t i=0;i<fNumberOfTracks;i++)  {    //loop over tracks in event
+         fFlowTrack = (AliFlowTrack*)fFlowTracks->At(i) ;   //get object at array position i
+         if(fFlowSelect->Select(fFlowTrack)) {
+           Float_t fPhi = fFlowTrack->Phi();
+           fQtheta += cos(2*(fPhi-fTheta));
+         }//track selected
+     
+       }//loop over tracks
+
+       if (theta==0) fHistQtheta->Fill(fQtheta);  //is correct!
+       cerr<<"fQtheta = "<<fQtheta<<endl;
+
+       //get R0
+       Double_t fR0 = p1->GetBinContent(theta+1); 
+       fHistProR0thetaHar2->Fill(theta,fR0); //is correct!
+       cerr<<"fR0 = "<<fR0<<endl;
+
+       //get Dtheta
+       Double_t ReDtheta = h1->GetBinContent(theta+1);
+       Double_t ImDtheta = h2->GetBinContent(theta+1);
+       fDtheta(ReDtheta,ImDtheta);
+       
+       fHistProReDtheta->Fill(theta,ReDtheta); //is correct!
+       fHistProImDtheta->Fill(theta,ImDtheta); //is correct!
+       cerr<<"Dtheta stored"<<endl;
+
+       TComplex fExpo(0.,fR0*fQtheta);                  //Complex number: 0 +(i r0 Qtheta)
+       TComplex ratio =(TComplex::Exp(fExpo))/fDtheta;  //(e^(i r0 Qtheta))/Dtheta
+
+       //sum over theta
+       cosTerm += ratio.Re() * TMath::Cos(2*fTheta);    //Re{(e^(i r0 Qtheta))/Dtheta } cos(2 theta)  
+       sinTerm += ratio.Re() * TMath::Sin(2*fTheta);    //Re{(e^(i r0 Qtheta))/Dtheta } sin(2 theta)
+
+      }//loop over theta
+
+
+      //average over theta
+      cosTerm /= fNtheta;  
+      sinTerm /= fNtheta;
+      cerr<<"cosTerm and sinTerm: "<<cosTerm<<" "<<sinTerm<<endl;
+
+      //calculate fWR
+      Float_t fWR = TMath::Sqrt(cosTerm*cosTerm + sinTerm*sinTerm);
+      cerr<<"fWR = "<<fWR<<endl;
+
+      //calculate fRP
+      Float_t fRP = 0.5*TMath::ATan2(sinTerm,cosTerm);
+      cerr<<"fRP = "<<fRP<<endl;
+
+      //loop over the tracks of the event
+      for (Int_t i=0;i<fNumberOfTracks;i++) 
+       {
+         fFlowTrack = (AliFlowTrack*)fFlowTracks->At(i) ;   //get object at array position i
+         if (fFlowSelect->SelectPart(fFlowTrack))           //if track is selected
+           {
+             Float_t fPhi = fFlowTrack->Phi();
+             if (fPhi<0.) fPhi+=2*TMath::Pi();
+             //calculate flow v2:
+             Float_t fv2 = fWR * TMath::Cos(2*(fPhi-fRP));
+             Float_t fPt = fFlowTrack->Pt();
+             //fill histogram
+             fHistProFlow->Fill(fPt,2.405*100*fv2);   //2.405 = j01, was missing from method, do not know where
+           }//track selected
+       }//loop over tracks
+         
+    }//event selected
+
+
+
+  delete fFlowEvent; 
+  
+   
+  return kTRUE;
+}
+
+//-----------------------------------------------------------------------
+
+void AliSelectorLYZNewMethod::SlaveTerminate()
+{
+  // The SlaveTerminate() function is called after all entries or objects
+  // have been processed. When running with PROOF SlaveTerminate() is called
+  // on each slave server.
+
+  AliDebug(AliLog::kDebug, "=======SLAVETERMINATE=======");
+
+  DeleteKinematicsFile();
+}
+
+//-----------------------------------------------------------------------
+
+void AliSelectorLYZNewMethod::Terminate()
+{
+  // The Terminate() function is the last function to be called during
+  // a query. It always runs on the client, it can be used to present
+  // the results graphically or save the results to file.
+
+  AliDebug(AliLog::kDebug, "=========TERMINATE==========");
+
+  cout << " Finished ... " << endl ;
+
+  //save histograms in file //temp for testing selector
+  fOutfile->cd();
+  fOutfile->Write();
+
+  //plot some histograms or store them in a file
+  //
+  TCanvas *canvas = new TCanvas("canvas","compare v2 vs pt",800,800);
+  //canvas->Divide(2,1);
+  canvas->cd(1); 
+  p2->SetLineColor(3);
+  p2->SetLineWidth(2);
+  p2->Draw();
+  fHistProFlow->Draw("SAME");
+  //canvas->cd(2); 
+  //fHistProDivide = new TProfile("Divide_VPt_Har2","Divide_VPt_Har2",20,0.,2.);
+  //Float_t integrated1 = 0.;
+  //Float_t integrated2 = 0.;
+  //for (Int_t b=1;b<=20;b++)
+  //{
+  //    Float_t pt = fHistProFlow->GetBinCenter(b);
+  //    Float_t v1 = fHistProFlow->GetBinContent(b);
+  //    Float_t v2 = p2->GetBinContent(b);
+  //    if (v1==0.) Float_t v3 = 0.;
+  //    else Float_t v3 = v2/v1;
+  //    fHistProDivide->Fill(pt,v3);
+  //    integrated1 += v1;
+  //    integrated2 += v2;
+  //  }
+  //fHistProDivide ->Draw();
+  //cout<<"new method gives: "<<integrated1<<" and LYZ gives: "<<integrated2<<". Ratio between them: "<<integrated2/integrated1<<endl;
+
+  TCanvas *canvas2 = new TCanvas("canvas2","compare Qtheta",800,600);
+  canvas2->cd(); 
+  h3->SetLineColor(3);
+  h3->SetLineWidth(2);
+  h3->Draw();
+  fHistQtheta->Draw("SAME");
+
+
+  TCanvas *canvas3 = new TCanvas("canvas3","compare r0",800,600);
+  canvas3->cd(); 
+  p3->SetLineColor(3);
+  p3->SetLineWidth(2);
+  p3->Draw();
+  fHistProR0thetaHar2->Draw("SAME");
+
+  TCanvas *canvas4 = new TCanvas("canvas4","compare Dtheta",800,600);
+  canvas4->Divide(2,1);
+  canvas4->cd(1); 
+  h1->SetLineColor(3);
+  h1->SetLineWidth(2);
+  h1->Draw();
+  fHistProReDtheta->Draw("SAME");
+  canvas4->cd(2); 
+  h2->SetLineColor(3);
+  h2->SetLineWidth(2);
+  h2->Draw();
+  fHistProImDtheta->Draw("SAME");
+
+  delete fFlowSelect ;
+  
+  //cout << endl ; 
+  return ;
+} 
+
+//-----------------------------------------------------------------------
+
+TTree* AliSelectorLYZNewMethod::GetKinematics()
+{
+  // Returns kinematics tree corresponding to current ESD active in fTree
+  // Loads the kinematics from the kinematics file, the file is identified by replacing "AliESDs" to
+  // "Kinematics" in the file path of the ESD file. This is a hack, to be changed!
+
+  if (!fKineFile)
+  {
+    if(!fTree->GetCurrentFile()) { return 0 ; }
+
+    TString fileName(fTree->GetCurrentFile()->GetName());
+    fileName.ReplaceAll("AliESDs", "Kinematics");
+
+    // temporary workaround for PROOF bug #18505
+    fileName.ReplaceAll("#Kinematics.root#Kinematics.root", "#Kinematics.root");
+
+    AliDebug(AliLog::kInfo, Form("Opening %s", fileName.Data()));
+
+    fKineFile = TFile::Open(fileName);
+    if(!fKineFile) { return 0 ; }
+  }
+
+  return dynamic_cast<TTree*> (fKineFile->Get(Form("Event%d/TreeK", fTree->GetTree()->GetReadEntry())));
+}
+
+//-----------------------------------------------------------------------
+
+void AliSelectorLYZNewMethod::DeleteKinematicsFile()
+{
+  //
+  // Closes the kinematics file and deletes the pointer.
+  //
+
+  if (fKineFile)
+  {
+    fKineFile->Close();
+    delete fKineFile;
+    fKineFile = 0;
+  }
+}
+
+//-----------------------------------------------------------------------
+
+
diff --git a/PWG2/FLOW/macros/AliSelectorLYZNewMethod.h b/PWG2/FLOW/macros/AliSelectorLYZNewMethod.h
new file mode 100644 (file)
index 0000000..cbdb0ed
--- /dev/null
@@ -0,0 +1,104 @@
+/* Id: AliSelectorLYZNewMethod.h, v1.0 30/07/2007 kolk Exp */
+/* derived from AliSelectorFoF.h, v1.1 01/02/2007 esimili Exp */
+/* derived from AliSelector.h,v 1.10 2006/08/15 jgrosseo Exp */
+
+// This selector is only dependent on the ESD library, if you need the whole of AliROOT use AliSelectorRL
+#ifndef ALISELECTORLYZNEWMETHOD_H
+#define ALISELECTORLYZNEWMETHOD_H
+
+#include <iostream>
+using namespace std;
+
+#include <TSelector.h>
+#include "AliFlowConstants.h"
+#include "AliFlowLYZConstants.h"
+
+class AliFlowEvent;
+class AliFlowTrack;
+class AliFlowSelection;
+class AliFlowMaker;
+class AliESD;
+class AliESDtrack;
+
+class TFile;
+class TTree;
+class TObjArray;
+class TH1F;
+class TProfile;
+
+class AliSelectorLYZNewMethod : public TSelector {
+
+
+  public:
+
+    AliSelectorLYZNewMethod();
+    virtual ~AliSelectorLYZNewMethod();
+
+   // default AliSelector things
+    virtual Int_t   Version() const {return 1;}
+    virtual void    Begin(TTree*);
+    virtual void    SlaveBegin(TTree* tree);
+    virtual void    Init(TTree *tree);
+    virtual Bool_t  Notify();
+    virtual Bool_t  Process(Long64_t entry);
+    virtual void    SlaveTerminate();
+    virtual void    Terminate();
+
+  
+ protected:
+  
+    TTree*       fTree;                  //! pointer to the TTree containing the events
+    AliESD*       fESD;                          //! "ESD" branch in fChain
+    Int_t        fCountFiles ;           //! number of processed file
+  
+  // default AliSelector things
+    TTree*       GetKinematics();
+    void         CheckOptions();
+
+ private:
+  // flow things
+    TFile*        fOutfile; 
+    TFile*        fFirstRunFile ;      //! pointer to file from first run
+    TFile*        fSecondRunFile ;     //! pointer to file from second run
+    AliFlowEvent*             fFlowEvent ;        //! pointer to flow event
+    AliFlowTrack*             fFlowTrack;         //! 
+    TObjArray*                fFlowTracks;        //! 
+    AliFlowSelection*         fFlowSelect;       //! pointer to flow selection
+    AliFlowMaker*             fFlowMaker;        //!
+
+  // enumerators                                 
+    Int_t         fRunID;            //! last run ID
+    Int_t        fEventNumber ;      //! progressive enumeration of ESD events
+    Int_t         fNumberOfTracks ;   //! progressive enumeration of ESD tracks
+    Int_t         fNumberOfV0s ;      //! progressive enumeration of ESD V0
+    Int_t         fNumberOfEvents ;   //! total number of ESD events in file
+    //histograms
+    //input
+    TProfile*  h1;    //!
+    TProfile*  h2;    //!
+    TH1F*      h3;    //!
+    TProfile*  p1;    //!
+    TProfile*  p2;    //!
+    TProfile*  p3;    //!
+    TProfile*  p4;    //!
+    TProfile*  p5;    //!
+    //output
+    TProfile*  fHistProFlow;         //!
+    TH1F*      fHistQtheta;          //!
+    TProfile*  fHistProR0thetaHar2;  //!
+    TProfile*  fHistProReDtheta;     //!
+    TProfile*  fHistProImDtheta;     //!
+
+  // default AliSelector things
+    void             DeleteKinematicsFile();
+    TFile*            fKineFile;          //! pointer to Kinematics.root if the file was opened
+
+  // to make the code checker happy
+    AliSelectorLYZNewMethod(const AliSelectorLYZNewMethod&);
+    AliSelectorLYZNewMethod& operator=(const AliSelectorLYZNewMethod&);
+
+  ClassDef(AliSelectorLYZNewMethod,0);
+};
+
+#endif
diff --git a/PWG2/FLOW/macros/makeSelectorLYZ.C b/PWG2/FLOW/macros/makeSelectorLYZ.C
new file mode 100644 (file)
index 0000000..3f2ac73
--- /dev/null
@@ -0,0 +1,171 @@
+////////////////////////////////////////////////////////////////////////////////
+//macro to run AliSelectorLYZ for LYZ analysis on ESDs                        //
+//run first with "Bool_t firstrun = kTRUE" by running .x makeSelectorLYZ()    //
+//for the first run over the data (integrated flow)                           //
+//run second with "Bool_t firstrun = kFALSE" by running .x makeSelectorLYZ(0) //
+//for the second run over the data (differential flow)                        //
+////////////////////////////////////////////////////////////////////////////////
+
+
+// from CreateESDChain.C - instead of  #include "CreateESDChain.C"
+TChain* CreateESDChain(const char* aDataDir = "ESDfiles.txt", Int_t aRuns = 20, Int_t offset = 0) ;
+void LookupWrite(TChain* chain, const char* target) ;
+
+
+
+void makeSelectorLYZ(Bool_t firstrun = kTRUE, Bool_t usesum = kTRUE, const Char_t* dataDir="/data/alice1/simili/lcgHijing/4", Int_t nRuns = -1, Int_t offset = 0)
+//void makeSelectorLYZ(Bool_t firstrun = kTRUE, Bool_t usesum = kTRUE, const Char_t* dataDir="/data/alice/kolk/TestLYZData/data/cent5", Int_t nRuns = 1, Int_t offset = 0)
+//void makeSelectorLYZ(Bool_t firstrun = kTRUE, Bool_t usesum = kTRUE, const Char_t* dataDir="/data/alice/simili/lcgGevSim3x/LDL/0", Int_t nRuns = -1, Int_t offset = 0)
+
+//void makeSelectorLYZ(Bool_t firstrun = kTRUE, Bool_t usesum = kFALSE, const Char_t* dataDir="/data/alice/simili/lcgHijing/5",Int_t nRuns = -1, Int_t offset = 0)
+//void makeSelectorLYZ(Bool_t firstrun = kTRUE, Bool_t usesum = kFALSE, const Char_t* dataDir="/data/alice/kolk/TestLYZData/data/cent5", Int_t nRuns =1, Int_t offset = 0)
+
+
+
+{
+ // include path (to find the .h files when compiling)
+ gSystem->AddIncludePath("-I$ALICE_ROOT/include") ;
+ gSystem->AddIncludePath("-I$ROOTSYS/include") ;
+ gSystem->AddIncludePath("-I$ALICE_ROOT/PWG2/FLOW") ;
+
+ // load needed libraries
+ gSystem->Load("libESD");
+  
+ // Flow libraries 
+ gSystem->Load("libPWG2flow.so");
+ gROOT->LoadMacro("AliFlowLYZConstants.cxx+");
+ gROOT->LoadMacro("AliFlowLYZHist1.cxx+");
+ gROOT->LoadMacro("AliFlowLYZHist2.cxx+");
+ gROOT->LoadMacro("AliFlowLeeYangZerosMaker.cxx+");
+ gROOT->LoadMacro("AliSelectorLYZ.cxx+");
+ // create the TChain. CreateESDChain() is defined in CreateESDChain.C
+ TChain* chain = CreateESDChain(dataDir, nRuns, offset);
+ cout << " * " << chain->GetEntries() << " * " << endl ;
+
+ // enable debugging
+ AliLog::SetClassDebugLevel("AliSelectorLYZ", AliLog::kInfo);
+
+ // run selector on chain
+ AliSelectorLYZ* selector = new AliSelectorLYZ; //create new selector object
+ selector->SetFirstRunLYZ(firstrun);            //set to first or second run
+ selector->SetUseSumLYZ(usesum);                //set to sum gen.function or product gen.function
+ Long64_t result = chain->Process(selector);    //proces the selector on the chain of data
+  
+ if (result != 0)  {
+   cout<<"ERROR: Executing process failed with "<<result<<endl;
+   return; }
+
+ cout<<"Execution complete."<<endl<<endl;
+ delete selector;
+}
+
+// Helper macros for creating chains
+// from: CreateESDChain.C,v 1.10 jgrosseo Exp
+
+TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
+{
+  // creates chain of files in a given directory or file containing a list.
+  // In case of directory the structure is expected as:
+  // <aDataDir>/<dir0>/AliESDs.root
+  // <aDataDir>/<dir1>/AliESDs.root
+  // ...
+
+  if (!aDataDir)
+    return 0;
+
+  Long_t id, size, flags, modtime;
+  if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
+  {
+    printf("%s not found.\n", aDataDir);
+    return 0;
+  }
+
+  TChain* chain = new TChain("esdTree");
+  TChain* chaingAlice = 0;
+
+  if (flags & 2)
+  {
+    TString execDir(gSystem->pwd());
+    TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
+    TList* dirList            = baseDir->GetListOfFiles();
+    Int_t nDirs               = dirList->GetEntries();
+    gSystem->cd(execDir);
+
+    Int_t count = 0;
+
+    for (Int_t iDir=0; iDir<nDirs; ++iDir)
+    {
+      TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
+      if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
+        continue;
+
+      if (offset > 0)
+      {
+        --offset;
+        continue;
+      }
+
+      if (count++ == aRuns)
+        break;
+
+      TString presentDirName(aDataDir);
+      presentDirName += "/";
+      presentDirName += presentDir->GetName();
+
+      chain->Add(presentDirName + "/AliESDs.root/esdTree");
+    }
+  }
+  else
+  {
+    // Open the input stream
+    ifstream in;
+    in.open(aDataDir);
+
+    Int_t count = 0;
+
+    // Read the input list of files and add them to the chain
+    TString esdfile;
+    while(in.good()) {
+      in >> esdfile;
+      if (!esdfile.Contains("root")) continue; // protection
+
+      if (offset > 0)
+      {
+        --offset;
+        continue;
+      }
+
+      if (count++ == aRuns)
+        break;
+
+        // add esd file
+      chain->Add(esdfile);
+    }
+
+    in.close();
+  }
+
+  return chain;
+}
+
+void LookupWrite(TChain* chain, const char* target)
+{
+  // looks up the chain and writes the remaining files to the text file target
+
+  chain->Lookup();
+
+  TObjArray* list = chain->GetListOfFiles();
+  TIterator* iter = list->MakeIterator();
+  TObject* obj = 0;
+
+  ofstream outfile;
+  outfile.open(target);
+
+  while ((obj = iter->Next()))
+    outfile << obj->GetTitle() << "#AliESDs.root" << endl;
+
+  outfile.close();
+
+  delete iter;
+}
diff --git a/PWG2/FLOW/macros/makeSelectorNMLYZ.C b/PWG2/FLOW/macros/makeSelectorNMLYZ.C
new file mode 100644 (file)
index 0000000..16f6216
--- /dev/null
@@ -0,0 +1,162 @@
+///////////////////////////////////////////////////////////////////////////////
+// macro to run AliSelectorLYZNewMethod for LYZ analysis on ESDs             //
+// Make sure that the input files are available:
+// "fof_flowLYZAnal_firstrun.root" from the first run of AliSelectorLYZ.C and
+// "fof_flowLYZAnal_secondrun.root" from the second run of AliSelectorLYZ.C(0)
+//
+// (this dependence on input files will change at some point)                //
+///////////////////////////////////////////////////////////////////////////////
+
+
+// from CreateESDChain.C - instead of  #include "CreateESDChain.C"
+TChain* CreateESDChain(const char* aDataDir = "ESDfiles.txt", Int_t aRuns = 20, Int_t offset = 0) ;
+void LookupWrite(TChain* chain, const char* target) ;
+
+
+
+void makeSelectorNMLYZ(const Char_t* dataDir="/data/alice1/simili/lcgHijing/4", Int_t nRuns = 1, Int_t offset = 0)
+
+
+
+{
+ // include path (to find the .h files when compiling)
+ gSystem->AddIncludePath("-I$ALICE_ROOT/include") ;
+ gSystem->AddIncludePath("-I$ROOTSYS/include") ;
+ gSystem->AddIncludePath("-I$ALICE_ROOT/PWG2/FLOW") ;
+
+ // load needed libraries
+ gSystem->Load("libESD");
+  
+ // Flow libraries 
+ gSystem->Load("libPWG2flow.so");
+ gROOT->LoadMacro("AliFlowLYZConstants.cxx+");
+ gROOT->LoadMacro("AliSelectorLYZNewMethod.cxx+");
+ // create the TChain. CreateESDChain() is defined in CreateESDChain.C
+ TChain* chain = CreateESDChain(dataDir, nRuns, offset);
+ cout << " * " << chain->GetEntries() << " * " << endl ;
+
+ // enable debugging
+ AliLog::SetClassDebugLevel("AliSelectorLYZ", AliLog::kInfo);
+
+ // run selector on chain
+ AliSelectorLYZNewMethod* selector = new AliSelectorLYZNewMethod; //create new selector object
+ Long64_t result = chain->Process(selector);    //proces the selector on the chain of data
+  
+ if (result != 0)  {
+   cout<<"ERROR: Executing process failed with "<<result<<endl;
+   return; }
+
+ cout<<"Execution complete."<<endl<<endl;
+ delete selector;
+}
+
+// Helper macros for creating chains
+// from: CreateESDChain.C,v 1.10 jgrosseo Exp
+
+TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
+{
+  // creates chain of files in a given directory or file containing a list.
+  // In case of directory the structure is expected as:
+  // <aDataDir>/<dir0>/AliESDs.root
+  // <aDataDir>/<dir1>/AliESDs.root
+  // ...
+
+  if (!aDataDir)
+    return 0;
+
+  Long_t id, size, flags, modtime;
+  if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
+  {
+    printf("%s not found.\n", aDataDir);
+    return 0;
+  }
+
+  TChain* chain = new TChain("esdTree");
+  TChain* chaingAlice = 0;
+
+  if (flags & 2)
+  {
+    TString execDir(gSystem->pwd());
+    TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
+    TList* dirList            = baseDir->GetListOfFiles();
+    Int_t nDirs               = dirList->GetEntries();
+    gSystem->cd(execDir);
+
+    Int_t count = 0;
+
+    for (Int_t iDir=0; iDir<nDirs; ++iDir)
+    {
+      TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
+      if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
+        continue;
+
+      if (offset > 0)
+      {
+        --offset;
+        continue;
+      }
+
+      if (count++ == aRuns)
+        break;
+
+      TString presentDirName(aDataDir);
+      presentDirName += "/";
+      presentDirName += presentDir->GetName();
+
+      chain->Add(presentDirName + "/AliESDs.root/esdTree");
+    }
+  }
+  else
+  {
+    // Open the input stream
+    ifstream in;
+    in.open(aDataDir);
+
+    Int_t count = 0;
+
+    // Read the input list of files and add them to the chain
+    TString esdfile;
+    while(in.good()) {
+      in >> esdfile;
+      if (!esdfile.Contains("root")) continue; // protection
+
+      if (offset > 0)
+      {
+        --offset;
+        continue;
+      }
+
+      if (count++ == aRuns)
+        break;
+
+        // add esd file
+      chain->Add(esdfile);
+    }
+
+    in.close();
+  }
+
+  return chain;
+}
+
+void LookupWrite(TChain* chain, const char* target)
+{
+  // looks up the chain and writes the remaining files to the text file target
+
+  chain->Lookup();
+
+  TObjArray* list = chain->GetListOfFiles();
+  TIterator* iter = list->MakeIterator();
+  TObject* obj = 0;
+
+  ofstream outfile;
+  outfile.open(target);
+
+  while ((obj = iter->Next()))
+    outfile << obj->GetTitle() << "#AliESDs.root" << endl;
+
+  outfile.close();
+
+  delete iter;
+}
diff --git a/PWG2/FLOW/macros/makeTaskLYZ.C b/PWG2/FLOW/macros/makeTaskLYZ.C
new file mode 100644 (file)
index 0000000..0416b47
--- /dev/null
@@ -0,0 +1,249 @@
+/////////////////////////////////////////////////////////////
+//
+// $Id$
+//
+// Author: N. van der Kolk
+//
+/////////////////////////////////////////////////////////////
+//
+// Description: ROOT macro to perform Flow analysis on AliFlowEvents with the Lee Yang Zeros method
+//
+/////////////////////////////////////////////////////////////
+
+// from CreateESDChain.C - instead of  #include "CreateESDChain.C"
+TChain* CreateESDChain(const char* aDataDir = "ESDfiles.txt", Int_t aRuns = 20, Int_t offset = 0) ;
+void LookupWrite(TChain* chain, const char* target) ;
+
+
+#include <vector>
+#include <iostream>
+#include <fstream>
+//#include "TVector.h"
+//#include "TVector2.h"
+//#include "TVector3.h"
+//#include "TMath.h"
+//#include "TObject.h"
+#include "TObjArray.h"
+//#include "TStopwatch.h"
+//#include "TList.h"
+
+//class AliFlowTrack;
+//class AliFlowEvent;
+//class AliFlowSelection;
+//class AliFlowConstants;
+
+using namespace std; //required for resolving the 'cout' symbol
+
+
+void makeTaskLYZ(Bool_t firstrun = kTRUE, Bool_t usesum = kTRUE, const Char_t* dataDir="/data/alice1/simili/lcgHijing/4", Int_t nRuns = -1, Int_t offset = 0)
+{
+  cout<<"---Lee Yang Zeros Flow Analysis with Task Framework---"<<endl;
+
+
+  // include path (to find the .h files when compiling)
+  gSystem->AddIncludePath("-I$ALICE_ROOT/include") ;
+  gSystem->AddIncludePath("-I$ROOTSYS/include") ;
+  gSystem->AddIncludePath("-I$ALICE_ROOT/PWG2/FLOW") ;
+
+  // load needed libraries
+  gSystem->Load("libESD");
+  cerr<<"libESD loaded..."<<endl;
+  gSystem->Load("libANALYSIS.so");
+  cerr<<"libANALYSIS.so loaded..."<<endl;
+  gSystem->Load("libANALYSISRL.so");
+  cerr<<"libANALYSISRL.so loaded..."<<endl;
+
+  // Flow libraries 
+  gSystem->Load("libPWG2flow.so");
+  cerr<<"libPWG2flow.so loaded..."<<endl;
+  gROOT->LoadMacro("AliFlowLYZConstants.cxx+");
+  cerr<<"."<<endl;
+  gROOT->LoadMacro("AliFlowLYZHist1.cxx+");
+  cerr<<".."<<endl;
+  gROOT->LoadMacro("AliFlowLYZHist2.cxx+");
+  cerr<<"..."<<endl;
+  gROOT->LoadMacro("AliFlowLeeYangZerosMaker.cxx+");
+  cerr<<"...."<<endl;
+  gROOT->LoadMacro("AliAnalysisTaskRLLYZ.cxx+");
+  cerr<<"....."<<endl;
+
+  cout<<"---loaded libraries!---"<<endl;
+
+  // create the TChain. CreateESDChain() is defined in CreateESDChain.C
+  TChain* chain = CreateESDChain(dataDir, nRuns, offset);
+  cout<<"chain ("<<chain<<")"<<endl;
+  //cout << " * " << chain->GetEntriesFast() << "*" << endl;
+  //cout << " * " << chain->GetEntries() << " * " << endl ;
+
+  // first run file (read) (from selector!)
+  if (!firstrun){
+    TString firstRunFileName = "testTaskLYZ_firstrun.root" ;
+    TFile* fFirstRunFile = new TFile(firstRunFileName.Data(),"READ");
+    if(!fFirstRunFile || fFirstRunFile->IsZombie()) { cerr << " ERROR: NO first Run file... " << endl ; }
+  } 
+
+
+  //____________________________________________//
+  // Make the analysis manager
+  AliAnalysisManager *mgr = new AliAnalysisManager("TestLYZManager");
+  cout<<"---defined the manager---"<<endl;
+  //____________________________________________//
+  // 1st LYZ task
+  AliAnalysisTaskRLLYZ *task1 = new AliAnalysisTaskRLLYZ("LYZtest", firstrun);
+  task1->SetFirstRunLYZ(firstrun);            //set to first or second run
+  task1->SetUseSumLYZ(usesum);                //set to sum gen.function or product gen.function
+  //if (!firstrun) task1->SetFirstRunFile(fFirstRunFile);
+
+  //add tasks to manager
+  mgr->AddTask(task1);
+  cout<<"---task1 added---"<<endl;
+  
+
+  // Create containers for input/output
+  AliAnalysisDataContainer *cinput1 = 
+    mgr->CreateContainer("cchain1",TChain::Class(),AliAnalysisManager::kInputContainer);
+  cout<<"---created input container---"<<endl;
+
+  if (!firstrun) { 
+    AliAnalysisDataContainer *cinput2 = 
+      mgr->CreateContainer("cobj2",TList::Class(),AliAnalysisManager::kInputContainer);
+    cout<<"---created input container2---"<<endl; 
+  }
+
+
+  //AliAnalysisDataContainer *coutput1 = 
+  //mgr->CreateContainer("cobj1", TList::Class(),AliAnalysisManager::kOutputContainer,"TestTaskLYZ.root");
+  AliAnalysisDataContainer *coutput1 = 
+    mgr->CreateContainer("cobj1", TList::Class());
+
+  
+  //____________________________________________//
+  mgr->ConnectInput(task1,0,cinput1);
+  cout<<"---ConnectInput(task1,0,cinput1)---"<<endl;
+  if (!firstrun) { mgr->ConnectInput(task1,1,cinput2);
+  cout<<"---ConnectInput(task1,1,cinput2)---"<<endl; }
+  mgr->ConnectOutput(task1,0,coutput1);
+  cout<<"---ConnectOutput(task1,0,coutput1)---"<<endl;
+  
+  cerr<<"chain ("<<chain<<")"<<endl;
+  cinput1->SetData(chain);
+  if (!firstrun) cinput2->SetData(fFirstRunFile);
+
+  if(mgr->InitAnalysis()) {
+    mgr->PrintStatus();
+    mgr->StartAnalysis("local",chain);
+  } 
+}
+
+
+// Helper macros for creating chains
+// from: CreateESDChain.C,v 1.10 jgrosseo Exp
+
+TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
+{
+  // creates chain of files in a given directory or file containing a list.
+  // In case of directory the structure is expected as:
+  // <aDataDir>/<dir0>/AliESDs.root
+  // <aDataDir>/<dir1>/AliESDs.root
+  // ...
+  
+  if (!aDataDir)
+    return 0;
+  
+  Long_t id, size, flags, modtime;
+  if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
+    {
+      printf("%s not found.\n", aDataDir);
+      return 0;
+    }
+  
+  TChain* chain = new TChain("esdTree");
+  TChain* chaingAlice = 0;
+  
+  if (flags & 2)
+    {
+      TString execDir(gSystem->pwd());
+      TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
+      TList* dirList            = baseDir->GetListOfFiles();
+      Int_t nDirs               = dirList->GetEntries();
+      gSystem->cd(execDir);
+      
+      Int_t count = 0;
+      
+      for (Int_t iDir=0; iDir<nDirs; ++iDir)
+       {
+         TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
+         if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
+           continue;
+         
+         if (offset > 0)
+           {
+             --offset;
+             continue;
+           }
+         
+         if (count++ == aRuns)
+           break;
+         
+         TString presentDirName(aDataDir);
+         presentDirName += "/";
+         presentDirName += presentDir->GetName();        
+         chain->Add(presentDirName + "/AliESDs.root/esdTree");
+         cerr<<presentDirName<<endl;
+       }
+      
+    }
+  else
+    {
+      // Open the input stream
+      ifstream in;
+      in.open(aDataDir);
+      
+      Int_t count = 0;
+      
+      // Read the input list of files and add them to the chain
+      TString esdfile;
+      while(in.good()) {
+       in >> esdfile;
+       if (!esdfile.Contains("root")) continue; // protection
+       
+       if (offset > 0)
+         {
+           --offset;
+           continue;
+         }
+       
+       if (count++ == aRuns)
+         break;
+       
+        // add esd file
+       chain->Add(esdfile);
+      }
+      
+      in.close();
+    }
+  
+  return chain;
+}
+
+void LookupWrite(TChain* chain, const char* target)
+{
+  // looks up the chain and writes the remaining files to the text file target
+  
+  chain->Lookup();
+  
+  TObjArray* list = chain->GetListOfFiles();
+  TIterator* iter = list->MakeIterator();
+  TObject* obj = 0;
+  
+  ofstream outfile;
+  outfile.open(target);
+  
+  while ((obj = iter->Next()))
+    outfile << obj->GetTitle() << "#AliESDs.root" << endl;
+  
+  outfile.close();
+  
+  delete iter;
+}
+
diff --git a/PWG2/FLOW/macros/makeTaskNMLYZ.C b/PWG2/FLOW/macros/makeTaskNMLYZ.C
new file mode 100644 (file)
index 0000000..dab8196
--- /dev/null
@@ -0,0 +1,236 @@
+/////////////////////////////////////////////////////////////
+//
+// $Id$
+//
+// Author: N. van der Kolk
+//
+/////////////////////////////////////////////////////////////
+//
+// Description: ROOT macro to perform Flow analysis on AliFlowEvents with the Lee Yang Zeros method
+//
+/////////////////////////////////////////////////////////////
+
+// from CreateESDChain.C - instead of  #include "CreateESDChain.C"
+TChain* CreateESDChain(const char* aDataDir = "ESDfiles.txt", Int_t aRuns = 20, Int_t offset = 0) ;
+void LookupWrite(TChain* chain, const char* target) ;
+
+
+#include <vector>
+#include <iostream>
+#include <fstream>
+#include "TObjArray.h"
+
+//class AliFlowTrack;
+//class AliFlowEvent;
+//class AliFlowSelection;
+//class AliFlowConstants;
+
+using namespace std; //required for resolving the 'cout' symbol
+
+
+void makeTaskNMLYZ(const Char_t* dataDir="/data/alice1/simili/lcgHijing/4", Int_t nRuns =-1, Int_t offset = 0)
+{
+  cout<<"---New Method for Lee Yang Zeros Flow Analysis with Task Framework---"<<endl;
+
+
+  // include path (to find the .h files when compiling)
+  gSystem->AddIncludePath("-I$ALICE_ROOT/include") ;
+  gSystem->AddIncludePath("-I$ROOTSYS/include") ;
+  gSystem->AddIncludePath("-I$ALICE_ROOT/PWG2/FLOW") ;
+
+  // load needed libraries
+  gSystem->Load("libESD");
+  cerr<<"libESD loaded..."<<endl;
+  gSystem->Load("libANALYSIS.so");
+  cerr<<"libANALYSIS.so loaded..."<<endl;
+  gSystem->Load("libANALYSISRL.so");
+  cerr<<"libANALYSISRL.so loaded..."<<endl;
+
+  // Flow libraries 
+  gSystem->Load("libPWG2flow.so");
+  cerr<<"libPWG2flow.so loaded..."<<endl;
+  gROOT->LoadMacro("AliFlowLYZConstants.cxx+");
+  cerr<<"."<<endl;
+  gROOT->LoadMacro("AliAnalysisTaskRLLYZNewMethod.cxx+");
+  cerr<<"....."<<endl;
+
+  cout<<"---loaded libraries!---"<<endl;
+
+  // create the TChain. CreateESDChain() is defined in CreateESDChain.C
+  TChain* chain = CreateESDChain(dataDir, nRuns, offset);
+  cout<<"chain ("<<chain<<")"<<endl;
+  //cout << " * " << chain->GetEntriesFast() << "*" << endl;
+  //cout << " * " << chain->GetEntries() << " * " << endl ;
+
+  // input files (read) 
+  
+  TString firstRunFileName = "testTaskLYZ_firstrun.root" ;
+  TString secondRunFileName = "testTaskLYZ_secondrun.root" ;
+  TFile* fFirstRunFile = new TFile(firstRunFileName.Data(),"READ");
+  if(!fFirstRunFile || fFirstRunFile->IsZombie()) { cerr << " ERROR: NO first Run file... " << endl ; }
+  TFile* fSecondRunFile = new TFile(secondRunFileName.Data(),"READ");
+  if(!fSecondRunFile || fSecondRunFile->IsZombie()) { cerr << " ERROR: NO first Run file... " << endl ; }
+
+
+  //____________________________________________//
+  // Make the analysis manager
+  AliAnalysisManager *mgr = new AliAnalysisManager("TestLYZNMManager");
+  cout<<"---defined the manager---"<<endl;
+  //____________________________________________//
+  // 1st LYZ task
+  AliAnalysisTaskRLLYZNewMethod *task1 = new AliAnalysisTaskRLLYZNewMethod("LYZtest");
+  
+  //add tasks to manager
+  mgr->AddTask(task1);
+  cout<<"---task1 added---"<<endl;
+  
+  // Create containers for input/output
+  AliAnalysisDataContainer *cinput1 = 
+    mgr->CreateContainer("cchain1",TChain::Class(),AliAnalysisManager::kInputContainer);
+  cout<<"---created input container---"<<endl;
+  
+  AliAnalysisDataContainer *cinput2 = 
+    mgr->CreateContainer("cobj2",TList::Class(),AliAnalysisManager::kInputContainer);
+  cout<<"---created input container2---"<<endl; 
+  
+  AliAnalysisDataContainer *cinput3 = 
+    mgr->CreateContainer("cobj3",TList::Class(),AliAnalysisManager::kInputContainer);
+  cout<<"---created input container3---"<<endl; 
+  
+  AliAnalysisDataContainer *coutput1 = 
+    mgr->CreateContainer("cobj1", TList::Class());
+
+  
+  //____________________________________________//
+  mgr->ConnectInput(task1,0,cinput1);
+  cout<<"---ConnectInput(task1,0,cinput1)---"<<endl;
+  mgr->ConnectInput(task1,1,cinput2);
+  cout<<"---ConnectInput(task1,1,cinput2)---"<<endl; 
+  mgr->ConnectInput(task1,2,cinput3);
+  cout<<"---ConnectInput(task1,1,cinput3)---"<<endl; 
+  mgr->ConnectOutput(task1,0,coutput1);
+  cout<<"---ConnectOutput(task1,0,coutput1)---"<<endl;
+  
+  cerr<<"chain ("<<chain<<")"<<endl;
+  cinput1->SetData(chain);
+  cinput2->SetData(fFirstRunFile);
+  cinput3->SetData(fSecondRunFile);
+
+  if(mgr->InitAnalysis()) {
+    mgr->PrintStatus();
+    mgr->StartAnalysis("local",chain);
+  } 
+}
+
+
+// Helper macros for creating chains
+// from: CreateESDChain.C,v 1.10 jgrosseo Exp
+
+TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
+{
+  // creates chain of files in a given directory or file containing a list.
+  // In case of directory the structure is expected as:
+  // <aDataDir>/<dir0>/AliESDs.root
+  // <aDataDir>/<dir1>/AliESDs.root
+  // ...
+  
+  if (!aDataDir)
+    return 0;
+  
+  Long_t id, size, flags, modtime;
+  if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
+    {
+      printf("%s not found.\n", aDataDir);
+      return 0;
+    }
+  
+  TChain* chain = new TChain("esdTree");
+  TChain* chaingAlice = 0;
+  
+  if (flags & 2)
+    {
+      TString execDir(gSystem->pwd());
+      TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
+      TList* dirList            = baseDir->GetListOfFiles();
+      Int_t nDirs               = dirList->GetEntries();
+      gSystem->cd(execDir);
+      
+      Int_t count = 0;
+      
+      for (Int_t iDir=0; iDir<nDirs; ++iDir)
+       {
+         TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
+         if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
+           continue;
+         
+         if (offset > 0)
+           {
+             --offset;
+             continue;
+           }
+         
+         if (count++ == aRuns)
+           break;
+         
+         TString presentDirName(aDataDir);
+         presentDirName += "/";
+         presentDirName += presentDir->GetName();        
+         chain->Add(presentDirName + "/AliESDs.root/esdTree");
+         cerr<<presentDirName<<endl;
+       }
+      
+    }
+  else
+    {
+      // Open the input stream
+      ifstream in;
+      in.open(aDataDir);
+      
+      Int_t count = 0;
+      
+      // Read the input list of files and add them to the chain
+      TString esdfile;
+      while(in.good()) {
+       in >> esdfile;
+       if (!esdfile.Contains("root")) continue; // protection
+       
+       if (offset > 0)
+         {
+           --offset;
+           continue;
+         }
+       
+       if (count++ == aRuns)
+         break;
+       
+        // add esd file
+       chain->Add(esdfile);
+      }
+      
+      in.close();
+    }
+  
+  return chain;
+}
+
+void LookupWrite(TChain* chain, const char* target)
+{
+  // looks up the chain and writes the remaining files to the text file target
+  
+  chain->Lookup();
+  
+  TObjArray* list = chain->GetListOfFiles();
+  TIterator* iter = list->MakeIterator();
+  TObject* obj = 0;
+  
+  ofstream outfile;
+  outfile.open(target);
+  
+  while ((obj = iter->Next()))
+    outfile << obj->GetTitle() << "#AliESDs.root" << endl;
+  
+  outfile.close();
+  
+  delete iter;
+}
+