ProcessMesons3D.C 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. #include "HistoCollector3D.h"
  2. #include "HbtFitter.h"
  3. #include <TCanvas.h>
  4. #include <TLegend.h>
  5. #include <TMath.h>
  6. #include <TROOT.h>
  7. #include <TGraphErrors.h>
  8. #include <vector>
  9. #include <iostream>
  10. #include <fstream>
  11. using namespace std;
  12. int PartType = 4;
  13. int qInvBins = 40;
  14. double qInvLo = 0.;
  15. double qInvHi = 0.4;
  16. int NKtBins = 11;
  17. int SourceFunc = 0; //Gauss
  18. int NonFemtoFunc = 0; //Constant
  19. double FitRangeLo = 0.;
  20. double FitRangeHi = 0.2;
  21. double CoulombSR = 5.;
  22. HbtFitter *DoFit(TH3F* hNum, TH3F* hDen, TH3F* hQinv,
  23. int aPartType=3, int aSourceFunc=0,
  24. int aNonFemtoFunc=0);
  25. void SetTGraphStyle(TGraphErrors *gr, int charge);
  26. void SetProjectionStyle(TH1* h, int proj, Bool_t isFit=false);
  27. //_________________
  28. void ProcessMesons3D(int PID=3, int cent=8, int energy=200) {
  29. double PionMassSqr = 0.019479835;
  30. double KaonMassSqr = 0.24371698;
  31. HistoCollector3D mHistoCollector;
  32. PartType = PID;
  33. int Centrality = cent;
  34. TString inFileName, oFileName, oTxtFileName;
  35. inFileName = "/home/nigmatkulov/work/star/data/bes/cent";
  36. inFileName += cent;
  37. inFileName += "/auau";
  38. oFileName = "oAuAu";
  39. oTxtFileName = "oAuAu";
  40. inFileName += energy;
  41. oFileName += energy;
  42. oTxtFileName += energy;
  43. if(PartType == 3) {
  44. inFileName += "_pions_";
  45. oFileName += "_pions_";
  46. oTxtFileName += "_pions_";
  47. }
  48. else if(PartType == 4) {
  49. inFileName += "_kaons_";
  50. oFileName += "_kaons_";
  51. oTxtFileName += "_kaons_";
  52. }
  53. inFileName += "3d_cent";
  54. oFileName += "3d_cent";
  55. oTxtFileName += "3d_cent";
  56. inFileName += cent;
  57. oFileName += cent;
  58. oTxtFileName += cent;
  59. inFileName += ".root";
  60. oFileName += ".root";
  61. oTxtFileName += ".txt";
  62. //Here... add centralitRoutKtGrErr_0y and make output
  63. //Pions
  64. const char* fname;
  65. if(PartType == 3) {
  66. fname = "auau200_pions_3d_cent8.root";
  67. }
  68. //Kaons
  69. if(PartType == 4) {
  70. fname = "auau200_kaons_3d_cent8.root";
  71. }
  72. mHistoCollector.SetFileName(inFileName.Data());
  73. mHistoCollector.SetQinvBins(qInvBins,qInvLo,qInvHi);
  74. mHistoCollector.SetPartType(PartType);
  75. mHistoCollector.SetKtBins(NKtBins);
  76. mHistoCollector.LoadData();
  77. int nKtSumBins;
  78. if(PartType == 3) {
  79. nKtSumBins = 7;
  80. }
  81. else if(PartType == 4) {
  82. nKtSumBins = 5;
  83. }
  84. //AuAu200 pions
  85. //int FitKtArray[7][2] = {{2,2}, {3,3}, {4,4}, {5,5}, {6,6}, {7,7}, {8,10} };
  86. //AuAu200 kaons
  87. int FitKtArray[5][2] = {{1,3}, {4,5}, {5,6}, {7,8}, {8,10} };
  88. std::vector<TH3F *> hNumer;
  89. std::vector<TH3F *> hDenom;
  90. std::vector<TH3F *> hQinv;
  91. for(int iCharge=0; iCharge<3; iCharge++) {
  92. for(int iKtBin=0; iKtBin<nKtSumBins; iKtBin++) {
  93. TH3F* hA = mHistoCollector.BuildKt3DNum(iCharge,FitKtArray[iKtBin][0],FitKtArray[iKtBin][1]);
  94. TH3F* hB = mHistoCollector.BuildKt3DDen(iCharge,FitKtArray[iKtBin][0],FitKtArray[iKtBin][1]);
  95. TH3F* hC = mHistoCollector.BuildKt3DQinv(iCharge,FitKtArray[iKtBin][0],FitKtArray[iKtBin][1]);
  96. hNumer.push_back(hA);
  97. hDenom.push_back(hB);
  98. hQinv.push_back(hC);
  99. }
  100. }
  101. vector<double> LamVect, RoutVect, RsideVect, RlongVect, Chi2Vect;
  102. vector<double> LamErrVect, RoutErrVect, RsideErrVect, RlongErrVect;
  103. vector<double> retParVect;
  104. //HbtFitter *myFitter = NULL;
  105. double LamArr[nKtSumBins];
  106. double RoutArr[nKtSumBins];
  107. double RsideArr[nKtSumBins];
  108. double RlongArr[nKtSumBins];
  109. double LamErrArr[nKtSumBins];
  110. double RoutErrArr[nKtSumBins];
  111. double RsideErrArr[nKtSumBins];
  112. double RlongErrArr[nKtSumBins];
  113. double RosRatArr[nKtSumBins];
  114. double RosRatErrArr[nKtSumBins];
  115. double RosDiffArr[nKtSumBins];
  116. double RosDiffErrArr[nKtSumBins];
  117. double KtArr[nKtSumBins];
  118. double KtErrArr[nKtSumBins];
  119. double MtArr[nKtSumBins];
  120. double KtShift = 0.1;
  121. double KtStep = 0.1;
  122. double KtLo,KtHi,KtVal,MtVal;
  123. double MassSqr;
  124. if(PartType == 3) {
  125. MassSqr = PionMassSqr;
  126. }
  127. else if(PartType == 4) {
  128. MassSqr = KaonMassSqr;
  129. }
  130. //Kt dependence
  131. TGraphErrors *LamKtGrErr[3];
  132. TGraphErrors *RoutKtGrErr[3];
  133. TGraphErrors *RsideKtGrErr[3];
  134. TGraphErrors *RlongKtGrErr[3];
  135. TGraphErrors *RosRatKtGrErr[3];
  136. TGraphErrors *RosDiffKtGrErr[3];
  137. //Mt dependence
  138. TGraphErrors *LamMtGrErr[3];
  139. TGraphErrors *RoutMtGrErr[3];
  140. TGraphErrors *RsideMtGrErr[3];
  141. TGraphErrors *RlongMtGrErr[3];
  142. TGraphErrors *RosRatMtGrErr[3];
  143. TGraphErrors *RosDiffMtGrErr[3];
  144. vector<TH1F *> hOutProjVect,hSideProjVect,hLongProjVect;
  145. vector<TH1F *> hFitOutProjVect,hFitSideProjVect,hFitLongProjVect;
  146. //For all charges: +, -, sum
  147. for(int iCharge=0; iCharge<3; iCharge++) {
  148. for(int iKtBin=0; iKtBin<nKtSumBins; iKtBin++) {
  149. int iter = iCharge*nKtSumBins + iKtBin;
  150. HbtFitter *myFitter = DoFit(hNumer.at(iter),hDenom.at(iter),hQinv.at(iter),
  151. PartType,SourceFunc,NonFemtoFunc);
  152. TH1F *hExpOutProj = myFitter->Get3DOutProjection();
  153. TH1F *hExpSideProj = myFitter->Get3DSideProjection();
  154. TH1F *hExpLongProj = myFitter->Get3DLongProjection();
  155. TH1F *hFitOutProj = myFitter->Get3DFitOutProjection();
  156. TH1F *hFitSideProj = myFitter->Get3DFitSideProjection();
  157. TH1F *hFitLongProj = myFitter->Get3DFitLongProjection();
  158. hExpOutProj->SetName(Form("hOutProj_%d_%d",iCharge,iKtBin));
  159. hExpSideProj->SetName(Form("hSideProj_%d_%d",iCharge,iKtBin));
  160. hExpLongProj->SetName(Form("hLongProj_%d_%d",iCharge,iKtBin));
  161. hFitOutProj->SetName(Form("hFitOutProj_%d_%d",iCharge,iKtBin));
  162. hFitSideProj->SetName(Form("hFitSideProj_%d_%d",iCharge,iKtBin));
  163. hFitLongProj->SetName(Form("hFitLongProj_%d_%d",iCharge,iKtBin));
  164. hOutProjVect.push_back(hExpOutProj);
  165. hSideProjVect.push_back(hExpSideProj);
  166. hLongProjVect.push_back(hExpLongProj);
  167. hFitOutProjVect.push_back(hFitOutProj);
  168. hFitSideProjVect.push_back(hFitSideProj);
  169. hFitLongProjVect.push_back(hFitLongProj);
  170. //Calculate kT and mT binning
  171. KtLo=KtShift + FitKtArray[iKtBin][0]*KtStep;
  172. KtHi=KtShift + FitKtArray[iKtBin][1]*KtStep + KtStep;
  173. KtVal = (KtHi + KtLo)*0.5;
  174. MtVal = TMath::Sqrt(KtVal*KtVal + MassSqr);
  175. KtArr[iKtBin] = KtVal;
  176. KtErrArr[iKtBin] = 0.01;
  177. MtArr[iKtBin] = MtVal;
  178. //Obtain fit parameters
  179. retParVect.clear();
  180. retParVect = myFitter->GetFemto3DParameters();
  181. Chi2Vect.push_back(myFitter->GetChi2PerNDF());
  182. LamVect.push_back(retParVect.at(0));
  183. RoutVect.push_back(retParVect.at(1));
  184. RsideVect.push_back(retParVect.at(2));
  185. RlongVect.push_back(retParVect.at(3));
  186. /*
  187. ///////// DEBUG ///////////
  188. std::cout << "-------------------------------------------------------------" << std::endl;
  189. std::cout << "Rout: " << RoutVect.back() << " Rside: " << RsideVect.back()
  190. << " Rlong: " << RlongVect.back() << std::endl;
  191. std::cout << "-------------------------------------------------------------" << std::endl;
  192. */
  193. //Obtain fit error parameters
  194. retParVect.clear();
  195. retParVect = myFitter->GetFemto3DParError();
  196. LamErrVect.push_back(retParVect.at(0));
  197. RoutErrVect.push_back(retParVect.at(1));
  198. RsideErrVect.push_back(retParVect.at(2));
  199. RlongErrVect.push_back(retParVect.at(3));
  200. /*
  201. ///////// DEBUG ///////////
  202. std::cout << "-------------------------------------------------------------" << std::endl;
  203. std::cout << "RoutErr: " << RoutErrVect.back() << " RsideErr: " << RsideErrVect.back()
  204. << " RlongErr: " << RlongErrVect.back() << std::endl;
  205. std::cout << "-------------------------------------------------------------" << std::endl;
  206. */
  207. //Parameters for the given charge and each kT bin
  208. LamArr[iKtBin] = LamVect.back();
  209. LamErrArr[iKtBin] = LamErrVect.back();
  210. RoutArr[iKtBin] = RoutVect.back();
  211. RoutErrArr[iKtBin] = RoutErrVect.back();
  212. RsideArr[iKtBin] = RsideVect.back();
  213. RsideErrArr[iKtBin] = RsideErrVect.back();
  214. RlongArr[iKtBin] = RlongVect.back();
  215. RlongErrArr[iKtBin] = RlongErrVect.back();
  216. RosRatArr[iKtBin] = RoutArr[iKtBin]/RsideArr[iKtBin];
  217. RosRatErrArr[iKtBin] = ( (RoutArr[iKtBin] * RsideErrArr[iKtBin] +
  218. RsideArr[iKtBin] * RoutErrArr[iKtBin]) /
  219. (RsideArr[iKtBin] * RsideArr[iKtBin]) );
  220. RosDiffArr[iKtBin] = (RoutArr[iKtBin] * RoutArr[iKtBin] -
  221. RsideArr[iKtBin] * RsideArr[iKtBin]);
  222. RosDiffErrArr[iKtBin] = (2 * RoutArr[iKtBin] * RoutErrArr[iKtBin] -
  223. 2 * RsideArr[iKtBin] * RsideErrArr[iKtBin]);
  224. } //for(int iKtBin=0; iKtBin<nKtSumBins; iKtBin++)
  225. /*
  226. ///////// DEBUG ///////////
  227. std::cout << "Rout array" << std::endl;
  228. for(int iKt=0; iKt<nKtSumBins; iKt++) {
  229. std::cout << RoutArr[iKt] << "\t";
  230. }
  231. std::cout << std::endl;
  232. std::cout << "Rout error array" << std::endl;
  233. for(int iKt=0; iKt<nKtSumBins; iKt++) {
  234. std::cout << RoutErrArr[iKt] << "\t";
  235. }
  236. std::cout << std::endl;
  237. */
  238. //Lambda
  239. LamKtGrErr[iCharge] = new TGraphErrors(nKtSumBins,KtArr,LamArr,KtErrArr,LamErrArr);
  240. LamKtGrErr[iCharge]->SetName(Form("LamKtGrErr_%d",iCharge));
  241. SetTGraphStyle(LamKtGrErr[iCharge], iCharge);
  242. LamKtGrErr[iCharge]->GetXaxis()->SetTitle("k_{T} (GeV/c)");
  243. LamKtGrErr[iCharge]->GetYaxis()->SetTitle("#lambda");
  244. LamMtGrErr[iCharge] = new TGraphErrors(nKtSumBins,MtArr,LamArr,KtErrArr,LamErrArr);
  245. LamMtGrErr[iCharge]->SetName(Form("LamMtGrErr_%d",iCharge));
  246. SetTGraphStyle(LamMtGrErr[iCharge], iCharge);
  247. LamMtGrErr[iCharge]->GetXaxis()->SetTitle("m_{T} (GeV/c^{2})");
  248. LamMtGrErr[iCharge]->GetYaxis()->SetTitle("#lambda");
  249. //Rout
  250. RoutKtGrErr[iCharge] = new TGraphErrors(nKtSumBins,KtArr,RoutArr,KtErrArr,RoutErrArr);
  251. RoutKtGrErr[iCharge]->SetName(Form("RoutKtGrErr_%d",iCharge));
  252. SetTGraphStyle(RoutKtGrErr[iCharge], iCharge);
  253. RoutKtGrErr[iCharge]->GetXaxis()->SetTitle("k_{T} (GeV/c)");
  254. RoutKtGrErr[iCharge]->GetYaxis()->SetTitle("R_{out} (fm)");
  255. RoutMtGrErr[iCharge] = new TGraphErrors(nKtSumBins,MtArr,RoutArr,KtErrArr,RoutErrArr);
  256. RoutMtGrErr[iCharge]->SetName(Form("RoutMtGrErr_%d",iCharge));
  257. SetTGraphStyle(RoutMtGrErr[iCharge], iCharge);
  258. RoutMtGrErr[iCharge]->GetXaxis()->SetTitle("m_{T} (GeV/c^{2})");
  259. RoutMtGrErr[iCharge]->GetYaxis()->SetTitle("R_{out} (fm)");
  260. //Rside
  261. RsideKtGrErr[iCharge] = new TGraphErrors(nKtSumBins,KtArr,RsideArr,KtErrArr,RsideErrArr);
  262. RsideKtGrErr[iCharge]->SetName(Form("RsideKtGrErr_%d",iCharge));
  263. SetTGraphStyle(RsideKtGrErr[iCharge], iCharge);
  264. RsideKtGrErr[iCharge]->GetXaxis()->SetTitle("k_{T} (GeV/c)");
  265. RsideKtGrErr[iCharge]->GetYaxis()->SetTitle("R_{side} (fm)");
  266. RsideMtGrErr[iCharge] = new TGraphErrors(nKtSumBins,MtArr,RsideArr,KtErrArr,RsideErrArr);
  267. RsideMtGrErr[iCharge]->SetName(Form("RsideMtGrErr_%d",iCharge));
  268. SetTGraphStyle(RsideMtGrErr[iCharge], iCharge);
  269. RsideMtGrErr[iCharge]->GetXaxis()->SetTitle("m_{T} (GeV/c^{2})");
  270. RsideMtGrErr[iCharge]->GetYaxis()->SetTitle("R_{side} (fm)");
  271. //Rlong
  272. RlongKtGrErr[iCharge] = new TGraphErrors(nKtSumBins,KtArr,RlongArr,KtErrArr,RlongErrArr);
  273. RlongKtGrErr[iCharge]->SetName(Form("RlongKtGrErr_%d",iCharge));
  274. SetTGraphStyle(RlongKtGrErr[iCharge], iCharge);
  275. RlongKtGrErr[iCharge]->GetXaxis()->SetTitle("k_{T} (GeV/c)");
  276. RlongKtGrErr[iCharge]->GetYaxis()->SetTitle("R_{long} (fm)");
  277. RlongMtGrErr[iCharge] = new TGraphErrors(nKtSumBins,MtArr,RlongArr,KtErrArr,RlongErrArr);
  278. RlongMtGrErr[iCharge]->SetName(Form("RlongMtGrErr_%d",iCharge));
  279. SetTGraphStyle(RlongMtGrErr[iCharge], iCharge);
  280. RlongMtGrErr[iCharge]->GetXaxis()->SetTitle("m_{T} (GeV/c^{2})");
  281. RlongMtGrErr[iCharge]->GetYaxis()->SetTitle("R_{long} (fm)");
  282. //RosRat
  283. RosRatKtGrErr[iCharge] = new TGraphErrors(nKtSumBins,KtArr,RosRatArr,KtErrArr,RosRatErrArr);
  284. RosRatKtGrErr[iCharge]->SetName(Form("RosRatKtGrErr_%d",iCharge));
  285. SetTGraphStyle(RosRatKtGrErr[iCharge], iCharge);
  286. RosRatKtGrErr[iCharge]->GetXaxis()->SetTitle("k_{T} (GeV/c)");
  287. RosRatKtGrErr[iCharge]->GetYaxis()->SetTitle("R_{o}/R_{s}");
  288. RosRatMtGrErr[iCharge] = new TGraphErrors(nKtSumBins,MtArr,RosRatArr,KtErrArr,RosRatErrArr);
  289. RosRatMtGrErr[iCharge]->SetName(Form("RosRatMtGrErr_%d",iCharge));
  290. SetTGraphStyle(RosRatMtGrErr[iCharge], iCharge);
  291. RosRatMtGrErr[iCharge]->GetXaxis()->SetTitle("m_{T} (GeV/c^{2})");
  292. RosRatMtGrErr[iCharge]->GetYaxis()->SetTitle("R_{o}/R_{s}");
  293. //RosDiff
  294. RosDiffKtGrErr[iCharge] = new TGraphErrors(nKtSumBins,KtArr,RosDiffArr,KtErrArr,RosDiffErrArr);
  295. RosDiffKtGrErr[iCharge]->SetName(Form("RosDiffKtGrErr_%d",iCharge));
  296. SetTGraphStyle(RosDiffKtGrErr[iCharge], iCharge);
  297. RosDiffKtGrErr[iCharge]->GetXaxis()->SetTitle("k_{T} (GeV/c)");
  298. RosDiffKtGrErr[iCharge]->GetYaxis()->SetTitle("R_{o}^{2}-R_{s}^{2} (fm)");
  299. RosDiffMtGrErr[iCharge] = new TGraphErrors(nKtSumBins,MtArr,RosDiffArr,KtErrArr,RosDiffErrArr);
  300. RosDiffMtGrErr[iCharge]->SetName(Form("RosDiffMtGrErr_%d",iCharge));
  301. SetTGraphStyle(RosDiffMtGrErr[iCharge], iCharge);
  302. RosDiffMtGrErr[iCharge]->GetXaxis()->SetTitle("m_{T} (GeV/c^{2})");
  303. RosDiffMtGrErr[iCharge]->GetYaxis()->SetTitle("R_{o}^{2}-R_{s}^{2} (fm)");
  304. } //for(unsigned int iCharge=0; iCharge<3; iCharge++)
  305. TFile *oFile = new TFile(oFileName.Data(),"recreate");
  306. for(unsigned int iHisto = 0; iHisto<hOutProjVect.size(); iHisto++) {
  307. SetProjectionStyle(hOutProjVect.at(iHisto),0);
  308. hOutProjVect.at(iHisto)->Write();
  309. SetProjectionStyle(hSideProjVect.at(iHisto),1);
  310. hSideProjVect.at(iHisto)->Write();
  311. SetProjectionStyle(hLongProjVect.at(iHisto),2);
  312. hLongProjVect.at(iHisto)->Write();
  313. SetProjectionStyle(hFitOutProjVect.at(iHisto),0,true);
  314. hFitOutProjVect.at(iHisto)->Write();
  315. SetProjectionStyle(hFitSideProjVect.at(iHisto),1,true);
  316. hFitSideProjVect.at(iHisto)->Write();
  317. SetProjectionStyle(hFitLongProjVect.at(iHisto),2,true);
  318. hFitLongProjVect.at(iHisto)->Write();
  319. }
  320. for(int iCharge=0; iCharge<3; iCharge++) {
  321. LamKtGrErr[iCharge]->Write();
  322. LamMtGrErr[iCharge]->Write();
  323. RoutKtGrErr[iCharge]->Write();
  324. RoutMtGrErr[iCharge]->Write();
  325. RsideKtGrErr[iCharge]->Write();
  326. RsideMtGrErr[iCharge]->Write();
  327. RlongKtGrErr[iCharge]->Write();
  328. RlongMtGrErr[iCharge]->Write();
  329. RosRatKtGrErr[iCharge]->Write();
  330. RosRatMtGrErr[iCharge]->Write();
  331. RosDiffKtGrErr[iCharge]->Write();
  332. RosDiffMtGrErr[iCharge]->Write();
  333. }
  334. ofstream oTxtFile;
  335. oTxtFile.open(oTxtFileName.Data());
  336. oTxtFile << Form("Collision energy: %3i \t Centrality: %1i \t Coulomb R: %2.1f \n",
  337. energy, cent, CoulombSR);
  338. oTxtFile << "-------------------------------\n";
  339. int point;
  340. Double_t x,y,ey;
  341. //Write to file
  342. for(int iCharge=0; iCharge<3; iCharge++) {
  343. switch(iCharge) {
  344. case 0:
  345. oTxtFile << "Positive charge: \n";
  346. break;
  347. case 1:
  348. oTxtFile << "Negative charge: \n";
  349. break;
  350. case 2:
  351. oTxtFile << "Sum of charges: \n";
  352. break;
  353. default:
  354. oTxtFile << "Error in the charge cycle \n";
  355. break;
  356. };
  357. oTxtFile << "-------------------------------\n";
  358. for(int iKtBin=0; iKtBin<nKtSumBins; iKtBin++) {
  359. if(iKtBin==0) {
  360. oTxtFile << "lambda: ";
  361. }
  362. point = LamKtGrErr[iCharge]->GetPoint(iKtBin,x,y);
  363. ey = LamKtGrErr[iCharge]->GetErrorY(iKtBin);
  364. oTxtFile << Form(" %5.4f +- %5.4f ", y, ey);
  365. if(iKtBin == (nKtSumBins-1)) {
  366. oTxtFile << "\n";
  367. }
  368. else {
  369. oTxtFile << " | ";
  370. }
  371. }
  372. for(int iKtBin=0; iKtBin<nKtSumBins; iKtBin++) {
  373. if(iKtBin==0) {
  374. oTxtFile << "Rout : ";
  375. }
  376. point = RoutKtGrErr[iCharge]->GetPoint(iKtBin,x,y);
  377. ey = RoutKtGrErr[iCharge]->GetErrorY(iKtBin);
  378. oTxtFile << Form(" %5.4f +- %5.4f ", y, ey);
  379. if(iKtBin == (nKtSumBins-1)) {
  380. oTxtFile << "\n";
  381. }
  382. else {
  383. oTxtFile << " | ";
  384. }
  385. }
  386. for(int iKtBin=0; iKtBin<nKtSumBins; iKtBin++) {
  387. if(iKtBin==0) {
  388. oTxtFile << "Rside : ";
  389. }
  390. point = RsideKtGrErr[iCharge]->GetPoint(iKtBin,x,y);
  391. ey = RsideKtGrErr[iCharge]->GetErrorY(iKtBin);
  392. oTxtFile << Form(" %5.4f +- %5.4f ", y, ey);
  393. if(iKtBin == (nKtSumBins-1)) {
  394. oTxtFile << "\n";
  395. }
  396. else {
  397. oTxtFile << " | ";
  398. }
  399. }
  400. for(int iKtBin=0; iKtBin<nKtSumBins; iKtBin++) {
  401. if(iKtBin==0) {
  402. oTxtFile << "Rlong : ";
  403. }
  404. point = RlongKtGrErr[iCharge]->GetPoint(iKtBin,x,y);
  405. ey = RlongKtGrErr[iCharge]->GetErrorY(iKtBin);
  406. oTxtFile << Form(" %5.4f +- %5.4f ", y, ey);
  407. if(iKtBin == (nKtSumBins-1)) {
  408. oTxtFile << "\n";
  409. }
  410. else {
  411. oTxtFile << " | ";
  412. }
  413. }
  414. for(int iKtBin=0; iKtBin<nKtSumBins; iKtBin++) {
  415. if(iKtBin==0) {
  416. oTxtFile << "RosRat : ";
  417. }
  418. point = RosRatKtGrErr[iCharge]->GetPoint(iKtBin,x,y);
  419. ey = RosRatKtGrErr[iCharge]->GetErrorY(iKtBin);
  420. oTxtFile << Form(" %5.4f +- %5.4f ", y, ey);
  421. if(iKtBin == (nKtSumBins-1)) {
  422. oTxtFile << "\n";
  423. }
  424. else {
  425. oTxtFile << " | ";
  426. }
  427. }
  428. for(int iKtBin=0; iKtBin<nKtSumBins; iKtBin++) {
  429. if(iKtBin==0) {
  430. oTxtFile << "RosDiff : ";
  431. }
  432. point = RosDiffKtGrErr[iCharge]->GetPoint(iKtBin,x,y);
  433. ey = RosDiffKtGrErr[iCharge]->GetErrorY(iKtBin);
  434. oTxtFile << Form(" %5.4f +- %5.4f ", y, ey);
  435. if(iKtBin == (nKtSumBins-1)) {
  436. oTxtFile << "\n";
  437. }
  438. else {
  439. oTxtFile << " | ";
  440. }
  441. }
  442. oTxtFile << "-------------------------------\n";
  443. } //for(int iCharge=0; iCharge<3; iCharge++)
  444. oTxtFile << "\n";
  445. oTxtFile.close();
  446. oFile->Write();
  447. oFile->Close();
  448. }
  449. //_________________
  450. HbtFitter *DoFit(TH3F* hNum, TH3F* hDen, TH3F* hQinv,
  451. int aPartType, int aSourceFunc, int aNonFemtoFunc) {
  452. HbtFitter *fitter = new HbtFitter(aPartType,aSourceFunc,aNonFemtoFunc,false);
  453. fitter->SetFitMethod(1); //Log-likelihood
  454. fitter->SetCorrectOnMc(false);
  455. fitter->SetProjectionType(false); //Project by vals
  456. fitter->Set3DBinsNum(qInvBins,qInvBins,qInvBins);
  457. fitter->Set3DHistoRange(qInvLo,qInvHi,
  458. qInvLo,qInvHi,
  459. qInvLo,qInvHi);
  460. fitter->UseCoulombCorrection(true); //on/off Coulomb correction
  461. fitter->SetCoulombSourceRadius(CoulombSR);
  462. hQinv->Divide(hDen); //!!!!!! Hey dude, do not forget to divide !!!!!!!
  463. fitter->Set3DNumer(hNum);
  464. fitter->Set3DDenom(hDen);
  465. fitter->Set3DCoulomb(hQinv);
  466. //Set fit range
  467. fitter->Set3DFitRange(FitRangeLo, FitRangeHi,
  468. FitRangeLo, FitRangeHi,
  469. FitRangeLo, FitRangeHi);
  470. fitter->SetInit3DFitParameters(0.3, 3., 3., 3., 0., 0., 0., 0.1,
  471. 0., 0., 0., 0., 0., 0.);
  472. fitter->SetInit3DFitParErrors(0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.001,
  473. 0.1, 0.1, 0.1, 0.1, 0.1, 0.1);
  474. fitter->SetInit3DFitParLimitLo(0.05, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.,
  475. -2., -2., -2., -2., -2., -2.);
  476. fitter->SetInit3DFitParLimitHi(1.05, 10., 10., 10., 10., 10., 10., 10.,
  477. +2., +2., +2., +2., +2., +2.);
  478. //Fix cross-term parameters
  479. fitter->FixFitParameter3D(4); //out-side
  480. fitter->FixFitParameter3D(5); //out-long
  481. fitter->FixFitParameter3D(6); //side-long
  482. //Main magic
  483. fitter->Fit3D();
  484. fitter->MakeProjections();
  485. std::cout << "Chi2: " << fitter->GetChi2() << " NDF: " << fitter->GetNDF()
  486. << " Chi2/NDF: " << fitter->GetChi2PerNDF() << std::endl;
  487. return fitter;
  488. }
  489. //_________________
  490. void SetTGraphStyle(TGraphErrors *gr, int charge) {
  491. Int_t mColor;
  492. Int_t mMarkerStyle;
  493. Double_t mMarkerSize = 1.5;
  494. Int_t mLineWidth = 2;
  495. if(charge == 0) {
  496. mColor = 2; //Red
  497. mLineWidth = 2;
  498. if(PartType == 3) {
  499. mMarkerStyle = 20;
  500. }
  501. else if(PartType == 4) {
  502. mMarkerStyle = 29;
  503. }
  504. }
  505. else if(charge == 1) {
  506. mColor = 4; //Blue
  507. mLineWidth = 2;
  508. if(PartType == 3) {
  509. mMarkerStyle = 20;
  510. }
  511. else if(PartType == 4) {
  512. mMarkerStyle = 29;
  513. }
  514. }
  515. else {
  516. mColor = 1; //Black
  517. mLineWidth = 2;
  518. if(PartType == 3) {
  519. mMarkerStyle = 20;
  520. }
  521. else if(PartType == 4) {
  522. mMarkerStyle = 29;
  523. }
  524. }
  525. gr->SetLineColor(mColor);
  526. gr->SetMarkerColor(mColor);
  527. gr->SetLineWidth(mLineWidth);
  528. gr->SetMarkerStyle(mMarkerStyle);
  529. gr->SetMarkerSize(mMarkerSize);
  530. }
  531. //_________________
  532. void SetProjectionStyle(TH1* h, int proj, Bool_t isFit) {
  533. TString Xstr,Ystr;
  534. if(proj == 0) {
  535. Xstr = "q_{out} (GeV/c)";
  536. Ystr = "C(q_{out})";
  537. }
  538. else if(proj == 1) {
  539. Xstr = "q_{side} (GeV/c)";
  540. Ystr = "C(q_{side})";
  541. }
  542. else if(proj == 2) {
  543. Xstr = "q_{long} (GeV/c)";
  544. Ystr = "C(q_{long})";
  545. }
  546. int color;
  547. if(isFit == false) {
  548. color = 1;
  549. }
  550. else {
  551. color = 2;
  552. }
  553. h->SetLineWidth(2);
  554. h->SetLineColor(color);
  555. h->SetMarkerColor(color);
  556. h->SetAxisRange(0.9, 1.6,"Y");
  557. h->SetAxisRange(FitRangeLo,FitRangeHi,"X");
  558. h->GetXaxis()->SetTitle(Xstr.Data());
  559. h->GetYaxis()->SetTitle(Ystr.Data());
  560. h->SetNdivisions(505,"X");
  561. h->SetNdivisions(505,"Y");
  562. }