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


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

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


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

示例1: explore_zmass_boost

void explore_zmass_boost()
{
  // Tell root not to draw everything to the screen.
  gROOT->SetBatch();

  //    TString dyfilename         = TString("/home/acarnes/h2mumu/samples/stage1/monte_carlo/bg/stage_1_dy_jetsToLL_asympt50_ALL.root");
  TString dyfilename         = TString("/home/acarnes/h2mumu/samples/stage1/monte_carlo/bg/stage_1_dy_ZToMuMu_asympt50_ALL.root");
  TString datafilename         = TString("/home/acarnes/h2mumu/samples/stage1/data_from_json/Cert_246908-251883_13TeV_PromptReco_Collisions15_JSON_v2/stage_1_doubleMuon_RunBPrompt_MINIAOD.root");

  TString savedir = TString("../png/dy_vs_data/run1cuts_v2_golden_json/dyzmumu/");

  // Initialize the DiMuPlottingSystems for MC and data
  DiMuPlottingSystem* dpsdata = new DiMuPlottingSystem(datafilename);
  DiMuPlottingSystem* dpsdy = new DiMuPlottingSystem(dyfilename);
  addDiMuMassPrimeBranch(dpsdata);
  dpsdata->applyRun1Cuts();
  dpsdy->applyRun1Cuts();

  // Get the 2D histos
  TH2F* hdataZPt = ZMassVsZPtHist2D("data_zpt", "recoCandMassPrime", "(14,0,60,30,87,95)", dpsdata);
  TH2F* hdyZPt = ZMassVsZPtHist2D("dy_zpt", "recoCandMass", "(14,0,60,30,87,95)", dpsdy);

  //overlayTProfiles(TH2F* hdata, TH2F* hdy, TString bininfo, TString savename)
  TProfile* p = overlayTProfiles(hdataZPt, hdyZPt, 90, 92, savedir+"z_mass_vs_z_pt.png");
  gStyle->SetOptFit(0011);
  fitTProfileCustom(p);
  TCanvas* c = new TCanvas();
  c->cd();
  p->Draw("hist c");
  p->Draw("E0 X0 same");
  dpsdata->arrangeStatBox(c);
  c->Draw();
  c->Print("blah2.png");

  // Look at RMS
  c->Clear();
  c->cd();
  c->SetGridx(kTRUE);
  c->SetGridy(kTRUE);
  c->cd();
  TH1F* h = dpsdata->hist1D("recoCandMass", "(100,87,95)", "");
  TH1F* h2 = dpsdata->hist1D("recoCandMassPrime", "(100,87,95)", "");
  h2->SetLineColor(2);
  h->Draw("");
  h2->Draw("same");

  std::cout << "mass  rms: " << h->GetRMS() << std::endl;
  std::cout << "mass' rms: " << h2->GetRMS() << std::endl;
  std::cout << "mass  mean: " << h->GetMean() << std::endl;
  std::cout << "mass' mean: " << h2->GetMean() << std::endl;
  std::cout << "mass  num: " << h->Integral() << std::endl;
  std::cout << "mass' num: " << h2->Integral() << std::endl;

  DiMuPlottingSystem* dps = new DiMuPlottingSystem();
  dps->arrangeStatBox(c);
  c->Draw();
  c->Print("newfit.png");
}
开发者ID:acarnes,项目名称:h2muPlotting,代码行数:58,代码来源:explore_zmass_boost.C

示例2: lstModulesDrawItem

void __fastcall TfrmMainFormServer::lstModulesDrawItem(
      TWinControl *Control, int Index, TRect &Rect, TOwnerDrawState State)
{
    TRect cRect(0, 0, lstModules->Width, lstModules->Height);


    TCanvas*        pCanvas     = ((TListBox*)Control)->Canvas;

    pCanvas->FillRect(Rect);  //This clears the rect

    Graphics::TBitmap* bitmap = new Graphics::TBitmap();
    AnsiString moduleName = lstModules->Items->Strings[Index];

    if(Index == 0){
        imgList->GetBitmap(1, bitmap);    //table image
    }else{
        imgList->GetBitmap(0, bitmap);    //table image
    }

    
    pCanvas->Draw(Rect.Left + 1, Rect.Top, bitmap);
    delete bitmap;

    pCanvas->TextOut(Rect.Left + 22, Rect.Top + 2, moduleName);


}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:27,代码来源:MainFormServer.cpp

