calculateCumulant.C 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831
  1. #include "float.h"
  2. #include "calculateCumulant.h"
  3. void calculateCumulant(const char* histFileName){
  4. // gSystem->Load("myProjectProfile_C.so"); //user defined integration
  5. double r0Sq=r0*r0;
  6. double perCent=0.01;
  7. TString xLabel = "Pseudorapidity";
  8. if (isPidFlow) { xLabel = "Rapidity"; }
  9. TFile* f = new TFile(histFileName,"UPDATE");
  10. struct histFullHars {
  11. TProfile2D** mHistCumul2D;
  12. TProfile** mHistCumulEta;
  13. TProfile** mHistCumulPt;
  14. TProfile2D* mHistCumulMix2D;
  15. TProfile* mHistCumulMixEta;
  16. TProfile* mHistCumulMixPt;
  17. TH2D** mHist_v2D;
  18. TH1D** mHist_vEta;
  19. TH1D** mHist_vPt;
  20. TH2D* mHistMix_v2D;
  21. TH1D* mHistMix_vEta;
  22. TH1D* mHistMix_vPt;
  23. Double_t mCumulIntegG0[nCumulIntegOrders*nCumulInteg_qMax];
  24. TH1D* mHistMultSum; //histo for holding mMultSum.
  25. TH1D* mHistNEvent;
  26. TH1D* mHistMeanWgtSqrSum; // sum <w^2> over evts.
  27. Double_t mCumulIntegG0Mix[nCumulMixHar_pMax*nCumulMixHar_qMax];
  28. TH1D** mHistCumulIntegG0Sum; //summation of G value.
  29. TH1D** mHistCumulIntegG0MixSum; //summation of G value.
  30. };
  31. struct histFulls {
  32. TProfile** mHistCumul; //integrated cumulant from differential
  33. TH1D** mHist_v; //integrated flow from differential
  34. TProfile* mHistCumulMix; //cumulant for mix 1st and 2nd hars.
  35. TH1D* mHistMix_v; //integrated flow from differential
  36. struct histFullHars histFullHar[nHars];
  37. };
  38. struct histFulls histFull[nSels];
  39. TString* histTitle;
  40. TString* histTitle2;
  41. //================ fill in pointers ===================
  42. //for each selection
  43. for (int k = 0; k < nSels; k++) {
  44. char countSels[2];
  45. sprintf(countSels,"%d",k+1);
  46. histFull[k].mHistCumul = new TProfile*[nCumulDiffOrders];
  47. histFull[k].mHist_v = new TH1D*[nCumulDiffOrders];
  48. for (int ord = 0; ord < nCumulDiffOrders; ord++) {
  49. char theCumulOrderChar[2]; // if >10, need to use char*
  50. sprintf(theCumulOrderChar,"%d",(ord+1)*2);
  51. histTitle = new TString("Flow_Cumul_Order");
  52. histTitle->Append(*theCumulOrderChar);
  53. histTitle->Append("_Sel");
  54. histTitle->Append(*countSels);
  55. histFull[k].mHistCumul[ord] = (TProfile *)f->Get(histTitle->Data());
  56. delete histTitle;
  57. histTitle = new TString("Flow_Cumul_v_Order");
  58. histTitle->Append(*theCumulOrderChar);
  59. histTitle->Append("_Sel");
  60. histTitle->Append(*countSels);
  61. histFull[k].mHist_v[ord] =
  62. new TH1D(*(histFull[k].mHistCumul[ord]->ProjectionX(histTitle->Data(),"e")));
  63. histFull[k].mHist_v[ord]->SetTitle(histTitle->Data());
  64. histFull[k].mHist_v[ord]->SetXTitle("harmonic");
  65. histFull[k].mHist_v[ord]->SetYTitle("v (%)");
  66. if (ord>0) histFull[k].mHist_v[ord]->Scale(1./profScale);
  67. delete histTitle;
  68. }
  69. ///////////// mixed harmonic
  70. histTitle = new TString("Flow_CumulMix");
  71. histTitle->Append("_Sel");
  72. histTitle->Append(*countSels);
  73. histFull[k].mHistCumulMix = (TProfile *)f->Get(histTitle->Data());
  74. delete histTitle;
  75. histTitle = new TString("Flow_CumulMix_v_Sel");
  76. histTitle->Append(*countSels);
  77. histFull[k].mHistMix_v =
  78. new TH1D(*(histFull[k].mHistCumulMix->ProjectionX(histTitle->Data(),"e")));
  79. histFull[k].mHistMix_v->SetTitle(histTitle->Data());
  80. histFull[k].mHistMix_v->SetXTitle("place for v1 from mixed harmonic");
  81. histFull[k].mHistMix_v->SetYTitle("v (%)");
  82. histFull[k].mHistMix_v->Scale(1./profScale);
  83. delete histTitle;
  84. ///////////////
  85. // for each harmonic
  86. for (int j = 0; j < nHars; j++) {
  87. char countHars[2];
  88. sprintf(countHars,"%d",j+1);
  89. histFull[k].histFullHar[j].mHistCumul2D =
  90. new TProfile2D*[nCumulDiffOrders];
  91. histFull[k].histFullHar[j].mHistCumulEta =
  92. new TProfile*[nCumulDiffOrders];
  93. histFull[k].histFullHar[j].mHistCumulPt =
  94. new TProfile*[nCumulDiffOrders];
  95. histFull[k].histFullHar[j].mHist_v2D =
  96. new TH2D*[nCumulDiffOrders];
  97. histFull[k].histFullHar[j].mHist_vEta =
  98. new TH1D*[nCumulDiffOrders];
  99. histFull[k].histFullHar[j].mHist_vPt =
  100. new TH1D*[nCumulDiffOrders];
  101. ///////////mixed har
  102. if (j==0){ //only j==0 makes sense here.
  103. histTitle = new TString("Flow_CumulMix2D");
  104. histTitle->Append("_Sel");
  105. histTitle->Append(*countSels);
  106. histTitle->Append("_Har");
  107. histTitle->Append(*countHars);
  108. histFull[k].histFullHar[j].mHistCumulMix2D =
  109. (TProfile2D *)f->Get(histTitle->Data());
  110. delete histTitle;
  111. histTitle = new TString("Flow_CumulMixEta");
  112. histTitle->Append("_Sel");
  113. histTitle->Append(*countSels);
  114. histTitle->Append("_Har");
  115. histTitle->Append(*countHars);
  116. histFull[k].histFullHar[j].mHistCumulMixEta =
  117. (TProfile *)f->Get(histTitle->Data());
  118. delete histTitle;
  119. histTitle = new TString("Flow_CumulMixPt");
  120. histTitle->Append("_Sel");
  121. histTitle->Append(*countSels);
  122. histTitle->Append("_Har");
  123. histTitle->Append(*countHars);
  124. histFull[k].histFullHar[j].mHistCumulMixPt =
  125. (TProfile *)f->Get(histTitle->Data());
  126. delete histTitle;
  127. histFull[k].histFullHar[j].mHistCumulIntegG0MixSum =
  128. new TH1D*[nCumulMixHar_pMax*nCumulMixHar_qMax];
  129. for (int pq = 0; pq < nCumulMixHar_pMax*nCumulMixHar_qMax ; pq++) {
  130. int pIndex = (pq/nCumulMixHar_qMax);
  131. int qIndex = pq%nCumulMixHar_qMax;
  132. char pIndexChar[2];
  133. char qIndexChar[2]; // if >10, need to use char*
  134. sprintf(pIndexChar,"%d",pIndex);
  135. sprintf(qIndexChar,"%d",qIndex);
  136. histTitle = new TString("Flow_CumulIntegG0MixSum");
  137. histTitle->Append("_GenFunIdxp");
  138. histTitle->Append(*pIndexChar);
  139. histTitle->Append("_GenFunIdxq");
  140. histTitle->Append(*qIndexChar);
  141. histTitle->Append("_Sel");
  142. histTitle->Append(*countSels);
  143. histTitle->Append("_Har");
  144. histTitle->Append(*countHars);
  145. histFull[k].histFullHar[j].mHistCumulIntegG0MixSum[pq]=
  146. (TH1D *)f->Get(histTitle->Data());
  147. delete histTitle;
  148. histFull[k].histFullHar[j].mCumulIntegG0Mix[pq] = 0.;
  149. }
  150. }
  151. ////////////////
  152. // For each cumulant order
  153. for (int ord = 0; ord < nCumulDiffOrders; ord++) {
  154. char theCumulOrderChar[2]; // if >10, need to use char*
  155. sprintf(theCumulOrderChar,"%d",(ord+1)*2);
  156. histTitle = new TString("Flow_Cumul2D_Order");
  157. histTitle->Append(*theCumulOrderChar);
  158. histTitle->Append("_Sel");
  159. histTitle->Append(*countSels);
  160. histTitle->Append("_Har");
  161. histTitle->Append(*countHars);
  162. histFull[k].histFullHar[j].mHistCumul2D[ord] =
  163. (TProfile2D *)f->Get(histTitle->Data());
  164. delete histTitle;
  165. histTitle = new TString("Flow_CumulEta_Order");
  166. histTitle->Append(*theCumulOrderChar);
  167. histTitle->Append("_Sel");
  168. histTitle->Append(*countSels);
  169. histTitle->Append("_Har");
  170. histTitle->Append(*countHars);
  171. histFull[k].histFullHar[j].mHistCumulEta[ord]=
  172. (TProfile *)f->Get(histTitle->Data());
  173. delete histTitle;
  174. histTitle = new TString("Flow_CumulPt_Order");
  175. histTitle->Append(*theCumulOrderChar);
  176. histTitle->Append("_Sel");
  177. histTitle->Append(*countSels);
  178. histTitle->Append("_Har");
  179. histTitle->Append(*countHars);
  180. histFull[k].histFullHar[j].mHistCumulPt[ord] =
  181. (TProfile *)f->Get(histTitle->Data());
  182. delete histTitle;
  183. }
  184. histFull[k].histFullHar[j].mHistCumulIntegG0Sum =
  185. new TH1D*[nCumulIntegOrders*nCumulInteg_qMax];
  186. for (int pq = 0; pq < nCumulIntegOrders*nCumulInteg_qMax; pq++) {
  187. int cumulIndex = (pq/nCumulInteg_qMax) + 1; // like 1,2,3.
  188. //not begining with 0. That is "p" in Eq. (B1, PG5).
  189. int qIndex = pq%(nCumulInteg_qMax); // like 0,1,..qMax-1
  190. //begining with 0. Just like Eq. (B3, PG5).
  191. char theCumulOrderChar[2];
  192. char qIndexOrderChar[2]; // if >10, need to use char*
  193. sprintf(theCumulOrderChar,"%d",cumulIndex*2);
  194. sprintf(qIndexOrderChar,"%d",qIndex);
  195. histTitle = new TString("Flow_CumulIntegG0Sum_Order");
  196. histTitle->Append(*theCumulOrderChar);
  197. histTitle->Append("_GenFunIdx");
  198. histTitle->Append(*qIndexOrderChar);
  199. histTitle->Append("_Sel");
  200. histTitle->Append(*countSels);
  201. histTitle->Append("_Har");
  202. histTitle->Append(*countHars);
  203. histFull[k].histFullHar[j].mHistCumulIntegG0Sum[pq] =
  204. (TH1D *)f->Get(histTitle->Data());
  205. delete histTitle;
  206. histFull[k].histFullHar[j].mCumulIntegG0[pq] = 0.;
  207. }
  208. histTitle = new TString("Flow_CumulMultSum_Sel");
  209. histTitle->Append(*countSels);
  210. histTitle->Append("_Har");
  211. histTitle->Append(*countHars);
  212. histFull[k].histFullHar[j].mHistMultSum =
  213. (TH1D *)f->Get(histTitle->Data());
  214. delete histTitle;
  215. histTitle = new TString("Flow_CumulNEvent_Sel");
  216. histTitle->Append(*countSels);
  217. histTitle->Append("_Har");
  218. histTitle->Append(*countHars);
  219. histFull[k].histFullHar[j].mHistNEvent =
  220. (TH1D *)f->Get(histTitle->Data());
  221. delete histTitle;
  222. histTitle = new TString("Flow_CumulMeanWgtSqrSum_Sel");
  223. histTitle->Append(*countSels);
  224. histTitle->Append("_Har");
  225. histTitle->Append(*countHars);
  226. histFull[k].histFullHar[j].mHistMeanWgtSqrSum =
  227. (TH1D *)f->Get(histTitle->Data());
  228. delete histTitle;
  229. }
  230. }
  231. //================ end of fill in pointers ===================
  232. for (int k = 0; k < nSels; k++) {
  233. char countSels[2];
  234. sprintf(countSels,"%d",k+1);
  235. double meanIntegV[nHars]; // V**1
  236. double meanIntegV2[nHars]; // V**2
  237. double meanIntegV3[nHars]; // V**3
  238. double meanIntegV4[nHars]; // V**4
  239. double cumulInteg1[nHars]; // outside of harmonic loop
  240. double cumulInteg2[nHars];
  241. double cumulInteg3[nHars];
  242. double q2[nHars]; // for old method. <Q>**2 in (74) of old paper.
  243. double q4[nHars];
  244. double q6[nHars];
  245. double cumulIntegMix[nHars];
  246. double meanIntegVMix[nHars];
  247. for (int j = 0; j < nHars; j++) {
  248. meanIntegV[j] = 0.;
  249. meanIntegV2[j] = 0.;
  250. meanIntegV3[j] = 0.;
  251. meanIntegV4[j] = 0.;
  252. cumulInteg1[j] = 0.;
  253. cumulInteg2[j] = 0.;
  254. cumulInteg3[j] = 0.;
  255. cumulIntegMix[j] = 0.;
  256. meanIntegVMix[j] = 0.;
  257. }
  258. for (int j = 0; j < nHars; j++) {
  259. char countHars[2];
  260. sprintf(countHars,"%d",j+1);
  261. cout<<" ========== Sel"<<k+1<<" Har"<<j+1<<" ==========="<<endl;
  262. cout<<" event # "<<histFull[k].histFullHar[j].mHistNEvent->GetBinContent(1)<<endl;
  263. double mAvMult =
  264. histFull[k].histFullHar[j].mHistMultSum->GetBinContent(1)/
  265. histFull[k].histFullHar[j].mHistNEvent->GetBinContent(1);
  266. cout<<"mAvMult Sel"<<k<<" har"<<j<<" "<<mAvMult<<endl;
  267. double CpInteg[nCumulIntegOrders]; // Cp in (B4, PG6)
  268. for (int pq = 0; pq < nCumulIntegOrders; pq ++) CpInteg[pq] = 0.;
  269. for (int pq = 0; pq < nCumulIntegOrders*nCumulInteg_qMax; pq++) {
  270. int theCumulOrder = (pq/nCumulInteg_qMax) + 1; // like 1,2,3.
  271. histFull[k].histFullHar[j].mCumulIntegG0[pq] =
  272. histFull[k].histFullHar[j].mHistCumulIntegG0Sum[pq]->GetBinContent(1)/
  273. histFull[k].histFullHar[j].mHistNEvent->GetBinContent(1);
  274. // cout<<" --- histFull[k].histFullHar[j].mCumulIntegG0[pq] "<<histFull[k].histFullHar[j].mCumulIntegG0[pq]<<endl;
  275. if (!isNewMethod){
  276. CpInteg[theCumulOrder-1] +=
  277. (log(histFull[k].histFullHar[j].mCumulIntegG0[pq]) /
  278. ((float)nCumulInteg_qMax));
  279. } else {
  280. CpInteg[theCumulOrder-1] +=
  281. (mAvMult*(pow(histFull[k].histFullHar[j].mCumulIntegG0[pq], 1./mAvMult) -1.) /
  282. float(nCumulInteg_qMax)); // (B3, PG6)
  283. // cout<<" CpInteg[theCumulOrder-1] "<<CpInteg[theCumulOrder-1]<<endl;
  284. }
  285. }
  286. cumulInteg1[j] = // (B5, PG7)
  287. (3.*CpInteg[1-1] - (3./2.)*CpInteg[2-1] + (1./3.)*CpInteg[3-1]) / r0Sq;
  288. cumulInteg2[j] = ((-10.*CpInteg[1-1]) + (8.*CpInteg[2-1]) -
  289. (2.*CpInteg[3-1])) / (r0Sq*r0Sq);
  290. cumulInteg3[j] = ( (18.*CpInteg[1-1]) - (18.*CpInteg[2-1]) + (6.*CpInteg[3-1]))
  291. / (r0Sq*r0Sq*r0Sq);
  292. for (int ord = 0; ord < nCumulDiffOrders; ord++) {
  293. char theCumulOrderChar[2]; // if >10, need to use char*
  294. sprintf(theCumulOrderChar,"%d",(ord+1)*2);
  295. histTitle = new TString("Flow_Cumul_vEta_Order");
  296. histTitle->Append(*theCumulOrderChar);
  297. histTitle->Append("_Sel");
  298. histTitle->Append(*countSels);
  299. histTitle->Append("_Har");
  300. histTitle->Append(*countHars);
  301. histFull[k].histFullHar[j].mHist_vEta[ord] =
  302. new TH1D(*(histFull[k].histFullHar[j].mHistCumulEta[ord]->
  303. ProjectionX(histTitle->Data(),"e")));
  304. histFull[k].histFullHar[j].mHist_vEta[ord]->SetTitle(histTitle->Data());
  305. histFull[k].histFullHar[j].mHist_vEta[ord]->SetXTitle((char*)xLabel.Data());
  306. histFull[k].histFullHar[j].mHist_vEta[ord]->SetYTitle("v (%)");
  307. if (ord>0) histFull[k].histFullHar[j].mHist_vEta[ord]->Scale(1./profScale);
  308. delete histTitle;
  309. histTitle = new TString("Flow_Cumul_vPt_Order");
  310. histTitle->Append(*theCumulOrderChar);
  311. histTitle->Append("_Sel");
  312. histTitle->Append(*countSels);
  313. histTitle->Append("_Har");
  314. histTitle->Append(*countHars);
  315. // if you want integrate for only TPC/FTPC, you need to do
  316. // 1. load myProjectProfile.C at the begining
  317. // 2. append "_TPC" or "_FTPC" here to the title
  318. // 3. use myProjectionY (X) to get mHist_vPt or mHist_vEta.
  319. // histTitle->Append("_TPC");
  320. histTitle2 = new TString("Flow_Cumul2D_Order");
  321. histTitle2->Append(*theCumulOrderChar);
  322. histTitle2->Append("_Sel");
  323. histTitle2->Append(*countSels);
  324. histTitle2->Append("_Har");
  325. histTitle2->Append(*countHars);
  326. histFull[k].histFullHar[j].mHist_vPt[ord] =
  327. //uncomment this line if you want to integrate over different range
  328. //myProjectionY((TProfile2D *)f->Get(histTitle2->Data()) , 0., 1., 1, ((j==0 || j== 2) ? 1 : 0) );
  329. new TH1D(*(histFull[k].histFullHar[j].mHistCumulPt[ord]->ProjectionX(histTitle->Data(),"e")));
  330. histFull[k].histFullHar[j].mHist_vPt[ord]->SetTitle(histTitle->Data());
  331. histFull[k].histFullHar[j].mHist_vPt[ord]->SetName(histTitle->Data());
  332. histFull[k].histFullHar[j].mHist_vPt[ord]->SetXTitle("Pt (GeV)");
  333. histFull[k].histFullHar[j].mHist_vPt[ord]->SetYTitle("v (%)");
  334. if (ord>0) histFull[k].histFullHar[j].mHist_vPt[ord]->Scale(1./profScale);
  335. delete histTitle;
  336. delete histTitle2;
  337. //do not reverse the order of getting v2D and vPt !!
  338. histTitle = new TString("Flow_Cumul_v2D_Order");
  339. histTitle->Append(*theCumulOrderChar);
  340. histTitle->Append("_Sel");
  341. histTitle->Append(*countSels);
  342. histTitle->Append("_Har");
  343. histTitle->Append(*countHars);
  344. histFull[k].histFullHar[j].mHist_v2D[ord] =
  345. new TH2D(*(histFull[k].histFullHar[j].mHistCumul2D[ord]->
  346. ProjectionXY(histTitle->Data(),"e")));
  347. histFull[k].histFullHar[j].mHist_v2D[ord]->SetTitle(histTitle->Data());
  348. histFull[k].histFullHar[j].mHist_v2D[ord]->SetXTitle((char*)xLabel.Data());
  349. histFull[k].histFullHar[j].mHist_v2D[ord]->SetYTitle("Pt (GeV)");
  350. histFull[k].histFullHar[j].mHist_v2D[ord]->SetZTitle("v (%)");
  351. if (ord>0) histFull[k].histFullHar[j].mHist_v2D[ord]->Scale(1./profScale);
  352. delete histTitle;
  353. }
  354. //In the case if cumulant fails, let <V> etc. to be 1. to avoid crash.
  355. meanIntegV[j] = (cumulInteg1[j]>0.) ? sqrt(cumulInteg1[j]) : 1.; // <v> 2-part, m=1
  356. meanIntegV2[j] = (cumulInteg1[j]>0.) ? cumulInteg1[j] : 1.; // <v**2> 2-part, m=2
  357. meanIntegV3[j] = (cumulInteg2[j]<0.) ? pow(-1.*cumulInteg2[j], 3./4.) : 1.; // <v**3> 4-part, m=1
  358. meanIntegV4[j] = (cumulInteg2[j]<0.) ? -1.*cumulInteg2[j] : 1.; // <v**4> 4-part, m=2
  359. if (m_M==1) { // Eq. (PG14)
  360. histFull[k].histFullHar[j].mHist_v2D[0]->Scale(1./(meanIntegV[j]*perCent)); // (34a)
  361. histFull[k].histFullHar[j].mHist_v2D[1]->Scale(-1./(meanIntegV3[j]*perCent));// (34b)
  362. histFull[k].histFullHar[j].mHist_vEta[0]->Scale(1./(meanIntegV[j]*perCent)); // (34a)
  363. histFull[k].histFullHar[j].mHist_vEta[1]->Scale(-1./(meanIntegV3[j]*perCent)); // (34b)
  364. histFull[k].histFullHar[j].mHist_vPt[0]->Scale(1./(meanIntegV[j]*perCent)); // (34a)
  365. histFull[k].histFullHar[j].mHist_vPt[1]->Scale(-1./(meanIntegV3[j]*perCent)); // (34b)
  366. } else if (m_M==2) {
  367. histFull[k].histFullHar[j].mHist_v2D[0]->Scale(1./(meanIntegV2[j]*perCent)); // (35a)
  368. histFull[k].histFullHar[j].mHist_v2D[1]->Scale(-0.5/(meanIntegV4[j]*perCent)); // (35b)
  369. histFull[k].histFullHar[j].mHist_vEta[0]->Scale(1./(meanIntegV2[j]*perCent)); // (35a)
  370. histFull[k].histFullHar[j].mHist_vEta[1]->Scale(-0.5/(meanIntegV4[j]*perCent) ); // (35b)
  371. histFull[k].histFullHar[j].mHist_vPt[0]->Scale(1./(meanIntegV2[j]*perCent)); // (35a)
  372. histFull[k].histFullHar[j].mHist_vPt[1]->Scale(-0.5/(meanIntegV4[j]*perCent)); // (35b)
  373. }
  374. if (cumulInteg1[j]<0.) {
  375. cout<<" Sel"<<k+1<<", <V**2> less than zero ! v"<<j+1<<" from 2 particle correlation failed."<<endl;
  376. histFull[k].histFullHar[j].mHist_v2D[0]->Reset();
  377. histFull[k].histFullHar[j].mHist_vEta[0]->Reset();
  378. histFull[k].histFullHar[j].mHist_vPt[0]->Reset();
  379. }
  380. if (-1.*cumulInteg2[j]<0.) {
  381. cout<<" Sel"<<k+1<<", <V**4> less than zero ! v"<<j+1<<" from 4 particle correlation failed."<<endl;
  382. histFull[k].histFullHar[j].mHist_v2D[1]->Reset();
  383. histFull[k].histFullHar[j].mHist_vEta[1]->Reset();
  384. histFull[k].histFullHar[j].mHist_vPt[1]->Reset();
  385. }
  386. }// end of for (int j = 0; j < nHars; j++)
  387. ///////////// v1{3} calculation. mixed harmonics.
  388. for (int j = 0; j < nHars; j++) {
  389. if (j != 0) continue; //only j==0 makes sense for mixed har.
  390. char countHars[2];
  391. sprintf(countHars,"%d",j+1);
  392. cout<<" ========== Sel"<<k+1<<" Har"<<j+1<<" ===== v1{3} ======"<<endl;
  393. double mAvMult =
  394. histFull[k].histFullHar[j].mHistMultSum->GetBinContent(1)/
  395. histFull[k].histFullHar[j].mHistNEvent->GetBinContent(1);
  396. // cout<<" mAveMult "<<mAvMult<<endl;
  397. double mAveMeanWgtSqr = // <w**2>
  398. histFull[k].histFullHar[j].mHistMeanWgtSqrSum->GetBinContent(1)/
  399. histFull[k].histFullHar[j].mHistNEvent->GetBinContent(1);
  400. cout<<" histFull[k].histFullHar[j].mHistMeanWgtSqrSum->GetBinContent(1) "<<histFull[k].histFullHar[j].mHistMeanWgtSqrSum->GetBinContent(1)<<endl;
  401. cout<<" histFull[k].histFullHar[j].mHistNEvent->GetBinContent(1) "<<histFull[k].histFullHar[j].mHistNEvent->GetBinContent(1)<<endl;
  402. double CpqMix[nCumulMixHar_pMax][nCumulMixHar_qMax];//(30)
  403. for (int pq = 0; pq < nCumulMixHar_pMax*nCumulMixHar_qMax; pq++) {
  404. int pIndex = pq/nCumulMixHar_qMax;
  405. int qIndex = pq%nCumulMixHar_qMax;
  406. histFull[k].histFullHar[j].mCumulIntegG0Mix[pq] =
  407. histFull[k].histFullHar[j].mHistCumulIntegG0MixSum[pq]->GetBinContent(1)/
  408. histFull[k].histFullHar[j].mHistNEvent->GetBinContent(1);
  409. CpqMix[pIndex][qIndex]=mAvMult*(pow(histFull[k].histFullHar[j].mCumulIntegG0Mix[pq], 1./mAvMult) -1.);
  410. }
  411. double CpxMix[nCumulMixHar_pMax];
  412. double CpyMix[nCumulMixHar_pMax];
  413. for (int p =0; p<nCumulMixHar_pMax; p++){
  414. CpxMix[p] = (1./(4.*r0Mix))*(CpqMix[p][0] - CpqMix[p][2]);
  415. CpyMix[p] = (1./(4.*r0Mix))*(CpqMix[p][3] - CpqMix[p][1]);
  416. }
  417. cumulIntegMix[j] = (1./(4.*r0Mix*r0Mix))*(
  418. CpxMix[0]-CpyMix[1]-CpxMix[2]+CpyMix[3]
  419. +CpxMix[4]-CpyMix[5]-CpxMix[6]+CpyMix[7]);
  420. //use v2{4}
  421. double tempMeanV = pow(-1.*cumulInteg2[1]*mAveMeanWgtSqr*mAveMeanWgtSqr,1./4.); // <wgt*v2>
  422. //use v2{2}
  423. // double tempMeanV = pow(cumulInteg1[1]*mAveMeanWgtSqr,1./2.); // <wgt*v2>
  424. cout<<"mAveMeanWgtSqr "<<mAveMeanWgtSqr<<endl;
  425. cout<<" cmumulInteg2[1] "<<cumulInteg2[1]<<endl;
  426. cout<<" tempMeanV "<<tempMeanV<<endl;
  427. double tempMeanVMixSq = cumulIntegMix[j]/tempMeanV; //(24)
  428. /////////// following block is for calculating delta c{3} 's square
  429. /////////// see Eq. 35.
  430. // double chi1 = sqrt(tempMeanVMixSq)*sqrt(mAvMult); //(36)
  431. // double chi2 = tempMeanV*sqrt(mAvMult);
  432. // double deltaC3Sqr = (2. + 4.*chi1*chi1 + 2.*chi2*chi2 + 4.*chi1*chi1*chi2*chi2+chi1*chi1*chi1*chi1)/(2.*mAvMult*mAvMult*mAvMult*(histFull[k].histFullHar[j].mHistNEvent->GetBinContent(1)));
  433. //
  434. // cout<<" C3 is "<<cumulIntegMix[j]<<endl;
  435. // cout<<" delta C3 square is "<<deltaC3Sqr<<endl;
  436. /////////////////////////////////////////////////////////////
  437. histTitle = new TString("Flow_CumulMix_v2D_Sel");
  438. histTitle->Append(*countSels);
  439. histTitle->Append("_Har");
  440. histTitle->Append(*countHars);
  441. histFull[k].histFullHar[j].mHistMix_v2D =
  442. new TH2D(*(histFull[k].histFullHar[j].mHistCumulMix2D->
  443. ProjectionXY(histTitle->Data(),"e")));
  444. histFull[k].histFullHar[j].mHistMix_v2D->SetTitle(histTitle->Data());
  445. histFull[k].histFullHar[j].mHistMix_v2D->SetXTitle((char*)xLabel.Data());
  446. histFull[k].histFullHar[j].mHistMix_v2D->SetYTitle("Pt (GeV)");
  447. histFull[k].histFullHar[j].mHistMix_v2D->SetZTitle("v (%)");
  448. histFull[k].histFullHar[j].mHistMix_v2D->Scale(1./profScale);
  449. delete histTitle;
  450. histTitle = new TString("Flow_CumulMix_vEta_Sel");
  451. histTitle->Append(*countSels);
  452. histTitle->Append("_Har");
  453. histTitle->Append(*countHars);
  454. histFull[k].histFullHar[j].mHistMix_vEta =
  455. new TH1D(*(histFull[k].histFullHar[j].mHistCumulMixEta->
  456. ProjectionX(histTitle->Data(),"e")));
  457. histFull[k].histFullHar[j].mHistMix_vEta->SetTitle(histTitle->Data());
  458. histFull[k].histFullHar[j].mHistMix_vEta->SetXTitle((char*)xLabel.Data());
  459. histFull[k].histFullHar[j].mHistMix_vEta->SetYTitle("v (%)");
  460. histFull[k].histFullHar[j].mHistMix_vEta->Scale(1./profScale);
  461. delete histTitle;
  462. histTitle = new TString("Flow_CumulMix_vPt_Sel");
  463. histTitle->Append(*countSels);
  464. histTitle->Append("_Har");
  465. histTitle->Append(*countHars);
  466. // histTitle->Append("_TPC");
  467. histTitle2 = new TString("Flow_CumulMix2D_Sel");
  468. histTitle2->Append(*countSels);
  469. histTitle2->Append("_Har");
  470. histTitle2->Append(*countHars);
  471. histFull[k].histFullHar[j].mHistMix_vPt =
  472. //myProjectionY((TProfile2D *)f->Get(histTitle2->Data()) , 0., 1. , 1, ((j==0)?1:0) );
  473. new TH1D(*(histFull[k].histFullHar[j].mHistCumulMixPt->ProjectionX(histTitle->Data(),"e")));
  474. histFull[k].histFullHar[j].mHistMix_vPt->SetTitle(histTitle->Data());
  475. histFull[k].histFullHar[j].mHistMix_vPt->SetXTitle("Pt (GeV)");
  476. histFull[k].histFullHar[j].mHistMix_vPt->SetYTitle("v (%)");
  477. histFull[k].histFullHar[j].mHistMix_vPt->Scale(1./profScale);
  478. delete histTitle;
  479. delete histTitle2;
  480. if (tempMeanVMixSq>0.){
  481. meanIntegVMix[j] = sqrt(tempMeanVMixSq);//(24) <w1v1>
  482. histFull[k].histFullHar[j].mHistMix_v2D->Scale(1./(tempMeanV*meanIntegVMix[j]*perCent));
  483. histFull[k].histFullHar[j].mHistMix_vEta->Scale(1./(tempMeanV*meanIntegVMix[j]*perCent));
  484. histFull[k].histFullHar[j].mHistMix_vPt->Scale(1./(tempMeanV*meanIntegVMix[j]*perCent));
  485. histFull[k].mHistMix_v->Scale(1./(tempMeanV*meanIntegVMix[j]*perCent));
  486. } else {
  487. histFull[k].histFullHar[j].mHistMix_v2D->Reset();
  488. histFull[k].histFullHar[j].mHistMix_vEta->Reset();
  489. histFull[k].histFullHar[j].mHistMix_vPt->Reset();
  490. histFull[k].mHistMix_v->Reset();
  491. cout<<"### <wgt*v1>**2 = "<<tempMeanVMixSq<<" < 0. 3-part mixed har ana. failed "<<endl;
  492. }
  493. } //end of Har loop for Mixed har.
  494. if (m_M==1) {
  495. TH1D* histOfMeanIntegV = new TH1D(*(histFull[k].mHist_v[0]));
  496. histOfMeanIntegV->Reset();
  497. TH1D* histOfMeanIntegV3 = new TH1D(*(histFull[k].mHist_v[1]));
  498. histOfMeanIntegV3->Reset();
  499. for (int j = 1; j < nHars+1; j++) {
  500. histOfMeanIntegV->SetBinContent(j, 1./(meanIntegV[j-1]*perCent));
  501. histOfMeanIntegV->SetBinError(j,0.);
  502. histOfMeanIntegV3->SetBinContent(j, -1./(meanIntegV3[j-1]*perCent));
  503. histOfMeanIntegV3->SetBinError(j,0.);
  504. }
  505. histFull[k].mHist_v[0]->Multiply(histOfMeanIntegV);
  506. histFull[k].mHist_v[1]->Multiply(histOfMeanIntegV3);
  507. //force to be zero if the value is "nan"
  508. for (int ord = 0; ord < nCumulDiffOrders; ord++){
  509. for (int j=0; j<histFull[k].mHist_v[ord]->GetNbinsX(); j++) {
  510. if ( !(histFull[k].mHist_v[ord]->GetBinContent(j) < FLT_MAX &&
  511. histFull[k].mHist_v[ord]->GetBinContent(j) > -1.*FLT_MAX) ) {
  512. histFull[k].mHist_v[ord]->SetBinContent(j,0.);
  513. histFull[k].mHist_v[ord]->SetBinError(j,0.);
  514. }
  515. }
  516. }
  517. for (int j = 1; j < nHars+1; j++) {
  518. if (histFull[k].mHist_v[0]->GetBinContent(j)< FLT_MAX &&
  519. histFull[k].mHist_v[0]->GetBinContent(j)> -1.*FLT_MAX)
  520. cout << "##### 2-part v" << j << " = ("
  521. << histFull[k].mHist_v[0]->GetBinContent(j)
  522. <<" +/- "<< histFull[k].mHist_v[0]->GetBinError(j)<<" )"<<endl;
  523. if (histFull[k].mHist_v[1]->GetBinContent(j)< FLT_MAX &&
  524. histFull[k].mHist_v[1]->GetBinContent(j)> -1.*FLT_MAX)
  525. cout << "##### 4-part v" << j << " = ("
  526. << histFull[k].mHist_v[1]->GetBinContent(j)
  527. <<" +/- "<< histFull[k].mHist_v[1]->GetBinError(j)<<" )"<<endl;
  528. }
  529. delete histOfMeanIntegV;
  530. delete histOfMeanIntegV3;
  531. } else if (m_M==2) {
  532. TH1D* histOfMeanIntegV2 = new TH1D(*(histFull[k].mHist_v[0]));
  533. histOfMeanIntegV2->Reset();
  534. TH1D* histOfMeanIntegV4 = new TH1D(*(histFull[k].mHist_v[1]));
  535. histOfMeanIntegV4->Reset();
  536. for (int j = 1; j < nHars+1; j++) {
  537. histOfMeanIntegV2->SetBinContent(j, 1./(meanIntegV2[j-1]*perCent));
  538. histOfMeanIntegV2->SetBinError(j,0.);
  539. histOfMeanIntegV4->SetBinContent(j, -0.5/(meanIntegV4[j-1]*perCent));
  540. histOfMeanIntegV4->SetBinError(j,0.);
  541. }
  542. histFull[k].mHist_v[0]->Multiply(histOfMeanIntegV2);
  543. histFull[k].mHist_v[1]->Multiply(histOfMeanIntegV4);
  544. //force to be zero if the value is "nan"
  545. for (int ord = 0; ord < nCumulDiffOrders; ord++){
  546. for (int j=0; j<histFull[k].mHist_v[ord]->GetNbinsX(); j++) {
  547. if ( !(histFull[k].mHist_v[ord]->GetBinContent(j) < FLT_MAX &&
  548. histFull[k].mHist_v[ord]->GetBinContent(j) > -1.*FLT_MAX) ){
  549. histFull[k].mHist_v[ord]->SetBinContent(j,0.);
  550. histFull[k].mHist_v[ord]->SetBinError(j,0.);
  551. }
  552. }
  553. }
  554. for (int j = 1; j < nHars+1; j++) {
  555. if (histFull[k].mHist_v[0]->GetBinContent(j)< FLT_MAX &&
  556. histFull[k].mHist_v[0]->GetBinContent(j)> -1.*FLT_MAX)
  557. cout << "##### 2-part v" << j << " = ("
  558. << histFull[k].mHist_v[0]->GetBinContent(j)
  559. <<") +/- "<< histFull[k].mHist_v[0]->GetBinError(j)<<endl;
  560. if (histFull[k].mHist_v[1]->GetBinContent(j)< FLT_MAX &&
  561. histFull[k].mHist_v[1]->GetBinContent(j)> -1.*FLT_MAX)
  562. cout << "##### 4-part v" << j << " = ("
  563. << histFull[k].mHist_v[1]->GetBinContent(j)
  564. <<") +/- "<< histFull[k].mHist_v[1]->GetBinError(j)<<endl;
  565. }
  566. delete histOfMeanIntegV2;
  567. delete histOfMeanIntegV4;
  568. }
  569. }
  570. // ============== write out ====================
  571. f->cd();
  572. for (int k = 0; k < nSels; k++) {
  573. for (int ord = 0; ord < nCumulDiffOrders; ord++) {
  574. histFull[k].mHist_v[ord]->Write(histFull[k].mHist_v[ord]->GetTitle(),TObject::kOverwrite | TObject::kSingleKey);
  575. }
  576. histFull[k].mHistMix_v->Write(histFull[k].mHistMix_v->GetTitle(),TObject::kOverwrite | TObject::kSingleKey);
  577. for (int j = 0; j < nHars; j++) {
  578. cout<<" writting ........................."<<endl;
  579. for (int ord = 0; ord < nCumulDiffOrders; ord++){
  580. histFull[k].histFullHar[j].mHist_v2D[ord]->Write(histFull[k].histFullHar[j].mHist_v2D[ord]->GetTitle(),TObject::kOverwrite | TObject::kSingleKey);
  581. histFull[k].histFullHar[j].mHist_vEta[ord]->Write(histFull[k].histFullHar[j].mHist_vEta[ord]->GetTitle(),TObject::kOverwrite | TObject::kSingleKey);
  582. histFull[k].histFullHar[j].mHist_vPt[ord]->Write(histFull[k].histFullHar[j].mHist_vPt[ord]->GetTitle(),TObject::kOverwrite | TObject::kSingleKey);
  583. }
  584. if (j==0){
  585. cout<<" j "<<j<<" k "<<k<<endl;
  586. cout<<" histFull[k].histFullHar[j].mHistMix_v2D "<<histFull[k].histFullHar[j].mHistMix_v2D->GetTitle()<<endl;
  587. (histFull[k].histFullHar[j].mHistMix_v2D)->Write((histFull[k].histFullHar[j].mHistMix_v2D)->GetTitle(),TObject::kOverwrite | TObject::kSingleKey);
  588. (histFull[k].histFullHar[j].mHistMix_vEta)->Write((histFull[k].histFullHar[j].mHistMix_vEta)->GetTitle(),TObject::kOverwrite | TObject::kSingleKey);
  589. (histFull[k].histFullHar[j].mHistMix_vPt)->Write((histFull[k].histFullHar[j].mHistMix_vPt)->GetTitle(),TObject::kOverwrite | TObject::kSingleKey);
  590. }
  591. }
  592. }
  593. //=============================================
  594. f->Close();
  595. }