plotCen.C 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // $Id: plotCen.C,v 1.29 2010/09/30 19:28:25 posk Exp $
  4. //
  5. // Author: Art Poskanzer, LBNL, July 2000
  6. // FTPC added by Markus Oldenburg, MPI, Dec 2000
  7. // Description: Macro to plot histograms made by StFlowAnalysisMaker.
  8. // Plots a set of histograms with different centrality
  9. // starting with anaXX.root given by first run number XX.
  10. // Run Number appended to "ana" is entered in the bottom, left box.
  11. // Default selN = 2 and harN = 2.
  12. // First time type .x plotCen.C() to see the menu.
  13. // After the first execution, just type plotCen(N) .
  14. // A negative N plots all pages starting with page N.
  15. // Place a symbolic link to this file in StRoot/macros/analysis .
  16. //
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////
  19. #include <iomanip.h>
  20. #include <math.h>
  21. #include "TMath.h"
  22. const Int_t nCens = 10; // min bias + 9 centralities
  23. //const Int_t nCens = 9; // 9 centralities
  24. int runNumber = 0;
  25. char runName[60];
  26. char fileName[60];
  27. char histTitle[30];
  28. TFile* histFile[nCens];
  29. char tmp[10];
  30. TCanvas* can;
  31. TCanvas* plotCen(Int_t pageNumber=0, Int_t selN=2, Int_t harN=2){
  32. gInterpreter->ProcessLine(".O0");
  33. TCanvas* cOld = (TCanvas*)gROOT->GetListOfCanvases(); // delete old canvas
  34. if (cOld) cOld->Delete();
  35. //gROOT->SetStyle("Pub"); // set style
  36. gROOT->SetStyle("Bold"); // set style
  37. gStyle->SetPalette(1);
  38. gROOT->ForceStyle();
  39. gStyle->SetLabelSize(.1,"X");
  40. int canvasWidth = 600, canvasHeight = 780; // portrait
  41. int columns = 2;
  42. int rows;
  43. bool oddPads = (nCens) % 2;
  44. if (oddPads) {
  45. rows = nCens/columns + 1;
  46. } else {
  47. rows = nCens/columns;
  48. }
  49. int pads = nCens;
  50. // names of histograms made by StFlowAnalysisMaker
  51. // also projections of some of these histograms
  52. const char* baseName[] = {
  53. "Flow_Cos_Sel",
  54. "Flow_Res_Sel",
  55. "Flow_v_Sel",
  56. "FlowLYZ_V_Sel",
  57. "FlowLYZ_vr0_Sel",
  58. "FlowLYZ_v_Sel",
  59. "Flow_v_ScalarProd_Sel",
  60. "Flow_Cumul_v_Order2_Sel",
  61. "Flow_Cumul_v_Order4_Sel",
  62. "Flow_VertexZ",
  63. "Flow_VertexXY2D",
  64. "Flow_EtaSymVerZ2D_Tpc",
  65. "Flow_EtaSym_Tpc",
  66. "Flow_EtaSymVerZ2D_Ftpc",
  67. "Flow_EtaSym_Ftpc",
  68. "Flow_CTBvsZDC2D",
  69. "Flow_Cent",
  70. "Flow_OrigMult",
  71. "Flow_Mult",
  72. "FlowLYZ_Mult",
  73. "Flow_MultOverOrig",
  74. "Flow_MultEta",
  75. "Flow_MultPart",
  76. "Flow_Charge_Ftpc",
  77. "Flow_DcaGlobal_Tpc",
  78. "Flow_Dca_Ftpc",
  79. "Flow_DcaGlobal_Ftpc",
  80. "Flow_Chi2_Tpc",
  81. "Flow_Chi2_Ftpc",
  82. "Flow_FitPts_Tpc",
  83. "Flow_MaxPts_Tpc",
  84. "Flow_FitOverMax_Tpc",
  85. "Flow_FitPts_Ftpc",
  86. "Flow_MaxPts_Ftpc",
  87. "Flow_FitOverMax_Ftpc",
  88. "Flow_YieldAll2D",
  89. "Flow_YieldAll.Eta",
  90. "Flow_YieldAll.Pt",
  91. "Flow_YieldPart2D",
  92. "Flow_YieldPart.Eta",
  93. "Flow_YieldPart.Pt",
  94. "Flow_MeanDedxPos2D",
  95. "Flow_MeanDedxNeg2D",
  96. // "Flow_PidPiPlusPart",
  97. // "Flow_PidPiMinusPart",
  98. // "Flow_PidProtonPart",
  99. // "Flow_PidAntiProtonPart",
  100. // "Flow_PidKplusPart",
  101. // "Flow_PidKminusPart",
  102. // "Flow_PidDeuteronPart",
  103. // "Flow_PidAntiDeuteronPart",
  104. // "Flow_PidElectronPart",
  105. // "Flow_PidPositronPart",
  106. "Flow_PidMult",
  107. // "Flow_CosPhiLab",
  108. "Flow_Yield2D_Sel",
  109. "Flow_Yield.Eta_Sel",
  110. "Flow_Yield.Pt_Sel",
  111. "Flow_Mul_Sel",
  112. // "Flow_Phi_East_Sel",
  113. // "Flow_Phi_Flat_East_Sel",
  114. // "Flow_Phi_West_Sel",
  115. // "Flow_Phi_Flat_West_Sel",
  116. // "Flow_Phi_FtpcEast_Sel",
  117. // "Flow_Phi_Flat_FtpcEast_Sel",
  118. // "Flow_Phi_FtpcWest_Sel",
  119. // "Flow_Phi_Flat_FtpcWest_Sel",
  120. "Flow_Psi_Subs",
  121. "Flow_Psi_Sel",
  122. "Flow_Psi_Sub_Corr_Sel",
  123. "Flow_Psi_Sub_Corr_Diff_Sel",
  124. "Flow_Phi_Corr_Sel",
  125. "Flow_vObs2D_Sel",
  126. "Flow_vObsEta_Sel",
  127. "Flow_vObsPt_Sel",
  128. "Flow_v2D_Sel",
  129. "Flow_vEta_Sel",
  130. "Flow_vPt_Sel",
  131. "Flow_q_Sel",
  132. "FlowLYZ_r0theta_Sel",
  133. "FlowLYZ_Vtheta_Sel",
  134. "FlowLYZ_vEta_Sel",
  135. "FlowLYZ_vPt_Sel",
  136. "FlowLYZ_Gtheta0_Sel",
  137. "Flow_vObs2D_ScalarProd_Sel",
  138. "Flow_v2D_ScalarProd_Sel",
  139. "Flow_vEta_ScalarProd_Sel",
  140. "Flow_vPt_ScalarProd_Sel",
  141. "Flow_Cumul_vEta_Order2_Sel",
  142. "Flow_Cumul_vPt_Order2_Sel",
  143. "Flow_Cumul_vEta_Order4_Sel",
  144. "Flow_Cumul_vPt_Order4_Sel"
  145. };
  146. int nName = sizeof(baseName) / sizeof(char*);
  147. const Int_t nNames = nName;
  148. const int nDoubles = 9;
  149. const int nSingles = 46 + nDoubles;
  150. // construct array of short names
  151. char* shortName[nNames];
  152. for (int n = 0; n < nNames; n++) {
  153. shortName[n] = new char[35];
  154. strcpy(shortName[n], baseName[n]);
  155. char* cp = strstr(shortName[n],"_Sel");
  156. if (cp) *cp = '\0'; // truncate
  157. }
  158. cout << "Harmonic = " << harN << endl << endl;
  159. // input the first run number
  160. if (runNumber == 0) {
  161. cout << " first run number? ";
  162. fgets(tmp, sizeof(tmp), stdin);
  163. runNumber = atoi(tmp);
  164. sprintf(runName, "ana%2d", runNumber); // add ana prefix
  165. cout << " first run name = " << runName << endl;
  166. // open the files
  167. for (int n = 0; n < nCens; n++) {
  168. sprintf(fileName, "ana%2d.root", runNumber + n);
  169. cout << " file name = " << fileName << endl;
  170. histFile[n] = new TFile(fileName);
  171. }
  172. }
  173. // input the page number
  174. while (pageNumber <= 0 || pageNumber > nNames) {
  175. if (pageNumber < 0) { // plot all
  176. plotCenAll(nNames, selN, harN, -pageNumber);
  177. return can;
  178. }
  179. cout << "-1: \t All" << endl; // print menu
  180. for (int i = 0; i < nNames; i++) {
  181. cout << i+1 << ":\t " << shortName[i] << endl;
  182. }
  183. cout << " page number? ";
  184. fgets(tmp, sizeof(tmp), stdin);
  185. pageNumber = atoi(tmp);
  186. }
  187. // set flags
  188. bool multiGraph = kFALSE;
  189. bool doubleGraph = kFALSE;
  190. bool singleGraph = kFALSE;
  191. if (pageNumber > 0 && pageNumber <= nDoubles) {
  192. doubleGraph = kTRUE;
  193. } else if (pageNumber > nDoubles && pageNumber <= nSingles) {
  194. singleGraph = kTRUE;
  195. } else {
  196. multiGraph = kTRUE;
  197. }
  198. pageNumber--;
  199. // set constants
  200. float twopi = 2. * TMath::Pi();
  201. float etaMax = 1.5;
  202. float yMin = -4.5;
  203. float yMax = 4.5;
  204. float qMax = 3.5;
  205. float phiMax = twopi;
  206. int n_qBins = 50;
  207. float Ycm = 0.0;
  208. TString* histProjName = NULL;
  209. // construct histName and histProjName
  210. char sel[2];
  211. sprintf(sel,"%d",selN);
  212. char har[2];
  213. sprintf(har,"%d",harN);
  214. float order = (float)harN;
  215. char* temp = new char[35]; // construct histName
  216. strcpy(temp,shortName[pageNumber]);
  217. char* cproj = strstr(temp,".");
  218. if (cproj) { // a projection
  219. *cproj = '\0'; // remove from "." on
  220. if (singleGraph) {
  221. cproj = strstr(temp,"2");
  222. if (cproj) { // a 2D projection
  223. *cproj = '\0'; // remove from "2D" on
  224. strcat(temp,"3D");
  225. } else {
  226. strcat(temp,"2D");
  227. }
  228. } else {
  229. strcat(temp,"2D_Sel");
  230. }
  231. TString* histName = new TString(temp);
  232. histProjName = new TString(baseName[pageNumber]);
  233. if (multiGraph) {
  234. histProjName->Append(*sel);
  235. histProjName->Append("_Har");
  236. histProjName->Append(*har);
  237. }
  238. } else { // not projection
  239. TString* histName = new TString(baseName[pageNumber]);
  240. }
  241. if (!singleGraph) histName->Append(*sel);
  242. if (multiGraph) {
  243. histName->Append("_Har");
  244. histName->Append(*har);
  245. }
  246. cout << pageNumber+1 << ": graph name= " << histName->Data() << endl;
  247. // make the graph page
  248. can = new TCanvas(shortName[pageNumber], shortName[pageNumber],
  249. canvasWidth, canvasHeight);
  250. can->ToggleEventStatus();
  251. TPaveLabel* title = new TPaveLabel(0.1,0.96,0.9,0.99,histName->Data());
  252. title->Draw();
  253. TPaveLabel* run = new TPaveLabel(0.1,0.01,0.2,0.03,runName);
  254. run->Draw();
  255. TDatime now;
  256. TPaveLabel* date = new TPaveLabel(0.7,0.01,0.9,0.03,now.AsString());
  257. date->Draw();
  258. TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.97,0.95);
  259. graphPad->Draw();
  260. graphPad->cd();
  261. graphPad->Divide(columns, rows);
  262. TLine* lineZeroY = new TLine(yMin, 0., yMax, 0.);
  263. TLine* lineYcm = new TLine(Ycm, -10., Ycm, 10.);
  264. float v;
  265. float err;
  266. int centr;
  267. for (int i = 0; i < pads; i++) {
  268. int fileN = i; // file number
  269. int padN = fileN + 1; // pad number
  270. centr = oddPads ? padN : padN-1;
  271. sprintf(histTitle,"Centrality %d",centr);
  272. cout << "centrality= " << centr << endl;
  273. // get the histogram
  274. bool twoD;
  275. bool threeD;
  276. if (histProjName) {
  277. if (strstr(temp,"3D")) { // 2D projection
  278. twoD = kTRUE;
  279. TH3* hist3D = (TH3*)(histFile[fileN]->Get(histName->Data()));
  280. if (!hist3D) {
  281. cout << "### Can't find histogram " << histName->Data() << endl;
  282. return can;
  283. }
  284. hist3D->SetTitle(histTitle);
  285. } else { // 1D projection
  286. TH2* hist2D = (TH2*)(histFile[fileN]->Get(histName->Data()));
  287. if (!hist2D) {
  288. cout << "### Can't find histogram " << histName->Data() << endl;
  289. return can;
  290. }
  291. hist2D->SetTitle(histTitle);
  292. }
  293. } else {
  294. if (strstr(shortName[pageNumber],"3D")!=0) { // 3D
  295. threeD = kTRUE;
  296. TH3* hist3D = (TH3*)(histFile[fileN]->Get(histName->Data()));
  297. if (!hist3D) {
  298. cout << "### Can't find histogram " << histName->Data() << endl;
  299. return can;
  300. }
  301. hist3D->SetTitle(histTitle);
  302. } else if (strstr(shortName[pageNumber],"2D")!=0) { // 2D
  303. twoD = kTRUE;
  304. TH2* hist2D = (TH2*)(histFile[fileN]->Get(histName->Data()));
  305. if (!hist2D) {
  306. cout << "### Can't find histogram " << histName->Data() << endl;
  307. return can;
  308. }
  309. hist2D->SetTitle(histTitle);
  310. } else { // 1D
  311. TH1* hist = (TH1*)(histFile[fileN]->Get(histName->Data()));
  312. if (!hist) {
  313. cout << "### Can't find histogram " << histName->Data() << endl;
  314. return can;
  315. }
  316. float ptMax = hist->GetXaxis()->GetXmax();
  317. hist->SetTitle(histTitle);
  318. }
  319. }
  320. // make the plots
  321. graphPad->cd(padN);
  322. if (threeD) { // 3D
  323. gStyle->SetOptStat(10);
  324. hist3D->Draw("BOX");
  325. } else if (twoD) { // 2D
  326. if (strstr(shortName[pageNumber],".PhiEta")!=0) { // 3D Phi Eta proj.
  327. TH2D* projZX = (TH2*)hist3D->Project3D("zx");
  328. projZX->SetName(histProjName->Data());
  329. projZX->SetYTitle("azimuthal angle (rad)");
  330. projZX->SetXTitle("rapidity");
  331. gStyle->SetOptStat(0);
  332. if (projZX) projZX->Draw("COLZ");
  333. } else if (strstr(shortName[pageNumber],".PhiPt")!=0) { // 3D Phi Pt proj.
  334. TH2D* projZY = (TH2*)hist3D->Project3D("zy");
  335. projZY->SetName(histProjName->Data());
  336. projZY->SetYTitle("azimuthal angle (rad");
  337. projZY->SetXTitle("Pt (GeV)");
  338. gStyle->SetOptStat(0);
  339. if (projZY) projZY->Draw("COLZ");
  340. } else if (strstr(shortName[pageNumber],"XY")!=0) { // Vertex XY
  341. TLine* lineZeroX = new TLine(-1., 0., 1., 0.);
  342. TLine* lineZero = new TLine(0., -1., 0., 1.);
  343. gStyle->SetOptStat(10);
  344. hist2D->Draw("COLZ");
  345. lineZeroX->Draw();
  346. lineZero->Draw();
  347. } else if (strstr(shortName[pageNumber],"Dedx")!=0) { // dE/dx
  348. gStyle->SetOptStat(10);
  349. (TVirtualPad::Pad()) ->SetLogz();
  350. hist2D->Draw("COLZ");
  351. } else if (strstr(shortName[pageNumber],"_v")!=0) { // v
  352. hist2D->SetMaximum(20.);
  353. hist2D->SetMinimum(-20.);
  354. gStyle->SetOptStat(0);
  355. hist2D->Draw("COLZ");
  356. } else { // other 2D
  357. gStyle->SetOptStat(10);
  358. hist2D->Draw("COLZ");
  359. }
  360. } else if (strstr(shortName[pageNumber],".Eta")!=0) { // 2D Eta projection
  361. if (singleGraph) {
  362. TH1D* projX = hist2D->ProjectionX(histName->Data(), 0, 9999);
  363. } else {
  364. TH1D* projX = hist2D->ProjectionX(histName->Data(), 0, 9999);
  365. }
  366. projX->SetName(histProjName->Data());
  367. char* xTitle = hist2D->GetXaxis()->GetTitle();
  368. projX->SetXTitle(xTitle);
  369. projX->SetYTitle("Counts");
  370. gStyle->SetOptStat(0);
  371. if (projX) projX->Draw("H");
  372. if (!singleGraph) lineZeroY->Draw();
  373. } else if (strstr(shortName[pageNumber],".Pt")!=0) { // 2D Pt projection
  374. if (singleGraph) {
  375. TH1D* projY = hist2D->ProjectionY(histName->Data(), 0, 9999);
  376. } else {
  377. TH1D* projY = hist2D->ProjectionY(histName->Data(), 0, 9999, "E");
  378. }
  379. projY->SetName(histProjName->Data());
  380. projY->SetXTitle("Pt (GeV)");
  381. projY->SetYTitle("Counts");
  382. (TVirtualPad::Pad())->SetLogy();
  383. gStyle->SetOptStat(0);
  384. if (projY) projY->Draw("H");
  385. } else if (strstr(shortName[pageNumber],"Corr")!=0) { // azimuthal corr.
  386. float norm = (float)(hist->GetNbinsX()) / hist->Integral();
  387. cout << " Normalized by: " << norm << endl;
  388. hist->Scale(norm); // normalize height to one
  389. if (strstr(shortName[pageNumber],"Sub")!=0) {
  390. TF1* funcSubCorr = new TF1("SubCorr", SubCorr, 0., twopi/order, 2);
  391. funcSubCorr->SetParNames("chi", "har");
  392. funcSubCorr->SetParameters(1., order); // initial value
  393. funcSubCorr->SetParLimits(1, 1, 1); // har is fixed
  394. hist->Fit("SubCorr");
  395. delete funcSubCorr;
  396. } else {
  397. TF1* funcCos2 = new TF1("funcCos2",
  398. "1+[0]*2/100*cos([2]*x)+[1]*2/100*cos(([2]+1)*x)", 0., twopi/order);
  399. funcCos2->SetParNames("k=1", "k=2", "har");
  400. funcCos2->SetParameters(0, 0, order); // initial values
  401. funcCos2->SetParLimits(2, 1, 1); // har is fixed
  402. hist->Fit("funcCos2");
  403. delete funcCos2;
  404. }
  405. if (strstr(shortName[pageNumber],"Phi")!=0)
  406. hist->SetMinimum(0.9*(hist->GetMinimum()));
  407. gStyle->SetOptStat(10);
  408. gStyle->SetOptFit(111);
  409. hist->Draw("E1");
  410. } else if (strstr(shortName[pageNumber],"_q")!=0) { // q distibution
  411. gStyle->SetOptStat(110);
  412. gStyle->SetOptFit(111);
  413. double area = hist->Integral() * qMax / (float)n_qBins;
  414. TString* histMulName = new TString("Flow_Mul_Sel");
  415. histMulName->Append(*sel);
  416. histMulName->Append("_Har");
  417. histMulName->Append(*har);
  418. TH1* histMult = (TH1*)(histFile[fileN]->Get(histMulName->Data()));
  419. if (!histMult) {
  420. cout << "### Can't find histogram " << histMulName->Data() << endl;
  421. return can;
  422. }
  423. delete histMulName;
  424. float mult = histMult->GetMean();
  425. TF1* fit_q = new TF1("qDist", qDist, 0., qMax, 4);
  426. fit_q->SetParNames("v", "mult", "area", "g");
  427. float qMean = hist->GetMean();
  428. float vGuess = (qMean > 1.) ? sqrt(2.*(qMean - 1.) / mult) : 0.03;
  429. // the 0.03 is a wild guess
  430. vGuess *= 100.;
  431. cout << "vGuess = " << vGuess << endl;
  432. fit_q->SetParameters(vGuess, mult, area, 0.3); // initial values
  433. fit_q->SetParLimits(1, 1, 1); // mult is fixed
  434. fit_q->SetParLimits(2, 1, 1); // area is fixed
  435. //fit_q->FixParameter(3, 0.6); // g is fixed
  436. hist->Fit("qDist");
  437. fit_q->Draw("same");
  438. } else if (strstr(shortName[pageNumber],"Phi")!=0) { // Phi distibutions
  439. hist->SetMinimum(0.9*(hist->GetMinimum()));
  440. if (strstr(shortName[pageNumber],"Weight")!=0) {
  441. TLine* lineOnePhi = new TLine(0., 1., phiMax, 1.);
  442. gStyle->SetOptStat(0);
  443. hist->Draw();
  444. lineOnePhi->Draw();
  445. } else {
  446. gStyle->SetOptStat(10);
  447. hist->Draw();
  448. }
  449. } else if (strstr(shortName[pageNumber],"Psi")!=0) { // Psi distibutions
  450. gStyle->SetOptStat(10);
  451. hist->Draw("E1");
  452. } else if (strstr(shortName[pageNumber],"Eta")!=0) { // Eta distibutions
  453. if (strstr(shortName[pageNumber],"_v")!=0 ) {
  454. hist->SetMaximum(10.);
  455. hist->SetMinimum(-10.);
  456. }
  457. gStyle->SetOptStat(100110);
  458. hist->Draw();
  459. lineZeroY->Draw();
  460. lineYcm->Draw();
  461. } else if (strstr(shortName[pageNumber],"Pt")!=0) { // Pt distibutions
  462. if (strstr(shortName[pageNumber],"_v")!=0 ) {
  463. hist->SetMaximum(30.);
  464. hist->SetMinimum(-5.);
  465. }
  466. gStyle->SetOptStat(100110);
  467. hist->Draw();
  468. if (strstr(shortName[pageNumber],"v")!=0) {
  469. TLine* lineZeroPt = new TLine(0., 0., ptMax, 0.);
  470. lineZeroPt->Draw();
  471. }
  472. } else if (strstr(shortName[pageNumber],"Bin")!=0) { // Bin hists
  473. if (strstr(shortName[pageNumber],"Pt")!=0) {
  474. TLine* lineDiagonal = new TLine(0., 0., ptMax, ptMax);
  475. } else {
  476. TLine* lineDiagonal = new TLine(-etaMax, -etaMax, etaMax, etaMax);
  477. }
  478. gStyle->SetOptStat(0);
  479. hist->SetMarkerStyle(21);
  480. hist->SetMarkerColor(2);
  481. hist->Draw();
  482. lineDiagonal->Draw();
  483. // } else if (strstr(shortName[pageNumber],"CosPhi")!=0) { // CosPhiLab
  484. // TLine* lineZeroHar = new TLine(0.5, 0., 3.5, 0.);
  485. // gStyle->SetOptStat(0);
  486. // hist->Draw();
  487. // lineZeroHar->Draw();
  488. } else if (strstr(shortName[pageNumber],"Mult")!=0) { // Mult
  489. float mult = hist->GetMean();
  490. cout << centr << ": " << mult << endl;
  491. (TVirtualPad::Pad())->SetLogy();
  492. gStyle->SetOptStat(0);
  493. hist->Draw();
  494. } else if (strstr(shortName[pageNumber],"MultPart")!=0) { // Part Mult
  495. float multPart = hist->GetMean();
  496. cout << centr << ": " << multPart << endl;
  497. (TVirtualPad::Pad())->SetLogy();
  498. gStyle->SetOptStat(0);
  499. hist->Draw();
  500. } else if (strstr(shortName[pageNumber],"PidMult")!=0) { // PID Mult
  501. (TVirtualPad::Pad())->SetLogy();
  502. gStyle->SetOptStat(0);
  503. hist->Draw();
  504. } else if (strstr(shortName[pageNumber],"LYZ_G")!=0) { // LYZ G
  505. (TVirtualPad::Pad())->SetLogy();
  506. gStyle->SetOptStat(0);
  507. TString hist_r0Name("FlowLYZ_r0theta_Sel"); // get r0
  508. hist_r0Name += selN;
  509. hist_r0Name += "_Har";
  510. hist_r0Name += harN;
  511. cout << hist_r0Name << endl;
  512. TH1D* hist_r0 = (TH1D*)histFile[fileN]->Get(hist_r0Name);
  513. float r0 = hist_r0->GetBinContent(1);
  514. hist->SetAxisRange(0., 2*r0, "X");
  515. hist->Draw();
  516. TLine* r0Line = new TLine(r0, 0., r0, 1.);
  517. r0Line->SetLineColor(kBlue);
  518. r0Line->Draw("same");
  519. } else if (strstr(shortName[pageNumber],"LYZ_M")!=0) { // LYZ mult
  520. hist->SetMinimum(0.);
  521. gStyle->SetOptStat(0);
  522. hist->Draw();
  523. Float_t mult = hist->GetMean();
  524. TString* multChar = new TString("mult= ");
  525. *multChar += (int)mult;
  526. TLatex l;
  527. l.SetNDC();
  528. l.SetTextSize(0.1);
  529. l.DrawLatex(0.65,0.8,multChar->Data());
  530. } else if (strstr(shortName[pageNumber],"LYZ")!=0) { // LYZ
  531. hist->SetMinimum(0.);
  532. hist->Draw();
  533. } else if (strstr(shortName[pageNumber],"_v")!=0 ) { // v 1D
  534. TLine* lineZeroHar = new TLine(0.5, 0., 4.5, 0.);
  535. hist->SetMaximum(10.);
  536. gStyle->SetOptStat(0);
  537. hist->Draw();
  538. lineZeroHar->Draw();
  539. for (int n=1; n <= 4; n++) {
  540. v = hist->GetBinContent(n); // output v values
  541. err = hist->GetBinError(n);
  542. if (n==2) cout << " v2 = " << setprecision(3) << v << " +/- " <<
  543. setprecision(2) << err << endl;
  544. if (n==4) cout << " v4 = " << setprecision(3) << v << " +/- " <<
  545. setprecision(2) << err << endl;
  546. if (TMath::IsNaN(v)) {
  547. hist->SetBinContent(n, 0.);
  548. hist->SetBinError(n, 0.);
  549. }
  550. }
  551. } else if (strstr(shortName[pageNumber],"_Res")!=0 ) { // res
  552. for (int n=1; n < 4; n++) {
  553. double res = hist->GetBinContent(n); // output res values
  554. err = hist->GetBinError(n);
  555. if (n==2) cout << " res = " << setprecision(3) << res << " +/- " <<
  556. setprecision(2) << err << endl;
  557. if (TMath::IsNaN(v)) {
  558. hist->SetBinContent(n, 0.);
  559. hist->SetBinError(n, 0.);
  560. }
  561. }
  562. hist->Draw();
  563. } else { // all other 1D
  564. gStyle->SetOptStat(100110);
  565. hist->Draw();
  566. }
  567. }
  568. delete [] temp;
  569. delete histName;
  570. if (histProjName) delete histProjName;
  571. for (int m = 0; m < nNames; m++) {
  572. delete [] shortName[m];
  573. }
  574. delete shortName[];
  575. return can;
  576. }
  577. void plotCenAll(Int_t nNames, Int_t selN, Int_t harN, Int_t first = 1) {
  578. for (int i = first; i < nNames + 1; i++) {
  579. can = plotCen(i, selN, harN);
  580. can->Update();
  581. cout << "save? y/[n], quit? q" << endl;
  582. fgets(tmp, sizeof(tmp), stdin);
  583. if (strstr(tmp,"y")!=0) can->Print(".pdf");
  584. else if (strstr(tmp,"q")!=0) return;
  585. }
  586. cout << " Done" << endl;
  587. }
  588. //-----------------------------------------------------------------------
  589. static Double_t qDist(double* q, double* par) {
  590. // Calculates the q distribution given the parameters v, mult, area, g
  591. double sig2 = 0.5 * (1. + par[3]);
  592. double expo = (par[1]*par[0]*par[0]/10000. + q[0]*q[0]) / (2*sig2);
  593. Double_t dNdq = par[2] * (q[0]*exp(-expo)/sig2) *
  594. TMath::BesselI0(q[0]*par[0]/100.*sqrt(par[1])/sig2);
  595. return dNdq;
  596. }
  597. //-----------------------------------------------------------------------
  598. static Double_t SubCorr(double* x, double* par) {
  599. // Calculates the n(Psi_a - Psi_b) distribution by fitting chi
  600. // From J.-Y. Ollitrault, Nucl. Phys. A590, 561c (1995), Eq. 6. with correc.
  601. // The Struve functions are included.
  602. double chi2 = par[0] * par[0] / 2; // divide by two for SV chi
  603. double z = chi2 * cos(par[1]*x[0]);
  604. double TwoOverPi = 2./TMath::Pi();
  605. Double_t dNdPsi = exp(-chi2)/TwoOverPi * (TwoOverPi*(1.+chi2)
  606. + z*(TMath::BesselI0(z) + TMath::StruveL0(z))
  607. + chi2*(TMath::BesselI1(z) + TMath::StruveL1(z)));
  608. return dNdPsi;
  609. }
  610. ///////////////////////////////////////////////////////////////////////////////
  611. //
  612. // $Log: plotCen.C,v $
  613. // Revision 1.29 2010/09/30 19:28:25 posk
  614. // Instead of reversing the weight for negative pseudrapidity for odd harmonics,
  615. // it is now done only for the first harmonic.
  616. // Recentering is now done for all harmonics.
  617. //
  618. // Revision 1.28 2010/03/05 17:04:40 posk
  619. // ROOT 5.22 compatable.
  620. // Moved doFlowEvents.C here from StRoot/macros/analysis/
  621. //
  622. // Revision 1.26 2006/03/22 22:02:12 posk
  623. // Updates to macros.
  624. //
  625. // Revision 1.25 2006/02/22 19:35:20 posk
  626. // Added graphs for the StFlowLeeYangZerosMaker
  627. //
  628. // Revision 1.24 2005/08/26 19:00:26 posk
  629. // plot style back to bold
  630. //
  631. // Revision 1.23 2005/08/05 20:13:44 posk
  632. // Improved first guess for qDist fit.
  633. //
  634. // Revision 1.22 2005/02/08 22:37:55 posk
  635. // Fixed trigger histogram for year=4.
  636. //
  637. // Revision 1.21 2004/11/19 16:54:41 posk
  638. // Replaced gPad with (TVirtualPad::Pad()). Reverted to TMath::Struve functions.
  639. //
  640. // Revision 1.20 2004/11/11 18:25:55 posk
  641. // Minor updates.
  642. //
  643. // Revision 1.19 2004/03/11 18:00:06 posk
  644. // Added Random Subs analysis method.
  645. //
  646. // Revision 1.18 2004/03/01 22:43:44 posk
  647. // Changed some "->" to ".".
  648. //
  649. // Revision 1.17 2003/06/27 21:25:45 posk
  650. // v4 and v6 are with repect to the 2nd harmonic event plane.
  651. //
  652. // Revision 1.16 2003/05/06 21:33:08 posk
  653. // Removed some histograms.
  654. //
  655. // Revision 1.15 2003/03/18 17:58:38 posk
  656. // Kirill Fillimonov's improved fit to the angle between subevent planes.
  657. //
  658. // Revision 1.14 2003/03/17 20:46:57 posk
  659. // Improved fit to q dist.
  660. //
  661. // Revision 1.13 2003/03/11 23:04:31 posk
  662. // Includes scalar product hists.
  663. //
  664. // Revision 1.12 2003/02/25 19:25:33 posk
  665. // Improved plotting.
  666. //
  667. // Revision 1.11 2003/01/10 16:40:55 oldi
  668. // Several changes to comply with FTPC tracks:
  669. // - Switch to include/exclude FTPC tracks introduced.
  670. // The same switch changes the range of the eta histograms.
  671. // - Eta symmetry plots for FTPC tracks added and separated from TPC plots.
  672. // - PhiWgts and related histograms for FTPC tracks split in FarEast, East,
  673. // West, FarWest (depending on vertex.z()).
  674. // - Psi_Diff plots for 2 different selections and the first 2 harmonics added.
  675. // - Cut to exclude mu-events with no primary vertex introduced.
  676. // (This is possible for UPC events and FTPC tracks.)
  677. // - Global DCA cut for FTPC tracks added.
  678. // - Global DCA cuts for event plane selection separated for TPC and FTPC tracks.
  679. // - Charge cut for FTPC tracks added.
  680. //
  681. // Revision 1.10 2001/12/11 22:04:17 posk
  682. // Four sets of phiWgt histograms.
  683. // StFlowMaker StFlowEvent::PhiWeight() changes.
  684. // Cumulant histogram names changed.
  685. //
  686. // Revision 1.9 2001/11/09 21:15:11 posk
  687. // Switched from CERNLIB to TMath. Using global dca instead of dca.
  688. //
  689. // Revision 1.8 2001/05/22 20:11:24 posk
  690. // Changed dEdx graphs.
  691. //
  692. // Revision 1.7 2000/12/12 15:01:11 posk
  693. // Put log comments at end of file.
  694. //
  695. // Revision 1.6 2000/12/08 17:04:09 oldi
  696. // Phi weights for both FTPCs included.
  697. //
  698. // Revision 1.3 2000/09/15 22:52:56 posk
  699. // Added Pt weighting for event plane calculation.
  700. //
  701. // Revision 1.1 2000/08/31 18:50:33 posk
  702. // Added plotCen.C to plot from a series of files with different centralities.
  703. //
  704. ///////////////////////////////////////////////////////////////////////////////