示例3: iterateFitter

TF1 * iterateFitter(TH1F * histo, int i, TF1 * previousResiduals = 0, TCanvas * inputCanvas = 0)
{
  TCanvas * canvas = inputCanvas;
  std::stringstream ss;
  int iCanvas = i;
  ss << i;

  int nBins = histo->GetNbinsX();

  TF1 * functionToFit;
  if( previousResiduals == 0 ) {
    // functionToFit = relativisticBWFit(ss.str());
    // functionToFit = relativisticBWintFit(ss.str());
    // functionToFit = relativisticBWintPhotFit(ss.str());
    functionToFit = expRelativisticBWintPhotFit(ss.str());
    // functionToFit = crystalBallFit();
    // functionToFit = reversedCrystalBallFit();
    // functionToFit = lorentzianFit();
    // functionToFit = relativisticBWFit();
  }
  else {
    functionToFit = combinedFit(previousResiduals->GetParameters(), ss.str());
  }
  histo->Fit(functionToFit, "MN", "", 60, 120);


  double xMin = histo->GetXaxis()->GetXmin();
  double xMax = histo->GetXaxis()->GetXmax();
  double step = (xMax-xMin)/(double(nBins));
  TH1F * functionHisto = new TH1F(("functionHisto"+ss.str()).c_str(), "functionHisto", nBins, xMin, xMax);
  for( int i=0; i<nBins; ++i ) {
    functionHisto->SetBinContent( i+1, functionToFit->Eval(xMin + (i+0.5)*step) );
  }

  if( canvas == 0 ) {
    canvas = new TCanvas(("canvasResiduals"+ss.str()).c_str(), ("canvasResiduals"+ss.str()).c_str(), 1000, 800);
    canvas->Divide(2,1);
    canvas->Draw();
    iCanvas = 0;
  }
  canvas->cd(1+2*iCanvas);
  histo->Draw();
  functionToFit->SetLineColor(kRed);
  functionToFit->Draw("same");
  // functionHisto->Draw("same");
  // functionHisto->SetLineColor(kGreen);
  canvas->cd(2+2*iCanvas);
  TH1F * residuals = (TH1F*)histo->Clone();
  residuals->Add(functionHisto, -1);
  residuals->SetName("Residuals");

  // TF1 * residualFit = new TF1("residualFit", "-[0] + [1]*x+sqrt( ([1]-1)*([1]-1)*x*x + [0]*[0] )", 0., 1000. );
  // TF1 * residualFit = new TF1("residualFit", "[0]*(x - [1])/([2]*x*x + [3]*x + [4])", 0., 1000. );
  TF1 * residualFitFunction = residualFit(ss.str());
  residuals->Fit(residualFitFunction, "ME", "", 90.56, 120);

  residuals->Draw();

  return residualFitFunction;
}
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:60,代码来源:ProbsFitter.C

示例4: improveHisto

void improveHisto(TFile * inputFile, const TString & histoName, TFile * inputFile2, const TString & histoName2)
{
  TH1F * histo = (TH1F*)inputFile->FindObjectAny(histoName);
  TCanvas * canvas = new TCanvas();
  canvas->Draw();
  histo->Draw();
  histo->GetXaxis()->SetTitle("#eta");
  histo->GetXaxis()->SetTitleOffset(1.1);
  histo->GetXaxis()->SetRangeUser(-1.5, 1.5);
  double binWidth = histo->GetXaxis()->GetBinWidth(1);
  stringstream ss;
  ss << binWidth;
  histo->GetYaxis()->SetTitle(TString("Efficiency/("+ss.str()+")"));
  histo->GetYaxis()->SetTitleOffset(1.1);
  histo->GetYaxis()->SetRangeUser(0., 1.1);
  TH1F * histo2 = (TH1F*)inputFile2->FindObjectAny(histoName2);
  histo2->Draw("same");
  histo2->SetMarkerColor(kRed);
  TLegend * legend = new TLegend(0.5, 0.67, 0.88, 0.88);
  legend->AddEntry(histo, "top");
  legend->AddEntry(histo2, "bottom");
  legend->Draw("same");
  legend->SetFillColor(kWhite);
  legend->SetBorderSize(0);
  canvas->Write();
}
开发者ID:Hosein47,项目名称:usercode,代码行数:26,代码来源:ImproveEta.C

