1 #include "commonmacro/common.h"
2 #include "commonmacro/histutil.h"
3 #include "common/Name.cc"
5 void QMRatio(
const char* inName=
6 "links/P01hi.minbias.2000.hist/hianalysis_1000.hist.root",
7 const char* psDir=
"ps",
9 const char* outDir=
"./",
13 bool doScale=(extraValue>0);
15 cout <<
"--------------------------" << endl;
16 cout <<
"in name=" << inName << endl
17 <<
"ps dir=" << psDir << endl
18 <<
"cut=" << cut << endl
19 <<
"scale? " << (doScale ?
"yes" :
"no") << endl;
20 cout <<
"--------------------------" << endl;
22 char qm[100]; strcpy(qm,
"finish_central_cut1_QM.hist.root");
26 inRoot[0] =
new TFile(inName);
27 inRoot[1] =
new TFile(more);
28 if(!inRoot[0] || !inRoot[1]){
29 cout <<
"cannot find the infile" << endl;
32 cout <<
"file 2=" << more << endl;
35 TString trigger[2]; trigger[0]=inName; trigger[1]=
"QM";
36 trigger[0].Remove(0,trigger[0].Last(
'/'));
38 TH1* h1[2]; TH1* ha[2]; TH1* hRatio;
39 TGraphAsymmErrors* g[2];
41 TCanvas c1(
"c1",
"c1",400,500);
42 float minpt=2,maxpt=6;
45 const int nBin=2;
const int nBase=2;
const int nCharge=3;
46 char* baseName[] = {
"h1Raw",
"h1Corrected" };
47 char* baseTitle[] = {
"raw",
"corrected"};
48 char* charge[] = { 0,
"Plus",
"Minus"};
49 int markerStyle[] = {4,8,2};
50 char* oldcharge[] = {0,
"plus",
"minus"};
52 gStyle->SetOptStat(0);
53 gStyle->SetTitleBorderSize(0);
54 for(
int iCharge=0; iCharge<nCharge; iCharge++){
56 sprintf(title,
"%s : %s/%s ",
58 trigger[0].Data(),trigger[1].Data());
61 c1.Clear();c1.cd(1); gPad->SetTickx(); gPad->SetTicky();
62 gPad->SetGridx(); gPad->SetGridy();
64 for(
int iBase=0; iBase<nBase; iBase++){
65 setName(name,baseName[iBase],0,charge[iCharge]);
66 h1[0]=(TH1*)inRoot[0]->Get(name);
68 setName(name,baseName[iBase],1,oldcharge[iCharge]);
71 setName(name,baseName[iBase],1,3,oldcharge[iCharge]);
74 h1[1]=(TH1*)inRoot[1]->Get(name);
77 hRatio=(TH1*)h1[0]->Clone();
79 hRatio->Divide(h1[1]);
80 SetRange(hRatio->GetXaxis(),minpt,maxpt);
81 hRatio->SetMarkerStyle(8); SetMinMax(hRatio,0.5,1.5);
83 hRatio->SetTitle(title);
84 hRatio->SetMarkerStyle(markerStyle[iBase]);
86 hRatio->Scale(1./hRatio->GetBinContent(hRatio->GetXaxis()->GetFirst()));
96 hRatio->GetXaxis()->SetTitle(
"pT (GeV/c)");
100 hRatio->Draw(
"e1same");
106 TLegend* l=
new TLegend(.2,.7,.3,.80); l->SetBorderSize(0);
108 l->AddEntry(ha[0],
"raw",
"p");
109 l->AddEntry(ha[1],
"corrected",
"p");
112 sTitle=hRatio->GetName();
113 sTitle.Remove(sTitle.Last(
'.'));
114 Print(&c1,psDir,sTitle.Data());