00001 #include "commonmacro/common.h"
00002 #include "commonmacro/histutil.h"
00003 #include "common/Name.cc"
00004
00005 void QMRatio(const char* inName=
00006 "links/P01hi.minbias.2000.hist/hianalysis_1000.hist.root",
00007 const char* psDir="ps",
00008 int cut = 1,
00009 const char* outDir="./",
00010 char* more = "west",
00011 float extraValue = 0)
00012 {
00013 bool doScale=(extraValue>0);
00014
00015 cout << "--------------------------" << endl;
00016 cout << "in name=" << inName << endl
00017 << "ps dir=" << psDir << endl
00018 << "cut=" << cut << endl
00019 << "scale? " << (doScale ? "yes" : "no") << endl;
00020 cout << "--------------------------" << endl;
00021
00022 char qm[100]; strcpy(qm,"finish_central_cut1_QM.hist.root");
00023 more=qm;
00024
00025 TFile* inRoot[2];
00026 inRoot[0] = new TFile(inName);
00027 inRoot[1] = new TFile(more);
00028 if(!inRoot[0] || !inRoot[1]){
00029 cout << "cannot find the infile" << endl;
00030 return;
00031 }
00032 cout << "file 2=" << more << endl;
00033
00034
00035 TString trigger[2]; trigger[0]=inName; trigger[1]="QM";
00036 trigger[0].Remove(0,trigger[0].Last('/'));
00037
00038 TH1* h1[2]; TH1* ha[2]; TH1* hRatio;
00039 TGraphAsymmErrors* g[2];
00040
00041 TCanvas c1("c1","c1",400,500);
00042 float minpt=2,maxpt=6;
00043
00044
00045 const int nBin=2; const int nBase=2; const int nCharge=3;
00046 char* baseName[] = {"h1Raw","h1Corrected" };
00047 char* baseTitle[] = { "raw","corrected"};
00048 char* charge[] = { 0,"Plus","Minus"};
00049 int markerStyle[] = {4,8,2};
00050 char* oldcharge[] = {0,"plus","minus"};
00051
00052 gStyle->SetOptStat(0);
00053 gStyle->SetTitleBorderSize(0);
00054 for(int iCharge=0; iCharge<nCharge; iCharge++){
00055
00056 sprintf(title,"%s : %s/%s ",
00057 charge[iCharge],
00058 trigger[0].Data(),trigger[1].Data());
00059
00060
00061 c1.Clear();c1.cd(1); gPad->SetTickx(); gPad->SetTicky();
00062 gPad->SetGridx(); gPad->SetGridy();
00063
00064 for(int iBase=0; iBase<nBase; iBase++){
00065 setName(name,baseName[iBase],0,charge[iCharge]);
00066 h1[0]=(TH1*)inRoot[0]->Get(name);
00067 if(iBase==0){
00068 setName(name,baseName[iBase],1,oldcharge[iCharge]);
00069 }
00070 else{
00071 setName(name,baseName[iBase],1,3,oldcharge[iCharge]);
00072 }
00073
00074 h1[1]=(TH1*)inRoot[1]->Get(name);
00075 if(!h1[1])return;
00076
00077 hRatio=(TH1*)h1[0]->Clone();
00078 ha[iBase]=hRatio;
00079 hRatio->Divide(h1[1]);
00080 SetRange(hRatio->GetXaxis(),minpt,maxpt);
00081 hRatio->SetMarkerStyle(8); SetMinMax(hRatio,0.5,1.5);
00082
00083 hRatio->SetTitle(title);
00084 hRatio->SetMarkerStyle(markerStyle[iBase]);
00085 if(doScale)
00086 hRatio->Scale(1./hRatio->GetBinContent(hRatio->GetXaxis()->GetFirst()));
00087
00088
00089
00090
00091
00092
00093
00094 if(iBase==0){
00095 hRatio->Draw("e1");
00096 hRatio->GetXaxis()->SetTitle("pT (GeV/c)");
00097
00098 }
00099 else{
00100 hRatio->Draw("e1same");
00101 }
00102
00103 }
00104
00105 if(nBase>1){
00106 TLegend* l=new TLegend(.2,.7,.3,.80); l->SetBorderSize(0);
00107 l->SetFillColor(0);
00108 l->AddEntry(ha[0],"raw","p");
00109 l->AddEntry(ha[1],"corrected","p");
00110 l->Draw();
00111 }
00112 sTitle=hRatio->GetName();
00113 sTitle.Remove(sTitle.Last('.'));
00114 Print(&c1,psDir,sTitle.Data());
00115
00116 }
00117
00118 }
00119