示例5: improveHisto

void improveHisto(TFile * inputFile, const TString & histoName, const TString & histoName2 = "")
{
    TH1F * histo = (TH1F*)inputFile->FindObjectAny(histoName);
    TCanvas * canvas = new TCanvas();
    canvas->Draw();
    histo->Draw();
    histo->GetXaxis()->SetTitle("|d_{0}| [cm]");
    histo->GetXaxis()->SetTitleOffset(1.1);
    histo->GetXaxis()->SetRangeUser(0., 50.);
    double binWidth = histo->GetXaxis()->GetBinWidth(1);
    stringstream ss;
    ss << binWidth;
    histo->GetYaxis()->SetTitle(TString("Efficiency/("+ss.str()+" cm)"));
    histo->GetYaxis()->SetTitleOffset(1.1);
    histo->GetYaxis()->SetRangeUser(0., 1.1);
    if( histoName2 != "" ) {
        TH1F * histo2 = (TH1F*)inputFile->FindObjectAny(histoName2);
        histo2->Draw("same");
        histo2->SetMarkerColor(kRed);
        TLegend * legend = new TLegend(0.5, 0.67, 0.88, 0.88);
        legend->AddEntry(histo, "cosmicMuons1Leg");
        legend->AddEntry(histo2, "MC truth");
        // TLegend * legend = canvas->BuildLegend();
        legend->Draw("same");
        legend->SetFillColor(kWhite);
        legend->SetBorderSize(0);
    }
    canvas->Write();
}
开发者ID:RemKamal,项目名称:usercode-1,代码行数:29,代码来源:Improve.C

示例6: DrawElementFace

//===========================================================================
void TWave::DrawElementFace()
{
    TCanvas    *dbCanvas = VisualElementParam->Bitmap->Canvas;
    int         aw       = VisualElementParam->Width;
    int         ah       = VisualElementParam->Height;

    dbCanvas->Brush->Color = clWhite;
    dbCanvas->Pen  ->Color = clBlack;

    dbCanvas->Rectangle(0, 0, aw, ah);

    // --------- Отрисовка прямоугольника --- (прямокгольник процесса разработки) -----
    if (DesignPhase != dpAllreadyTesting) {
        if (DesignPhase == dpNotTesting  ) {
            dbCanvas->Pen  ->Color = clRed;
        }
        if (DesignPhase == dpNeedModified) {
            dbCanvas->Pen  ->Color = clRed;
            dbCanvas->Pen  ->Style = psDot;
        }

        dbCanvas->Rectangle(2, 2, VisualElementParam->Width - 2, VisualElementParam->Height - 2);

        dbCanvas->Pen->Color = clBlack;
        dbCanvas->Pen->Style = psSolid;
    }
    // -------------- Отрисовка ресурса если он есть ----------
    dbCanvas->Draw((aw - ResourseBitmapFaceElement->Width) / 2, (ah - ResourseBitmapFaceElement->Height) / 2,ResourseBitmapFaceElement);
}
开发者ID:Medcheg,项目名称:sources_old,代码行数:30,代码来源:M_Wave.cpp

示例7: makePassFail_QCDMC

