当前位置: 首页>>代码示例>>C++>>正文


C++ TLegend::Draw方法代码示例

本文整理汇总了C++中TLegend::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ TLegend::Draw方法的具体用法?C++ TLegend::Draw怎么用?C++ TLegend::Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TLegend的用法示例。


在下文中一共展示了TLegend::Draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: analyzer_stack


//.........这里部分代码省略.........
        else out_efficiency<<leg_names[files]<<"&\t  "<<histos[4]->Integral()*1000. <<"&\t"<< histos[4]->Integral()/xsec[files] <<endl;
        if (files==nfiles-1) out_efficiency<<"Total BG"<<"&\t \t \t  "<<totalBG*1000.<< endl;
        files++;
    } while (files<nfiles);
    out_efficiency.close();

    for (int d=0; d<nhistos; d++) {
        discriminators[d] = Discr(discr_histos[d],signal_histos[d]);
    }

    bubblesort(discriminators, hist_names_sort,nhistos);

    out_discrimination.open(trigger+dir_name+"discrimination.txt");
    for (int d=0; d<nhistos; d++) {
        if (d==0) out_discrimination<<"Variable &\t d"<<endl;
        out_discrimination<<"$"<<hist_names_sort[d]<<"$"<<" & \t "<< std::setprecision(2)<< discriminators[d]<<endl;
    }
    out_discrimination.close();
    TLatex* tex = new TLatex(0.90,0.92,"13 TeV, PU = 20, bx = 25 ns, 1 pb^{-1}");
    tex->SetNDC();
    tex->SetTextAlign(35);
    tex->SetTextFont(42);
    tex->SetTextSize(0.04);
    tex->SetLineWidth(2);
    TLatex *tex1 = new TLatex(0.13,0.83,"CMS");
    tex1->SetNDC();
    tex1->SetTextAlign(20);
    tex1->SetTextFont(61);
    tex1->SetTextSize(0.06);
    tex1->SetLineWidth(2);
    TLatex* tex2 = new TLatex(0.22,0.77,"Work in progress");
    tex2->SetNDC();
    tex2->SetTextAlign(20);
    tex2->SetTextFont(52);
    tex2->SetTextSize(0.04);
    tex2->SetLineWidth(2);
    TLatex* tex_file = new TLatex(0.35,0.92,"Spring15, DoubleBtag");
    //	TLatex* tex_file = new TLatex(0.35,0.92,"Spring15, SingleBtag");
    tex_file->SetNDC();
    tex_file->SetTextAlign(35);
    tex_file->SetTextFont(42);
    tex_file->SetTextSize(0.04);
    tex_file->SetLineWidth(2);
    for (int i=0; i<nhistos; i++) {
        TString temp_str;
        temp_str.Form("%2.2f",Discr(discr_histos[i],signal_histos[i]));
        TString disc_value = temp_str.Prepend(", d = ");
        TLatex *disc_value_text = new TLatex(0.86,0.853,disc_value);
        disc_value_text->SetNDC();
        disc_value_text->SetTextAlign(35);
        disc_value_text->SetTextFont(42);
        disc_value_text->SetTextSize(0.04);
        disc_value_text->SetLineWidth(2);

        TCanvas *c1 = new TCanvas();
        c1->SetBottomMargin(.12);
        c1->cd();
        c1->SetLogy();
        Double_t xmin = signal_histos[i]->GetBinCenter(0);
        Double_t xmax = signal_histos[i]->GetBinCenter(signal_histos[i]->GetNbinsX());
        TH1F *frame = new TH1F("frame","",1,xmin,xmax);
        frame->SetMinimum(1e-4);
        frame->SetMaximum(1e10);
        frame->GetYaxis()->SetTitleOffset(0.9);
        frame->GetXaxis()->SetTitleOffset(0.91);
        frame->SetStats(0);
        frame->SetTitleFont(42,"x");
        frame->SetTitleFont(42,"y");
        frame->SetTitleSize(0.05, "XYZ");
        frame->SetXTitle(signal_histos[i]->GetXaxis()->GetTitle());

        if ((i<4))frame->SetYTitle("Events  /  20 GeV");
        else if (i==37)frame->SetYTitle("Events  /  20 GeV");
        else if (i==41)frame->SetYTitle("Events  /  20 GeV");
        else if ((i>=4) && (i<8)) frame->SetYTitle("Events  /  0.5");
        else if (i==15) frame->SetYTitle("Events  /  0.5");
        else if ((i>=8) && (i<12)) frame->SetYTitle("Events  /  0.2");
        else if (i==40) frame->SetYTitle("Events / 100 GeV");
        else if ((i==10)||(i==12)||(i==16)||(i==17)||(i==18) || (i==20) || (i==25) || (i==26) || (i==27) || (i==35) || (i==36) ||(i==38) || (i==39)) frame->SetYTitle("Events / 10 GeV");
        else if ((i==13)||(i==14)) frame->SetYTitle("Events / 0.1");
        else if ((i==21)||(i==22)) frame->SetYTitle("Events / 0.05");
        else if ((i==23)||(i==24)) frame->SetYTitle("Events / 0.01");
        else if (i==28) frame->SetYTitle("Events / 0.02");
        else if ((i==29) || (i==30) || (i==31) || (i==32) )frame->SetYTitle("Events / 0.1");
        else if ((i==33) || (i==33))frame->SetYTitle("Events / 0.01");
        else frame->SetYTitle("Events");
        frame->Draw();
        tex->Draw();
        tex1->Draw();
        tex2->Draw();
        tex_file->Draw();
        stacks[i]->Draw("nostacksame");
        leg->Draw("same");
        signal_histos[i]->Draw("same");
        disc_value_text->Draw();
        c1->Print(output_names[i]);
        c1->Delete();
    }

}
开发者ID:chernyavskaya,项目名称:Hbb,代码行数:101,代码来源:analyzer_stack.C

示例2: bcal_hist_eff_summary


//.........这里部分代码省略.........
    
   }

      in->Close();
   
   }   // end loop over histogram files

   //
   TCanvas *c1 = new TCanvas("c1","c1 bcal_hist_eff_summary ",200,10,700,700);
   c1->SetBorderMode(0);
   c1->SetFillColor(0);

   c1->SetGridx();
   c1->SetGridy();
   c1->SetBorderMode(0);
   c1->SetFillColor(0);

  TLegend *leg = new TLegend(0.6,0.8,0.85,0.95);
  leg->AddEntry(hsummary_layer1,"Layer 1","p");
  leg->AddEntry(hsummary_layer2,"Layer 2","p");
  leg->AddEntry(hsummary_layer3,"Layer 3","p");
  leg->AddEntry(hsummary_layer4,"Layer 4","p");

   hsummary_layer1->SetTitle("");
   //hsummary_layer1->GetXaxis()->SetRangeUser(xmin,xmax);
   hsummary_layer1->GetYaxis()->SetRangeUser(ymin,ymax);
   hsummary_layer1->GetXaxis()->SetTitleSize(0.05);
   hsummary_layer1->GetYaxis()->SetTitleSize(0.05);
   hsummary_layer1->GetXaxis()->SetTitle("File Number");
   hsummary_layer1->GetYaxis()->SetTitle("Efficiency Clusters");
   hsummary_layer1->SetLineColor(2);
   hsummary_layer1->SetMarkerColor(2);
   hsummary_layer1->SetMarkerStyle(20);
   hsummary_layer1->Draw("p");

   hsummary_layer2->SetLineColor(4);
   hsummary_layer2->SetMarkerColor(4);
   hsummary_layer2->SetMarkerStyle(20);
   hsummary_layer2->Draw("samep");

   hsummary_layer3->SetLineColor(1);
   hsummary_layer3->SetMarkerColor(1);
   hsummary_layer3->SetMarkerStyle(20);
   hsummary_layer3->Draw("samep");

   hsummary_layer4->SetLineColor(3);
   hsummary_layer4->SetMarkerColor(3);
   hsummary_layer4->SetMarkerStyle(20);
   hsummary_layer4->Draw("samep");

   sprintf(string,"hd_rawdata_002179");
   printf ("Histogram input filename=%s\n",string);
   TLatex *t1 = new TLatex(0.15,0.92,string);
   t1->SetNDC();
   t1->SetTextSize(0.03);
   t1->Draw();

  leg->Draw();

   //
   TCanvas *c2 = new TCanvas("c2","c2 bcal_hist_eff_summary ",200,10,700,700);
   c2->SetBorderMode(0);
   c2->SetFillColor(0);

   c2->SetGridx();
   c2->SetGridy();
开发者ID:JeffersonLab,项目名称:sim-recon,代码行数:67,代码来源:bcal_hist_eff_summary.C

