00001
00002 const int maxFiles=5;
00003
00004 void plReweight(){
00005
00006 gStyle->SetOptStat(00000);
00007 gStyle->SetOptDate(0);
00008
00009 char* iPath="./outEmb/";
00010 char* fileName[maxFiles]={"Wplus","Wminus","Wtau","Zany","Ze+e-Interf"};
00011 TH1F* h[maxFiles];
00012 for(int i=0; i<maxFiles; i++){
00013 TString file=iPath; file+=fileName[i];
00014 h[i]=plReweightX(file,fileName[i]);
00015 }
00016
00017
00018 outf=new TFile("zVertReweight.root","recreate");
00019 for(int j=0;j<maxFiles;j++)
00020 h[j]->Write();
00021 }
00022
00023
00024 TH1F* plReweightX(TString file, char* name){
00025
00026
00027 file+=".wana.hist.root";
00028 fd=new TFile(file);
00029
00030
00031 fdata=new TFile("/star/data01/pwg/stevens4/wAnalysis/xSecPaper/sl11b/data/run9setABCD.wana.hist.root");
00032
00033
00034 TH1F* simZ=fd->Get("muZv"); simZ->Rebin();
00035 TH1F* dataZ=fdata->Get("muZv"); dataZ->Rebin();
00036
00037 assert(simZ); assert(dataZ);
00038
00039
00040 TH1F* ratio=dataZ->Clone();
00041 ratio->Divide(simZ);
00042 ratio->Scale(1./ratio->GetBinContent(24));
00043 ratio->SetName(name);
00044
00045
00046
00047
00048 TH1F* test= simZ->Clone();
00049 for(int i=1; i<=test->GetNbinsX(); i++){
00050 float z=test->GetBinCenter(i);
00051 test->SetBinContent(i,test->GetBinContent(i)*ratio->GetBinContent(ratio->FindBin(z)));
00052 }
00053
00054 TCanvas *c1=new TCanvas("aa","bb",600,400);
00055 dataZ->Draw(); dataZ->SetTitle("; Z_{vertex} (cm)");
00056 test->SetLineColor(2);
00057 test->DrawNormalized("same",dataZ->Integral());
00058 simZ->SetLineColor(4);
00059 simZ->DrawNormalized("same",dataZ->Integral());
00060
00061
00062 TLegend *leg = new TLegend(0.6,0.65,0.9,0.9);
00063 leg->SetFillColor(0);
00064 leg->AddEntry(dataZ," Data Z_{vertex}","l");
00065 leg->AddEntry(simZ," Thrown MC Z_{vertex}","l");
00066 leg->AddEntry(test," Re-weighted MC Z_{vertex}","l");
00067 leg->Draw("same");
00068 c1->Print(Form("plots/vertReweight/%s.png",name));
00069 c1->Print(Form("plots/vertReweight/%s.eps",name));
00070
00071 return ratio;
00072
00073
00074 dataZ->Draw();
00075 simZ->SetLineColor(2);
00076 simZ->DrawNormalized("same",dataZ->GetEntries());
00077 dataZ->SetMinimum(1);
00078 gPad->SetLogy();
00079
00080 }