示例#1
0
文件: pstable.C 项目: adevress/root-1
void table(Float_t x1, Float_t x2, Float_t yrange, TText *t, 
   const char **symbol, Bool_t octal)
{
   Int_t i;
   Int_t n = 0;
   for (i=0;i<1000;i++) {
      if (!strcmp(symbol[i],"END")) break;
      n++;
   }
   Float_t y1  = 2.5;
   Float_t y2  = yrange - 0.5;
   Float_t dx  = (x2-x1)/5;
   Float_t dy  = (y2 - 1 -y1)/(n+1);
   Float_t y   = y2 - 1 - 0.7*dy;
   Float_t xc0 = x1  + 0.5*dx;
   Float_t xc1 = xc0 + dx;
   Float_t xc2 = xc1 + dx;
   Float_t xc3 = xc2 + dx;
   Float_t xc4 = xc3 + dx;
   TLine *line = new TLine();
   line->DrawLine(x1,y1,x1,y2);
   line->DrawLine(x1,y1,x2,y1);
   line->DrawLine(x1,y2,x2,y2);
   line->DrawLine(x2,y1,x2,y2);
   line->DrawLine(x1,y2-1,x2,y2-1);
   line->DrawLine(x1+  dx,y1,x1+  dx,y2);
   line->DrawLine(x1+2*dx,y1,x1+2*dx,y2);
   line->DrawLine(x1+3*dx,y1,x1+3*dx,y2);
   line->DrawLine(x1+4*dx,y1,x1+4*dx,y2);
   TText *tit = new TText(0,0,"a");
   tit->SetTextSize(0.015);
   tit->SetTextFont(72);
   tit->SetTextAlign(22);
   tit->DrawText(xc0,y2-0.6,"Input");
   tit->DrawText(xc1,y2-0.6,"Roman");
   tit->DrawText(xc2,y2-0.6,"Greek");
   tit->DrawText(xc3,y2-0.6,"Special");
   tit->DrawText(xc4,y2-0.6,"Zapf");
   char text[12];
   for (i=0;i<n;i++) {
      if (octal) {
         unsigned char value = *symbol[i];
         sprintf(text,"@\\ %3o",value);
      } else {
         strcpy(text,symbol[i]);
      }
      t->DrawText(xc0,y,text);
      sprintf(text,"%s",symbol[i]);
      t->DrawText(xc1,y,text);
      sprintf(text,"`%s",symbol[i]);
      t->DrawText(xc2,y,text);
      sprintf(text,"'%s",symbol[i]);
      t->DrawText(xc3,y,text);
      sprintf(text,"~%s",symbol[i]);
      t->DrawText(xc4,y,text);
      y -= dy;
   }
}
示例#2
0
void postprocess(TCanvas* c2, const char* name, Int_t rWrite, Int_t rPerformance) {

        if (rPerformance){

                TLatex *alice = new TLatex(0.65,0.47,"Performance");
                alice->SetNDC();
                alice->SetTextColor(myDarkRed);
                alice->SetTextFont(42);
                alice->SetTextSize(0.05);
                alice->SetLineWidth(2);
                alice->Draw();

                TLatex *alice2 = new TLatex(0.62,0.41,"LHC10h - Pass2");
                alice2->SetNDC();
                alice2->SetTextColor(myDarkRed);
                alice->SetTextFont(42);
                alice2->SetTextSize(0.05);
                alice2->SetLineWidth(2);
                alice2->Draw();

                TText *date = new TText(0.68,0.35,cStamp2);
                date->SetNDC();
                date->SetTextFont(42);
                date->SetTextSize(0.04);
                date->Draw();

                //Acquire canvas proportions
                Double_t AliLogo_LowX = 0.67;
                Double_t AliLogo_LowY = 0.53;
                Double_t AliLogo_Height = 0.22;
                //ALICE logo is a png file that is 821x798 pixels->should be wider than a square
                Double_t AliLogo_Width  = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw();

                TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height);
                //    myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment !
                myPadSetUp(myPadLogo,0,0,0,0);
                //myPadLogo->SetFixedAspectRatio(1);
                myPadLogo->Draw();
                myPadLogo->cd();
                TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png");
                myAliceLogo->Draw();
        }

        if (rWrite == 1)
                c2->SaveAs(Form("%s.png",name));

        if (rWrite == 2)
                c2->SaveAs(Form("%s.eps",name));

}
示例#3
0
void fill_with_text(TGraph *real, TGraph *down, TGraph *up, TVirtualPad *can, int scantype, std::string scanx = "") {
  can->cd();
  float xpos_of_text = 0.22;
  TLegend* this_leg = new TLegend(xpos_of_text,0.6,0.38,0.75);
  //TLegend* this_leg = new TLegend(xpos_of_text,0.55,0.45,0.75,"n_{jets} #geq 3"); // this was the style of the paper. 
  this_leg->SetFillColor(0);
  this_leg->SetBorderSize(0);
  this_leg->SetTextSize(0.035);
  //this_leg->SetTextSize(0.04); // paper style. 
  if(scantype==PlottingSetup::SMS||scantype==PlottingSetup::GMSB) {
    //this_leg->AddEntry(real,"#sigma^{prod} = #sigma^{NLO-QCD}" , "l");
    //this_leg->AddEntry(up,"#sigma^{prod} = 3 #times #sigma^{NLO-QCD}" , "l");
    //this_leg->AddEntry(down,"#sigma^{prod} = 1/3 #times #sigma^{NLO-QCD}" , "l");
    this_leg->AddEntry(real,"#sigma^{NLO-QCD}" , "l");
    this_leg->AddEntry(up,"3 #times #sigma^{NLO-QCD}" , "l");
    this_leg->AddEntry(down,"1/3 #times #sigma^{NLO-QCD}" , "l");
  } else {
    write_warning(__FUNCTION__,"Not implemented yet for mSUGRA");
  }
    
  this_leg->Draw();
  TText *title = write_text(xpos_of_text+0.005,0.52,"JZB");
  title->SetTextSize(0.04);
  title->SetTextAlign(13);
  title->SetTextFont(62);
  title->Draw();
  
  write_SMS_text( scantype, scanx, xpos_of_text );
  
//  //string legT5zz="pp #rightarrow  #tilde{g} #tilde{g}, #tilde{g} #rightarrow 2j + #chi^{0}_{1}, #chi^{0}_{1} #rightarrow Z + #tilde{G}";
//  string legT5zz="pp #rightarrow  #tilde{g} #tilde{g}, #tilde{g} #rightarrow 2j + #chi^{0}_{2}, #chi^{0}_{2} #rightarrow Z #chi^{0}_{1}";
//  string legT5zzl2="m(#tilde{q}) >> m(#tilde{g}), x = "+scanx;
//  string legT5zzl3=" GMSB";
//  TText *title = write_text(xpos_of_text,0.85,legT5zz);
//  title->SetTextAlign(11);
//  title->SetTextSize(0.035);
//  if(scantype!=PlottingSetup::mSUGRA) title->Draw("same");
//  TText *title2 = write_text(xpos_of_text,0.79,legT5zzl2);
//  title2->SetTextAlign(11);
//  title2->SetTextSize(0.035);
//  if(scantype!=PlottingSetup::mSUGRA) title2->Draw("same");
//  TText *title3 = write_text(0.40,0.79,legT5zzl3);
//  title3->SetTextAlign(11);
//  title3->SetTextSize(0.035);
//  title3->SetTextColor(kRed);
////  if(scantype==PlottingSetup::GMSB) title3->Draw("same");
  DrawPrelim();
  draw_diagonal_xchange( scantype, scanx );
}
void plot_example(){
 THStack *hs = new THStack("hs","");
   TH1F *h1 = new TH1F("h1","test hstack",10,-4,4);
   h1->FillRandom("gaus",20000);
   h1->SetFillColor(kRed);
   hs->Add(h1);
   TH1F *h2 = new TH1F("h2","test hstack",10,-4,4);
   h2->FillRandom("gaus",15000);
   h2->SetFillColor(kBlue);
   hs->Add(h2);
   TH1F *h3 = new TH1F("h3","test hstack",10,-4,4);
   h3->FillRandom("gaus",10000);
   h3->SetFillColor(kGreen);
   hs->Add(h3);
   TCanvas *cs = new TCanvas("cs","cs",10,10,700,900);
   TText T; T.SetTextFont(42); T.SetTextAlign(21);
   cs->Divide(2,2);
   cs->cd(1); hs->Draw(); T.DrawTextNDC(.5,.95,"Default drawing option");
   cs->cd(2); hs->Draw("nostack"); T.DrawTextNDC(.5,.95,"Option \"nostack\"");
   cs->cd(3); hs->Draw("nostackb"); T.DrawTextNDC(.5,.95,"Option \"nostackb\"");
   cs->cd(4); hs->Draw("lego1"); T.DrawTextNDC(.5,.95,"Option \"lego1\"");
}
示例#5
0
文件: event.C 项目: Y--/root
void event(){
   TCanvas *c1 = new TCanvas("c1","ROOT Event description",700,500);
   c1->Range(0,0,14,15.5);
   TPaveText *event = new TPaveText(1,13,3,15);
   event->SetFillColor(11);
   event->Draw();
   event->AddText("Event");
   TLine *line = new TLine(1.1,13,1.1,1.5);
   line->SetLineWidth(2);
   line->Draw();
   line->DrawLine(1.3,13,1.3,3.5);
   line->DrawLine(1.5,13,1.5,5.5);
   line->DrawLine(1.7,13,1.7,7.5);
   line->DrawLine(1.9,13,1.9,9.5);
   line->DrawLine(2.1,13,2.1,11.5);
   TArrow *arrow = new TArrow(1.1,1.5,3.9,1.5,0.02,"|>");
   arrow->SetFillStyle(1001);
   arrow->SetFillColor(1);
   arrow->Draw();
   arrow->DrawArrow(1.3,3.5,3.9,3.5,0.02,"|>");
   arrow->DrawArrow(1.5,5.5,3.9,5.5,0.02,"|>");
   arrow->DrawArrow(1.7,7.5,3.9,7.5,0.02,"|>");
   arrow->DrawArrow(1.9,9.5,3.9,9.5,0.02,"|>");
   arrow->DrawArrow(2.1,11.5,3.9,11.5,0.02,"|>");
   TPaveText *p1 = new TPaveText(4,1,11,2);
   p1->SetTextAlign(12);
   p1->SetFillColor(42);
   p1->AddText("1 Mbyte");
   p1->Draw();
   TPaveText *p2 = new TPaveText(4,3,10,4);
   p2->SetTextAlign(12);
   p2->SetFillColor(42);
   p2->AddText("100 Kbytes");
   p2->Draw();
   TPaveText *p3 = new TPaveText(4,5,9,6);
   p3->SetTextAlign(12);
   p3->SetFillColor(42);
   p3->AddText("10 Kbytes");
   p3->Draw();
   TPaveText *p4 = new TPaveText(4,7,8,8);
   p4->SetTextAlign(12);
   p4->SetFillColor(42);
   p4->AddText("1 Kbytes");
   p4->Draw();
   TPaveText *p5 = new TPaveText(4,9,7,10);
   p5->SetTextAlign(12);
   p5->SetFillColor(42);
   p5->AddText("100 bytes");
   p5->Draw();
   TPaveText *p6 = new TPaveText(4,11,6,12);
   p6->SetTextAlign(12);
   p6->SetFillColor(42);
   p6->AddText("10 bytes");
   p6->Draw();
   TText *text = new TText();
   text->SetTextAlign(12);
   text->SetTextSize(0.04);
   text->SetTextFont(72);
   text->DrawText(6.2,11.5,"Header:Event_flag");
   text->DrawText(7.2,9.5,"Trigger_Info");
   text->DrawText(8.2,7.5,"Muon_Detector: TOF");
   text->DrawText(9.2,5.5,"Calorimeters");
   text->DrawText(10.2,3.5,"Forward_Detectors");
   text->DrawText(11.2,1.5,"TPCs");
}
示例#6
0
文件: pstable.C 项目: adevress/root-1
void pstable()
{
// Display all possible types of ROOT/Postscript characters

   const char *symbol1[] =
      {"A","B","C","D","E","F","G","H","I","J","K","L","M","N",
       "O","P","Q","R","S","T","U","V","W","X","Y","Z",
       "0","1","2","3","4","5","6","7","8","9",
       ".",",","+","-","*","/","=","(",")","{","}","END"};

   const char *symbol2[] =
      {"a","b","c","d","e","f","g","h","i","j","k","l","m","n",
       "o","p","q","r","s","t","u","v","w","x","y","z",
       ":",";","@","\\","_","|","%",
       "@'","<",">","[","]","\42","@\43","@\136",
       "@\77","@\41","@&","$","@\176"," ","END"};

   const char *symbol3[] =
      {"\241","\242","\243","\244","\245","\246","\247","\250",
       "\251","\252","\253","\254","\255","\256","\257","\260",
       "\261","\262","\263","\264","\265","\266","\267","\270",
       "\271","\272","\273","\274","\275","\276","\277","\300",
       "\301","\302","\303","\304","\305","\306","\307","\310",
       "\311","\312","\313","\314","\315","\316","\317","END"};

   const char *symbol4[] =
      {"\321","\322","\323","\324","\325","\326","\327","\330",
       "\331","\332","\333","\334","\335","\336","\337","\340",
       "\341","\342","\343","\344","\345","\346","\347","\340",
       "\351","\352","\353","\354","\355","\356","\357","\360",
       "\361","\362","\363","\364","\365","\366","\367","\370",
       "\371","\372","\373","\374","\375","\376","\377","END"};

   const char *symbol5[] =
      {"\177","\200","\201","\202","\203","\204","\205","\206",
       "\207","\210","\211","\212","\213","\214","\215","\216",
       "\217","\220","\221","\222","\223","\224","\225","\226",
       "\227","\230","\231","\232","\233","\234","\235","\236",
       "\237","\240","END"};

   Float_t xrange = 18;
   Float_t yrange = 25;
   Int_t w = 650;
   Int_t h = w*yrange/xrange;
   
   TCanvas *c1 = new TCanvas("c1","c1",200,10,w,h);
   c1->Range(0,0,xrange,yrange);

   TText *t = new TText(0,0,"a");
   t->SetTextSize(0.02);
   t->SetTextFont(62);
   t->SetTextAlign(22);

   table(0.5,0.5*xrange-0.5,yrange,t,symbol1,0);
   table(0.5*xrange+0.5,xrange-0.5,yrange,t,symbol2,0);
   TText *tlabel = new TText(0,0,"a");
   tlabel->SetTextFont(72);
   tlabel->SetTextSize(0.018);
   tlabel->SetTextAlign(22);
   tlabel->DrawText(0.5*xrange,1.3,
      "Input characters are standard keyboard characters");
   c1->Modified();
   c1->Update();
   c1->Print("pstable1.ps");

   TCanvas *c2 = new TCanvas("c2","c2",220,20,w,h);
   c2->Range(0,0,xrange,yrange);

   table(0.5,0.5*xrange-0.5,yrange,t,symbol3,1);
   table(0.5*xrange+0.5,xrange-0.5,yrange,t,symbol4,1);
   tlabel->DrawText(0.5*xrange,1.3,
      "Input characters using backslash and octal numbers");
   c2->Modified();
   c2->Update();
   c2->Print("pstable2.ps");

   TCanvas *c3 = new TCanvas("c3","c3",240,20,w,h);
   c3->Range(0,0,xrange,yrange);

   table(0.5,0.5*xrange-0.5,yrange,t,symbol5,1);
   tlabel->DrawText(0.5*xrange,1.3,
      "Input characters using backslash and octal numbers");
   c3->Modified();
   c3->Update();
   c3->Print("pstable3.ps");
}
示例#7
0
// infilename - root file with relevant histograms
// system - PP,APAP,PP
// status - Pass,Fail
// rWrite - 0-no,1-png,2-eps
// rPerformance - 0-no,1-yes (ALICE logo etc.)
// bin: 0 - all, 1- 0:5, 2- 5:10, etc
void drawDCA(const char* infilename, const char* system, const char* status, Int_t rWrite, Int_t rPerformance, int isMC, Int_t bin, Int_t ptrange)
{

    myOptions(0);

    gROOT->ForceStyle();
    gStyle->SetPalette(1.0);

    TDatime now;
    int iDate = now.GetDate();
    int iYear=iDate/10000;
    int iMonth=(iDate%10000)/100;
    int iDay=iDate%100;
    char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun",
                      "Jul","Aug","Sep","Oct","Nov","Dec"};
    char cStamp1[25],cStamp2[25];
    sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear);
    sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear);

    TFile *f = new TFile(infilename, "read");

    // DCA xy
    TH2D* DCAxy =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%d","Pass", system,0));


    if (!bin) {
        int minMultBin = 0;
        int maxMultBin = 6; // 8
    }
    else {
        int minMultBin = bin-1;
        int maxMultBin = bin; // 8
    }

    // int minMultBin = 0;
    // int maxMultBin = 0; // 8

    double EvMultall = 0;

    for(int i = minMultBin; i<maxMultBin; i++) {

        TH2D* DCAxyN = (TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%d",status, system,i));
        DCAxy->Add(DCAxyN);

        cout<<i<<" "<<DCAxyN->GetEntries()<<endl;

        //delete hEvMult;
    }


    if (!isMC) {
        TCanvas *c2 = new TCanvas("DCA xy prim", "DCA xy prim");
        c2->SetGridx();
        c2->SetGridy();
        c2->SetFillColor(10);
        c2->SetRightMargin(1.9);
        c2->SetLogz();

        DCAxy->GetXaxis()->SetTitle("DCA_{XY} (cm)");
        DCAxy->GetXaxis()->SetRangeUser(-5.0,5.0);
        DCAxy->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
        // DCAxy->GetZaxis()->SetLabelSize(0.05);
        DCAxy->Draw("colz");
        postprocess(c2,Form("DCAxy%s",status),rWrite,rPerformance,system);

        // TCanvas *c4 = new TCanvas("DCA xy Projection X", "DCA xy Projection X");
        // c4->SetGridx();
        // c4->SetGridy();
        // c4->SetFillColor(10);
        // c4->SetRightMargin(1.9);
        // c4->SetLogy();

        gStyle->SetOptTitle(1);
        TCanvas *myCan = new TCanvas("myCan",cStamp1,600,400);
        myCan->Draw();
        myCan->cd();

        TPad *myPad = new TPad("myPad", "The pad",0,0,1,1);
        myPadSetUp(myPad,0.15,0.04,0.04,0.15);
        myPad->Draw();
        myPad->SetLogy();

        myPad->cd();

        if (ptrange == 0) {
            TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",1,100);
            pripp->SetTitle("0.5 < #it{p}_{T} < 3 GeV/#it{c}");
        }
        else if (ptrange == 1) {
            TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",15,33);
            pripp->SetTitle("0.5 < #it{p}_{T} < 1 GeV/#it{c}");
        }
        else if (ptrange == 2) {
            TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",33,100);
            pripp->SetTitle("1 < #it{p}_{T} < 3 GeV/#it{c}");
        }

        pripp->SetYTitle("Number of Entries (normalized)");
        pripp->GetXaxis()->SetTitleSize(0.068);
        pripp->GetYaxis()->SetTitleSize(0.068);
        pripp->GetXaxis()->SetLabelSize(0.058);
        pripp->GetYaxis()->SetLabelSize(0.058);

        // pripp->SetLabelSize(0.05);
        // DCAxy->ProjectionX("asd",50,100)->SetYTitle("Number of Entries");
        // DCAxy->ProjectionX("asd",50,100)->SetTitle("1.0 < p_{T} < 2.0 GeV");
        // DCAxy->ProjectionX("asd",0,200)->SetTitle("");
        // DCAxy->ProjectionX("asd",50,100)->GetXaxis()->SetNdivisions(8);
        // DCAxy->ProjectionX("asd",50,100)->GetYaxis()->SetNdivisions(8);
        // DCAxy->ProjectionX("asd",50,100)->GetXaxis()->SetTitleSize(0.05);
        // DCAxy->ProjectionX("asd",50,100)->GetYaxis()->SetTitleSize(0.05);
        // DCAxy->ProjectionX("asd",50,100)->GetXaxis()->SetLabelSize(0.05);
        // DCAxy->ProjectionX("asd",50,100)->GetYaxis()->SetLabelSize(0.05);

        pripp->Draw("");

        //if (!isMC) {
        pripp->Scale(1./pripp->Integral());
        TFile* fout = new TFile("dca.root","update");
        pripp->SetName(Form("dcaxyMC%d",isMC));
        pripp->Write();
        //}

        postprocess(myCan,Form("DCAxy%sProX",status),rWrite,rPerformance,system);

    }
    else if (isMC) {

        TH2D* primp =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%dprim","Pass", system,0));
        TH2D* weakp =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%dweak","Pass", system,0));
        TH2D* matp =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%dmat","Pass", system,0));

        // prim 2D
        TCanvas *c3prim = new TCanvas("DCA xy primary", "DCA xy primary");
        c3prim->SetGridx();
        c3prim->SetGridy();
        c3prim->SetFillColor(10);
        c3prim->SetRightMargin(1.9);
        c3prim->SetLogz();

        primp->GetXaxis()->SetTitle("DCA_{XY} (cm)");
        primp->GetXaxis()->SetRangeUser(-5.0,5.0);
        primp->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
        primp->GetZaxis()->SetLabelSize(0.03);
        primp->Draw("colz");
        postprocess(c3prim,Form("DCAxy%s",status),rWrite,rPerformance,system);

        // weak 2D
        TCanvas *c3 = new TCanvas("DCA xy weak", "DCA xy weak");
        c3->SetGridx();
        c3->SetGridy();
        c3->SetFillColor(10);
        c3->SetRightMargin(1.9);
        c3->SetLogz();

        weakp->GetXaxis()->SetTitle("DCA_{XY} (cm)");
        weakp->GetXaxis()->SetRangeUser(-5.0,5.0);
        weakp->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
        weakp->GetZaxis()->SetLabelSize(0.03);
        weakp->Draw("colz");
        postprocess(c3,Form("DCAxy%s",status),rWrite,rPerformance,system);

        // mat 2D
        TCanvas *c4 = new TCanvas("DCA xy mat", "DCA xy mat");
        c4->SetGridx();
        c4->SetGridy();
        c4->SetFillColor(10);
        c4->SetRightMargin(1.9);
        c4->SetLogz();

        matp->GetXaxis()->SetTitle("DCA_{XY} (cm)");
        matp->GetXaxis()->SetRangeUser(-5.0,5.0);
        matp->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
        matp->GetZaxis()->SetLabelSize(0.03);
        matp->Draw("colz");
        postprocess(c4,Form("DCAxy%s",status),rWrite,rPerformance,system);


        // prim proj
        gStyle->SetOptTitle(1);

        TCanvas *myCan3prim = new TCanvas("myCan3prim",cStamp1);
        myCan3prim->Draw();
        myCan3prim->cd();

        TPad *myPad3prim = new TPad("myPad3prim", "The pad3prim",0,0,1,1);
        myPadSetUp(myPad3prim,0.15,0.04,0.04,0.15);
        myPad3prim->Draw();
        myPad3prim->SetLogy();

        myPad3prim->cd();

        TH1D* primpp = (TH1D*)primp->ProjectionX("zxc22",0,100);
        primpp->Draw("");

        cout << primpp->FindBin(-0.1) << endl;
        cout << primpp->FindBin(0.1) << endl;

        cout << "primary in cut- " << primpp->Integral(191,211) << endl;
        cout << "primary all- " << primpp->Integral(1,400) << endl;

        postprocess(myCan3prim,Form("DCAxy%sProX",status),rWrite,rPerformance,system);


        // weak proj
        TCanvas *myCan3 = new TCanvas("myCan3",cStamp1);
        myCan3->Draw();
        myCan3->cd();

        TPad *myPad3 = new TPad("myPad3", "The pad3",0,0,1,1);
        myPadSetUp(myPad3,0.15,0.04,0.04,0.15);
        myPad3->Draw();
        myPad3->SetLogy();

        myPad3->cd();

        TH1D* weakpp = (TH1D*)weakp->ProjectionX("zxc2",0,100);
        weakpp->Draw("");

        cout << "weak in cut- " << weakpp->Integral(191,211) << endl;
        cout << "weak all- " << weakpp->Integral(1,400) << endl;

        postprocess(myCan3,Form("DCAxy%sProX",status),rWrite,rPerformance,system);

        // mat proj
        gStyle->SetOptTitle(1);
        TCanvas *myCan4 = new TCanvas("myCan4",cStamp1);
        myCan4->Draw();
        myCan4->cd();

        TPad *myPad4 = new TPad("myPad4", "The pad4",0,0,1,1);
        myPadSetUp(myPad4,0.15,0.04,0.04,0.15);
        myPad4->Draw();
        myPad4->SetLogy();

        myPad4->cd();

        TH1D* matpp = (TH1D*)matp->ProjectionX("zxc3",0,100);
        matpp->Draw("");

        cout << "material in cut- " << matpp->Integral(191,211) << endl;
        cout << "material all- " << matpp->Integral(1,400) << endl;

        postprocess(myCan4,Form("DCAxy%sProX",status),rWrite,rPerformance,system);

        cout  << "in cut: " << endl;
        cout << "prim - " << primpp->Integral(191,211) / (primpp->Integral(191,211)+weakpp->Integral(191,211)+matpp->Integral(191,211)) << endl;
        cout << "weak - " << weakpp->Integral(191,211) / (primpp->Integral(191,211)+weakpp->Integral(191,211)+matpp->Integral(191,211)) << endl;
        cout << "mat - " << matpp->Integral(191,211) / (primpp->Integral(191,211)+weakpp->Integral(191,211)+matpp->Integral(191,211)) << endl;

        cout << endl << "in cut / all " << endl;
        cout << "prim - " << primpp->Integral(191,211) / primpp->Integral(1,400) << endl;
        cout << "weak - " << weakpp->Integral(191,211) / weakpp->Integral(1,400) << endl;
        cout << "mat - " << matpp->Integral(191,211) / matpp->Integral(1,400) << endl;


        // _____sum____

        TH2D* psum = new TH2D("psum","",400, -2.0, 2.0, 100,0.0,2.0);
        psum->GetXaxis()->SetTitle("DCA_{xy} (cm)");
        psum->GetYaxis()->SetTitle("Number of Entries (normalized)");
        psum->GetXaxis()->SetLimits(-2,2);


        for (int i = 0; i < primp->GetNbinsX(); i++) {
            for (int j = 0; j < primp->GetNbinsY(); j++) {
                psum->SetBinContent(i,j,primp->GetBinContent(i,j)+weakp->GetBinContent(i,j)+matp->GetBinContent(i,j));
            }
        }

        gStyle->SetOptStat(0);

        TCanvas *cansum = new TCanvas("cansum",cStamp1,600,400);
        cansum->Draw();
        cansum->cd();

        TPad *padsum = new TPad("padsum", "The pad4",0,0,1,1);
        myPadSetUp(padsum,0.15,0.04,0.04,0.15);
        padsum->Draw();
        padsum->SetLogy();

        padsum->cd();

        // TCanvas* cansum = new TCanvas("cansum","cansum");
        // cansum->SetLogy();
        //psum->Draw("colz");
        TH1D* asd0 = (TH1D*)psum->ProjectionX("zxc",0,100);

        // asd0->Scale(1./asd0->Integral());
        // TFile* fout = new TFile("dca.root","update");
        // asd0->SetName(Form("dcaxyMC%d",isMC));
        // asd0->Write();

        asd0->GetXaxis()->SetTitle("DCA_{xy} (cm)");
        asd0->GetYaxis()->SetTitle("Number of Entries (normalized)");
        //asd0->SetMaximum(5000);
        //asd0->SetMinimum(0.00008);
        asd0->GetXaxis()->SetNdivisions(8);
        asd0->GetYaxis()->SetNdivisions(8);
        //asd0->GetYaxis()->SetTitleOffset(1.4);
        asd0->GetXaxis()->SetTitleSize(0.068);
        asd0->GetYaxis()->SetTitleSize(0.068);
        asd0->GetXaxis()->SetLabelSize(0.058);
        asd0->GetYaxis()->SetLabelSize(0.058);
        asd0->SetFillColor(kBlack);

        Double_t norm = asd0->Integral();
        //asd0->Scale(1./norm);
        //asd0->SetMinimum(0.00007);

        asd0->SetMarkerSize(1.3);
        asd0->SetMarkerColor(kBlack);
        asd0->SetMarkerStyle(20);
        asd0->Draw("pc");

        primpp->SetFillColor(kGreen+2);
        //primpp->Scale(1./norm);
        primpp->SetMarkerSize(1.3);
        primpp->SetMarkerColor(kGreen+2);
        primpp->SetMarkerStyle(20);
        primpp->Draw("psame");

        matpp->SetFillColor(kRed);
        //matpp->Scale(1./norm);
        matpp->SetMarkerSize(1.3);
        matpp->SetMarkerColor(kRed);
        matpp->SetMarkerStyle(20);
        matpp->Draw("psame");

        weakpp->SetFillColor(kBlue);
        //weakpp->Scale(1./norm);
        weakpp->SetMarkerSize(1.3);
        weakpp->SetMarkerColor(kBlue);
        weakpp->SetMarkerStyle(20);
        weakpp->Draw("psame");



        // _____endofsum____


        TLegend *myLegend = new TLegend(0.6,0.6,0.89,0.89);
        myLegend->SetFillColor(10);
        myLegend->SetBorderSize(0);

        myLegend->AddEntry(asd0,"all","f");
        myLegend->AddEntry(primpp,"primary","f");
        myLegend->AddEntry(weakpp,"weak decay","f");
        myLegend->AddEntry(matpp,"material","f");
        //myLegend->Draw("same");


        // logo

        TLatex *sys = new TLatex(0.16,0.91,"AMPT Pb-Pb #sqrt{s_{NN}} = 2.76 TeV");
        sys->SetNDC();
        sys->SetTextFont(42);
        sys->SetTextSize(0.05);
        sys->SetTextColor(kRed+2);
        sys->Draw();

        TDatime now;
        int iDate = now.GetDate();
        int iYear=iDate/10000;
        int iMonth=(iDate%10000)/100;
        int iDay=iDate%100;
        char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun",
                          "Jul","Aug","Sep","Oct","Nov","Dec"};
        char cStamp1[25],cStamp2[25];
        sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear);
        sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear);


        TText *date = new TText(0.27,0.5,cStamp2);
        date->SetNDC();
        date->SetTextFont(42);
        date->SetTextSize(0.04);
        date->Draw();

        //           //Acquire canvas proportions