示例3: compare_ATLAS_pp_fitBoth

void compare_ATLAS_pp_fitBoth(Int_t nfit=6, Int_t FitStart=50, Int_t FitEnd=450) {

//=========Macro generated from canvas: cATLAS_pp/
//=========  (Wed Jul 22 23:01:26 2015) by ROOT version5.32/00
    TCanvas *cATLAS_pp = new TCanvas("cATLAS_pp", "",0,0,1200,1000);
    TH1::SetDefaultSumw2();
    gStyle->SetOptFit(1);
    gStyle->SetOptStat(0);
    cATLAS_pp->Range(-3.725291e-06,-5.878322,500,3.279288);
    cATLAS_pp->SetFillColor(0);
    cATLAS_pp->SetBorderMode(0);
    cATLAS_pp->SetBorderSize(2);
    cATLAS_pp->SetLogy();
    cATLAS_pp->SetFrameBorderMode(0);
    cATLAS_pp->SetFrameBorderMode(0);
    TF1 *fitppATLAS = new TF1("fitppATLAS","[0]*pow(x+[2],[1])"); //create function
    fitppATLAS->SetParameters(1e10,-5,0);
    fitppATLAS->SetLineColor(kRed);
    TF1 *fitppCMS = new TF1("fitppCMS","[0]*pow(x+[2],[1])"); //create function
    fitppCMS->SetParameters(1e10,-5,0);
    fitppCMS->SetLineColor(kBlue);

    TGraphAsymmErrors *grae = new TGraphAsymmErrors(12);
    grae->SetName("/HepData/8719/d2x1y1");
    grae->SetTitle(" ");
    grae->SetFillColor(1);
    grae->SetMarkerStyle(33);
    grae->SetPoint(0,35,180);
    grae->SetPointError(0,4,4,29.95905,29.95905);
    grae->SetPoint(1,44.5,55.7);
    grae->SetPointError(1,5.5,5.5,7.828377,7.828377);
    grae->SetPoint(2,56.5,16.9);
    grae->SetPointError(2,6.5,6.5,2.625436,2.625436);
    grae->SetPoint(3,71,4.85);
    grae->SetPointError(3,8,8,0.6276957,0.6276957);
    grae->SetPoint(4,89.5,1.42);
    grae->SetPointError(4,10.5,10.5,0.1878054,0.1878054);
    grae->SetPoint(5,112.5,0.364);
    grae->SetPointError(5,12.5,12.5,0.04772427,0.04772427);
    grae->SetPoint(6,141.5,0.0882);
    grae->SetPointError(6,16.5,16.5,0.01103805,0.01103805);
    grae->SetPoint(7,178.5,0.0197);
    grae->SetPointError(7,20.5,20.5,0.002292152,0.002292152);
    grae->SetPoint(8,225,0.00406);
    grae->SetPointError(8,26,26,0.0004822521,0.0004822521);
    grae->SetPoint(9,283.5,0.000735);
    grae->SetPointError(9,32.5,32.5,8.981748e-05,8.981748e-05);
    grae->SetPoint(10,357,0.000114);
    grae->SetPointError(10,41,41,1.442494e-05,1.442494e-05);
    grae->SetPoint(11,449.5,1.41e-05);
    grae->SetPointError(11,51.5,51.5,1.98855e-06,1.98855e-06);

    TH1F *hATLASpp = new TH1F("hATLASpp"," ",100,50,450);
    hATLASpp->SetMinimum(1.090031e-05);
    hATLASpp->SetMaximum(230.955);
    hATLASpp->SetDirectory(0);
    hATLASpp->SetStats(0);

    Int_t ci;   // for color index setting
    ci = TColor::GetColor("#000099");
    hATLASpp->SetLineColor(ci);
    hATLASpp->GetXaxis()->SetTitle("ak R=0.4 Jet p_{T} (GeV/c)");
    hATLASpp->GetXaxis()->SetLabelFont(42);
    hATLASpp->GetXaxis()->SetLabelSize(0.035);
    hATLASpp->GetXaxis()->SetTitleSize(0.035);
    hATLASpp->GetXaxis()->SetTitleFont(42);
    hATLASpp->GetYaxis()->SetTitle("#frac{d^{2}#sigma}{dp_{T} d#eta} nb");
    hATLASpp->GetYaxis()->SetLabelFont(42);
    hATLASpp->GetYaxis()->SetLabelSize(0.035);
    hATLASpp->GetYaxis()->SetTitleSize(0.035);
    hATLASpp->GetYaxis()->SetTitleFont(42);
    hATLASpp->GetZaxis()->SetLabelFont(42);
    hATLASpp->GetZaxis()->SetLabelSize(0.035);
    hATLASpp->GetZaxis()->SetTitleSize(0.035);
    hATLASpp->GetZaxis()->SetTitleFont(42);
    grae->SetHistogram(hATLASpp);
    hATLASpp->Draw();
    grae->Draw("ap,same");

    for(int i=0; i<nfit; ++i) {
        grae->Fit("fitppATLAS","I","",FitStart,FitEnd); //fit function
    }

    Double_t xAxis2086[101] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800, 810, 820, 830, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940, 950, 960, 970, 980, 990, 1000};

    TH1F *uPP_R4_SVD = new TH1F("uPP_R4_SVD","Unfold Matrix refpt jtpt from trigger addition R4 20_eta_20 ",100, xAxis2086);
    uPP_R4_SVD->SetBinContent(1,15.44572);
    uPP_R4_SVD->SetBinContent(2,81.73347);
    uPP_R4_SVD->SetBinContent(3,85.49986);
    uPP_R4_SVD->SetBinContent(4,90.07588);
    uPP_R4_SVD->SetBinContent(5,47.67952);
    uPP_R4_SVD->SetBinContent(6,18.31659);
    uPP_R4_SVD->SetBinContent(7,7.348095);
    uPP_R4_SVD->SetBinContent(8,3.295203);
    uPP_R4_SVD->SetBinContent(9,1.60486);
    uPP_R4_SVD->SetBinContent(10,0.8393627);
    uPP_R4_SVD->SetBinContent(11,0.4622419);
    uPP_R4_SVD->SetBinContent(12,0.265131);
    uPP_R4_SVD->SetBinContent(13,0.1587068);
    uPP_R4_SVD->SetBinContent(14,0.09774788);
//.........这里部分代码省略.........
开发者ID:rkunnawa,项目名称:usercode-2,代码行数:101,代码来源:compare_ATLAS_pp_fitBoth.C

示例4: studyTemplate

void studyTemplate(const TString conf="sample.conf") {

  const Int_t nSamples=3;

  vector<TString> sampleNames;
  vector<TString> sampleTitles;
  vector<Int_t> sampleColors;

  confParse(conf, sampleNames, sampleTitles, sampleColors);

  TH1D *hSample[nSamples];

  char hname[100];

  for(UInt_t iSamp=0; iSamp<nSamples; iSamp++) {

    sprintf(hname, "hSample_%s", sampleTitles[iSamp].Data()); hSample[iSamp]= new TH1D(hname, "", 4, 0, 4);

  }

  UInt_t eventNum;
  UInt_t bTag1, bTag2;
  UInt_t tauDecayCat1, tauDecayCat2;
  LorentzVector *genB1=0, *genB2=0, *recoB1=0, *recoB2=0;
  LorentzVector *genTau1=0, *genTau2=0, *genDecayTau1=0, *genDecayTau2=0, *recoTau1=0, *recoTau2=0;

  TFile *infile;
  TTree *intree;

  for (UInt_t iSamp=0; iSamp<nSamples; iSamp++) { // sample loop

    TString infilename = sampleNames[iSamp];
    cout << "Processing  " << infilename << " ..." << endl;
    infile = new TFile(infilename); assert(infile);
    intree = (TTree*) infile->Get("Events"); assert(intree);
 
    intree->SetBranchAddress("eventNum",       &eventNum);
    intree->SetBranchAddress("bTag1",          &bTag1);
    intree->SetBranchAddress("bTag2",          &bTag2);
    intree->SetBranchAddress("genB1",          &genB1);
    intree->SetBranchAddress("genB2",          &genB2);
    intree->SetBranchAddress("recoB1",         &recoB1);
    intree->SetBranchAddress("recoB2",         &recoB2);
    intree->SetBranchAddress("tauDecayCat1",   &tauDecayCat1);
    intree->SetBranchAddress("tauDecayCat2",   &tauDecayCat2);
    intree->SetBranchAddress("genTau1",        &genTau1);
    intree->SetBranchAddress("genTau2",        &genTau2);
    intree->SetBranchAddress("genDecayTau1",   &genDecayTau1);
    intree->SetBranchAddress("genDecayTau2",   &genDecayTau2);
    intree->SetBranchAddress("recoTau1",       &recoTau1);
    intree->SetBranchAddress("recoTau2",       &recoTau2);

    for(UInt_t iEntry=0; iEntry<intree->GetEntries(); iEntry++) { // entry loop
      intree->GetEntry(iEntry);

      hSample[iSamp]->Fill(tauDecayCat1);

    } // end entry loop
    delete infile;
    infile=0, intree=0;

  } // end sample loop

  char pname[100];
  char xlabel[100];
  char ylabel[100];
  
  TCanvas *c = new TCanvas("c", "c", 800, 600);
  TLegend *leg = new TLegend(0.6, 0.7, 0.9, 0.9);
  leg->SetShadowColor(0);
  leg->SetFillColor(0);

  for (UInt_t iSamp=0; iSamp<nSamples; iSamp++) {

    sprintf(xlabel, "Tau Decay Cat");
    sprintf(ylabel, "Events");
    sprintf(pname, "taudecay_%s", sampleTitles[iSamp].Data());
    hSample[iSamp]->SetLineColor(sampleColors[iSamp]);
    leg->AddEntry(hSample[iSamp], sampleTitles[iSamp],"l");

    if (iSamp==0) {
      hSample[iSamp]->GetXaxis()->SetTitle(xlabel);
      hSample[iSamp]->GetYaxis()->SetTitle(ylabel);
      hSample[iSamp]->Draw();
    }
    else {
      if (hSample[iSamp]->GetMaximum() > hSample[0]->GetMaximum()) hSample[0]->GetYaxis()->SetRangeUser(0,hSample[iSamp]->GetMaximum()*1.2);
      hSample[iSamp]->Draw("same");
    }
  }
  leg->Draw();
}
开发者ID:jaylawhorn,项目名称:delphes-dihiggs,代码行数:92,代码来源:studyTemplate.C

