#include "TProfile.h"
#include "TString.h"
#include "TComplex.h"
#include "TList.h"
#include "AliFlowLYZConstants.h"
#include "AliFlowLYZHist1.h"
#include "TBrowser.h"
class TH1D;
ClassImp(AliFlowLYZHist1)
AliFlowLYZHist1::AliFlowLYZHist1():
TNamed(),
fHistGtheta(0),
fHistProReGtheta(0),
fHistProImGtheta(0),
fHistList(NULL)
{
}
AliFlowLYZHist1::AliFlowLYZHist1(Int_t theta, const char *anInput, Bool_t useSum):
TNamed(anInput,anInput),
fHistGtheta(0),
fHistProReGtheta(0),
fHistProImGtheta(0),
fHistList(NULL)
{
Int_t iNbins = AliFlowLYZConstants::GetMaster()->GetNbins();
Double_t dMaxSUM = AliFlowLYZConstants::GetMaster()->GetMaxSUM();
Double_t dMaxPROD = AliFlowLYZConstants::GetMaster()->GetMaxPROD();
Double_t dMin = 0.;
TString name, addlast;
if (useSum) { addlast = "LYZSUM"; }
else { addlast = "LYZPROD"; }
name = "First_Flow_Gtheta";
name +=theta;
name +=addlast;
if (useSum) { fHistGtheta = new TH1D(name.Data(),name.Data(),iNbins,dMin,dMaxSUM); }
else { fHistGtheta = new TH1D(name.Data(),name.Data(),iNbins,dMin,dMaxPROD); }
fHistGtheta->SetXTitle("r");
fHistGtheta->SetYTitle("|G^{#theta}(ir)|^{2}");
name = "First_FlowPro_ReGtheta";
name +=theta;
name +=addlast;
if (useSum) { fHistProReGtheta = new TProfile(name.Data(),name.Data(),iNbins,dMin,dMaxSUM); }
else { fHistProReGtheta = new TProfile(name.Data(),name.Data(),iNbins,dMin,dMaxPROD); }
fHistProReGtheta->SetXTitle("r");
fHistProReGtheta->SetYTitle("Re G^{#theta}(ir)");
name = "First_FlowPro_ImGtheta";
name +=theta;
name +=addlast;
if (useSum) { fHistProImGtheta = new TProfile(name.Data(),name.Data(),iNbins,dMin,dMaxSUM); }
else { fHistProImGtheta = new TProfile(name.Data(),name.Data(),iNbins,dMin,dMaxPROD); }
fHistProImGtheta->SetXTitle("r");
fHistProImGtheta->SetYTitle("Im G^{#theta}(ir)");
fHistList = new TList();
fHistList-> Add(fHistGtheta);
fHistList-> Add(fHistProReGtheta);
fHistList-> Add(fHistProImGtheta);
}
AliFlowLYZHist1::~AliFlowLYZHist1()
{
delete fHistGtheta;
delete fHistProReGtheta;
delete fHistProImGtheta;
delete fHistList;
}
void AliFlowLYZHist1::Fill(Double_t f, TComplex c)
{
fHistProReGtheta->Fill(f, c.Re());
fHistProImGtheta->Fill(f, c.Im());
}
TH1D* AliFlowLYZHist1::FillGtheta()
{
Int_t iNbins = fHistGtheta->GetNbinsX();
for (Int_t bin=1;bin<=iNbins;bin++)
{
Double_t dRe = fHistProReGtheta->GetBinContent(bin);
Double_t dIm = fHistProImGtheta->GetBinContent(bin);
TComplex cGtheta(dRe,dIm);
fHistGtheta->SetBinContent(bin,cGtheta.Rho2());
fHistGtheta->SetBinError(bin,0.0);
}
return fHistGtheta;
}
Double_t AliFlowLYZHist1::GetR0()
{
Int_t iNbins = fHistGtheta->GetNbinsX();
Double_t dR0 = 0.;
for (Int_t b=2;b<iNbins;b++)
{
Double_t dG0 = fHistGtheta->GetBinContent(b);
Double_t dGnext = fHistGtheta->GetBinContent(b+1);
Double_t dGnextnext = fHistGtheta->GetBinContent(b+2);
if (dGnext > dG0 && dGnextnext > dG0)
{
Double_t dGlast = fHistGtheta->GetBinContent(b-1);
Double_t dXlast = fHistGtheta->GetBinCenter(b-1);
Double_t dX0 = fHistGtheta->GetBinCenter(b);
Double_t dXnext = fHistGtheta->GetBinCenter(b+1);
dR0 = dX0 - ((dX0-dXlast)*(dX0-dXlast)*(dG0-dGnext) - (dX0-dXnext)*(dX0-dXnext)*(dG0-dGlast))/
(2.*((dX0-dXlast)*(dG0-dGnext) - (dX0-dXnext)*(dG0-dGlast)));
break;
}
}
return dR0;
}
Double_t AliFlowLYZHist1::GetBinCenter(Int_t i)
{
Double_t dR = fHistGtheta->GetBinCenter(i);
return dR;
}
Int_t AliFlowLYZHist1::GetNBins()
{
Int_t iNbins = fHistGtheta->GetNbinsX();
return iNbins;
}
Double_t AliFlowLYZHist1::Merge(TCollection *aList)
{
if (!aList) return 0;
if (aList->IsEmpty()) return 0;
Int_t iCount = 0;
TIter next(aList);
AliFlowLYZHist1 *toMerge;
TList *pTemp = new TList();
while ((toMerge=(AliFlowLYZHist1*)next())) {
pTemp->Add(toMerge->GetHistList());
iCount++;
}
fHistList->Merge(pTemp);
delete pTemp;
return (double)iCount;
}
void AliFlowLYZHist1::Print(Option_t *option) const
{
printf( "Class.Print Name = %s, Histogram list:\n",GetName());
if (fHistList) {
fHistList->Print(option);
}
else
{
printf( "Empty histogram list \n");
}
}
void AliFlowLYZHist1::Browse(TBrowser *b)
{
if (!b) return;
if (fHistList) b->Add(fHistList,"AliFlowLYZHist1List");
}