//                 Double_t AliLogo_LowX = 0.27;
//                 Double_t AliLogo_LowY = 0.6;
//                 Double_t AliLogo_Height = 0.22;
//                 //ALICE logo is a png file that is 821x798 pixels->should be wider than a square
//                 Double_t AliLogo_Width  = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw();

//                 TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height);
//                 //    myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment !
//                 myPadSetUp(myPadLogo,0,0,0,0);
//                 myPadLogo->SetFixedAspectRatio(1);
//                 myPadLogo->Draw();
//                 myPadLogo->cd();

// //                TASImage *myAliceLogo = new TASImage("alice_preliminary.eps");
//                 TASImage *myAliceLogo = new TASImage("alice_performance.eps");
// //		TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png");
//                 myAliceLogo->Draw();

        DrawALICELogo(0,0.27,0.55,0.7,0.8);

//logo

        // postprocess(cansum,Form("DCAxyMC%s",status),rWrite,rPerformance,system);
        cansum->SaveAs("DCAxyMC.png");
        cansum->SaveAs("DCAxyMC.eps");
    }

//__________________________________________________


}
示例#8
0
void plottingmacro_IVF()
{


  double fa = 0.46502;
  double fb = 0.53498;
  bool debug_ = true;

  //  std::string path("Nov10thFall11Plots/");
  //  std::string path("Nov10Fall1160MTopSlimPlots/");
  std::string path("Nov10Fall1160MTopIVFPlots_b/");

  if(debug_)
    std::cout << "Init the style form setTDRStyle" << std::endl;
  setTDRStyle();
  gStyle->SetErrorX(0.5);
  gROOT->ForceStyle();
  initOptions();
  

  if(debug_)
    std::cout << "Init the sample" << std::endl;
  //  std::vector<Sample> s = Nov10thDiJetPtUpdatedSlimHistos();
  //std::vector<Sample> s = Nov10Fall1160MTopSlimHistos();
  std::vector<Sample> s = Nov10Fall1160MTopIVFHistos();

  Sample data(1,"fake data","S1.root",0,true,1000);

  if(debug_)
    std::cout << "Init the data sample" << std::endl;
  for(size_t i=0;i< s.size();i++) if(s[i].data) {data=s[i];break;}

  if(debug_)
    std::cout << "Ls data sample" << std::endl;
  data.file()->ls(); 

  if(debug_)
    std::cout << "Init the mc sample" << std::endl;
  for(size_t i=0;i< s.size();i++) s[i].dump(1,fa,fb);

  std::vector<std::string> names;

  if(debug_)
    std::cout << "Get List of Keys" << std::endl;
  TList * subs = data.file()->GetListOfKeys();
  for(size_t i=0;i< subs->GetSize();i++)
    {
      TString nn = subs->At(i)->GetName();
      if( nn.Contains(TRegexp("Count*")) )
	continue;
      if(debug_)
	std::cout << "Get List of Keys in subdirs" << std::endl;
      TList * objs = ((TDirectoryFile *)data.file()->Get(subs->At(i)->GetName()))->GetListOfKeys();
      for(size_t j=0;j< objs->GetSize();j++)
	{
	  if(debug_)
	    std::cout << "Name = " << subs->At(i)->GetName()+std::string("/")  + objs->At(j)->GetName() << std::endl;
	  names.push_back(subs->At(i)->GetName()+std::string("/")  + objs->At(j)->GetName());
	  //      std::cout << subs->At(i)->GetName() << "/"  << objs->At(j)->GetName() << std::endl;
	  //TODO: select plots via regexp
	}
    }


  if(debug_)
    std::cout << "Starting plotting" << std::endl;

  std::string process;

  for(size_t i = 0 ; i < names.size() ; i++) 
    {
      
      std::map<std::string,TH1F *> grouped;
      TString n=names[i];
      //      if(!n.Contains(TRegexp("VlightRegionHZee/HiggsPtVlightRegionHZee"))) continue;
      //      if(!n.Contains(TRegexp("VlightRegionHZee/ZPtVlightRegionHZee"))) continue;
      //      if(!n.Contains(TRegexp("VlightRegionHZee"))) continue;
      //      if(!n.Contains(TRegexp("ZSVRegionZmmSV"))) continue;
      //      if(!n.Contains(TRegexp("ZSVRegionZeeSV"))) continue;
      //      if(!n.Contains(TRegexp("ZSVRegionZcombSV"))) continue;
      //      if(!n.Contains(TRegexp("ZSVPureRegionZcombSV"))) continue;
      //      if(!n.Contains(TRegexp("ZSVTTbarPureRegionZcombSV"))) continue;
      if(!n.Contains(TRegexp("TTbarRegionZeeSVJets"))) continue;

      if(n.Contains(TRegexp("RegionHZcomb")))
	process = "Z(l^{+}l^{-})H(b#bar{b})";
      if(n.Contains(TRegexp("RegionHZmm")))
	process = "Z(#mu^{+}#mu^{-})H(b#bar{b})";
      if(n.Contains(TRegexp("RegionHZee")))
	process = "Z(e^{+}e^{-})H(b#bar{b})";

      if(debug_)
	std::cout << "Creating the Canvas" << std::endl;

      TCanvas *c = new TCanvas();
      c->SetLogy(false);
      c->SetTitle(names[i].c_str());

      if(debug_)
	std::cout << "Creating histograms" << std::endl;
  
      TH1F *hd = ((TH1F*)data.file()->Get(names[i].c_str()));
      hd->Sumw2();
      Options o=options[names[i]];
      //      hd->Rebin(o.rebin);
      hd->SetMarkerStyle(20);
      hd->GetXaxis()->SetLabelOffset(99);
      hd->SetYTitle(o.yaxis.c_str());
      double nbin = hd->GetNbinsX();
      double min_bin = hd->GetXaxis()->GetXmin();
      double max_bin = hd->GetXaxis()->GetXmax();
      TH1F *hmc = new TH1F("hmc","hmc", nbin, min_bin, max_bin);
      hmc->SetFillColor(kWhite);
      hmc->Sumw2();
      //      hmc->Rebin(o.rebin);

      if(debug_)
	std::cout << "Creating the THStack and Legend" << std::endl;
      THStack * sta = new THStack("sta",hd->GetTitle());
      TLegend * l = new TLegend(o.legendx1,o.legendy1,o.legendx2,o.legendy2); //0.7,0.1,0.9,0.6);
      l->SetFillColor(kWhite);
      l->SetBorderSize(0);
      l->SetTextFont(62);
      l->SetTextSize(0.03);
      if(debug_)
	std::cout << "Adding data to the legend" << std::endl;  
      l->AddEntry(hd, "Data","P");
      if(debug_)
	std::cout << "Adding MC to the THStack" << std::endl;  

      //with the proper trigger eff
      //      double SF[] = {1.01,1.03,1.00};
      //      double SF[] = {1.03,1.054,1.032};
      double SF[] = {1.0,1.0,1.0};

      if(debug_){
	for(int i = 0; i< 3; ++i)
	  std::cout << "SF [" << i << "] = " << SF[i] << std::endl;
      }

      double mcIntegral=0;
      for(size_t j=0;j< s.size() ;j++) 
	{ 
	  if(!s[j].data) 
	    {
	      if(debug_)
		std::cout << "Creating TH1F from file " << s[j].name << std::endl;  
	      TH1F * h = ((TH1F*)s[j].file()->Get(names[i].c_str()));
	      h->Sumw2();
	      if(debug_){
		std::cout << "TH1F created from file " << s[j].name << std::endl;  
		std::cout << "Scaling : " << s[j].scale(data.lumi(),fa,fb) << std::endl;  
		std::cout << "Scaling with SF : " << s[j].scale(data.lumi(),fa,fb,SF) << std::endl;  
		std::cout << "Histo integral before scaling = " << h->Integral() << std::endl;
	      }
	      h->Scale(s[j].scale(data.lumi(),fa,fb,SF));
	      if(debug_){
		std::cout << "Histo integral after scaling = " << h->Integral() << std::endl;
		std::cout << "Managing style... " << std::endl;  
	      }
	      h->SetLineWidth(1.);
	      h->SetFillColor(s[j].color);
	      h->SetLineColor(s[j].color);
	      //	      h->Rebin(options[names[i]].rebin);
	      if(debug_)
		std::cout << "Cloning and update legend " << std::endl;  
	      if(grouped.find(s[j].name) == grouped.end()){
		l->AddEntry(h,s[j].name.c_str(),"F");
	      }
	      std::cout << "Sample : " << s[j].name << " - Integral for plot " << names[i] << " = " << h->Integral(-10000,10000) << std::endl;
	      mcIntegral += h->Integral();
	      sta->Add(h);
	      hmc->Add(h);	      
	      //TO FIX grouped map
	      // sovrascrive histo con lo stesso nome tipo VV o ST etc...
	      grouped[s[j].name]=(TH1F *)h->Clone(("_"+names[i]).c_str());
	    }
	}

      if(debug_){
	std::cout << "Data total = " << hd->Integral() << std::endl;
	std::cout << "MC = " << mcIntegral << std::endl;
	std::cout << "Data/MC = " << hd->Integral()/mcIntegral << std::endl;
      }

      TPad * TopPad = new TPad("TopPad","Top Pad",0.,0.3,1.,1. ) ;
      TPad * BtmPad = new TPad("BtmPad","Bottom Pad",0.,0.,1.,0.313 ) ;
      TopPad->SetBottomMargin(0.02);
      BtmPad->SetTopMargin(0.0);
      BtmPad->SetFillStyle(4000);
      TopPad->SetFillStyle(4000);
      BtmPad->SetFillColor(0);
      BtmPad->SetBottomMargin(0.35);
      TopPad->Draw() ;
      BtmPad->Draw() ;
      std::cout << "hd maximum = " << hd->GetMaximum() << "  sta maximum = " << sta->GetMaximum() << std::endl;
      double maxY;
      if(hd->GetMaximum() > sta->GetMaximum()) maxY = (hd->GetMaximum())*1.5;
      else maxY = (sta->GetMaximum())*1.5;
      TopPad->cd();
      hd->Draw("E1X0");
      sta->Draw("sameHIST");
      hmc->Draw("sameE2");
      hmc->SetFillColor(2);
      hmc->SetMarkerSize(0);
      hmc->SetFillStyle(3013);
      hd->Draw("E1X0same");
      l->Draw("same");
      std::cout << "Set Maximum to = " << maxY << std::endl;
      hd->GetYaxis()->SetRangeUser(0.,maxY);
      hd->GetXaxis()->SetRangeUser(options[names[i]].min,options[names[i]].max);

      BtmPad->cd();
      std::cout << "Division" << std::endl;

      TH1D * divisionErrorBand = (TH1D*)(hmc)->Clone("divisionErrorBand");
      divisionErrorBand->Sumw2();
      divisionErrorBand->Divide(hmc);
      divisionErrorBand->Draw("E2");      
      divisionErrorBand->SetMaximum(2.49);
      divisionErrorBand->SetMinimum(0);
      divisionErrorBand->SetMarkerStyle(20);
      divisionErrorBand->SetMarkerSize(0.55);
      divisionErrorBand->GetXaxis()->SetTitleOffset(1.12);
      divisionErrorBand->GetXaxis()->SetLabelSize(0.12);
      divisionErrorBand->GetXaxis()->SetTitleSize(0.5);
      divisionErrorBand->GetYaxis()->SetTitle("Data/MC");
      divisionErrorBand->GetYaxis()->SetLabelSize(0.12);
      divisionErrorBand->GetYaxis()->SetTitleSize(0.12);
      divisionErrorBand->GetYaxis()->SetTitleOffset(0.40);
      divisionErrorBand->GetYaxis()->SetNdivisions(505);
      //divisionErrorBand->UseCurrentStyle();
      divisionErrorBand->SetFillColor(2);
      divisionErrorBand->SetFillStyle(3001);
      divisionErrorBand->SetMarkerSize(0.);

      TH1D * division = (TH1D*)(hd)->Clone("division");
      division->Sumw2();
      division->Divide(hmc);
//       division->SetMaximum(2.5);
//       division->SetMinimum(0);
//       division->SetMarkerStyle(20);
//       division->SetMarkerSize(0.55);
//       division->GetXaxis()->SetLabelSize(0.12);
//       division->GetXaxis()->SetTitleSize(0.14);
//       division->GetYaxis()->SetLabelSize(0.10);
//       division->GetYaxis()->SetTitleSize(0.10);
//      division->GetYaxis()->SetTitle("Data/MC");
      Double_t min = division->GetXaxis()->GetXmin();
      Double_t max = division->GetXaxis()->GetXmax();
      division->Draw("E1X0same");

      TLine *line = new TLine(min, 1.0, max, 1.0);
      line->SetLineColor(kRed);
      line->Draw("same");
      
      TLegend * leg3 =new TLegend(0.50,0.86,0.69,0.96);
      leg3->AddEntry(divisionErrorBand,"MC uncert. (stat.)","f");
      leg3->SetFillColor(0);
      leg3->SetLineColor(0);
      leg3->SetShadowColor(0);
      leg3->SetTextFont(62);
      leg3->SetTextSize(0.06);
      leg3->Draw();

      TPaveText *pave = new TPaveText(0.15,0.85,0.32,0.96,"brNDC");
      pave->SetTextAlign(12);
      pave->SetLineColor(0);
      pave->SetFillColor(0);
      pave->SetShadowColor(0);
      //TText *text = pave->AddText(Form("#chi_{#nu}^{2} = %.3f, K_{s} = %.3f",histDt->Chi2Test(histCopyMC5,"UWCHI2/NDF"),histDt->KolmogorovTest(histCopyMC5))); // stat + sys
      TText *text = pave->AddText(Form("#chi_{#nu}^{2} = %.3f, K_{s} = %.3f",hd->Chi2Test(hmc,"UWCHI2/NDF"),hd->KolmogorovTest(hmc))); // stat only
      text->SetTextFont(62);
      text->SetTextSize(0.08);
      pave->Draw();

      TopPad->cd();
      TLatex latex;
      latex.SetNDC();
      latex.SetTextAlign(12);
      latex.SetTextSize(0.052);
      latex.DrawLatex(0.17,0.89,"CMS Preliminary");
      latex.SetTextSize(0.04);
      latex.DrawLatex(0.17,0.84,"#sqrt{s} = 7 TeV, L = 4.7 fb^{-1}");
      //      latex.DrawLatex(0.17,0.79,"Z(e^{+}e^{-})H(b#bar{b})");
      latex.DrawLatex(0.17,0.79,process.c_str());
      c->Update();
      std::string cName= hd->GetName();
      cName += "_bare.pdf";
      cName = path+cName;
      c->Print(cName.c_str(),"pdf");

//       std::cout << names[i] << " d: " <<  hd->Integral() << " ";
//       THStack * sta2 = new THStack("sta2",hd->GetTitle());
//       float tot=0;
//       float toterr2=0;

//       if(debug_)
// 	std::cout << "Putting the iterator in the for loop" << std::endl;
//       for(std::map<std::string,TH1F *>::reverse_iterator it=grouped.rbegin(); it!=grouped.rend();++it)
//  	{
// 	  if(debug_)
// 	    std::cout << "Using the iterator" << std::endl;
// 	  std::cout << (*it).first << " " << (*it).second->Integral() << " | " << std::endl ;
// 	  if((*it).second->GetEntries() > 0) {
// 	    float er=1.*sqrt((*it).second->GetEntries())/(*it).second->GetEntries()*(*it).second->Integral();
// 	    toterr2+=er*er;
// 	  }
// 	  tot+=(*it).second->Integral();
// 	  sta2->Add(it->second);
//  	}
//       std::cout << " Tot: " << tot << "+-" << sqrt(toterr2) <<  " SF: " << hd->Integral()/tot << std::endl;
//       TCanvas *c2 = new TCanvas();
//       c2->SetTitle(names[i].c_str());
//       std::cout << "hd maximum = " << hd->GetMaximum() << "  sta2 maximum = " << sta2->GetMaximum() << std::endl;
//       if(hd->GetMaximum() > sta2->GetMaximum()) maxY =  hd->GetBinContent(hd->GetMaximumBin()) * 1.5;
//       else maxY = ( sta2->GetMaximum())*1.5;
//       //      hd->Draw("E1"); 
//       sta2->Draw("PADSHIST");
//       //    hd->Draw("E1same");
//       //      l->Draw("same");
//       std::cout << "Set Maximum to = " << maxY << std::endl;
//       hd->GetYaxis()->SetRangeUser(0.,maxY);
//       hd->GetXaxis()->SetRangeUser(options[names[i]].min,options[names[i]].max);
//       c2->Update();

//       std::string c2Name = hd->GetName();
//       c2Name = path+c2Name;
//       c2Name += "_norm.pdf";
//       c2->Print(c2Name.c_str(),"pdf");  

    }

}
示例#9
0
// all users - please change the name of this file to lhcbStyle.C
// Commits to lhcbdocs svn of .C files are not allowed
void lhcbStyle(){

  // define names for colours
  Int_t black  = 1;
  Int_t red    = 2;
  Int_t green  = 3;
  Int_t blue   = 4;
  Int_t yellow = 5; 
  Int_t magenta= 6;
  Int_t cyan   = 7;
  Int_t purple = 9;
  

////////////////////////////////////////////////////////////////////
// PURPOSE:
//
// This macro defines a standard style for (black-and-white) 
// "publication quality" LHCb ROOT plots. 
//
// USAGE:
//
// Include the lines
//   gROOT->ProcessLine(".L lhcbstyle.C");
//   lhcbStyle();
// at the beginning of your root macro.
//
// Example usage is given in myPlot.C
//
// COMMENTS:
//
// Font:
// 
// The font is chosen to be 132, this is Times New Roman (like the text of
//  your document) with precision 2.
//
// "Landscape histograms":
//
// The style here is designed for more or less square plots.
// For longer histograms, or canvas with many pads, adjustements are needed. 
// For instance, for a canvas with 1x5 histograms:
//  TCanvas* c1 = new TCanvas("c1", "L0 muons", 600, 800);
//  c1->Divide(1,5);
//  Adaptions like the following will be needed:
//  gStyle->SetTickLength(0.05,"x");
//  gStyle->SetTickLength(0.01,"y");
//  gStyle->SetLabelSize(0.15,"x");
//  gStyle->SetLabelSize(0.1,"y");
//  gStyle->SetStatW(0.15);
//  gStyle->SetStatH(0.5);
//
// Authors: Thomas Schietinger, Andrew Powell, Chris Parkes, Niels Tuning
// Maintained by Editorial board member (currently Niels)
///////////////////////////////////////////////////////////////////

  // Use times new roman, precision 2 
  Int_t lhcbFont        = 132;  // Old LHCb style: 62;
  // Line thickness
  Double_t lhcbWidth    = 2.00; // Old LHCb style: 3.00;
  // Text size
  Double_t lhcbTSize    = 0.06; 
  
  // use plain black on white colors
  gROOT->SetStyle("Plain"); 
  TStyle *lhcbStyle= new TStyle("lhcbStyle","LHCb plots style");
  
  //lhcbStyle->SetErrorX(0); //  don't suppress the error bar along X

  lhcbStyle->SetFillColor(1);
  lhcbStyle->SetFillStyle(1001);   // solid
  lhcbStyle->SetFrameFillColor(0);
  lhcbStyle->SetFrameBorderMode(0);
  lhcbStyle->SetPadBorderMode(0);
  lhcbStyle->SetPadColor(0);
  lhcbStyle->SetCanvasBorderMode(0);
  lhcbStyle->SetCanvasColor(0);
  lhcbStyle->SetStatColor(0);
  lhcbStyle->SetLegendBorderSize(0);

  // If you want the usual gradient palette (blue -> red)
  lhcbStyle->SetPalette(1);
  // If you want colors that correspond to gray scale in black and white:
  int colors[8] = {0,5,7,3,6,2,4,1};
  lhcbStyle->SetPalette(8,colors);

  // set the paper & margin sizes
  lhcbStyle->SetPaperSize(20,26);
  lhcbStyle->SetPadTopMargin(0.05);
  lhcbStyle->SetPadRightMargin(0.05); // increase for colz plots
  lhcbStyle->SetPadBottomMargin(0.16);
  lhcbStyle->SetPadLeftMargin(0.14);
  
  // use large fonts
  lhcbStyle->SetTextFont(lhcbFont);
  lhcbStyle->SetTextSize(lhcbTSize);
  lhcbStyle->SetLabelFont(lhcbFont,"x");
  lhcbStyle->SetLabelFont(lhcbFont,"y");
  lhcbStyle->SetLabelFont(lhcbFont,"z");
  lhcbStyle->SetLabelSize(lhcbTSize,"x");
  lhcbStyle->SetLabelSize(lhcbTSize,"y");
  lhcbStyle->SetLabelSize(lhcbTSize,"z");
  lhcbStyle->SetTitleFont(lhcbFont);
  lhcbStyle->SetTitleFont(lhcbFont,"x");
  lhcbStyle->SetTitleFont(lhcbFont,"y");
  lhcbStyle->SetTitleFont(lhcbFont,"z");
  lhcbStyle->SetTitleSize(1.2*lhcbTSize,"x");
  lhcbStyle->SetTitleSize(1.2*lhcbTSize,"y");
  lhcbStyle->SetTitleSize(1.2*lhcbTSize,"z");

  // use medium bold lines and thick markers
  lhcbStyle->SetLineWidth(lhcbWidth);
  lhcbStyle->SetFrameLineWidth(lhcbWidth);
  lhcbStyle->SetHistLineWidth(lhcbWidth);
  lhcbStyle->SetFuncWidth(lhcbWidth);
  lhcbStyle->SetGridWidth(lhcbWidth);
  lhcbStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
  lhcbStyle->SetMarkerStyle(20);
  lhcbStyle->SetMarkerSize(1.0);

  // label offsets
  lhcbStyle->SetLabelOffset(0.010,"X");
  lhcbStyle->SetLabelOffset(0.010,"Y");

  // by default, do not display histogram decorations:
  //lhcbStyle->SetOptStat(0);  
  lhcbStyle->SetOptStat("emr");  // show only nent -e , mean - m , rms -r
  // full opts at http://root.cern.ch/root/html/TStyle.html#TStyle:SetOptStat
  lhcbStyle->SetStatFormat("6.3g"); // specified as c printf options
  lhcbStyle->SetOptTitle(0);
  lhcbStyle->SetOptFit(0);
  //lhcbStyle->SetOptFit(1011); // order is probability, Chi2, errors, parameters
  //titles
  lhcbStyle->SetTitleOffset(0.95,"X");
  lhcbStyle->SetTitleOffset(0.95,"Y");
  lhcbStyle->SetTitleOffset(1.2,"Z");
  lhcbStyle->SetTitleFillColor(0);
  lhcbStyle->SetTitleStyle(0);
  lhcbStyle->SetTitleBorderSize(0);
  lhcbStyle->SetTitleFont(lhcbFont,"title");
  lhcbStyle->SetTitleX(0.0);
  lhcbStyle->SetTitleY(1.0); 
  lhcbStyle->SetTitleW(1.0);
  lhcbStyle->SetTitleH(0.05);
  
  // look of the statistics box:
  lhcbStyle->SetStatBorderSize(0);
  lhcbStyle->SetStatFont(lhcbFont);
  lhcbStyle->SetStatFontSize(0.05);
  lhcbStyle->SetStatX(0.9);
  lhcbStyle->SetStatY(0.9);
  lhcbStyle->SetStatW(0.25);
  lhcbStyle->SetStatH(0.15);

  // put tick marks on top and RHS of plots
  lhcbStyle->SetPadTickX(1);
  lhcbStyle->SetPadTickY(1);

  // histogram divisions: only 5 in x to avoid label overlaps
  lhcbStyle->SetNdivisions(505,"x");
  lhcbStyle->SetNdivisions(510,"y");
  
  gROOT->SetStyle("lhcbStyle");
  gROOT->ForceStyle();
/*
  // add LHCb label
  lhcbName = new TPaveText(gStyle->GetPadLeftMargin() + 0.05,
                           0.87 - gStyle->GetPadTopMargin(),
                           gStyle->treeGetPadLeftMargin() + 0.20,
                           0.95 - gStyle->GetPadTopMargin(),
                           "BRNDC");
  lhcbName->AddText("LHCb");
  lhcbName->SetFillColor(0);
  lhcbName->SetTextAlign(12);
  lhcbName->SetBorderSize(0);
*/
  TText *lhcbLabel = new TText();
  lhcbLabel->SetTextFont(lhcbFont);
  lhcbLabel->SetTextColor(1);
  lhcbLabel->SetTextSize(lhcbTSize);
  lhcbLabel->SetTextAlign(12);

  TLatex *lhcbLatex = new TLatex();
  lhcbLatex->SetTextFont(lhcbFont);
  lhcbLatex->SetTextColor(1);
  lhcbLatex->SetTextSize(lhcbTSize);
  lhcbLatex->SetTextAlign(12);

  //std::cout << "-------------------------" << std::endl;  
  //std::cout << "Set LHCb Style - Feb 2012" << std::endl;
  //std::cout << "-------------------------" << std::endl;  
  
}
示例#10
0
文件: analyze.C 项目: MycrofD/root
void analyze() {
   TCanvas *c1 = new TCanvas("c1","Analyze.mac",620,790);
   c1->Range(-1,0,19,30);
   TPaveLabel *pl1 = new TPaveLabel(0,27,3.5,29,"Analyze");
   pl1->SetFillColor(42);
   pl1->Draw();
   TPaveText *pt1 = new TPaveText(0,22.8,4,25.2);
   TText *t1  = pt1->AddText("Parenthesis matching");
   TText *t2  = pt1->AddText("Remove unnecessary");
   TText *t2a = pt1->AddText("parenthesis");
   pt1->Draw();
   TPaveText *pt2 = new TPaveText(6,23,10,25);
   TText *t3 = pt2->AddText("break of");
   TText *t4 = pt2->AddText("Analyze");
   pt2->Draw();
   TPaveText *pt3 = new TPaveText(0,19,4,21);
   t4=pt3->AddText("look for simple");
   TText *t5 = pt3->AddText("operators");
   pt3->Draw();
   TPaveText *pt4 = new TPaveText(0,15,4,17);
   TText *t6 = pt4->AddText("look for an already");
   TText *t7 = pt4->AddText("defined expression");
   pt4->Draw();
   TPaveText *pt5 = new TPaveText(0,11,4,13);
   TText *t8 = pt5->AddText("look for usual");
   TText *t9 = pt5->AddText("functions :cos sin ..");
   pt5->Draw();
   TPaveText *pt6 = new TPaveText(0,7,4,9);
   TText *t10 = pt6->AddText("look for a");
   TText *t11 = pt6->AddText("numeric value");
   pt6->Draw();
   TPaveText *pt7 = new TPaveText(6,18.5,10,21.5);
   TText *t12 = pt7->AddText("Analyze left and");
   TText *t13 = pt7->AddText("right part of");
   TText *t14 = pt7->AddText("the expression");
   pt7->Draw();
   TPaveText *pt8 = new TPaveText(6,15,10,17);
   TText *t15 = pt8->AddText("Replace expression");
   pt8->Draw();
   TPaveText *pt9 = new TPaveText(6,11,10,13);
   TText *t16 = pt9->AddText("Analyze");
   pt9->SetFillColor(42);
   pt9->Draw();
   TPaveText *pt10 = new TPaveText(6,7,10,9);
   TText *t17 = pt10->AddText("Error");
   TText *t18 = pt10->AddText("Break of Analyze");
   pt10->Draw();
   TPaveText *pt11 = new TPaveText(14,22,17,24);
   pt11->SetFillColor(42);
   TText *t19  = pt11->AddText("Analyze");
   TText *t19a = pt11->AddText("Left");
   pt11->Draw();
   TPaveText *pt12 = new TPaveText(14,19,17,21);
   pt12->SetFillColor(42);
   TText *t20  = pt12->AddText("Analyze");
   TText *t20a = pt12->AddText("Right");
   pt12->Draw();
   TPaveText *pt13 = new TPaveText(14,15,18,18);
   TText *t21 = pt13->AddText("StackNumber++");
   TText *t22 = pt13->AddText("operator[StackNumber]");
   TText *t23 = pt13->AddText("= operator found");
   pt13->Draw();
   TPaveText *pt14 = new TPaveText(12,10.8,17,13.2);
   TText *t24 = pt14->AddText("StackNumber++");
   TText *t25 = pt14->AddText("operator[StackNumber]");
   TText *t26 = pt14->AddText("= function found");
   pt14->Draw();
   TPaveText *pt15 = new TPaveText(6,7,10,9);
   TText *t27 = pt15->AddText("Error");
   TText *t28 = pt15->AddText("break of Analyze");
   pt15->Draw();
   TPaveText *pt16 = new TPaveText(0,2,7,5);
   TText *t29 = pt16->AddText("StackNumber++");
   TText *t30 = pt16->AddText("operator[StackNumber] = 0");
   TText *t31 = pt16->AddText("value[StackNumber] = value found");
   pt16->Draw();
   TArrow *ar = new TArrow(2,27,2,25.4,0.012,"|>");
   ar->SetFillColor(1);
   ar->Draw();
   ar->DrawArrow(2,22.8,2,21.2,0.012,"|>");
   ar->DrawArrow(2,19,2,17.2,0.012,"|>");
   ar->DrawArrow(2,15,2,13.2,0.012,"|>");
   ar->DrawArrow(2,11,2, 9.2,0.012,"|>");
   ar->DrawArrow(2, 7,2, 5.2,0.012,"|>");
   ar->DrawArrow(4,24,6,24,0.012,"|>");
   ar->DrawArrow(4,20,6,20,0.012,"|>");
   ar->DrawArrow(4,16,6,16,0.012,"|>");
   ar->DrawArrow(4,12,6,12,0.012,"|>");
   ar->DrawArrow(4, 8,6, 8,0.012,"|>");
   ar->DrawArrow(10,20,14,20,0.012,"|>");
   ar->DrawArrow(12,23,14,23,0.012,"|>");
   ar->DrawArrow(12,16.5,14,16.5,0.012,"|>");
   ar->DrawArrow(10,12,12,12,0.012,"|>");
   TText *ta = new TText(2.2,22.2,"err = 0");
   ta->SetTextFont(71);
   ta->SetTextSize(0.015);
   ta->SetTextColor(4);
   ta->SetTextAlign(12);
   ta->Draw();
   ta->DrawText(2.2,18.2,"not found");
   ta->DrawText(2.2,6.2,"found");
   TText *tb = new TText(4.2,24.1,"err != 0");
   tb->SetTextFont(71);
   tb->SetTextSize(0.015);
   tb->SetTextColor(4);
   tb->SetTextAlign(11);
   tb->Draw();
   tb->DrawText(4.2,20.1,"found");
   tb->DrawText(4.2,16.1,"found");
   tb->DrawText(4.2,12.1,"found");
   tb->DrawText(4.2, 8.1,"not found");
   TLine *l1 = new TLine(12,16.5,12,23);
   l1->Draw();
}
示例#11
0
void plotpurity()
{

 Bool_t dolines = kFALSE;
 //Bool_t dolines = kTRUE;
 TString lines = "";

 TString xn = "";
 //TString xn = "_onlyQCD";
 //TString xn = "_onlyGJ";
 //TString xn = "_denominator";
 if(dolines){lines="/lines";}

 std::vector<TString> rebins;
 rebins.push_back("");
// rebins.push_back("rebin1");
// rebins.push_back("rebin2");
// rebins.push_back("rebin3");
// rebins.push_back("rebin4");
// rebins.push_back("rebin5");

 std::vector<TString> ptranges;
// ptranges.push_back("90to120");
// ptranges.push_back("120to155");
// ptranges.push_back("155to175");
 ptranges.push_back("175to190");
 ptranges.push_back("190to250");
 ptranges.push_back("250to400");
 ptranges.push_back("400to700");
 ptranges.push_back("700to1000");
 ptranges.push_back("175to1000");
 //ptranges.push_back("250to1000");
 //ptranges.push_back("400to1000");

 std::vector<TString> isovars;
 //isovars.push_back("wchiso");
 isovars.push_back("chiso");
// isovars.push_back("sieieF5x5");
// isovars.push_back("sieipF5x5");
// isovars.push_back("sipipF5x5");
// isovars.push_back("rho");
// isovars.push_back("nVtx");
// isovars.push_back("phoet");
// isovars.push_back("pfMET");

 std::vector<TString> cuts;
 cuts.push_back("a_idnc");
 cuts.push_back("b_idnc_mL30");
 cuts.push_back("c_idnc_trig");
 cuts.push_back("d_idnc_mL30_trig");
 cuts.push_back("e_idnc_t175");
 cuts.push_back("f_idnc_mL30_t175");
 cuts.push_back("g_idnc_t250");
 cuts.push_back("h_idnc_mL30_t250");
 cuts.push_back("i_idnc_mL30_allt");
// cuts.push_back("oldj");

 TString inpath = "/afs/hep.wisc.edu/cms/tperry/LoneG_slc6_491_CMSSW_7_4_14/src/LoneGamma/qcdStudy/gitignore/Lire/analyzed";
 TString outpath = "/afs/hep.wisc.edu/cms/tperry/LoneG_slc6_491_CMSSW_7_4_14/src/LoneGamma/qcdStudy/gitignore/Lire/plots";
 TString wwwpath = "/afs/hep.wisc.edu/home/tperry/www/MonoPhoton/qcdPlots/Lire/purity";

 TString inname_GJ  = inpath+"/purity_GJets_Merged.root";
 TString inname_QCD = inpath+"/purity_QCD_Merged.root";
// TString inname_GJ  = inpath+"/purity_mrg4bins_GJets.root";
// TString inname_QCD = inpath+"/purity_mrg4bins_QCD.root";
 //TString inname_GJ  = inpath+"/purity_mrg3bins_GJets.root";
 //TString inname_QCD = inpath+"/purity_mrg3bins_QCD.root";
 
 TFile *infile_GJ  = new TFile(inname_GJ);
 TFile *infile_QCD = new TFile(inname_QCD);
 
 ofstream log;
 ofstream log_latex;
 log.open (outpath+"/Purity_log"+xn+".txt");
 log_latex.open (outpath+"/Purity_log_latex"+xn+".txt");

 Int_t fillcolor = 3;
 gStyle->SetOptStat(0);
 gStyle->SetOptTitle(0);
 gStyle->SetFrameLineWidth(3);
 gStyle->SetLineWidth(2);

 TCanvas* canvas = new TCanvas("canvas","canvas",900,100,500,500);
 gStyle->SetOptStat(0);
 gPad->SetTickx();
 gPad->SetTicky();
 gStyle->SetLineWidth(3);


 TText* title = new TText(1,1,"") ;
 title->SetTextSize(0.07);
 title->SetTextColor(kBlack);
 title->SetTextAlign(13);
 title->SetTextFont(62);

 TText* extra = new TText(1,1,"") ;
 extra->SetTextSize(0.05);
 extra->SetTextColor(kBlack);
 extra->SetTextAlign(13);
 extra->SetTextFont(52);

 TText* lumi = new TText(1,1,"") ;
 lumi->SetTextSize(0.05);
 lumi->SetTextColor(kBlack);
 lumi->SetTextAlign(31);
 lumi->SetTextFont(42);

 int c_sig = 4;
 int c_bkg = 2;
 int c_den = 8;
 int ls_cmb = 1;
 int ls_gj  = 2;
 int ls_qcd = 3;

 //for(std::vector<TString>::iterator it = ptranges.begin(); it != ptranges.end(); ++it) {
 for(unsigned i=0; i<ptranges.size(); i++) {
  for(unsigned j=0; j<isovars.size(); j++) {
   for(unsigned k=0; k<cuts.size(); k++) {
    for(unsigned l=0; l<rebins.size(); l++) {

     TString ptrange = ptranges.at(i);
     TString isovar = isovars.at(j);
     TString cut = cuts.at(k);
     TString rebin = rebins.at(l);

     TString cutname;
     if(cut=="idnc"){cutname="ID";}
     if(cut=="idnc_mL30"){cutname="ID+MET";}
     if(cut=="idnc_trig"){cutname="ID+Trigger";}
     if(cut=="idnc_mL30_trig"){cutname="ID+MET+Trigger";}

     TString bwidth;
     if(rebin=="rebin1"){bwidth="width=0.5";}
     if(rebin=="rebin2"){bwidth="width=1.0";}
     if(rebin=="rebin3"){bwidth="width=1.5";}
     if(rebin=="rebin4"){bwidth="width=2.0";}
     if(rebin=="rebin5"){bwidth="width=2.5";}

     std::cout<<boost::format("%8s %15s %7s %7s ") % ptrange % cut % isovar % rebin<<std::endl;

     //Signal purity
     TH1F* h_Nsig_GJ  = (TH1F*)infile_GJ->Get("h_Nsig_"+isovar+"_"+ptrange+"_"+cut);
     TH1F* h_Nsig_QCD = (TH1F*)infile_QCD->Get("h_Nsig_"+isovar+"_"+ptrange+"_"+cut);
     h_Nsig_GJ->Rebin(3); h_Nsig_QCD->Rebin(3); //h_Nsig_GJ->Rebin(l+1); h_Nsig_QCD->Rebin(l+1);
             //TH1F* h_Nsig  = (TH1F*)h_Nsig_QCD->Clone("h_Nsig");
     TH1F* h_Nsig  = (TH1F*)h_Nsig_GJ->Clone("h_Nsig");
     h_Nsig->Add(h_Nsig_QCD);
     h_Nsig->SetLineColor(c_sig); h_Nsig_GJ->SetLineColor(c_sig); h_Nsig_QCD->SetLineColor(c_sig);
     h_Nsig->SetLineStyle(ls_cmb); h_Nsig_GJ->SetLineStyle(ls_gj); h_Nsig_QCD->SetLineStyle(ls_qcd);
     h_Nsig->SetLineWidth(2); h_Nsig_GJ->SetLineWidth(2); h_Nsig_QCD->SetLineWidth(2);
     //Background purity
     TH1F* h_Nbkg_GJ  = (TH1F*)infile_GJ->Get("h_Nbkg_"+isovar+"_"+ptrange+"_"+cut);
     TH1F* h_Nbkg_QCD = (TH1F*)infile_QCD->Get("h_Nbkg_"+isovar+"_"+ptrange+"_"+cut);
     h_Nbkg_GJ->Rebin(3); h_Nbkg_QCD->Rebin(3);
             //TH1F* h_Nbkg  = (TH1F*)h_Nbkg_QCD->Clone("h_Nbkg");
     TH1F* h_Nbkg  = (TH1F*)h_Nbkg_GJ->Clone("h_Nbkg");
     h_Nbkg->Add(h_Nbkg_QCD);
     h_Nbkg->SetLineColor(c_bkg); h_Nbkg_GJ->SetLineColor(c_bkg); h_Nbkg_QCD->SetLineColor(c_bkg);
     h_Nbkg->SetLineStyle(ls_cmb); h_Nbkg_GJ->SetLineStyle(ls_gj); h_Nbkg_QCD->SetLineStyle(ls_qcd);
     h_Nbkg->SetLineWidth(2); h_Nbkg_GJ->SetLineWidth(2); h_Nbkg_QCD->SetLineWidth(2);

     //Denominator
     TH1F* h_Deno_GJ  = (TH1F*)h_Nsig_GJ->Clone("h_Deno_GJ");
     h_Deno_GJ->Add(h_Nbkg_GJ);

     TH1F* h_Deno_QCD  = (TH1F*)h_Nsig_QCD->Clone("h_Deno_QCD");
     h_Deno_QCD->Add(h_Nbkg_QCD);

//     TH1F* h_Deno_GJ  = (TH1F*)infile_GJ->Get("h_Deno_"+isovar+"_"+ptrange+"_"+cut);
//     TH1F* h_Deno_QCD = (TH1F*)infile_QCD->Get("h_Deno_"+isovar+"_"+ptrange+"_"+cut);
//     h_Deno_GJ->Rebin(3); h_Deno_QCD->Rebin(3);
//             //TH1F* h_Deno  = (TH1F*)h_Deno_QCD->Clone("h_Deno");
     TH1F* h_Deno  = (TH1F*)h_Deno_GJ->Clone("h_Deno");
     h_Deno->Add(h_Deno_QCD);

     h_Deno->SetLineColor(c_den); h_Deno_GJ->SetLineColor(c_den); h_Deno_QCD->SetLineColor(c_den);
     h_Deno->SetLineStyle(ls_cmb); h_Deno_GJ->SetLineStyle(ls_gj); h_Deno_QCD->SetLineStyle(ls_qcd);
     h_Deno->SetLineWidth(1); h_Deno_GJ->SetLineWidth(1); h_Deno_QCD->SetLineWidth(1);

     // should probably add these as last bin..
     h_Nsig->ClearUnderflowAndOverflow();
     h_Nbkg->ClearUnderflowAndOverflow();
     h_Deno->ClearUnderflowAndOverflow();
     
     //Define purity
     TGraphAsymmErrors *purity_signal     = new TGraphAsymmErrors(h_Nsig,h_Deno,"n");
     purity_signal->SetLineWidth(2);
     purity_signal->SetLineColor(4);
     purity_signal->SetMarkerColor(4);
     purity_signal->SetMarkerStyle(20);
     
     TGraphAsymmErrors *purity_background = new TGraphAsymmErrors(h_Nbkg,h_Deno,"n");
     purity_background->SetLineWidth(2);
     purity_background->SetLineColor(2);
     purity_background->SetMarkerColor(2);
     purity_background->SetMarkerStyle(24);

     //-----------------------------------------------------
     // Calculations
     log<<boost::format("%8s %15s %7s %7s ") % ptrange % cut % isovar % rebin  ;

     // Start lower bound calculation
     Int_t nbins;
     nbins = purity_background->GetN();
     log<<boost::format("(%2i bins) \n") % nbins ; 

     std::vector<Double_t> thresholds, xsatthresh, ysatthresh, xsatqt, avgpur;
     std::vector<Int_t> batthresh, batqt;

     thresholds.clear(); // purity thresholds
     xsatthresh.clear(); // x st. f(x) > thresh
     ysatthresh.clear(); // y = f(x)x at thresh
     batthresh.clear();  // bin corresponding to x

     batqt.clear();      // bin at upper threshold
     xsatqt.clear();     // x value at upper thresh

     avgpur.clear();     // average purity over range

     thresholds.push_back(0.50);
     thresholds.push_back(0.55);
     thresholds.push_back(0.60);
     thresholds.push_back(0.65);
     thresholds.push_back(0.70);
     Int_t nthreshs;
     nthreshs = thresholds.size();

     // find purity lower bounds = x st. f(x)>thresh
     Double_t pointx, pointy;     
     for(int m=0; m<nbins; ++m){
      purity_background->GetPoint(m, pointx, pointy);
      //log<<boost::format(" %2i %2.2f %2.2f \n") % i % pointx % pointy;
      
      for(int n=0; n<nthreshs; ++n){
       if(pointy > thresholds.at(n) && ysatthresh.size()==n ){
        ysatthresh.push_back(pointy);
        xsatthresh.push_back(pointx);
        batthresh.push_back(h_Nsig->FindBin(pointx));
       }
      }
     }

     // for thresholds never reached, fill with content of xmax
     purity_background->GetPoint(nbins-1,pointx,pointy);
     Int_t nrnpassthresh = 0;
     nrnpassthresh = nthreshs - ysatthresh.size();
     for(int n=0; n<nrnpassthresh; ++n){
       ysatthresh.push_back(pointy);
       xsatthresh.push_back(pointx);
       batthresh.push_back(h_Nsig->FindBin(pointx));
     }

     //// dump lower bound threshold info
     //for(int n=0; n<nthreshs; ++n){
     // log<<boost::format("  Threshold: %.2f  %2i (%2.2f, %0.2f)\n")
     //  % thresholds.at(n) % batthresh.at(n) % xsatthresh.at(n) % ysatthresh.at(n) ;
     //}

     log<<boost::format("   Threshold bin (xx.x,yy.y) TotalSize   above|below\n");
     // Start upper bound calculation
     Double_t fullsize = h_Nbkg->Integral(0,-1);
     for(int n=0; n<nthreshs; ++n){
      Double_t sizedown = h_Nbkg->Integral(0,batthresh.at(n)-1);
      Double_t sizeup =   h_Nbkg->Integral(batthresh.at(n),-1);
      log<<boost::format("    %7.2f %3i (%2.1f,%1.2f)    %4.1f  %6.1f|%6.1f \n")
       % thresholds.at(n) % batthresh.at(n) % xsatthresh.at(n) % ysatthresh.at(n)    
       % fullsize % sizeup % sizedown ;
     }

     // upper bound calculation 
     // keep adding contents of bins starting at threshbin 
      // until sum > fraction (1/4) of full integral
     Double_t goalsize = fullsize / 4.;

     for(int n=0; n<nthreshs; ++n){
      Double_t thissize = 0.;
      int thisbin = batthresh.at(n);
      while( thisbin < nbins+1 ){
       thissize += h_Nbkg->GetBinContent(thisbin); 
       if(thissize > goalsize){
        break;
        }
       thisbin++;
      }
      batqt.push_back(thisbin);
      xsatqt.push_back(h_Nbkg->GetBinCenter(thisbin));
     }

    log<<"       Target Eventcount: "<<goalsize<<" = fullsize/4 = "<<fullsize<<"/4 \n";
     log<<boost::format("   Threshold blo bhi (xlo,xhi) Int(blo,bhi) Int(blo,bhi+1) Int(blo,bhi-1)\n");

    // find average purity over range
    // must weight each purity bin by nr. events in bin
    for(int n=0; n<nthreshs; ++n){
     int nbins = batqt.at(n) - batthresh.at(n);
     //std::cout<<nbins<<" "<<batthresh.at(n)<<" "<<batqt.at(n)<<std::endl;
     Double_t sumpurs, sumweights;
     sumpurs = 0.;
     sumweights = 0.;
     for(int o=0; o<nbins+1; ++o){
      int thisbin = batthresh.at(n) + o;
      int thispoint = thisbin - 1;  // bin nr = point nr + 1
      purity_background->GetPoint(thispoint, pointx,pointy);
      sumpurs += pointy*h_Nbkg->GetBinContent(thisbin);
      sumweights += h_Nbkg->GetBinContent(thisbin);
      //std::cout<<" "<<thispoint<<"|"<<pointy<<"|"<<h_Nbkg->GetBinContent(thisbin)<<" "<<std::endl;;
     }
     //std::cout<<std::endl;
     //std::cout<<sumpurs/sumweights<<std::endl<<std::endl;;
     avgpur.push_back( sumpurs/sumweights );
    }
     log_latex<<"\\begin{tabular}{r|r|r|r|r|r|r|r}\n";
     log_latex<<boost::format("\\multicolumn{2}{c|}{%8s} & \\multicolumn{2}{c|}{%15s} & \\multicolumn{2}{c|}{%7s} & \\multicolumn{2}{c|}{%7s} \\\\ \\hline \\hline  \n") % ptrange % cutname % isovar % bwidth  ;
     log_latex<<boost::format("   %10s & %5s & %5s & %10s & %5s & %8s & %15s & %10s  \\\\  \\hline \n")
      % "Threshold" 
      % "x lo" % "x hi" 
      % "avg purity"
      % "err \\%" 
      % "evts. tot." 
      % "evts. > x lo" 
      % "evts in rng." ;

     ///log_latex<<"\\begin{tabular}{r|r|r|r|r}\n";
     ///log_latex<<boost::format("%8s & \\multicolumn{2}{c}{%15s} & %7s & %7s \\\\  \n \\hline \\hline \n") % ptrange % cutname % isovar % bwidth  ;
     ///log_latex<<boost::format("   %10s & %5s & %5s & %10s & %5s \\\\ \n \\hline \n")
     /// % "Threshold" 
     /// % "x lo" % "x hi" 
     /// % "avg purity"
     /// % "err \\%" ;
    for(int n=0; n<nthreshs; ++n){
     log<<boost::format("    %7.2f %3i %3i (%2.1f,%1.2f) %10.2f %10.2f %10.2f  \n")
      % thresholds.at(n) % batthresh.at(n) %batqt.at(n)
      % xsatthresh.at(n) % xsatqt.at(n) 
      % h_Nbkg->Integral(batthresh.at(n),batqt.at(n))
      % h_Nbkg->Integral(batthresh.at(n),batqt.at(n)+1)
      % h_Nbkg->Integral(batthresh.at(n),batqt.at(n)-1) ;

     Double_t nrevents, errevents, pcterr;
     nrevents = h_Nbkg->IntegralAndError(batthresh.at(n),batqt.at(n),errevents);
     pcterr = errevents/nrevents;
     log_latex<<boost::format("   %10.2f & %5.2f & %5.2f & %10.4f &  %5.2f &  %8.1f & %15.1f & %10.1f  \\\\  \n")
      % thresholds.at(n) 
      % h_Nbkg->GetBinLowEdge(h_Nbkg->FindBin(xsatthresh.at(n))) % h_Nbkg->GetBinLowEdge(h_Nbkg->FindBin(xsatqt.at(n) ))
      //% xsatthresh.at(n) % xsatqt.at(n) 
      % avgpur.at(n)
      % (pcterr*100) 
      % fullsize 
      % h_Nbkg->Integral(batthresh.at(n),-1)
      % h_Nbkg->Integral(batthresh.at(n),batqt.at(n));

     ///log_latex<<boost::format("   %10.2f & %5.2f & %5.2f & %7.3f &  %5.2f  \\\\  \n")
     /// % thresholds.at(n) 
     /// % xsatthresh.at(n) % xsatqt.at(n) 
     /// % avgpur.at(n)
     /// % (pcterr*100) ;
    }
     log_latex<<"\\hline \n  \\end{tabular}\n";

     //-----------------------------------------------------
     // all set, now to start thinking about plotting
     //Make lower bound lines (purity)
     Double_t frac = 1./nthreshs;
     TLine *lgb_lo0 = new TLine(xsatthresh.at(0), 0*frac, xsatthresh.at(0), 1*frac);
     TLine *lgb_lo1 = new TLine(xsatthresh.at(1), 1*frac, xsatthresh.at(1), 2*frac);
     TLine *lgb_lo2 = new TLine(xsatthresh.at(2), 2*frac, xsatthresh.at(2), 3*frac);
     TLine *lgb_lo3 = new TLine(xsatthresh.at(3), 3*frac, xsatthresh.at(3), 4*frac);
     TLine *lgb_lo4 = new TLine(xsatthresh.at(4), 4*frac, xsatthresh.at(4), 5*frac);
     TLine *lgc_lo0 = new TLine(xsatthresh.at(0), 0*frac, xsatthresh.at(0), 1*frac);
     TLine *lgc_lo1 = new TLine(xsatthresh.at(1), 1*frac, xsatthresh.at(1), 2*frac);
     TLine *lgc_lo2 = new TLine(xsatthresh.at(2), 2*frac, xsatthresh.at(2), 3*frac);
     TLine *lgc_lo3 = new TLine(xsatthresh.at(3), 3*frac, xsatthresh.at(3), 4*frac);
     TLine *lgc_lo4 = new TLine(xsatthresh.at(4), 4*frac, xsatthresh.at(4), 5*frac);

     lgb_lo0->SetLineColor(1);
     lgb_lo1->SetLineColor(1);
     lgb_lo2->SetLineColor(1);
     lgb_lo3->SetLineColor(1);
     lgb_lo4->SetLineColor(1);
     lgc_lo0->SetLineColor(2);
     lgc_lo1->SetLineColor(3);
     lgc_lo2->SetLineColor(4);
     lgc_lo3->SetLineColor(5);
     lgc_lo4->SetLineColor(6);

     lgb_lo0->SetLineWidth(4);
     lgb_lo1->SetLineWidth(4);
     lgb_lo2->SetLineWidth(4);
     lgb_lo3->SetLineWidth(4);
     lgb_lo4->SetLineWidth(4);
     lgc_lo0->SetLineWidth(2);
     lgc_lo1->SetLineWidth(2);
     lgc_lo2->SetLineWidth(2);
     lgc_lo3->SetLineWidth(2);
     lgc_lo4->SetLineWidth(2);

     //Make upper bound lines (purity)
     TLine *lgb_hi0 = new TLine(xsatqt.at(0), 0*frac, xsatqt.at(0), 1*frac);
     TLine *lgb_hi1 = new TLine(xsatqt.at(1), 1*frac, xsatqt.at(1), 2*frac);
     TLine *lgb_hi2 = new TLine(xsatqt.at(2), 2*frac, xsatqt.at(2), 3*frac);
     TLine *lgb_hi3 = new TLine(xsatqt.at(3), 3*frac, xsatqt.at(3), 4*frac);
     TLine *lgb_hi4 = new TLine(xsatqt.at(4), 4*frac, xsatqt.at(4), 5*frac);
     TLine *lgc_hi0 = new TLine(xsatqt.at(0), 0*frac, xsatqt.at(0), 1*frac);
     TLine *lgc_hi1 = new TLine(xsatqt.at(1), 1*frac, xsatqt.at(1), 2*frac);
     TLine *lgc_hi2 = new TLine(xsatqt.at(2), 2*frac, xsatqt.at(2), 3*frac);
     TLine *lgc_hi3 = new TLine(xsatqt.at(3), 3*frac, xsatqt.at(3), 4*frac);
     TLine *lgc_hi4 = new TLine(xsatqt.at(4), 4*frac, xsatqt.at(4), 5*frac);

     lgb_hi0->SetLineColor(1);
     lgb_hi1->SetLineColor(1);
     lgb_hi2->SetLineColor(1);
     lgb_hi3->SetLineColor(1);
     lgb_hi4->SetLineColor(1);
     lgc_hi0->SetLineColor(2);
     lgc_hi1->SetLineColor(3);
     lgc_hi2->SetLineColor(4);
     lgc_hi3->SetLineColor(5);
     lgc_hi4->SetLineColor(6);

     lgb_hi0->SetLineWidth(4);
     lgb_hi1->SetLineWidth(4);
     lgb_hi2->SetLineWidth(4);
     lgb_hi3->SetLineWidth(4);
     lgb_hi4->SetLineWidth(4);
     lgc_hi0->SetLineWidth(2);
     lgc_hi1->SetLineWidth(2);
     lgc_hi2->SetLineWidth(2);
     lgc_hi3->SetLineWidth(2);
     lgc_hi4->SetLineWidth(2);

     lgc_hi0->SetLineStyle(2);
     lgc_hi1->SetLineStyle(2);
     lgc_hi2->SetLineStyle(2);
     lgc_hi3->SetLineStyle(2);
     lgc_hi4->SetLineStyle(2);

     //Make avg purity horizontal lines
     TLine *lgb_pur0 = new TLine(xsatthresh.at(0), avgpur.at(0), xsatqt.at(0), avgpur.at(0));
     TLine *lgb_pur1 = new TLine(xsatthresh.at(1), avgpur.at(1), xsatqt.at(1), avgpur.at(1));
     TLine *lgb_pur2 = new TLine(xsatthresh.at(2), avgpur.at(2), xsatqt.at(2), avgpur.at(2));
     TLine *lgb_pur3 = new TLine(xsatthresh.at(3), avgpur.at(3), xsatqt.at(3), avgpur.at(3));
     TLine *lgb_pur4 = new TLine(xsatthresh.at(4), avgpur.at(4), xsatqt.at(4), avgpur.at(4));
     TLine *lgc_pur0 = new TLine(xsatthresh.at(0), avgpur.at(0), xsatqt.at(0), avgpur.at(0));
     TLine *lgc_pur1 = new TLine(xsatthresh.at(1), avgpur.at(1), xsatqt.at(1), avgpur.at(1));
     TLine *lgc_pur2 = new TLine(xsatthresh.at(2), avgpur.at(2), xsatqt.at(2), avgpur.at(2));
     TLine *lgc_pur3 = new TLine(xsatthresh.at(3), avgpur.at(3), xsatqt.at(3), avgpur.at(3));
     TLine *lgc_pur4 = new TLine(xsatthresh.at(4), avgpur.at(4), xsatqt.at(4), avgpur.at(4));

     lgb_pur0->SetLineColor(1);
     lgb_pur1->SetLineColor(1);
     lgb_pur2->SetLineColor(1);
     lgb_pur3->SetLineColor(1);
     lgb_pur4->SetLineColor(1);
     //lgb_pur0->SetLineColor(2);
     //lgb_pur1->SetLineColor(3);
     //lgb_pur2->SetLineColor(4);
     //lgb_pur3->SetLineColor(5);
     //lgb_pur4->SetLineColor(6);
     lgc_pur0->SetLineColor(2);
     lgc_pur1->SetLineColor(3);
     lgc_pur2->SetLineColor(4);
     lgc_pur3->SetLineColor(5);
     lgc_pur4->SetLineColor(6);

     lgb_pur0->SetLineWidth(4);
     lgb_pur1->SetLineWidth(4);
     lgb_pur2->SetLineWidth(4);
     lgb_pur3->SetLineWidth(4);
     lgb_pur4->SetLineWidth(4);
     lgc_pur0->SetLineWidth(2);
     lgc_pur1->SetLineWidth(2);
     lgc_pur2->SetLineWidth(2);
     lgc_pur3->SetLineWidth(2);
     lgc_pur4->SetLineWidth(2);

     //lgc_pur0->SetLineStyle(2);
     //lgc_pur1->SetLineStyle(2);
     //lgc_pur2->SetLineStyle(2);
     //lgc_pur3->SetLineStyle(2);
     //lgc_pur4->SetLineStyle(2);

     //-----------------------------------------------------
     Double_t themax = 0 ;
     themax = std::max(themax, h_Nsig->GetMaximum());
     themax = std::max(themax, h_Nbkg->GetMaximum());
     themax = std::max(themax, h_Deno->GetMaximum());

     //Make lower bound lines (hist)
     Double_t logmax;
     Double_t logmin;
     logmax = std::log(themax);
     logmin = std::log(1);
     Double_t spacing = (logmax-logmin)/nthreshs;
     //std::cout<<spacing<<std::endl;

     //Double_t fifmax = themax/5.;
     TLine *lhb_lo0 = new TLine(xsatthresh.at(0), exp(logmin+0*spacing), xsatthresh.at(0), exp(logmin+1*spacing));
     TLine *lhb_lo1 = new TLine(xsatthresh.at(1), exp(logmin+1*spacing), xsatthresh.at(1), exp(logmin+2*spacing));
     TLine *lhb_lo2 = new TLine(xsatthresh.at(2), exp(logmin+2*spacing), xsatthresh.at(2), exp(logmin+3*spacing));
     TLine *lhb_lo3 = new TLine(xsatthresh.at(3), exp(logmin+3*spacing), xsatthresh.at(3), exp(logmin+4*spacing));
     TLine *lhb_lo4 = new TLine(xsatthresh.at(4), exp(logmin+4*spacing), xsatthresh.at(4), exp(logmin+5*spacing));
     TLine *lhc_lo0 = new TLine(xsatthresh.at(0), exp(logmin+0*spacing), xsatthresh.at(0), exp(logmin+1*spacing));
     TLine *lhc_lo1 = new TLine(xsatthresh.at(1), exp(logmin+1*spacing), xsatthresh.at(1), exp(logmin+2*spacing));
     TLine *lhc_lo2 = new TLine(xsatthresh.at(2), exp(logmin+2*spacing), xsatthresh.at(2), exp(logmin+3*spacing));
     TLine *lhc_lo3 = new TLine(xsatthresh.at(3), exp(logmin+3*spacing), xsatthresh.at(3), exp(logmin+4*spacing));
     TLine *lhc_lo4 = new TLine(xsatthresh.at(4), exp(logmin+4*spacing), xsatthresh.at(4), exp(logmin+5*spacing));

     lhb_lo0->SetLineColor(1);
     lhb_lo1->SetLineColor(1);
     lhb_lo2->SetLineColor(1);
     lhb_lo3->SetLineColor(1);
     lhb_lo4->SetLineColor(1);
     lhc_lo0->SetLineColor(2);
     lhc_lo1->SetLineColor(3);
     lhc_lo2->SetLineColor(4);
     lhc_lo3->SetLineColor(5);
     lhc_lo4->SetLineColor(6);

     lhb_lo0->SetLineWidth(4);
     lhb_lo1->SetLineWidth(4);
     lhb_lo2->SetLineWidth(4);
     lhb_lo3->SetLineWidth(4);
     lhb_lo4->SetLineWidth(4);
     lhc_lo0->SetLineWidth(2);
     lhc_lo1->SetLineWidth(2);
     lhc_lo2->SetLineWidth(2);
     lhc_lo3->SetLineWidth(2);
     lhc_lo4->SetLineWidth(2);

     //Make upper bound lines (hist)
     TLine *lhb_hi0 = new TLine(xsatqt.at(0), exp(logmin+0*spacing), xsatqt.at(0), exp(logmin+1*spacing));
     TLine *lhb_hi1 = new TLine(xsatqt.at(1), exp(logmin+1*spacing), xsatqt.at(1), exp(logmin+2*spacing));
     TLine *lhb_hi2 = new TLine(xsatqt.at(2), exp(logmin+2*spacing), xsatqt.at(2), exp(logmin+3*spacing));
     TLine *lhb_hi3 = new TLine(xsatqt.at(3), exp(logmin+3*spacing), xsatqt.at(3), exp(logmin+4*spacing));
     TLine *lhb_hi4 = new TLine(xsatqt.at(4), exp(logmin+4*spacing), xsatqt.at(4), exp(logmin+5*spacing));
     TLine *lhc_hi0 = new TLine(xsatqt.at(0), exp(logmin+0*spacing), xsatqt.at(0), exp(logmin+1*spacing));
     TLine *lhc_hi1 = new TLine(xsatqt.at(1), exp(logmin+1*spacing), xsatqt.at(1), exp(logmin+2*spacing));
     TLine *lhc_hi2 = new TLine(xsatqt.at(2), exp(logmin+2*spacing), xsatqt.at(2), exp(logmin+3*spacing));
     TLine *lhc_hi3 = new TLine(xsatqt.at(3), exp(logmin+3*spacing), xsatqt.at(3), exp(logmin+4*spacing));
     TLine *lhc_hi4 = new TLine(xsatqt.at(4), exp(logmin+4*spacing), xsatqt.at(4), exp(logmin+5*spacing));

     lhb_hi0->SetLineColor(1);
     lhb_hi1->SetLineColor(1);
     lhb_hi2->SetLineColor(1);
     lhb_hi3->SetLineColor(1);
     lhb_hi4->SetLineColor(1);
     lhc_hi0->SetLineColor(2);
     lhc_hi1->SetLineColor(3);
     lhc_hi2->SetLineColor(4);
     lhc_hi3->SetLineColor(5);
     lhc_hi4->SetLineColor(6);

     lhb_hi0->SetLineWidth(4);
     lhb_hi1->SetLineWidth(4);
     lhb_hi2->SetLineWidth(4);
     lhb_hi3->SetLineWidth(4);
     lhb_hi4->SetLineWidth(4);
     lhc_hi0->SetLineWidth(2);
     lhc_hi1->SetLineWidth(2);
     lhc_hi2->SetLineWidth(2);
     lhc_hi3->SetLineWidth(2);
     lhc_hi4->SetLineWidth(2);

     lhc_hi0->SetLineStyle(2);
     lhc_hi1->SetLineStyle(2);
     lhc_hi2->SetLineStyle(2);
     lhc_hi3->SetLineStyle(2);
     lhc_hi4->SetLineStyle(2);
     //-----------------------------------------------------


     //-----------------------------------------------------
     //Draw Histograms
     TLegend *meg = new TLegend(0.4,0.6,0.88,0.88);
     //meg->SetTextSize(0.04) ;
     meg->SetFillColor(0); meg->SetShadowColor(0);meg->SetBorderSize(2);
     meg->SetTextFont(22.);
     meg->AddEntry(h_Nsig,"Signal","l");
     meg->AddEntry(h_Nsig_GJ,"Signal (GJ MC)","l");
     meg->AddEntry(h_Nsig_QCD,"Signal (QCD MC)","l");
     meg->AddEntry(h_Nbkg,"Background","l");
     meg->AddEntry(h_Nbkg_GJ,"Background (GJ MC)","l");
     meg->AddEntry(h_Nbkg_QCD,"Background (QCD MC)","l");
     meg->AddEntry(h_Deno,"Denominator","l");
     meg->AddEntry(h_Deno_GJ,"Denominator (GJ MC)","l");
     meg->AddEntry(h_Deno_QCD,"Denominator (QCD MC)","l");
     
     TString leg_h0;  leg_h0.Form("Purity > %0.2f (%2.1f-%2.1f)", thresholds.at(0), xsatthresh.at(0), xsatqt.at(0));
     TString leg_h1;  leg_h1.Form("Purity > %0.2f (%2.1f-%2.1f)", thresholds.at(1), xsatthresh.at(1), xsatqt.at(1));
     TString leg_h2;  leg_h2.Form("Purity > %0.2f (%2.1f-%2.1f)", thresholds.at(2), xsatthresh.at(2), xsatqt.at(2));
     TString leg_h3;  leg_h3.Form("Purity > %0.2f (%2.1f-%2.1f)", thresholds.at(3), xsatthresh.at(3), xsatqt.at(3));
     TString leg_h4;  leg_h4.Form("Purity > %0.2f (%2.1f-%2.1f)", thresholds.at(4), xsatthresh.at(4), xsatqt.at(4));

     TLegend *neg = new TLegend(0.15,0.5,0.4,0.75);
     //meg->SetTextSize(0.04) ;
     neg->SetFillColor(0); neg->SetShadowColor(0);neg->SetBorderSize(2);
     neg->SetTextFont(22.);
     neg->AddEntry(lhc_lo0,leg_h0,"l");
     neg->AddEntry(lhc_lo1,leg_h1,"l");
     neg->AddEntry(lhc_lo2,leg_h2,"l");
     neg->AddEntry(lhc_lo3,leg_h3,"l");
     neg->AddEntry(lhc_lo4,leg_h4,"l");

     h_Nsig->SetTitle(cut);
     h_Nsig->SetXTitle(h_Nsig->GetTitle());
     h_Nsig->SetYTitle("Events ");
     h_Nsig->SetMaximum(1000*themax);
     h_Nsig->SetMinimum(1);

     h_Nsig->Draw("hist");
     h_Nsig_GJ->Draw("hist,same");
     h_Nsig_QCD->Draw("hist,same");
     h_Nbkg->Draw("hist,same");
     h_Nbkg_GJ->Draw("hist,same");
     h_Nbkg_QCD->Draw("hist,same");
     h_Deno->Draw("hist,same");
     h_Deno_GJ->Draw("hist,same");
     h_Deno_QCD->Draw("hist,same");

     meg->SetHeader("photon p_{T}: "+ptrange);
     meg->Draw();
     if(dolines){
      neg->Draw();
     }
     title->DrawTextNDC(0.17,0.87,"CMS");
     extra->DrawTextNDC(0.17,0.81,"Preliminary");
     lumi->DrawTextNDC(0.9,0.91,"2.32 /fb (13 TeV)");

     if(dolines){
      lhb_lo0->Draw();
      lhb_lo1->Draw();
      lhb_lo2->Draw();
      lhb_lo3->Draw();
      lhb_lo4->Draw();
      
      lhb_hi0->Draw();
      lhb_hi1->Draw();
      lhb_hi2->Draw();
      lhb_hi3->Draw();
      lhb_hi4->Draw();

      lhc_lo0->Draw();
      lhc_lo1->Draw();
      lhc_lo2->Draw();
      lhc_lo3->Draw();
      lhc_lo4->Draw();
      
      lhc_hi0->Draw();
      lhc_hi1->Draw();
      lhc_hi2->Draw();
      lhc_hi3->Draw();
      lhc_hi4->Draw();
     }

     gPad->SetLogy();

     canvas->SaveAs(outpath+"/Histos_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".pdf");
     canvas->SaveAs(wwwpath+"/pdf/"+ptrange+"/"+isovar+"/"+cut+lines+"/Histos_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".pdf");
     canvas->SaveAs(wwwpath+"/png/"+ptrange+"/"+isovar+"/"+cut+lines+"/Histos_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".png");
     canvas->Clear();
     gPad->SetLogy(kFALSE);
     //-----------------------------------------------------
     //-----------------------------------------------------
     //Draw Purity
     TLegend *leg = new TLegend(0.5,0.75,0.88,0.88);
     leg->SetTextSize(0.04) ;
     leg->SetFillColor(0); leg->SetShadowColor(0);leg->SetBorderSize(0);
     leg->SetTextFont(22.);
     leg->AddEntry(purity_signal,"Signal","lep");
     leg->AddEntry(purity_background,"Background","lep");

     float xmin ; //= 0.;
     float xmax ; //= 25.;
     xmin = h_Nsig->GetXaxis()->GetXmin();
     xmax = h_Nsig->GetXaxis()->GetXmax();
     TLine *lowline = new TLine(xmin,0,xmax,0);
     TLine *hiline = new TLine(xmin,1,xmax,1);
     lowline->SetLineWidth(1); lowline->SetLineColor(1); lowline->SetLineStyle(3);         
     hiline->SetLineWidth(1); hiline->SetLineColor(1); hiline->SetLineStyle(3);         

     TH1F *hframe = canvas->DrawFrame(xmin,-0.05,xmax,1.4,"");
     lowline->Draw();
     hiline->Draw();
     title->DrawTextNDC(0.17,0.87,"CMS");
     extra->DrawTextNDC(0.17,0.81,"Preliminary");
     lumi->DrawTextNDC(0.9,0.91,"2.32 /fb (13 TeV)");
     hframe->SetTitle(cut);
     hframe->SetXTitle(isovar);
     hframe->SetYTitle("Purity");
     
     // draw points
     purity_signal->Draw("P");
     purity_background->Draw("P");
     leg->SetHeader("photon p_{T}: "+ptrange);
     leg->Draw();

     //canvas->SaveAs(outpath+"/Purity_"+isovar+"_"+ptrange+"_"+cut+"_"+rebin+xn+".pdf");

     if(dolines){
      lgb_lo0->Draw();
      lgb_lo1->Draw();
      lgb_lo2->Draw();
      lgb_lo3->Draw();
      lgb_lo4->Draw();
      
      lgb_hi0->Draw();
      lgb_hi1->Draw();
      lgb_hi2->Draw();
      lgb_hi3->Draw();
      lgb_hi4->Draw();
      
      lgc_lo0->Draw();
      lgc_lo1->Draw();
      lgc_lo2->Draw();
      lgc_lo3->Draw();
      lgc_lo4->Draw();
      
      lgc_hi0->Draw();
      lgc_hi1->Draw();
      lgc_hi2->Draw();
      lgc_hi3->Draw();
      lgc_hi4->Draw();

      lgb_pur0->Draw();
      lgb_pur1->Draw();
      lgb_pur2->Draw();
      lgb_pur3->Draw();
      lgb_pur4->Draw();
      lgc_pur0->Draw();
      lgc_pur1->Draw();
      lgc_pur2->Draw();
      lgc_pur3->Draw();
      lgc_pur4->Draw();
     }
     
     canvas->SaveAs(outpath+"/Purity_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".pdf");
     canvas->SaveAs(wwwpath+"/pdf/"+ptrange+"/"+isovar+"/"+cut+lines+"/Purity_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".pdf");
     canvas->SaveAs(wwwpath+"/png/"+ptrange+"/"+isovar+"/"+cut+lines+"/Purity_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".png");

     canvas->Clear();
     //-----------------------------------------------------

     // clean your room!
     h_Nsig->Delete();
     h_Nsig_GJ->Delete();
     h_Nsig_QCD->Delete();
     h_Nbkg->Delete();
     h_Nbkg_GJ->Delete();
     h_Nbkg_QCD->Delete();
     h_Deno->Delete();
     h_Deno_GJ->Delete();
     h_Deno_QCD->Delete();
    }
   log<<"--------------------------------------\n";
   log_latex<<"--------------------------------------\n";
   }
  }
 }
 log.close();
 log_latex.close();
}
void Plot_searchBin_full_ICHEP_wQCD(string option="", int pull=0){ // string option="QCD"

  // Use option="QCD" to produce plots in QCD binning

  char tempname[200];
  // Open root file
  sprintf(tempname,"LLPrediction_QCD.root");

  // true: do closure test (MC prediction vs MC truth)
  // false: do data driven prediction and compare to MC truth
  bool doDataVsMC = false;

  // Add systematics in quadrature to stat. uncertainty on prediction
  // Non-closure systematic not included yet!
  bool showSystematics = false;

  bool doClosurewoIsoTrackVeto = false;

  ///////////////////////////////////////////////////////////////////////////////////////////
  ////Some cosmetic work for official documents.
  //
  // Set basic style
  //
  setTDRStyle();
  gStyle->SetPalette(1) ; // for better color output

  //
  // Canvas size
  int W = 1200;
  int H = 740;
  int H_ref = 740;
  int W_ref = 800;
  float T = 0.10*H_ref;
  float B = 0.06*H_ref;
  float L = 0.16*W_ref;
  float R = 0.04*W_ref;

  //
  // Various vertical line coordinates
  float ymax_top = 40000.;
  float ymin_top = 0.015;

  float ymax2_top = 1000.;
  float ymax3_top = 200.;
  float ymax4_top = 30.;
  float ymax5_top = 5.;

  float ymax_bottom = 1.99;
  float ymin_bottom = 0.01;

  float ymax2_bottom = 2.15;
  float ymax3_bottom = 2.15;
  float ymax4_bottom = 2.15;

  //
  // Luminosity information for scaling
  double lumi     = 7.6; // normaliza to this lumi (fb-1)
  double lumi_ref = 7.6; // normaliza to 3 (fb-1)
  
  ///////////////////////////////////////////////////////////////////////////////////////////
  //
  // More specific style set, opening input files etc

  gStyle->SetOptStat(0);  ///to avoid the stat. on the plots
  //gStyle->SetErrorX(0);
  char xtitlename[200];
  char ytitlename[200];

  TFile * LLFile = new TFile(tempname,"R");
  printf("Opened %s\n",tempname);

  //
  // Define legend
  //
  Float_t legendX1 = .655; //.50;
  Float_t legendX2 = .955; //.70;
  Float_t legendY1 = .53; //.65;
  Float_t legendY2 = .78;

  TLegend* catLeg1 = new TLegend(legendX1,legendY1,legendX2,legendY2);
  //catLeg1->SetTextSize(0.060);
  catLeg1->SetTextSize(0.044);
  catLeg1->SetTextFont(42);
  catLeg1->SetFillColor(0);
  catLeg1->SetLineColor(1);
  catLeg1->SetBorderSize(1);

  //
  // Define canvas
  //
  TCanvas *canvas = new TCanvas("canvas","canvas",10,10,W,H);

  canvas->SetFillColor(0);
  canvas->SetBorderMode(0);
  canvas->SetFrameFillStyle(0);
  canvas->SetFrameBorderMode(0);
  canvas->SetLeftMargin( L/W );
  canvas->SetRightMargin( R/W );
  canvas->SetTopMargin( T/H );
  canvas->SetBottomMargin( B/H );
  canvas->SetTickx(0);
  canvas->SetTicky(0);

  canvas->Divide(1, 2);
  
  //
  // Define pads
  //
  TPad* canvas_up = (TPad*) canvas->GetListOfPrimitives()->FindObject("canvas_1");
  TPad* canvas_dw = (TPad*) canvas->GetListOfPrimitives()->FindObject("canvas_2");

  //
  // define the size
  double up_height     = 0.8;  // please tune so that the upper figures size will meet your requirement
  double dw_correction = 1.30; // please tune so that the smaller canvas size will work in your environment
  double font_size_dw  = 0.1;  // please tune the font size parameter for bottom figure
  double dw_height     = (1. - up_height) * dw_correction;
  double dw_height_offset = 0.04; // KH, added to put the bottom one closer to the top panel

  //
  // set pad size
  canvas_up->SetPad(0., 1 - up_height,    1., 1.00);
  canvas_dw->SetPad(0., 0.,               1., dw_height+dw_height_offset);
  //
  canvas_up->SetFrameFillColor(0);
  canvas_up->SetFillColor(0);
  canvas_up->SetTopMargin(0.12);
  canvas_up->SetLeftMargin(0.1);
  //
  canvas_dw->SetFillColor(0);
  canvas_dw->SetFrameFillColor(0);
  canvas_dw->SetBottomMargin(0.35);
  canvas_dw->SetTopMargin(0);
  canvas_dw->SetLeftMargin(0.1);
  
  //
  // draw top figure
  canvas_up->cd();

  TH1D * GenHist, * EstHist,* thist;
  TH1D * GenHistTemp, * EstHistTemp;
  TH1D * GenHistD, * EstHistD;
  TH1D * GenHistDTemp, * EstHistDTemp;
  TH1D * EstSystematics;
  TH1D * histTemplate;

  double HT_x_max=2500.;
  double HT_x_min=400.;
  double MHT_x_max=1000.;
  double NJet_x_max=15.;
  double NBtag_x_max=4.;
  double search_x_max=208.-0.5;
  if(option.find("QCD")!=string::npos)search_x_max=208.-0.5;
  double search_x_min=1.-0.5;

  TDirectory *dPre = 0;
  TDirectory *dExp = (TDirectory*)LLFile->Get("Expectation");

  if(doDataVsMC){
    dPre = (TDirectory*)LLFile->Get("Prediction_data");
  }else{
    dPre = (TDirectory*)LLFile->Get("Prediction_MC");
  }  

  if(doDataVsMC){    
      EstHistTemp=(TH1D*) dPre->Get("totalPred_LL")->Clone();
      EstHistDTemp=(TH1D*) dPre->Get("totalPred_LL")->Clone();
  }else{
    if(doClosurewoIsoTrackVeto){
      EstHistTemp=(TH1D*) dPre->Get("totalPred_woIsoTrack_LL_MC")->Clone();
      EstHistDTemp=(TH1D*) dPre->Get("totalPred_woIsoTrack_LL_MC")->Clone();
    }else{
      EstHistTemp=(TH1D*) dPre->Get("totalPred_LL_MC")->Clone();
      EstHistDTemp=(TH1D*) dPre->Get("totalPred_LL_MC")->Clone();
    }
  }


  if(doClosurewoIsoTrackVeto){
      GenHistTemp=(TH1D*) dExp->Get("totalExp_woIsoTrack_LL")->Clone();
      GenHistDTemp=(TH1D*) dExp->Get("totalExp_woIsoTrack_LL")->Clone();;
  }else{
      GenHistTemp=(TH1D*) dExp->Get("totalExp_LL")->Clone();
      GenHistDTemp=(TH1D*) dExp->Get("totalExp_LL")->Clone();
  }

  if(showSystematics){
    TDirectory *dSys = (TDirectory*)LLFile->Get("AdditionalContent");
    if(doDataVsMC){
      EstSystematics=(TH1D*) dSys->Get("totalPropSysUp_LL")->Clone();
    }else{
      EstSystematics=(TH1D*) dSys->Get("totalPropSysUp_LL_MC")->Clone();
    }
  }

  if(EstHistTemp->GetNbinsX() != GenHistTemp->GetNbinsX()) std::cout<<"NbinsX of Expectation and Prediction don't agree!"<<std::endl;

  EstHist = new TH1D("Exp", "Exp", EstHistTemp->GetNbinsX(), 0.5, EstHistTemp->GetNbinsX()+0.5);
  EstHistD = new TH1D("ExpD", "ExpD", EstHistDTemp->GetNbinsX(), 0.5, EstHistDTemp->GetNbinsX()+0.5);
  GenHist = new TH1D("Pred", "Pred", GenHistTemp->GetNbinsX(), 0.5, GenHistTemp->GetNbinsX()+0.5);
  GenHistD = new TH1D("PredD", "PredD", GenHistDTemp->GetNbinsX(), 0.5, GenHistDTemp->GetNbinsX()+0.5);

  for(int i = 0; i <= EstHistTemp->GetNbinsX()+1; i++){
    EstHist->SetBinContent(i, EstHistTemp->GetBinContent(i));    
    EstHistD->SetBinContent(i, EstHistDTemp->GetBinContent(i));

    if(showSystematics){
      EstHist->SetBinError(i, std::sqrt(EstHistTemp->GetBinError(i)*EstHistTemp->GetBinError(i)+EstSystematics->GetBinContent(i)*EstSystematics->GetBinContent(i)*EstHistTemp->GetBinError(i)*EstHistTemp->GetBinError(i)));
      EstHistD->SetBinError(i, std::sqrt(EstHistDTemp->GetBinError(i)*EstHistDTemp->GetBinError(i)+EstSystematics->GetBinContent(i)*EstSystematics->GetBinContent(i)*EstHistDTemp->GetBinError(i)*EstHistDTemp->GetBinError(i)));
    }else{
      EstHist->SetBinError(i, EstHistTemp->GetBinError(i));
      EstHistD->SetBinError(i, EstHistDTemp->GetBinError(i));
    }    

    GenHist->SetBinContent(i, GenHistTemp->GetBinContent(i));
    GenHist->SetBinError(i, GenHistTemp->GetBinError(i));
    GenHistD->SetBinContent(i, GenHistDTemp->GetBinContent(i));
    GenHistD->SetBinError(i, GenHistDTemp->GetBinError(i));
  }

  GenHist->SetLineColor(4);
  EstHist->SetLineColor(4);
  //GenHist->GetXaxis()->SetLabelFont(42);
  //GenHist->GetXaxis()->SetLabelOffset(0.007);
  //GenHist->GetXaxis()->SetLabelSize(0.04);
  //GenHist->GetXaxis()->SetTitleSize(0.05);
  //GenHist->GetXaxis()->SetTitleOffset(0.9);
  //GenHist->GetXaxis()->SetTitleOffset(0.5);
  //GenHist->GetXaxis()->SetTitleFont(42);
  //GenHist->GetYaxis()->SetLabelFont(42);
  //GenHist->GetYaxis()->SetLabelOffset(0.007);
  //GenHist->GetYaxis()->SetLabelSize(0.04);
  GenHist->GetYaxis()->SetLabelSize(0.045*1.15);
  GenHist->GetYaxis()->SetTitleSize(0.06*1.15);
  GenHist->GetYaxis()->SetTitleOffset(0.6);
  GenHist->GetYaxis()->SetTitleFont(42);


  //EstHist->GetXaxis()->SetLabelFont(42);
  //EstHist->GetXaxis()->SetLabelOffset(0.007);
  //EstHist->GetXaxis()->SetLabelSize(0.04);
  //EstHist->GetXaxis()->SetTitleSize(0.05);
  //EstHist->GetXaxis()->SetTitleOffset(0.9);
  //EstHist->GetXaxis()->SetTitleFont(42);
  //EstHist->GetYaxis()->SetLabelFont(42);
  //EstHist->GetYaxis()->SetLabelOffset(0.007);
  //EstHist->GetYaxis()->SetLabelSize(0.04);
  //EstHist->GetYaxis()->SetTitleSize(0.08);
  //EstHist->GetYaxis()->SetTitleOffset(2.0);
  //EstHist->GetYaxis()->SetTitleFont(42);
  sprintf(xtitlename,"Search region bin number");
  sprintf(ytitlename,"Events");
  gPad->SetLogy();
  GenHist->SetMaximum(ymax_top);
  GenHist->SetMinimum(ymin_top);
  GenHist->GetXaxis()->SetRangeUser(search_x_min,search_x_max);

  //GenHist->GetYaxis()->SetTickLength(0.015);
  //GenHist->GetXaxis()->SetTickLength(0.02);

  //gPad->SetGridx(1);
  TExec *ex1 = new TExec("ex1","gStyle->SetErrorX(0);");
  TExec *ex2 = new TExec("ex2","gStyle->SetErrorX(0.5);");

  GenHist->SetTitle("");
  GenHist->SetMarkerStyle(20);
  GenHist->SetMarkerSize(1.2);
  GenHist->SetLineColor(1);
  GenHist->GetXaxis()->SetTitle(xtitlename);
  GenHist->GetYaxis()->SetTitle(ytitlename);
  GenHist->Scale(lumi/lumi_ref);
  EstHist->Scale(lumi/lumi_ref);
  TH1D * GenHist_Normalize = static_cast<TH1D*>(GenHist->Clone("GenHist_Normalize"));
  GenHist_Normalize->SetMaximum(ymax_top);
  GenHist_Normalize->SetMinimum(ymin_top);
  ex1->Draw();
  //GenHist_Normalize->GetListOfFunctions()->Add(ex1);
  GenHist_Normalize->DrawCopy("e");

  EstHist->SetFillStyle(3144);
  EstHist->SetFillColor(kRed-10);
  EstHist->SetMarkerStyle(20);
  EstHist->SetMarkerSize(0.0001);
  TH1D * EstHist_Normalize = static_cast<TH1D*>(EstHist->Clone("EstHist_Normalize"));
  ex2->Draw();
  //EstHist_Normalize->GetListOfFunctions()->Add(ex2);
  EstHist_Normalize->DrawCopy("e2same");
  //EstHist_Normalize->DrawCopy("esame");

  TH1D *EstHist_Normalize_Clone = (TH1D*)EstHist_Normalize->Clone();
  for(int i=1; i<208; i++) {
    EstHist_Normalize_Clone->SetBinError(i,0);
  }
  EstHist_Normalize_Clone->SetFillColor(kWhite);
  EstHist_Normalize_Clone->Draw("esame");

  GenHist->Print("all");
  EstHist->Print("all");
  
  //
  // Re-draw to have "expectation" on top of "prediction"
  ex1->Draw();
  GenHist_Normalize->DrawCopy("esame");
  //

  TString line = "";
  sprintf(tempname,"%8.1f",lumi);
  line+=tempname;
  line+=" fb^{-1} (13 TeV)";
  
  int iPeriod = 0;    // 1=7TeV, 2=8TeV, 3=7+8TeV, 7=7+8+13TeV, 0=free form (uses lumi_sqrtS)
  int iPos=0;
    
  writeExtraText = true;  
  if(doDataVsMC) extraText   = "        Preliminary";
  else extraText   = "        Simulation";
  //float extraTextFont = 52;  // default is helvetica-italics

  // text sizes and text offsets with respect to the top frame
  // in unit of the top margin size
  //lumiTextSize     = 0.5;
  //float lumiTextOffset   = 0.2;
  //cmsTextSize      = 0.65;
  //float cmsTextOffset    = 0.1;  // only used in outOfFrame version
  
  //relPosX    = 0.045;
  //relPosY    = 0.035;
  //relExtraDY = 1.2;
  
  // ratio of "CMS" and extra text size
  //float extraOverCmsTextSize  = 0.76;
    
  //TString lumi_13TeV = "20.1 fb^{-1}";
  //TString lumi_8TeV  = "19.7 fb^{-1}";
  //TString lumi_7TeV  = "5.1 fb^{-1}";
  TString lumi_sqrtS = line;

  //
  if(option.find("QCD")==string::npos ){
    
    //-----------------------------------------------------------
    // Putting lines and labels explaining search region definitions
    //-----------------------------------------------------------

    //TString CMSlabel = "";
    //cmsText = "#bf{CMS} #it{Simulation}";
    //CMSlabel += "#splitline{#bf{CMS}}{#scale[0.6]{#it{Simulation}}}";

    /*
    double x0 = gStyle->GetPadLeftMargin();
    double x1 = 1.-gStyle->GetPadRightMargin();
    double y0 = 1.005-gStyle->GetPadTopMargin();
    double y1 = 0.96;
    TPaveText *Lumitxt = new TPaveText(x0,y0,x1,y1,"NDC");
    Lumitxt->SetBorderSize(0);
    Lumitxt->SetFillColor(0);
    Lumitxt->SetTextFont(42);
    Lumitxt->SetTextAlign(31);
    Lumitxt->SetTextSize(1.2*gStyle->GetPadTopMargin());
    Lumitxt->SetMargin(0.);
    Lumitxt->AddText(line);
    //Lumitxt->Draw("same");

    x0 = gStyle->GetPadLeftMargin()+0.03;
    x1 = gStyle->GetPadLeftMargin()+0.13;
    y0 = 0.905-gStyle->GetPadTopMargin();
    y1 = 0.88;
    TPaveText *CMStxt = new TPaveText(x0,y0,x1,y1,"NDC");
    CMStxt->SetBorderSize(0);
    CMStxt->SetFillColor(0);
    CMStxt->SetTextFont(42);
    CMStxt->SetTextAlign(11);
    CMStxt->SetTextSize(1.2*gStyle->GetPadTopMargin());
    CMStxt->SetMargin(0.);
    CMStxt->AddText(CMSlabel);
    //CMStxt->Draw("same");
    */

    // Njet separation lines
    TLine *tl_njet = new TLine();
    tl_njet->SetLineStyle(2);
    tl_njet->DrawLine(53.-0.5,ymin_top,53.-0.5,ymax_top); 
    tl_njet->DrawLine(105.-0.5,ymin_top,105.-0.5,ymax_top); 
    tl_njet->DrawLine(157.-0.5,ymin_top,157.-0.5,ymax_top); 

    // Njet labels
    TLatex * ttext_njet = new TLatex();
    ttext_njet->SetTextFont(42);
    ttext_njet->SetTextSize(0.04);
    ttext_njet->SetTextAlign(22);
    ttext_njet->DrawLatex(26.-0.5 , ymax_top/4. , "3 #leq N_{#scale[0.2]{ }jet} #leq 4");
    ttext_njet->DrawLatex(78.-0.5 , ymax_top/4. , "5 #leq N_{#scale[0.2]{ }jet} #leq 6");
    ttext_njet->DrawLatex(130.-0.5 , ymax_top/4. , "7 #leq N_{#scale[0.2]{ }jet} #leq 8");
    ttext_njet->DrawLatex(182.-0.5 , ymax_top/4. , "N_{#scale[0.2]{ }jet} #geq 9");

    // Nb separation lines
    TLine *tl_nb = new TLine();
    tl_nb->SetLineStyle(3);
    tl_nb->DrawLine(14.-0.5,ymin_top,14.-0.5,ymax2_top); 
    tl_nb->DrawLine(27.-0.5,ymin_top,27.-0.5,ymax2_top); 
    tl_nb->DrawLine(40.-0.5,ymin_top,40.-0.5,ymax2_top);
    tl_nb->DrawLine(53.-0.5,ymin_top,53.-0.5,ymax2_top);
    tl_nb->DrawLine(66.-0.5,ymin_top,66.-0.5,ymax3_top); 
    tl_nb->DrawLine(79.-0.5,ymin_top,79.-0.5,ymax3_top); 
    tl_nb->DrawLine(92.-0.5,ymin_top,92.-0.5,ymax3_top); 
    tl_nb->DrawLine(105.-0.5,ymin_top,105.-0.5,ymax3_top); 
    tl_nb->DrawLine(118.-0.5,ymin_top,118.-0.5,ymax4_top); 
    tl_nb->DrawLine(131.-0.5,ymin_top,131.-0.5,ymax4_top); 
    tl_nb->DrawLine(144.-0.5,ymin_top,144.-0.5,ymax4_top);
    tl_nb->DrawLine(157.-0.5,ymin_top,157.-0.5,ymax4_top);
    tl_nb->DrawLine(170.-0.5,ymin_top,170.-0.5,ymax5_top);
    tl_nb->DrawLine(183.-0.5,ymin_top,183.-0.5,ymax5_top);
    tl_nb->DrawLine(196.-0.5,ymin_top,196.-0.5,ymax5_top);
    
    // Nb labels
    TLatex * ttext_nb = new TLatex();
    ttext_nb->SetTextFont(42);
    ttext_nb->SetTextSize(0.04);
    ttext_nb->SetTextAlign(22);
    
    ttext_nb->DrawLatex(9.-0.5 , ymax_top/12. , "N_{#scale[0.2]{ }b-jet}");
    ttext_nb->DrawLatex(8.-0.5 , ymax_top/40. , "0");
    ttext_nb->DrawLatex(20.-0.5 , ymax_top/40. , "1");
    ttext_nb->DrawLatex(33.-0.5 , ymax_top/40. , "2");
    ttext_nb->DrawLatex(46.-0.5 , ymax_top/40. , "#geq 3");

    //
  } else {
    
    //-----------------------------------------------------------
    // Putting lines and labels explaining search region definitions
    //-----------------------------------------------------------

    // Njet separation lines
    TLine *tl_njet = new TLine();
    tl_njet->SetLineStyle(2);
    tl_njet->DrawLine( 45.,ymin_top, 45.,ymax_top); 
    tl_njet->DrawLine( 89.,ymin_top, 89.,ymax_top); 
    tl_njet->DrawLine(133.,ymin_top,133.,ymax_top); 
    tl_njet->DrawLine(177.,ymin_top,177.,ymax_top); 

    // Njet labels
    TLatex * ttext_njet = new TLatex();
    ttext_njet->SetTextFont(42);
    ttext_njet->SetTextSize(0.04);
    ttext_njet->SetTextAlign(22);
    ttext_njet->DrawLatex(23. , ymax_top/4. , "N_{jets} = 4");
    ttext_njet->DrawLatex(67. , ymax_top/4. , "N_{jets} = 5");
    ttext_njet->DrawLatex(111., ymax_top/4. , "N_{jets} = 6");
    ttext_njet->DrawLatex(155., ymax_top/4. , "7 #leq N_{jets} #leq 8");
    ttext_njet->DrawLatex(199., ymax_top/4. , "N_{jets} #geq 9");

    // Nb separation lines
    TLine *tl_nb = new TLine();
    tl_nb->SetLineStyle(3);
    tl_nb->DrawLine(12.,ymin_top,12.,ymax2_top); 
    tl_nb->DrawLine(23.,ymin_top,23.,ymax2_top); 
    tl_nb->DrawLine(34.,ymin_top,34.,ymax2_top); 

    tl_nb->DrawLine(56.,ymin_top,56.,ymax2_top); 
    tl_nb->DrawLine(67.,ymin_top,67.,ymax2_top); 
    tl_nb->DrawLine(78.,ymin_top,78.,ymax2_top); 

    tl_nb->DrawLine(100.,ymin_top,100.,ymax2_top); 
    tl_nb->DrawLine(111.,ymin_top,111.,ymax2_top); 
    tl_nb->DrawLine(122.,ymin_top,122.,ymax2_top); 

    tl_nb->DrawLine(144.,ymin_top,144.,ymax3_top); 
    tl_nb->DrawLine(155.,ymin_top,155.,ymax3_top); 
    tl_nb->DrawLine(166.,ymin_top,166.,ymax3_top); 

    tl_nb->DrawLine(188.,ymin_top,188.,ymax4_top); 
    tl_nb->DrawLine(199.,ymin_top,199.,ymax4_top); 
    tl_nb->DrawLine(210.,ymin_top,210.,ymax4_top); 

    // Nb labels
    TLatex * ttext_nb = new TLatex();
    ttext_nb->SetTextFont(42);
    ttext_nb->SetTextSize(0.04);
    ttext_nb->SetTextAlign(22);
    ttext_nb->SetTextAngle(90);

    ttext_nb->DrawLatex( 6. , ymax_top/50. , "N_{b} = 0");
    ttext_nb->DrawLatex(17. , ymax_top/50. , "N_{b} = 1");
    ttext_nb->DrawLatex(28. , ymax_top/50. , "N_{b} = 2");
    ttext_nb->DrawLatex(39. , ymax_top/50. , "N_{b} #geq 3");
    
    TText * ttext = new TLatex(160. , ymax_top/50. , "Normalized to 10 fb^{-1}");
    ttext->SetTextFont(42);
    ttext->SetTextSize(0.045);
    ttext->SetTextAlign(22);
    ttext->Draw();

  }

  // Legend & texts
  sprintf(tempname,"Lost-lepton background");
  catLeg1->SetHeader(tempname);
  //sprintf(tempname,"#tau_{hadronic} BG expectation (MC truth)");
  sprintf(tempname,"Direct from simulation");
  catLeg1->AddEntry(GenHist,tempname,"p");
  //sprintf(tempname,"Prediction from MC");
  if(doDataVsMC) sprintf(tempname,"Prediction from data");
  else sprintf(tempname,"Treat simulation like data");
  catLeg1->AddEntry(EstHist,tempname);
  catLeg1->Draw();

  gPad->RedrawAxis();

  //
  // Bottom ratio plot
  //
  // ----------

    //
    // Preparing ratio histograms
      TH1D * numerator   = static_cast<TH1D*>(GenHist->Clone("numerator"));
      TH1D * numerator_fullstaterr   = static_cast<TH1D*>(GenHist->Clone("numerator_fullstaterr"));
      TH1D * denominator = static_cast<TH1D*>(EstHist->Clone("denominator"));

      TH1D * GenHist_Clone = static_cast<TH1D*>(GenHist->Clone("GenHist_Clone"));
      TH1D * EstHist_Clone = static_cast<TH1D*>(EstHist->Clone("EstHist_Clone"));
      TH1D * EstHist_NoError = static_cast<TH1D*>(EstHist->Clone("EstHist_NoError"));
      TH1D * One_NoError = static_cast<TH1D*>(EstHist->Clone("EstHist_NoError"));
      for (int ibin=0; ibin<EstHist_NoError->GetNbinsX()+2; ibin++){ // scan including underflow and overflow bins
	EstHist_NoError->SetBinError(ibin,0.);
	One_NoError->SetBinContent(ibin,1.);
	One_NoError->SetBinError(ibin,0.);
      }

      //EstHistD->Add(GenHistD,-1);
      numerator->Divide(GenHist_Clone,EstHist_NoError,1,1,"");
      denominator->Divide(EstHist_Clone,EstHist_NoError,1,1,"");

      numerator_fullstaterr->Divide(GenHist_Clone,EstHist_Clone,1,1,"");  // Expectation/Prediction
      numerator_fullstaterr->Add(One_NoError,-1.);                        // Expectation/Prediction-1

      // draw bottom figure
      canvas_dw->cd();
      // font size
      numerator->GetXaxis()->SetLabelSize(font_size_dw);
      numerator->GetXaxis()->SetTitleSize(font_size_dw);
      numerator->GetYaxis()->SetLabelSize(font_size_dw);
      numerator->GetYaxis()->SetTitleSize(font_size_dw);

      //
      // Horizontal Lines
      TLine *tline  = new TLine(search_x_min,1.,search_x_max,1.);
      TLine *tline0 = new TLine(search_x_min,0.,search_x_max,0.);

      //
      // Common to all bottom plots
      //
      //sprintf(ytitlename,"#frac{Estimate - #tau_{had} BG}{#tau_{had} BG} ");
      sprintf(ytitlename,"#frac{Direct}{Prediction} ");
      numerator->SetMaximum(ymax_bottom);
      numerator->SetMinimum(ymin_bottom);

      //
      // Specific to each bottom plot
      //
      // Setting style
      //numerator->SetMaximum(1.4);
      //numerator->GetXaxis()->SetLabelFont(42);
      //numerator->GetXaxis()->SetLabelOffset(0.007);
      numerator->GetXaxis()->SetLabelSize(0.18*0.045/0.06);
      numerator->GetXaxis()->SetTitleSize(0.18);
      numerator->GetXaxis()->SetTitleOffset(0.9);
      numerator->GetXaxis()->SetTitleFont(42);
      //numerator->GetYaxis()->SetLabelFont(42);
      //numerator->GetYaxis()->SetLabelOffset(0.007);
      numerator->GetYaxis()->SetLabelSize(0.18*0.045/0.06);
      numerator->GetYaxis()->SetTitleSize(0.18);
      //numerator->GetYaxis()->SetTitleOffset(0.5);
      numerator->GetYaxis()->SetTitleOffset(0.25);
      numerator->GetYaxis()->SetTitleFont(42);

      numerator->GetXaxis()->SetTitle(xtitlename);
      numerator->GetYaxis()->SetTitle(ytitlename);

      //gPad->SetGridx(1);


      if (pull==1){

	sprintf(ytitlename,"#frac{Exp - Pre}{Stat Error} ");
	numerator->SetMaximum(8.);
	numerator->SetMinimum(-8.);
	
	//
	// Specific to each bottom plot
	//
	// Setting style

	for (int ibin=0; ibin<numerator_fullstaterr->GetNbinsX()+2; ibin++){ // scan including underflow and overflow bins
	  numerator_fullstaterr->SetBinContent(ibin,numerator_fullstaterr->GetBinContent(ibin)/numerator_fullstaterr->GetBinError(ibin));
	  numerator_fullstaterr->SetBinError(ibin,0.);
	}
	numerator_fullstaterr->Print("all");
	
	numerator_fullstaterr->GetXaxis()->SetLabelSize(font_size_dw);
	numerator_fullstaterr->GetXaxis()->SetTitleSize(font_size_dw);
	numerator_fullstaterr->GetYaxis()->SetLabelSize(font_size_dw);
	numerator_fullstaterr->GetYaxis()->SetTitleSize(font_size_dw);

	numerator_fullstaterr->GetXaxis()->SetTitleSize(0.12);
	numerator_fullstaterr->GetXaxis()->SetTitleOffset(0.9);
	numerator_fullstaterr->GetXaxis()->SetTitleFont(42);
	numerator_fullstaterr->GetYaxis()->SetTitleSize(0.13);
	numerator_fullstaterr->GetYaxis()->SetTitleOffset(0.5);
	numerator_fullstaterr->GetYaxis()->SetTitleFont(42);
	
	numerator_fullstaterr->GetXaxis()->SetTitle(xtitlename);
	numerator_fullstaterr->GetYaxis()->SetTitle(ytitlename);
	//numerator_fullstaterr->SetFillColor(kGreen-3);
	numerator_fullstaterr->SetFillColor(kRed-10);
	numerator_fullstaterr->DrawCopy();

	//
	// Drawing lines
	tline0->SetLineStyle(2);
	//tline0->Draw();

      }
      else {

      //
      // Plotting
      numerator->GetYaxis()->SetNdivisions(505);
      numerator->GetYaxis()->SetTickLength(0.015);
      numerator->GetXaxis()->SetTickLength(0.08);
      numerator->SetTitle("");
      ex1->Draw();
      numerator->DrawCopy();

      ex2->Draw();
      denominator->DrawCopy("e2same");
      //denominator->DrawCopy("same");

      TH1D *denominator_Clone = (TH1D*)denominator->Clone();
      denominator_Clone->SetFillColor(kWhite);
      denominator_Clone->Draw("hist same");

      ex1->Draw();
      numerator->DrawCopy("same");

      numerator->Print("all");
      denominator->Print("all");
      numerator_fullstaterr->Print("all");

      //
      // Drawing lines
      tline->SetLineStyle(2);
      //tline->Draw();

      }
      

      //
      if(option.find("QCD")==string::npos ){
	
        // Njet separation lines
        TLine *tl_njet = new TLine();
        tl_njet->SetLineStyle(2);
        tl_njet->DrawLine(53.-0.5,ymin_bottom,53.-0.5,ymax_bottom); 
        tl_njet->DrawLine(105.-0.5,ymin_bottom,105.-0.5,ymax_bottom); 
        tl_njet->DrawLine(157.-0.5,ymin_bottom,157.-0.5,ymax_bottom); 

        // Nb separation lines
        TLine *tl_nb = new TLine();
        tl_nb->SetLineStyle(3);
        tl_nb->DrawLine(14.-0.5,ymin_bottom,14.-0.5,ymax2_bottom); 
        tl_nb->DrawLine(27.-0.5,ymin_bottom,27.-0.5,ymax2_bottom); 
        tl_nb->DrawLine(40.-0.5,ymin_bottom,40.-0.5,ymax2_bottom);
        tl_nb->DrawLine(53.-0.5,ymin_bottom,53.-0.5,ymax2_bottom);
        tl_nb->DrawLine(66.-0.5,ymin_bottom,66.-0.5,ymax2_bottom); 
        tl_nb->DrawLine(79.-0.5,ymin_bottom,79.-0.5,ymax2_bottom); 
        tl_nb->DrawLine(92.-0.5,ymin_bottom,92.-0.5,ymax2_bottom); 
        tl_nb->DrawLine(105.-0.5,ymin_bottom,105.-0.5,ymax2_bottom); 
        tl_nb->DrawLine(118.-0.5,ymin_bottom,118.-0.5,ymax2_bottom); 
        tl_nb->DrawLine(131.-0.5,ymin_bottom,131.-0.5,ymax2_bottom); 
        tl_nb->DrawLine(144.-0.5,ymin_bottom,144.-0.5,ymax2_bottom);
        tl_nb->DrawLine(157.-0.5,ymin_bottom,157.-0.5,ymax2_bottom);
        tl_nb->DrawLine(170.-0.5,ymin_bottom,170.-0.5,ymax2_bottom);
        tl_nb->DrawLine(183.-0.5,ymin_bottom,183.-0.5,ymax2_bottom);
        tl_nb->DrawLine(196.-0.5,ymin_bottom,196.-0.5,ymax2_bottom);

      } else {
	
      // Njet separation lines
      TLine *tl_njet = new TLine();
      tl_njet->SetLineStyle(2);
      tl_njet->DrawLine( 45.,ymin_bottom, 45.,ymax_bottom); 
      tl_njet->DrawLine( 89.,ymin_bottom, 89.,ymax_bottom); 
      tl_njet->DrawLine(133.,ymin_bottom,133.,ymax_bottom); 
      tl_njet->DrawLine(177.,ymin_bottom,177.,ymax_bottom); 


      // Nb separation lines
      TLine *tl_nb = new TLine();
      tl_nb->SetLineStyle(3);
      tl_nb->DrawLine(12.,ymin_bottom,12.,ymax2_bottom); 
      tl_nb->DrawLine(23.,ymin_bottom,23.,ymax2_bottom); 
      tl_nb->DrawLine(34.,ymin_bottom,34.,ymax2_bottom); 
      
      tl_nb->DrawLine(56.,ymin_bottom,56.,ymax2_bottom); 
      tl_nb->DrawLine(67.,ymin_bottom,67.,ymax2_bottom); 
      tl_nb->DrawLine(78.,ymin_bottom,78.,ymax2_bottom); 
      
      tl_nb->DrawLine(100.,ymin_bottom,100.,ymax2_bottom); 
      tl_nb->DrawLine(111.,ymin_bottom,111.,ymax2_bottom); 
      tl_nb->DrawLine(122.,ymin_bottom,122.,ymax2_bottom); 

      tl_nb->DrawLine(144.,ymin_bottom,144.,ymax2_bottom); 
      tl_nb->DrawLine(155.,ymin_bottom,155.,ymax2_bottom); 
      tl_nb->DrawLine(166.,ymin_bottom,166.,ymax2_bottom); 
      
      tl_nb->DrawLine(188.,ymin_bottom,188.,ymax2_bottom); 
      tl_nb->DrawLine(199.,ymin_bottom,199.,ymax2_bottom); 
      tl_nb->DrawLine(210.,ymin_bottom,210.,ymax2_bottom); 
    
      }

      gPad->RedrawAxis();

      //
      //

  CMS_lumi(canvas, iPeriod, iPos, lumi_sqrtS);

  if(doDataVsMC){
    sprintf(tempname,"DataMC_Full_Plot.pdf");
    if (pull==1)    sprintf(tempname,"DataMCPull_Full_Plot.pdf");
  }else{
    if(doClosurewoIsoTrackVeto){
      if(option.find("QCD")!=string::npos) sprintf(tempname,"Closure_QCD_HDP_woIsoTrack_Full_Plot.pdf");
        else sprintf(tempname,"Closure_woIsoTrack_Full_Plot.pdf");
      if (pull==1)    sprintf(tempname,"ClosurePull_woIsoTrack_Full_Plot.pdf");
    }else{
      if(option.find("QCD")!=string::npos) sprintf(tempname,"Closure_QCD_HDP_Full_Plot.pdf");
        else sprintf(tempname,"Closure_Full_Plot.pdf");
      if (pull==1)    sprintf(tempname,"ClosurePull_Full_Plot.pdf");
    }
  }

  canvas->Print(tempname);

}
示例#13
0
文件: style.C 项目: renqgl90/Seeding
void style()
{
  ////////////////////////////////////////////////////////////////////
  // PURPOSE:
  //
  // This macro defines a reasonable style for (black-and-white)
  // "publication quality" ROOT plots. The default settings contain
  // many features that are either not desirable for printing on white
  // paper or impair the general readibility of plots.
  //
  // USAGE:
  //
  // Simply include the line
  //   gROOT->ProcessLine(".x $LHCBSTYLE/root/lhcbstyle.C");
  // at the beginning of your root macro.
  //
  // SOME COMMENTS:
  //
  // Statistics and fit boxes:
  //
  // "Decorative" items around the histogram are kept to a minimum.
  // In particular there is no box with statistics or fit information.
  // You can easily change this either by editing your private copy
  // of this style file or by calls to "gStyle" in your macro.
  // For example,
  //   gStyle->SetOptFit(1011);
  // will add some fit information.
  //
  // Font:
  //
  // The font is chosen to be 62, i.e.helvetica-bold-r-normal with
  // precision 2. Font is of course a matter of taste, but most people
  // will probably agree that Helvetica bold gives close to optimal
  // readibility in presentations. It appears to be the ROOT default,
  // and since there are still some features in ROOT that simply won't
  // respond to any font requests, it is the wise choice to avoid
  // ugly font mixtures on the same plot... The precision of the font (2)
  // is chosen in order to have a rotatable and scalable font. Be sure
  // to use true-type fonts! I.e.
  // Unix.*.Root.UseTTFonts: true  in your .rootrc file.
  //
  // "Landscape histograms":
  //
  // The style here is designed for more or less quadratic plots.
  // For very long histograms, adjustements are needed. For instance,
  // for a canvas with 1x5 histograms:
  //  TCanvas* c1 = new TCanvas("c1", "L0 muons", 600, 800);
  //  c1->Divide(1,5);
  // adaptions like the following will be needed:
  //  gStyle->SetTickLength(0.05,"x");
  //  gStyle->SetTickLength(0.01,"y");
  //  gStyle->SetLabelSize(0.15,"x");
  //  gStyle->SetLabelSize(0.1,"y");
  //  gStyle->SetStatW(0.15);
  //  gStyle->SetStatH(0.5);
  //
  ////////////////////////////////////////////////////////////////////
  /*cout << "executing lhcbStyle.C:" << endl;
    cout << "                      " << endl;
    cout << "                      " << endl;
    cout << "                         $      $   $   $$$   $    " << endl;
    cout << "                         $      $   $  $      $    " << endl;
    cout << "                         $      $$$$$  $      $$$  " << endl;
    cout << "                         $      $   $  $      $  $ " << endl;
    cout << "                         $$$$$  $   $   $$$   $$$  " << endl;
    cout << " " << endl;
    cout << "                           LHCb ROOT style file " << endl;
    cout << " " << endl;
    cout <<
    "     Problems, suggestions, contributions to [email protected]" << endl;
    cout << " " << endl;*/
  //gROOT->Reset();
  TStyle *lhcbStyle= new TStyle("lhcbStyle","Thomas personal plots style");
  // use helvetica-bold-r-normal, precision 2 (rotatable)
  Int_t lhcbFont = 62;
  // line thickness
  Double_t lhcbWidth = 3.00;
  // use plain black on white colors
  lhcbStyle->SetFrameBorderMode(0);
  lhcbStyle->SetCanvasBorderMode(0);
  lhcbStyle->SetPadBorderMode(0);
  lhcbStyle->SetPadColor(0);
  lhcbStyle->SetCanvasColor(0);
  lhcbStyle->SetStatColor(0);
  lhcbStyle->SetPalette(1);
  //lhcbStyle->SetTitleColor(0);
  //lhcbStyle->SetFillColor(0);
  // set the paper & margin sizes
  lhcbStyle->SetPaperSize(20,26);
  lhcbStyle->SetPadTopMargin(0.05);
  lhcbStyle->SetPadRightMargin(0.05); // increase for colz plots!!
  lhcbStyle->SetPadBottomMargin(0.16);
  lhcbStyle->SetPadLeftMargin(0.14);
  // use large fonts
  lhcbStyle->SetTextFont(lhcbFont);
  lhcbStyle->SetTextSize(0.08);
  lhcbStyle->SetLabelFont(lhcbFont,"x");
  lhcbStyle->SetLabelFont(lhcbFont,"y");
  lhcbStyle->SetLabelFont(lhcbFont,"z");
  lhcbStyle->SetLabelSize(0.03,"x");
  lhcbStyle->SetLabelSize(0.03,"y");
  lhcbStyle->SetLabelSize(0.03,"z");
  lhcbStyle->SetTitleFont(lhcbFont);
  lhcbStyle->SetTitleSize(0.06,"x");
  lhcbStyle->SetTitleSize(0.06,"y");
  lhcbStyle->SetTitleSize(0.06,"z");
  // use bold lines and markers
  lhcbStyle->SetLineWidth(lhcbWidth);
  lhcbStyle->SetFrameLineWidth(lhcbWidth);
  lhcbStyle->SetHistLineWidth(lhcbWidth);
  lhcbStyle->SetFuncWidth(lhcbWidth);
  lhcbStyle->SetGridWidth(lhcbWidth);
  lhcbStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
  //lhcbStyle->SetMarkerStyle(15);
  lhcbStyle->SetMarkerStyle(20);
  lhcbStyle->SetMarkerSize(1.2);
  // label offsets
  lhcbStyle->SetLabelOffset(0.020);
  // by default, do not display histogram decorations:
  lhcbStyle->SetOptStat(0);
  lhcbStyle->SetOptStat(1110);  // show only nent, mean, rms
  //lhcbStyle->SetOptTitle(0);
  lhcbStyle->SetOptFit(0);
  //lhcbStyle->SetOptFit(1011); // show probability, parameters and errors
  // look of the statistics box:
  lhcbStyle->SetStatBorderSize(1);
  lhcbStyle->SetStatFont(lhcbFont);
  lhcbStyle->SetStatFontSize(0.05);
  lhcbStyle->SetStatX(0.9);
  lhcbStyle->SetStatY(0.9);
  lhcbStyle->SetStatW(0.25);
  lhcbStyle->SetStatH(0.15);
  // put tick marks on top and RHS of plots
  lhcbStyle->SetPadTickX(1);
  lhcbStyle->SetPadTickY(1);
  // histogram divisions: only 5 in x to avoid label overlaps
  lhcbStyle->SetNdivisions(505,"x");
  lhcbStyle->SetNdivisions(510,"y");
  TPaveText *lhcbName = new TPaveText(0.65,0.8,0.9,0.9,"BRNDC");
  lhcbName->SetFillColor(0);
  lhcbName->SetTextAlign(12);
  lhcbName->SetBorderSize(0);
  lhcbName->AddText("LHCb");
  // TPaveText *lhcbPrelimR = new TPaveText(0.70 - lhcbStyle->GetPadRightMargin(),
  //                                        0.80 - lhcbStyle->GetPadTopMargin(),
  //                                        0.95 - lhcbStyle->GetPadRightMargin(),
  //                                        0.85 - lhcbStyle->GetPadTopMargin(),
  //                                        "BRNDC");
  // lhcbPrelimR->SetFillColor(0);
  // lhcbPrelimR->SetTextAlign(12);
  // lhcbPrelimR->SetBorderSize(0);
  // lhcbPrelimR->AddText("#splitline{LHCb}{#scale[1.0]{Preliminary}}");
  // TPaveText *lhcbPrelimL = new TPaveText(lhcbStyle->GetPadLeftMargin() + 0.05,
  //                                        0.87 - lhcbStyle->GetPadTopMargin(),
  //                                        lhcbStyle->GetPadLeftMargin() + 0.30,
  //                                        0.95 - lhcbStyle->GetPadTopMargin(),
  //                                        "BRNDC");
  // lhcbPrelimL->SetFillColor(0);
  // lhcbPrelimL->SetTextAlign(12);
  // lhcbPrelimL->SetBorderSize(0);
  // lhcbPrelimL->AddText("#splitline{LHCb}{#scale[1.0]{Preliminary}}");
  // TPaveText *lhcb7TeVPrelimR = new TPaveText(0.70 - lhcbStyle->GetPadRightMargin(),
  //                                            0.75 - lhcbStyle->SetPadTopMargin(0.05),
  //                                            0.95 - lhcbStyle->GetPadRightMargin(),
  //                                            0.85 - lhcbStyle->SetPadTopMargin(0.05),
  //                                            "BRNDC");
  // lhcb7TeVPrelimR->SetFillColor(0);
  // lhcb7TeVPrelimR->SetTextAlign(12);
  // lhcb7TeVPrelimR->SetBorderSize(0);
  // lhcb7TeVPrelimR->AddText("#splitline{#splitline{LHCb}{Preliminary}}{#scale[0.7]{#sqrt{s} = 7 TeV Data}}");
  // TPaveText *lhcb7TeVPrelimL = new TPaveText(lhcbStyle->GetPadLeftMargin() + 0.05,
  //                                            0.78 - lhcbStyle->SetPadTopMargin(0.05),
  //                                            lhcbStyle->GetPadLeftMargin() + 0.30,
  //                                            0.88 - lhcbStyle->SetPadTopMargin(0.05),
  //                                            "BRNDC");
  // lhcb7TeVPrelimL->SetFillColor(0);
  // lhcb7TeVPrelimL->SetTextAlign(12);
  // lhcb7TeVPrelimL->SetBorderSize(0);
  // lhcb7TeVPrelimL->SetTextSize(0.06);
  // lhcb7TeVPrelimL->AddText("#splitline{#splitline{LHCb}{Preliminary}}{#scale[0.7]{#sqrt{s} = 7 TeV Data}}");
  // TPaveText *lhcb7TeVPrelimR = new TPaveText(0.70 - lhcbStyle->GetPadRightMargin(),
  //                                            0.75 - lhcbStyle->SetPadTopMargin(0.05),
  //                                            0.95 - lhcbStyle->GetPadRightMargin(),
  //                                            0.85 - lhcbStyle->SetPadTopMargin(0.05),
  //                                            "BRNDC");
  // lhcb7TeVPrelimR->SetFillColor(0);
  // lhcb7TeVPrelimR->SetTextAlign(12);
  // lhcb7TeVPrelimR->SetBorderSize(0);
  // lhcb7TeVPrelimR->AddText("#splitline{#splitline{LHCb}{Preliminary}}{#scale[0.7]{#sqrt{s} = 900 eV Data}}");
  // TPaveText *lhcb0_9TeVPrelimL = new TPaveText(lhcbStyle->GetPadLeftMargin() + 0.05,
  //                                              0.78 - lhcbStyle->SetPadTopMargin(0.05),
  //                                              lhcbStyle->GetPadLeftMargin() + 0.30,
  //                                              0.88 - lhcbStyle->SetPadTopMargin(0.05),
  //                                              "BRNDC");
  // lhcb0_9TeVPrelimL->SetFillColor(0);
  // lhcb0_9TeVPrelimL->SetTextAlign(12);
  // lhcb0_9TeVPrelimL->SetBorderSize(0);
  // lhcb0_9TeVPrelimL->SetTextSize(0.06);
  // lhcb0_9TeVPrelimL->AddText("#splitline{#splitline{LHCb}{Preliminary}}{#scale[0.7]{#sqrt{s} = 900 GeV Data}}");
  TText *lhcbLabel = new TText();
  lhcbLabel->SetTextFont(lhcbFont);
  lhcbLabel->SetTextColor(1);
  lhcbLabel->SetTextSize(0.04);
  lhcbLabel->SetTextAlign(12);
  TLatex *lhcbLatex = new TLatex();
  lhcbLatex->SetTextFont(lhcbFont);
  lhcbLatex->SetTextColor(1);
  lhcbLatex->SetTextSize(0.04);
  lhcbLatex->SetTextAlign(12);
  gROOT->SetStyle("lhcbStyle");
  gROOT->ForceStyle();
}
示例#14
0
void postprocess(TCanvas* c2, const char* name, Int_t rWrite, Int_t rPerformance,const char* system) {
    if (rPerformance){
        TLatex *alice = new TLatex(0.22,0.57,"Pb-Pb #sqrt{s_{NN}} = 2.76 TeV");
        alice->SetNDC();
        alice->SetTextColor(myDarkRed);
        //    alice->SetTextFont(42);
        alice->SetTextSize(0.05);
        alice->SetLineWidth(2);
        alice->Draw();

        TLatex *alice2 = new TLatex(0.62,0.41,"LHC10h - Pass2");
        alice2->SetNDC();
        alice2->SetTextColor(myDarkRed);
        //    alice->SetTextFont(42);
        alice2->SetTextSize(0.05);
        alice2->SetLineWidth(2);
        // alice2->Draw();

        TDatime now;
        int iDate = now.GetDate();
        int iYear=iDate/10000;
        int iMonth=(iDate%10000)/100;
        int iDay=iDate%100;
        char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun",
                          "Jul","Aug","Sep","Oct","Nov","Dec"};
        char cStamp1[25],cStamp2[25];
        sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear);
        sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear);


        TText *date = new TText(0.67,0.48,cStamp2);
        date->SetNDC();
        date->SetTextFont(42);
        date->SetTextSize(0.04);
        date->Draw();

//                 //Acquire canvas proportions
//                 Double_t AliLogo_LowX = 0.67;
//                 Double_t AliLogo_LowY = 0.53;
//                 Double_t AliLogo_Height = 0.22;
//                 //ALICE logo is a png file that is 821x798 pixels->should be wider than a square
//                 Double_t AliLogo_Width  = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw();

//                 TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height);
//                 //    myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment !
//                 myPadSetUp(myPadLogo,0,0,0,0);
//                 //myPadLogo->SetFixedAspectRatio(1);
//                 myPadLogo->Draw();
//                 myPadLogo->cd();
// //                TASImage *myAliceLogo = new TASImage("alice_performance.png");
//                 TASImage *myAliceLogo = new TASImage("alice_performance.eps");
// //    TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png");
//                 myAliceLogo->Draw();

        DrawALICELogo(0,0.65,0.52,0.8,0.8);


    }

    if (rWrite == 1){
        c2->SaveAs(Form("%s_%s.png",name,system));
        //}
        //if (rWrite == 2)
        c2->SaveAs(Form("%s.eps",name));
    }
}
示例#15
0
void gluinoMass(double lumi=-1., double maxInstLumi=-1.) {
	
  if (lumi<0)
    lumi=877.;
  if (maxInstLumi<0)
    maxInstLumi=1300.;
  LimitPlots plots(lumi);
  
  plots.calculateCrossSections(7,4,39,9);
	
  // expected limit (1 and 2 sigma bands)
  TGraph* g_exp = plots.getExpMassLimitGluino();
  TGraphAsymmErrors* g_exp1 = plots.getExpMassLimitGluino1Sig();
  TGraphAsymmErrors* g_exp2 = plots.getExpMassLimitGluino2Sig();
  
  // three points on counting expt curve
  TGraph* g_gluino = plots.getMassLimitGluino();
  TGraph* g_stop = plots.getMassLimitStop();
  
  // one point from lifetime fit
  TGraph* g_tp = plots.getMassLimitGluinoTP();
  
  // theory prediction
  TGraph* g_thGluino = plots.getGluinoTheory();
  TGraph* g_thStop = plots.getStopTheory();
  
  TCanvas* canvas = new TCanvas("canvas");
  
  //canvas->SetGrid();
  canvas->SetLogy();
  
  TH1 * h;
  h = canvas->DrawFrame(300., .02, 1000., 1e2);
  //h->SetTitle("Beamgap Expt;m_{#tilde{g}} [GeV/c^{2}]; Stopped HSCP Cross Section #times BR [pb]");
  h->SetTitle("Beamgap Expt;m_{#tilde{g}} [GeV/c^{2}]; #sigma(pp #rightarrow #tilde{g}#tilde{g}) #times BR(#tilde{g} #rightarrow g#tilde{#chi}^{0}) [pb]");
  
  // not covered region
  TBox* nc = new TBox(100., .1, 150., 5e2);
  nc->SetFillStyle(3354);
  nc->SetFillColor(kRed-4);
  //nc->Draw();
  
  // details
  TPaveText* blurb = new TPaveText(300., 2, 550., 1e2);
  blurb->AddText("CMS Preliminary 2012");

  std::stringstream label;
  label<<"#int L dt = "<<lumi<<" fb^{-1}";
  blurb->AddText(label.str().c_str());
  label.str("");
  double peakInstLumi=maxInstLumi;
  int exponent=30;
  while (peakInstLumi>10) {
    peakInstLumi/=10.;
    ++exponent;
  }
  label<<"L^{max}_{inst} = "<<peakInstLumi<<" x 10^{"<<exponent<<"} cm^{-2}s^{-1}";
  blurb->AddText(label.str().c_str());
  label.str("");
  label << "#sqrt{s} = " << ENERGY << " TeV";
  blurb->AddText(label.str().c_str());
  blurb->AddText("m_{#tilde{g}} - m_{#tilde{#chi}^{0}} = 100 GeV/c^{2}");
  //blurb->AddText("m_{#tilde{t}} - m_{#tilde{#chi}^{0}} = 200 GeV/c^{2}");	
  blurb->SetTextFont(42);
  blurb->SetBorderSize(0);
  blurb->SetFillColor(0);
  blurb->SetShadowColor(0);
  blurb->SetTextAlign(12);
  blurb->SetTextSize(0.032);

  
  // legend
  TBox *legbg = new TBox(600., 2., 900., 1e2);
  legbg->Draw();
  TLegend *leg = new TLegend(600., 2., 900., 1e2,"95% C.L. Limits","");
  leg->SetTextSize(0.028);
  leg->SetBorderSize(0);
  leg->SetTextFont(42);
  leg->SetFillColor(0);
  leg->AddEntry(g_exp, "Expected: 10 #mus - 1000 s Counting Exp. ", "l");
  leg->AddEntry(g_exp1, "Expected #pm1#sigma: 10 #mus - 1000 s Counting Exp. ", "f");
  leg->AddEntry(g_exp2, "Expected #pm2#sigma: 10 #mus - 1000 s Counting Exp. ", "f");
  //	  leg->AddEntry(graph3, "Obs.: 10^{6} s Counting Exp.", "l");
  leg->AddEntry(g_gluino, "Obs.: 10 #mus - 1000 s Counting Exp. ", "l");
  leg->AddEntry(g_tp, "Obs.: 10 #mus Timing Profile ", "l");
  //leg->AddEntry(g_stop, "Obs.: 10 #mus - 1000 s Counting Exp. (#tilde{t})", "l");
  //leg->AddEntry(graph_em, "Obs.: 10 #mus - 1000 s Counting Exp. (EM only)", "l");
  //  leg->AddEntry(graph1, "Obs.: 570 ns Counting Exp.", "l");
  leg->Draw();
  
  
  
  // 2 sigma expected band
  g_exp2->SetLineColor(0);
  g_exp2->SetLineStyle(0);
  g_exp2->SetLineWidth(0);
  g_exp2->SetFillColor(5);
  g_exp2->SetFillStyle(1001);
  g_exp2->Draw("3");
  
  // 1 sigma expected band
  g_exp1->SetLineColor(0);
  g_exp1->SetLineStyle(0);
  g_exp1->SetLineWidth(0);
  g_exp1->SetFillColor(3);
  g_exp1->SetFillStyle(1001);
  g_exp1->Draw("3");  
  
  // expected line
  g_exp->SetLineStyle(2);
  g_exp->SetLineWidth(1);
  g_exp->Draw("l");
  
 
  // plateau limit - 1 ms
  g_gluino->SetLineColor(1);
  g_gluino->SetLineStyle(1);
  g_gluino->SetLineWidth(2);
  g_gluino->Draw("l");
  
  // stop curve
  g_stop->SetLineColor(1);
  g_stop->SetLineStyle(5);
  g_stop->SetLineWidth(2);
  //g_stop->Draw("l");
 

  // 1 mus lifetime fit limit
  g_tp->SetLineColor(kRed);
  g_tp->SetLineStyle(1);
  g_tp->SetLineWidth(2);
  g_tp->Draw("l");
  
  // theory line
  g_thGluino->SetLineColor(kBlue);
  g_thGluino->SetLineStyle(1);
  g_thGluino->SetLineWidth(2);
  g_thGluino->SetFillStyle(3001);
  g_thGluino->SetFillColor(kBlue-4);
  g_thGluino->Draw("l3");
  
  g_thStop->SetLineColor(kRed);
  g_thStop->SetLineStyle(1);
  g_thStop->SetLineWidth(2);
  g_thStop->SetFillStyle(3001);
  g_thStop->SetFillColor(kRed-4);
  //g_thStop->Draw("l3");


  // theory line label
  TLatex* th = new TLatex(600., .3, "NLO+NLL #tilde{g}");
  th->SetTextColor(kBlue);
  th->SetTextFont(42);
  th->SetTextSize(0.035);
  th->Draw();

  TLatex* ths = new TLatex(330., 2., "NLO+NLL #tilde{t}");
  ths->SetTextColor(kRed);
  ths->SetTextFont(42);
  ths->SetTextSize(0.035);
  //ths->Draw();

  // not explored label
  TText* ne = new TText(125., .2, "Not Sensitive");
  ne->SetTextColor(kRed+1);
  ne->SetTextFont(42);
  ne->SetTextAngle(90);
  ne->SetTextSize(0.035);
  //ne->Draw();

  blurb->Draw();

  canvas->RedrawAxis();

  canvas->Print("gluinoMassLimit.pdf");
  canvas->Print("gluinoMassLimit.C");

  plots.calculateIntercepts();
  
}
示例#16
0
void MakeClosurePlot(TH1D* hObs, TH1D* hPred, TString name, bool logy=true) {
  set_style(hObs,"data_obs");
  set_style(hPred,"pred");

  // Setup canvas and pads
  TCanvas * c1 = new TCanvas("c1", "c1", 700, 700);
  c1->SetFillStyle(4000);
  TPad * pad1 = new TPad("pad1", "top pad" , 0.0, 0.3, 1.0, 1.0);
  pad1->SetFillStyle(4000);
  pad1->SetBottomMargin(0.0);
  pad1->Draw();
  TPad * pad2 = new TPad("pad2", "bottom pad", 0.0, 0.0, 1.0, 0.3);
  pad2->SetFillStyle(4000);
  pad2->SetTopMargin(0.0);
  pad2->SetBottomMargin(0.35);
  pad2->Draw();
  pad1->cd();
  pad1->SetLogy(logy);

  TH1D * staterr = (TH1D *) hPred->Clone("staterr");
  //  staterr->Sumw2();
  //staterr->SetFillColor(kRed);
  staterr->SetFillColor(kGray+3);
  staterr->SetMarkerSize(0);
  staterr->SetFillStyle(3013);

  //cout << "Compute ratio hist..." << endl;
  TH1D * ratio = (TH1D *) hPred->Clone("ratio");
  //ratio->Sumw2();
  ratio->SetMarkerSize(0.8);
  ratio->SetMarkerColor(1);
  //ratio->SetMarkerSize(0.5);
  ratio->Divide(hObs, hPred, 1., 1., "B");
  ratio->Print("all");
  TH1D * ratiostaterr = (TH1D *) hObs->Clone("ratiostaterr");
  //  ratiostaterr->Sumw2();
  ratiostaterr->SetStats(0);
  ratiostaterr->SetTitle(hPred->GetTitle());
  ratiostaterr->GetYaxis()->SetTitle("Obs/Pred.");
  ratiostaterr->SetMaximum(2.2);
  ratiostaterr->SetMinimum(0);
  ratiostaterr->SetMarkerSize(0);
  //ratiostaterr->SetFillColor(kRed);
  ratiostaterr->SetFillColor(kGray+3);
  ratiostaterr->SetFillStyle(3013);
  ratiostaterr->GetXaxis()->SetLabelSize(0.2);
  ratiostaterr->GetXaxis()->SetLabelOffset(0.03);
  ratiostaterr->GetXaxis()->SetTitleSize(0.14);
  ratiostaterr->GetXaxis()->SetTitleOffset(1.10);
  ratiostaterr->GetYaxis()->SetLabelSize(0.10);
  ratiostaterr->GetYaxis()->SetTitleSize(0.12);
  ratiostaterr->GetYaxis()->SetTitleOffset(0.6);
  ratiostaterr->GetYaxis()->SetNdivisions(505);
  TLine* ratiounity = new TLine(hPred->GetBinLowEdge(1),1,hPred->GetBinLowEdge(hPred->GetNbinsX()+1),1);
  ratiounity->SetLineStyle(2);
  for (Int_t i = 0; i < hPred->GetNbinsX()+2; i++) {
    // if (hObs->GetBinContent(i)>0.) ratio->SetBinError(i, hObs->GetBinError(i)/hObs->GetBinContent(i)); // just the fractional uncertainty on the observation
    ratiostaterr->SetBinContent(i, 1.0);
    if (hPred->GetBinContent(i) > 1e-6) { //< not empty
      double binerror = hPred->GetBinError(i) / hPred->GetBinContent(i);
      ratiostaterr->SetBinError(i, binerror);
    } else {
      ratiostaterr->SetBinError(i, 999.);
    }
  }
  TH1D * ratiosysterr = (TH1D *) ratiostaterr->Clone("ratiosysterr");
  //  ratiosysterr->Sumw2();
  ratiosysterr->SetMarkerSize(0);
  ratiosysterr->SetFillColor(kYellow-4);
  //ratiosysterr->SetFillStyle(3002);
  ratiosysterr->SetFillStyle(1001);
  for (Int_t i = 0; i < hPred->GetNbinsX()+2; i++) {
    if (hPred->GetBinContent(i) > 1e-6) { //< not empty
      double binerror2 = (pow(hPred->GetBinError(i), 2));
      double binerror = sqrt(binerror2);
      ratiosysterr->SetBinError(i, binerror / hPred->GetBinContent(i));
    }
  }


  double max = hObs->GetMaximum();
  if (hPred->GetMaximum() > max) max = hPred->GetMaximum();

  if (logy) {
    hPred->SetMaximum(max*10);
    hPred->SetMinimum(0.09);
  } else {
    hPred->SetMaximum(max*1.5);
    hPred->SetMinimum(0.);
  }

  hPred->GetYaxis()->SetTitle("Events / bin");
  hPred->Draw("hist");
  hObs->Draw("e1,same");
  staterr->Draw("e2 same");
  hPred->GetXaxis()->SetTitleSize(0.035);
  hPred->GetXaxis()->SetLabelSize(0.035);
  /* hObs->GetYaxis()->SetTitleSize(0.035); */
  /* hObs->GetYaxis()->SetLabelSize(0.035); */

  TLegend * leg2 = new TLegend(0.72, 0.68, 0.94, 0.92);
  set_style(leg2,0.035);
  leg2->AddEntry(hObs,"Obs.","elp");
  leg2->AddEntry(hPred,"Pred.","f");
  leg2->AddEntry(staterr, "Syst. uncert.", "f");
  leg2->Draw();
  TLatex * latex = new TLatex();
  latex->SetNDC();
  latex->SetTextAlign(12);
  latex->SetTextFont(62);
  latex->SetTextSize(0.042);
  latex->DrawLatex(0.19, 0.89, "CMS Simulation");
  latex->SetTextSize(0.03);
  TString stamp = Form("#sqrt{s} = 13 TeV, L = %3.1f fb^{-1}", int_lumi);
  latex->DrawLatex(0.19, 0.84, stamp);

  pad2->cd();
  pad2->SetGridy(0);
  ratiostaterr->GetXaxis()->SetRangeUser(0,6);
  ratiostaterr->Draw("e2");
  //ratiosysterr->Draw("e2 same");
  ratiostaterr->Draw("e2 same");
  ratiounity->Draw();
  ratio->Draw("e1 same");

  TPaveText * pave = new TPaveText(0.18, 0.86, 0.4, 0.96, "brNDC");
  pave->SetLineColor(0);
  pave->SetFillColor(kWhite);
  pave->SetShadowColor(0);
  pave->SetBorderSize(1);
  double nchisq = hObs->Chi2Test(hPred, "UWCHI2/NDF, P"); // MC uncert. (stat)
  double p_value = hObs->Chi2Test(hPred, "UW"); // MC uncert. (stat)
  // //double kolprob = hdata_obs->KolmogorovTest(hmc_pred); // MC uncert. (stat)
  TText * text = pave->AddText(Form("#chi_{#nu}^{2}/ndf = %.3f, p = %.3f", nchisq, p_value));
  // //TText * text = pave->AddText(Form("#chi_{#nu}^{2} = %.3f, K_{s} = %.3f", nchisq, kolprob));
  text->SetTextFont(62);
  text->SetTextSize(0.07);
  // text->SetTextSize(0.06);
  pave->Draw();
  
  /* TLegend * ratioleg = new TLegend(0.72, 0.88, 0.94, 0.96); */
  /* set_style(ratioleg); */
  /* ratioleg->SetTextSize(0.07); */
  /* ratioleg->AddEntry(ratiostaterr, "MC uncert. (stat)", "f"); */
  /* ratioleg->Draw(); */

  pad1->cd();
  gPad->RedrawAxis();
  gPad->Modified();
  gPad->Update();
  pad2->cd();
  gPad->RedrawAxis();
  gPad->Modified();
  gPad->Update();

  c1->cd();
  
  c1->Print("Closure/plots/no_dp_cut/"+name+".pdf");

  delete staterr;
  delete ratio;
  delete ratiostaterr;
  delete ratiosysterr;
  delete leg2;
  // delete ratioleg;
  delete pad1;
  delete pad2;
  delete c1;
  delete latex;
  
}
示例#17
0
void massPlot(double lumi=-1., double maxInstLumi=-1.) {

  setTDRStyle();
  //tdrGrid(false, tdrStyle);

  writeExtraText = true;
  //extraText  = "Preliminary Simulation"; 
  //lumi_8TeV = ""; 
  int iPeriod = 2; // 1=7TeV, 2=8TeV, 3=7+8TeV, 7=7+8+13TeV 
  //int iPos=0;
  int iPos=11;
  //int iPos=22;
	
  if (lumi<0)
    lumi=LUMI;
  if (maxInstLumi<0)
    maxInstLumi=MAXINSTLUMI;
  DifferentXSLimitPlots plots(lumi);

  //mchamp index 0 is used, corresponds to 0th mass point = 100 GeV
  plots.calculateCrossSections(0,0,0,39,9);
    
  // three points on counting expt curve
  //TGraph* g_obs_gluino = plots.getMassLimitGluino();
  TGraph* g_gluino = plots.getExpMassLimitGluino();

  //TGraph* g_obs_stop = plots.getMassLimitStop();
  TGraph* g_stop = plots.getExpMassLimitStop();

  TGraph* g_obs_mchamp = plots.getMassLimitMchamp();
  TGraph* g_mchamp = plots.getExpMassLimitMchamp();

  //TGraphAsymmErrors* g_expGluino_1sig = plots.getExpMassLimitGluino1Sig();  
  //TGraphAsymmErrors* g_expGluino_2sig = plots.getExpMassLimitGluino2Sig();  

  //TGraphAsymmErrors* g_expStop_1sig = plots.getExpMassLimitStop1Sig();  
  //TGraphAsymmErrors* g_expStop_2sig = plots.getExpMassLimitStop2Sig();  

  TGraphAsymmErrors* g_exp_1sig = plots.getExpMassLimitMchamp1Sig();  
  TGraphAsymmErrors* g_exp_2sig = plots.getExpMassLimitMchamp2Sig();  

  // one point from lifetime fit
  TGraph* g_tpg = plots.getMassLimitGluinoTP();
  TGraph* g_tps = plots.getMassLimitStopTP();
  
  // theory prediction
  TGraph* g_thGluino = plots.getGluinoTheory();
  TGraph* g_thStop = plots.getStopTheory();
  TGraph* g_thMchamp = plots.getMchampTheory();
  
  TCanvas* canvas = new TCanvas("canvas","",10,10,575,500);

  Double_t x[10], yMinus[10], x2[10], y[10], yPlus[10], z[10];
  cout<<"MCHAMP LIMITS ARE: "<<endl;
  for(Int_t i=0; i<g_mchamp->GetN(); i++){
    g_mchamp->GetPoint(i, x[i], y[i]);
    yPlus[i] = g_exp_1sig->GetErrorYhigh(i);
    yMinus[i] = g_exp_1sig->GetErrorYlow(i);
    g_obs_mchamp->GetPoint(i, x2[i], z[i]);
    cout<<" mass is: "<<x[i]<<", expected limit is: "<<y[i]<<", expected +1 sigma is: "<<yPlus[i]<<", expected -1 sigma is: "<<yMinus[i]<<", observed limit is: "<<z[i]<<endl;
  }

  //canvas->SetGrid();
  canvas->SetLogy();
  
  TH1 * h;
  //h = canvas->DrawFrame(100., 1e-5, 1500., 1e6); //2DSA gluios and stops
  h = canvas->DrawFrame(100., 1e-5, 1000., 1e3); //2DSA
  //h = canvas->DrawFrame(100., 1e-5, 1000., 1e4); //1DSA
  //h->SetTitle(";m [GeV];#sigma [pb]");
  h->SetTitle(";m_{mchamp} [GeV];#sigma(pp #rightarrow mchamp mchamp) [pb]");
  //h->SetTitle(";m_{mchamp} [GeV];#sigma(pp #rightarrow mch mch) #times BF(mch #rightarrow #mu#mu)  [pb]");
  //h->SetTitle("Beamgap Expt;m_{#tilde{g}} [GeV/c^{2}]; #sigma(pp #rightarrow #tilde{g}#tilde{g}) #times BR(#tilde{g} #rightarrow g#tilde{#chi}^{0}) [pb]");
  
  // not covered region
  TBox* nc = new TBox(100., .1, 150., 5e2);
  nc->SetFillStyle(3354);
  nc->SetFillColor(kRed-4);
  //nc->Draw();
  
  /*
  // details
  //TPaveText* blurb = new TPaveText(305., 1.e1, 550., 4.5e2);
  TPaveText* blurb = new TPaveText(0.25, 0.70, 0.50, 0.92, "NDC");
  blurb->AddText("CMS Preliminary 2012");
  
  std::stringstream label;
  label<<"#int L dt = 19.7 fb^{-1}";
  blurb->AddText(label.str().c_str());
  label.str("");
  double peakInstLumi=maxInstLumi;
  int exponent=30;
  while (peakInstLumi>10) {
    peakInstLumi/=10.;
    ++exponent;
  }
  //label<<"L^{max}_{inst} = "<<peakInstLumi<<" x 10^{"<<exponent<<"} cm^{-2}s^{-1}";
  //blurb->AddText(label.str().c_str());
  //label.str("");
  label << "#sqrt{s} = " << ENERGY << " TeV";
  blurb->AddText(label.str().c_str());
  //blurb->AddText("m_{#tilde{g}} - m_{#tilde{#chi}^{0}} = 100 GeV/c^{2}");
  //blurb->AddText("m_{#tilde{t}} - m_{#tilde{#chi}^{0}} = 180 GeV/c^{2}");	
  blurb->SetTextFont(42);
  blurb->SetBorderSize(0);
  blurb->SetFillColor(0);
  blurb->SetShadowColor(0);
  blurb->SetTextAlign(12);
  blurb->SetTextSize(0.033);
  */
  
  // legend
  TBox *legbg = new TBox(600., 1.e1, 900., 4e2);
  //legbg->Draw();
  //TLegend *leg = new TLegend(600., 1.e1, 900., 4e2,"95% C.L. Limits","");
  //TLegend* leg = new TLegend(0.67, 0.70, 0.82, 0.92,"95% CL Limits:","NDC");
  /////////TLegend* leg = new TLegend(0.52, 0.70, 0.77, 0.92,"95% CL Limits:","NDC");
  TLegend* leg = new TLegend(0.45, 0.70, 0.70, 0.92,"95% CL Limits:","NDC");
  leg->SetTextSize(0.033);
  leg->SetBorderSize(0);
  leg->SetTextFont(42);
  leg->SetFillColor(0);

  leg->AddEntry(g_obs_mchamp, "Observed, 10 #mus - 1000 s", "lp");
  leg->AddEntry(g_mchamp, "Expected, 10 #mus - 1000 s", "l");
  leg->AddEntry(g_exp_1sig, "Expected #pm1#sigma, 10 #mus - 1000 s", "lf");
  leg->AddEntry(g_exp_2sig, "Expected #pm2#sigma, 10 #mus - 1000 s", "lf");
  leg->AddEntry(g_thMchamp, "LO Prediction", "l");
  /*
  leg->AddEntry(g_gluino, "Expected Gluino Limit, 10 #mus - 1000 s", "l");
  leg->AddEntry(g_thGluino, "Gluino LO Prediction", "l");
  leg->AddEntry(g_stop, "Expected Stop Limit, 10 #mus - 1000 s", "l");
  leg->AddEntry(g_thStop, "Stop LO Prediction", "l");
  */
  //leg->AddEntry(g_thGluino, "NLO+NLL #tilde{g}", "l");
  //leg->AddEntry(g_gluino, "Obs.: 10 #mus - 1000 s Counting Exp. (#tilde{g})", "l");
  //leg->AddEntry(g_tpg, "Obs.: 10 #mus Timing Profile (#tilde{g})", "l");
  //leg->AddEntry(g_thStop, "NLO+NLL #tilde{t}", "l");
  //leg->AddEntry(g_stop, "Obs.: 10 #mus - 1000 s Counting Exp. (#tilde{t})", "l");
  //leg->AddEntry(g_tps, "Obs.: 10 #mus Timing Profile (#tilde{t})", "l");
  //leg->AddEntry(graph_em, "Obs.: 10 #mus - 1000 s Counting Exp. (EM only)", "l");
  //  leg->AddEntry(graph1, "Obs.: 570 ns Counting Exp.", "l");
  leg->Draw();
  
  
  
  /*
  // gluino curves
  g_gluino->SetLineColor(kBlue);
  g_gluino->SetLineStyle(2);
  g_gluino->SetLineWidth(3);
  g_gluino->Draw("l");

  g_tpg->SetLineColor(kBlue);
  g_tpg->SetLineStyle(3);
  g_tpg->SetLineWidth(3);
  //g_tpg->Draw("l");

  // theory line
  g_thGluino->SetLineColor(kGreen);
  g_thGluino->SetLineStyle(1);
  g_thGluino->SetLineWidth(2);
  g_thGluino->SetFillStyle(3001);
  g_thGluino->SetFillColor(kGreen-4);
  g_thGluino->Draw("l3");


  
   // stop curves
  g_stop->SetLineColor(kRed);
  g_stop->SetLineStyle(2);
  g_stop->SetLineWidth(2);
  g_stop->Draw("l");

  g_tps->SetLineColor(kRed);
  g_tps->SetLineStyle(3);
  g_tps->SetLineWidth(3);
  //g_tps->Draw("l");
   
  g_thStop->SetLineColor(kOrange);
  g_thStop->SetLineStyle(1);
  g_thStop->SetLineWidth(2);
  g_thStop->SetFillStyle(3001);
  g_thStop->SetFillColor(kOrange-4);
  g_thStop->Draw("l3");
  */

  // mchamp curves
  // 2 sigma band
  g_exp_2sig->SetLineColor(0);
  g_exp_2sig->SetLineStyle(0);
  g_exp_2sig->SetLineWidth(0);
  g_exp_2sig->SetFillColor(kYellow);
  g_exp_2sig->SetFillStyle(1001);
  g_exp_2sig->Draw("3");

  // 1 sigma band 
  // g_exp_1sig->SetLineColor(8);                                                                                                                                                           
  g_exp_1sig->SetLineColor(0);
  g_exp_1sig->SetLineStyle(0);
  g_exp_1sig->SetLineWidth(0);
  // g_exp_1sig->SetFillColor(8);                                                                                                                                                           
  g_exp_1sig->SetFillColor(kGreen);
  g_exp_1sig->SetFillStyle(1001);
  // g_exp_1sig->SetFillStyle(3005);                                                                                                                                                        
  g_exp_1sig->Draw("3");
  // g_exp_1sig->Draw("lX");                                                                                                                                                                

  g_obs_mchamp->SetLineStyle(1);
  g_obs_mchamp->SetLineWidth(2);
  g_obs_mchamp->SetMarkerStyle(20);
  g_obs_mchamp->SetMarkerSize(1);
  g_obs_mchamp->Draw("pl");

  //g_mchamp->SetLineColor(kBlue);
  g_mchamp->SetLineStyle(2);
  //g_mchamp->SetLineStyle(1);
  g_mchamp->SetLineWidth(3);
  g_mchamp->SetMarkerStyle(20);
  g_mchamp->SetMarkerSize(1);
  g_mchamp->Draw("l");

  // theory line
  g_thMchamp->SetLineColor(kRed);
  g_thMchamp->SetLineStyle(1);
  g_thMchamp->SetLineWidth(2);
  g_thMchamp->SetFillStyle(3001);
  g_thMchamp->SetFillColor(kRed-4);
  g_thMchamp->Draw("l3");

  // theory line label
  TLatex* th = new TLatex(480., 4., "NLO+NLL #tilde{g}");
  th->SetTextColor(kBlue);
  th->SetTextFont(42);
  th->SetTextSize(0.035);
  //th->Draw();

  TLatex* ths = new TLatex(330., 2., "NLO+NLL #tilde{t}");
  ths->SetTextColor(kRed);
  ths->SetTextFont(42);
  ths->SetTextSize(0.035);
  //ths->Draw();

  TLatex* thm = new TLatex(480., 4., "NLO+NLL mchamp");
  //thm->SetTextColor(kBlue);
  thm->SetTextFont(42);
  thm->SetTextSize(0.035);
  //thm->Draw();

  // not explored label
  TText* ne = new TText(125., .2, "Not Sensitive");
  ne->SetTextColor(kRed+1);
  ne->SetTextFont(42);
  ne->SetTextAngle(90);
  ne->SetTextSize(0.035);
  //ne->Draw();

  //blurb->Draw();

  canvas->RedrawAxis();

  CMS_lumi(canvas, iPeriod, iPos);

  canvas->Print("massLimit.pdf");
  canvas->Print("massLimit.png");
  canvas->Print("massLimit.C");

  plots.calculateIntercepts();

  TFile* fnew = new TFile("histos.root", "recreate");
  fnew->cd();
  g_obs_mchamp->Write();
  g_mchamp->Write();
  g_thMchamp->Write();

}
示例#18
0
drawMultiplicity(const char* infilename, const char* system, Int_t rWrite, Int_t rPerformance) {

        prepareAll();

        TFile *f = new TFile(infilename, "read");

        int minMultBin = 0; // 0, 2, 3
        int maxMultBin = 6; // 2, 6, 8

        double EvMultall = 0;

        for (int i = minMultBin; i < maxMultBin; i++) {

                if (i == minMultBin)
                        TH1D* hEvMult =(TH1D*)f->Get(Form("EvMultcutPass%stpcM%i",system,i));
                else
                        hEvMult->Add((TH1D*)f->Get(Form("EvMultcutPass%stpcM%i",system,i)));

                EvMultall += ((TH1D*)f->Get(Form("EvMultcutPass%stpcM%i",system,i)))->GetEntries();
                cout << "MultBin " << i << " " << ((TH1D*)f->Get(Form("EvMultcutPass%stpcM%i",system,i)))->GetEntries() << endl;
                //delete hEvMult;
        }

        cout << "Number of events (all bins): " << EvMultall << endl;

        TCanvas *c2 = new TCanvas("mult", "Event Multiplicity");
        c2->SetGridx();
        c2->SetGridy();
        c2->SetFillColor(10);
        c2->SetLogy();

        hEvMult->GetXaxis()->SetTitle("multiplicity");
        hEvMult->GetYaxis()->SetTitle("number of events");
        hEvMult->GetXaxis()->SetRangeUser(0,4000);
        hEvMult->Draw("");

        if (rPerformance){
                TLatex *alice = new TLatex(0.35,0.27,"Performance");
                alice->SetNDC();
                alice->SetTextColor(myDarkRed);
                alice->SetTextFont(42);
                alice->SetTextSize(0.05);
                alice->SetLineWidth(2);
                alice->Draw();

                TLatex *alice2 = new TLatex(0.32,0.21,"LHC10h - Pass2");
                alice2->SetNDC();
                alice2->SetTextColor(myDarkRed);
                alice->SetTextFont(42);
                alice2->SetTextSize(0.05);
                alice2->SetLineWidth(2);
                alice2->Draw();

                TText *date = new TText(0.38,0.15,cStamp2);
                date->SetNDC();
                date->SetTextFont(42);
                date->SetTextSize(0.04);
                date->Draw();

                //Acquire canvas proportions
                Double_t AliLogo_LowX = 0.37;
                Double_t AliLogo_LowY = 0.33;
                Double_t AliLogo_Height = 0.22;
                //ALICE logo is a png file that is 821x798 pixels->should be wider than a square
                Double_t AliLogo_Width  = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw();

                TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height);
                //    myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment !
                myPadSetUp(myPadLogo,0,0,0,0);
                //myPadLogo->SetFixedAspectRatio(1);
                myPadLogo->Draw();
                myPadLogo->cd();
                TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png");
                myAliceLogo->Draw();
        }

        if (rWrite == 1)
                c2->SaveAs(Form("multiplicity%s.png",system));

        if (rWrite == 2)
                c2->SaveAs(Form("multiplicity%s.eps",system));

}
示例#19
0
文件: tree.C 项目: digideskio/root
void tree() {
   //
   // This macro displays the Tree data structures
   //Author: Rene Brun
   TCanvas* c1 = new TCanvas("c1","Tree Data Structure",200,10,750,940);
   c1->Range(0,-0.1,1,1.15);

   gBenchmark->Start("tree");

   Int_t branchcolor = 26;
   Int_t leafcolor   = 30;
   Int_t basketcolor = 42;
   Int_t offsetcolor = 43;
   TPaveLabel* title = new TPaveLabel(.3,1.05,.8,1.13,c1->GetTitle());
   title->SetFillColor(16);
   title->Draw();
   TPaveText* treePave = new TPaveText(.01,.75,.15,1.00);
   treePave->SetFillColor(18);
   treePave->SetTextAlign(12);
   TText *tnt = treePave->AddText("Tree");
   tnt->SetTextAlign(22);
   tnt->SetTextSize(0.030);
   treePave->AddText("fScanField");
   treePave->AddText("fMaxEventLoop");
   treePave->AddText("fMaxVirtualSize");
   treePave->AddText("fEntries");
   treePave->AddText("fDimension");
   treePave->AddText("fSelectedRows");
   treePave->Draw();
   TPavesText* farm = new TPavesText(.01,1.02,.15,1.1,9,"tr");
   TText *tfarm = farm->AddText("CHAIN");
   tfarm->SetTextSize(0.024);
   farm->AddText("Collection");
   farm->AddText("of Trees");
   farm->Draw();
   TLine* llink = new TLine(.15,.92,.80,.92);
   llink->SetLineWidth(2);
   llink->SetLineColor(1);
   llink->Draw();
   llink->DrawLine(.21,.87,.21,.275);
   llink->DrawLine(.23,.87,.23,.375);
   llink->DrawLine(.25,.87,.25,.775);
   llink->DrawLine(.41,.25,.41,-.025);
   llink->DrawLine(.43,.25,.43,.075);
   llink->DrawLine(.45,.25,.45,.175);
   TPaveLabel* branch0 = new TPaveLabel(.20,.87,.35,.97,"Branch 0");
   branch0->SetTextSize(0.35);
   branch0->SetFillColor(branchcolor);
   branch0->Draw();
   TPaveLabel* branch1 = new TPaveLabel(.40,.87,.55,.97,"Branch 1");
   branch1->SetTextSize(0.35);
   branch1->SetFillColor(branchcolor);
   branch1->Draw();
   TPaveLabel* branch2 = new TPaveLabel(.60,.87,.75,.97,"Branch 2");
   branch2->SetTextSize(0.35);
   branch2->SetFillColor(branchcolor);
   branch2->Draw();
   TPaveLabel* branch3 = new TPaveLabel(.80,.87,.95,.97,"Branch 3");
   branch3->SetTextSize(0.35);
   branch3->SetFillColor(branchcolor);
   branch3->Draw();
   TPaveLabel* leaf0 = new TPaveLabel(.4,.75,.5,.8,"Leaf 0");
   leaf0->SetFillColor(leafcolor);
   leaf0->Draw();
   TPaveLabel* leaf1 = new TPaveLabel(.6,.75,.7,.8,"Leaf 1");
   leaf1->SetFillColor(leafcolor);
   leaf1->Draw();
   TPaveLabel* leaf2 = new TPaveLabel(.8,.75,.9,.8,"Leaf 2");
   leaf2->SetFillColor(leafcolor);
   leaf2->Draw();
   TPaveText* firstevent = new TPaveText(.4,.35,.9,.4);
   firstevent->AddText("First event of each basket");
   firstevent->AddText("Array of fMaxBaskets Integers");
   firstevent->SetFillColor(basketcolor);
   firstevent->Draw();
   TPaveLabel* basket0 = new TPaveLabel(.4,.25,.5,.3,"Basket 0");
   basket0->SetFillColor(basketcolor);
   basket0->Draw();
   TPaveLabel* basket1 = new TPaveLabel(.6,.25,.7,.3,"Basket 1");
   basket1->SetFillColor(basketcolor);
   basket1->Draw();
   TPaveLabel* basket2 = new TPaveLabel(.8,.25,.9,.3,"Basket 2");
   basket2->SetFillColor(basketcolor);
   basket2->Draw();

   TPaveText* offset = new TPaveText(.55,.15,.9,.2);
   offset->AddText("Offset of events in fBuffer");
   offset->AddText("Array of fEventOffsetLen Integers");
   offset->AddText("(if variable length structure)");
   offset->SetFillColor(offsetcolor);
   offset->Draw();
   TPaveText* buffer = new TPaveText(.55,.05,.9,.1);
   buffer->AddText("Basket buffer");
   buffer->AddText("Array of fBasketSize chars");
   buffer->SetFillColor(offsetcolor);
   buffer->Draw();
   TPaveText* zipbuffer = new TPaveText(.55,-.05,.75,.0);
   zipbuffer->AddText("Basket compressed buffer");
   zipbuffer->AddText("(if compression)");
   zipbuffer->SetFillColor(offsetcolor);
   zipbuffer->Draw();
   TArrow* ar1 = new TArrow();
   ar1->SetLineWidth(2);
   ar1->SetLineColor(1);
   ar1->SetFillStyle(1001);
   ar1->SetFillColor(1);
   ar1->DrawArrow(.21,.275,.39,.275,0.015,"|>");
   ar1->DrawArrow(.23,.375,.39,.375,0.015,"|>");
   ar1->DrawArrow(.25,.775,.39,.775,0.015,"|>");
   ar1->DrawArrow(.50,.775,.59,.775,0.015,"|>");
   ar1->DrawArrow(.70,.775,.79,.775,0.015,"|>");
   ar1->DrawArrow(.50,.275,.59,.275,0.015,"|>");
   ar1->DrawArrow(.70,.275,.79,.275,0.015,"|>");
   ar1->DrawArrow(.45,.175,.54,.175,0.015,"|>");
   ar1->DrawArrow(.43,.075,.54,.075,0.015,"|>");
   ar1->DrawArrow(.41,-.025,.54,-.025,0.015,"|>");
   TLine* ldot = new TLine(.95,.92,.99,.92);
   ldot->SetLineStyle(3);
   ldot->Draw();
   ldot->DrawLine(.9,.775,.99,.775);
   ldot->DrawLine(.9,.275,.99,.275);
   ldot->DrawLine(.55,.05,.55,0);
   ldot->DrawLine(.9,.05,.75,0);
   TText* pname = new TText(.46,.21,"fEventOffset");
   pname->SetTextFont(72);
   pname->SetTextSize(0.018);
   pname->Draw();
   pname->DrawText(.44,.11,"fBuffer");
   pname->DrawText(.42,.01,"fZipBuffer");
   pname->DrawText(.26,.81,"fLeaves = TObjArray of TLeaf");
   pname->DrawText(.24,.40,"fBasketEvent");
   pname->DrawText(.22,.31,"fBaskets = TObjArray of TBasket");
   pname->DrawText(.20,1.0,"fBranches = TObjArray of TBranch");
   TPaveText* ntleaf = new TPaveText(0.30,.42,.62,.7);
   ntleaf->SetTextSize(0.014);
   ntleaf->SetFillColor(leafcolor);
   ntleaf->SetTextAlign(12);
   ntleaf->AddText("fLen: number of fixed elements");
   ntleaf->AddText("fLenType: number of bytes of data type");
   ntleaf->AddText("fOffset: relative to Leaf0-fAddress");
   ntleaf->AddText("fNbytesIO: number of bytes used for I/O");
   ntleaf->AddText("fIsPointer: True if pointer");
   ntleaf->AddText("fIsRange: True if leaf has a range");
   ntleaf->AddText("fIsUnsigned: True if unsigned");
   ntleaf->AddText("*fLeafCount: points to Leaf counter");
   ntleaf->AddText(" ");
   ntleaf->AddLine(0,0,0,0);
   ntleaf->AddText("fName = Leaf name");
   ntleaf->AddText("fTitle = Leaf type (see Type codes)");
   ntleaf->Draw();
   TPaveText* type = new TPaveText(.65,.42,.95,.7);
   type->SetTextAlign(12);
   type->SetFillColor(leafcolor);
   type->AddText(" ");
   type->AddText("C : a character string");
   type->AddText("B : an 8 bit signed integer");
   type->AddText("b : an 8 bit unsigned integer");
   type->AddText("S : a 16 bit signed short integer");
   type->AddText("s : a 16 bit unsigned short integer");
   type->AddText("I : a 32 bit signed integer");
   type->AddText("i : a 32 bit unsigned integer");
   type->AddText("F : a 32 bit floating point");
   type->AddText("D : a 64 bit floating point");
   type->AddText("TXXXX : a class name TXXXX");
   type->Draw();
   TPaveLabel* typecode = new TPaveLabel(.7,.68,.9,.72,"fType codes");
   typecode->SetFillColor(leafcolor);
   typecode->Draw();
   ldot->DrawLine(.4,.75,.30,.7);
   ldot->DrawLine(.5,.75,.62,.7);
   TPaveText* ntbasket = new TPaveText(0.02,-0.07,0.35,.25);
   ntbasket->SetFillColor(basketcolor);
   ntbasket->SetTextSize(0.014);
   ntbasket->SetTextAlign(12);
   ntbasket->AddText("fNbytes: Size of compressed Basket");
   ntbasket->AddText("fObjLen: Size of uncompressed Basket");
   ntbasket->AddText("fDatime: Date/Time when written to store");
   ntbasket->AddText("fKeylen: Number of bytes for the key");
   ntbasket->AddText("fCycle : Cycle number");
   ntbasket->AddText("fSeekKey: Pointer to Basket on file");
   ntbasket->AddText("fSeekPdir: Pointer to directory on file");
   ntbasket->AddText("fClassName: 'TBasket'");
   ntbasket->AddText("fName: Branch name");
   ntbasket->AddText("fTitle: TreePave name");
   ntbasket->AddText(" ");
   ntbasket->AddLine(0,0,0,0);
   ntbasket->AddText("fNevBuf: Number of events in Basket");
   ntbasket->AddText("fLast: pointer to last used byte in Basket");
   ntbasket->Draw();
   ldot->DrawLine(.4,.3,0.02,0.25);
   ldot->DrawLine(.5,.25,0.35,-.07);
   ldot->DrawLine(.5,.3,0.35,0.25);
   TPaveText* ntbranch = new TPaveText(0.02,0.40,0.18,0.68);
   ntbranch->SetFillColor(branchcolor);
   ntbranch->SetTextSize(0.015);
   ntbranch->SetTextAlign(12);
   ntbranch->AddText("fBasketSize");
   ntbranch->AddText("fEventOffsetLen");
   ntbranch->AddText("fMaxBaskets");
   ntbranch->AddText("fEntries");
   ntbranch->AddText("fAddress of Leaf0");
   ntbranch->AddText(" ");
   ntbranch->AddLine(0,0,0,0);
   ntbranch->AddText("fName: Branchname");
   ntbranch->AddText("fTitle: leaflist");
   ntbranch->Draw();
   ldot->DrawLine(.2,.97,.02,.68);
   ldot->DrawLine(.35,.97,.18,.68);
   ldot->DrawLine(.35,.87,.18,.40);
   TPavesText* basketstore = new TPavesText(.8,-0.088,0.952,-0.0035,7,"tr");
   basketstore->SetFillColor(28);
   basketstore->AddText("Baskets");
   basketstore->AddText("Stores");
   basketstore->Draw();
   c1->Update();

   gBenchmark->Show("treePave");
}
示例#20
0
void ptBestFit(float BIN_SIZE=5.0,bool BLIND=false,TString MASS,TString NAME)
{
  gROOT->ProcessLine(".x ../../common/styleCMSTDR.C");
  gSystem->Load("libHiggsAnalysisCombinedLimit.so");
  gROOT->ForceStyle();
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);
  gROOT->SetBatch(1);
  gStyle->SetPadRightMargin(0.04);
  gStyle->SetPadLeftMargin(0.16);
  gStyle->SetPadTopMargin(0.06);
  gStyle->SetPadBottomMargin(0.10);
  gStyle->SetTitleFont(42,"XY");
  gStyle->SetTitleSize(0.0475,"XY");
  gStyle->SetTitleOffset(0.9,"X");
  gStyle->SetTitleOffset(1.5,"Y");
  gStyle->SetLabelSize(0.0375,"XY");

  RooMsgService::instance().setSilentMode(kTRUE);
  for(int i=0;i<2;i++) {
    RooMsgService::instance().setStreamStatus(i,kFALSE);
  }
  float XMIN = 80;
  float XMAX = 200; 

  TFile *f1 = TFile::Open("datacards/datacard_m"+MASS+"_"+NAME+".root");
  TFile *f2 = TFile::Open("combine/mlfit.vbfHbb_"+NAME+"_mH"+MASS+".root");
  TFile *f3 = TFile::Open("root/sig_shapes_workspace_B80-200.root");
  TFile *f4 = TFile::Open("root/data_shapes_workspace_"+NAME+".root");

  RooWorkspace *w = (RooWorkspace*)f1->Get("w");
  //w->Print();
  RooAbsPdf *bkg_model = (RooAbsPdf*)w->pdf("model_s");
  RooFitResult *res_s  = (RooFitResult*)f2->Get("fit_s"); 
  RooFitResult *res_b  = (RooFitResult*)f2->Get("fit_b");
  RooRealVar *rFit     = dynamic_cast<RooRealVar *>(res_s->floatParsFinal()).find("r");
  RooDataSet *data     = (RooDataSet*)w->data("data_obs");
  
  int nparS=0,nparB=0;
  cout << res_s->floatParsFinal().getSize() << endl;
  cout << res_b->floatParsFinal().getSize() << endl;
  nparS = res_s->floatParsFinal().getSize();
  nparB = res_b->floatParsFinal().getSize();  
  float chi2sumS = 0.;
  float chi2sumB = 0.;
  int nparsum = 0;
//  if (BLIND) {
//    res_b->Print();
//  }
//  else {
//    res_s->Print();
//  }
  
  w->allVars().assignValueOnly(res_s->floatParsFinal());
//  w->Print();
//  w->allVars()->Print();

  RooWorkspace *wSig = (RooWorkspace*)f3->Get("w"); 
  RooWorkspace *wDat = (RooWorkspace*)f4->Get("w"); 

  const RooSimultaneous *sim = dynamic_cast<const RooSimultaneous *> (bkg_model);
  const RooAbsCategoryLValue &cat = (RooAbsCategoryLValue &) sim->indexCat();
  TList *datasets = data->split(cat,true);
  TIter next(datasets);
  //int count = 0; 
  for(RooAbsData *ds = (RooAbsData*)next();ds != 0; ds = (RooAbsData*)next()) {
	 //if (count > 0) return 0;
	 //count++;
    RooAbsPdf *pdfi = sim->getPdf(ds->GetName());
    RooArgSet *obs = (RooArgSet*)pdfi->getObservables(ds);
    RooRealVar *x = dynamic_cast<RooRealVar *>(obs->first());

    RooRealVar *yield_vbf = (RooRealVar*)wSig->var("yield_signalVBF_mass"+MASS+"_"+TString(ds->GetName()));
    RooRealVar *yield_gf  = (RooRealVar*)wSig->var("yield_signalGF_mass"+MASS+"_"+TString(ds->GetName()));
    TString ds_name(ds->GetName());
    //----- get the QCD normalization -----------
    RooRealVar *qcd_norm_final = dynamic_cast<RooRealVar *>(res_s->floatParsFinal()).find("CMS_vbfbb_qcd_norm_"+ds_name);
    RooRealVar *qcd_yield      = (RooRealVar*)wDat->var("yield_data_"+ds_name);

    float Nqcd  = exp(log(1.5)*qcd_norm_final->getVal())*qcd_yield->getVal();
    float eNqcd = log(1.5)*qcd_norm_final->getError()*Nqcd;
    cout<<"QCD normalization = "<<Nqcd<<" +/- "<<eNqcd<<endl;
    
    TH1 *hCoarse = (TH1*)ds->createHistogram("coarseHisto_"+ds_name,*x);
    float norm = hCoarse->Integral();
  
	 int rebin = BIN_SIZE/hCoarse->GetBinWidth(1);
    hCoarse->Rebin(rebin);

    float MIN_VAL = TMath::Max(0.9*hCoarse->GetBinContent(hCoarse->GetMinimumBin()),1.0);
    float MAX_VAL = 1.3*hCoarse->GetBinContent(hCoarse->GetMaximumBin());
    RooDataHist ds_coarse("ds_coarse_"+ds_name,"ds_coarse_"+ds_name,*x,hCoarse);

    TH1F *hBlind = (TH1F*)hCoarse->Clone("blindHisto_"+ds_name);
    for(int i=0;i<hBlind->GetNbinsX();i++) {
      double x0 = hBlind->GetBinCenter(i+1);
      if (x0 > 100 && x0 < 150) {
        hBlind->SetBinContent(i+1,0);
        hBlind->SetBinError(i+1,0);
      }
    }
    
    RooDataHist ds_blind("ds_blind_"+ds_name,"ds_blind_"+ds_name,*x,hBlind); 
    
    RooHist *hresid,*hresid0;
    RooPlot *frame1 = x->frame();
    RooPlot *frame2 = x->frame();
    
    if (BLIND) {
		//cout << "Blind case: " << ds_coarse.GetName() << endl;
      ds_coarse.plotOn(frame1,LineColor(0),MarkerColor(0));
      pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),VisualizeError(*res_s,1,kTRUE),FillColor(0),MoveToBack());
      pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),LineWidth(2),LineStyle(3));
      ds_blind.plotOn(frame1);
      hresid = frame1->residHist();
      frame2->addPlotable(hresid,"pE1");
    }
    else {    
		//cout << "Non-blind case: " << ds_coarse.GetName() << endl;
		ds_coarse.plotOn(frame1);
      pdfi->plotOn(frame1);
		//cout << pdfi->getParameters(ds_coarse)->selectByAttrib("Constant",kFALSE)->getSize() << endl;
      cout<<"chi2/ndof (bkg+sig) = "<<frame1->chiSquare()<<endl;
		cout << ds_coarse.numEntries() << endl;
		chi2sumS += frame1->chiSquare()*ds_coarse.numEntries();
		nparsum += ds_coarse.numEntries();
		//hresid0 = frame1->residHist();
      //pdfi->plotOn(frame1,VisualizeError(*res_s,1,kTRUE),FillColor(0),MoveToBack());
      pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name),LineWidth(2),LineStyle(5),LineColor(kGreen+2));
      pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),LineWidth(2),LineStyle(2),LineColor(kBlack)); 
      cout<<"chi2/ndof (bkg) = "<<frame1->chiSquare()<<endl;
		chi2sumB += frame1->chiSquare()*ds_coarse.numEntries();
		pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),LineWidth(2),LineStyle(2),LineColor(kBlack),VisualizeError(*res_s,1,kTRUE),FillColor(0),MoveToBack()); 
      hresid = frame1->residHist();
      frame2->addPlotable(hresid,"pE1");
    
      float yield_sig = rFit->getValV()*(yield_vbf->getValV()+yield_gf->getValV());
      RooAbsPdf *signal_pdf = (RooAbsPdf*)w->pdf("shapeSig_qqH_"+ds_name);
      signal_pdf->plotOn(frame2,LineWidth(2),LineColor(kRed),Normalization(yield_sig,RooAbsReal::NumEvent),MoveToBack());
    }