void makePassFail_QCDMC(const string njetlabel= "XX")
{

	//dphioption == 0 for dphimin<0.2

	

	vector<string> folders, htbinlabels, dphibins;
	folders.push_back("Hist/HT0to500MHT0to7000");
	folders.push_back("Hist/HT500to7000MHT0to7000");
	//folders.push_back("Hist/HT500to900MHT0to7000");
	//folders.push_back("Hist/HT900to1300MHT0to7000");
	//folders.push_back("Hist/HT1300to7000MHT0to7000");

	htbinlabels.push_back("HT0to500");
	htbinlabels.push_back("HT500to900");
	htbinlabels.push_back("HT900to1300");
	htbinlabels.push_back("HT1300to7000");

	dphibins.push_back("0.15");
	dphibins.push_back("0.20");
	dphibins.push_back("0.25");
	dphibins.push_back("0.30");
	dphibins.push_back("0.35");
	dphibins.push_back("0.40");

	OpenFiles();
	TCanvas *c = new TCanvas("print");	
	c->Draw();
	c->Print("ratios.eps[");
	
	for (unsigned d = 0; d < dphibins.size(); ++d)
	{	
		for (unsigned i = 0; i < folders.size(); ++i)
		{	
//			for (unsigned j = 0; j < htbinlabels.size(); ++j)
			{
				string htrange("");
				if (i==0) htrange += "0<HT<500 GeV";
				else if (i==1) htrange += "500<HT<7000 GeV";
				//else if (i==1) htrange += "500<HT<900 GeV";
				//else if (i==2) htrange += "900<HT<1300 GeV";
				//else if (i==3) htrange += "1300<HT<7000 GeV";

				cout << " >>>>>>>>>>> " << htrange << endl; 
				stringstream title, numeHistName, denoHistName, signalHistName, controlHistName;
				//title << htrange << ";#slash{H}_{T};Ratio (r) = Pass(RA2 dPhi cuts) / Fail(#Delta #phi_{min}< 0.2);";
				title << "Njet " << njetlabel << ", " << htrange << ", #Delta #Phi _{min}<" << dphibins.at(d);
				numeHistName << folders.at(i) << "/signal";
				//denoHistName << folders.at(i) << "/fail1";
				denoHistName << folders.at(i) << "/fail" << d;
				signalHistName << folders.at(i) << "/signalFineBin";
				controlHistName << folders.at(i) << "/failFineBin" << d;
				makePassFail_QCDMC(numeHistName.str(), denoHistName.str(), title.str(), htbinlabels.at(i), signalHistName.str(), controlHistName.str()); 
			}
		}
	}
	c->Print("ratios.eps]");
}
开发者ID:hkaushalya,项目名称:UserCode,代码行数:59,代码来源:makePassFail_QCDMC.C

示例8: comparecfback

