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


C++ TPad::GetBottomMargin方法代码示例

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


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

示例1: can

void HiggsPlot::PlotChi2(){
  styles style; style.setPadsStyle(1); 
  style.PadLeftMargin = 0.14; style.PadBottomMargin = 0.17; 
  style.yTitleOffset = 0.7;   style.xTitleOffset = 0.7; 
  style.TitleSize = 0.1; style.LabelSize = 0.1;
  style.setDefaultStyle();
  TCanvas can("can","Likelihood scan");
  TPad *cPad = static_cast<TPad *>(can.cd(0));
  TString xTitle[] = {"R(D)", "R(D*)"};

  double nSig = 4.2;
  int nBins = 60;
  _varyRD = 0;

  double RD[2], RDs[2], frac=0.018;
  Compute(0,RD,1); Compute(0,RDs,2);
  double Limit[2][2] = {{Measurement[1][0]-nSig*Measurement[1][1], Measurement[1][0]+nSig*Measurement[1][1]},
			{Measurement[2][0]-nSig*Measurement[2][1], Measurement[2][0]+nSig*Measurement[2][1]}};
  TH2F hChi2("hChi2","",nBins, Limit[0][0],Limit[0][1], nBins, Limit[1][0],Limit[1][1]);

  for(int iRD=1; iRD<=nBins; iRD++){
    for(int iRDs=1; iRDs<=nBins; iRDs++){
      RD[0] = hChi2.GetXaxis()->GetBinCenter(iRD);
      RDs[0] = hChi2.GetYaxis()->GetBinCenter(iRDs);
      hChi2.SetBinContent(iRD, iRDs, ProbChi2(3, 0, RD, RDs));
      //cout<<1-ProbChi2(3, 0, RD, RDs)<<endl;
    }
    //cout<<endl;
  }

  hChi2.SetXTitle(xTitle[0]); hChi2.SetYTitle(xTitle[1]); 
  //int colors[] = {kBlue+2, kBlue+1, kBlue-4, kBlue-7, kBlue-9, kBlue-10, 0};
  int colors[] = {kBlue-3, kBlue-4, kBlue-7, kBlue-9, kBlue-10, 0};
  gStyle->SetPalette(Nsigma, colors);
  double zCont[Nsigma];
  for(int ns=1; ns<=Nsigma; ns++) zCont[ns] = IntG(0,1,-ns,ns);//cout<<endl<<zCont[ns]<<endl;}
  hChi2.SetContour(Nsigma,zCont);
  hChi2.GetXaxis()->CenterTitle(true); hChi2.GetYaxis()->CenterTitle(true);
  hChi2.SetLabelOffset(0.009,"xy");
  hChi2.SetLabelSize(0.09,"xy");
  hChi2.SetTitleOffset(1,"x");
  hChi2.SetTitleOffset(0.6,"y");
  hChi2.Draw("cont4");

  double padL[2][2] = {{cPad->GetLeftMargin(),   1-cPad->GetRightMargin()}, // Margins are reversed for x-y!
		       {cPad->GetBottomMargin(), 1-cPad->GetTopMargin()}};
  double SMyield[2];
  Compute(0,RD,1); Compute(0,RDs,2); RD[1] = RDs[0];
  TLine line; line.SetLineWidth(2); line.SetLineColor(1);
  for(int chan=0; chan<2; chan++){
    double range = Limit[chan][1]-Limit[chan][0];
    SMyield[chan] = padL[chan][0] + (padL[chan][1]-padL[chan][0])*(RD[chan]-Limit[chan][0])/range;
  }
  line.DrawLineNDC(SMyield[0]-frac, SMyield[1], SMyield[0]+frac, SMyield[1]);
  line.DrawLineNDC(SMyield[0], SMyield[1]-2*frac, SMyield[0], SMyield[1]+2*frac);

  TLatex latex; latex.SetNDC(kTRUE); latex.SetTextAlign(33); latex.SetTextSize(style.TitleSize);
  latex.DrawLatex(SMyield[0]-frac,SMyield[1]-frac,"SM");

  line.SetLineColor(0);
  for(int chan=0; chan<2; chan++){
    double range = Limit[chan][1]-Limit[chan][0];
    SMyield[chan] = padL[chan][0] + (padL[chan][1]-padL[chan][0])*(Measurement[1+chan][0]-Limit[chan][0])/range;
  }
  line.DrawLineNDC(SMyield[0]-frac, SMyield[1], SMyield[0]+frac, SMyield[1]);
  line.DrawLineNDC(SMyield[0], SMyield[1]-2*frac, SMyield[0], SMyield[1]+2*frac);
  
  TH1F *histo[Nsigma];
  double legW = 0.08, legH = 0.07*Nsigma;
  double legX = 1-style.PadRightMargin-0.02, legY = 1-style.PadTopMargin-0.02;
  TLegend *leg = new TLegend(legX-legW, legY-legH, legX, legY);
  leg->SetTextSize(0.08); leg->SetFillColor(0); leg->SetTextFont(style.nFont);
  for(int ileg=0; ileg<Nsigma-1; ileg++) {
    TString label = "histo"; label += ileg+1; 
    histo[ileg] = new TH1F(label,"histo",10,0,10);
    histo[ileg]->SetLineColor(colors[ileg]);histo[ileg]->SetFillColor(colors[ileg]);
    label = " "; label += ileg+1; label += "#sigma";
    leg->AddEntry(histo[ileg],label);
  }
  leg->Draw(); 

  
  TString pName = "public_html/Higgs_Chi2.eps"; 
  can.SaveAs(pName);

  for(int ileg=0; ileg<Nsigma-1; ileg++) histo[ileg]->Delete();
}
开发者ID:manuelfs,项目名称:babar_code,代码行数:87,代码来源:higgs_plots.cpp

