#include "DataProcessing.h" #include "FemtoUtils.h" #include "HbtFitter.h" #include #include #include const Double_t MHC = 0.197326960277; // GeV * fm const Double_t MHC_SQR = 0.038937929230; // GeV^2 * fm^2 const Double_t INVSQRTPI = 0.564189584; // 1/sqrt(pi) const Double_t PION_MASS = 0.13957; const Double_t PION_MASS_SQR = 0.0194797; const Double_t KAON_MASS = 0.493677; const Double_t KAON_MASS_SQR = 0.24371698; vector DoFit(TH1* histo, Int_t PartType=4, Int_t SourceFunc=0, Int_t NonFemtoFunc=1, Bool_t DrawFitLegend=false, Bool_t ExcludePoints=false); //_________________ DataProcessing::DataProcessing() { mExpFileName = "~/work/star/data/expKaonHBT_auau200_2011.root"; mOutFileName = "~/work/star/soft/star_software/processing/auau/oKaonHBT_pp200.root"; mQinvBins = 40; mQinvLow = 0.; mQinvHi = 0.4; mExpFile = NULL; mOutFile = NULL; mDetSelection = 2; mPartType = 4; mCorrFctnColor = 1; mCorrFctnLineWidth = 2; mCorrFctnMarkerStyle = 20; mCorrFctnMarkerSize = 1.5; mYaxisLo = 0.6; mYaxisHi = 1.6; mMultBins = 9; mKtBins = 24; mKtRanges = 6; mSourceFunc = 0; mNonFemtoFunc = 0; mDrawLegend = true; } //_________________ DataProcessing::~DataProcessing() { /* noting to do */ } //_________________ void DataProcessing::SetCorrFctnStyle(Int_t color, Int_t width, Int_t style, Double_t size) { mCorrFctnColor = color; mCorrFctnLineWidth = width; mCorrFctnMarkerStyle = style; mCorrFctnMarkerSize = size; } //_________________ void DataProcessing::SetHistoStyle(TH1 *h) { h->SetLineColor(mCorrFctnColor); h->SetLineWidth(mCorrFctnLineWidth); h->SetMarkerStyle(mCorrFctnMarkerStyle); h->SetMarkerSize(mCorrFctnMarkerSize); h->SetMarkerColor(mCorrFctnColor); h->GetYaxis()->SetRangeUser(mYaxisLo,mYaxisHi); } //_________________ void DataProcessing::OpenFiles() { std::cout << "Opening file with experimental data: " << mExpFileName; mExpFile = TFile::Open(mExpFileName); std::cout << "\t [DONE]" << std::endl; std::cout << "Creating output file: " << mOutFileName; mOutFile = new TFile(mOutFileName,"recreate"); std::cout << "\t [DONE]" << std::endl; } //_________________ void DataProcessing::DoProcessing() { std::cout << "Start processing..." << std::endl; OpenFiles(); ReadHistos(); ProcessHistos(); FitHistos(); MakeTGraphs(); Finish(); std::cout << "Processing is finished" << std::endl; } //_________________ void DataProcessing::ReadHistos() { std::cout << "Retrieving histograms from files..."; for(Int_t iCharge=0; iCharge<2; iCharge++) { //for(Int_t iDet=0; iDet<5; iDet++) { for(Int_t iMult=0; iMultGet(Form("hKaonQinvMixKt_%d_%d_%d_Num_bin_%d", iCharge,mDetSelection,iMult,iKt)); TH1F *hExpKaonKtMixDen = (TH1F*)mExpFile->Get(Form("hKaonQinvMixKt_%d_%d_%d_Den_bin_%d", iCharge,mDetSelection,iMult,iKt)); hQinvMixNum.push_back(hExpKaonKtMixNum); hQinvMixDen.push_back(hExpKaonKtMixDen); } else if(mPartType == 3) { //Pions TH1F *hExpPionKtMixNum = (TH1F*)mExpFile->Get(Form("hPionQinvMixKt_%d_%d_%d_Num_bin_%d", iCharge,mDetSelection,iMult,iKt)); TH1F *hExpPionKtMixDen = (TH1F*)mExpFile->Get(Form("hPionQinvMixKt_%d_%d_%d_Den_bin_%d", iCharge,mDetSelection,iMult,iKt)); hQinvMixNum.push_back(hExpPionKtMixNum); hQinvMixDen.push_back(hExpPionKtMixDen); } } //for(Int_t iKt=0; iKt<20; iKt++) } //for(Int_t iMult=0; iMult<10; iMult++) //} //for(Int_t iDet=0; iDet<5; iDet++) } //for(Int_t iCharge=0; iCharge<2; iCharge++) std::cout << "\t [DONE]" << std::endl; std::cout << Form("Number of histos in numerator: %d", hQinvMixNum.size()) << std::endl << Form("Number of histos in denominator: %d", hQinvMixDen.size()) << std::endl; } //_________________ void DataProcessing::ProcessHistos() { std::cout << "Processing multiplicity histograms..."; ProcessMultHistos(); std::cout << "\t [DONE]" << std::endl; std::cout << "Processing Mult vs kT histograms..."; ProcessMultKtHistos(); std::cout << "\t [DONE]" << std::endl; } //_________________ TH1F* DataProcessing::BuildMultCF(Int_t charge, Int_t BinLo, Int_t BinHi) { if(charge<0 || charge>2) { std::cout << "DataProcessing::BuildMultCF [WARNING] - Wrong charge: " << charge << std::endl; return 0; } if(BinLo<0 || BinHi>=mMultBins) { std::cout << "DataProcessing::BuildMultCF [WARNING] - Wrong multiplicity bins: " << BinLo << "_" << BinHi << std::endl; return 0; } TH1F *hNumSum = new TH1F("hNumSum","",mQinvBins, mQinvLow, mQinvHi); TH1F *hDenSum = new TH1F("hDenSum","",mQinvBins, mQinvLow, mQinvHi); TH1F *hRatio; TString sName = "h"; sName += "CentCF_"; sName += charge; sName += "_"; sName += BinLo; sName += "_"; sName += BinHi; hRatio = new TH1F(sName.Data(),"",mQinvBins,mQinvLow,mQinvHi); if(charge<2) { for(Int_t iMult=BinLo; iMult<=BinHi; iMult++) { for(Int_t iKt=0; iKtAdd(hQinvMixNum[charge*mMultBins*mKtBins+iMult*mKtBins+iKt]); hDenSum->Add(hQinvMixDen[charge*mMultBins*mKtBins+iMult*mKtBins+iKt]); } //for(Int_t iKt=0; iKtAdd(hQinvMixNum[iCharge*mMultBins*mKtBins+iMult*mKtBins+iKt]); hDenSum->Add(hQinvMixDen[iCharge*mMultBins*mKtBins+iMult*mKtBins+iKt]); } //for(Int_t iKt=0; iKt2) { std::cout << "DataProcessing::BuildMultKtCF [WARNING] - Wrong charge: " << charge << std::endl; return 0; } if(MultBinLo<0 || MultBinHi>=mMultBins) { std::cout << "DataProcessing::BuildMultKtCF [WARNING] - Wrong multiplicity bins: " << MultBinLo << "_" << MultBinHi << std::endl; return 0; } if(KtBinLo<0 || KtBinHi>=mKtBins) { std::cout << "DataProcessing::BuildMultKtCF [WARNING] - Wrong kT bins: " << KtBinLo << "_" << KtBinHi << std::endl; return 0; } TH1F *hNumSum = new TH1F("hNumSum","",mQinvBins, mQinvLow, mQinvHi); TH1F *hDenSum = new TH1F("hDenSum","",mQinvBins, mQinvLow, mQinvHi); TH1F *hRatio; TString sName = "h"; sName += "MultKtCF_"; sName += charge; sName += "_"; sName += MultBinLo; sName += "_"; sName += MultBinHi; sName += "_"; sName += KtBinLo; sName += "_"; sName += KtBinHi; hRatio = new TH1F(sName.Data(),"",mQinvBins,mQinvLow,mQinvHi); if(charge<2) { for(Int_t iMult=MultBinLo; iMult<=MultBinHi; iMult++) { for(Int_t iKt=KtBinLo; iKt<=KtBinHi; iKt++) { hNumSum->Add(hQinvMixNum[charge*mMultBins*mKtBins+iMult*mKtBins+iKt]); hDenSum->Add(hQinvMixDen[charge*mMultBins*mKtBins+iMult*mKtBins+iKt]); } //for(Int_t iKt=KtBinLo; iKt<=KtBinHi; iKt++) } //for(Int_t iMult=MultBinLo; iMult<=MultBinHi; iMult++) } //if(charge<2) else { for(Int_t iCharge=0; iCharge<2; iCharge++) { for(Int_t iMult=MultBinLo; iMult<=MultBinHi; iMult++) { for(Int_t iKt=KtBinLo; iKt<=KtBinHi; iKt++) { hNumSum->Add(hQinvMixNum[iCharge*mMultBins*mKtBins+iMult*mKtBins+iKt]); hDenSum->Add(hQinvMixDen[iCharge*mMultBins*mKtBins+iMult*mKtBins+iKt]); } //for(Int_t iKt=KtBinLo; iKt<=KtBinHi; iKt++) } //for(Int_t iMult=MultBinLo; iMult<=MultBinHi; iMult++) } //for(Int_t iCharge=0; iCharge<2; iCharge++) } //if(charge==2) Make1DCorrFctn(hRatio,hNumSum,hDenSum); delete hNumSum; delete hDenSum; return hRatio; } //_________________ void DataProcessing::ProcessMultHistos() { Int_t multBinLo, multBinHi; for(Int_t iCharge=0; iCharge<3; iCharge++) { for(Int_t iMultBin=0; iMultBinWrite(); for(Int_t iCent=0; iCent<9; iCent++) { gMultKtDepRadiiGrErr[iCharge][iCent]->Write(); gMultKtDepRadiiMtGrErr[iCharge][iCent]->Write(); } } mOutFile->Write(); mOutFile->Close(); mExpFile->Close(); } //_________________ void DataProcessing::FitHistos() { vector mFitParams; for(unsigned int i=0; iSetName(Form("gMultDepRadiiGrErr_%d",iCharge)); gMultDepRadiiGrErr[iCharge]->SetMarkerColor(mMultDepColor[iCharge]); gMultDepRadiiGrErr[iCharge]->SetLineColor(mMultDepColor[iCharge]); gMultDepRadiiGrErr[iCharge]->SetMarkerStyle(mMultDepMarkerStyle); gMultDepRadiiGrErr[iCharge]->SetMarkerSize(mMultDepMarkerSize); } //for(Int_t iCharge=0; iCharge<3; iCharge++) //Multiplicity and kT depence for(Int_t iCharge=0; iCharge<3; iCharge++) { if(iCharge==2) { std::cout << std::endl; std::cout << "Radii values (kT) for sum of charges:" << std::endl; } for(Int_t iCent=0; iCentSetName(Form("gMultKtDepRadiiGrErr_%d_%d", iCharge,iCent)); gMultKtDepRadiiMtGrErr[iCharge][iCent] = new TGraphErrors(mKtRanges, mMtVal, mKtRadiiTmp, mKtErrVal, mKtRadiiErrTmp); gMultKtDepRadiiMtGrErr[iCharge][iCent]->SetName(Form("gMultKtDepRadiiMtGrErr_%d_%d", iCharge,iCent)); if(iCent<2) continue; //Skip first 2 point due to the mistake. gMultKtDepRadiiGrErr[iCharge][iCent]->SetMarkerColor(mMultKtDepColor[iCent]); gMultKtDepRadiiGrErr[iCharge][iCent]->SetLineColor(mMultKtDepColor[iCent]); gMultKtDepRadiiGrErr[iCharge][iCent]->SetMarkerSize(mMultKtDepMarkerSize); gMultKtDepRadiiGrErr[iCharge][iCent]->SetMarkerStyle(mMultKtDepMarkerStyle[iCharge]); gMultKtDepRadiiMtGrErr[iCharge][iCent]->SetMarkerColor(mMultKtDepColor[iCent]); gMultKtDepRadiiMtGrErr[iCharge][iCent]->SetLineColor(mMultKtDepColor[iCent]); gMultKtDepRadiiMtGrErr[iCharge][iCent]->SetMarkerSize(mMultKtDepMarkerSize); gMultKtDepRadiiMtGrErr[iCharge][iCent]->SetMarkerStyle(mMultKtDepMarkerStyle[iCharge]); } //for(Int_t iCent=0; iCent DoFit(TH1* histo, Int_t PartType, Int_t SourceFunc, Int_t NonFemtoFunc, Bool_t DrawFitLegend, Bool_t mExcludePoints) { vector mRetVect; Int_t mNbins = histo->GetXaxis()->GetNbins(); Double_t mFitMinVal = 0.; Double_t mDeltaMaxFitVal = -0.009; // -0.005 Double_t mFitMaxVal = histo->GetXaxis()->GetBinUpEdge(mNbins) + mDeltaMaxFitVal; Int_t mFemtoParNum = 2; //lambda, R Int_t mNonFemtoParNum = 0; if(NonFemtoFunc == 0) mNonFemtoParNum = 1; else if(NonFemtoFunc == 1) mNonFemtoParNum = 2; else if(NonFemtoFunc >= 2 && NonFemtoFunc<=3) mNonFemtoParNum = 3; else if(NonFemtoFunc >= 4) mNonFemtoParNum = 2; Int_t mFullParNum = mFemtoParNum + mNonFemtoParNum; HbtFitter* mHbtFitter = new HbtFitter(PartType,SourceFunc,NonFemtoFunc); mHbtFitter->Set1DMaxVal(histo->GetXaxis()->GetBinUpEdge(mNbins)); mHbtFitter->Set1DBinsNum(mNbins); TF1* mCorrFit = new TF1("mCorrFit",mHbtFitter,&HbtFitter::FitFunction, mFitMinVal,mFitMaxVal,mFullParNum,"HbtFitter","FitFunction"); mCorrFit->SetParameter(0, 0.5); mCorrFit->SetParLimits(0, 0., 1.05); mCorrFit->SetParameter(1, 15.); mCorrFit->SetParLimits(1, 0., 50.); mCorrFit->SetParameter(2, 1.); //mCorrFit->SetParLimits(2, 0.9, 1.1); mCorrFit->SetLineWidth(3); mCorrFit->SetLineColor(kRed); mCorrFit->SetNpx(40); histo->Fit("mCorrFit","MRQE","ep"); mCorrFit->Draw("same"); if(SourceFunc==0) { mRetVect.push_back(mCorrFit->GetParameter(1)*MHC); //0 R mRetVect.push_back(mCorrFit->GetParError(1)*MHC); //1 dR } else if(SourceFunc==1) { mRetVect.push_back(mCorrFit->GetParameter(1)*MHC*INVSQRTPI); //0 R mRetVect.push_back(mCorrFit->GetParError(1)*MHC*INVSQRTPI); //1 dR } mRetVect.push_back(mCorrFit->GetParameter(0)); //2 Lam mRetVect.push_back(mCorrFit->GetParError(0)); //3 dLam mRetVect.push_back(mCorrFit->GetChisquare()/mCorrFit->GetNDF()); //4 chi2/ndf mRetVect.push_back(mCorrFit->GetParameter(2)); //5 Norm mRetVect.push_back(mCorrFit->GetParError(2)); //6 dNorm if(DrawFitLegend) { TLegend* mLegend = new TLegend(0.4,0.5,0.9,0.9); mLegend->SetFillColor(kWhite); mLegend->SetHeader("Fit parameters:"); mLegend->AddEntry("mCorrFit","Bowler-Sinyukov fit","l"); mLegend->AddEntry((TObject*)0, Form( "#chi^{2}/n.d.f. = %4.3f / %2d", mCorrFit->GetChisquare(),mCorrFit->GetNDF() ),""); mLegend->AddEntry((TObject*)0, Form("N = %4.3f \\pm %4.3f", mRetVect.at(5),mRetVect.at(6) ), ""); mLegend->AddEntry((TObject*)0, Form("#lambda = %4.2f \\pm %4.2f", mRetVect.at(2),mRetVect.at(3) ),""); mLegend->AddEntry((TObject*)0, Form("R = %4.2f \\pm %4.2f", mRetVect.at(0),mRetVect.at(1)), ""); mLegend->Draw(); } return mRetVect; }