void comparecfback(TString file1, TString file2, TString histname1, TString histname2, TString histname3,TString sys) {

  TFile* ifile1_ = new TFile(Form("%s",file1.Data()), "read");
  TFile* ifile2_ = new TFile(Form("%s",file2.Data()), "read");

  TH1D* hist1;
  TH1D* hist2;
  TH1D* hist3;

  // if ( (strcmp(sys,"V0LL") == 0) || (strcmp(sys,"V0ALAL") == 0) || (strcmp(sys,"V0LAL") == 0)  ) {
  //   hist1 = (TH1D*)ifile1_->Get(Form("Numcqinv%stpcM%d%s",sys,mult,kT));
  //   hist2 = (TH1D*)ifile2_->Get(Form("Numcqinv%stpcM%d%s",sys,mult,kT));
  // }
  // else {
  hist1 = (TH1D*)ifile1_->Get(Form("%s",histname1.Data()));
  hist2 = (TH1D*)ifile2_->Get(Form("%s",histname2.Data()));
  hist3 = (TH1D*)ifile2_->Get(Form("%s",histname3.Data()));
  // }

  TCanvas *myCan = new TCanvas("asd","asd");
  myCan->Draw();
  myCan->cd();
  hist1->SetMarkerColor(kBlack);
  hist2->SetMarkerColor(kRed);
  hist3->SetMarkerColor(kBlue);
  hist1->SetMarkerStyle(20);
  hist2->SetMarkerStyle(20);
  hist3->SetMarkerStyle(20);
  hist1->SetMarkerSize(1.6);
  hist2->SetMarkerSize(1.6);
  hist3->SetMarkerSize(1.6);
  hist1->SetTitle("");
  hist1->GetXaxis()->SetRangeUser(0.,1.0);
  hist2->GetXaxis()->SetRangeUser(0.,1.0);
  hist3->GetXaxis()->SetRangeUser(0.,1.0);
  gStyle->SetOptStat(0);

  //hist1->Scale(1./1.026);//1.026, 1.05

    hist1->SetMaximum(1.015);
  hist1->SetMinimum(0.9425);
  hist1->GetXaxis()->SetTitleSize(0.05);
  hist1->GetYaxis()->SetTitleSize(0.05);
  hist1->Draw("p");
  hist2->Draw("psame");
  hist3->Draw("psame");
  TLatex Tl;
  Tl.SetTextAlign(23);
  Tl.SetTextSize(0.08);
  Tl.SetTextColor(kBlack);
  Tl.DrawLatex(0.5,0.995,"p#bar{p}");
  Tl.SetTextColor(kRed);
  Tl.DrawLatex(0.5,0.980,"p#bar{#Lambda}");
  Tl.SetTextColor(kBlue);
  Tl.DrawLatex(0.5,0.965,"#bar{p}#Lambda");

  myCan->SaveAs(Form("comp%s.eps",sys.Data()));
}
开发者ID:maszyman,项目名称:FitBaryonAntibaryon,代码行数:58,代码来源:comparecfback.C

示例9: compare_weights

void compare_weights() {
  TFile pwhg("POWHEG/ee/ee_ttbarsignalplustau_pwhgbox_m172p5.root");
  TFile pwhg_pos("POWHEG/ee/ee_ttbarsignalplustau_pwhgbox_m172p5_posweights.root");
  TFile output("comparison_pwhg_weights.root","recreate");

  gDirectory->pwd();

  std::vector<std::string> histograms;

  histograms.push_back("VisGenTTBarpT"); // TTBar system pT
  histograms.push_back("VisGenTTBarMass"); // TTBar system Mass
  histograms.push_back("VisGenTTBarRapidity"); // TTBar Rapidity
  histograms.push_back("VisGenLeptonpT"); // Lepton pT
  histograms.push_back("VisGenLeptonEta"); // Lepton Eta
  histograms.push_back("VisGenBJetpT"); // BJet pT
  histograms.push_back("VisGenBJetRapidity"); // BJet Rapidity
  //histograms.push_back("VisGenJetMulti"); // Jet Multiplicity
  histograms.push_back("VisGenExtraJetpT"); // Additional Jet pT
  histograms.push_back("VisGenTTBar1stJetMass"); // Invariant Mass TTBar+1Jet  

  for(std::vector<std::string>::iterator hist = histograms.begin(); hist != histograms.end(); hist++) {
    
    std::cout << "Plotting " << (*hist) << "..." << std::endl;
    
    TCanvas *c = new TCanvas(hist->c_str(), hist->c_str());
    TH1D *sample_powhegbox = (TH1D*)pwhg.Get(hist->c_str());
    TH1D *sample_pwhg_pos = (TH1D*)pwhg_pos.Get(hist->c_str());
    sample_pwhg_pos->Scale(1/sample_pwhg_pos->Integral(),"width");
    sample_powhegbox->Scale(1/sample_powhegbox->Integral(),"width");

    bool rebin = true;
    
    if(rebin) {
      Int_t rebinning = 4;
      if((*hist) == "VisGenTTBar1stJetMass") { rebinning *= 4; }
      if((*hist) == "VisGenTTBarRapidity") { rebinning /= 2; }
      if((*hist) == "VisGenTTBarpT") { rebinning *= 10; }
      if((*hist) == "VisGenTTBarMass") { rebinning = 20; }

      sample_powhegbox->Rebin(rebinning);
      sample_pwhg_pos->Rebin(rebinning);
    }

    sample_powhegbox->Draw();
    sample_pwhg_pos->SetLineColor(kRed);
    sample_pwhg_pos->Draw("same");

    TLegend *leg = new TLegend(0.6,0.6,0.9,.9);
    leg->AddEntry(sample_powhegbox,"withnegweights 1","l");
    leg->AddEntry(sample_pwhg_pos,"withnegweights 0","l");
    leg->Draw();

    c->Draw();
    c->Write();
  }
}
开发者ID:simonspa,项目名称:topmassextractor,代码行数:56,代码来源:compare_weights.C