示例2: vs_PlotQCDcomp


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

  if ( hptFOR != 0 ) {
    for (int b = 0; b < hptFOR->GetNbinsX(); b++) {

      Double_t mainHistoContent   = hptFOR->GetBinContent(b);
      Double_t systUpHistoContent = hptSUR->GetBinContent(b);
      Double_t systDnHistoContent = hptSDR->GetBinContent(b);
      Double_t systDiffUp = fabs( (double) systUpHistoContent - mainHistoContent );
      Double_t systDiffDn = fabs( (double) mainHistoContent - systDnHistoContent );

      // use average error for histogram
      Double_t systDiff = ( systDiffUp + systDiffDn ) / 2.;
      
      Double_t statErr   = hptFOR->GetBinError(b);
      Double_t combError = sqrt( systDiff * systDiff + statErr * statErr );
      hptFOR->SetBinError(b, combError);
    } //for
  }//if
    
  cPt->SetLogy(1);
  gPad->Update();
  cPt->Update();

  //  hptR->Scale(1,"width");
  //  hptR->SetMinimum(0.02);
  //  hptR->SetMaximum(1000); 
  hptR->GetXaxis()->SetTitle("1^{st} photon p_{T} [GeV]");
  hptR->GetYaxis()->SetTitle("Number of Events / GeV");

  if(isMC) hptR->SetMarkerSize(0);
  if(isMC) hptR->Draw("histE");
  else     hptR->Draw("E X0");


  hptFOR->SetMarkerSize(0);
  hptFOR->SetLineColor(2);
  hptFOR->SetFillColor(2);
  hptFOR->SetFillStyle(3004);
  hptFOR->Draw("same hist ][ E2");

  legend->Clear();
  if(isMC) legend->SetHeader("#gamma/QCD (Sim)");
  else     legend->SetHeader("#gamma/QCD (Data)");
  if(isMC) legend->AddEntry(hptR, "#gamma", "l");
  else     legend->AddEntry(hptR, "#gamma", "p");
  legend->AddEntry(hptFOR, "Pred (from #gamma_{jet})", "f");
  legend->Draw();

  as->DrawLatex(0.17, 0.93, outLumi.c_str() );
  cPt->Update();
  cPt->SetBottomMargin(0.2 + 0.8 * cPt->GetBottomMargin() - 0.2 * cPt->GetTopMargin());

  TPad *ratioPt = new TPad("BottomPad", "", 0, 0, 1, 1);
  ratioPt->SetTopMargin(0.8 - 0.8 * ratioPt->GetBottomMargin() + 0.2 * ratioPt->GetTopMargin());
  ratioPt->SetFillStyle(0);
  ratioPt->SetFrameFillColor(10);
  ratioPt->SetFrameBorderMode(0);
  ratioPt->Draw();

  ratioPt->cd();
  ratioPt->SetLogy(0);

  TH1F *hptRat = (TH1F*) divideHistosForRatio(hptR,hptFOR);
  hptRat->SetMinimum(0.);
  hptRat->SetMaximum(10.);
  hptRat->GetXaxis()->SetNdivisions(505);
  if(isMC) hptRat->GetYaxis()->SetTitle("Sim/Pred");
  else     hptRat->GetYaxis()->SetTitle("Data/Pred");
  hptRat->GetYaxis()->SetTitleSize(0.04);
  hptRat->GetYaxis()->SetLabelSize(0.03);
  hptRat->GetYaxis()->SetTitleOffset(1.3);
  hptRat->GetYaxis()->SetNdivisions(505);
  hptRat->SetMarkerStyle(20);
  hptRat->SetMarkerSize(1);
  hptRat->SetMarkerColor(1);
  hptRat->SetLineColor(1);
  hptRat->Draw("E X0");

  TH1F *hptFRat = (TH1F*) getSystErrForRatio(hptFOR);
  hptFRat->SetLineColor(2);
  hptFRat->SetFillColor(2);
  hptFRat->SetFillStyle(3004);
  hptFRat->Draw("same hist ][ E2");


  TLine * line = new TLine( hptRat->GetXaxis()->GetXmin(), 1., hptRat->GetXaxis()->GetXmax(), 1. );
  line->SetLineColor(1);
  line->SetLineWidth(0.5);
  line->SetLineStyle(1);
  line->Draw("same");

  hptR->GetXaxis()->SetLabelSize(0);
  hptR->GetXaxis()->SetTitle("");
  cPt->RedrawAxis();
  gPad->Update();
  cPt->Update();


  return;
}
开发者ID:vsola,项目名称:RA3SinglePhoton,代码行数:101,代码来源:vs_PlotQCDcomp.C

