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


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

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


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

示例1: ProcEvent

void ProcEvent(Int_t event, Int_t px, Int_t py, TObject *sel)
{
   //  print event type and current cursor position


   TCanvas *c = (TCanvas *) gTQSender;
   TPad *pad = (TPad *) c->GetSelectedPad();
   
    if(!pad) return;
    gROOT->SetEditHistograms(kFALSE);
    //printf("event=%d, px=%d, py=%d\n", event, px, py);
    //Float_t x = pad->AbsPixeltoX(px);
    //Float_t y = pad->AbsPixeltoY(py);
    //x = pad->PadtoX(x);
    //y = pad->PadtoY(y);
    //printf("x=%.3g, y=%.3g\n",x,y);
   if(event==kButton1Double){ 
     pad->Pop();
     //printf("%s %d\n",pad->GetName(),pad->GetNumber());
     pad->cd();
     TCanvas *c_blow;
     TIter next(pad->GetListOfPrimitives());
     if((TCanvas*)gROOT->GetListOfCanvases()->FindObject("c_blow")){
       c_blow=(TCanvas*)gROOT->GetListOfCanvases()->FindObject("c_blow");
       c_blow->Clear();
       //printf("show %d\n",c_blow->GetUniqueID());
       //c_blow->GetCanvasImp()->Show();
       //c_blow->RaiseWindow();
       //c_blow->GetCanvasImp()->RaiseWindow();
       //c_blow->Flush();
       //gVirtualX->RaiseWindow(c_blow->GetUniqueID());
       //c_blow->Show();

     }
     else{
 //      c_blow = new TCanvas("c_blow","blowup",750,0,743,525);
       c_blow = new TCanvas("c_blow","blowup",100,50,600,600);
       c_blow->SetFillColor(10); //white
       //c_blow->ToggleEventStatus();
       //c_blow->SetCrosshair();
       c_blow->Draw();
     }
     c_blow->cd();

     gROOT->SetSelectedPad((TPad*)c_blow);
     TPad *clone =(TPad*)pad->Clone();
     clone->SetPad(0,0,1,1);
     clone->Draw();
     clone->Modified();
     clone->Update();
     c_blow->Show();
  }
}
开发者ID:sbianchin,项目名称:TREK_Offline,代码行数:53,代码来源:ProcEvent.C

示例2: tnail

void tnail(){
  TPad *sel = (TPad*)gPad->GetSelectedPad();
  int px = gPad->GetEventX();
  int py = gPad->GetEventY();
  if (sel && sel != c  && sel != ct) {
    ct->cd();
    TPad *newpad = (TPad*)sel->Clone();
    ct->GetListOfPrimitives()->Add(newpad);
    newpad->SetPad(0,0,1,1);
    selold_tnail = newpad;
    ct->Update();
    ct->cd();
  }
}
开发者ID:arjun-trivedi,项目名称:ana2pi,代码行数:14,代码来源:xsec-tools.092513.pretwoscales.C

示例3: Error

/** 
 * Draw the Poisson estimate of the occupancy in a given ring.
 * 
 * @param p            List 
 * @param d            Detector
 * @param r            Ring
 * 
 * @return The occupancy (in percent)
 *
 * @deprecated Use QATrender instead
 * @ingroup pwglf_forward_scripts_qa
 */
Double_t
DrawRingOccupancy(TList* p, UShort_t d, Char_t r)
{
  if (!p) return 0;

  TList* ring = static_cast<TList*>(p->FindObject(Form("FMD%d%c",d,r)));
  if (!ring) { 
    Error("DrawOccupancy", "List FMD%d%c not found in %s",d,r,p->GetName());
    return 0;
  }
  
  TH1* corr = static_cast<TH1*>(ring->FindObject("occupancy"));
  if (!corr) { 
    Error("DrawRingOccupancy", "Histogram occupancy not found in FMD%d%c",
	  d, r);
    return 0;
  }
  corr->Rebin(4);

  TPad* pad = static_cast<TPad*>(gPad);
  pad->SetGridy();
  pad->SetGridx();
  pad->SetLogy();
  pad->SetFillColor(0);
    pad->SetRightMargin(0.01);
#if 0
  if (d == 3) { 
    pad->SetPad(pad->GetXlowNDC(), pad->GetYlowNDC(), .99, 
		 pad->GetYlowNDC()+pad->GetHNDC());
    pad->SetRightMargin(0.15);
  }
#endif

  corr->Draw("hist");

  TLatex* ltx = new TLatex(.95, .95, Form("FMD%d%c", d, r));
  ltx->SetNDC();
  ltx->SetTextAlign(33);
  ltx->SetTextSize(.08);
  ltx->Draw();

  return corr->GetMean();
}
开发者ID:ktf,项目名称:AliPhysics,代码行数:55,代码来源:DrawOccupancy.C

