]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Merge methods
authorsnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 19 Jun 2008 17:13:07 +0000 (17:13 +0000)
committersnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 19 Jun 2008 17:13:07 +0000 (17:13 +0000)
PWG2/FLOW/AliFlowCommonHistResults.cxx
PWG2/FLOW/AliFlowCommonHistResults.h
PWG2/FLOW/AliFlowLYZHist1.cxx
PWG2/FLOW/AliFlowLYZHist1.h
PWG2/FLOW/AliFlowLYZHist2.cxx
PWG2/FLOW/AliFlowLYZHist2.h

index 155a2667b43bb39fd3b668e61c02b30c60ed3c43..78542cfaaa815ac1e0b1b2f272738702524f37f6 100644 (file)
@@ -20,6 +20,7 @@
 #include "TString.h" 
 #include "TH1D.h"   //needed as include
 #include "TMath.h"  //needed as include
+#include "TList.h"
 
 class TH1F;
 class AliFlowVector;
@@ -35,11 +36,25 @@ ClassImp(AliFlowCommonHistResults)
 
 //-----------------------------------------------------------------------
 
-  AliFlowCommonHistResults::AliFlowCommonHistResults(TString input): TObject(),
-  fHistIntFlow(0),
-  fHistDiffFlow(0),
-  fHistChi(0)
-  {
+  AliFlowCommonHistResults::AliFlowCommonHistResults(): 
+    TObject(),
+    fHistIntFlow(0),
+    fHistDiffFlow(0),
+    fHistChi(0),
+    fHistList(NULL)
+{
+  //default constructor
+} 
+
+//-----------------------------------------------------------------------
+
+  AliFlowCommonHistResults::AliFlowCommonHistResults(TString input): 
+    TObject(),
+    fHistIntFlow(0),
+    fHistDiffFlow(0),
+    fHistChi(0),
+    fHistList(NULL)
+{
   //constructor creating histograms 
   Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
   TString name;
@@ -67,6 +82,13 @@ ClassImp(AliFlowCommonHistResults)
   fHistChi = new TH1D(name.Data(), name.Data(),1,0.5,1.5);
   fHistChi ->SetXTitle("");
   fHistChi ->SetYTitle("Chi");
+
+  //list of histograms
+  fHistList = new TList();
+  fHistList-> Add(fHistIntFlow);
+  fHistList-> Add(fHistDiffFlow);
+  fHistList-> Add(fHistChi);
+
   }
 
 //----------------------------------------------------------------------- 
@@ -77,6 +99,7 @@ AliFlowCommonHistResults::~AliFlowCommonHistResults()
   delete fHistIntFlow;
   delete fHistDiffFlow;
   delete fHistChi;
+  delete fHistList;
 }
 
 //----------------------------------------------------------------------- 
@@ -112,5 +135,30 @@ Bool_t AliFlowCommonHistResults::FillChi(Double_t aChi)
 }
 
 //----------------------------------------------------------------------- 
+ Double_t AliFlowCommonHistResults::Merge(TCollection *aList)
+{
+  //merge fuction
+  cout<<"entering merge function"<<endl;
+  if (!aList) return 0;
+  if (aList->IsEmpty()) return 0; //no merging is needed
+
+  Int_t iCount = 0;
+  TIter next(aList); // list is supposed to contain only objects of the same type as this
+  AliFlowCommonHistResults *toMerge;
+  // make a temporary list
+  TList *pTemp = new TList();
+  while ((toMerge=(AliFlowCommonHistResults*)next())) {
+    pTemp->Add(toMerge->GetHistList()); 
+    iCount++;
+  }
+  // Now call merge for fHistList providing temp list
+  fHistList->Merge(pTemp);
+  // Cleanup
+  delete pTemp;
+    
+  cout<<"Merged"<<endl;
+  return (double)iCount;
+    
+}
 
 
index 88574298813481722537f30f6f20b7964fac81e4..824cab616014fc6db652b91cbe5cce7d6ef84115 100644 (file)
@@ -7,6 +7,8 @@
 
 class TH1F;
 class TH1D;
+class TCollection;
+class TList;
 
 // AliFlowCommonHistResults:
 // Class to organize the common histograms for Flow Analysis
