00001 #include "commonmacro/common.h"
00002 #include "commonmacro/histutil.h"
00003
00004 void yieldEOverW(TString inName=
00005 "links/P01hi.minbias.2000.hist/hianalysis_1000.hist.root",
00006 const char* psDir="ps",
00007 int cut = 1,
00008 const char* outDir="./",
00009 const char* more = "west",
00010 float extraValue = 0)
00011 {
00012
00013 if(!strstr(inName.Data(),"east")){
00014 cout << "input must be east" << endl; return;
00015 }
00016
00017 TString inName2 = inName;
00018 inName2.ReplaceAll("east","west");
00019
00020 TFile* inRoot[2];
00021 inRoot[0] = new TFile(inName.Data());
00022 inRoot[1] = new TFile(inName2.Data());
00023
00024 cout << "--------------------------" << endl;
00025 cout << "in name east=" << inName << endl
00026 << "in name west=" << inName2 << endl
00027 << "ps dir=" << psDir << endl
00028 << "cut=" << cut << endl;
00029 cout << "--------------------------" << endl;
00030
00031 if(!inRoot[0]){
00032 cout << "cannot find the infile" << endl;
00033 return;
00034 }
00035
00036 TCanvas c1("c1","c1",400,500);
00037
00038 TH1* h1[2][2];
00039
00040 gStyle->SetOptStat(0); gStyle->SetPadGridX(1); gStyle->SetPadGridY(1);
00041
00042 TString sName,sTitle;
00043 int j;
00044 float minpt=2,maxpt=6;
00045 float mindca=-1.5, maxdca=1.5;
00046
00047 int n=2;
00048 char* baseName[] = { "h3PhiPrDcaXYGlPtPr","h3PhiGlDcaXYGlPtGl"};
00049
00050 gStyle->SetPadTickY(1);
00051
00052
00053
00054 for(int i=0; i<n; i++){
00055 TLegend legend(.1,.1,.25,.2);
00056 TH3* h3;
00057 for(int iew=0; iew<2; iew++){
00058 for(int ic=0; ic<2; ic++){
00059
00060
00061 sprintf(name,"%s.%s",sPM[ic].Data(),baseName[i]);
00062 h3 = (TH3*) inRoot[iew]->Get(name);
00063
00064
00065
00066 h1[iew][ic] =
00067 HistSlice(h3,name,"",
00068 0,-165,195,0,mindca,maxdca,
00069 "z","e");
00070 SetRange(h1[iew][ic]->GetXaxis(),minpt,maxpt);
00071
00072 sName=h1[iew][ic]->GetTitle();
00073 sName.Prepend(sEW[iew]);
00074 h1[iew][ic]->SetTitle(sName.Data());
00075
00076 }
00077 h1[iew][0]->SetMarkerStyle(4); h1[iew][1]->SetMarkerStyle(8);
00078
00079 }
00080
00081
00082 sprintf(name,"yieldV%sew",h3->GetZaxis()->GetTitle());
00083 sName=name;
00084 sprintf(title,"yield V %s %s (east/west)",h3->GetZaxis()->GetTitle(),
00085 h1[0][0]->GetTitle());
00086 sTitle=title;
00087
00088
00089 Divide(&c1,1,3,title,inName);c1.SetName(sName.Data());
00090
00091 int j=0; TLine* line=new TLine;
00092 for(int ic=0; ic<2; ic++){
00093 h1a = (TH1*)h1[0][ic]->Clone();
00094 h1a->Divide(h1[1][ic]);
00095 h1a->SetMinimum(0.5); h1a->SetMaximum(1.6);
00096 ReplaceTitle(h1a,sEW[0].Data(),"");
00097 sprintf(title,"%s (east/west)",sPM[ic].Data());
00098 h1a->SetXTitle(h1[0][ic]->GetXaxis()->GetTitle());
00099 h1a->SetTitle(title);
00100 c1.cd(ic+1); h1a->Draw("e");
00101
00102 TAxis* axis=h1a->GetXaxis();
00103 line->DrawLine(axis->GetBinLowEdge(axis->GetFirst()),1,
00104 axis->GetBinUpEdge(axis->GetLast()),1);
00105 }
00106 h1a=(TH1*)h1[0][0]->Clone();
00107 h1a->Add(h1[0][1]);
00108 h1b=(TH1*)h1[1][0]->Clone();
00109 h1b->Add(h1[1][1]);
00110 h1a->Divide(h1b); h1a->SetMinimum(0.5); h1a->SetMaximum(1.6);
00111 sprintf(title,"plus+minus (east/west)");
00112 h1a->SetMinimum(0.8); h1a->SetMaximum(1.2);
00113 h1a->SetTitle(title); c1.cd(3); h1a->Draw("e");
00114 line->DrawLine(axis->GetBinLowEdge(axis->GetFirst()),1,
00115 axis->GetBinUpEdge(axis->GetLast()),1);
00116 Print(&c1,psDir,c1.GetName());
00117
00118 }
00119
00120
00121
00122 for(int iew=0; iew<2; iew++){
00123 for(int ic=0; ic<2; ic++){
00124 sprintf(name,"%s.%s",sPM[ic].Data(),"RawVarBin");
00125 h1[iew][ic]=(TH1*)inRoot[iew]->Get(name);
00126 h1[iew][ic]->Sumw2();
00127
00128
00129 h1[iew][ic]->SetAxisRange(minpt,maxpt-.001);
00130 dump(h1[iew][ic]);
00131 }
00132 h1[iew][0]->SetMarkerStyle(4); h1[iew][1]->SetMarkerStyle(8);
00133 }
00134
00135
00136 sprintf(name,"yieldVptVarBinew");
00137 sprintf(title,"yield V ptPr (var binning) (east/west)");
00138
00139 Divide(&c1,1,3,title,inName);c1.SetName(name);
00140
00141 int j=0; TLine* line=new TLine;
00142 for(int ic=0; ic<2; ic++){
00143 h1a = (TH1*)h1[0][ic]->Clone();
00144 h1a->Divide(h1[1][ic]);
00145 h1a->SetMinimum(0.5); h1a->SetMaximum(1.6);
00146 ReplaceTitle(h1a,sEW[0].Data(),"");
00147 sprintf(title,"%s (east/west)",sPM[ic].Data());
00148 h1a->SetXTitle(h1[0][ic]->GetXaxis()->GetTitle());
00149 h1a->SetTitle(title);
00150 c1.cd(ic+1); h1a->Draw("e");
00151
00152 cout << h1a->GetBinContent(4) << "\t" << h1a->GetBinError(4) << endl;
00153
00154 TAxis* axis=h1a->GetXaxis();
00155 line->DrawLine(axis->GetBinLowEdge(axis->GetFirst()),1,
00156 axis->GetBinUpEdge(axis->GetLast()),1);
00157 }
00158 h1a=(TH1*)h1[0][0]->Clone();
00159 h1a->Add(h1[0][1]);
00160 h1b=(TH1*)h1[1][0]->Clone();
00161 h1b->Add(h1[1][1]);
00162 h1a->Divide(h1b); h1a->SetMinimum(0.5); h1a->SetMaximum(1.6);
00163 sprintf(title,"plus+minus (east/west)");
00164 h1a->SetMinimum(0.8); h1a->SetMaximum(1.2);
00165 h1a->SetTitle(title); c1.cd(3); h1a->Draw("e");
00166 line->DrawLine(axis->GetBinLowEdge(axis->GetFirst()),1,
00167 axis->GetBinUpEdge(axis->GetLast()),1);
00168 Print(&c1,psDir,c1.GetName());
00169
00170
00171 }