示例5: plotTreeNorms

void plotTreeNorms(TTree *tree_, std::string selectString, bool do7TeV){

	// Create a map for plotting the pullsummaries:
	std::map < const char*, std::pair <double,double> > pullSummaryMap;
	int nPulls=0;

	TObjArray *l_branches = tree_->GetListOfBranches();
	int nBranches = l_branches->GetEntries();

	gStyle->SetPadTopMargin(0.01);

	TCanvas *c = new TCanvas("c","",960,800);

	std::string treename = tree_->GetName();
	c->SaveAs(Form("%s_normresiduals.pdf[",treename.c_str()));
	// File to store plots in 
	TFile *fOut = new TFile(Form("%s_normresiduals.root",treename.c_str()),"RECREATE");

        TH1F *bHd = new TH1F("bHd","",50,-1.0,1.0);
        TH1F *bHfd = new TH1F("bHfd","",50,-1.0,1.0);

	for (int iobj=0;iobj<nBranches;iobj++){

		TBranch *br =(TBranch*) l_branches->At(iobj);

		// Draw the normal histogram
		const char* name = br->GetName();

                // select only the normalizations
                string namestr(name);
                if(namestr.find("n_exp")==string::npos) continue;

                bool fitPull=true;
                bool fitPullf=true;

		double p_mean =0;

		int nToysInTree = tree_->GetEntries();
		// Find out if paramter is fitted value or constraint term.
                bool isFitted = true;
			
                p_mean = prenorms_[name].first;	// toy initial parameters from the datacards
                std::cout << "******* "<< name << " *******"<<std::endl;
                std::cout << p_mean << std::endl;
                std::cout << "******************************" <<std::endl;

                TH1F* bH = (TH1F*)bHd->Clone(Form("%s",name));
                TH1F* bHf = (TH1F*)bHfd->Clone(Form("%s_fail",name));
                
                const char* drawInput = Form("(%s-%f)/%f",name,p_mean,p_mean);
                tree_->Draw(Form("%s>>%s",drawInput,name),"");
                tree_->Draw(Form("%s>>%s_fail",drawInput,name),selectString.c_str(),"same");
                fitPull  = true;
                fitPullf = true;
                  
		bHf->SetLineColor(2);
		bH->GetXaxis()->SetTitle(bH->GetTitle());
		bH->GetYaxis()->SetTitle(Form("no toys (%d total)",nToysInTree));
		bH->GetYaxis()->SetTitleOffset(1.05);
		bH->GetXaxis()->SetTitleOffset(0.9);
		bH->GetYaxis()->SetTitleSize(0.05);
		bH->GetXaxis()->SetTitleSize(0.05);
		bH->GetXaxis()->SetTitle(Form("%s",name));
                
		
		bH->SetTitle("");	

		if ( bH->Integral() <=0 )  fitPull = false;
		if (fitPull) {bH->Fit("gaus"); bH->GetFunction("gaus")->SetLineColor(4);}
		
		if ( bHf->Integral() <=0 )  fitPullf = false;
		if (fitPullf) {bHf->Fit("gaus"); bHf->GetFunction("gaus")->SetLineColor(2);}

		c->Clear();
		
 		TPad pad1("t1","",0.01,0.01,0.66,0.95);
 		TPad pad2("t2","",0.70,0.20,0.98,0.80);

		pad1.SetNumber(1); pad2.SetNumber(2);

                if ( isFitted ) {pad2.Draw();}

		pad1.Draw();
		pad1.SetGrid(true);


		TLatex *titletext = new TLatex();titletext->SetNDC();

		
		c->cd(1); bH->Draw(); bHf->Draw("same");
		TLegend *legend = new TLegend(0.6,0.8,0.9,0.89);
		legend->SetFillColor(0);
		legend->AddEntry(bH,"All Toys","L");
		legend->AddEntry(bHf,selectString.c_str(),"L");
		legend->Draw();

		if (fitPull){
			c->cd(2);
			double gap;
			TLatex *tlatex = new TLatex(); tlatex->SetNDC(); 
//.........这里部分代码省略.........
开发者ID:VecbosApp,项目名称:HiggsAnalysisTools,代码行数:101,代码来源:plotParametersFromToys.C

示例6: SimplePlots

void SimplePlots(TString Cut="2btag", TString Channel="mujets"){
  gROOT->SetStyle("Plain");
  gStyle->SetOptStat(kFALSE);

  const int nh = 3;
  //TString namefile = "TopResults/hSF-EffCSVFull_Tree_LepJets_GenCone_v8-0-0_Spring16-80X_5913pb-1_ttbar_PowhegPythia";
  TString namefile = "TopResults/hSF-NuiPar-v0_Tree_LepJets_KFCSVOrder01NoSkim_v8-0-1_Spring16-80X_15920pb-1_ttbar_LepJetsPowhegPythiaTranche3FullPhSp";

  TFile *hFile=NULL;
  hFile = TFile::Open(namefile + ".root");

  if(!hFile){
    std::cerr << "ERROR: Could not open " <<  namefile  << " files!!!"  << std::endl;
    std::exit(0);
  }

  TH1F *histo[nh];
  // TEfficiency *histo[nh];
  TString histoname[nh] = {"hTJetPosition","hWJetPosition","hOJetPosition"};

  cout << "Loading: " << Cut + "/" + Channel + "/" + histoname[0] + "_" + Channel + "_" + Cut << endl;

  histo[0] = (TH1F*)hFile->Get(Cut + "/" + Channel + "/" + histoname[0] + "_" + Channel + "_" + Cut );
  histo[1] = (TH1F*)hFile->Get(Cut + "/" + Channel + "/" + histoname[1] + "_" + Channel + "_" + Cut );
  histo[2] = (TH1F*)hFile->Get(Cut + "/" + Channel + "/" + histoname[2] + "_" + Channel + "_" + Cut );
  //histo[0] = (TEfficiency*)hFile->Get(Cut + "/" + Channel + "/" + histoname[0] + "_" + Channel + "_" + Cut ) ->Clone(histoname[0] + Channel + Cut);

  TCanvas *histocanvas;
  histocanvas = new TCanvas("plots", "Plots");

  histocanvas->SetGrid();
  histocanvas->cd();

  for (int ih=0; ih<3; ih++){
    float Nhisto = histo[ih]->Integral();
    if(Nhisto!=0.0) histo[ih]->Scale(1.0/Nhisto);
  }
  histo[0]->SetTitle("CSV Jet Positions");
  histo[0]->SetMarkerStyle(20);
  histo[0]->SetMarkerColor(4);
  histo[0]->SetLineColor(4);
  histo[0]->Draw();

  histo[1]->SetMarkerStyle(21);
  histo[1]->SetMarkerColor(2);
  histo[1]->SetLineColor(2);
  histo[1]->Draw("SAME");

  histo[2]->SetMarkerStyle(22);
  histo[2]->SetMarkerColor(kGreen-2);
  histo[2]->SetLineColor(kGreen-2);
  histo[2]->Draw("SAME");

  TLegend *leg;
  leg = new TLegend(0.70, 0.64,
		     0.93, 0.87);
  leg->AddEntry(histo[0],"Jets From Top",   "LP");
  leg->AddEntry(histo[1],"Jets From W",     "LP");
  leg->AddEntry(histo[2],"Additional Jets", "LP");
  leg->Draw("SAME");

  histocanvas->SaveAs(TString(histo[0]->GetName()) + ".pdf");

}
开发者ID:brochero,项目名称:LepJetsAnalyzer,代码行数:64,代码来源:SimplePlots.C

示例7: DrawBoosted

void DrawBoosted(TString VAR, float XMIN, float XMAX, int REBIN, TString XTITLE)
{
  gROOT->ForceStyle();
  const int N = 7;
  float XSEC[N] = {1.74e+6,3.67e+5,2.94e+4,6.524e+03,1.064e+03,121.5,2.542e+01};

  TString SAMPLE[N] = {
    "QCD_HT200to300",
    "QCD_HT300to500",
    "QCD_HT500to700", 
    "QCD_HT700to1000",
    "QCD_HT1000to1500",
    "QCD_HT1500to2000",
    "QCD_HT2000toInf" 
  };
 
  TFile *inf[N];
  TH1F  *h0[N],*h1[N];
  TH1F  *hQCD0,*hQCD1; 

  TCanvas *can = new TCanvas("Boosted","Boosted",900,600);
  can->cd(1);
  can->SetBottomMargin(0.3);
  //can->SetRightMargin(0.15);
  for(int k=0;k<N;k++) {
    inf[k] = TFile::Open("Histo_"+SAMPLE[k]+".root");
    h0[k]  = (TH1F*)inf[k]->Get("hadtopBoost/h_"+VAR+"_Cut_ctl");
    h0[k]->Sumw2();
    h0[k]->Rebin(REBIN);
    h1[k]  = (TH1F*)inf[k]->Get("hadtopBoost/h_"+VAR+"_Cut_sig");
    h1[k]->Sumw2();
    h1[k]->Rebin(REBIN);
    h0[k]->Scale(XSEC[k]/((TH1F*)inf[k]->Get("hadtopBoost/TriggerPass"))->GetBinContent(1));
    h1[k]->Scale(XSEC[k]/((TH1F*)inf[k]->Get("hadtopBoost/TriggerPass"))->GetBinContent(1)); 
    cout<<SAMPLE[k]<<": "<<h0[k]->GetEntries()<<" "<<h0[k]->Integral()<<endl;
    if (k == 0) {
      hQCD0 = (TH1F*)h0[k]->Clone();
      hQCD1 = (TH1F*)h1[k]->Clone();
    }
    if (k > 0) {
      hQCD0->Add(h0[k]);
      hQCD1->Add(h1[k]);
    }
  } 
  hQCD0->Scale(1/hQCD0->Integral());
  hQCD1->Scale(1/hQCD1->Integral());
  double max1 = TMath::Max(hQCD0->GetBinContent(hQCD0->GetMaximumBin()),hQCD1->GetBinContent(hQCD1->GetMaximumBin()));
  hQCD0->SetMaximum(1.2*max1);
  hQCD0->SetMinimum(1e-4);
  hQCD0->GetXaxis()->SetLabelSize(0.0);
  hQCD0->GetXaxis()->SetRangeUser(XMIN,XMAX); 
  hQCD0->Draw("HIST");
  hQCD1->Draw("sameE");

  TLegend *leg = new TLegend(0.6,0.7,0.9,0.9);
  leg->SetHeader("QCD Closure");
  leg->SetBorderSize(0);
  leg->SetTextFont(42);
  leg->SetTextSize(0.05);
  leg->AddEntry(hQCD1,"Signal sample","P");
  leg->AddEntry(hQCD0,"Control sample","F");
  leg->Draw();

  TH1F *hRatio = (TH1F*)hQCD1->Clone("Ratio");
  hRatio->Divide(hQCD0);

  hRatio->SetLineColor(kBlack);
  hRatio->SetMarkerColor(kBlack);

  TPad* pad = new TPad("pad", "pad", 0., 0., 1., 1.);
  pad->SetTopMargin(0.7);
  //pad->SetRightMargin(0.15);
  pad->SetFillColor(0);
  pad->SetFillStyle(0);
  pad->Draw();
  pad->cd(0);
  gPad->SetGridy();
  hRatio->GetXaxis()->SetTitle(XTITLE);
  hRatio->GetXaxis()->SetRangeUser(XMIN,XMAX); 
  hRatio->GetYaxis()->SetNdivisions(505);
  hRatio->GetYaxis()->SetRangeUser(0,2);
  hRatio->GetYaxis()->SetLabelSize(0.04);
  hRatio->Draw();
  hRatio->Draw("same");
}
开发者ID:isildakbora,项目名称:UserCode,代码行数:85,代码来源:DrawBoosted.C

示例8: plotvn

void plotvn(){
    gStyle->SetOptStat(kFALSE);
    int icent = 0;
    int n = 3;
    int color[6] = {1,2,4,7,8,5};
    int style[12] = {20,21,24,25,26,27,29,30,31,32,33,34};
    TGraphErrors *gr[nsub][3][2];
    TGraphErrors *grraw[nsub][3][2];
    TString CNTEP, dire;
    for(int isub=0;isub<nsub;isub++){
    for(int idire=0;idire<3;idire++){
    for(int iCNTEP=0;iCNTEP<1;iCNTEP++){
        if(iCNTEP==0) CNTEP = "NoUseCNTEP";
        if(iCNTEP==1) CNTEP = "UseCNTEP";
        if(idire==0) dire = "";
        if(idire==1) dire = "_east";
        if(idire==2) dire = "_west";
        TString str = choosesub(isub);
        if(str=="ABORT") continue;
        gr[isub][idire][iCNTEP] = new TGraphErrors(Form("Result/%s/v%d_00_%d%s_%s.dat",CNTEP.Data(),n,icent,dire.Data(),str.Data()),"%lg %lg %lg");
        grraw[isub][idire][iCNTEP] = new TGraphErrors(Form("Result/%s/v%draw_00_%d%s_%s.dat",CNTEP.Data(),n,icent,dire.Data(),str.Data()),"%lg %lg %lg");
        SetStyle(*gr[isub][idire][iCNTEP], 1.2, color[idire+3*iCNTEP],style[isub]);
        SetStyle(*grraw[isub][idire][iCNTEP], 1.2, color[idire+3*iCNTEP],style[isub]);
    }
    }
    }
TH1F* h = new TH1F("h","",50,0,5);
h->GetXaxis()->SetRangeUser(0,3.2);
/*
TCanvas *c1 = new TCanvas("c1","c1",800,450);
iCNTEP = 0;
idire = 0;
c1->Divide(2);
c1->cd(1);
h->SetMinimum(0);
h->SetMaximum(0.3);
h->GetXaxis()->SetRangeUser(0,3.2);
//SetTitle(h,"","p_{T}","v_{2}^{raw}");
SetTitle(h,"","p_{T}","v_{2}");
h->DrawCopy();
TLegend *leg = new TLegend(0.2,0.7,0.5,0.9);
leg->SetFillColor(0);
leg->SetBorderSize(0);
for(int ilay = 0;ilay<4;ilay++){
leg->AddEntry(gr[ilay+8][idire][iCNTEP],Form("FVTX layer %d",ilay));
gr[ilay+8][idire][iCNTEP]->Draw("Psame");
}
gr[6][0][1]->Draw("Psame");
leg->AddEntry(gr[6][idire][iCNTEP],Form("FVTX -3.0<#eta<-1.0"));
leg->Draw("Psame");

c1->cd(2);
h->SetMinimum(0.8);
h->SetMaximum(1.2);
SetTitle(h,"","p_{T}","v_{2} ratio");
h->DrawCopy();
for(int ilay = 0;ilay<4;ilay++){
TGraphErrors *grr = (TGraphErrors*)DivideTwoGraphs(gr[ilay+8][idire][iCNTEP],gr[6][idire][iCNTEP]);
SetStyle(*grr,1.2,color[idire+3*iCNTEP],style[ilay+8]);
grr->Draw("Psame");
}
*/
TCanvas *c2 = new TCanvas("c2","c2",450,450);
iCNTEP = 0;
idire = 0;
//c2->Divide(2);
c2->cd(1);
if(n==1){
h->SetMinimum(-0.05);
h->SetMaximum(0.);
}
else if(n==2){
isub=5;
h->SetMinimum(0);
h->SetMaximum(0.3);
}
else if(n==3){
isub=6;
h->SetMinimum(-0.05);
h->SetMaximum(0.2);
}
//SetTitle(h,"","p_{T}","v_{2}^{raw}");
SetTitle(*h,"p_{T} (GeV/c)",Form("v_{%d}",n),"");
c2->SetLeftMargin(0.12);
h->GetXaxis()->CenterTitle();
h->GetYaxis()->CenterTitle();
h->GetYaxis()->SetTitleSize(0.06);
h->DrawCopy();
TLatex t;
t.SetNDC();
t.DrawLatex(0.6,0.82,"d+Au 62GeV");
TLegend *leg = new TLegend(0.2,0.7,0.5,0.88);
leg->SetFillColor(0);
leg->SetBorderSize(0);
leg->SetTextSize(0.04);
SetStyle(*gr[4][idire][iCNTEP], 1.2, 2,style[6]);
SetStyle(*gr[isub][idire][iCNTEP], 1.2, 4,style[6]);
gr[4][idire][iCNTEP]->Draw("Psame");
gr[isub][idire][iCNTEP]->Draw("Psame");
leg->AddEntry(gr[4][idire][iCNTEP],Form("BBCs"),"P");
//.........这里部分代码省略.........
开发者ID:XuQiao,项目名称:phenix,代码行数:101,代码来源:plotvn.C

示例9: PlotPtTresh2

void PlotPtTresh2() {
	//  gROOT->ProcessLine(".L ./tdrstyle.C");
	//  setTDRStyle();
	Int_t r=1; 
	

	TFile *f1 = new TFile("histo_file_QCDPU50GEM2019.root");
	
	char  histo[40], histo1[40], histo2[40], histoDC[40];
	
	TH1F *hInitialBarrel = (TH1F*)f1->Get("hInitialBarrel"); 
	TH1F *hInitialEndcap = (TH1F*)f1->Get("hInitialEndcap"); 	
	
	TH1F *hPtBarrel = (TH1F*)f1->Get("hMuonPtFinal_Barrel"); 
	TH1F *hPtHE = (TH1F*)f1->Get("hMuonPtFinal_HE"); 
	TH1F *hPtFull = (TH1F*)f1->Get("hMuonPtFinal_Full"); 
	TH1F *hInitial = (TH1F*)f1->Get("entries_after_vertex"); 
	TH1F *hWP2012Pt = (TH1F*)f1->Get("hMuonPtWP2012"); 
	TH1F *h_HTot = (TH1F*)f1->Get("H_tot"); 
	TH1F *initial_entries = (TH1F*)f1->Get("initial_entries"); 
	
	cout<<"Htot"<<h_HTot->Integral()<<"  initial entries  "<<initial_entries->Integral()<<endl;
	
	int  Ninitial=hInitial->Integral();    
	cout<<" initial  "<<Ninitial<<endl;
	cout<<" initial  barrel "<<hInitialBarrel->Integral()<<endl;
	cout<<" initial endcap"<<hInitialEndcap->Integral()<<endl;
	
	cout<<" after muon barrel  "<<hPtBarrel->Integral()<<endl;
	cout<<" after muon HE  "<<hPtHE->Integral()<<endl;
	
	float MuonEff2012[1] =0;
	MuonEff2012[0]= hWP2012Pt->Integral()/hInitial->Integral();
	float Err_MuonEff2012[1];
	Err_MuonEff2012[0]=(TMath::Sqrt(Err_MuonEff2012[0]*(1-Err_MuonEff2012[0])))/Ninitial;
	//cout<<"Muon Eff WP 2012 "<<hWP2012Pt->Integral()/hInitial->Integral()<<endl;
	
	/////////////////////////compute selection eff as a function of muon pt threshold/////////////////////////////
	int EvAfterPtCut_HE[100]; float EffSel[100], xgr[100], ex[100],ey[100], EffSelFull[100], eyfull[100], Eff_Barrel[100], Eff_Endcap[100], err_Eff_barrel[100],err_Eff_endcap[100];
	int EvAfterPtCut_Barrel[100]; 
	int EvAfterPtCut[100];
	int EvAfterPtCut_BB[100];	
	int EvAfterPtCut_EE[100];	
	
	//  std::cout<<" Muon Pt in |eta|<2.4 "<<hMuonTot->Integral(0,200)<<endl;
	
	for(int i=0;i<40;i++){
		EvAfterPtCut_Barrel[i]=hPtBarrel->Integral(10,100);
		EvAfterPtCut_HE[i]=hPtHE->Integral(i+1,100);
		
		EvAfterPtCut[i]=hPtFull->Integral(i+1,100); 
		EvAfterPtCut_BB[i] =hPtBarrel->Integral(i+1,100);
		EvAfterPtCut_EE[i] =hPtHE->Integral(i+1,100);
		
		EffSelFull[i] = EvAfterPtCut[i] / (hInitialBarrel->Integral() + hInitialEndcap->Integral() );		
		Eff_Barrel[i]= EvAfterPtCut_BB[i]/hInitialBarrel->Integral();  
		Eff_Endcap[i]=EvAfterPtCut_EE[i]/hInitialEndcap->Integral();  
		
		std::cout<<i*2<<" nev after pt cut barrel "<<EvAfterPtCut_BB[i]<<"  nev after pt cut endcap  "<<EvAfterPtCut_HE[i]<<"  eff sel  "<<endl;
		
		xgr[i]=i*2;
		ex[i]=0; 
		EffSel[i]=(EvAfterPtCut_Barrel[i]+EvAfterPtCut_HE[i])/(hInitial->Integral());
		
		ey[i]=TMath::Sqrt((EffSel[i]*(1-EffSel[i])))/hInitial->Integral();
		eyfull[i]=TMath::Sqrt((EffSelFull[i]*(1-EffSelFull[i])))/hInitial->Integral();
		//  std::cout<<i*2<<" nev after pt cut barrel || endcap "<<EvAfterPtCut_Barrel[i]+EvAfterPtCut_HE[i]<<" eff sel  "<<EffSel[i]<<" errore "<<ey[i]<<endl;
	}
	
	double xgr12[1]; xgr12[0]=13.0; 
	double ex12[1]; ex12[0]=0.; 
	TGraphErrors* gr = new TGraphErrors(26,xgr,EffSel,ex,ey);
	TGraphErrors* gr_full = new TGraphErrors(26,xgr,EffSelFull,ex,eyfull);
	TGraph* gr12 = new TGraph(1);
	gr12->SetPoint(0,20,MuonEff2012[0]);
	
	TGraphErrors* gr_BB = new TGraphErrors(26,xgr,Eff_Barrel,ex,ey);	
	TGraphErrors* gr_EE = new TGraphErrors(26,xgr,Eff_Endcap,ex,ey);	
	
	///////////////////////////////////////////************************************////////////////////////////////////////////
	TCanvas *Canv5 = new TCanvas("Canv5","Palle",800,700);
	gr->SetMarkerStyle(24);  
	gr12->SetMarkerStyle(23); 
	gr->SetMarkerColor(kRed);  
	gr12->SetMarkerColor(kBlue);  
	gr->SetTitle(" Selection Efficiency as a function of muon pt threshold ");
	gr->GetYaxis()->SetTitle("Selection Efficiency");
	gr->GetYaxis()->SetTitleOffset(1.4);
	gr->GetXaxis()->SetTitle("P_{T}^{#mu Endcap} Cut (GeV/c)");
	
	gr->SetMarkerSize(1.2);  
	gr12->SetMarkerSize(1.4); 
	
	gr->Draw("ACP");
	gr12->Draw("CP");
	gr->SetMinimum(0.5);
	TLegend* legend = new TLegend( 0.15, 0.5, 0.75, 0.7);
	legend->SetTextSize(0.025);
	legend->SetFillColor(0);
	legend->AddEntry(gr, "PU=50 wGEM (P_{T}^{#mu, barrel}>20, |#eta|<2.1)","p");
//.........这里部分代码省略.........
开发者ID:rvenditti,项目名称:H2tau_GEMAnalysis,代码行数:101,代码来源:PlotPtTresh2.C

示例10: METJetsb3


//.........这里部分代码省略.........
   METJetsb310->SetBinError(10,8.216396e-05);
   METJetsb310->SetBinError(11,7.115607e-05);
   METJetsb310->SetBinError(12,5.809869e-05);
   METJetsb310->SetBinError(13,6.708659e-05);
   METJetsb310->SetBinError(14,4.437361e-05);
   METJetsb310->SetBinError(15,3.750254e-05);
   METJetsb310->SetBinError(16,4.108198e-05);
   METJetsb310->SetEntries(132);

   ci = TColor::GetColor("#0000ff");
   METJetsb310->SetFillColor(ci);

   ci = TColor::GetColor("#0000ff");
   METJetsb310->SetLineColor(ci);

   ci = TColor::GetColor("#0000ff");
   METJetsb310->SetMarkerColor(ci);
   METJetsb310->SetMarkerStyle(21);
   METJetsb310->GetXaxis()->SetTitle("METJetsb3");
   METJetsb310->GetXaxis()->SetLabelFont(42);
   METJetsb310->GetXaxis()->SetLabelSize(0.035);
   METJetsb310->GetXaxis()->SetTitleSize(0.035);
   METJetsb310->GetXaxis()->SetTitleFont(42);
   METJetsb310->GetYaxis()->SetTitle("Events/pb");
   METJetsb310->GetYaxis()->SetLabelFont(42);
   METJetsb310->GetYaxis()->SetLabelSize(0.035);
   METJetsb310->GetYaxis()->SetTitleSize(0.035);
   METJetsb310->GetYaxis()->SetTitleFont(42);
   METJetsb310->GetZaxis()->SetLabelFont(42);
   METJetsb310->GetZaxis()->SetLabelSize(0.035);
   METJetsb310->GetZaxis()->SetTitleSize(0.035);
   METJetsb310->GetZaxis()->SetTitleFont(42);
   b3/METJetsb3->Add(METJetsb3,"");
   b3/METJetsb3->Draw("nostack");
   
   TPaveText *pt = new TPaveText(0.3218966,0.94,0.6781034,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextFont(42);
   TText *AText = pt->AddText("b3/METJetsb3");
   pt->Draw();
   
   TLegend *leg = new TLegend(0.54023,0.639881,0.938218,0.924107,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextSize(0.034965);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("METJetsb3","b3/METJetsb3_QCD_b3/","lp");

   ci = TColor::GetColor("#00cc00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#00cc00");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(22);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("METJetsb3","b3/METJetsb3_WJetsToLNu_b3/","lp");
开发者ID:delgadoandrea,项目名称:CMSSW_7_4_6_patch6,代码行数:66,代码来源:METJetsb3.C

示例11: FitPlotAndSave

//***############## main fitting Fxn ################ *****//
void FitPlotAndSave( char *Ifile ){
 
/** Plot Options***/	
//gROOT->Reset();
// gROOT->Clear();
gROOT->SetStyle("Plain") ;
gROOT->SetBatch(kFALSE);
gStyle->SetOptTitle(1);
gStyle->SetOptStat(0);
gStyle->SetOptFit(1);
gStyle->SetStatX(.89);
gStyle->SetStatY(.89) ;
gStyle->SetStatBorderSize(0);
//gStyle->SetOptStat(1111111)
gStyle->SetCanvasColor(kWhite);   // background is no longer mouse-dropping white
gStyle->SetPalette(1);        // blue to red false color palette. Use 9 for b/w
gStyle->SetCanvasBorderMode(0);     // turn off canvas borders
gStyle->SetPadBorderMode(0);
gStyle->SetPaintTextFormat("5.2f");  // What precision to put numbers if plotted with "TEXT"

// For publishing:
gStyle->SetLineWidth(2);
gStyle->SetTextSize(1.1);
gStyle->SetLabelSize(0.06,"xy");
gStyle->SetTitleSize(0.08,"xy");
gStyle->SetTitleOffset(1.2,"x");
gStyle->SetTitleOffset(1.0,"y");
gStyle->SetPadTopMargin(0.1);
gStyle->SetPadRightMargin(0.1);
gStyle->SetPadBottomMargin(0.16);
gStyle->SetPadLeftMargin(0.12);
TGaxis::SetMaxDigits(1); // Set Axis to be of the form 0.11 10^N


       TFile *ifile  = new TFile(Ifile);
        
	TF1 *fitFcn  = new TF1("fitFcn", mygaus, FitLowRange, FitHighRange, 3 );
	fitFcn->SetNpx(500);
	fitFcn->SetLineWidth(4);
	fitFcn->SetLineStyle(5);
	fitFcn->SetLineColor(kBlue);
        cout <<" Calling Fitting Fxntion" << endl;
	TH1F*h_Seed_TimeEBEB = (TH1F*)ifile->Get("EBEB/seed time");
	if(h_Seed_TimeEBEB == 0){ std::cout  <<"!! Histogram Does not exist!!" << std::endl; throw 1;}
        
	h_Seed_TimeEBEB->SetTitle("Seed Time[ns]");   
        h_Seed_TimeEBEB->SetMarkerStyle(20);
        h_Seed_TimeEBEB->SetMarkerSize(0.8);
        h_Seed_TimeEBEB->SetStats(1);
        h_Seed_TimeEBEB->SetTitleSize(0.08, "x");   
        h_Seed_TimeEBEB->SetTitleOffset(1.0, "x");    
        h_Seed_TimeEBEB->SetTitleSize(0.06, "y"); 
        h_Seed_TimeEBEB->SetTitleOffset(0.95, "y");    
        h_Seed_TimeEBEB->SetYTitle("Number of Seeds/0.05ns"); 
        h_Seed_TimeEBEB->SetXTitle("t_{seed}[ns]"); 
        h_Seed_TimeEBEB->GetXaxis()->SetRangeUser(FitLowRange, FitHighRange);   

       /** Set parms as parms of Fit Fxn **/
	fitFcn->SetParameters(500, h_Seed_TimeEBEB->GetMean(), h_Seed_TimeEBEB->GetRMS() );
	fitFcn->SetParNames("CONST", "#mu(ns)", "#sigma(ns)");
	h_Seed_TimeEBEB->Fit("fitFcn", "LL"); /**Fit with improved LL**/
	std::cout << "Printing Fit Parameters for EBEB ......   " << std::endl;
        printf("Integral of function in EBEB = %g\n", fitFcn->Integral( FitLowRange, FitHighRange));

        //*** retrive fit results***//
        int npar = fitFcn->GetNpar();
        TVirtualFitter *fit = TVirtualFitter::GetFitter();
        fit->PrintResults(2,0.);
        TMatrixD *CovMatrix = new TMatrixD ( npar, npar, fit->GetCovarianceMatrix() );
	CovMatrix->Print();
        TCanvas *c1 = new TCanvas("c1","EB-EB",200,10,800,900);
     	c1->SetGridx();
     	c1->SetGridy();
	c1->GetFrame()->SetFillColor(21);
	c1->GetFrame()->SetBorderMode(-1);
	c1->GetFrame()->SetBorderSize(5);
        /* c1->Divide(2,1);  */
	c1->cd();
	h_Seed_TimeEBEB->Draw();
	fitFcn->Draw("sames");
        c1->SetLogy(0);
	//  draw the legend
    	TLegend *leg = new TLegend(0.15,0.72,0.3,0.85);
       	leg->SetTextFont(72);
        leg->SetTextSize(0.04);
        leg->AddEntry(h_Seed_TimeEBEB,"EB","lpe");
        leg->AddEntry(fitFcn,"GAUS","l");
        leg->Draw();
	c1->SaveAs("Seed_Time_DoubleElectron_Run2012A-EB-EB.png");
}       
开发者ID:TENorbert,项目名称:ECALTime,代码行数:91,代码来源:FitPlotAndSave.C

示例12: forData


//.........这里部分代码省略.........
  dataSetZjetsSB.  plotOn(mJetFrame, Binning(binsmJet));  
  ext_model_mJetSB.plotOn(mJetFrame, Range("allRange"));
  mJetFrame->SetTitle("M_{jet} distribution in Z+jets MC");

  // Alpha ratio part

  mZH.setRange("fullRange", 900., 3000.);

  RooBinning binsmZH(21, 900, 3000);

  RooRealVar a("a", "a",  0., -1.,    1.);
  RooRealVar b("b", "b", 1000,  0., 4000.);
  
  RooGenericPdf model_ZHSB("model_ZHSB", "model_ZHSB", "TMath::Exp(@1*@[email protected]/@0)", RooArgSet(mZH,a,b));
  RooGenericPdf model_ZHSG("model_ZHSG", "model_ZHSG", "TMath::Exp(@1*@[email protected]/@0)", RooArgSet(mZH,a,b));
  RooGenericPdf model_ZH  ("model_ZH",   "model_ZH",   "TMath::Exp(@1*@[email protected]/@0)", RooArgSet(mZH,a,b));

  RooExtendPdf ext_model_ZHSB("ext_model_ZHSB", "ext_model_ZHSB", model_ZHSB, nMcEvents);
  RooExtendPdf ext_model_ZHSG("ext_model_ZHSG", "ext_model_ZHSG", model_ZHSG, nMcEvents);
  RooExtendPdf ext_model_ZH  ("ext_model_ZH",   "ext_model_ZH",   model_ZH,   nDataEvents);

  // Fit ZH mass in side band  

  RooFitResult* mZHSB_result = ext_model_ZHSB.fitTo(dataSetZjetsSB, SumW2Error(true), Extended(true), Range("fullRange"), Strategy(2), Minimizer("Minuit2"), Save(1));

  float p0 = a.getVal();
  float p1 = b.getVal();

  // Fit ZH mass in signal region

  RooFitResult* mZHSG_result = ext_model_ZHSG.fitTo(dataSetZjetsSG, SumW2Error(true), Extended(true), Range("fullRange"), Strategy(2), Minimizer("Minuit2"), Save(1));

  float p2 = a.getVal();
  float p3 = b.getVal();

  // Fit ZH mass in side band region (data)

  RooFitResult* mZH_result = ext_model_ZH.fitTo(dataSetDataSB, SumW2Error(true), Extended(true), Range("fullRange"), Strategy(2), Minimizer("Minuit2"), Save(1));

  // Draw the model of alpha ratio
  // Multiply the model of background in data side band with the model of alpha ratio to the a model of background in data signal region

  RooGenericPdf model_alpha("model_alpha", "model_alpha", Form("TMath::Exp(%f*@0+%f/@0)/TMath::Exp(%f*@0+%f/@0)", p2,p3,p0,p1), RooArgSet(mZH));
  RooProdPdf    model_sigData("model_sigData", "ext_model_ZH*model_alpha", RooArgList(ext_model_ZH,model_alpha));

  // Plot the results to a frame 

  RooPlot* mZHFrameMC = mZH.frame();

  dataSetZjetsSB.plotOn(mZHFrameMC, Binning(binsmZH));
  ext_model_ZHSB.plotOn(mZHFrameMC, VisualizeError(*mZHSB_result), FillColor(kYellow));
  dataSetZjetsSB.plotOn(mZHFrameMC, Binning(binsmZH));
  ext_model_ZHSB.plotOn(mZHFrameMC, LineStyle(7), LineColor(kBlue));

  dataSetZjetsSG.plotOn(mZHFrameMC, Binning(binsmZH));
  ext_model_ZHSG.plotOn(mZHFrameMC, VisualizeError(*mZHSG_result), FillColor(kYellow));
  dataSetZjetsSG.plotOn(mZHFrameMC, Binning(binsmZH));
  ext_model_ZHSG.plotOn(mZHFrameMC, LineStyle(7), LineColor(kRed));

  TLegend* leg = new TLegend(0.65,0.77,0.85,0.85);

  leg->AddEntry(mZHFrameMC->findObject(mZHFrameMC->nameOf(3)), "side band",     "l");
  leg->AddEntry(mZHFrameMC->findObject(mZHFrameMC->nameOf(7)), "signal region", "l");
  leg->Draw();

  mZHFrameMC->addObject(leg);
  mZHFrameMC->SetTitle("M_{ZH} distribution in MC");

  RooPlot* mZHFrame = mZH.frame();

  dataSetDataSB.plotOn(mZHFrame, Binning(binsmZH));
  ext_model_ZH .plotOn(mZHFrame, VisualizeError(*mZH_result), FillColor(kYellow));
  dataSetDataSB.plotOn(mZHFrame, Binning(binsmZH));
  ext_model_ZH .plotOn(mZHFrame, LineStyle(7), LineColor(kBlue));
  model_sigData.plotOn(mZHFrame, Normalization(normFactor, RooAbsReal::NumEvent), LineStyle(7), LineColor(kRed));

  TLegend* leg1 = new TLegend(0.65,0.77,0.85,0.85);

  leg1->AddEntry(mZHFrame->findObject(mZHFrame->nameOf(3)), "side band",     "l");
  leg1->AddEntry(mZHFrame->findObject(mZHFrame->nameOf(4)), "signal region", "l");
  leg1->Draw();
  
  mZHFrame->addObject(leg1);
  mZHFrame->SetTitle("M_{ZH} distribution in Data");

  TCanvas* c = new TCanvas("c","",0,0,1000,800);

  c->cd();
  mZHFrameMC->Draw();
  c->Print(Form("rooFit_forData_%s_cat%s.pdf(", channel.data(), catcut.data()));

  c->cd();
  mZHFrame->Draw();
  c->Print(Form("rooFit_forData_%s_cat%s.pdf", channel.data(), catcut.data()));

  c->cd();
  mJetFrame->Draw();
  c->Print(Form("rooFit_forData_%s_cat%s.pdf)", channel.data(), catcut.data()));

}
开发者ID:yuchanggit,项目名称:ZpZHllbb_13TeV,代码行数:101,代码来源:forData.C

示例13: pi0_HadCorrelations_Projections


//.........这里部分代码省略.........
      _hSignal_pPb[iCount]->Divide(_hBackground_pPb[iCount]);
      int _x0 = _hBackground_pPb[iCount]->GetXaxis()->FindBin(0.0);
      int _y0 = _hBackground_pPb[iCount]->GetYaxis()->FindBin(0.0);
      double _B0 = _hBackground_pPb[iCount]->GetBinContent(_x0,_y0);
      _hSignal_pPb[iCount]->Scale(_B0/(_nEvents_pPb));
      _hSignal_pPb[iCount]->Scale(1.0/_etabinwidth/_phibinwidth);
        
      c1->cd(iCount+1);
    
      _hSignal_pPb[iCount]->GetXaxis()->SetRange(5,29);
        
      _hSignal_pPb[iCount]->GetXaxis()->SetTitle("#Delta#eta");
      _hSignal_pPb[iCount]->GetXaxis()->SetRange(5,29);
      _hSignal_pPb[iCount]->GetXaxis()->CenterTitle(true);
      _hSignal_pPb[iCount]->GetXaxis()->SetLabelFont(42);
      _hSignal_pPb[iCount]->GetXaxis()->SetLabelSize(0.035);
      _hSignal_pPb[iCount]->GetXaxis()->SetTitleSize(0.05);
      _hSignal_pPb[iCount]->GetXaxis()->SetTitleOffset(1.38);
      _hSignal_pPb[iCount]->GetXaxis()->SetTitleFont(42);
      _hSignal_pPb[iCount]->GetYaxis()->SetTitle("#Delta#phi");
      _hSignal_pPb[iCount]->GetYaxis()->CenterTitle(true);
      _hSignal_pPb[iCount]->GetYaxis()->SetLabelFont(42);
      _hSignal_pPb[iCount]->GetYaxis()->SetLabelSize(0.035);
      _hSignal_pPb[iCount]->GetYaxis()->SetTitleSize(0.05);
      _hSignal_pPb[iCount]->GetYaxis()->SetTitleOffset(1.59);
      _hSignal_pPb[iCount]->GetYaxis()->SetTitleFont(42);
      _hSignal_pPb[iCount]->GetZaxis()->SetTitle("#frac{1}{N_{trig}} #frac{d^{2}N^{pair}}{d#Delta#etad#Delta#phi}");
      _hSignal_pPb[iCount]->GetZaxis()->SetLabelFont(42);
      _hSignal_pPb[iCount]->GetZaxis()->SetLabelSize(0.035);
      _hSignal_pPb[iCount]->GetZaxis()->SetTitleSize(0.035);
      _hSignal_pPb[iCount]->GetZaxis()->SetTitleOffset(2.33);
      _hSignal_pPb[iCount]->GetZaxis()->SetTitleFont(42);
      _hSignal_pPb[iCount]->GetZaxis()->SetNdivisions(505);
      _hSignal_pPb[iCount]->Draw("SURF1");
        
      TLatex * tex = new TLatex(-0.8847018,0.9364877,Form("%5.1f < p_{T} < %5.1f (GeV/c)",_ptMin[iCount],_ptMax[iCount]));
      tex->SetTextSize(0.06);
      tex->Draw();

    } // loop over 8 histogram bins
    
  cout <<"\n Now drawing the projections..." << endl;
  float etaMin = 2.0;
  float etaMax = 3.6;
    
  TString _Name = "projClone";
  TString _Name2 = "_pi0HadProj";
  TString _Name4 = "FourierDecompose";
  TString _Name1, _Name3, _Name5;
    
  TH2D *_projCorrFunc[9];
  TH1D * _pi0HadCorrProj[9];
  TF1 *_FourierDecompose[9];
  const int n = 9;
  double _Parameter0[n];
  double _Par0Error[n];
  double _Parameter2[n];
  double _Par2Error[n];
  double _Ratio[n];
  double _Error[n];
    
  for(long iCount=0; iCount<nPtBins; ++iCount) {
    _Name1 = _Name + iCount;
    _Name3 = _Name2 + iCount;
    _Name5 = _Name4 + iCount;
        
开发者ID:ravijanjam,项目名称:Pi0Analysis,代码行数:66,代码来源:pi0_HadCorrelations_Projections.C

示例14: jet2ptb3


//.........这里部分代码省略.........
   jet2ptb345->SetBinError(11,1.677165e-05);
   jet2ptb345->SetBinError(12,1.677165e-05);
   jet2ptb345->SetBinError(13,2.371869e-05);
   jet2ptb345->SetBinError(15,2.371869e-05);
   jet2ptb345->SetBinError(17,1.677165e-05);
   jet2ptb345->SetBinError(18,1.677165e-05);
   jet2ptb345->SetBinError(21,1.677165e-05);
   jet2ptb345->SetEntries(132);

   ci = TColor::GetColor("#0000ff");
   jet2ptb345->SetFillColor(ci);

   ci = TColor::GetColor("#0000ff");
   jet2ptb345->SetLineColor(ci);

   ci = TColor::GetColor("#0000ff");
   jet2ptb345->SetMarkerColor(ci);
   jet2ptb345->SetMarkerStyle(21);
   jet2ptb345->GetXaxis()->SetTitle("jet2ptb3");
   jet2ptb345->GetXaxis()->SetLabelFont(42);
   jet2ptb345->GetXaxis()->SetLabelSize(0.035);
   jet2ptb345->GetXaxis()->SetTitleSize(0.035);
   jet2ptb345->GetXaxis()->SetTitleFont(42);
   jet2ptb345->GetYaxis()->SetTitle("Events/pb");
   jet2ptb345->GetYaxis()->SetLabelFont(42);
   jet2ptb345->GetYaxis()->SetLabelSize(0.035);
   jet2ptb345->GetYaxis()->SetTitleSize(0.035);
   jet2ptb345->GetYaxis()->SetTitleFont(42);
   jet2ptb345->GetZaxis()->SetLabelFont(42);
   jet2ptb345->GetZaxis()->SetLabelSize(0.035);
   jet2ptb345->GetZaxis()->SetTitleSize(0.035);
   jet2ptb345->GetZaxis()->SetTitleFont(42);
   b3/jet2ptb3->Add(jet2ptb3,"");
   b3/jet2ptb3->Draw("nostack");
   
   TPaveText *pt = new TPaveText(0.3578161,0.9342857,0.6421839,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextFont(42);
   TText *AText = pt->AddText("b3/jet2ptb3");
   pt->Draw();
   
   TLegend *leg = new TLegend(0.54023,0.639881,0.938218,0.924107,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextSize(0.034965);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("jet2ptb3","b3/jet2ptb3_QCD_b3/","lp");

   ci = TColor::GetColor("#00cc00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#00cc00");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(22);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("jet2ptb3","b3/jet2ptb3_WJetsToLNu_b3/","lp");
开发者ID:delgadoandrea,项目名称:CMSSW_7_4_6_patch6,代码行数:66,代码来源:jet2ptb3.C

示例15: drawLateralScan

void drawLateralScan( const std::string& outputdir, const std::string& name, std::vector<LateralScanStruct> lss, const std::string& axisName, const std::string& fullVarName_mc ) {


  ResoStruct rs_ref_mc;
  ResoStruct rs_ref_data;

  for( unsigned i=0; i<lss.size(); ++i ) {

    if( lss[i].offset==0. ) {

      std::string histoName_data("data_ref");
      TH1D* h1_data = new TH1D( histoName_data.c_str(), "", 200, 0., 5000. );
      lss[i].tree_data->Project( histoName_data.c_str(), "cef3_corr[0]+cef3_corr[1]+cef3_corr[2]+cef3_corr[3]", "isSingleEle_scintFront" );
  
      std::string histoName_mc("mc_ref");
      TH1D* h1_mc = new TH1D( histoName_mc.c_str(), "", 100, 0., 500. );
      lss[i].tree_mc->Project( histoName_mc.c_str(), fullVarName_mc.c_str() );

      rs_ref_mc   = getRespResoFromHisto( h1_mc );
      rs_ref_data = getRespResoFromHisto( h1_data );

      delete h1_data;
      delete h1_mc;

      break;

    }

  }



  TGraphErrors* gr_RespVsDiag_data = new TGraphErrors(0);
  TGraphErrors* gr_ResoVsDiag_data = new TGraphErrors(0);
  TGraphErrors* gr_RespVsDiag_mc   = new TGraphErrors(0);
  TGraphErrors* gr_ResoVsDiag_mc   = new TGraphErrors(0);

  for( unsigned i=0; i<lss.size(); ++i ) {

    std::string histoName_data(Form("data_%.0f", lss[i].offset));
    TH1D* h1_data = new TH1D( histoName_data.c_str(), "", 200, 0., 5000. );
    lss[i].tree_data->Project( histoName_data.c_str(), "cef3_corr[0]+cef3_corr[1]+cef3_corr[2]+cef3_corr[3]", "isSingleEle_scintFront" );

    std::string histoName_mc(Form("mc_%.0f", lss[i].offset));
    TH1D* h1_mc = new TH1D( histoName_mc.c_str(), "", 100, 0., 500. );
    lss[i].tree_mc->Project( histoName_mc.c_str(), fullVarName_mc.c_str() );


    ResoStruct rs_mc = getRespResoFromHisto( h1_mc );
    ResoStruct rs_data = getRespResoFromHisto( h1_data );

    gr_RespVsDiag_data->SetPoint( i, lss[i].offset, rs_data.resp/rs_ref_data.resp );
    gr_ResoVsDiag_data->SetPoint( i, lss[i].offset, rs_data.reso/rs_ref_data.reso );
    gr_RespVsDiag_mc  ->SetPoint( i, lss[i].offset, rs_mc.resp/rs_ref_mc.resp );
    gr_ResoVsDiag_mc  ->SetPoint( i, lss[i].offset, rs_mc.reso/rs_ref_mc.reso );
    
    gr_RespVsDiag_data->SetPointError( i, 0., getRatioError( rs_data.resp, rs_ref_data.resp, rs_data.resp_error, rs_ref_data.resp_error) );
    gr_ResoVsDiag_data->SetPointError( i, 0., getRatioError( rs_data.reso, rs_ref_data.reso, rs_data.reso_error, rs_ref_data.reso_error) );
    gr_RespVsDiag_mc  ->SetPointError( i, 0., getRatioError( rs_mc  .resp, rs_ref_mc  .resp, rs_mc  .resp_error, rs_ref_mc  .resp_error) );
    gr_ResoVsDiag_mc  ->SetPointError( i, 0., getRatioError( rs_mc  .reso, rs_ref_mc  .reso, rs_mc  .reso_error, rs_ref_mc  .reso_error) );

    delete h1_data;
    delete h1_mc;
    
  }


  TCanvas* c1 = new TCanvas("c2", "", 600, 600);
  c1->cd();

  float xMax = (axisName=="Diagonal") ? 20. : 13.;
  float xMin = (axisName=="Diagonal") ? -1. : -xMax;
  TH2D* h2_axes = new TH2D("axes", "", 10, xMin, xMax, 10, 0., 1.1);
  h2_axes->SetXTitle( Form("%s Distance From Center [mm]", axisName.c_str()));
  h2_axes->SetYTitle( "Response Ratio" );

  h2_axes->Draw();

  TLine* line_one = new TLine( xMin, 1., xMax, 1. );
  line_one->Draw("same");

  gr_RespVsDiag_data->SetMarkerSize(1.6);
  gr_RespVsDiag_mc->SetMarkerSize(1.6);

  gr_RespVsDiag_data->SetMarkerStyle(20);
  gr_RespVsDiag_mc->SetMarkerStyle(24);

  gr_RespVsDiag_data->SetMarkerColor(46);
  gr_RespVsDiag_mc->SetMarkerColor(kBlack);

  gr_RespVsDiag_data->Draw("p same");
  gr_RespVsDiag_mc->Draw("p same");

  TLegend* legend = new TLegend( 0.22, 0.21, 0.45, 0.39 );
  legend->SetFillStyle(1);
  legend->SetFillColor(0);
  legend->SetTextSize(0.038);
  legend->AddEntry( gr_RespVsDiag_data, "Data", "P" );
  legend->AddEntry( gr_RespVsDiag_mc, "Geant4", "P" );
  legend->Draw("same");
//.........这里部分代码省略.........
开发者ID:CeF3TB,项目名称:BTFAnalysis,代码行数:101,代码来源:drawResolutionStudies.cpp


注:本文中的TLegend::Draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。