示例3: compareInDir


//.........这里部分代码省略.........
      pt->Draw();
      cv->cd();
      pD = new TPad("dis","dis", 0, 0.0, 1, 0.93);
      pD->Draw();
      pD->cd();
    }
    
    pD->Clear();
    pD->cd();
    std::cout<<"Save : "<<dirName.c_str()<<"/"<<h1->GetName()<<std::endl;

    if (! isH2){
      h1->SetLineWidth(2);
      h1->SetLineColor(1);
      h1->SetMarkerColor(1);
      h2->SetLineColor(2);
      h2->SetMarkerColor(2);
      //      if (h1->GetNbinsX() > 25) h1 = h1->Rebin();
 //     if (h2->GetNbinsX() > 25) h2 = h2->Rebin();
      //      if (h1->GetNbinsX() > 50) h1 = h1->Rebin(5);
      //      if (h2->GetNbinsX() > 50) h2 = h2->Rebin(5);
      double max1 = h1->GetMaximum();
      double max2 = h2->GetMaximum();
      double min1 = h1->GetMinimum();
      double min2 = h2->GetMinimum();
      if (max2> max1) h1->SetMaximum(max2+0.15*fabs(max2));
      if (min2 < min1) h1->SetMinimum(min2-0.15*fabs(min2));
      //      pD->SetLogy();
      if ((logmod&1)) pD->SetLogx();
      if ((logmod&2)) pD->SetLogy();
      h1->Draw();
      h2->Draw("sames");   

      if (std::string(h1->GetName())==std::string("reconstruction_step_module_total")
	  || std::string(h1->GetName())==std::string("validation_step_module_total")){
	TPaveText ksPt(0,0, 0.35, 0.04, "NDC"); ksPt.SetBorderSize(0); ksPt.SetFillColor(0);
	ksPt.AddText(Form("P(KS)=%g, diffBins=%g, eblk %g ered %g",ksProb, bDiff, h1->GetEntries(), h2->GetEntries()));
	//	ksPt.AddText(h1->GetName());
	ksPt.Draw();
	cv->Print("diff.ps");

	int nX = h1->GetNbinsX();
	TAxis* h1Ax = h1->GetXaxis();
	int nRanges = nX/20 + 1;
	double h1Int = h1->Integral();
	float curBMargin = pD->GetBottomMargin(); 
	pD->SetBottomMargin(0.3);
	for (int iR = 0; iR < nRanges; iR++){
	  h1Ax->SetRange(iR*20+1, iR*20+20);
	  double bDiffL = 0;
	  double max1L = -1;
	  double max2L = -1;
	  double min1L = h1->GetMaximum();
	  double min2L = h2->GetMaximum();
	  for (int iBL = iR*20+1; iBL<= iR*20+20; ++iBL){
	    double h1L = h1->GetBinContent(iBL);
	    double h2L = h2->GetBinContent(iBL);
	    bDiffL += std::abs(h1L-h2L);
	    if (max1L < h1L) max1L = h1L;
	    if (max2L < h2L) max2L = h2L;
	    if (min1L > h1L) min1L = h1L;
	    if (min2L > h2L) min2L = h2L;
	  }
	  if (max2L> max1L)  h1->SetMaximum(max2L+0.15*std::abs(max2L));
	  else h1->SetMaximum(max1L+0.15*std::abs(max1L));
	  if (min2L < min1L) h1->SetMinimum(min2L-0.15*std::abs(min2L));
	  else h1->SetMinimum(min1L-0.15*std::abs(min1L));
	  h1->Draw();
	  h2->Draw("sames");
	  TPaveText ksPtL(0,0, 0.35, 0.04, "NDC"); ksPtL.SetBorderSize(0); ksPtL.SetFillColor(0);
	  ksPtL.AddText(Form("P(KS)=%g, diffBinsL=%g(%g), eblk %g ered %g",ksProb, bDiffL, bDiffL/h1Int, h1->GetEntries(), h2->GetEntries()));
	  ksPtL.Draw();
	  cv->Print("diff.ps");
	}
	pD->SetBottomMargin(curBMargin);

      }
    }
    if (isH2){
      pD->Divide(2);
      pD->cd(1);
      h1->Draw("colz");
      pD->cd(2);
      h2->Draw("colz");
    }
    TPaveText ksPt(0,0, 0.55, 0.06, "NDC"); ksPt.SetBorderSize(0); ksPt.SetFillColor(0);
    ksPt.AddText(Form("P(KS)=%g, diffBins=%g, eblk %g ered %g",ksProb, bDiff, h1->GetEntries(), h2->GetEntries()));
    ksPt.AddText(h1->GetName());
    ksPt.Draw();
    cv->Print("diff.ps");
    cv->Print("diff.pdf");


  }

  //  std::cout<<"Done in "<<dirName.c_str()<<std::endl;
  //  delete pH; delete pD;
  if (cv) delete cv;
  //  cv->Print("diff.ps]");
}
开发者ID:HuguesBrun,项目名称:cms-bot,代码行数:101,代码来源:compareValHists.C

