Example #1
0
File: event.C Project: 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");
}
Example #2
0
   void toyplotsge1btight() {

      gStyle->SetPadBottomMargin(0.15) ;
      gStyle->SetPadLeftMargin(0.15) ;
      gStyle->SetOptTitle(0) ;


      TCanvas* c1 = new TCanvas("c1","c1") ;

      TArrow* arrow = new TArrow() ;
      arrow->SetLineWidth(3) ;


      TChain toyns("tt_toy_nosusyfit") ;
      toyns.Add("an-11-257-v3-files/output-files/toyge1btight-smonly-mctest.root") ;

      TChain bgo("tt_cls_bgonly") ;
      TChain spb("tt_cls_splusb") ;

      bgo.Add("an-11-257-v3-files/output-files/toyge1btight-smonly-mctest.root") ;
      spb.Add("an-11-257-v3-files/output-files/toyge1btight-smonly-mctest.root") ;



     //============ fit values

      gStyle->SetOptStat("emr") ;

      TH1F* httwjfit = new TH1F("httwjfit","ttwj",40, 0., 45. ) ;
      TH1F* hqcdfit  = new TH1F("hqcdfit" ,"qcd" ,40, 0., 10. ) ;
      TH1F* hznnfit  = new TH1F("hznnfit" ,"znn" ,40, 0., 20. ) ;

      toyns.Draw("ttwj_sig_fit>>httwjfit","") ;
      toyns.Draw("qcd_sig_fit>>hqcdfit","") ;
      toyns.Draw("znn_sig_fit>>hznnfit","") ;

      httwjfit->SetLineWidth(2) ;
      hqcdfit->SetLineWidth(2) ;
      hznnfit->SetLineWidth(2) ;

      httwjfit->SetFillColor(11) ;
      hqcdfit->SetFillColor(11) ;
      hznnfit->SetFillColor(11) ;

      httwjfit->SetXTitle("Fit ttwj SIG events") ;
      hqcdfit->SetXTitle("Fit QCD SIG events") ;
      hznnfit->SetXTitle("Fit Znn SIG events") ;

      httwjfit->SetYTitle("Toy experiments") ;
      hqcdfit->SetYTitle("Toy experiments") ;
      hznnfit->SetYTitle("Toy experiments") ;

      httwjfit->Draw() ;
      arrow->DrawArrow(19.6,40,19.6,0) ;
      c1->SaveAs("an-11-257-v3-files/output-files/toymc-ttwj-sig-fit-ge1btight.png") ;
      hqcdfit->Draw() ;
      arrow->DrawArrow(1.3,60,1.3,0) ;
      c1->SaveAs("an-11-257-v3-files/output-files/toymc-qcd-sig-fit-ge1btight.png") ;
      hznnfit->Draw() ;
      arrow->DrawArrow(4.25,40,4.25,0) ;
      c1->SaveAs("an-11-257-v3-files/output-files/toymc-znn-sig-fit-ge1btight.png") ;


     //============ fit uncertainty

      TH1F* httwjerr = new TH1F("httwjerr","ttwj",40, 0., 10. ) ;
      TH1F* hqcderr  = new TH1F("hqcderr" ,"qcd" ,40, 0., 8. ) ;
      TH1F* hznnerr  = new TH1F("hznnerr" ,"znn" ,40, 0., 10. ) ;

      toyns.Draw("ttwj_sig_err>>httwjerr","") ;
      toyns.Draw("qcd_sig_err>>hqcderr","") ;
      toyns.Draw("znn_sig_err>>hznnerr","") ;

      httwjerr->SetLineWidth(2) ;
      hqcderr->SetLineWidth(2) ;
      hznnerr->SetLineWidth(2) ;

      httwjerr->SetFillColor(11) ;
      hqcderr->SetFillColor(11) ;
      hznnerr->SetFillColor(11) ;

      httwjerr->SetXTitle("err ttwj SIG events") ;
      hqcderr->SetXTitle("err QCD SIG events") ;
      hznnerr->SetXTitle("err Znn SIG events") ;

      httwjerr->SetYTitle("Toy experiments") ;
      hqcderr->SetYTitle("Toy experiments") ;
      hznnerr->SetYTitle("Toy experiments") ;

      httwjerr->Draw() ;
      c1->SaveAs("an-11-257-v3-files/output-files/toymc-ttwj-sig-err-ge1btight.png") ;
      hqcderr->Draw() ;
      c1->SaveAs("an-11-257-v3-files/output-files/toymc-qcd-sig-err-ge1btight.png") ;
      hznnerr->Draw() ;
      c1->SaveAs("an-11-257-v3-files/output-files/toymc-znn-sig-err-ge1btight.png") ;


     //============ q value distributions.

      gStyle->SetOptStat(0) ;

      TH1F* hbgo = new TH1F("hbgo","BG only", 50, 0., 15.) ;
      TH1F* hspb = new TH1F("hspb","SIG + BG", 50, 0., 15.) ;

      hbgo->SetLineWidth(2) ;
      hspb->SetLineWidth(2) ;
      hbgo->SetLineColor(2) ;
      hspb->SetLineColor(4) ;

      bgo.Draw("testStat>>hbgo","") ;
      spb.Draw("testStat>>hspb","") ;

      hspb->SetXTitle("q value") ;
      hspb->SetYTitle("Toy experiments") ;

      hspb->Draw() ;
      hbgo->Draw("same") ;


    //+++ X value below is hardwired to 2.44.
    //    If inputs are changed, grep the string "Data value of test statistic"
    //    in the runtoyge1btight log file to find the new value.
    //
      arrow->DrawArrow(1.13,150,1.13,0.,0,">") ;

      TLegend* legend = new TLegend(0.4,0.5,0.8,0.8) ;
      legend->AddEntry( hbgo, "BG-only hypothesis") ;
      legend->AddEntry( hspb, "SUSY+BG hypothesis") ;
      legend->SetFillColor(kWhite) ;

      legend->Draw() ;


      c1->SaveAs("an-11-257-v3-files/output-files/toymc-qvalue-distributions-ge1btight.png") ;




   }
