1 #include "commonmacro/common.h"
2 #include "commonmacro/histutil.h"
3 #include "common/Name.cc"
5 void compareSpectra(
const char* inName=
6 "links/P01hi.minbias.2000.hist/hianalysis_1000.hist.root",
7 const char* psDir=
"ps",
9 const char* outDir=
"./",
10 const char* more =
"west",
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;
25 inRoot[0] =
new TFile(inName);
26 inRoot[1] =
new TFile(more);
27 if(!inRoot[0] || !inRoot[1]){
28 cout <<
"cannot find the infile" << endl;
31 cout <<
"file 2=" << more << endl;
34 TString trigger[2]; trigger[0]=inName; trigger[1]=more;
36 trigger[i].Remove(0,trigger[i].Last(
'/'));
41 TString sCut = trigger[1];
42 sCut.Remove(0,sCut.First(
"_")+1);
43 sCut.Remove(sCut.First(
'.'),sCut.Length());
44 sCut.ReplaceAll(
"cut",
"");
45 cout <<
"cut2=" << sCut << endl;
49 TH1* h1[2]; TH1* ha[2]; TH1* hRatio;
50 TGraphAsymmErrors* g[2];
52 TCanvas c1(
"c1",
"c1",400,500);
53 float minpt=2,maxpt=6;
56 const int nBin=2;
const int nBase=2;
const int nCharge=3;
57 char* baseName[] = {
"h1Raw",
"h1Corrected" };
58 char* baseTitle[] = {
"raw",
"corrected"};
59 char* charge[] = { 0,
"Plus",
"Minus"};
60 int markerStyle[] = {4,8,2};
61 float ratioMin=0.2,ratioMax=1.5;
63 gStyle->SetOptStat(0);
64 gStyle->SetTitleBorderSize(0);
65 for(
int iBin=0; iBin<nBin; iBin++){
66 for(
int iCharge=0; iCharge<nCharge; iCharge++){
68 sprintf(title,
"bin %d %s : %s/%s ",
70 trigger[0].Data(),trigger[1].Data());
73 c1.Clear();c1.cd(1); gPad->SetTickx(); gPad->SetTicky();
74 gPad->SetGridx(); gPad->SetGridy();
76 for(
int iBase=0; iBase<nBase; iBase++){
77 for(
int if=0;
if<2;
if++){
78 setName(name,baseName[iBase],iBin,charge[iCharge]);
79 h1[
if]=(TH1*)inRoot[
if]->Get(name);
82 hRatio=(TH1*)h1[0]->Clone();
84 hRatio->Divide(h1[1]);
85 SetRange(hRatio->GetXaxis(),minpt,maxpt);
86 hRatio->SetMarkerStyle(8); SetMinMax(hRatio,ratioMin,ratioMax);
88 hRatio->SetTitle(title);
89 hRatio->SetMarkerStyle(markerStyle[iBase]);
91 hRatio->Scale(1./hRatio->GetBinContent(hRatio->GetXaxis()->GetFirst()));
101 hRatio->GetXaxis()->SetTitle(
"pT (GeV/c)");
105 hRatio->Draw(
"e1same");
111 TLegend* l=
new TLegend(.7,.7,.85,.85); l->SetBorderSize(0);
113 l->AddEntry(ha[0],
"raw",
"p");
114 l->AddEntry(ha[1],
"corrected",
"p");
117 sTitle=hRatio->GetName();
118 sTitle.Remove(sTitle.Last(
'.'));
119 sprintf(title,
"_cut%dcut%s",cut,sCut.Data());
121 Print(&c1,psDir,sTitle.Data());