示例4: boostcontrolplots

void boostcontrolplots( TDirectory *boostdir ) {

   const Int_t nPlots = 4;

   Int_t width  = 900;
   Int_t height = 900;
   char cn[100];
   const TString titName = boostdir->GetName();
   sprintf( cn, "cv_%s", titName.Data() );
   TCanvas *c = new TCanvas( cn,  Form( "%s Control Plots", titName.Data() ),
                             width, height ); 
   c->Divide(2,3);


   const TString titName = boostdir->GetName();

   TString hname[nPlots]={"Booster_BoostWeight","Booster_MethodWeight","Booster_ErrFraction","Booster_OrigErrFraction"};

   for (Int_t i=0; i<nPlots; i++){
      Int_t color = 4; 
      TPad * cPad = (TPad*)c->cd(i+1);
      TH1 *h = (TH1*) boostdir->Get(hname[i]);
      TString plotname = h->GetName();
      h->SetMaximum(h->GetMaximum()*1.3);
      h->SetMinimum( 0 );
      h->SetMarkerColor(color);
      h->SetMarkerSize( 0.7 );
      h->SetMarkerStyle( 24 );
      h->SetLineWidth(2);
      h->SetLineColor(color);
      h->Draw();
      c->Update();
   }

   // draw combined ROC plots

   TString hname_roctest[2] ={"Booster_ROCIntegral_test",  "Booster_ROCIntegralBoosted_test"};
   TString hname_roctrain[2]={"Booster_ROCIntegral_train", "Booster_ROCIntegralBoosted_train"};
   TString htitle[2] = {"ROC integral of single classifier", "ROC integral of boosted method"}

   for (Int_t i=0; i<2; i++){
      Int_t color = 4; 
      TPad * cPad = (TPad*)c->cd(nPlots+i+1);
      TH1 *htest  = (TH1*) boostdir->Get(hname_roctest[i]);
      TH1 *htrain = (TH1*) boostdir->Get(hname_roctrain[i]);

      // check if filled 
      Bool_t histFilled = (htest->GetMaximum() > 0 || htrain->GetMaximum() > 0);

      htest->SetTitle(htitle[i]);
      htest->SetMaximum(1.0);
      htest->SetMinimum(0.0);
      htest->SetMarkerColor(color);
      htest->SetMarkerSize( 0.7 );
      htest->SetMarkerStyle( 24 );
      htest->SetLineWidth(2);
      htest->SetLineColor(color);
      htest->Draw();
      htrain->SetMaximum(1.0);
      htrain->SetMinimum(0.0);
      htrain->SetMarkerColor(color-2);
      htrain->SetMarkerSize( 0.7 );
      htrain->SetMarkerStyle( 24 );
      htrain->SetLineWidth(2);
      htrain->SetLineColor(color-2);
      htrain->Draw("same");

      if (histFilled) {
         TLegend *legend= new TLegend( cPad->GetLeftMargin(), 
                                       0.2 + cPad->GetBottomMargin(),
                                       cPad->GetLeftMargin() + 0.6, 
                                       cPad->GetBottomMargin() );
         legend->AddEntry(htest,  TString("testing sample"),  "L");
         legend->AddEntry(htrain, TString("training sample (orig. weights)"), "L");
         legend->SetFillStyle( 1 );
         legend->SetBorderSize(1);
         legend->SetMargin( 0.3 );
         legend->Draw("same");
      }
      else {
         TText* t = new TText();
         t->SetTextSize( 0.056 );
         t->SetTextColor( 2 );
         t->DrawText( 1, 0.6, "Use MethodBoost option: \"DetailedMonitoring\" " );        
         t->DrawText( 1, 0.51, "to fill this histograms" );        
      }

      c->Update();
   }

   // write to file
   TString fname = Form( "plots/%s_ControlPlots", titName.Data() );
   TMVAGlob::imgconv( c, fname );
   
}
开发者ID:CMSAachen3B,项目名称:RWTH3b,代码行数:95,代码来源:BoostControlPlots.C


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