void CCProtonPi0_SideBandTool::Plot_NoRatio(int ind, std::string sb_name, std::string var_name, MnvH1D* data, MnvH1D* mc_total, MnvH1D* signal, MnvH1D* WithPi0, MnvH1D* QELike, MnvH1D* SinglePiPlus, MnvH1D* Other)
{
    (void) mc_total;
    std::string type;
    if (ind == 0) type = "Nominal";
    else type = "Fitted";

    std::string norm = "POT";
    std::string plot_title = "Side Band: " + sb_name + " " + type + " " + norm + " Normalized";

    // Get Histograms -- Use new Histograms not to change originals
    MnvH1D* h_data = new MnvH1D(*data);
    h_data->GetYaxis()->CenterTitle();
    h_data->GetXaxis()->SetNdivisions(5,5,0);
    h_data->GetYaxis()->SetNdivisions(5,5,0);

    MnvH1D* h_signal = new MnvH1D(*signal);
    h_signal->GetYaxis()->CenterTitle();
    h_signal->SetFillColor(kGreen+1);
    h_signal->SetLineColor(kGreen+1);
    h_signal->SetFillStyle(3002);
    h_signal->SetLineWidth(2);
    h_signal->GetXaxis()->SetNdivisions(5,5,0);
    h_signal->GetYaxis()->SetNdivisions(5,5,0);

    MnvH1D* h_WithPi0 = new MnvH1D(*WithPi0);
    h_WithPi0->GetYaxis()->CenterTitle();
    h_WithPi0->SetFillColor(kRed);
    h_WithPi0->SetLineColor(kRed);
    h_WithPi0->SetFillStyle(3002);
    h_WithPi0->SetLineWidth(2);
    h_WithPi0->GetXaxis()->SetNdivisions(5,5,0);
    h_WithPi0->GetYaxis()->SetNdivisions(5,5,0);
  
    MnvH1D* h_QELike = new MnvH1D(*QELike);
    h_QELike->GetYaxis()->CenterTitle();
    h_QELike->SetFillColor(kOrange-1);
    h_QELike->SetLineColor(kOrange-1);
    h_QELike->SetFillStyle(3002);
    h_QELike->SetLineWidth(2);
    h_QELike->GetXaxis()->SetNdivisions(5,5,0);
    h_QELike->GetYaxis()->SetNdivisions(5,5,0);
 
    MnvH1D* h_SinglePiPlus = new MnvH1D(*SinglePiPlus);
    h_SinglePiPlus->GetYaxis()->CenterTitle();
    h_SinglePiPlus->SetFillColor(kBlue);
    h_SinglePiPlus->SetLineColor(kBlue);
    h_SinglePiPlus->SetFillStyle(3002);
    h_SinglePiPlus->SetLineWidth(2);
    h_SinglePiPlus->GetXaxis()->SetNdivisions(5,5,0);
    h_SinglePiPlus->GetYaxis()->SetNdivisions(5,5,0);

    MnvH1D* h_Other = new MnvH1D(*Other);
    h_Other->GetYaxis()->CenterTitle();
    h_Other->SetFillColor(kGray+2);
    h_Other->SetLineColor(kGray+2);
    h_Other->SetFillStyle(3002);
    h_Other->SetLineWidth(2);
    h_Other->GetXaxis()->SetNdivisions(5,5,0);
    h_Other->GetYaxis()->SetNdivisions(5,5,0);
  
    // Clear Error Bars
    h_signal->ClearAllErrorBands();
    h_WithPi0->ClearAllErrorBands();
    h_QELike->ClearAllErrorBands();
    h_SinglePiPlus->ClearAllErrorBands();
    h_Other->ClearAllErrorBands();

    TObjArray* mc_hists = new TObjArray;
    mc_hists->Add(h_Other);
    mc_hists->Add(h_SinglePiPlus);
    mc_hists->Add(h_QELike);
    mc_hists->Add(h_WithPi0);
    mc_hists->Add(h_signal);
 
    // ------------------------------------------------------------------------
    // Plot 
    // ------------------------------------------------------------------------
    MnvPlotter* plotter = new MnvPlotter();
    plotter->SetRootEnv();
 
    gStyle->SetCanvasDefW(640);
    gStyle->SetCanvasDefH(480); // 4x3 aspect ratio
    gStyle->SetPadRightMargin(0.05);
    gStyle->SetEndErrorSize(2);
    gStyle->SetStripDecimals(false);

    plotter->axis_minimum = 0.01;
    plotter->legend_text_size  = 0.04;
    plotter->legend_text_font = 42; // default 62 (bold)
    plotter->data_marker_size = 0.8;
    plotter->axis_title_font_x   = 42;
    plotter->axis_title_size_x   = 0.06;
    plotter->axis_title_offset_x = 1.1;
    plotter->axis_title_font_y   = 42;
    plotter->axis_title_size_y   = 0.06;
    plotter->axis_title_offset_y = 1.0;
    plotter->axis_label_size = 0.05;
    plotter->axis_label_font = 42;
    plotter->headroom = 1.75;

    plotter->mc_line_width = 2;
    
    TCanvas* c = new TCanvas("c");

    /*
       void MnvPlotter::DrawDataStackedMC(
            const MnvH1D *  dataHist,
            const TObjArray *    mcHists,
            const Double_t   mcScale = 1.0,
            const std::string &  legPos = "L",
            const std::string &  dataName = "Data",
            const Int_t  mcBaseColor = 2,
            const Int_t  mcColorOffset = 1,
            const Int_t  mcFillStyle = 3001,
            const char *     xaxislabel = "",
            const char *     yaxislabel = "",
            bool     cov_area_normalize = false   
       )    
    */
    plotter->DrawDataStackedMC(h_data, mc_hists, POT_ratio, "N", "Data (3.33e20 POT)", 0, 0, 3002);

    // Add Legend
    double leg_x_min = 0.55;
    double leg_x_max = 0.90;
    double leg_y_min = 0.55;
    double leg_y_max = 0.85;

    h_data->SetMarkerStyle(plotter->data_marker);
    h_data->SetMarkerSize(plotter->data_marker_size);
    h_data->SetMarkerColor(plotter->data_color);
    h_data->SetLineColor(plotter->data_color);
    h_data->SetLineWidth(plotter->data_line_width);

    TLegend *legend = new TLegend(leg_x_min, leg_y_min, leg_x_max, leg_y_max);
    legend->SetBorderSize(0);
    legend->SetFillColor(-1);
    legend->SetFillStyle(0);
    legend->SetTextFont(42);
    legend->SetTextSize(0.04);
    legend->AddEntry(h_data, "Data", "lep");
    legend->AddEntry(h_signal, "Signal", "f");
    legend->AddEntry(h_WithPi0, "Bkgrd: #pi^{0} + meson(s)", "f");
    legend->AddEntry(h_QELike, "Bkgrd: zero meson", "f");
    legend->AddEntry(h_SinglePiPlus, "Bkgrd: charged meson(s)", "f");
    legend->AddEntry(h_Other, "Bkgrd: other", "f");
    legend->SetTextSize(0.04);
    legend->SetTextFont(42);
    legend->Draw();

    // Add Alines if Original Side Band
    //if (false) {
    if (sb_name.compare("Original") == 0) {
        double max_bin = h_data->GetMaximumBin();
        double hist_max = h_data->GetBinContent(max_bin)*1.2;

        TLine line;
        TArrow arrow;
        // Cut Line at 60 MeV
        line.SetLineWidth(2);
        line.SetLineStyle(2);
        line.SetLineColor(kBlack);
        arrow.SetLineWidth(2);
        arrow.SetLineColor(kBlack);
        line.DrawLine(60.0, 0.0, 60.0, hist_max);
        arrow.DrawArrow(60.0, hist_max, 50.0, hist_max, 0.01);

        line.DrawLine(200.0, 0.0, 200.0, hist_max);
        arrow.DrawArrow(200.0, hist_max, 210.0, hist_max, 0.01);

        arrow.SetLineColor(kBlue);
        arrow.DrawArrow(134.98,hist_max/8,134.98,0, 0.01); 
    } 

    // Add Normalization Label
    TLatex norm_text;
    norm_text.SetNDC();
    norm_text.SetTextColor(kBlue);
    norm_text.SetTextSize(0.03);
    norm_text.SetTextAlign(22);
    norm_text.DrawLatex(0.35,0.85,"POT Normalized");

    double info_text_x = 0.85;
    double info_text_y = 0.85;
    TLatex info_text;
    info_text.SetNDC();
    info_text.SetTextColor(kBlack);
    info_text.SetTextFont(62);
    info_text.SetTextAlign(12);
    info_text.SetTextSize(0.04);
    if ( ind == 0) info_text.DrawLatex(info_text_x, info_text_y, "(a)");
    else info_text.DrawLatex(info_text_x, info_text_y, "(b)");

    // Plot Output
    c->Update();
    std::string plotDir = Folder_List::plotDir_Paper;
    std::string out_name;
    out_name = plotDir + var_name + "_" + sb_name + "_" + type + "_" + norm + ".pdf"; 

    c->Print(out_name.c_str(),"pdf");

    delete h_data;
    delete h_signal;
    delete h_WithPi0;
    delete h_QELike;
    delete h_SinglePiPlus;
    delete h_Other;
    delete legend;
    delete c;
    delete plotter;
}
Example #4
0
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();
}
Example #5
0
void toyplotsge1btight() {

    gStyle->SetPadBottomMargin(0.15) ;
    gStyle->SetPadLeftMargin(0.15) ;
    gStyle->SetOptTitle(0) ;


    TCanvas* c1 = new TCanvas("c1","c1") ;

    TArrow* arrow = new TArrow() ;
    arrow->SetLineWidth(3) ;


    TChain toyns("toytt") ;
    toyns.Add("output-files/toy-data-ge1btight.root") ;


    //--- extract true values from TTree.

    double fit_tru_ttwj ;
    TBranch* b_fit_tru_ttwj ;
    toyns.SetBranchAddress("fit_tru_ttwj", &fit_tru_ttwj, &b_fit_tru_ttwj ) ;
    toyns.GetEntry() ;
    printf("\n\n true value for ttwj : %8.2f\n", fit_tru_ttwj ) ;

    double fit_tru_qcd ;
    TBranch* b_fit_tru_qcd ;
    toyns.SetBranchAddress("fit_tru_qcd", &fit_tru_qcd, &b_fit_tru_qcd ) ;
    toyns.GetEntry() ;
    printf("\n\n true value for qcd : %8.2f\n", fit_tru_qcd ) ;

    double fit_tru_znn ;
    TBranch* b_fit_tru_znn ;
    toyns.SetBranchAddress("fit_tru_znn", &fit_tru_znn, &b_fit_tru_znn ) ;
    toyns.GetEntry() ;
    printf("\n\n true value for znn : %8.2f\n", fit_tru_znn ) ;


    //============ fit values

    gStyle->SetOptStat("emr") ;

    TH1F* httwjfit = new TH1F("httwjfit","ttwj",40, 0., 40. ) ;
    TH1F* hqcdfit  = new TH1F("hqcdfit" ,"qcd" ,40, 0., 15. ) ;
    TH1F* hznnfit  = new TH1F("hznnfit" ,"znn" ,40, 0., 25. ) ;

    toyns.Draw("fit_val_ttwj>>httwjfit","fit_cov_qual==3") ;
    toyns.Draw("fit_val_qcd>>hqcdfit","fit_cov_qual==3") ;
    toyns.Draw("fit_val_znn>>hznnfit","fit_cov_qual==3") ;

    httwjfit->SetLineWidth(2) ;
    hqcdfit->SetLineWidth(2) ;
    hznnfit->SetLineWidth(2) ;

    httwjfit->SetFillColor(11) ;
    hqcdfit->SetFillColor(11) ;
    hznnfit->SetFillColor(11) ;

    httwjfit->SetXTitle("Fit ttwj SIG events") ;
    hqcdfit->SetXTitle("Fit QCD SIG events") ;
    hznnfit->SetXTitle("Fit Znn SIG events") ;

    httwjfit->SetYTitle("Toy experiments") ;
    hqcdfit->SetYTitle("Toy experiments") ;
    hznnfit->SetYTitle("Toy experiments") ;

    httwjfit->Draw() ;
    arrow->DrawArrow(fit_tru_ttwj, 0.4*(httwjfit->GetMaximum()), fit_tru_ttwj, 0) ;
    c1->SaveAs("output-files/toymc-ttwj-sig-fit-ge1btight.png") ;
    hqcdfit->Draw() ;
    arrow->DrawArrow(fit_tru_qcd, 0.4*(hqcdfit->GetMaximum()), fit_tru_qcd, 0) ;
    c1->SaveAs("output-files/toymc-qcd-sig-fit-ge1btight.png") ;
    hznnfit->Draw() ;
    arrow->DrawArrow(fit_tru_znn, 0.4*(hznnfit->GetMaximum()), fit_tru_znn, 0) ;
    c1->SaveAs("output-files/toymc-znn-sig-fit-ge1btight.png") ;


    //============ fit uncertainty

    TH1F* httwjerr = new TH1F("httwjerr","ttwj",40, 0., 15. ) ;
    TH1F* hqcderr  = new TH1F("hqcderr" ,"qcd" ,40, 0., 10. ) ;
    TH1F* hznnerr  = new TH1F("hznnerr" ,"znn" ,40, 0., 15. ) ;

    toyns.Draw("fit_err_ttwj>>httwjerr","fit_cov_qual==3") ;
    toyns.Draw("fit_err_qcd>>hqcderr","fit_cov_qual==3") ;
    toyns.Draw("fit_err_znn>>hznnerr","fit_cov_qual==3") ;

    httwjerr->SetLineWidth(2) ;
    hqcderr->SetLineWidth(2) ;
    hznnerr->SetLineWidth(2) ;

    httwjerr->SetFillColor(11) ;
    hqcderr->SetFillColor(11) ;
    hznnerr->SetFillColor(11) ;

    httwjerr->SetXTitle("err ttwj SIG events") ;
    hqcderr->SetXTitle("err QCD SIG events") ;
    hznnerr->SetXTitle("err Znn SIG events") ;

    httwjerr->SetYTitle("Toy experiments") ;
    hqcderr->SetYTitle("Toy experiments") ;
    hznnerr->SetYTitle("Toy experiments") ;

    httwjerr->Draw() ;
    c1->SaveAs("output-files/toymc-ttwj-sig-err-ge1btight.png") ;
    hqcderr->Draw() ;
    c1->SaveAs("output-files/toymc-qcd-sig-err-ge1btight.png") ;
    hznnerr->Draw() ;
    c1->SaveAs("output-files/toymc-znn-sig-err-ge1btight.png") ;






}
Example #6
0
void fildir(){


   TCanvas *c1 = new TCanvas("c1","ROOT FilDir description",700,900);
   c1->Range(1,1,19,24.5);
   TPaveLabel *title = new TPaveLabel(4,23,16,24.2,"ROOT File/Directory/Key description");
   title->SetFillColor(16);
   title->Draw();

   Int_t keycolor = 42;
   Int_t dircolor = 21;
   Int_t objcolor = 46;
   TPaveText *file = new TPaveText(2,19,6,22);
   file->SetFillColor(39);
   file->Draw();
   file->SetTextSize(0.04);
   file->AddText("TFile");
   file->AddText("Header");
   TArrow *arrow = new TArrow(6,20.5,17,20.5,0.02,"|>");
   arrow->SetFillStyle(1001);
   arrow->SetLineWidth(2);
   arrow->Draw();
   TPaveText *free1 = new TPaveText(8,20,11,21);
   free1->SetFillColor(18);
   free1->Draw();
   free1->AddText("First:Last");
   TPaveText *free2 = new TPaveText(12,20,15,21);
   free2->SetFillColor(18);
   free2->Draw();
   free2->AddText("First:Last");
   TText *tfree = new TText(6.2,21.2,"fFree = TList of free blocks");
   tfree->SetTextSize(0.02);
   tfree->Draw();
   TText *tkeys = new TText(5.2,18.2,"fKeys = TList of Keys");
   tkeys->SetTextSize(0.02);
   tkeys->Draw();
   TText *tmemory = new TText(3.2,15.2,"fListHead = TList of Objects in memory");
   tmemory->SetTextSize(0.02);
   tmemory->Draw();

   arrow->DrawArrow(5,17,17,17,0.02,"|>");
   TLine *line = new TLine(5,19,5,17);
   line->SetLineWidth(2);
   line->Draw();
   TPaveText *key0 = new TPaveText(7,16,10,18);
   key0->SetTextSize(0.04);
   key0->SetFillColor(keycolor);
   key0->AddText("Key 0");
   key0->Draw();
   TPaveText *key1 = new TPaveText(12,16,15,18);
   key1->SetTextSize(0.04);
   key1->SetFillColor(keycolor);
   key1->AddText("Key 1");
   key1->Draw();
   line->DrawLine(3,19,3,14);
   line->DrawLine(3,14,18,14);
   TPaveText *obj0 = new TPaveText(5,13,8,15);
   obj0->SetFillColor(objcolor);
   obj0->AddText("Object");
   obj0->Draw();
   TPaveText *dir1 = new TPaveText(10,13,13,15);
   dir1->SetFillColor(dircolor);
   dir1->AddText("SubDir");
   dir1->Draw();
   TPaveText *obj1 = new TPaveText(15,13,18,15);
   obj1->SetFillColor(objcolor);
   obj1->AddText("Object");
   obj1->Draw();
   arrow->DrawArrow(12,11,17,11,0.015,"|>");
   arrow->DrawArrow(11,9,17,9,0.015,"|>");
   line->DrawLine(12,13,12,11);
   line->DrawLine(11,13,11,9);
   TPaveText *key2 = new TPaveText(14,10.5,16,11.5);
   key2->SetFillColor(keycolor);
   key2->AddText("Key 0");
   key2->Draw();
   TPaveText *obj2 = new TPaveText(14,8.5,16,9.5);
   obj2->SetFillColor(objcolor);
   obj2->AddText("Object");
   obj2->Draw();
   TLine *ldot = new TLine(10,15,2,11);
   ldot->SetLineStyle(2);
   ldot->Draw();
   ldot->DrawLine(13,15,8,11);
   ldot->DrawLine(13,13,8,5);
   TPaveText *dirdata = new TPaveText(2,5,8,11);
   dirdata->SetTextAlign(12);
   dirdata->SetFillColor(dircolor);
   dirdata->Draw();
   dirdata->SetTextSize(0.015);
   dirdata->AddText("fModified: True if directory is modified");
   dirdata->AddText("fWritable: True if directory is writable");
   dirdata->AddText("fDatimeC: Creation Date/Time");
   dirdata->AddText("fDatimeM: Last mod Date/Time");
   dirdata->AddText("fNbytesKeys: Number of bytes of key");
   dirdata->AddText("fNbytesName : Header length up to title");
   dirdata->AddText("fSeekDir: Start of Directory on file");
   dirdata->AddText("fSeekParent: Start of Parent Directory");
   dirdata->AddText("fSeekKeys: Pointer to Keys record");
   TPaveText *keydata = new TPaveText(10,2,17,7);
   keydata->SetTextAlign(12);
   keydata->SetFillColor(keycolor);
   keydata->Draw();
   ldot->DrawLine(14,11.5,10,7);
   ldot->DrawLine(16,11.5,17,7);
   keydata->SetTextSize(0.015);
   keydata->AddText("fNbytes: Size of compressed Object");
   keydata->AddText("fObjLen: Size of uncompressed Object");
   keydata->AddText("fDatime: Date/Time when written to store");
   keydata->AddText("fKeylen: Number of bytes for the key");
   keydata->AddText("fCycle : Cycle number");
   keydata->AddText("fSeekKey: Pointer to Object on file");
   keydata->AddText("fSeekPdir: Pointer to directory on file");
   keydata->AddText("fClassName: 'TKey'");
   keydata->AddText("fName: Object name");
   keydata->AddText("fTitle: Object Title");
   c1->Print("fildir.png");
}
Example #7
0
File: file.C Project: MycrofD/root
void file(){

   TCanvas *c1 = new TCanvas("c1","ROOT File description",200,10,700,550);

   c1->Range(0,-0.25,21,14);
   TPaveLabel *title = new TPaveLabel(5,12,15,13.7,c1->GetTitle());
   title->SetFillColor(16);
   title->Draw();

   // horizonthal file layout
   TPave *file = new TPave(1,8.5,20,11);
   file->SetFillColor(11);
   file->Draw();
   TPave *fileh = new TPave(1,8.5,2.5,11);
   fileh->SetFillColor(44);
   fileh->Draw();
   TPave *lrh = new TPave(2.5,8.5,3.3,11,1);
   lrh->SetFillColor(33);
   lrh->Draw();
   lrh->DrawPave(6.9,8.5,7.7,11,1);
   lrh->DrawPave(10.5,8.5,11.3,11,1);
   lrh->DrawPave(14.5,8.5,15.3,11,1);
   TLine *ldot = new TLine(1,8.5,0.5,6.5);
   ldot->SetLineStyle(2);
   ldot->Draw();
   ldot->DrawLine(2.5, 8.5, 9.4, 6.5);
   ldot->DrawLine(10.5, 8.5, 10, 6.5);
   ldot->DrawLine(11.3, 8.5, 19.5, 6.5);
   TLine *line = new TLine(2.6,11,2.6,11.5);
   line->Draw();
   line->DrawLine(2.6,11.5,7,11.5);
   TArrow *arrow = new TArrow(7,11.5,7,11.1,0.01,"|>");
   arrow->SetFillStyle(1001);
   arrow->Draw();
   line->DrawLine( 7, 8.5, 7, 8.0);
   line->DrawLine( 7, 8.0, 10.6, 8);
   arrow->DrawArrow( 10.6,8, 10.6, 8.4,0.01,"|>");
   line->DrawLine( 10.6, 11, 10.6, 11.5);
   line->DrawLine( 10.6, 11.5, 14.6, 11.5);
   arrow->DrawArrow( 14.6,11.5, 14.6,11.1,0.01,"|>");
   line->DrawLine( 14.6, 8.5, 14.6, 8.0);
   line->DrawLine( 14.6, 8.0, 16, 8);
   ldot->DrawLine(16, 8, 19, 8);
   TText *vert = new TText(1.5,9.75,"File");
   vert->SetTextAlign(21);
   vert->SetTextAngle(90);
   vert->SetTextSize(0.025);
   vert->Draw();
   vert->DrawText(2.0, 9.75,"Header");
   vert->DrawText(2.9, 9.75,"Logical Record");
   vert->DrawText(3.2, 9.75,"Header");
   vert->DrawText(7.3, 9.75,"Logical Record");
   vert->DrawText(7.6, 9.75,"Header");
   vert->DrawText(10.9,9.75,"Logical Record");
   vert->DrawText(11.2,9.75,"Header");
   vert->DrawText(14.9,9.75,"Logical Record");
   vert->DrawText(15.2,9.75,"Header");
   TText *hori = new TText(4.75,10,"Object");
   hori->SetTextAlign(22);
   hori->SetTextSize(0.035);
   hori->Draw();
   hori->DrawText(4.75, 9.5,"Data");
   hori->DrawText(9.2, 10,"Deleted");
   hori->DrawText(9.2, 9.5,"Object");
   line->DrawLine( 6.9, 8.5, 10.5, 11);
   line->DrawLine( 6.9, 11, 10.5, 8.5);
   TText *tbig = new TText(17,9.75,"............");
   tbig->SetTextAlign(22);
   tbig->SetTextSize(0.03);
   tbig->Draw();
   tbig->DrawText(2.6, 7, "fBEGIN");
   tbig->DrawText(20., 7, "fEND");
   arrow->DrawArrow( 2.6,7, 2.6,8.4,0.01,"|>");
   arrow->DrawArrow( 20,7, 20,8.4,0.01,"|>");

   //file header
   TPaveText *header = new TPaveText(0.5,.2,9.4,6.5);
   header->SetFillColor(44);
   header->Draw();
   TText *fh=header->AddText("File Header");
   fh->SetTextAlign(22);
   fh->SetTextSize(0.04);
   header->SetTextSize(0.027);
   header->SetTextAlign(12);
   header->AddText(" ");
   header->AddLine(0,0,0,0);
   header->AddText("\"root\": Root File Identifier");
   header->AddText("fVersion: File version identifier");
   header->AddText("fBEGIN: Pointer to first data record");
   header->AddText("fEND: Pointer to first free word at EOF");
   header->AddText("fSeekFree: Pointer to FREE data record");
   header->AddText("fNbytesFree: Number of bytes in FREE");
   header->AddText("fNfree: Number of free data records");
   header->AddText("fNbytesName: Number of bytes in name/title");
   header->AddText("fUnits: Number of bytes for pointers");
   header->AddText("fCompress: Compression level");

   //logical record header
   TPaveText *lrecord = new TPaveText(10,0.2,19.5,6.5);
   lrecord->SetFillColor(33);
   lrecord->Draw();
   TText *tlrh=lrecord->AddText("Logical Record Header (TKEY)");
   tlrh->SetTextAlign(22);
   tlrh->SetTextSize(0.04);
   lrecord->SetTextSize(0.027);
   lrecord->SetTextAlign(12);
   lrecord->AddText(" ");
   lrecord->AddLine(0,0,0,0);
   lrecord->AddText("fNbytes: Length of compressed object");
   lrecord->AddText("fVersion: Key version identifier");
   lrecord->AddText("fObjLen: Length of uncompressed object");
   lrecord->AddText("fDatime: Date/Time when written to store");
   lrecord->AddText("fKeylen: Number of bytes for the key");
   lrecord->AddText("fCycle : Cycle number");
   lrecord->AddText("fSeekKey: Pointer to object on file");
   lrecord->AddText("fSeekPdir: Pointer to directory on file");
   lrecord->AddText("fClassName: class name of the object");
   lrecord->AddText("fName: name of the object");
   lrecord->AddText("fTitle: title of the object");

   c1->Update();
   c1->Print("file.png");
}
Example #8
0
void EvtSel_Q2Pmiss(){

  Styles style2; style2.setPadsStyle(2); style2.applyStyle();

  TString NameTrees[3] = {"AWG82/ntuples/small/RAll_RunAll.root", 
			  "AWG82/ntuples/small/uds_RunAll.root", "AWG82/ntuples/small/ccbar_RunAll.root"};
  TChain gen("ntp1"), cont("ntp1");
  gen.Add(NameTrees[0]);
  for(int t=1; t<3; t++) cont.Add(NameTrees[t]);
  double totMCB = 0, totuds = 0, totccbar = 0, totdata = 0, totOffdata = 0;
  getNumberB(NameTrees[0], "All", totMCB, totdata, totuds, totccbar, totOffdata);
  double wuds = totMCB/totuds*2.09/1.05;     

  TH1F *hCount = new TH1F("hCount","",100,-4,12);
  gen.Draw("candM2>>hCount","weight");
  double nTotal = hCount->Integral();
  cont.Draw("candM2>>hCount","weight");
  nTotal += hCount->Integral()*wuds;

  TLine line; line.SetLineStyle(2); line.SetLineColor(28); line.SetLineWidth(2);
  TArrow arrow; arrow.SetLineColor(28); arrow.SetFillColor(28); arrow.SetLineWidth(2);
  TCanvas can("can","Pmiss and q2 cuts");
  can.Divide(2,1); TPad *cPad = (TPad *)can.cd(1);
  int bins[] = {42,40}, colors[2][4] = {{8,4,1,3},{8,2,4,1}};
  double xrange[2][2] = {{0,4.2},{-3,13}}, yield[2][4], maxi[] = {-99,-99};
  TString Variable[] = {"candPMiss","candQ2"};
  TString labels[2][4] = {{"Signal (", "Normaliz. (","Had. bkg. (",""},
 			  {"Signal (", "D l #nu (", "D* l #nu (", "Bkg. ("}};
//   TString labels[2][4] = {{"Signal", "Normaliz.","Had. Bkg.",""},
// 			  {"Signal", "D l #nu", "D* l #nu", "Bkg."}};
  TString cuts[2][4] = {{"(candType<3&&MCType>4&&MCType<7||candType>2&&MCType>10&&MCType<13)*weight",
			 "(candType<3&&MCType>0&&MCType<5||candType>2&&MCType>6&&MCType<11)*weight",
			 "(MCType==0&&MCCombmode==12)*weight", ""},
			{"(candType<3&&MCType>4&&MCType<7||candType>2&&MCType>10&&MCType<13)*weight",
			 "(candType<3&&(MCType==1||MCType==3)||candType>2&&(MCType==7||MCType==9))*weight",
			 "(candType<3&&(MCType==2||MCType==4)||candType>2&&(MCType==8||MCType==10))*weight",
			 "(!(candType<3&&MCType>0&&MCType<7||candType>2&&MCType>6&&MCType<13))*weight"}};
  double legW = 0.4, legH = 0.225;
  double legX = 1-style2.PadRightMargin-0.02, legY = 1-style2.PadTopMargin-0.02;
  TLegend *leg[2];
  leg[0] = new TLegend(legX-legW, legY-legH, legX, legY);
  legW = 0.24; legH = 0.285; legX = 0.47;
  leg[1] = new TLegend(legX-legW, legY-legH, legX, legY);
  TH1F* h[2][4];
  for(int pad=0; pad<2; pad++){
    leg[pad]->SetTextSize(style2.LabelSize); leg[pad]->SetFillColor(0); 
    leg[pad]->SetTextFont(style2.nFont);  leg[pad]->SetBorderSize(0);
    for(int i=0; i<4; i++) {
      if(pad==0 && i==3) continue;
      TString hname = "h"; hname += pad; hname += i;
      h[pad][i] = new TH1F(hname,"",bins[pad],xrange[pad][0],xrange[pad][1]);
      h[pad][i]->SetLineWidth(2);  h[pad][i]->SetLineColor(colors[pad][i]);
      TString vari = Variable[pad]; vari += ">>"; vari += hname;
      gen.Draw(vari,cuts[pad][i]);
      if(i==3){
	hname = "hCont"; hname += pad; hname += i;
	TH1F *hCont = new TH1F(hname,"",bins[pad],xrange[pad][0],xrange[pad][1]);
	TString vari = Variable[pad]; vari += ">>"; vari += hname;
	cont.Draw(vari,cuts[pad][i]);
	hCont->Scale(wuds);
	h[pad][i]->Add(hCont);
	hCont->Delete();
      }
      yield[pad][i] = h[pad][i]->Integral();
      h[pad][i]->Scale(1000/h[pad][i]->Integral());
      if(h[pad][i]->GetMaximum()>maxi[pad]) maxi[pad] = h[pad][i]->GetMaximum();
      labels[pad][i] += RoundNumber(yield[pad][i]*100,0,nTotal); labels[pad][i] += "%)";
      leg[pad]->AddEntry(h[pad][i],labels[pad][i]);
    }
    h[pad][0]->SetMaximum(maxi[pad]*1.22);
  }
  h[0][0]->Draw();
  style2.fixYAxis(h[0][0],cPad);
  style2.setTitles(h[0][0],"|p_{miss}| (GeV)","Entries/(100 MeV)","a)");
  h[0][1]->Draw("same");h[0][2]->Draw("same");
  leg[0]->Draw();
  line.DrawLine(0.2,h[0][0]->GetMinimum(), 0.2,maxi[0]/1.45);
  arrow.DrawArrow(0.2,maxi[0]/1.65,0.5,maxi[0]/1.65,0.01,"|>");


  cPad = (TPad *)can.cd(2);
  h[1][0]->Draw();
  style2.fixYAxis(h[1][0],cPad);
  style2.setTitles(h[1][0],"q^{2} (GeV^{2})","Entries/(0.4 GeV^{2})","b)");
  h[1][1]->Draw("same"); h[1][2]->Draw("same"); h[1][3]->Draw("same");
  leg[1]->Draw();
  line.DrawLine(4,h[1][0]->GetMinimum(), 4,maxi[1]/1.45);
  arrow.DrawArrow(4,maxi[1]/1.65,5.4,maxi[1]/1.65,0.01,"|>");

  TString pName = "public_html/EvtSel_Q2Pmiss.eps"; 
  can.SaveAs(pName);
  for(int pad=0; pad<2; pad++){
    leg[pad]->Delete();
    for(int i=0; i<4; i++){
      if(pad==0 && i==3) continue;
      h[pad][i]->Delete();
    }
  }
  hCount->Delete();
}