@@ -15,7 +17,7 @@ class TH1D;
 class AliFlowCommonHistResults : public TObject {
 
  public:
-
+  AliFlowCommonHistResults();               //default constructor
   AliFlowCommonHistResults(TString input);  //constructor
   virtual ~AliFlowCommonHistResults();      //destructor
 
@@ -28,19 +30,20 @@ class AliFlowCommonHistResults : public TObject {
   TH1D*    GetfHistDiffFlow()               {return fHistDiffFlow; } ; 
   TH1D*    GetfHistChi()                    {return fHistChi; } ;
   TH1D*    GetfHistIntFlow()                {return fHistIntFlow; } ;
+  TList*   GetHistList()                    {return fHistList;} ;  
+
+  virtual Double_t  Merge(TCollection *aList);  //merge function
+
  private:
 
   AliFlowCommonHistResults(const AliFlowCommonHistResults& aSetOfResultHists);            //copy constructor
   AliFlowCommonHistResults& operator=(const AliFlowCommonHistResults& aSetOfResultHists); //assignment operator
 
-  //integrated flow
-  TH1D*     fHistIntFlow;      
-  //differential flow
-  TH1D*     fHistDiffFlow; 
-  //resolution
-  TH1D*     fHistChi;
-  
+  TH1D*     fHistIntFlow;      //integrated flow
+  TH1D*     fHistDiffFlow;     //differential flow
+  TH1D*     fHistChi;          //resolution
+  TList*    fHistList;         //list to hold all histograms
+
   ClassDef(AliFlowCommonHistResults,0)                 // macro for rootcint
 };
  
index 62d981306ea71d0194cc744157610ad10a193c35..cf2a9c4e0978717d95a43b468bee0790e85126a1 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-*/ 
 
 //#include "Riostream.h"  //in case one wants to make print statements
 #include "TProfile.h"
 #include "TString.h" 
-#include "TComplex.h"  
+#include "TComplex.h" 
+#include "TList.h"
 #include "AliFlowLYZConstants.h" 
 #include "AliFlowLYZHist1.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():
+    TObject(),
+    fHistGtheta(0),
+    fHistProReGtheta(0),
+    fHistProImGtheta(0),
+    fHistList(NULL)
+{
+  //default constructor
+} 
 
 //-----------------------------------------------------------------------
 
   AliFlowLYZHist1::AliFlowLYZHist1(Int_t theta):
+    TObject(),
     fHistGtheta(0),
     fHistProReGtheta(0),
-    fHistProImGtheta(0)
+    fHistProImGtheta(0),
+    fHistList(NULL)
 {
 
   //constructor creating histograms 
@@ -86,6 +93,12 @@ ClassImp(AliFlowLYZHist1)
   fHistProImGtheta = new TProfile(name.Data(),title.Data(),iNbins,dMin,dMax);
   fHistProImGtheta->SetXTitle("r");
   fHistProImGtheta->SetYTitle("Im G^{#theta}(ir)");
+
+  //list of histograms
+  fHistList = new TList();
+  fHistList-> Add(fHistGtheta);
+  fHistList-> Add(fHistProReGtheta);
+  fHistList-> Add(fHistProImGtheta);
       
 }
   
@@ -97,6 +110,7 @@ AliFlowLYZHist1::~AliFlowLYZHist1()
   delete fHistGtheta;
   delete fHistProReGtheta;
   delete fHistProImGtheta;
+  delete fHistList;
 }
 
 //----------------------------------------------------------------------- 
@@ -180,3 +194,28 @@ Int_t AliFlowLYZHist1::GetNBins()
   return iNbins;
 }
 
+//----------------------------------------------------------------------- 
+ Double_t AliFlowLYZHist1::Merge(TCollection *aList)
+{
+  //merge fuction
+  if (!aList) return 0;
+  if (aList->IsEmpty()) return 0; //no merging is needed
+
+  Int_t iCount = 0;
+  TIter next(aList); // list is supposed to contain only objects of the same type as this
+  AliFlowLYZHist1 *toMerge;
+  // make a temporary list
+  TList *pTemp = new TList();
+  while ((toMerge=(AliFlowLYZHist1*)next())) {
+    pTemp->Add(toMerge->GetHistList()); 
+    iCount++;
+  }
+  // Now call merge for fHistList providing temp list
+  fHistList->Merge(pTemp);
+  // Cleanup
+  delete pTemp;
+    
+  return (double)iCount;
+    
+}
+
index 4d17e7b2984452f3c6571fd903e10f89e855b6c3..daca90500c1005a9830318ac97d17bfc471ee5fe 100644 (file)
@@ -10,6 +10,9 @@
 #include "TComplex.h"  //explicitly called in void Fill(Float_t f, TComplex C);
 
 class TH1D;
+class TCollection;
+class TList;
+
 
 // Description: Class to organise histograms for Flow 
 //              by the LeeYangZeros method in the first run.
@@ -17,10 +20,11 @@ class TH1D;
 //              in the generating function.
 
 