示例4: plotOutlierModules

//------------------------------------------------------------------------------
void PlotAlignmentValidation::plotOutlierModules(const char *outputFileName, std::string plotVariable,
						 float plotVariable_cut ,int unsigned minHits)
{
 
  Int_t counter=0;
  setNiceStyle();
  
  gStyle->SetOptStat(111111);
  gStyle->SetStatY(0.9);
  //TList treelist=getTreeList();
  
  TCanvas *c1 = new TCanvas("canv", "canv", 800, 500);
  //setCanvasStyle( *c1 );
  outputFile = outputDir +'/'+ outputFileName;   
  c1->Print( (outputFile+'[').Data() ); 
  
  
  c1->Divide(2,1);
  
  TTree *tree= (*sourceList.begin())->getTree();
  TkOffTreeVariables *treeMem = 0; // ROOT will initilise
  tree->SetBranchAddress("TkOffTreeVariables", &treeMem);
  
  
  Long64_t nentries =  tree->GetEntriesFast();
  
  for (Long64_t i = 0; i < nentries; i++){
    
    tree->GetEntry(i);
    float var = 0;
    if (plotVariable == "chi2PerDofX") var =treeMem->chi2PerDofX;
    else if(plotVariable == "chi2PerDofY") var =treeMem->chi2PerDofY;
    else if(plotVariable == "fitMeanX") var =treeMem->fitMeanX;
    else if(plotVariable == "fitMeanY") var =treeMem->fitMeanY;
    else if(plotVariable == "fitSigmaX") var =treeMem->fitSigmaX;
    else if(plotVariable == "fitSigmaY") var =treeMem->fitSigmaY;
    else {
      cout<<"There is no variable "<<plotVariable<<" included in the tree."<<endl;
      break;
    }
//   cout<<"treeMem->entries  "<<treeMem->entries<<endl;  
//  cout<<"var                  "<<var<<endl;
//  cout<<"plotVariable_cut     "<<plotVariable_cut<<endl;
    
    if (var > plotVariable_cut && treeMem->entries > minHits)
      {
	
	TFile *f=(*sourceList.begin())->getFile();//(TFile*)sourcelist->First();
	
	if(f->FindKeyAny(treeMem->histNameX.c_str())!=0){
	  TH1 *h = (TH1*) f->FindKeyAny(treeMem->histNameX.c_str())->ReadObj();//f->FindObjectAny(treeMem->histNameX.c_str());
	  gStyle->SetOptFit(0111);
	  cout<<"hist name "<<h->GetName()<<endl;
	  
	  TString path =(char*)strstr( gDirectory->GetPath(), "TrackerOfflineValidation" );
	  //cout<<"hist path "<<path<<endl;
	  //cout<<"wrote text "<<endl;
	  if(h) cout<<h->GetEntries()<<endl;
	  
	  //modules' location as title
	  c1->cd(0);
	  TPaveText * text=new TPaveText(0,0.95,0.99,0.99);
	  text->AddText(path);
	  text->SetFillColor(0);
	  text->SetShadowColor(0);
	  text->SetBorderSize( 0 );
	  text->Draw();
	  
	  //residual histogram
	  c1->cd(1);
	  TPad *subpad = (TPad*)c1->GetPad(1);
	  subpad->SetPad(0,0,0.5,0.94);
	  h->Draw();
	  
	  //norm. residual histogram
	  h = (TH1*) f->FindObjectAny(treeMem->histNameNormX.c_str());
	  if(h) cout<<h->GetEntries()<<endl;
	  c1->cd(2);
	  TPad *subpad2 = (TPad*)c1->GetPad(2);
	  subpad2->SetPad(0.5,0,0.99,0.94);
	  h->Draw();
	  
	  c1->Print(outputFile);
	  counter++;
	}
	else{
	  cout<<"There are no residual histograms on module level stored!"<<endl;
	  cout<<"Please make sure that moduleLevelHistsTransient = cms.bool(False) in the validation job!"<<endl;
	  break;
	}
      }
    
  }
  c1->Print( (outputFile+"]").Data() );
  if (counter == 0) cout<<"no bad modules found"<<endl;
  
  
  //read the number of entries in the t3
  //TTree* tree=0;
//.........这里部分代码省略.........
开发者ID:HeinerTholen,项目名称:cmssw,代码行数:101,代码来源:PlotAlignmentValidation.C

示例5: RooFitMacro


//.........这里部分代码省略.........
    //RooFitResult* filters = model.fitTo(dh, "mhe");
    //RooFitResult* filters = cb.fitTo(dh,Range(0,200),"qr");
    //RooFitResult* filters = bw.fitTo(dh,Range(0,100),"qr");
    //RooFitResult* filters = bag.fitTo(dh,"qr");


    TCanvas* canvas = new TCanvas("ZmassHisto","ZmassHisto",0, 0, 1000,700) ;
    canvas->cd() ; //gPad->SetLeftMargin(0.15);
    //gPad->SetLogy();
    RooPlot* frame = x.frame(Title("e #gamma invariant mass fit")) ;
    dh.plotOn(frame,MarkerSize(0.5),Name("data_hist"));  //this will show histogram data points on canvas

    dh.statOn(frame,Layout(0.15,0.37,0.85),What("N")) ;


    //dh.statOn(frame);  //this will display hist stat on canvas

    //sum.plotOn(frame,LineColor(4));//this will show fit overlay on canvas
    //sum.paramOn(frame); //this will display the fit parameters on canvas

    //bag.plotOn(frame,LineColor(2));//this will show fit overlay on canvas 
    //bag.paramOn(frame); //this will display the fit parameters on canvas

    model.plotOn(frame,Components(bag),LineColor(2));//this will show fit overlay on canvas 
    model.plotOn(frame,Components(signal),LineColor(3));//this will show fit overlay on canvas 
    model.plotOn(frame,LineColor(kBlue),Name("main_curve"));//this will show fit overlay on canvas 

    //	model.paramOn(frame); //this will display the fit parameters on canvas
    model.paramOn(frame, Layout(0.6, 0.95, 0.92)); //this will display the fit parameters on canvas
    //model.paramOn(frame, Layout(0.6, 0.99, 0.75));
    //	model.plotOn(frame,LineColor(4));//this will show fit overlay on canvas 
    //	model.paramOn(frame); //this will display the fit parameters on canvas

    RooHist* histogram = frame->getHist("data_hist");
    RooCurve* curve = frame->getCurve("main_curve");
    TH1D* hresidual  = residualHist(histogram,curve);
    hresidual->Sumw2();
    canvas->Divide( 1, 2, .1, .1 );
    TPad* padHisto = (TPad*) canvas->cd(1);
    TPad* padResid = (TPad*) canvas->cd(2);
    double small = 0.1;
    padHisto->SetPad( 0., r , 1., 1. );
    padHisto->SetBottomMargin( small );
    padResid->SetPad( 0., 0., 1., r  );
    padResid->SetBottomMargin( 0.3  );
    padResid->SetTopMargin   ( small );
    padHisto->cd();


    //float fitvalue = frame.GetX()[60];
    //Double_t nX = x.getVal();
    //cout << "nX  : " << nX << endl;
    //results->SetBinContent(results->GetXaxis()->FindBin(60), nX);
    //float fitvalue = results->GetBinContent(59);
    //cout << "59.5daki fit value  : " << fitvalue << endl;

    //cb.plotOn(frame,LineColor(2));//this will show fit overlay on canvas 
    //cb.paramOn(frame); //this will display the fit parameters on canvas

    //bw.plotOn(frame,LineColor(4));//this will show fit overlay on canvas 
    //bw.paramOn(frame); //this will display the fit parameters on canvas


    //gPad->SetLogy();
    cout << "chisquare : " << frame->chiSquare() << endl ;

    //cout << "Total Number of events: " << Z_mass->Integral() << endl;
    //cout << "Number of signal events: " << fsig.getVal() *  Z_mass->Integral() << endl;
    //cout << "Number of background events: " << (1 - fsig.getVal()) * Z_mass->Integral() << endl;

    //Draw all frames on a canvas

    //TPaveLabel *label1 = new TPaveLabel(1,500,15,700,"Chisquare:");
    frame->GetXaxis()->SetTitle("Invariant mass w/ NoElectronVeto photon (in GeV/c^{2})");  
    //frame->GetXaxis()->SetTitle("Invariant mass w/ TIGHT photon (in GeV/c^{2})");  
    //frame->GetXaxis()->SetTitleOffset(1.2);
    frame->Draw();
    //float binsize = Z_mass->GetBinWidth(1);
    //char Bsize[50]; 
    //sprintf(Bsize,"Events per %2.2f",binsize);
    //frame->GetYaxis()->SetTitle(Bsize);  
    //frame->GetYaxis()->SetTitleOffset(1.2);
    //results->Sumw2();
    padResid->cd();
    hresidual->Draw();
    Lines( hresidual );
    hresidual->Draw( "SAME" );

    //frame->Draw();
    //results->Draw();

    //canvas->Update();
    //title->Draw("same");
    //hresidual->Draw();

    canvas->SaveAs("pdf_TagAndProbe/ResidualNumerator_binned_negligible_errorfit.pdf");
    //canvas->SaveAs("pdf_TagAndProbe/ResidualDenominator_binned_negligible_errorfit.pdf");


}
开发者ID:cardaci,项目名称:T2TopPlusPhoton,代码行数:101,代码来源:RooFitMacro.C

