00001 #include "commonmacro/common.h"
00002 #include "commonmacro/histutil.h"
00003 #include "common/Name.cc"
00004
00005 void divideSpectra(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 const char* more = "west",
00011 float extraValue = 0)
00012 {
00013 cout << "--------------------------" << endl;
00014 cout << "in name=" << inName << endl
00015 << "ps dir=" << psDir << endl
00016 << "cut=" << cut << endl;
00017 cout << "--------------------------" << endl;
00018
00019
00020
00021 TFile* inRoot;
00022 inRoot = new TFile(inName);
00023 if(!inRoot){
00024 cout << "cannot find the infile" << endl;
00025 return;
00026 }
00027
00028 TH1* h1[2];
00029 TGraphAsymmErrors* g[2];
00030
00031 TCanvas c1("c1","c1",400,500);
00032 float minpt=2,maxpt=6;
00033
00034 const int nCharge=1;
00035 char* charge[] = { 0,"Plus","Minus"};
00036 const int nBin=1;
00037 float ratioMin=0.2,ratioMax=1.5;
00038 float ptMin=2,ptMax=6;
00039
00040 char name1[100],name2[100];
00041
00042 int nPair=2;
00043 char* namePair[][2]={
00044 {"h1Raw","h1EffCorrected"},
00045 {"h1Corrected","h1EffCorrected"}
00046 };
00047 int nx=1,ny=2;
00048
00049 gStyle->SetOptStat(0); gStyle->SetTitleBorderSize(0);
00050 gStyle->SetPadTickY(1); gStyle->SetPadTickX(1);
00051
00052
00053
00054
00055
00056 c1.Clear();
00057
00058 for(int ib=0; ib<nBin; ib++){
00059 for(int ic=0; ic<nCharge; ic++){
00060
00061 sprintf(title,"spectra ratios (binning %d, cut %d)",cut);
00062 Divide(&c1,nx,ny,title,inName);
00063
00064 for(int ip=0; ip<nPair; ip++){
00065 c1.cd(ip+1); gPad->SetGridx(); gPad->SetGridy();
00066 setName(name1,namePair[ip][0],ib,charge[ic]);
00067 cout << name1 << "\t";
00068 h1[0]=(TH1*)inRoot->Get(name1);
00069 setName(name2,namePair[ip][1],ib,charge[ic]);
00070 cout << name2 << endl;
00071 h1[1]=(TH1*)inRoot->Get(name2);
00072
00073 sprintf(title,"%s / %s",name1,name2);
00074 cout << h1[0]->GetBinContent(5)
00075 << "\t" << h1[1]->GetBinContent(5) << endl;
00076
00077 h1[0]->Divide(h1[1]);
00078 h1[0]->SetTitle(title);
00079 h1[0]->Draw("e");
00080
00081 h1[0]->SetAxisRange(ptMin,ptMax-.00001);
00082
00083 h1[0]->SetMinimum(); h1[0]->SetMaximum(1.2);
00084 }
00085
00086 if(ic==0)
00087 sprintf(title,"bin%d.divideSpectra",ib);
00088 else
00089 sprintf(title,"bin%d.%s.divideSpectra",ib,ic);
00090 Print(&c1,psDir,title);
00091 }
00092 }
00093 }