From 8de6876dd21d8de8b2aea963043331026409fd54 Mon Sep 17 00:00:00 2001 From: snelling Date: Thu, 19 Jun 2008 17:13:07 +0000 Subject: [PATCH] Merge methods --- PWG2/FLOW/AliFlowCommonHistResults.cxx | 58 ++++++++++++++++++++-- PWG2/FLOW/AliFlowCommonHistResults.h | 21 ++++---- PWG2/FLOW/AliFlowLYZHist1.cxx | 57 +++++++++++++++++---- PWG2/FLOW/AliFlowLYZHist1.h | 20 +++++--- PWG2/FLOW/AliFlowLYZHist2.cxx | 69 ++++++++++++++++++++++---- PWG2/FLOW/AliFlowLYZHist2.h | 34 +++++++------ 6 files changed, 207 insertions(+), 52 deletions(-) diff --git a/PWG2/FLOW/AliFlowCommonHistResults.cxx b/PWG2/FLOW/AliFlowCommonHistResults.cxx index 155a2667b43..78542cfaaa8 100644 --- a/PWG2/FLOW/AliFlowCommonHistResults.cxx +++ b/PWG2/FLOW/AliFlowCommonHistResults.cxx @@ -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"<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"<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; + +} + diff --git a/PWG2/FLOW/AliFlowLYZHist1.h b/PWG2/FLOW/AliFlowLYZHist1.h index 4d17e7b2984..daca90500c1 100644 --- a/PWG2/FLOW/AliFlowLYZHist1.h +++ b/PWG2/FLOW/AliFlowLYZHist1.h @@ -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 }; diff --git a/PWG2/FLOW/AliFlowLYZHist2.cxx b/PWG2/FLOW/AliFlowLYZHist2.cxx index 49e96be22bf..4d3b723f9f5 100644 --- a/PWG2/FLOW/AliFlowLYZHist2.cxx +++ b/PWG2/FLOW/AliFlowLYZHist2.cxx @@ -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; + +} diff --git a/PWG2/FLOW/AliFlowLYZHist2.h b/PWG2/FLOW/AliFlowLYZHist2.h index 82f3f58bfc6..1e71db86e79 100644 --- a/PWG2/FLOW/AliFlowLYZHist2.h +++ b/PWG2/FLOW/AliFlowLYZHist2.h @@ -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 }; -- 2.43.0