示例6: makePlot


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

  THStack stack("Background MC","");
  setPlotTitle(stack, lumi);

  // Add all different background MC to this stack
  TLegend *legend= new TLegend(0.5,0.6,0.85,0.85);

  totalBkgMCIntegral = addBackgroundHistos(anaType, histoName, stack, legend, lumi, minIntegral, maxIntegral);


//  if ( histoName=="nMinus1_isolationLeptonH_removedLifetimeCuts" || histoName=="nMinus1_relIsolationLeptonH_removedLifetimeCuts" ) {
//    std::cout << "Integral of background between " << minIntegral << " and " << maxIntegral << " : " << totalBkgMCIntegral << std::endl;
//  }

  // Output histograms to file
  outputFile->cd();

  // Setup canvas
  TCanvas canvas(histoName);
  canvas.cd();
  // Draw one or two pads
  TPad * up = new TPad("u","u",0.01,0.25,0.99,0.99);
  up->SetNumber(1);
  up->Draw();
  TPad * dp = new TPad("d","d",0.01,0.01,0.99,0.25);

  if ( drawRatioPlot ) {
    dp->SetNumber(2);
    dp->UseCurrentStyle();
    dp->Draw();
  }
  else {
    up->SetPad(0.01,0.01,0.99,0.99);
    up->Draw();
  }

  if ( logY ) up->SetLogy();
  canvas.Draw();
  canvas.cd(1);
  up->cd();
  canvas.SetFillColor(kWhite);
  canvas.SetBorderMode(0);


  // Draw background MC
  // There may be zero entries, which will mess up drawing options
  // Not a good fix at the moment
  bool axesExist=false;
  if (totalBkgMCIntegral>0) {
    axesExist=true;

    stack.Draw("HISTE");

    stack.GetXaxis()->SetRangeUser(xMin, xMax);
    stack.SetMaximum(yMax);
    stack.SetMinimum(yMin);
    stack.GetXaxis()->SetTitle(xTitle);
    stack.GetYaxis()->SetTitle("Entries");
  }

  std::cout << "Drawing signal histos" << std::endl;
  // Draw signal MC
  histoSignal1->SetLineStyle(2);
  histoSignal1->SetLineColor(kMagenta+2);
  histoSignal1->SetLineWidth(2);
开发者ID:TENorbert,项目名称:usercode-2,代码行数:67,代码来源:makeAllPlots.C


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