27 #define AliFlowAnalysisWithFittingQDistribution_cxx 29 #include "Riostream.h" 38 #include "TParticle.h" 64 fBookOnlyBasicCCH(kTRUE),
66 fCommonHistsResults(NULL),
83 fUsePhiWeights(kFALSE),
84 fUsePtWeights(kFALSE),
85 fUseEtaWeights(kFALSE),
86 fUseParticleWeights(NULL),
90 fSumOfParticleWeights(NULL),
95 fStoreqDistributionVsMult(kFALSE),
96 fqDistributionVsMult(NULL),
100 fFittingParameters(NULL),
108 fFinalResultIsFromSigma2Fitted(kTRUE),
109 fPrintOnTheScreen(kTRUE),
116 fHistList =
new TList();
117 fHistList->SetName(
"cobjFQD");
118 fHistList->SetOwner(kTRUE);
121 fAnalysisLabel =
new TString();
124 fWeightsList =
new TList();
127 this->InitializeArrays();
151 Bool_t oldHistAddStatus = TH1::AddDirectoryStatus();
152 TH1::AddDirectory(kFALSE);
174 TH1::AddDirectory(oldHistAddStatus);
203 Int_t nCounterNoRPs = 0;
205 Double_t dSumOfParticleWeights = 0.;
211 for(
Int_t i=0;i<nPrim;i++)
219 dPhi = aftsTrack->
Phi();
220 dPt = aftsTrack->
Pt();
221 dEta = aftsTrack->
Eta();
236 dReQ += wPhi*wPt*wEta*TMath::Cos(n*dPhi);
237 dImQ += wPhi*wPt*wEta*TMath::Sin(n*dPhi);
239 dSumOfParticleWeights += wPhi*wPt*wEta;
245 if(dSumOfParticleWeights > 1.)
247 q = pow(dReQ*dReQ+dImQ*dImQ,0.5)/pow(dSumOfParticleWeights,0.5);
257 dMultiplicityBin = nNumberOfRPsEBE+0.5;
261 dMultiplicityBin = nReferenceMultiplicityEBE+0.5;
265 dMultiplicityBin = nNumberOfPOIsEBE+0.5;
321 cout<<
" WARNING (FQD::Make()): fCommonHists is NULL !!!!"<<endl;
328 cout<<
" WARNING (FQD::Make()): fqDistribution is NULL !!!!"<<endl;
335 cout<<
" WARNING (FQD::Make()): fSumOfParticleWeights is NULL !!!!"<<endl;
342 cout<<
" WARNING (FQD::Make()): fPhiWeights is NULL !!!!"<<endl;
349 cout<<
" WARNING (FQD::Make()): fPtWeights is NULL !!!!"<<endl;
356 cout<<
" WARNING (FQD::Make()): fEtaWeights is NULL !!!!"<<endl;
372 cout<<
" WARNING (FQD::Finish()): fFittingParameters is NULL !!!!"<<endl;
379 cout<<
" WARNING (FQD::Finish()): fqDistribution is NULL !!!!"<<endl;
386 cout<<
" WARNING (FQD::Finish()): fSumOfParticleWeights is NULL !!!!"<<endl;
390 for(
Int_t s2F=0;s2F<2;s2F++)
395 cout<<
" WARNING (FQD::Finish()): "<<Form(
"fIntFlow[%d] is NULL !!!!",s2F)<<endl;
402 cout<<
" WARNING (FQD::Finish()): "<<Form(
"fSigma2[%d] is NULL !!!!",s2F)<<endl;
409 cout<<
" WARNING (FQD::Finish()): "<<Form(
"fChi2[%d] is NULL !!!!",s2F)<<endl;
417 cout<<
"WARNING (FQD::Finish()): fCommonHistsResults is NULL !!!!"<<endl;
424 cout<<
"WARNING (FQD::Finish()): fCommonHists is NULL !!!!"<<endl;
440 TString commonHistName =
"AliFlowCommonHistFQD";
445 TString commonHistResName =
"AliFlowCommonHistResultsFQD";
448 (outputListHistos->FindObject(commonHistResName.Data()));
452 TList *weightsList =
dynamic_cast<TList*
>(outputListHistos->FindObject(
"Weights"));
454 Bool_t bUsePhiWeights = kFALSE;
455 Bool_t bUsePtWeights = kFALSE;
456 Bool_t bUseEtaWeights = kFALSE;
457 TString fUseParticleWeightsName =
"fUseParticleWeightsFQD";
459 TProfile *useParticleWeights = NULL;
462 useParticleWeights =
dynamic_cast<TProfile*
>(weightsList->FindObject(fUseParticleWeightsName.Data()));
464 if(useParticleWeights)
467 bUsePhiWeights = (
Int_t)useParticleWeights->GetBinContent(1);
469 bUsePtWeights = (
Int_t)useParticleWeights->GetBinContent(2);
471 bUseEtaWeights = (
Int_t)useParticleWeights->GetBinContent(3);
476 TString sigmaFlag[2] = {
"#sigma^{2} not fitted",
"#sigma^{2} fitted"};
478 TString qDistributionName =
"fqDistribution";
481 TString sumOfParticleWeightsName =
"fSumOfParticleWeights";
484 TString intFlowName =
"fIntFlowFQD";
487 TString sigma2Name =
"fSigma2";
493 TString fittingFunctionName =
"fFittingFunction";
496 TH1D *qDistribution = NULL;
497 TH1D *sumOfParticleWeights = NULL;
498 TH1D *intFlow[2] = {NULL};
499 TH1D *sigma2[2] = {NULL};
500 TH1D *chi2[2] = {NULL};
501 TF1 *fittingFunction[2] = {NULL};
504 qDistribution =
dynamic_cast<TH1D*
>(outputListHistos->FindObject(Form(
"%s",qDistributionName.Data())));
510 cout<<
"WARNING: qDistribution is NULL in AFAWFQD::GOH() !!!!"<<endl;
513 sumOfParticleWeights =
dynamic_cast<TH1D*
>(outputListHistos->FindObject(Form(
"%s",sumOfParticleWeightsName.Data())));
514 if(sumOfParticleWeights)
519 cout<<
"WARNING: sumOfParticleWeights is NULL in AFAWFQD::GOH() !!!!"<<endl;
522 for(
Int_t f=0;f<2;f++)
525 intFlow[f] =
dynamic_cast<TH1D*
>(outputListHistos->FindObject(Form(
"%s, %s",intFlowName.Data(),sigmaFlag[f].Data())));
531 cout<<
"WARNING: intFlow[f] is NULL in AFAWFQD::GOH() !!!!"<<endl;
532 cout<<
"f = "<<f<<endl;
535 sigma2[f] =
dynamic_cast<TH1D*
>(outputListHistos->FindObject(Form(
"%s, %s",sigma2Name.Data(),sigmaFlag[f].Data())));
541 cout<<
"WARNING: sigma2[f] is NULL in AFAWFQD::GOH() !!!!"<<endl;
542 cout<<
"f = "<<f<<endl;
545 chi2[f] =
dynamic_cast<TH1D*
>(outputListHistos->FindObject(Form(
"%s, %s",chi2Name.Data(),sigmaFlag[f].Data())));
551 cout<<
"WARNING: chi2[f] is NULL in AFAWFQD::GOH() !!!!"<<endl;
552 cout<<
"f = "<<f<<endl;
555 fittingFunction[f] =
dynamic_cast<TF1*
>(outputListHistos->FindObject(Form(
"%s, %s",fittingFunctionName.Data(),sigmaFlag[f].Data())));
556 if(fittingFunction[f])
561 cout<<
"WARNING: fittingFunction[f] is NULL in AFAWFQD::GOH() !!!!"<<endl;
562 cout<<
"f = "<<f<<endl;
568 TString fittingParametersName =
"fFittingParameters";
570 TProfile *fittingParameters = NULL;
571 fittingParameters =
dynamic_cast<TProfile*
>(outputListHistos->FindObject(fittingParametersName.Data()));
572 if(fittingParameters)
577 cout<<
"WARNING:fittingParameters is NULL in AFAWFQD::GOH() !!!!"<<endl;
582 cout<<
"WARNING: outputListHistos is NULL in AFAWFQD::GOH() !!!!"<<endl;
593 TFile *output =
new TFile(outputFileName->Data(),
"RECREATE");
606 TFile *output =
new TFile(outputFileName.Data(),
"RECREATE");
622 outputFileName->Write(outputFileName->GetName(), TObject::kSingleKey);
631 for(
Int_t s2F=0;s2F<2;s2F++)
648 TString commonHistName =
"AliFlowCommonHistFQD";
654 TString commonHistResName =
"AliFlowCommonHistResultsFQD";
669 cout<<
"WARNING: fWeightsList is NULL in AFAWFQD::BAFWH() !!!!"<<endl;
673 TString fUseParticleWeightsName =
"fUseParticleWeightsFQD";
675 fUseParticleWeights =
new TProfile(fUseParticleWeightsName.Data(),
"0 = particle weight not used, 1 = particle weight used ",3,0,3);
690 if(!
fPhiWeights){printf(
"\n WARNING (FQD): !fPhiWeights !!!!\n");exit(0);}
694 cout<<
"WARNING (FQD): Inconsistent binning in histograms for phi-weights throughout the code."<<endl;
700 cout<<
"WARNING: fWeightsList->FindObject(\"phi_weights\") is NULL in AFAWFQD::BAFWH() !!!!"<<endl;
710 if(!
fPtWeights){printf(
"\n WARNING (FQD): !fPtWeights !!!!\n");exit(0);}
714 cout<<
"WARNING (FQD): Inconsistent binning in histograms for pt-weights throughout the code."<<endl;
720 cout<<
"WARNING: fWeightsList->FindObject(\"pt_weights\") is NULL in AFAWFQD::BAFWH() !!!!"<<endl;
730 if(!
fEtaWeights){printf(
"\n WARNING (FQD): !fEtaWeights !!!!\n");exit(0);}
734 cout<<
"WARNING (FQD): Inconsistent binning in histograms for eta-weights throughout the code."<<endl;
740 cout<<
"WARNING: fUseEtaWeights && fWeightsList->FindObject(\"eta_weights\") is NULL in AFAWFQD::BAFWH() !!!!"<<endl;
775 TString sigmaFlag[2] = {
"#sigma^{2} not fitted",
"#sigma^{2} fitted"};
777 TString fqDistributionName =
"fqDistribution";
786 TString fqDistributionVsMultName =
"fqDistributionVsMult";
803 TString fSumOfParticleWeightsName =
"fSumOfParticleWeights";
811 TString fIntFlowName =
"fIntFlowFQD";
814 TString fSigma2Name =
"fSigma2";
820 TString fittingFunctionName =
"fFittingFunction";
823 for(
Int_t f=0;f<2;f++)
826 fIntFlow[f] =
new TH1D(Form(
"%s, %s",fIntFlowName.Data(),sigmaFlag[f].Data()),Form(
"Reference Flow (%s)",sigmaFlag[f].
Data()),1,0,1);
830 fSigma2[f] =
new TH1D(Form(
"%s, %s",fSigma2Name.Data(),sigmaFlag[f].Data()),Form(
"#sigma^{2} (%s)",sigmaFlag[f].
Data()),1,0,1);
831 fSigma2[f]->SetLabelSize(0.08);
832 (
fSigma2[f]->GetXaxis())->SetBinLabel(1,
"#sigma^{2}");
835 fChi2[f] =
new TH1D(Form(
"%s, %s",fChi2Name.Data(),sigmaFlag[f].Data()),Form(
"#chi^{2} (%s)",sigmaFlag[f].
Data()),1,0,1);
836 fChi2[f]->SetLabelSize(0.08);
837 (
fChi2[f]->GetXaxis())->SetLabelOffset(0.01);
838 (
fChi2[f]->GetXaxis())->SetBinLabel(1,
"#chi^{2}");
841 fFittingFunction[f] =
new TF1(Form(
"%s, %s",fittingFunctionName.Data(),sigmaFlag[f].Data()),
"[2]*(x/[1])*exp(-(x*x+[0]*[0])/(2.*[1]))*TMath::BesselI0(x*[0]/[1])");
845 TString fFittingParametersName =
"fFittingParameters";
847 fFittingParameters =
new TProfile(fFittingParametersName.Data(),
"Parameters for fitting q-distribution",13,0,13);
856 fFittingParameters->GetXaxis()->SetBinLabel(8,
"Final result is from #sigma^{2} fitted?");
881 if(TMath::Abs(binWidth) < 1.e-44)
884 cout<<
"WARNING (FQD): binWidth == 0 in AFAWFQD::DoFit()"<<endl;
888 Double_t qmin = (binMin-1)*binWidth;
891 for(
Int_t b=binMin;b<=binMax;b++)
899 fFittingFunction[s2F]->SetParNames(
"v*sqrt{sum of particle weights}",
"sigma^2",
"norm");
929 fIntFlow[s2F]->SetBinError(1,vError);
933 cout<<
"WARNING (FQD): AvM == 0 in AFAWFQD::DoFit()"<<endl;
940 fSigma2[0]->SetBinContent(1,sigma2);
946 fSigma2[1]->SetBinContent(1,sigma2);
947 fSigma2[1]->SetBinError(1,sigma2Error);
951 fChi2[s2F]->SetBinContent(1,chi2);
995 cout<<
"***************************************"<<endl;
996 cout<<
"***************************************"<<endl;
997 cout<<
" reference flow by fitting "<<endl;
998 cout<<
" q-distribution: "<<endl;
1001 cout<<
" (with weights) "<<endl;
1004 cout<<
" (without weights) "<<endl;
1007 cout<<
"1.) sigma^2 not fitted: "<<endl;
1008 cout<<
" v_"<<n<<
"{FQD} = "<<
fIntFlow[0]->GetBinContent(1)<<
" +/- "<<
fIntFlow[0]->GetBinError(1)<<endl;
1009 cout<<
" sigma^2 = 0.5 +/- 0 "<<endl;
1010 cout<<
" chi^2 = "<<
fChi2[0]->GetBinContent(1)<<
" (Minuit)"<<endl;
1012 if(TMath::Abs(
fIntFlow[0]->GetBinContent(1)-
fvMin)<1.e-10 ||
1015 cout<<
" WARNING: value of v_"<<n<<
"{FQD}"<<
" is on the boundary"<<endl;
1016 cout<<
" of fitting interval. Redo the fit."<< endl;
1019 cout<<
"2.) sigma^2 fitted: "<<endl;
1020 cout<<
" v_"<<n<<
"{FQD} = "<<
fIntFlow[1]->GetBinContent(1)<<
" +/- "<<
fIntFlow[1]->GetBinError(1)<<endl;
1021 cout<<
" sigma^2 = "<<
fSigma2[1]->GetBinContent(1)<<
" +/- "<<
fSigma2[1]->GetBinError(1)<<endl;
1022 cout<<
" chi^2 = "<<
fChi2[1]->GetBinContent(1)<<
" (Minuit)"<<endl;
1024 if(TMath::Abs(
fIntFlow[0]->GetBinContent(1)-
fvMin)<1.e-10 ||
1027 cout<<
" WARNING: value of v_"<<n<<
"{FQD}"<<
" is on the boundary"<<endl;
1028 cout<<
" of fitting interval. Redo the fit."<< endl;
1034 cout<<
" WARNING: value of sigma^2 is on the boundary"<<endl;
1035 cout<<
" of fitting interval. Redo the fit."<< endl;
1040 cout<<
"***************************************"<<endl;
1041 cout<<
"***************************************"<<endl;
1055 cout<<
"WARNING (FQD): fFittingParameters is NULL in AFAWFQD::SFP() !!!!"<<endl;
Double_t GetEtaMax() const
Bool_t FillChi(Double_t aChi)
virtual void BookCommonHistograms()
virtual void StoreFittingParameters()
AliFlowCommonHistResults * fCommonHistsResults
void SetqDistribution(TH1D *const qd)
void SetUsePtWeights(Bool_t const uPtW)
AliFlowTrackSimple * GetTrack(Int_t i)
TH1D * fSumOfParticleWeights
Int_t GetNumberOfRPs() const
void SetCommonHistsResults(AliFlowCommonHistResults *const chr)
AliFlowCommonHist * fCommonHists
Int_t GetNbinsPhi() const
Double_t GetPtMin() const
virtual void DoFit(Bool_t sigma2Fitted)
virtual void CheckPointersUsedInFinish()
Bool_t fStoreqDistributionVsMult
TF1 * fFittingFunction[2]
virtual void CheckPointersUsedInMake()
void SetWeightsList(TList *wlist)
virtual void AccessFittingParameters()
Double_t GetPtMax() const
void SetIntFlow(TH1D *const intFlow, Int_t sigmaFitted)
Bool_t InRPSelection() const
Bool_t FillControlHistograms(AliFlowEventSimple *anEvent, TList *weightsList=NULL, Bool_t usePhiWeights=kFALSE, Bool_t usePtWeights=kFALSE, Bool_t useEtaWeights=kFALSE)
virtual void PrintOnTheScreen()
AliFlowCommonConstants::ERefMultSource fMultiplicityIs
void SetFittingFunction(TF1 *const ff, Int_t sigmaFitted)
Double_t GetPhiMax() const
virtual void FillCommonHistResults(Bool_t sigma2Fitted)
void SetUsePhiWeights(Bool_t const uPhiW)
void SetCommonHists(AliFlowCommonHist *const ch)
void SetFittingParameters(TProfile *const fp)
void SetUseEtaWeights(Bool_t const uEtaW)
Int_t GetNbinsEta() const
static AliFlowCommonConstants * GetMaster()
Int_t GetNumberOfPOIs(Int_t i=1) const
TProfile * fFittingParameters
void SetChi2(TH1D *const chi2, Int_t sigmaFitted)
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
TProfile * fUseParticleWeights
Bool_t FillIntegratedFlow(Double_t aV, Double_t anError)
virtual void Make(AliFlowEventSimple *anEvent)
void SetSumOfParticleWeights(TH1D *const sopW)
Int_t GetReferenceMultiplicity() const
virtual void InitializeArrays()
Double_t GetPhiMin() const
virtual ~AliFlowAnalysisWithFittingQDistribution()
Double_t GetEtaMin() const
Bool_t fFinalResultIsFromSigma2Fitted
void SetUseParticleWeights(TProfile *const uPW)
virtual void GetOutputHistograms(TList *outputListHistos)
virtual void WriteHistograms(TString *outputFileName)
virtual void BookEverythingForDistributions()
void SetSigma2(TH1D *const sigma2, Int_t sigmaFitted)
virtual void AccessConstants()
virtual void BookAndFillWeightsHistograms()
TH2D * fqDistributionVsMult
virtual void Finish(Bool_t doFit=kTRUE)
Int_t NumberOfTracks() const