-class AliFlowLYZHist1 {
+class AliFlowLYZHist1: public TObject  {
 
  public:
 
+  AliFlowLYZHist1();                          //default constructor
   AliFlowLYZHist1(Int_t theta);               //constructor
   virtual  ~AliFlowLYZHist1();                //destructor
   
@@ -29,18 +33,22 @@ class AliFlowLYZHist1 {
   Double_t GetR0();                           //get R0
   Double_t GetBinCenter(Int_t i);             //Get a bincentre of fHistGtheta
   Int_t GetNBins();                           //Gets Nbins
+  TList*    GetHistList()  {return fHistList;} ;  
+
+  virtual Double_t  Merge(TCollection *aList);  //merge function
    
 private:
 
   AliFlowLYZHist1(const AliFlowLYZHist1& aAnalysis);             //copy constructor
   AliFlowLYZHist1& operator=(const AliFlowLYZHist1& aAnalysis);  //assignment operator
 
-  TH1D* fHistGtheta;                          //holds |Gtheta|^2(r)
-  TProfile* fHistProReGtheta;                 //holds Re of Gtheta(r)
-  TProfile* fHistProImGtheta;                 //holds Im of Gtheta(r)
-  
+  TH1D*     fHistGtheta;             //holds |Gtheta|^2(r)
+  TProfile* fHistProReGtheta;        //holds Re of Gtheta(r)
+  TProfile* fHistProImGtheta;        //holds Im of Gtheta(r)
+  TList*    fHistList;               //list to hold all histograms  
+
 
-  ClassDef(AliFlowLYZHist1,0)                 // macro for rootcint
+  ClassDef(AliFlowLYZHist1,0)        // macro for rootcint
     };
  
      
index 49e96be22bff1a2e5059f8988e3d9f1bd87746eb..4d3b723f9f54dae2da9be51f8d063bd2e46a47aa 100644 (file)
@@ -24,6 +24,7 @@ $Log$
 #include "TProfile2D.h"
 #include "TString.h" 
 #include "TComplex.h"
+#include "TList.h"
 
 class TH1D;
 
@@ -37,18 +38,33 @@ class TH1D;
  
 
 ClassImp(AliFlowLYZHist2)
-
   
+//-----------------------------------------------------------------------
 
+  AliFlowLYZHist2::AliFlowLYZHist2():
+    TObject(),
+    fHistProReNumer(0),
+    fHistProImNumer(0),
+    fHistProReNumerPt(0),
+    fHistProImNumerPt(0),
+    fHistProReNumer2D(0),
+    fHistProImNumer2D(0),
+    fHistList(NULL)
+{
+  //default constructor
+}
 //-----------------------------------------------------------------------
 
   AliFlowLYZHist2::AliFlowLYZHist2(Int_t theta):
+    TObject(),
     fHistProReNumer(0),
     fHistProImNumer(0),
     fHistProReNumerPt(0),
     fHistProImNumerPt(0),
     fHistProReNumer2D(0),
-    fHistProImNumer2D(0)
+    fHistProImNumer2D(0),
+    fHistList(NULL)
 {
 
   //constructor creating histograms 
@@ -126,6 +142,16 @@ ClassImp(AliFlowLYZHist2)
   fHistProImNumer2D = new TProfile2D(name.Data(),title.Data(),iNbinsEta,dEtaMin,dEtaMax,iNbinsPt,dPtMin,dPtMax);  
   fHistProImNumer2D->SetXTitle("eta");
   fHistProImNumer2D->SetYTitle("Pt (GeV/c)");
+
+  //list of histograms
+  fHistList = new TList();
+  fHistList-> Add(fHistProReNumer);
+  fHistList-> Add(fHistProImNumer);
+  fHistList-> Add(fHistProReNumerPt);
+  fHistList-> Add(fHistProImNumerPt);
+  fHistList-> Add(fHistProReNumer2D);
+  fHistList-> Add(fHistProImNumer2D);
+
 }
 
 //----------------------------------------------------------------------- 
@@ -139,21 +165,22 @@ AliFlowLYZHist2::~AliFlowLYZHist2()
   delete fHistProImNumerPt;
   delete fHistProReNumer2D;
   delete fHistProImNumer2D;
+  delete fHistList;
 }
 
 //----------------------------------------------------------------------- 
-void AliFlowLYZHist2::Fill(Double_t f1, Double_t f2, TComplex c)
+void AliFlowLYZHist2::Fill(Double_t d1, Double_t d2, TComplex c)
 {
   //fill the real and imaginary part of fNumer
 
-  fHistProReNumer->Fill(f1, c.Re());  
-  fHistProImNumer->Fill(f1, c.Im());
+  fHistProReNumer->Fill(d1, c.Re());  
+  fHistProImNumer->Fill(d1, c.Im());
    
-  fHistProReNumerPt->Fill(f2, c.Re());  
-  fHistProImNumerPt->Fill(f2, c.Im());
+  fHistProReNumerPt->Fill(d2, c.Re());  
+  fHistProImNumerPt->Fill(d2, c.Im());
   
-  fHistProReNumer2D->Fill(f1, f2, c.Re());          
-  fHistProImNumer2D->Fill(f1, f2, c.Im());           
+  fHistProReNumer2D->Fill(d1, d2, c.Re());          
+  fHistProImNumer2D->Fill(d1, d2, c.Im());           
 }
 
 //-----------------------------------------------------------------------
@@ -177,3 +204,27 @@ TComplex AliFlowLYZHist2::GetNumerPt(Int_t i)
   return cNumer;
 }
 