示例10: flipPCB

//______________________________________________________________________________
void flipPCB(const char* srcName)
{
  // flip PCB in X-direction

//  AliMpSlatMotifMap* srcMotifs = new AliMpSlatMotifMap;
//  AliMpSlatMotifMap* destMotifs = new AliMpSlatMotifMap;

  AliMpDataProcessor mp;
  AliMpDataMap* dataMap = mp.CreateDataMap("data");
  AliMpDataStreams dataStream(dataMap);
  
  AliMpSt345Reader reader(dataStream);

  AliMpPCB* src = reader.ReadPCB(srcName);
  
  if (!src) return;

  AliMpSlatMotifMap* destMotifs = reader.MotifMap();
  
  AliMpPCB* dest = flipX(*src,*destMotifs);
    
  if (!dest)
  {
    cout << "Flipping failed" << endl;
  }
  
  TCanvas* csrc = new TCanvas("src","src");
  csrc->Draw();
  AliMpVPainter* psrc = AliMpVPainter::CreatePainter(src);
  psrc->Draw("MZT");

  if ( dest ) 
  {
    TCanvas* cdest = new TCanvas("dest","dest");
    cdest->Draw();
    AliMpVPainter* pdest = AliMpVPainter::CreatePainter(dest);
    pdest->Draw("MZT");
    dest->Save();

  }
  
}
开发者ID:alisw,项目名称:AliRoot,代码行数:43,代码来源:flipPCB.C

示例11: plot

TCanvas * plot (TH1F* histoDataIn, TString legendData, TH1F* histoSimulationIn, TString legendSimulation,
                TString & canvasName, Float_t maximum = 0.15, TString xAxisTitle = "#eta",
                TString yAxisTitle = "Number of Clusters", TString error = "", bool useLegend = true,
                TString text = "", Float_t textX = 0.7, Float_t textY = 0.4, Float_t rebin = 0 ) {

  TH1F * histoData = (TH1F*)histoDataIn->Clone();
  TH1F * histoSimulation = (TH1F*)histoSimulationIn->Clone();

  // histoData->Sumw2();
  histoData->Scale(1/(histoData->Integral()));
  histoSimulation->Scale(1/(histoSimulation->Integral()));

  // Create also the legend and add the histograms
  TLegend * legend = new TLegend( 0.55, 0.65, 0.76, 0.82 );
  legend->AddEntry( histoData, xAxisTitle );
  legend->AddEntry( histoSimulation, yAxisTitle, "F" );

  cout << "histoData = " << histoData << endl;
  cout << "histoSimulation = " << histoSimulation << endl;

  TCanvas * c = new TCanvas( canvasName, canvasName, 1000, 800 );
  c->Draw();

  histoSimulation->SetMaximum(maximum);

  histoSimulation->SetFillColor(kRed);
  // histoSimulation->SetLineWidth(0);
  histoSimulation->SetLineColor(kRed);
  histoSimulation->SetXTitle(xAxisTitle);
  histoSimulation->SetYTitle(yAxisTitle);
  histoSimulation->SetTitleOffset(1.6,"Y");
  histoSimulation->SetTitle();

  histoData->SetLineStyle(1);
  histoData->SetLineWidth(2.5);

  histoSimulation->Draw();
  histoData->Draw("same");

  legend->SetFillColor(kWhite);
  if (useLegend) legend->Draw("same");

  if ( text != "" ) {
    TPaveText * pt = new TPaveText(textX, textY, textX+0.2, textY+0.17, "NDC" ); // "NDC" option sets coords relative to pad dimensions
    pt->SetFillColor(0); // text is black on white
    pt->SetTextSize(0.08); 
    pt->SetBorderSize(0);
    pt->SetTextAlign(12);
    pt->AddText(text);
    pt->Draw("same");       //to draw your text object
  }

  return c;
};
开发者ID:Hosein47,项目名称:usercode,代码行数:54,代码来源:plot.C

