Initial classes for Lee Yang Zeroes from Naomi van der Kolk
authorsnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 28 Sep 2007 14:13:45 +0000 (14:13 +0000)
committersnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 28 Sep 2007 14:13:45 +0000 (14:13 +0000)
PWG2/FLOW/AliFlowLYZConstants.cxx [new file with mode: 0644]
PWG2/FLOW/AliFlowLYZConstants.h [new file with mode: 0644]
PWG2/FLOW/AliFlowLYZHist1.cxx [new file with mode: 0644]
PWG2/FLOW/AliFlowLYZHist1.h [new file with mode: 0644]
PWG2/FLOW/AliFlowLYZHist2.cxx [new file with mode: 0644]
PWG2/FLOW/AliFlowLYZHist2.h [new file with mode: 0644]
PWG2/FLOW/AliFlowLeeYangZerosMaker.cxx [new file with mode: 0644]
PWG2/FLOW/AliFlowLeeYangZerosMaker.h [new file with mode: 0644]

diff --git a/PWG2/FLOW/AliFlowLYZConstants.cxx b/PWG2/FLOW/AliFlowLYZConstants.cxx
new file mode 100644 (file)
index 0000000..9b12318
--- /dev/null
@@ -0,0 +1,38 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/*
+$Log$
+*/ 
+
+#include "AliFlowLYZConstants.h"  
+
+
+// Description: constants for the LYZ flow analysis
+// Author: Naomi van der Kolk (kolk@nikhef.nl)
+
+  
+Float_t AliFlowLYZConstants::fgMin       =  0. ;
+Float_t AliFlowLYZConstants::fgMax       =  1.6;
+Float_t AliFlowLYZConstants::fgEtaMin    = -2. ;
+Float_t AliFlowLYZConstants::fgEtaMax    =  2. ;
+Float_t AliFlowLYZConstants::fgPtMin     =  0. ;
+Float_t AliFlowLYZConstants::fgPtMax     = 10. ;
+  
+
+
+  
+
+
diff --git a/PWG2/FLOW/AliFlowLYZConstants.h b/PWG2/FLOW/AliFlowLYZConstants.h
new file mode 100644 (file)
index 0000000..e94ca09
--- /dev/null
@@ -0,0 +1,39 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+#ifndef ALIFLOWLYZCONSTANTS_H
+#define ALIFLOWLYZCONSTANTS_H
+
+#include <TROOT.h>
+
+
+// Description: constants for the LYZ flow makers
+
+
+namespace AliFlowLYZConstants {
+
+
+ // Enumerators
+  enum {
+    kTheta       = 5,                // number of reference angles theta
+    kNbins       = 500,              // number of bins in fHistGtheta (AliFlowLYZHist1)
+    kEtaBins     = 100,                     // number of eta bins in histograms (AliFlowLYZHist2)
+    kPtBins      = 100              // number of pT bins in histograms (AliFlowLYZHist2)
+  };
+
+ // Histograms limits
+  extern Float_t  fgMin ;            // lower limit for fHistGtheta (AliFlowLYZHist1)
+  extern Float_t  fgMax ;            // upper limit for fHistGtheta (AliFlowLYZHist1)
+  extern Float_t  fgEtaMin ;        // eta lower limit for histograms
+  extern Float_t  fgEtaMax ;        // eta upper limit for histograms
+  extern Float_t  fgPtMin ;         // pT lower limit for  histograms
+  extern Float_t  fgPtMax ;         // pT upper limit for  histograms
+  
+}
+
+#endif
+
diff --git a/PWG2/FLOW/AliFlowLYZHist1.cxx b/PWG2/FLOW/AliFlowLYZHist1.cxx
new file mode 100644 (file)
index 0000000..cb8c67f
--- /dev/null
@@ -0,0 +1,193 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/*
+$Log$
+*/ 
+
+#include "Riostream.h"
+#include "AliFlowLYZHist1.h"
+#include "AliFlowLYZConstants.h"  //??
+#include "TProfile.h"
+#include "TString.h" 
+#include "TComplex.h" 
+
+class TH1D; 
+
+
+// Class to organize the histograms in the first run
+// in the Lee Yang Zeros Flow analysis.
+// Also contains methods to find the first minimum R0
+// of the generating function.
+// author: N. van der Kolk (kolk@nikhef.nl)
+
+
+ClassImp(AliFlowLYZHist1)
+
+  
+
+//-----------------------------------------------------------------------
+
+  AliFlowLYZHist1::AliFlowLYZHist1(Int_t theta, Int_t har)
+{
+  //constructor creating histograms 
+  Int_t fNbins = AliFlowLYZConstants::kNbins;
+  Float_t fMin = AliFlowLYZConstants::fgMin;
+  Float_t fMax = AliFlowLYZConstants::fgMax;
+  TString title, name;
+  
+  //fHistGtheta
+  name = "FirstHist_FlowLYZ_Gtheta";
+  name +=theta;
+  name +="_Har";
+  name +=har;
+  title = "FirstHist_FlowLYZ_Gtheta";
+  title +=theta;
+  title +="_Har";
+  title +=har;
+  fHistGtheta = new TH1D(name.Data(),title.Data(),fNbins,fMin,fMax);  
+  fHistGtheta->SetXTitle("r");
+  fHistGtheta->SetYTitle("|G^{#theta}(ir)|^{2}");
+  
+  //fHistProReGtheta
+  name = "FirstHist_FlowProLYZ_ReGtheta";
+  name +=theta;
+  name +="_Har";
+  name +=har;
+  title = "FirstHist_FlowProLYZ_ReGtheta";
+  title +=theta;
+  title +="_Har";
+  title +=har;
+  fHistProReGtheta = new TProfile(name.Data(),title.Data(),fNbins,fMin,fMax);
+  fHistProReGtheta->SetXTitle("r");
+  fHistProReGtheta->SetYTitle("Re G^{#theta}(ir)");
+  
+  //fHistProImGtheta
+  name = "FirstHist_FlowProLYZ_ImGtheta";
+  name +=theta;
+  name +="_Har";
+  name +=har;
+  title = "FirstHist_FlowProLYZ_ImGtheta";
+  title +=theta;
+  title +="_Har";
+  title +=har;
+  fHistProImGtheta = new TProfile(name.Data(),title.Data(),fNbins,fMin,fMax);
+  fHistProImGtheta->SetXTitle("r");
+  fHistProImGtheta->SetYTitle("Im G^{#theta}(ir)");
+    
+   
+}
+  
+
+
+//----------------------------------------------------------------------- 
+
+AliFlowLYZHist1::~AliFlowLYZHist1()
+{
+  //deletes histograms
+  delete fHistGtheta;
+  delete fHistProReGtheta;
+  delete fHistProImGtheta;
+  
+}
+
+
+//----------------------------------------------------------------------- 
+
+void AliFlowLYZHist1::Fill(Float_t f, TComplex C)
+{
+  //fill the histograms
+
+  fHistProReGtheta->Fill(f, C.Re());
+  fHistProImGtheta->Fill(f, C.Im());
+  
+}
+
+
+//----------------------------------------------------------------------- 
+
+TH1D* AliFlowLYZHist1::FillGtheta()
+{
+  //fill the fHistGtheta histograms
+  Int_t fNbins = fHistGtheta->GetNbinsX();
+  for (Int_t bin=1;bin<=fNbins;bin++)
+       {
+         //get bincentre of bins in histogram
+         Float_t fBin = fHistGtheta->GetBinCenter(bin); 
+         Float_t fRe = fHistProReGtheta->GetBinContent(bin);
+         Float_t fIm = fHistProImGtheta->GetBinContent(bin);
+         TComplex fGtheta(fRe,fIm);
+         //fill fHistGtheta with the modulus squared of fGtheta
+         fHistGtheta->Fill(fBin,fGtheta.Rho2());
+       }
+
+  return fHistGtheta;
+}
+
+//----------------------------------------------------------------------- 
+
+Float_t AliFlowLYZHist1::GetR0()
+{
+  //find the first minimum of the square of the modulus of Gtheta 
+
+  Int_t fNbins = fHistGtheta->GetNbinsX();
+  Float_t fR0 = 0; 
+
+  for (Int_t b=2;b<fNbins;b++)
+    {
+      Float_t fG0 = fHistGtheta->GetBinContent(b);
+      Float_t fGnext = fHistGtheta->GetBinContent(b+1);
+      Float_t fGnextnext = fHistGtheta->GetBinContent(b+2);
+      //fprintf(fTemp,"%f\t %f\t %f\n",fG0,fGnext,fGnextnext);
+
+      if (fGnext > fG0 && fGnextnext > fG0)
+       {
+         Float_t fGlast = fHistGtheta->GetBinContent(b-1);
+         Float_t fXlast = fHistGtheta->GetBinCenter(b-1);
+         Float_t fX0 = fHistGtheta->GetBinCenter(b);
+         Float_t fXnext = fHistGtheta->GetBinCenter(b+1);
+
+         fR0 = fX0 - ((fX0-fXlast)*(fX0-fXlast)*(fG0-fGnext) - (fX0-fXnext)*(fX0-fXnext)*(fG0-fGlast))/
+           (2.*((fX0-fXlast)*(fG0-fGnext) - (fX0-fXnext)*(fG0-fGlast))); //interpolated minimum
+         
+         break; //stop loop if minimum is found
+       } //if
+
+    }//b
+
+      
+  return fR0;
+}
+   
+//----------------------------------------------------------------------- 
+Float_t AliFlowLYZHist1::GetBinCenter(Int_t i)
+{
+  //gets bincenter of histogram
+  Float_t fR = fHistGtheta->GetBinCenter(i);
+  return fR;
+
+}
+
+//----------------------------------------------------------------------- 
+
+Int_t AliFlowLYZHist1::GetNBins()
+{
+  //gets fNbins
+  Int_t fNbins = fHistGtheta->GetNbinsX();
+  return fNbins;
+
+}
+
diff --git a/PWG2/FLOW/AliFlowLYZHist1.h b/PWG2/FLOW/AliFlowLYZHist1.h
new file mode 100644 (file)
index 0000000..8cb33c8
--- /dev/null
@@ -0,0 +1,52 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+#ifndef AliFlowLYZHist1_H
+#define AliFlowLYZHist1_H
+
+
+#include "TComplex.h"  //explicitly called in void Fill(Float_t f, TComplex C);
+
+class TProfile;
+class TH1D;
+
+// Description: Class to organise histograms for Flow 
+//              by the LeeYangZeros method in the first run.
+//              Also includes methods to find the first minimum R0
+//              in the generating function.
+
+
+class AliFlowLYZHist1 {
+
+ public:
+
+  AliFlowLYZHist1(Int_t i1, Int_t i2);        //constructor
+  AliFlowLYZHist1(const AliFlowLYZHist1&);    //copy constructor (dummy)
+  virtual  ~AliFlowLYZHist1();                //destructor
+
+  AliFlowLYZHist1& operator=(const AliFlowLYZHist1&); //assignment operator (dummy)
+
+  void Fill(Float_t f, TComplex C);           //fill the histograms
+  TH1D* FillGtheta();                         //fills fHistGtheta
+  Float_t GetR0();                            //get R0
+  Float_t GetBinCenter(Int_t i);              //Get a bincentre of fHistGtheta
+  Int_t GetNBins();                           //Gets fNbins
+
+  //void Save();                              //save the histograms 
+
+private:
+
+  TH1D* fHistGtheta;                          //!
+  TProfile* fHistProReGtheta;                 //!
+  TProfile* fHistProImGtheta;                 //!
+  
+
+  ClassDef(AliFlowLYZHist1,0)                 // macro for rootcint
+    };
+     
+#endif
+
diff --git a/PWG2/FLOW/AliFlowLYZHist2.cxx b/PWG2/FLOW/AliFlowLYZHist2.cxx
new file mode 100644 (file)
index 0000000..e83bc46
--- /dev/null
@@ -0,0 +1,207 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/*
+$Log$
+*/ 
+
+#include "Riostream.h"
+#include "AliFlowLYZHist2.h"
+#include "AliFlowLYZConstants.h" //??
+#include "TProfile.h"
+#include "TProfile2D.h"
+#include "TString.h" 
+#include "TComplex.h"
+
+class TH1D;
+
+
+// Class to organize the histograms in the second run
+// in the Lee Yang Zeros Flow analysis.
+// Also contains methods to get values from the histograms
+// which are called in AliFlowLeeYandZerosMaker::Finish().
+// author: N. van der Kolk (kolk@nikhef.nl)
+
+
+ClassImp(AliFlowLYZHist2)
+
+  
+
+//-----------------------------------------------------------------------
+
+  AliFlowLYZHist2::AliFlowLYZHist2(Int_t theta, Int_t har)
+{
+  //constructor creating histograms 
+  TString title, name;
+  Int_t fEtaBins = AliFlowLYZConstants::kEtaBins;
+  Int_t fPtBins = AliFlowLYZConstants::kPtBins;
+  Float_t fEtaMin = AliFlowLYZConstants::fgEtaMin;
+  Float_t fEtaMax = AliFlowLYZConstants::fgEtaMax;
+  Float_t fPtMin = AliFlowLYZConstants::fgPtMin;
+  Float_t fPtMax = AliFlowLYZConstants::fgPtMax;
+
+  
+  //fHistProReNumer
+  name = "SecondHist_FlowProLYZ_ReNumer";
+  name +=theta;
+  name +="_Har";
+  name +=har;
+  title = "SecondHist_FlowProLYZ_ReNumer";
+  title +=theta;
+  title +="_Har";
+  title +=har;
+  fHistProReNumer = new TProfile(name.Data(),title.Data(),fEtaBins,fEtaMin,fEtaMax); 
+  fHistProReNumer->SetXTitle("eta");
+  fHistProReNumer->SetYTitle("v (%)");
+
+  //fHistProImNumer
+  name = "SecondHist_FlowProLYZ_ImNumer";
+  name +=theta;
+  name +="_Har";
+  name +=har;
+  title = "SecondHist_FlowProLYZ_ImNumer";
+  title +=theta;
+  title +="_Har";
+  title +=har;
+  fHistProImNumer = new TProfile(name.Data(),title.Data(),fEtaBins,fEtaMin,fEtaMax);  
+  fHistProImNumer->SetXTitle("eta");
+  fHistProImNumer->SetYTitle("v (%)");
+
+  //fHistProReNumerPt
+  name = "SecondHist_FlowProLYZ_ReNumerPt";
+  name +=theta;
+  name +="_Har";
+  name +=har;
+  title = "SecondHist_FlowProLYZ_ReNumerPt";
+  title +=theta;
+  title +="_Har";
+  title +=har;
+  fHistProReNumerPt = new TProfile(name.Data(),title.Data(),fPtBins,fPtMin,fPtMax); 
+  fHistProReNumerPt->SetXTitle("Pt");
+  fHistProReNumerPt->SetYTitle("v (%)");
+
+  //fHistProImNumerPt
+  name = "SecondHist_FlowProLYZ_ImNumerPt";
+  name +=theta;
+  name +="_Har";
+  name +=har;
+  title = "SecondHist_FlowProLYZ_ImNumerPt";
+  title +=theta;
+  title +="_Har";
+  title +=har;
+  fHistProImNumerPt = new TProfile(name.Data(),title.Data(),fPtBins,fPtMin,fPtMax);  
+  fHistProImNumerPt->SetXTitle("Pt");
+  fHistProImNumerPt->SetYTitle("v (%)");
+
+  //fHistProReNumer2D
+  name = "SecondHist_FlowProLYZ_ReNumer2D";
+  name +=theta;
+  name +="_Har";
+  name +=har;
+  title = "SecondHist_FlowProLYZ_ReNumer2D";
+  title +=theta;
+  title +="_Har";
+  title +=har;
+  fHistProReNumer2D = new TProfile2D(name.Data(),title.Data(),fEtaBins,fEtaMin,fEtaMax,fPtBins,fPtMin,fPtMax);  
+  fHistProReNumer2D->SetXTitle("eta");
+  fHistProReNumer2D->SetYTitle("Pt (GeV/c)");
+
+  //fHistProImNumer2D 
+  name = "SecondHist_FlowProLYZ_ImNumer2D";
+  name +=theta;
+  name +="_Har";
+  name +=har;
+  title = "SecondHist_FlowProLYZ_ImNumer2D";
+  title +=theta;
+  title +="_Har";
+  title +=har;
+  fHistProImNumer2D = new TProfile2D(name.Data(),title.Data(),fEtaBins,fEtaMin,fEtaMax,fPtBins,fPtMin,fPtMax);  
+  fHistProImNumer2D->SetXTitle("eta");
+  fHistProImNumer2D->SetYTitle("Pt (GeV/c)");
+
+  
+  
+}
+
+
+
+//----------------------------------------------------------------------- 
+
+AliFlowLYZHist2::~AliFlowLYZHist2()
+{
+  //deletes histograms
+  delete fHistProReNumer;
+  delete fHistProImNumer;
+  delete fHistProReNumerPt;
+  delete fHistProImNumerPt;
+  delete fHistProReNumer2D;
+  delete fHistProImNumer2D;
+
+}
+
+
+//----------------------------------------------------------------------- 
+
+void AliFlowLYZHist2::Fill(Float_t f1, Float_t f2, TComplex C)
+{
+  //fill the real and imaginary part of fNumer
+
+  fHistProReNumer->Fill(f1, C.Re());  
+  fHistProImNumer->Fill(f1, C.Im());
+   
+  fHistProReNumerPt->Fill(f2, C.Re());  
+  fHistProImNumerPt->Fill(f2, C.Im());
+  
+  fHistProReNumer2D->Fill(f1, f2, C.Re());          
+  fHistProImNumer2D->Fill(f1, f2, C.Im());           
+}
+
+//-----------------------------------------------------------------------
+TComplex AliFlowLYZHist2::GetfNumer(Int_t i)
+{
+  //get the real and imaginary part of fNumer
+  Float_t fReNumer = fHistProReNumer->GetBinContent(i);
+  Float_t fImNumer = fHistProImNumer->GetBinContent(i);
+  TComplex fNumer(fReNumer,fImNumer);
+  //if (fNumer.Rho()==0) {cerr<<"modulus of fNumer is zero in AliFlowLYZHist2::GetfNumer(Int_t i)"<<endl;}
+  return fNumer;
+}
+
+//----------------------------------------------------------------------- 
+TComplex AliFlowLYZHist2::GetfNumerPt(Int_t i)
+{
+  //get the real and imaginary part of fNumer
+  Float_t fReNumer = fHistProReNumerPt->GetBinContent(i);
+  Float_t fImNumer = fHistProImNumerPt->GetBinContent(i);
+  TComplex fNumer(fReNumer,fImNumer);
+  return fNumer;
+}
+
+//----------------------------------------------------------------------- 
+Int_t AliFlowLYZHist2::GetNprime(Int_t i)
+{
+  //Get the number of entries in the bin 
+  Int_t Nprime = fHistProReNumer->GetBinEntries(i);
+  return Nprime;
+}
+
+//----------------------------------------------------------------------- 
+Int_t AliFlowLYZHist2::GetNprimePt(Int_t i)
+{
+  //Get the number of entries in the bin 
+  Int_t Nprime = fHistProReNumerPt->GetBinEntries(i);
+  return Nprime;
+}
diff --git a/PWG2/FLOW/AliFlowLYZHist2.h b/PWG2/FLOW/AliFlowLYZHist2.h
new file mode 100644 (file)
index 0000000..a33ccd4
--- /dev/null
@@ -0,0 +1,60 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+#ifndef AliFlowLYZHist2_H
+#define AliFlowLYZHist2_H
+
+#include "TComplex.h"
+#include "TProfile.h"   //no forward declaration possible because of inline functions
+
+class TProfile2D;
+
+
+// Description: Class to organise histograms for Flow
+//              by the LeeYangZeros method in the second run.
+//              Also contains methods to get values from the histograms
+//              which are called in AliFlowLeeYandZerosMaker::Finish().
+
+
+class AliFlowLYZHist2 {
+
+ public:
+
+  AliFlowLYZHist2(Int_t i1, Int_t i2);          //constructor
+  AliFlowLYZHist2(const AliFlowLYZHist2&);      //copy constructor (dummy)
+  virtual  ~AliFlowLYZHist2();                  //destructor
+
+  AliFlowLYZHist2& operator=(const AliFlowLYZHist2&);  //assignment operator (dummy)
+
+  void Fill(Float_t f1,Float_t f2, TComplex C); //fill the histograms
+  Int_t GetNbinsX()                {Int_t fMaxEtaBins = fHistProReNumer->GetNbinsX();  return fMaxEtaBins;}     
+  Int_t GetNbinsXPt()              {Int_t fMaxPtBins = fHistProReNumerPt->GetNbinsX(); return fMaxPtBins;}
+  Float_t GetBinCenter(Int_t i)    {Float_t fEta = fHistProReNumer->GetXaxis()->GetBinCenter(i);  return fEta;}
+  Float_t GetBinCenterPt(Int_t i)  {Float_t fPt = fHistProReNumerPt->GetXaxis()->GetBinCenter(i); return fPt;}
+  TComplex GetfNumer(Int_t i);     //get numerator for diff. flow (eta)
+  TComplex GetfNumerPt(Int_t i);   //get numerator for diff. flow (pt)
+  Int_t GetNprime(Int_t i);        //get number of entries in bin (eta)
+  Int_t GetNprimePt(Int_t i);      //get number of entries in bin (pt) 
+
+
+ private:
+  
+  TProfile* fHistProReNumer;                     //!
+  TProfile* fHistProImNumer;                     //!
+  TProfile* fHistProReNumerPt;                   //!
+  TProfile* fHistProImNumerPt;                   //!
+  TProfile2D* fHistProReNumer2D;                 //!
+  TProfile2D* fHistProImNumer2D;                 //!
+  
+
+
+
+
+  ClassDef(AliFlowLYZHist2,0)                    // macro for rootcint
+    };
+     
+#endif
+
diff --git a/PWG2/FLOW/AliFlowLeeYangZerosMaker.cxx b/PWG2/FLOW/AliFlowLeeYangZerosMaker.cxx
new file mode 100644 (file)
index 0000000..ca3e4a1
--- /dev/null
@@ -0,0 +1,1089 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/*
+$Log$
+*/ 
+
+#include "Riostream.h"
+#include "AliFlowLeeYangZerosMaker.h"
+#include "AliFlowEvent.h"
+#include "AliFlowSelection.h"
+#include "AliFlowConstants.h"     //??
+#include "AliFlowLYZHist1.h"
+#include "AliFlowLYZHist2.h"
+#include "AliFlowLYZConstants.h"  //??
+//#include "AliFlowLYZSummary.h"
+
+#include "TMath.h"
+#include "TComplex.h" 
+#include "TProfile.h"
+#include "TObjArray.h"
+#include "TFile.h"
+#include "TVector.h"
+#include "TVector2.h"
+#include "TGraphErrors.h"
+#include "TCanvas.h"
+
+class TTree;
+class TH1F;
+class TH1D;
+class TVector3;
+class TProfile2D;
+class TObject;
+
+//class Riostream; //does not compile
+//class TMath;     //does not compile
+//class TVector;   //does not compile
+
+//Description: Maker to analyze Flow using the LeeYangZeros method  
+//             Equation numbers are from Big Paper (BP): Nucl. Phys. A 727, 373 (2003)
+//             Practical Guide (PG):    J. Phys. G: Nucl. Part. Phys. 30, S1213 (2004)  
+//             Adapted from StFlowLeeYangZerosMaker.cxx           
+//             by Markus Oldenberg and Art Poskanzer, LBNL        
+//             with advice from Jean-Yves Ollitrault and Nicolas Borghini   
+//
+//Author: Naomi van der Kolk (kolk@nikhef.nl)
+
+
+
+ClassImp(AliFlowLeeYangZerosMaker)
+
+ //-----------------------------------------------------------------------
+  AliFlowLeeYangZerosMaker::AliFlowLeeYangZerosMaker():
+    fFirstRun(kTRUE),
+    fUseSum(kTRUE),
+    fDebug(kFALSE),
+    fHistFileName(0),
+    fHistFile(0),
+    fSummaryFile(0),
+    firstRunFile(0)
+
+{
+  //default constructor
+  if (fDebug) cout<<"****AliFlowLeeYangZerosMaker::AliFlowLeeYangZerosMaker default constructor****"<<endl;
+
+  fFlowSelect = new AliFlowSelection();
+  if (fDebug) { cerr<<"****fFlowSelect in constructor AliFlowLeeYangZerosMaker ("<<fFlowSelect<<")****"<<endl;}
+  // output file (histograms)
+  TString fHistFileName = "flowLYZAnalysPlot.root" ;
+}
+
+AliFlowLeeYangZerosMaker::AliFlowLeeYangZerosMaker(const AliFlowSelection* flowSelect):
+  fFirstRun(kTRUE),
+  fUseSum(kTRUE),
+  fDebug(kFALSE),
+  fHistFileName(0),
+  fHistFile(0),
+  fSummaryFile(0),
+  firstRunFile(0)
+{
+  //custum constructor
+  if (fDebug) cout<<"****AliFlowLeeYangZerosMaker::AliFlowLeeYangZerosMaker custum constructor****"<<endl;
+
+  if(flowSelect) { fFlowSelect = new AliFlowSelection(*flowSelect); }
+  else           { 
+    fFlowSelect = new AliFlowSelection() ; 
+    if (fDebug) cerr<<"****fFlowSelect in constructor AliFlowLeeYangZerosMaker ("<<fFlowSelect<<")****"<<endl;
+  }
+  // output file (histograms)
+  TString fHistFileName = "flowLYZAnalysPlot.root" ;
+}
+ //-----------------------------------------------------------------------
+
+
+ AliFlowLeeYangZerosMaker::~AliFlowLeeYangZerosMaker() 
+ {
+   //default destructor
+   if (fDebug) cout<<"****~AliFlowLeeYangZerosMaker****"<<endl;
+   delete fHistFile;
+ }
+ //-----------------------------------------------------------------------
+
+Bool_t AliFlowLeeYangZerosMaker::Init() 
+{
+  //init method 
+  if (fDebug) cout<<"****AliFlowLeeYangZerosMaker::Init()****"<<endl;
+
+  // Open output files (->plots)
+  fHistFile = new TFile(fHistFileName.Data(), "RECREATE");
+  //fHistFile->cd() ;  //all histograms will be saved in this file
+
+  //for each harmonic ???
+  fQsum.Set(0.,0.);
+  fQ2sum = 0.;
+  
+  // Book histograms
+  Int_t fNtheta = AliFlowLYZConstants::kTheta;
+  
+  
+  //for control histograms
+  fHistOrigMult = new TH1F("Control_FlowLYZ_OrigMult", "Control_FlowLYZ_OrigMult",1000, 0., 10000.);
+  fHistOrigMult->SetXTitle("Original Multiplicity");
+  fHistOrigMult->SetYTitle("Counts");
+
+  fHistMult = new TH1F("Control_FlowLYZ_Mult", "Control_FlowLYZ_Mult",1000, 0., 10000.);
+  fHistMult->SetXTitle("Multiplicity from selection");
+  fHistMult->SetYTitle("Counts");
+
+  fHistQ = new TH1F("Control_FlowLYZ_Q","Control_FlowLYZ_Q",500, 0., 10.);
+  fHistQ->SetXTitle("Qvector");
+  fHistQ->SetYTitle("Counts");
+
+  fHistPt = new TH1F("Control_FlowLYZ_Pt","Control_FlowLYZ_Pt",200, 0., 10.);
+  fHistPt->SetXTitle("Pt (GeV/c)");
+  fHistPt->SetYTitle("Counts");
+
+  fHistPhi = new TH1F("Control_FlowLYZ_Phi","Control_FlowLYZ_Phi",70, 0., 7.);
+  fHistPhi->SetXTitle("Phi");
+  fHistPhi->SetYTitle("Counts");
+
+  fHistEta = new TH1F("Control_FlowLYZ_Eta","Control_FlowLYZ_Eta",40, 0., 2.);
+  fHistEta->SetXTitle("Eta");
+  fHistEta->SetYTitle("Counts");
+
+  fHistQtheta = new TH1F("Control_FlowLYZ_Qtheta","Control_FlowLYZ_Qtheta",50,-1000.,1000.);
+  fHistQtheta->SetXTitle("Qtheta");
+  fHistQtheta->SetYTitle("Counts");
+  
+  if (fFirstRun){
+    //for first loop over events
+    fHistProR0thetaHar1  = new TProfile("First_FlowProLYZ_r0theta_Har1","First_FlowProLYZ_r0theta_Har1",fNtheta,-0.5,fNtheta-0.5);
+    fHistProR0thetaHar1->SetXTitle("#theta");
+    fHistProR0thetaHar1->SetYTitle("r_{0}^{#theta}");
+  
+    fHistProR0thetaHar2  = new TProfile("First_FlowProLYZ_r0theta_Har2","First_FlowProLYZ_r0theta_Har2",fNtheta,-0.5,fNtheta-0.5);
+    fHistProR0thetaHar2->SetXTitle("#theta");
+    fHistProR0thetaHar2->SetYTitle("r_{0}^{#theta}");
+
+    fHistProVthetaHar1  = new TProfile("First_FlowProLYZ_Vtheta_Har1","First_FlowProLYZ_Vtheta_Har1",fNtheta,-0.5,fNtheta-0.5);
+    fHistProVthetaHar1->SetXTitle("#theta");
+    fHistProVthetaHar1->SetYTitle("V_{n}^{#theta}");
+
+    fHistProVthetaHar2  = new TProfile("First_FlowProLYZ_Vtheta_Har2","First_FlowProLYZ_Vtheta_Har2",fNtheta,-0.5,fNtheta-0.5);
+    fHistProVthetaHar2->SetXTitle("#theta");
+    fHistProVthetaHar2->SetYTitle("V_{n}^{#theta}");
+
+    fHistProVR0 = new TProfile("First_FlowProLYZ_vR0","First_FlowProLYZ_vR0",2,0.5,2.5,-100.,100.);
+    fHistProVR0->SetXTitle("Harmonic");
+    fHistProVR0->SetYTitle("v integrated from r0 (%)");
+
+    fHistVR0 = new TH1D("First_FlowLYZ_vR0","First_FlowLYZ_vR0",2,0.5,2.5);
+    fHistVR0->SetXTitle("Harmonic");
+    fHistVR0->SetYTitle("v integrated from r0 (%)");
+
+    fHistProV = new TProfile("First_FlowProLYZ_V","First_FlowProLYZ_V",2,0.5,2.5,-1000.,1000.);
+    fHistProV->SetXTitle("Harmonic");
+    fHistProV->SetYTitle("v integrated");
+  
+    //class AliFlowLYZHist1 defines the histograms: fHistProGtheta, fHistProReGtheta, fHistProImGtheta, fHistProR0theta
+    for (Int_t j=0;j<AliFlowConstants::kHars;j++)  
+      {
+       for (Int_t theta=0;theta<fNtheta;theta++)
+         {  
+           fHist1[j][theta]=new AliFlowLYZHist1(theta,j+1);
+         }
+      }
+  }
+  else {
+    //for second loop over events
+    fHistProReDenomHar1 = new TProfile("Second_FlowProLYZ_ReDenom_Har1","Second_FlowProLYZ_ReDenom_Har1" , fNtheta, -0.5, fNtheta-0.5);
+    fHistProReDenomHar1->SetXTitle("#theta");
+    fHistProReDenomHar1->SetYTitle("Re(Q^{#theta}e^{ir_{0}^{#theta}Q^{#theta}})");
+
+    fHistProReDenomHar2 = new TProfile("Second_FlowProLYZ_ReDenom_Har2","Second_FlowProLYZ_ReDenom_Har2" , fNtheta, -0.5, fNtheta-0.5);
+    fHistProReDenomHar2->SetXTitle("#theta");
+    fHistProReDenomHar2->SetYTitle("Re(Q^{#theta}e^{ir_{0}^{#theta}Q^{#theta}})");
+
+    fHistProImDenomHar1 = new TProfile("Second_FlowProLYZ_ImDenom_Har1","Second_FlowProLYZ_ImDenom_Har1" , fNtheta, -0.5, fNtheta-0.5);
+    fHistProImDenomHar1->SetXTitle("#theta");
+    fHistProImDenomHar1->SetYTitle("Im(Q^{#theta}e^{ir_{0}^{#theta}Q^{#theta}})");
+
+    fHistProImDenomHar2 = new TProfile("Second_FlowProLYZ_ImDenom_Har2","Second_FlowProLYZ_ImDenom_Har2" , fNtheta, -0.5, fNtheta-0.5);
+    fHistProImDenomHar2->SetXTitle("#theta");
+    fHistProImDenomHar2->SetYTitle("Im(Q^{#theta}e^{ir_{0}^{#theta}Q^{#theta}})");
+
+    fHistProVetaHar1 = new TProfile("Second_FlowProLYZ_Veta_Har1","Second_FlowProLYZ_Veta_Har1",40,-2.,2.);
+    fHistProVetaHar1->SetXTitle("rapidity");
+    fHistProVetaHar1->SetYTitle("v (%)");
+
+    fHistProVetaHar2 = new TProfile("Second_FlowProLYZ_Veta_Har2","Second_FlowProLYZ_Veta_Har2",40,-2.,2.);
+    fHistProVetaHar2->SetXTitle("rapidity");
+    fHistProVetaHar2->SetYTitle("v (%)");
+
+    fHistProVPtHar1 = new TProfile("Second_FlowProLYZ_VPt_Har1","Second_FlowProLYZ_VPt_Har1",100,0.,10.);
+    fHistProVPtHar1->SetXTitle("Pt");
+    fHistProVPtHar1->SetYTitle("v (%)");
+
+    fHistProVPtHar2 = new TProfile("Second_FlowProLYZ_VPt_Har2","Second_FlowProLYZ_VPt_Har2",100,0.,10.);
+    fHistProVPtHar2->SetXTitle("Pt");
+    fHistProVPtHar2->SetYTitle("v (%)");
+
+    fHistVPtHar2 = new TH1D("Second_FlowLYZ_VPt_Har2","Second_FlowLYZ_VPt_Har2",100,0.,10.);
+    fHistVPtHar2->SetXTitle("Pt");
+    fHistVPtHar2->SetYTitle("v (%)");
+
+    fHistProReDtheta = new TProfile("Second_FlowProLYZ_ReDtheta_Har2","Second_FlowProLYZ_ReDtheta_Har2",fNtheta, -0.5, fNtheta-0.5);
+    fHistProReDtheta->SetXTitle("#theta");
+    fHistProReDtheta->SetYTitle("Re(D^{#theta})");
+
+    fHistProImDtheta = new TProfile("Second_FlowProLYZ_ImDtheta_Har2","Second_FlowProLYZ_ImDtheta_Har2",fNtheta, -0.5, fNtheta-0.5);
+    fHistProImDtheta->SetXTitle("#theta");
+    fHistProImDtheta->SetYTitle("Im(D^{#theta})");
+
+
+    //class AliFlowLYZHist2 defines the histograms: 
+    for (Int_t j=0;j<AliFlowConstants::kHars;j++) 
+      {
+       for (Int_t theta=0;theta<fNtheta;theta++)
+         {  
+           fHist2[j][theta]=new AliFlowLYZHist2(theta,j+1);
+         }
+      }
+
+    //read hists from first run file
+    //firstRunFile = new TFile("fof_flowLYZAnal_firstrun.root","READ");  //default is read
+    if (firstRunFile->IsZombie()){ //check if file exists
+      cout << "Error opening file, run first with fFirstrun = kTRUE" << endl;
+      exit(-1);
+    } else if (firstRunFile->IsOpen()){
+      cout<<"----firstRunFile is open----"<<endl<<endl;
+      fHistProVthetaHar1  = (TProfile*)firstRunFile->Get("First_FlowProLYZ_Vtheta_Har1");
+      fHistProVthetaHar2  = (TProfile*)firstRunFile->Get("First_FlowProLYZ_Vtheta_Har2");
+      fHistProR0thetaHar2  = (TProfile*)firstRunFile->Get("First_FlowProLYZ_r0theta_Har2");
+      fHistProV = (TProfile*)firstRunFile->Get("First_FlowProLYZ_V");
+    }    
+  }
+   
+
+  if (fDebug) cout<<"****Histograms initialised****"<<endl;
+  if (fDebug) cout<<"****fFlowSelect in Init() "<<fFlowSelect<<"****"<<endl;
+   
+  fEventNumber = 0; //set event counter to zero
+  /*
+  if (fUseSum)
+    {
+      //initialize LYZ summary class
+      fLYZSummary = new AliFlowLYZSummary(); 
+      fSummaryFile = new TFile("fFlowSummary.root","RECREATE","Flow LYZ summary file");
+      fSummaryFile->SetCompressionLevel(1);
+      fFlowTree = new TTree("FlowTree", "Flow Summary Tree");
+      fFlowTree->SetAutoSave(1000000);  // autosave when 1 Mbyte written
+      fFlowTree->Branch("fLYZSummary","AliFlowLYZSummary",&fLYZSummary,25000,99);
+    }
+  */
+  return kTRUE; 
+}
+ //-----------------------------------------------------------------------
+Bool_t AliFlowLeeYangZerosMaker::Make(AliFlowEvent* fFlowEvent) 
+{
+  //make method
+  if (fDebug) cout<<"****AliFlowLeeYangZerosMaker::Make()****"<<endl;
+        
+  //get tracks from event
+  if (fFlowEvent) {
+    fFlowTracks = fFlowEvent->TrackCollection();
+    if (fDebug) cout<<"****fFlowSelect in Make() "<<fFlowSelect<<"****"<<endl;
+    if (fDebug) fFlowSelect->PrintSelectionList() ;
+    if (fDebug) fFlowSelect->PrintList() ;
+     
+    if (fFlowSelect && fFlowSelect->Select(fFlowEvent))   // check if event is selected
+      {  
+       fFlowTracks = fFlowEvent->TrackCollection();     //get tracks from event
+       fFlowEvent->SetSelections(fFlowSelect) ;                // does the selection of tracks for r.p. calculation (sets flags in AliFlowTrack)
+       if (fFirstRun){
+         MakeControlHistograms(fFlowEvent);
+         FillFromFlowEvent(fFlowEvent);
+       }
+       else {
+         MakeControlHistograms(fFlowEvent);
+         SecondFillFromFlowEvent(fFlowEvent);
+       }
+      }
+  }
+  else {
+    cout<<"##### FlowLeeYangZero: FlowEvent pointer null"<<endl;
+    return kFALSE;
+  }
+
+  fEventNumber++;
+     
+  return kTRUE; 
+}
+
+
+  //-----------------------------------------------------------------------     
+ Bool_t AliFlowLeeYangZerosMaker::Finish() 
+{
+  //finish method
+  if (fDebug) cout<<"****AliFlowLeeYangZerosMaker::Finish()****"<<endl; 
+  
+ //define variables for both runs
+  Float_t  fR0 = 0;
+  Float_t  fv = 0;
+  Float_t  fVtheta = 0; 
+  Float_t  fSigma2 = 0;
+  Float_t  fChi= 0;
+  Float_t  fJ01 = 2.405; 
+  Int_t fNtheta = AliFlowLYZConstants::kTheta;
+  Float_t  fV = 0; 
+  
+  if (fFirstRun){
+    for (Int_t j=0;j<AliFlowConstants::kHars;j++)    
+      //loop over harmonics j=0 ->first harmonic, j=1 ->second harmonic
+      {
+       Float_t  fMeanMult = fHistMult->GetMean();
+       //cerr<<"fMeanMult = "<<fMeanMult<<endl;
+
+       for (Int_t theta=0;theta<fNtheta;theta++)
+         {
+           //get the first minimum r0
+           fHist1[j][theta]->FillGtheta();
+           fR0 = fHist1[j][theta]->GetR0();
+           //cerr<<"fR0 = "<<fR0<<endl;
+                  
+           //calculate integrated flow
+           if (fR0!=0) fVtheta = fJ01/fR0;
+           if (fMeanMult!=0.) 
+             {
+               fv = fVtheta/fMeanMult;
+               cerr<<"fv = "<<fv<<endl;
+             }
+          
+
+           //fill the histograms
+           if (j==0) 
+             {
+               fHistProR0thetaHar1->Fill(theta,fR0);
+               fHistProVthetaHar1->Fill(theta,fVtheta);
+               fHistProV->Fill(j+1,fVtheta);    //profile takes care of the averaging over theta.
+             }
+           if (j==1) 
+             {
+               fHistProR0thetaHar2->Fill(theta,fR0);
+               fHistProVthetaHar2->Fill(theta,fVtheta);
+               fHistProV->Fill(j+1,fVtheta);   //profile takes care of the averaging over theta.
+             }
+            
+           fHistProVR0->Fill(j+1,fv*100);    //*100 to get %     //profile takes care of the averaging over theta.              
+         
+         } //end of loop over theta
+       
+       //sigma2 and chi 
+       if (j==1)   //second harmonic only temporarily
+         { 
+           if (fEventNumber!=0) {
+             fQsum /= fEventNumber;
+             //cerr<<"fQsum.X() = "<<fQsum.X()<<endl;
+             //cerr<<"fQsum.Y() = "<<fQsum.Y()<<endl;
+             fQ2sum /= fEventNumber;
+             //cerr<<"fQ2sum = "<<fQ2sum<<endl;
+             fV = fHistProV->GetBinContent(j+1);
+             fSigma2 = fQ2sum - TMath::Power(fQsum.X(),2.) - TMath::Power(fQsum.Y(),2.) - TMath::Power(fV,2.);  //BP eq. 62
+             if (fSigma2>0) fChi = fV/TMath::Sqrt(fSigma2);
+             else fChi = -1.;
+             cerr<<"fV = "<<fV<<" and chi = "<<fChi<<endl;
+           }
+          
+         } //j==1
+
+      } //end of loop over harmonics
+
+    // recalculate statistical errors on integrated flow
+    //combining 5 theta angles to 1 relative error BP eq. 89
+    Double_t fRelErr2comb = 0.;
+    Int_t nEvts = fEventNumber;
+    for (Int_t theta=0;theta<fNtheta;theta++){
+      Double_t fTheta = ((double)theta/fNtheta)*TMath::Pi(); 
+      Double_t fApluscomb = TMath::Exp((fJ01*fJ01)/(2*fChi*fChi)*
+                                      TMath::Cos(fTheta));
+      Double_t fAmincomb = TMath::Exp(-(fJ01*fJ01)/(2*fChi*fChi)*
+                                     TMath::Cos(fTheta));
+      fRelErr2comb += (1/(2*nEvts*(fJ01*fJ01)*TMath::BesselJ1(fJ01)*
+                         TMath::BesselJ1(fJ01)))*
+       (fApluscomb*TMath::BesselJ0(2*fJ01*TMath::Sin(fTheta/2)) + 
+        fAmincomb*TMath::BesselJ0(2*fJ01)*TMath::Cos(fTheta/2));
+    }
+    fRelErr2comb /= fNtheta;
+    Double_t fRelErrcomb = TMath::Sqrt(fRelErr2comb);
+    cerr<<"fRelErrcomb = "<<fRelErrcomb<<endl;         
+
+    //copy content of profile into TH1D and add error
+    for(Int_t b=0;b<2;b++){
+      Double_t fv2pro = fHistProVR0->GetBinContent(b+1);
+      fHistVR0->SetBinContent(b+1,fv2pro);
+      Double_t fv2Err = fv2pro*fRelErrcomb ; 
+      cerr<<"fv2pro +- fv2Err = "<<fv2pro<<" +- "<<fv2Err<<" for bin "<<b+1<<endl;
+      fHistVR0->SetBinError(b+1,fv2Err);
+    }
+   
+
+    if (fDebug) cout<<"****histograms filled****"<<endl;  
+    /*
+      if (fUseSum)
+      {
+      if (fSummaryFile->IsOpen())
+      {
+      fSummaryFile->Write(0,TObject::kOverwrite);
+      fSummaryFile->Close();
+      }
+      }
+    */
+    
+    //save histograms in file //temp for testing selector
+    fHistFile->cd();
+    fHistFile->Write();
+
+    return kTRUE;
+    fEventNumber =0; //set to zero for second round over events
+  }  //firstrun
+   
+  else {  //second run
+   
+    //calculate differential flow
+    //declare variables
+    Float_t fEta, fPt, fReRatio, fVeta, fVPt;
+    Float_t fReDenom = 0;
+    Float_t fImDenom = 0; 
+    Double_t fR0 = 0;
+    TComplex fDenom, fNumer, fDtheta;
+    Int_t m = 1;
+    TComplex i = TComplex::I();
+    Float_t fBesselRatio[3] = {1., 1.202, 2.69};
+    Double_t fErrdifcomb = 0.;  //set error to zero
+    Double_t fErr2difcomb = 0.; //set error to zero
+    /*
+    //v1 integrated
+    for (Int_t j=0;j<AliFlowConstants::kHars;j++)   //loop over harmonics j=0 ->first harmonic, j=1 ->second harmonic
+    {
+    for (Int_t theta=0;theta<fNtheta;theta++)
+    {
+    //get the first minimum r0
+    //fR0 = GetR0(fHist1[j][theta]->FillGtheta()); 
+
+    fReDenom = fHistProReDenomHar2->GetBinContent(theta+1);
+    fImDenom = fHistProImDenomHar2->GetBinContent(theta+1);
+    TComplex fDenom(fReDenom,fImDenom);
+         
+    //complete!!
+
+    }//end of loop over theta
+    }//end of loop over harmonics
+    */
+
+    //differential flow
+    //for (Int_t j=0;j<AliFlowConstants::kHars;j++)    //loop over harmonics j=0 ->first harmonic, j=1 ->second harmonic
+    //{
+    Int_t j=1; //temp only harm 2
+    //fFlowSelect->SetHarmonic(j);  //not needed here?
+     
+    for (Int_t theta=0;theta<fNtheta;theta++)  { //loop over theta
+      if (j==0) {
+       fR0 = fHistProR0thetaHar1->GetBinContent(theta+1);
+       fVtheta = 2.405/fR0;
+       //fVtheta =  fHistProVthetaHar1->GetBinContent(theta+1);  // BP Eq. 9  -> Vn^theta = j01/r0^theta
+       fReDenom = fHistProReDenomHar1->GetBinContent(theta+1);
+       fImDenom = fHistProImDenomHar1->GetBinContent(theta+1);
+      }
+      if (j==1) {
+       fR0 = fHistProR0thetaHar2->GetBinContent(theta+1);
+       if (fDebug) cerr<<"fR0 = "<<fR0<<endl;
+       fVtheta = 2.405/fR0;                                    // BP Eq. 9  -> Vn^theta = j01/r0^theta
+       fReDenom = fHistProReDenomHar2->GetBinContent(theta+1);
+       fImDenom = fHistProImDenomHar2->GetBinContent(theta+1);
+      }
+        
+      fDenom(fReDenom,fImDenom);
+        
+
+      //for new method and use by others (only with the sum generating function):
+      if (fUseSum) {
+       fR0 = fHistProR0thetaHar2->GetBinContent(theta+1); 
+       fDtheta = fR0*fDenom;
+       fHistProReDtheta->Fill(theta,fDtheta.Re());
+       fHistProImDtheta->Fill(theta,fDtheta.Im());
+      }
+        
+      fDenom *= TComplex::Power(i, m-1);
+      //cerr<<"TComplex::Power(i, m-1) = "<<TComplex::Power(i, m-1).Rho()<<endl; //checked ok
+        
+      //v as a function of eta   
+      Int_t fEtaBins = AliFlowLYZConstants::kEtaBins;
+      for (Int_t be=1;be<=fEtaBins;be++)  {
+       fEta = fHist2[j][theta]->GetBinCenter(be);
+       fNumer = fHist2[j][theta]->GetfNumer(be);
+       if (fNumer.Rho()==0) {
+         if (fDebug) cerr<<"WARNING: modulus of fNumer is zero in Finish()"<<endl;
+         fReRatio = 0;
+       }
+       else if (fDenom.Rho()==0) {
+         if (fDebug) cerr<<"WARNING: modulus of fDenom is zero"<<endl;
+         fReRatio = 0;
+       }
+       else {
+         //if ( j==1 && theta==0) cerr<<"modulus of fNumer = "<<fNumer.Rho() <<endl; //always a number smaller than 1, or 0.
+         fReRatio = (fNumer/fDenom).Re();
+       }
+
+       fVeta = fBesselRatio[m-1]*fReRatio*fVtheta*100.; //BP eq. 12
+       //if ( j==1 && theta==0) cerr<<"eta = "<<fEta<<" cerr::fReRatio for eta = "<<fReRatio<<" cerr::fVeta for eta = "<<fVeta<<endl;
+                     
+       if (j==0) fHistProVetaHar1->Fill(fEta,fVeta);
+       if (j==1) fHistProVetaHar2->Fill(fEta,fVeta);
+      } //loop over bins be
+        
+       //v as a function of Pt
+      Int_t fPtBins = AliFlowLYZConstants::kPtBins;
+      for (Int_t bp=1;bp<=fPtBins;bp++)  {
+       fPt = fHist2[j][theta]->GetBinCenterPt(bp);
+       fNumer = fHist2[j][theta]->GetfNumerPt(bp);
+       if (fNumer.Rho()==0) {
+         if (fDebug) cerr<<"modulus of fNumer is zero"<<endl;
+         fReRatio = 0;
+       }
+       else if (fDenom.Rho()==0) {
+         if (fDebug) cerr<<"modulus of fDenom is zero"<<endl;
+         fReRatio = 0;
+       }
+       else {
+         //if ( j==1 && theta==0) cerr<<"modulus of fNumer = "<<fNumer.Rho() <<endl; //always a number smaller than 1, or 0.
+         fReRatio = (fNumer/fDenom).Re();
+       }
+   
+       fVPt = fBesselRatio[m-1]*fReRatio*fVtheta*100.; //BP eq. 12
+       //cerr<<"fBesselRatio[m-1] = "<<fBesselRatio[m-1]<<endl;   //checked ok
+       //if ( j==1 && theta==0) cerr<<"pt = "<<fPt<<" cerr::fReRatio for pt = "<<fReRatio<<" cerr::fVPt for pt = "<<fVeta<<endl;
+             
+       if (j==0) fHistProVPtHar1->Fill(fPt,fVPt);
+       if (j==1) fHistProVPtHar2->Fill(fPt,fVPt);
+      } //loop over bins bp
+
+    }//end of loop over theta
+
+
+    //sigma2 and chi (for statistical error calculations)
+    if (j==1) {  //second harmonic only temporarily
+      
+      if (fEventNumber!=0) {
+       fQsum /= fEventNumber;
+       //cerr<<"fQsum.X() = "<<fQsum.X()<<endl;
+       //cerr<<"fQsum.Y() = "<<fQsum.Y()<<endl;
+       fQ2sum /= fEventNumber;
+       cerr<<"fQ2sum = "<<fQ2sum<<endl;
+       fV = fHistProV->GetBinContent(j+1);
+       fSigma2 = fQ2sum - TMath::Power(fQsum.X(),2.) - TMath::Power(fQsum.Y(),2.) - TMath::Power(fV,2.);  //BP eq. 62
+       if (fSigma2>0) fChi = fV/TMath::Sqrt(fSigma2);
+       else fChi = -1.;
+       cerr<<"fV = "<<fV<<" and chi = "<<fChi<<endl;
+      }
+          
+    } //j==1
+
+    
+    //copy content of profile into TH1D and add error
+    for(Int_t b=0;b<100;b++){
+      Double_t fv2pro = fHistProVPtHar2->GetBinContent(b);
+      //calculate error
+      for (Int_t theta=0;theta<fNtheta;theta++) {
+       Double_t fTheta = ((double)theta/fNtheta)*TMath::Pi(); 
+       Int_t Nprime = fHist2[j][theta]->GetNprimePt(b);
+       //cerr<<"Nprime = "<<Nprime<<endl;
+       if (Nprime!=0.) { 
+         Double_t fApluscomb = TMath::Exp((fJ01*fJ01)/(2*fChi*fChi)*
+                                          TMath::Cos(fTheta));
+         Double_t fAmincomb = TMath::Exp(-(fJ01*fJ01)/(2*fChi*fChi)*
+                                         TMath::Cos(fTheta));
+         fErr2difcomb += (TMath::Cos(fTheta)/(4*Nprime*TMath::BesselJ1(fJ01)*
+                                                TMath::BesselJ1(fJ01)))*
+           ((fApluscomb*TMath::BesselJ0(2*fJ01*TMath::Sin(fTheta/2))) - 
+            (fAmincomb*TMath::BesselJ0(2*fJ01*TMath::Cos(fTheta/2))));
+       }
+      } //loop over theta
+      
+      if (fErr2difcomb!=0.) {
+       fErr2difcomb /= fNtheta;
+       fErrdifcomb = TMath::Sqrt(fErr2difcomb)*100;
+       //cerr<<"fErrdifcomb = "<<fErrdifcomb<<endl;
+      }
+      else {fErrdifcomb = 0.;}
+         
+      //fill TH1D
+      if (j==1) {
+       fHistVPtHar2->SetBinContent(b,fv2pro);
+       fHistVPtHar2->SetBinError(b,fErrdifcomb);
+      }
+      //check that error is set
+      //if (j==1) { cout<<"difference between calculated error and error in hostogram: "<< fErrdifcomb - fHistVPtHar2->GetBinError(b)<<endl; }
+           
+    } //loop over bins b
+
+           
+    //} //end of loop over harmonics         //temporarily out
+
+    //save histograms in file
+    fHistFile->cd();
+    fHistFile->Write();
+    fHistFile->Close();
+    //Note that when the file is closed, all histograms and Trees in memory associated with this file are deleted
+    if (fDebug) cout<<"****Histograms saved and fHistFile closed, all histograms deleted****"<<endl;
+     
+    //close the first run file 
+    firstRunFile->Close();
+
+     
+  } //secondrun
+   
+  delete fFlowSelect;
+  cout<<"----LYZ analysis finished....----"<<endl<<endl;
+
+  return kTRUE;
+}
+
+
+//-----------------------------------------------------------------------
+  Bool_t AliFlowLeeYangZerosMaker::MakeControlHistograms(AliFlowEvent* fFlowEvent) 
+{ 
+  //contol histograms of pt, eta, phi, Q, mult
+  if (fDebug) cout<<"****AliFlowLeeYangZerosMaker::MakeControlHistograms()****"<<endl; 
+   
+  //define variables
+  TVector2 fQ;
+  Float_t fPt, fPhi, fEta, fQmult;
+
+  if (!fFlowEvent){
+    cout<<"##### FlowLeeYangZero: FlowEvent pointer null"<<endl;
+    return kFALSE;
+  }
+
+  if (!fFlowSelect){
+    cout<<"##### FlowLeeYangZero: FlowSelect pointer null"<<endl;
+    return kFALSE;
+  }
+
+  //set selection and harmonic
+  fFlowSelect->SetSelection(1); 
+  fFlowSelect->SetHarmonic(1); //second harmonic
+     
+  //cerr<<"selection in MakeControlHistograms()"<<endl;
+  //fFlowSelect->PrintSelectionList() ;
+  //fFlowSelect->PrintList() ;
+
+  fFlowTracks = fFlowEvent->TrackCollection();
+  Int_t fNumberOfTracks = fFlowTracks->GetEntries();
+  fHistOrigMult->Fill(fNumberOfTracks);
+  //cerr<<"fNumberOfTracks = "<<fNumberOfTracks<<endl;
+  Int_t fMult = fFlowEvent->Mult(fFlowSelect);  // Multiplicity of tracks in the specified Selection
+  fHistMult->Fill(fMult);   
+  //cerr<<"Mult = "<<fMult<<endl;
+  
+  fQ = fFlowEvent ->Q(fFlowSelect);
+  fQmult = fQ.Mod()/TMath::Sqrt(fNumberOfTracks);
+  fHistQ->Fill(fQmult);
+   
+  Int_t tempmult = 0; //for testing
+  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
+      if (fFlowSelect->Select(fFlowTrack))  
+       {
+         fPt = fFlowTrack->Pt();
+         fHistPt->Fill(fPt);
+         tempmult++;
+         fPhi = fFlowTrack->Phi();
+         if (fPhi<0.) fPhi+=2*TMath::Pi();
+         fHistPhi->Fill(fPhi);
+         fEta = fFlowTrack->Eta();
+         fHistEta->Fill(fEta);
+       }
+    }
+  if (fMult!=tempmult){cerr<<"ERROR: Mult() is not tempmult! "<<fMult<<" :: "<<tempmult<<endl<<endl;}
+  //else {cerr<<"Mult()= tempmult "<<fMult<<" :: "<<tempmult<<endl<<endl;}
+
+  return kTRUE; 
+
+
+}
+
+
+
+//-----------------------------------------------------------------------
+ Bool_t AliFlowLeeYangZerosMaker::FillFromFlowEvent(AliFlowEvent* fFlowEvent) 
+{ 
+  // Get event quantities from AliFlowEvent for all particles
+
+  if (fDebug) cout<<"****AliFlowLeeYangZerosMaker::FillFromFlowEvent()****"<<endl;
+   
+  if (!fFlowEvent){
+    cout<<"##### FlowLeeYangZero: FlowEvent pointer null"<<endl;
+    return kFALSE;
+  }
+   
+  if (!fFlowSelect){
+    cout<<"##### FlowLeeYangZero: FlowSelect pointer null"<<endl;
+    return kFALSE;
+  }
+
+
+  //define variables
+  TComplex fExpo, fGtheta, fGthetaNew, fZ;
+  //Int_t m;   
+  Int_t fNtheta = AliFlowLYZConstants::kTheta;
+  Int_t fNbins = AliFlowLYZConstants::kNbins;
+   
+
+  //calculate flow
+  fFlowSelect->SetSelection(1); 
+      
+  for (Int_t j=0;j<AliFlowConstants::kHars;j++)   //loop over harmonics j=0 ->first harmonic, j=1 ->second harmonic
+    {
+      Int_t m=1;
+      fFlowSelect->SetHarmonic(j);
+      Float_t fOrder = (double)((j+1)/m);
+      //cerr<<"fOrder = "<<fOrder<<endl;
+
+      //get the Q vector from the FlowEvent
+      TVector2 fQ = fFlowEvent->Q(fFlowSelect); 
+      //for chi calculation:
+      if (j==1)  //second harmonic only temporarily
+       {
+         fQsum += fQ;
+         fQ2sum += fQ.Mod2();
+         //cerr<<"fQ2sum = "<<fQ2sum<<endl;
+       }
+
+      fFlowTracks = fFlowEvent->TrackCollection();
+
+      for (Int_t theta=0;theta<fNtheta;theta++)
+       {
+         fTheta = ((float)theta/fNtheta)*TMath::Pi()/fOrder; 
+         //cerr<<"fTheta = "<<fTheta<<endl;
+          
+         //calculate fQtheta = cos(fOrder*(fPhi-fTheta);the projection of the Q vector on the reference direction fTheta
+         fQtheta = GetQtheta(fFlowSelect,fFlowTracks,fTheta);
+         //save fQtheta in AliFlowLYZSummary class
+
+         //something
+         //AliFlowLYZSummary::SetQtheta(theta,fQtheta);
+
+         if (j==1 && theta==0) fHistQtheta->Fill(fQtheta);
+         //cerr<<"fQtheta = "<<fQtheta<<endl;
+          
+         for (Int_t bin=1;bin<=fNbins;bin++)
+           {
+             Float_t fR = fHist1[j][theta]->GetBinCenter(bin); //bincentre of bins in histogram
+             //if (theta == 0) cerr<<"cerr::fR = "<<fR<<endl;
+             if (fUseSum)
+               {
+                 //calculate the sum generating function
+                 fExpo(0.,fR*fQtheta);                           //Re=0 ; Im=fR*fQtheta
+                 fGtheta = TComplex::Exp(fExpo);
+               }
+             else
+               {
+                 //calculate the product generating function
+                 fGtheta = GetGrtheta(fFlowSelect,fR,fTheta);  //make this function
+                 if (fGtheta.Rho2() > 100.) break;
+               }
+
+             fHist1[j][theta]->Fill(fR,fGtheta);              //fill real and imaginary part of fGtheta
+
+           } //loop over bins
+       } //loop over theta 
+    } //loop over harmonics
+   
+  return kTRUE;
+
+          
+}
+
+ //-----------------------------------------------------------------------   
+ Bool_t AliFlowLeeYangZerosMaker::SecondFillFromFlowEvent(AliFlowEvent* fFlowEvent) 
+{ 
+  //for differential flow
+
+  if (fDebug) cout<<"****AliFlowLeeYangZerosMaker::SecondFillFromFlowEvent()****"<<endl;
+    
+  if (!fFlowEvent){
+    cout<<"##### FlowLeeYangZero: FlowEvent pointer null"<<endl;
+    return kFALSE;
+  }
+   
+  if (!fFlowSelect){
+    cout<<"##### FlowLeeYangZero: FlowSelect pointer null"<<endl;
+    return kFALSE;
+  }
+
+  //define variables
+  //TVector2 fQ;
+  TComplex fExpo, fDenom, fNumer,fCosTermComplex;
+  Float_t  fOrder, fR0, fPhi, fEta, fPt;
+  Double_t fCosTerm;
+  Double_t m = 1.;
+  Int_t fNtheta = AliFlowLYZConstants::kTheta;
+   
+  //calculate flow
+  fFlowSelect->SetSelection(1);
+
+  //cerr<<"selection in SecondFillFromFlowEvent()"<<endl;
+  //fFlowSelect->PrintSelectionList() ;
+  //fFlowSelect->PrintList() ;
+
+      
+  for (Int_t j=0;j<AliFlowConstants::kHars;j++)   //loop over harmonics j=0 ->first harmonic, j=1 ->second harmonic
+    {
+      m=1;
+      fFlowSelect->SetHarmonic(j);
+      fOrder = (double)((j+1)/m);
+
+      //get the Q vector from the FlowEvent
+      TVector2 fQ = fFlowEvent->Q(fFlowSelect); 
+      //for chi calculation:
+      if (j==1)  //second harmonic only temporarily
+       {
+         fQsum += fQ;
+         fQ2sum += fQ.Mod2();
+         //cerr<<"fQ2sum = "<<fQ2sum<<endl;
+       }
+
+      fFlowTracks = fFlowEvent->TrackCollection();
+       
+      for (Int_t theta=0;theta<fNtheta;theta++)
+       {
+         fTheta = ((float)theta/fNtheta)*TMath::Pi()/fOrder;   
+
+         //calculate fQtheta = cos(fOrder*(fPhi-fTheta);the projection of the Q vector on the reference direction fTheta
+         fQtheta = GetQtheta(fFlowSelect,fFlowTracks,fTheta);
+         //cerr<<"fQtheta for fdenom = "<<fQtheta<<endl;
+          
+         /*
+           if (j==0)  //first harmonic
+           {
+           //denominator for differential v
+           fR0 = fHistProR0thetaHar1->GetBinContent(theta+1);
+           fExpo(0.,fR0*fQtheta);
+           fDenom = fQtheta*(TComplex::Exp(fExpo)); //BP eq 12
+           //cerr<<"fDenom.Re() = "<<fDenom.Re()<<endl;
+           //cerr<<"fDenom.Im() = "<<fDenom.Im()<<endl;
+
+           //denominator for differential v
+           // ****put in product generating function!!
+
+              
+           fHistProReDenomHar1->Fill(theta,fDenom.Re());               //fill the real part of fDenom
+           fHistProImDenomHar1->Fill(theta,fDenom.Im());               //fill the imaginary part of fDenom
+           }
+         */
+
+         if (j==1)  //second harmonic
+           {
+             //denominator for differential v
+             fR0 = fHistProR0thetaHar2->GetBinContent(theta+1);
+             //cerr<<"fR0 = "<<fR0 <<endl;
+
+             if (fUseSum)                                                    //sum generating function
+               {
+                 fExpo(0.,fR0*fQtheta);
+                 fDenom = fQtheta*(TComplex::Exp(fExpo)); //BP eq 12
+                 //loop over tracks in event
+                 fFlowTracks = fFlowEvent->TrackCollection();
+                 Int_t fNumberOfTracks = fFlowTracks->GetEntries();
+                 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
+                       {
+                         fPhi = fFlowTrack->Phi();
+                         fCosTerm = cos(m*fOrder*(fPhi-fTheta));
+                         //cerr<<"fCosTerm = "<<fCosTerm <<endl;
+                         fNumer = fCosTerm*(TComplex::Exp(fExpo));
+                         if (fNumer.Rho()==0) {cerr<<"WARNING: modulus of fNumer is zero in SecondFillFromFlowEvent"<<endl;}
+                         if (fDebug) cerr<<"modulus of fNumer is "<<fNumer.Rho()<<endl;
+                         fEta = fFlowTrack->Eta();  //rapidity
+                         fPt = fFlowTrack->Pt();
+                         fHist2[j][theta]->Fill(fEta,fPt,fNumer);
+                       } //if
+                   } //loop over tracks
+                  
+               } //sum
+             else                                                        //product generating function
+               {
+                 fDenom = GetDiffFlow(fFlowSelect,fR0,theta); 
+                  
+               }//product
+             
+             fHistProReDenomHar2->Fill(theta,fDenom.Re());               //fill the real part of fDenom
+             fHistProImDenomHar2->Fill(theta,fDenom.Im());               //fill the imaginary part of fDenom
+           }//j==1
+                  
+                      
+       }//end of loop over theta
+
+    }//loop over harmonics
+
+  
+  return kTRUE;
+  
+}
+ //-----------------------------------------------------------------------   
+ Double_t AliFlowLeeYangZerosMaker::GetQtheta(AliFlowSelection* fFlowSelect, TObjArray* fFlowTracks, Float_t fTheta) 
+{
+  //calculate Qtheta. Qtheta is the sum over all particles of cos(fOrder*(fPhi-fTheta)) BP eq. 3
+  if (fDebug) cout<<"****AliFlowLeeYangZerosMaker::GetQtheta()****"<<endl;
+
+  if (!fFlowSelect){
+     cout<<"##### FlowLeeYangZero: FlowSelect pointer null"<<endl;
+     return kFALSE;
+   }
+
+
+  Double_t fQtheta = 0.;
+  Int_t fHarmonic = fFlowSelect->Har(); 
+  Double_t fOrder = (double)(fHarmonic+1);
+       
+  Int_t fNumberOfTracks = fFlowTracks->GetEntries();
+  //cerr<<"GetQtheta::fNumberOfTracks = "<<fNumberOfTracks<<endl;
+  
+  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))                //if track is selected  //gives the same number of particles as Mult(fFlowSelect) method
+       {
+         Float_t fPhi = fFlowTrack->Phi();
+         fQtheta += cos(fOrder*(fPhi-fTheta));
+       }
+     
+    }//loop over tracks
+  
+  return fQtheta;
+}
+//-----------------------------------------------------------------------   
+TComplex AliFlowLeeYangZerosMaker::GetGrtheta(AliFlowSelection* fFlowSelect, Float_t fR, Float_t fTheta) 
+{
+  // Product Generating Function for LeeYangZeros method
+  // PG Eq. 3 (J. Phys. G Nucl. Part. Phys 30 S1213 (2004))
+
+  if (fDebug) cout<<"****AliFlowLeeYangZerosMaker::GetGrtheta()****"<<endl;
+  
+  if (!fFlowSelect){
+    cout<<"##### FlowLeeYangZero: FlowSelect pointer null"<<endl;
+    return kFALSE;
+  }
+  
+  TComplex fG = TComplex::One();
+  Int_t fHarmonic = fFlowSelect->Har(); 
+  Double_t fOrder = (double)(fHarmonic+1);
+  Double_t fWgt = 1.;
+
+  Int_t fNumberOfTracks = fFlowTracks->GetEntries();
+  //cerr<<"GetGrtheta::fNumberOfTracks = "<<fNumberOfTracks<<endl; 
+
+  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->SelectPart(fFlowTrack))                        //if track is selected
+       {
+         Float_t fPhi = fFlowTrack->Phi();
+         Double_t fGIm = fR * fWgt*cos(fOrder*(fPhi - fTheta));
+         TComplex fGi(1., fGIm);
+         fG *= fGi;     //product over all tracks
+       }//if
+    }//loop over tracks
+
+  return fG;
+
+  } 
+
+
+//-----------------------------------------------------------------------   
+TComplex AliFlowLeeYangZerosMaker::GetDiffFlow(AliFlowSelection* fFlowSelect, Float_t fR0, Int_t theta) 
+{
+  // Sum for the denominator for diff. flow for the Product Generating Function for LeeYangZeros method
+  // PG Eq. 9 (J. Phys. G Nucl. Part. Phys 30 S1213 (2004))
+  // Also for v1 mixed harmonics: DF Eq. 5
+  // It is the deriverative of Grtheta at r0 divided by Grtheta at r0
+
+  if (fDebug) cout<<"****AliFlowLeeYangZerosMaker::GetGrtheta()****"<<endl;
+
+  if (!fFlowSelect){
+    cout<<"##### FlowLeeYangZero: FlowSelect pointer null"<<endl;
+    return kFALSE;
+  }
+
+
+  TComplex fG = TComplex::One();
+  TComplex fdGr0(0.,0.);
+  Int_t fHarmonic = fFlowSelect->Har(); 
+  Double_t fOrder = (double)(fHarmonic+1);
+  Double_t fWgt = 1.;
+
+  Int_t fNumberOfTracks = fFlowTracks->GetEntries();
+  //cerr<<"GetGrtheta::fNumberOfTracks = "<<fNumberOfTracks<<endl; 
+
+  Int_t fNtheta = AliFlowLYZConstants::kTheta;
+  Float_t fTheta = ((float)theta/fNtheta)*TMath::Pi()/fOrder;
+
+  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->SelectPart(fFlowTrack))                        //if track is selected
+       {
+         Float_t fPhi = fFlowTrack->Phi();
+         Double_t fCosTerm = fWgt*cos(fOrder*(fPhi - fTheta));
+         //GetGr0theta
+         Double_t fGIm = fR0 * fCosTerm;
+         TComplex fGi(1., fGIm);
+         fG *= fGi;     //product over all tracks
+         //GetdGr0theta
+         TComplex fCosTermComplex(1., fR0*fCosTerm);
+         fdGr0 +=(fCosTerm / fCosTermComplex);  //sum over all tracks
+       }//if
+    }//loop over tracks
+
+  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();
+         Double_t fCosTerm = cos(fOrder*(fPhi-fTheta));
+         TComplex fCosTermComplex(1.,fR0*fCosTerm);
+         
+         TComplex fNumer = fG*fCosTerm/fCosTermComplex;  //PG Eq. 9
+         Float_t fEta = fFlowTrack->Eta();  //rapidity
+         Float_t fPt = fFlowTrack->Pt();
+         fHist2[1][theta]->Fill(fEta,fPt,fNumer);
+       }//if
+    }//loop over tracks
+
+  TComplex fDenom = fG*fdGr0;
+  return fDenom;
+
+  } 
+
+//-------------------------------------------------
diff --git a/PWG2/FLOW/AliFlowLeeYangZerosMaker.h b/PWG2/FLOW/AliFlowLeeYangZerosMaker.h
new file mode 100644 (file)
index 0000000..0c42d14
--- /dev/null
@@ -0,0 +1,163 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+  
+#ifndef AliFlowLeeYangZerosMaker_H
+#define AliFlowLeeYangZerosMaker_H
+
+//#include <iostream>
+//using namespace std; //required for resolving the 'cout' symbol
+
+//#include "Riostream.h"
+#include "TVector2.h"          //called explicitly
+#include "AliFlowSelection.h"  //only with AliFlowSelection* called ???
+#include "AliFlowTrack.h"      //only with AliFlowTrack* called ???
+
+//class AliFlowTrack;          //why doesn't compile?
+//class AliFlowSelection;      //why doesn't compile?
+
+class AliFlowEvent;
+class AliFlowLYZHist1; 
+class AliFlowLYZHist2;
+//class AliFlowLYZSummary;     //class not yet finished
+
+class TH1F;
+class TH1D;
+class TProfile;
+class TProfile2D;
+class TObjArray;
+class TFile;
+class TTree;
+class TComplex;
+class Riostream;
+
+
+// Description: Maker to analyze Flow by the LeeYangZeros method
+//              One needs to do two runs over the data; 
+//              First to calculate the integrated flow 
+//              and in the second to calculate the differential flow
+class AliFlowLeeYangZerosMaker {
+
+ public:
+   AliFlowLeeYangZerosMaker();                                            //default constructor
+   AliFlowLeeYangZerosMaker(const AliFlowSelection* fFlowSelect);          //custum constructor
+
+   AliFlowLeeYangZerosMaker(const AliFlowLeeYangZerosMaker&);              //copy constuctor (dummy)
+
+   AliFlowLeeYangZerosMaker& operator=(const AliFlowLeeYangZerosMaker&);   //assignment operator (dummy)
+   
+   virtual  ~AliFlowLeeYangZerosMaker();                                   //destructor
+   Bool_t    Init();    //defines variables and histograms
+   Bool_t    Make(AliFlowEvent* fFlowEvent);    //calculates variables and fills histograms
+   Bool_t    Finish();  //saves histograms
+
+   Double_t  GetQtheta(AliFlowSelection* fFlowSelect, TObjArray* fFlowTracks, Float_t fTheta);
+
+   void      SetFirstRun(Bool_t kt)              { this->fFirstRun = kt ; }
+   Bool_t    GetFirstRun() const                 { return this->fFirstRun ; }
+   void      SetUseSum(Bool_t kt)                { this->fUseSum = kt ; }
+   Bool_t    GetUseSum() const                   { return this->fUseSum ; }
+   void      SetDebug(Bool_t kt)                 { this->fDebug = kt ; }
+   Bool_t    GetDebug() const                    { return this->fDebug ; }
+
+
+   // Output 
+   void            SetHistFileName(TString name)       { this->fHistFileName = name ; } // Sets output file name
+   TString  GetHistFileName() const            { return this->fHistFileName ; } // Gets output file name
+   TFile*   GetHistFile() const                 { return this->fHistFile ; }     // Gets output file
+  
+   // input for second run
+   void            SetFirstRunFileName(TString name)   { this->firstRunFileName = name ; } // Sets input file name
+   TString  GetFirstRunFileName() const                { return this->firstRunFileName ; } // Gets output file name
+   void     SetFirstRunFile(TFile* file)        { this->firstRunFile = file ; }        // Sets first run file
+
+ private:
+   Bool_t   MakeControlHistograms(AliFlowEvent* fFlowEvent); 
+   Bool_t   FillFromFlowEvent(AliFlowEvent* fFlowEvent);
+   Bool_t   SecondFillFromFlowEvent(AliFlowEvent* fFlowEvent);
+
+   //Double_t GetQtheta(AliFlowSelection* fFlowSelect, TObjArray* fFlowTracks, Float_t fTheta) const;
+   TComplex GetGrtheta(AliFlowSelection* fFlowSelect, Float_t fR, Float_t fTheta);
+   TComplex GetDiffFlow(AliFlowSelection* fFlowSelect, Float_t fR, Int_t theta); 
+   Float_t  GetR0(TH1D* fHistGtheta);
+
+  
+   
+#ifndef __CINT__
+   TVector2  fQ;            // flow vector
+   TVector2  fQsum;         // flow vector sum
+   Float_t   fQ2sum;        // flow vector sum squared
+   Double_t  fQtheta;       // flow vector projected on ref. angle theta
+   
+#endif /*__CINT__*/
+
+   Int_t     fEventNumber;  // event counter
+   Int_t     fMult;         // multiplicity
+   Int_t     fNbins;        // number of bins
+   Float_t   fTheta;        // ref. angle theta
+   
+   AliFlowEvent*      fFlowEvent;    //! pointer to AliFlowEvent
+   AliFlowSelection*  fFlowSelect;   //! pointer to AliFlowSelection
+   TObjArray*         fFlowTracks ;  //! pointer to the TrackCollection
+   AliFlowTrack*      fFlowTrack ;   //! pointer to the AliFlowTrack
+   //AliFlowLYZSummary* fLYZSummary;   //! 
+   TTree*             fFlowTree;     //!
+
+   Bool_t       fFirstRun ;         //! flag for lyz analysis: true=first run over data, false=second run 
+   Bool_t       fUseSum ;           //! flag for lyz analysis: true=use sum gen.function, false=use product gen.function
+   Bool_t       fDebug ;            //! flag for lyz analysis: more print statements
+
+   TString      fHistFileName;      //!
+   TFile*       fHistFile;          //!
+   TFile*       fSummaryFile;       //!
+   TDirectory * fFistLoop;          //!
+   TString      firstRunFileName;   //!
+   TFile*       firstRunFile;       //!
+  // for single histograms
+  TH1F*        fHistOrigMult;      //!
+  TH1F*        fHistMult;          //!
+  TH1F*        fHistQ;             //!
+  TH1F*        fHistPt;            //!
+  TH1F*        fHistEta;           //!
+  TH1F*        fHistPhi;           //!
+  TH1F*        fHistQtheta;        //!
+   
+
+  TProfile*    fHistProVthetaHar1;     //!
+  TProfile*    fHistProVthetaHar2;     //!
+  TProfile*    fHistProVetaHar1;       //!
+  TProfile*    fHistProVetaHar2;       //!
+  TProfile*    fHistProVPtHar1;        //!
+  TProfile*    fHistProVPtHar2;        //!
+  TH1D*        fHistVPtHar2;           //!
+  TProfile*    fHistProVR0;            //!
+  TH1D*        fHistVR0;               //!
+  TProfile*    fHistProV;              //!
+  TProfile*    fHistProR0thetaHar1;    //!
+  TProfile*    fHistProR0thetaHar2;    //!
+  TProfile*    fHistProReDenomHar1;    //!
+  TProfile*    fHistProReDenomHar2;    //!
+  TProfile*    fHistProImDenomHar1;    //!
+  TProfile*    fHistProImDenomHar2;    //!
+  TProfile*    fHistProReDtheta;       //!
+  TProfile*    fHistProImDtheta;       //!
+   
+   
+  //class AliFlowLYZHist1 defines the histograms: fHistProGtheta, fHistProReGtheta, fHistProImGtheta
+  AliFlowLYZHist1* fHist1[2][5];       //!
+
+  //class AliFlowLYZHist1 defines the histograms: fHistProReNumer, fHistProImNumer, fHistProReNumerPt,
+  //fHistProImNumerPt, fHistProReNumer2D, fHistProImNumer2D.
+  AliFlowLYZHist2* fHist2[2][5];       //!
+  ClassDef(AliFlowLeeYangZerosMaker,0)  // macro for rootcint
+    };
+     
+#endif