//	 hresid0->Print();
//	 hresid->Print();
//	 double x2,y2;
//	 for (int i=0; i<3; ++i) {
//		 hresid0->GetPoint(i,x2,y2);
//		 cout << "BKG+SIG\t" << x2 << "\t" << y2 << endl;
//		 hresid->GetPoint(i,x2,y2);
//		 cout << "BKG\t" << x2 << "\t" << y2 << endl;
//		 ds_coarse.get(i);
//		 cout << ds_coarse.weightError(RooAbsData::SumW2) << endl;
//		 cout << endl;
//	 }

    TCanvas* canFit = new TCanvas("Higgs_fit_"+ds_name,"Higgs_fit_"+ds_name,900,750);
    canFit->cd(1)->SetBottomMargin(0.4);
    frame1->SetMinimum(MIN_VAL);
    frame1->SetMaximum(MAX_VAL);
    frame1->GetYaxis()->SetNdivisions(510);
    frame1->GetXaxis()->SetTitleSize(0);
    frame1->GetXaxis()->SetLabelSize(0);
    frame1->GetYaxis()->SetTitle(TString::Format("Events / %1.1f GeV",BIN_SIZE));
    frame1->Draw();
    gPad->Update();
    
    TList *list = (TList*)gPad->GetListOfPrimitives();
    //list->Print();
    TH1F *hUncH  = new TH1F("hUncH"+ds_name,"hUncH"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
    TH1F *hUncL  = new TH1F("hUncL"+ds_name,"hUncL"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
    TH1F *hUnc2H = new TH1F("hUnc2H"+ds_name,"hUnc2H"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
    TH1F *hUnc2L = new TH1F("hUnc2L"+ds_name,"hUnc2L"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX); 
    TH1F *hUncC  = new TH1F("hUncC"+ds_name,"hUncC"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX); 
    
    RooCurve *errorBand,*gFit,*gQCDFit,*gBkgFit;
    
	//list->Print();
    if (BLIND) {
      errorBand = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]_errorband_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
      gFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]"+"_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
    }
    else {
      //errorBand = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]_errorband");
      errorBand = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]_errorband_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
      gFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]");
    } 
    gQCDFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]"+"_Comp[shapeBkg_qcd_"+ds_name+"]");  
    gBkgFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]"+"_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
    for(int i=0;i<hUncH->GetNbinsX();i++) {
      double x0 = hUncH->GetBinCenter(i+1);
      double e1 = fabs(errorBand->Eval(x0)-gBkgFit->Eval(x0));
      //double e1 = fabs(errorBand->Eval(x0)-gFit->Eval(x0));
      double e2 = eNqcd/hUncH->GetNbinsX();
      hUncH->SetBinContent(i+1,sqrt(pow(e2,2)+pow(e1,2)));
      hUnc2H->SetBinContent(i+1,2*sqrt(pow(e2,2)+pow(e1,2)));
      hUncL->SetBinContent(i+1,-sqrt(pow(e2,2)+pow(e1,2)));
      hUnc2L->SetBinContent(i+1,-2*sqrt(pow(e2,2)+pow(e1,2)));
		hUncC->SetBinContent(i+1,0.);
    }
   
    TPad* pad = new TPad("pad", "pad", 0., 0., 1., 1.);
    pad->SetTopMargin(0.63);
    pad->SetFillColor(0);
    pad->SetFillStyle(0);
    pad->Draw();
    pad->cd(0);
    hUnc2H->GetXaxis()->SetTitle("m_{bb} (GeV)");
    hUnc2H->GetYaxis()->SetTitle("Data - Bkg");
    //hUnc2H->GetYaxis()->SetTitle("Data - Fit");
    double YMAX = 1.1*frame2->GetMaximum();
    double YMIN = -1.1*frame2->GetMaximum();
    hUnc2H->GetYaxis()->SetRangeUser(YMIN,YMAX);
    hUnc2H->GetYaxis()->SetNdivisions(507);