示例12: main

int main( int argc, char **argv ) {

  cout << endl;
  cout << " ** QuickHist 0.0.1 beta" << endl;
  cout << " ** If you want colors, comment out the gStyle option and recompile." << endl;
  cout << " ** Exit with ctrl-c" << endl;
  cout << endl;
    

  TApplication theApp("App", &argc, argv);
  gROOT->Reset();
  gROOT->SetStyle( "Plain" );
//  gStyle->SetFillColor( 0 );

   
  double buffer;
  vector<double> numbersVector;



  while( ! cin.eof() ) {
    cin >> buffer;
    if( cin.eof() ) break; // break if eof
    numbersVector.push_back( buffer );
  }


  double lowerLimit = 0.;
  double upperLimit = 0.;
  double lowerLimitBuf = numbersVector[0]; 
  double upperLimitBuf = numbersVector[0];

  for( unsigned int i = 0; i < numbersVector.size(); i++ ) {
    if( numbersVector[i] < lowerLimitBuf ) lowerLimitBuf = numbersVector[i];
    if( numbersVector[i] > upperLimitBuf ) upperLimitBuf = numbersVector[i];
  }
  
  // broadening the limits a little bit
  upperLimit = upperLimitBuf + .1 * ( upperLimitBuf - lowerLimitBuf );
  lowerLimit = lowerLimitBuf - .1 * ( upperLimitBuf - lowerLimitBuf );

  TCanvas* canvas = new TCanvas( "QuickHist", "QuickHist" );
  canvas->Draw();

  TH1D* histogram = new TH1D( "QuickHist", "QuickHist", 1000, lowerLimit, upperLimit );
  for( unsigned int i = 0; i < numbersVector.size(); i++ ) histogram->Fill( numbersVector[i] );
  histogram->Draw();


  theApp.Run( kTRUE );

}
开发者ID:edorossi,项目名称:cmstkmodlab,代码行数:52,代码来源:quickhist.C

示例13: canvas_read

void canvas_read()
{
   TFile* f2 = new TSQLFile(dbname, "open", username, userpass);
   if (f2->IsZombie()) { delete f2; return; }

   f2->ls();
   gBenchmark->Start("readSQL");
   TCanvas* cc = (TCanvas*) f2->Get("Canvas");
   gBenchmark->Show("readSQL");
   if (cc!=0) cc->Draw();

   delete f2;
}
开发者ID:MycrofD,项目名称:root,代码行数:13,代码来源:sqlcanvas.C

示例14: printCanvasesPS

// Print all canvases in a single PS file
void printCanvasesPS(TString name){
  TPostScript * ps = new TPostScript(name,112);
  TIter iter(gROOT->GetListOfCanvases());
  TCanvas *c;
  while( (c = (TCanvas *)iter()) )
    {
      cout << "Printing " << c->GetName() << endl;
      ps->NewPage();
      c->Draw();
    }
  cout << " File " << name << " was created" << endl;
  ps->Close();
}
开发者ID:cerminar,项目名称:UserCode,代码行数:14,代码来源:macros.C

示例15: fireball

void fireball(){

  //set-up
  gROOT->Macro("init.C");
  setStyle();

  //ake the plot
  TCanvas *cFire = new TCanvas("cFire", "cFire", 500, 500);
  cFire->Draw();
 
  ellipises();
  arrows1();
}
开发者ID:skymeson,项目名称:root_macros,代码行数:13,代码来源:fireball.C


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