+//----------------------------------------------------------------------- 
+ Double_t AliFlowLYZHist2::Merge(TCollection *aList)
+{
+  //merge fuction
+  if (!aList) return 0;
+  if (aList->IsEmpty()) return 0; //no merging is needed
+
+  Int_t iCount = 0;
+  TIter next(aList); // list is supposed to contain only objects of the same type as this
+  AliFlowLYZHist2 *toMerge;
+  // make a temporary list
+  TList *pTemp = new TList();
+  while ((toMerge=(AliFlowLYZHist2*)next())) {
+    pTemp->Add(toMerge->GetHistList()); 
+    iCount++;
+  }
+  // Now call merge for fHistList providing temp list
+  fHistList->Merge(pTemp);
+  // Cleanup
+  delete pTemp;
+    
+  return (double)iCount;
+    
+}
index 82f3f58bfc6f0c8f813ed27e577a5e9e2b583b8e..1e71db86e7969fac4e0799471b71fa9975fc93d7 100644 (file)
@@ -10,7 +10,8 @@
 
 class TComplex;
 class TProfile2D;
-
+class TCollection;
+class TList;
 
 // Description: Class to organise histograms for Flow
 //              by the LeeYangZeros method in the second run.
@@ -18,17 +19,18 @@ class TProfile2D;
 //              which are called in AliFlowLeeYandZerosMaker::Finish().
 
 
-class AliFlowLYZHist2 {
+class AliFlowLYZHist2: public TObject  {
 
  public:
 
+  AliFlowLYZHist2();                                //default constructor
   AliFlowLYZHist2(Int_t theta);                     //constructor
   virtual  ~AliFlowLYZHist2();                      //destructor
   
-  void Fill(Double_t f1,Double_t f2, TComplex c);   //fill the histograms
-  Int_t GetNbinsX()                
+  void     Fill(Double_t d1,Double_t d2, TComplex c);   //fill the histograms
+  Int_t    GetNbinsX()                
     {Int_t iMaxEtaBins = fHistProReNumer->GetNbinsX();  return iMaxEtaBins;}     
-  Int_t GetNbinsXPt()              
+  Int_t    GetNbinsXPt()              
     {Int_t iMaxPtBins = fHistProReNumerPt->GetNbinsX(); return iMaxPtBins;}
   Double_t GetBinCenter(Int_t i)   
     {Double_t dEta = fHistProReNumer->GetXaxis()->GetBinCenter(i);  return dEta;}
@@ -36,21 +38,25 @@ class AliFlowLYZHist2 {
     {Double_t dPt = fHistProReNumerPt->GetXaxis()->GetBinCenter(i); return dPt;}
   TComplex GetNumerEta(Int_t i);                   //get numerator for diff. flow (eta)
   TComplex GetNumerPt(Int_t i);                    //get numerator for diff. flow (pt)
+  TList*   GetHistList()   
+    {return fHistList;}   
   
+  virtual Double_t Merge(TCollection *aList);  //merge function
  private:
  
   AliFlowLYZHist2(const AliFlowLYZHist2& aAnalysis);             //copy constructor
   AliFlowLYZHist2& operator=(const AliFlowLYZHist2& aAnalysis);  //assignment operator
   
-  TProfile* fHistProReNumer;                        //holds Re of Numerator(eta)
-  TProfile* fHistProImNumer;                        //holds Im of Numerator(eta)
-  TProfile* fHistProReNumerPt;                      //holds Re of Numerator(pt)
-  TProfile* fHistProImNumerPt;                      //holds Im of Numerator(pt)
-  TProfile2D* fHistProReNumer2D;                    //holds Re of Numerator
-  TProfile2D* fHistProImNumer2D;                    //holds Im of Numerator
-  
-
-  ClassDef(AliFlowLYZHist2,0)                    // macro for rootcint
+  TProfile*   fHistProReNumer;         //holds Re of Numerator(eta)
+  TProfile*   fHistProImNumer;         //holds Im of Numerator(eta)
+  TProfile*   fHistProReNumerPt;       //holds Re of Numerator(pt)
+  TProfile*   fHistProImNumerPt;       //holds Im of Numerator(pt)
+  TProfile2D* fHistProReNumer2D;       //holds Re of Numerator
+  TProfile2D* fHistProImNumer2D;       //holds Im of Numerator
+  TList*      fHistList;               //list to hold all histograms  
+
+  ClassDef(AliFlowLYZHist2,0)          // macro for rootcint
     };