00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00017
00018 #include <math.h>
00019 const Int_t nHars = 2;
00020 const Int_t nOrders = 2;
00021 Int_t runNumber = 0;
00022 char runName[6];
00023 char fileNum[4] = "x";
00024 char fileName[30];
00025 TFile* histFile;
00026 char tmp[10];
00027 TCanvas* c;
00028
00029 TCanvas* plotCumulant(Int_t pageNumber=0, Int_t selN=2, Int_t orderN=0, Int_t harN=0){
00030
00031 bool multiGraph = kFALSE;
00032 bool singleGraph = kFALSE;
00033 if (orderN == 0) multiGraph = kTRUE;
00034 bool mixGraph = kFALSE;
00035 TCanvas* cOld = (TCanvas*)gROOT->GetListOfCanvases();
00036 if (cOld) cOld->Delete();
00037
00038 gROOT->SetStyle("Bold");
00039 gROOT->ForceStyle();
00040
00041
00042 const char* baseName[] = {
00043 "Flow_Cumul_v_Order2",
00044 "Flow_Cumul_v_Order4",
00045 "Flow_CumulMix_v",
00046 "Flow_CumulMix_vEta",
00047 "Flow_CumulMix_vPt",
00048 "Flow_Cumul_vEta_Order",
00049 "Flow_Cumul_vPt_Order"
00050
00051 };
00052 const int nNames = sizeof(baseName) / sizeof(char*);
00053 const int nSingles = 5;
00054 float Ycm = 0.0;
00055
00056
00057 char* shortName[] = new char*[nNames];
00058 for (int n = 0; n < nNames; n++) {
00059 shortName[n] = new char[30];
00060 strcpy(shortName[n], baseName[n]);
00061 char* cp = strstr(shortName[n],"Order");
00062 if (cp) *cp = '\0';
00063 }
00064
00065
00066 if (runNumber == 0) {
00067 cout << " run number? ";
00068 fgets(tmp, sizeof(tmp), stdin);
00069 runNumber = atoi(tmp);
00070 sprintf(runName, "ana%2d", runNumber);
00071 cout << " run name = " << runName << endl;
00072 }
00073
00074
00075 if (strstr(fileNum, "x")!=0) {
00076 cout << " anaXX.root file number? [0= flow.hist.root] ";
00077 fgets(fileNum, sizeof(fileNum), stdin);
00078 fileNum[strlen(fileNum)-1] = '\0';
00079 if (strlen(fileNum) == 1 && strstr(fileNum,"0")) {
00080 sprintf(fileName, "flow.hist.root");
00081 } else {
00082 sprintf(fileName, "ana%s.root", fileNum);
00083 }
00084 cout << " file name = " << fileName << endl;
00085 histFile = new TFile(fileName);
00086 }
00087
00088
00089 while (pageNumber <= 0 || pageNumber > nNames) {
00090 if (pageNumber < 0) {
00091 plotCumulantAll(nNames, orderN, selN, harN, -pageNumber);
00092 return c;
00093 }
00094 cout << "-1: \t All" << endl;
00095 for (int i = 0; i < nNames; i++) {
00096 cout << i+1 << ":\t " << baseName[i] << endl;
00097 }
00098 cout << " page number? ";
00099 fgets(tmp, sizeof(tmp), stdin);
00100 pageNumber = atoi(tmp);
00101 }
00102 if (pageNumber > 0 && pageNumber <= nSingles) {
00103 singleGraph = kTRUE;
00104 multiGraph = kFALSE;
00105 strcpy(shortName[pageNumber-1], baseName[pageNumber-1]);
00106 }
00107 pageNumber--;
00108 cout << " graph name= " << shortName[pageNumber] << endl;
00109
00110 if (strstr(shortName[pageNumber],"Mix")!=0) {
00111 mixGraph = kTRUE;
00112 harN = 1;
00113 }
00114
00115
00116 int columns = nOrders;
00117 int rows = nHars;
00118 int pads = rows*columns;
00119
00120
00121 if (multiGraph) {
00122 int canvasWidth = 600, canvasHeight = 780;
00123 } else {
00124 int canvasWidth = 780, canvasHeight = 600;
00125 }
00126 c = new TCanvas(shortName[pageNumber], shortName[pageNumber],
00127 canvasWidth, canvasHeight);
00128 c->ToggleEventStatus();
00129 if (multiGraph) {
00130 TPaveLabel* title = new TPaveLabel(0.1,0.96,0.9,0.99,shortName[pageNumber]);
00131 title->Draw();
00132 }
00133 TPaveLabel* run = new TPaveLabel(0.1,0.01,0.2,0.03,runName);
00134 run->Draw();
00135 TDatime now;
00136 TPaveLabel* date = new TPaveLabel(0.7,0.01,0.9,0.03,now.AsString());
00137 date->Draw();
00138 TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.97,0.95);
00139 graphPad->Draw();
00140 graphPad->cd();
00141
00142 if (multiGraph) {
00143 graphPad->Divide(columns,rows);
00144 int firstK = 0, firstJ = 0, lastK = columns, lastJ = rows;
00145 } else if (singleGraph) {
00146 int firstK = 0, firstJ = 0, lastK = 1, lastJ = 1;
00147 } else {
00148 int firstK = orderN/2 -1, firstJ = harN -1, lastK = orderN/2, lastJ = harN;
00149 }
00150 for (int j = firstJ; j < lastJ; j++) {
00151 for (int k = firstK ; k < lastK; k++) {
00152 char countOrder[2];
00153 sprintf(countOrder,"%d",2*(k+1));
00154 int padN = j*columns + k + 1;
00155
00156
00157 TString* histName = new TString(baseName[pageNumber]);
00158 if (multiGraph) {
00159 histName->Append(*countOrder);
00160 }
00161 histName->Append("_Sel");
00162 *histName += selN;
00163 if (multiGraph) {
00164 histName->Append("_Har");
00165 *histName += j+1;
00166 } else if (mixGraph && strcmp(shortName[pageNumber],"Flow_CumulMix_v") != 0) {
00167 histName->Append("_Har");
00168 *histName += j+1;
00169 }
00170 cout << " col= " << k+1 << " row= " << j+1 << " pad= " << padN << "\t"
00171 << histName->Data() << endl;
00172
00173
00174 bool twoD;
00175 if (strstr(shortName[pageNumber],"2D")!=0) {
00176 twoD = kTRUE;
00177 TH2* hist2D = dynamic_cast<TH2*>(histFile->Get(histName->Data()));
00178 if (!hist2D) {
00179 cout << "### Can't find histogram " << histName->Data() << endl;
00180 return c;
00181 }
00182 } else {
00183 TH1* hist = dynamic_cast<TH1*>(histFile->Get(histName->Data()));
00184 if (!hist) {
00185 cout << "### Can't find histogram " << histName->Data() << endl;
00186 return c;
00187 }
00188 float xMax = hist->GetXaxis()->GetXmax();
00189 }
00190
00191
00192 if (multiGraph) graphPad->cd(padN);
00193 if (twoD) {
00194 gStyle->SetOptStat(10);
00195
00196 hist2D->Draw("LEGO1");
00197 } else {
00198 gStyle->SetOptStat(100110);
00199 hist->Draw();
00200 float yMax, yMin;
00201 if (strstr(shortName[pageNumber],"Eta")!=0) {
00202 if (strstr(shortName[pageNumber],"_v")!=0) {
00203 yMax = 10.;
00204 yMin = -10.;
00205 } else {
00206 yMax = 0.005;
00207 yMin = -0.005;
00208 }
00209 hist->SetMaximum(yMax);
00210 hist->SetMinimum(yMin);
00211 TLine* lineZeroEta = new TLine(-xMax, 0., xMax, 0.);
00212 lineZeroEta->Draw();
00213 TLine* lineEtaCM = new TLine(Ycm, yMin, Ycm, yMax);
00214 lineEtaCM->Draw();
00215 } else if (strstr(shortName[pageNumber],"Pt")!=0) {
00216 if (strstr(shortName[pageNumber],"_v")!=0) {
00217 yMax = 30.;
00218 yMin = -10.;
00219 } else {
00220 yMax = 0.02;
00221 yMin = -0.02;
00222 }
00223 hist->SetMaximum(yMax);
00224 hist->SetMinimum(yMin);
00225 TLine* lineZeroPt = new TLine(0., 0., xMax, 0.);
00226 lineZeroPt->Draw();
00227 } else {
00228 hist->SetMinimum(0.);
00229 TLine* lineZeroHar = new TLine(0.5, 0., nHars+0.5, 0.);
00230 lineZeroHar->Draw();
00231 }
00232 }
00233 delete histName;
00234 }
00235 }
00236 for (int m = 0; m < nNames; m++) {
00237 delete [] shortName[m];
00238 }
00239 delete [] shortName;
00240
00241 return c;
00242 }
00243
00244 void plotCumulantAll(Int_t nNames, Int_t orderN, Int_t selN, Int_t harN, Int_t first = 1) {
00245 for (int i = first; i < nNames + 1; i++) {
00246 c = plotCumulant(i, selN, orderN, harN);
00247 c->Update();
00248 cout << "save? y/[n], quit? q" << endl;
00249 fgets(tmp, sizeof(tmp), stdin);
00250 if (strstr(tmp,"y")!=0) c->Print(".ps");
00251 else if (strstr(tmp,"q")!=0) return;
00252 }
00253 cout << " plotCumulantAll Done" << endl;
00254 }
00255
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296