//    hUnc2H->GetXaxis()->SetTitleOffset(0.9);
//    hUnc2H->GetYaxis()->SetTitleOffset(1.0);
    hUnc2H->GetYaxis()->SetTickLength(0.0);
//    hUnc2H->GetYaxis()->SetTitleSize(0.05);
//    hUnc2H->GetYaxis()->SetLabelSize(0.04);
    hUnc2H->GetYaxis()->CenterTitle(kTRUE);
    hUnc2H->SetFillColor(kGreen);
    hUnc2L->SetFillColor(kGreen);
    hUncH->SetFillColor(kYellow);
    hUncL->SetFillColor(kYellow);
	 hUncC->SetLineColor(kBlack);
	 hUncC->SetLineStyle(7);
    hUnc2H->Draw("HIST");
    hUnc2L->Draw("same HIST");
    hUncH->Draw("same HIST");
    hUncL->Draw("same HIST");
	 hUncC->Draw("same HIST");
	 frame2->GetYaxis()->SetTickLength(0.03/0.4);
    frame2->Draw("same");

    TList *list1 = (TList*)gPad->GetListOfPrimitives();
    //list1->Print();
    RooCurve *gSigFit = (RooCurve*)list1->FindObject("shapeSig_qqH_"+ds_name+"_Norm[mbbReg_"+ds_name+"]");

    TLegend *leg = new TLegend(0.70,0.61,0.94,1.-gStyle->GetPadTopMargin()-0.01);
	 leg->SetTextFont(42);
	 leg->SetFillStyle(-1);
	 //leg->SetHeader(ds_name+" (m_{H}="+MASS+")");
    leg->SetHeader(TString::Format("Category %d",atoi(ds_name(3,1).Data())+1));
    leg->AddEntry(hBlind,"Data","P");
    if (!BLIND) {
      leg->AddEntry(gSigFit,"Fitted signal","L");
    }
	 TLine *gEmpty = new TLine(0.0,0.0,0.0,0.0);
	 gEmpty->SetLineWidth(0);
	 TLegendEntry *l1 = leg->AddEntry(gEmpty,"(m_{H} = "+MASS+" GeV)","");
	 l1->SetTextSize(0.038*0.97*0.85);
    leg->AddEntry(gFit,"Bkg. + signal","L");
    leg->AddEntry(gBkgFit,"Bkg.","L");
    leg->AddEntry(gQCDFit,"QCD","L");
    leg->AddEntry(hUnc2H,"2#sigma bkg. unc.","F");
    leg->AddEntry(hUncH,"1#sigma bkg. unc.","F");
    leg->SetFillColor(0);
    leg->SetBorderSize(0);
    leg->SetTextFont(42);
    leg->SetTextSize(0.038*0.98);
    leg->Draw(); 
	 leg->SetY1(leg->GetY2()-leg->GetNRows()*0.045*0.96);
     
    TPaveText *paveCMS = new TPaveText(gStyle->GetPadLeftMargin()+0.02,0.7,gStyle->GetPadLeftMargin()+0.15,1.-gStyle->GetPadTopMargin()-0.01,"NDC");
	 paveCMS->SetTextFont(62);
	 paveCMS->SetTextSize(gStyle->GetPadTopMargin()*3./4.);
	 paveCMS->SetBorderSize(0);
	 paveCMS->SetFillStyle(-1);
	 paveCMS->SetTextAlign(12);
	 paveCMS->AddText("CMS");
	 paveCMS->Draw();
	 gPad->Update();
	 paveCMS->SetY1NDC(paveCMS->GetY2NDC()-paveCMS->GetListOfLines()->GetSize()*gStyle->GetPadTopMargin());

	 TPaveText *paveLumi = new TPaveText(0.5,1.-gStyle->GetPadTopMargin(),0.98,1.00,"NDC");
	 paveLumi->SetTextFont(42);
	 paveLumi->SetTextSize(gStyle->GetPadTopMargin()*3./4.);
	 paveLumi->SetBorderSize(0);
	 paveLumi->SetFillStyle(-1);
	 paveLumi->SetTextAlign(32);
	 paveLumi->AddText(TString::Format("%.1f fb^{-1} (8TeV)",(atoi(ds_name(3,1).Data())<4 ? 19.8 : 18.3)).Data());//+ 18.2 ;
	 paveLumi->Draw();

	 TString path=".";
	 //TString path="BiasV10_limit_BRN5p4_dX0p1_B80-200_CAT0-6/output/";
	 system(TString::Format("[ ! -d %s/plot ] && mkdir %s/plot",path.Data(),path.Data()).Data());
	 system(TString::Format("[ ! -d %s/plot/fits ] && mkdir %s/plot/fits",path.Data(),path.Data()).Data());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s.pdf",path.Data(),MASS.Data(),ds_name.Data()).Data());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s.png",path.Data(),MASS.Data(),ds_name.Data()).Data());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s.eps",path.Data(),MASS.Data(),ds_name.Data()).Data());
	 TText *l = (TText*)paveCMS->AddText("Preliminary");
	 l->SetTextFont(52);
	 paveCMS->Draw();
	 gPad->Update();
	 paveCMS->SetY1NDC(paveCMS->GetY2NDC()-paveCMS->GetListOfLines()->GetSize()*gStyle->GetPadTopMargin());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s_prelim.pdf",path.Data(),MASS.Data(),ds_name.Data()).Data());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s_prelim.png",path.Data(),MASS.Data(),ds_name.Data()).Data());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s_prelim.eps",path.Data(),MASS.Data(),ds_name.Data()).Data());

    delete ds;
  }

  cout << "chi2sumS: " << chi2sumS << endl;
  cout << "chi2sumB: " << chi2sumB << endl;
  cout << "nparS: " << nparS << endl;
  cout << "nparB: " << nparB << endl;
  cout << "nbinsum: " << nparsum << endl;
  cout << "chi2sumS/(nbinsum - nparS): " << chi2sumS / (float)(nparsum - nparS) << endl;
  cout << "chi2sumB/(nbinsum - nparB): " << chi2sumB / (float)(nparsum - nparB) << endl;
  delete datasets; 
}