本文整理汇总了C++中TH1::GetZaxis方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1::GetZaxis方法的具体用法?C++ TH1::GetZaxis怎么用?C++ TH1::GetZaxis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1
的用法示例。
在下文中一共展示了TH1::GetZaxis方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawHistsAndGraphs
bool PlotBundle::drawHistsAndGraphs(const PlotStyle &plot_style) const {
if (hasDrawables()) {
std::vector<DrawableDataObjectDrawOptionPair<TH1*> >::const_iterator hist_it;
for (hist_it = histograms.begin(); hist_it != histograms.end();
hist_it++) {
TH1* hist = hist_it->data_object;
std::string draw_option(hist_it->draw_option);
if (hist) {
if (hist->GetDimension() > 1) {
hist->GetZaxis()->SetLimits(plot_axis.z_axis_range.low,
plot_axis.z_axis_range.high);
hist->GetZaxis()->SetRangeUser(plot_axis.z_axis_range.low,
plot_axis.z_axis_range.high);
}
draw_option.append("SAME");
hist->Draw(draw_option.c_str());
}
}
std::vector<DrawableDataObjectDrawOptionPair<TGraph*> >::const_iterator graph_it;
for (graph_it = graphs.begin(); graph_it != graphs.end(); graph_it++) {
TGraph* graph = graph_it->data_object;
std::string draw_option(graph_it->draw_option);
if (graph) {
draw_option.append("SAME");
graph->Draw(draw_option.c_str());
}
}
std::vector<DrawableDataObjectDrawOptionPair<TGraph2D*> >::const_iterator graph2d_it;
for (graph2d_it = graphs2d.begin(); graph2d_it != graphs2d.end();
graph2d_it++) {
TGraph2D* graph = graph2d_it->data_object;
std::string draw_option(graph2d_it->draw_option);
if (graph) {
draw_option.append("SAME");
graph->Draw(draw_option.c_str());
}
}
return true;
} else {
std::cout
<< "Dude, you forgot to add a histogram or graph in the plot bundle..."
<< " Please add at least one and make sure it points to an existing object!"
<< std::endl;
return false;
}
}
示例2: rf705_linearmorph
//.........这里部分代码省略.........
// Upper end point shape: a Polynomial
RooPolynomial g2("g2","g2",x,RooArgSet(RooConst(-0.03),RooConst(-0.001))) ;
// C r e a t e i n t e r p o l a t i n g p d f
// -----------------------------------------------
// Create interpolation variable
RooRealVar alpha("alpha","alpha",0,1.0) ;
// Specify sampling density on observable and interpolation variable
x.setBins(1000,"cache") ;
alpha.setBins(50,"cache") ;
// Construct interpolating pdf in (x,a) represent g1(x) at a=a_min
// and g2(x) at a=a_max
RooIntegralMorph lmorph("lmorph","lmorph",g1,g2,x,alpha) ;
// P l o t i n t e r p o l a t i n g p d f a t v a r i o u s a l p h a
// -----------------------------------------------------------------------------
// Show end points as blue curves
RooPlot* frame1 = x.frame() ;
g1.plotOn(frame1) ;
g2.plotOn(frame1) ;
// Show interpolated shapes in red
alpha.setVal(0.125) ;
lmorph.plotOn(frame1,LineColor(kRed)) ;
alpha.setVal(0.25) ;
lmorph.plotOn(frame1,LineColor(kRed)) ;
alpha.setVal(0.375) ;
lmorph.plotOn(frame1,LineColor(kRed)) ;
alpha.setVal(0.50) ;
lmorph.plotOn(frame1,LineColor(kRed)) ;
alpha.setVal(0.625) ;
lmorph.plotOn(frame1,LineColor(kRed)) ;
alpha.setVal(0.75) ;
lmorph.plotOn(frame1,LineColor(kRed)) ;
alpha.setVal(0.875) ;
lmorph.plotOn(frame1,LineColor(kRed)) ;
alpha.setVal(0.95) ;
lmorph.plotOn(frame1,LineColor(kRed)) ;
// S h o w 2 D d i s t r i b u t i o n o f p d f ( x , a l p h a )
// -----------------------------------------------------------------------
// Create 2D histogram
TH1* hh = lmorph.createHistogram("hh",x,Binning(40),YVar(alpha,Binning(40))) ;
hh->SetLineColor(kBlue) ;
// F i t p d f t o d a t a s e t w i t h a l p h a = 0 . 8
// -----------------------------------------------------------------
// Generate a toy dataset at alpha = 0.8
alpha=0.8 ;
RooDataSet* data = lmorph.generate(x,1000) ;
// Fit pdf to toy data
lmorph.setCacheAlpha(kTRUE) ;
lmorph.fitTo(*data,Verbose(kTRUE)) ;
// Plot fitted pdf and data overlaid
RooPlot* frame2 = x.frame(Bins(100)) ;
data->plotOn(frame2) ;
lmorph.plotOn(frame2) ;
// S c a n - l o g ( L ) v s a l p h a
// -----------------------------------------
// Show scan -log(L) of dataset w.r.t alpha
RooPlot* frame3 = alpha.frame(Bins(100),Range(0.1,0.9)) ;
// Make 2D pdf of histogram
RooNLLVar nll("nll","nll",lmorph,*data) ;
nll.plotOn(frame3,ShiftToZero()) ;
lmorph.setCacheAlpha(kFALSE) ;
TCanvas* c = new TCanvas("rf705_linearmorph","rf705_linearmorph",800,800) ;
c->Divide(2,2) ;
c->cd(1) ; gPad->SetLeftMargin(0.15) ; frame1->GetYaxis()->SetTitleOffset(1.6) ; frame1->Draw() ;
c->cd(2) ; gPad->SetLeftMargin(0.20) ; hh->GetZaxis()->SetTitleOffset(2.5) ; hh->Draw("surf") ;
c->cd(3) ; gPad->SetLeftMargin(0.15) ; frame3->GetYaxis()->SetTitleOffset(1.4) ; frame3->Draw() ;
c->cd(4) ; gPad->SetLeftMargin(0.15) ; frame2->GetYaxis()->SetTitleOffset(1.4) ; frame2->Draw() ;
return ;
}
示例3: csv
void csv(TString input="tmva.csvoutput.txt", TString par1="par2", TString par2="par3", TString par3="", TString value="eventEffScaled_5") {
std::cout << "Usage:" << std::endl
<< ".x scripts/csv.C with default arguments" << std::endl
<< ".x scripts/csv.C(filename, par1, par2, value)" << std::endl
<< std::endl
<< " Optional arguments:" << std::endl
<< " filename path to CSV file" << std::endl
<< " par1 name of X-parameter branch" << std::endl
<< " par2 name of Y-parameter branch (if empty, efficiency is drawn as a function of par1)" << std::endl
<< " value name of result (efficiency) branch" << std::endl
<< std::endl;
TTree *tree = new TTree("data", "data");
tree->ReadFile(input);
gStyle->SetPalette(1);
gStyle->SetPadRightMargin(0.14);
TCanvas *canvas = new TCanvas("csvoutput", "CSV Output", 1200, 900);
tree->SetMarkerStyle(kFullDotMedium);
tree->SetMarkerColor(kRed);
if(par2.Length() > 0) {
//tree->Draw(Form("%s:%s", par2.Data(), par1.Data()));
if(par3.Length() > 0)
tree->Draw(Form("%s:%s:%s:%s", par1.Data(), par2.Data(), par3.Data(), value.Data()), "", "COLZ"); //, "", "Z");
else
tree->Draw(Form("%s:%s:%s", par2.Data(), par1.Data(), value.Data()), "", "COLZ"); //, "", "Z");
TH1 *histo = tree->GetHistogram();
if(!histo)
return;
histo->SetTitle(Form("%s with different classifier parameters", value.Data()));
histo->GetXaxis()->SetTitle(Form("Classifier parameter %s", par1.Data()));
histo->GetYaxis()->SetTitle(Form("Classifier parameter %s", par2.Data()));
if(par3.Length() > 0)
histo->GetZaxis()->SetTitle(Form("Classifier parameter %s", par3.Data()));
else
histo->GetZaxis()->SetTitle("");
if(par3.Length() == 0) {
float x = 0;
float y = 0;
float val = 0;
double maxVal = tree->GetMaximum(value);
double minVal = tree->GetMinimum(value);
tree->SetBranchAddress(par1, &x);
tree->SetBranchAddress(par2, &y);
tree->SetBranchAddress(value, &val);
TLatex l;
l.SetTextSize(0.03);
Long64_t nentries = tree->GetEntries();
for(Long64_t entry=0; entry < nentries; ++entry) {
tree->GetEntry(entry);
l.SetTextColor(textColor(val, maxVal, minVal));
l.DrawLatex(x, y, Form("%.3f", val*100));
}
}
}
else {
tree->Draw(Form("%s:%s", value.Data(), par1.Data()));
TH1 *histo = tree->GetHistogram();
if(!histo)
return;
histo->SetTitle(Form("%s with different classifier parameters", value.Data()));
histo->GetXaxis()->SetTitle(Form("Classifier parameter %s", par1.Data()));
histo->GetYaxis()->SetTitle(value);
}
}
示例4: trigeff
void trigeff(){
gROOT->Reset();
//=========Macro generated from canvas: cEvtSel/EvtSel
//========= (Wed Apr 14 17:19:34 2010) by ROOT version5.22/00d
TCanvas *cEvtSel = new TCanvas("cEvtSel", "EvtSel",550,600);
/*
TCanvas *cEvtSel = new TCanvas("cEvtSel", "EvtSel",0,22,550,600);
gStyle->SetOptFit(1);
gStyle->SetOptStat(0);
cEvtSel->Range(-13.62658,-0.215625,63.58861,1.221875);
cEvtSel->SetFillColor(0);
cEvtSel->SetBorderMode(0);
cEvtSel->SetBorderSize(0);
cEvtSel->SetTickx(1);
cEvtSel->SetTicky(1);
cEvtSel->SetLeftMargin(0.17);
cEvtSel->SetRightMargin(0.04);
cEvtSel->SetTopMargin(0.05);
cEvtSel->SetBottomMargin(0.15);
cEvtSel->SetFrameLineColor(0);
cEvtSel->SetFrameBorderMode(0);
cEvtSel->SetFrameLineColor(0);
cEvtSel->SetFrameBorderMode(0);
*/
TH1 *hFrame1 = new TH2D("hFrame1","",1,-0.5,60.5,1,0,1.15);
hFrame1->SetDirectory(0);
hFrame1->SetStats(0);
hFrame1->GetXaxis()->SetTitle("Charged-particle multiplicity");
hFrame1->GetXaxis()->CenterTitle(true);
hFrame1->GetYaxis()->SetTitle("Selection efficiency");
hFrame1->GetYaxis()->CenterTitle(true);
hFrame1->Draw("");
hFrame1->GetXaxis()->SetNdivisions(312);
/*
TH1 *hFrame1 = new TH2D("hFrame1","",1,-0.5,60.5,1,0,1.15);
hFrame1->SetDirectory(0);
hFrame1->SetStats(0);
hFrame1->SetFillColor(1);
hFrame1->SetFillStyle(0);
hFrame1->SetLineStyle(0);
hFrame1->SetMarkerStyle(20);
hFrame1->SetMarkerSize(1.5);
hFrame1->GetXaxis()->SetTitle("Charged-particle multiplicity");
hFrame1->GetXaxis()->CenterTitle(true);
hFrame1->GetXaxis()->SetNdivisions(312);
hFrame1->GetXaxis()->SetLabelFont(42);
hFrame1->GetXaxis()->SetLabelOffset(0.01);
hFrame1->GetXaxis()->SetLabelSize(0.045);
hFrame1->GetXaxis()->SetTitleSize(0.055);
hFrame1->GetXaxis()->SetTitleFont(42);
hFrame1->GetYaxis()->SetTitle("Selection efficiency");
hFrame1->GetYaxis()->CenterTitle(true);
hFrame1->GetYaxis()->SetLabelFont(42);
hFrame1->GetYaxis()->SetLabelOffset(0.01);
hFrame1->GetYaxis()->SetLabelSize(0.045);
hFrame1->GetYaxis()->SetTitleSize(0.055);
hFrame1->GetYaxis()->SetTitleOffset(1.6);
hFrame1->GetYaxis()->SetTitleFont(42);
hFrame1->GetZaxis()->SetLabelFont(42);
hFrame1->GetZaxis()->SetLabelSize(0.045);
hFrame1->GetZaxis()->SetTitleFont(42);
hFrame1->Draw("");
*/
TH1 *trigeff = new TH1D("trigeff","trigeff",200,0,200);
trigeff->SetBinContent(1,0.007879584);
trigeff->SetBinContent(2,0.3524112);
trigeff->SetBinContent(3,0.5050529);
trigeff->SetBinContent(4,0.5978595);
trigeff->SetBinContent(5,0.6587795);
trigeff->SetBinContent(6,0.7034895);
trigeff->SetBinContent(7,0.7451056);
trigeff->SetBinContent(8,0.7911818);
trigeff->SetBinContent(9,0.8363224);
trigeff->SetBinContent(10,0.873251);
trigeff->SetBinContent(11,0.9012649);
trigeff->SetBinContent(12,0.9177872);
trigeff->SetBinContent(13,0.9395182);
trigeff->SetBinContent(14,0.9502278);
trigeff->SetBinContent(15,0.9600504);
trigeff->SetBinContent(16,0.9667429);
trigeff->SetBinContent(17,0.9722969);
trigeff->SetBinContent(18,0.977478);
trigeff->SetBinContent(19,0.9801504);
trigeff->SetBinContent(20,0.9840849);
trigeff->SetBinContent(21,0.9843521);
trigeff->SetBinContent(22,0.9856779);
trigeff->SetBinContent(23,0.9894354);
trigeff->SetBinContent(24,0.9892805);
trigeff->SetBinContent(25,0.9913111);
trigeff->SetBinContent(26,0.9934833);
trigeff->SetBinContent(27,0.9907814);
trigeff->SetBinContent(28,0.9928126);
trigeff->SetBinContent(29,0.990099);
//.........这里部分代码省略.........
示例5: diffrac
void diffrac(){
gROOT->Reset();
//gROOT->ProcessLine(".x rootlogon.C");
//=========Macro generated from canvas: cEvtSel/EvtSel
//========= (Wed Apr 14 17:19:02 2010) by ROOT version5.22/00d
TCanvas *cEvtSel = new TCanvas("cEvtSel", "EvtSel",550,600);
/*
TCanvas *cEvtSel = new TCanvas("cEvtSel", "EvtSel",0,22,550,600);
gStyle->SetOptFit(1);
gStyle->SetOptStat(0);
cEvtSel->Range(-32.99367,-0.009375,158.1456,0.053125);
cEvtSel->SetFillColor(0);
cEvtSel->SetBorderMode(0);
cEvtSel->SetBorderSize(0);
cEvtSel->SetTickx(1);
cEvtSel->SetTicky(1);
cEvtSel->SetLeftMargin(0.17);
cEvtSel->SetRightMargin(0.04);
cEvtSel->SetTopMargin(0.05);
cEvtSel->SetBottomMargin(0.15);
cEvtSel->SetFrameLineColor(0);
cEvtSel->SetFrameBorderMode(0);
cEvtSel->SetFrameLineColor(0);
cEvtSel->SetFrameBorderMode(0);
*/
//TH1 *hFrame2 = new TH2D("hFrame2","",1,-0.5,60.5,1,0,0.06);
TH1 *hFrame2 = new TH2D("hFrame2","",1,-0.5,150.5,1,0,0.05);
hFrame2->SetDirectory(0);
hFrame2->SetStats(0);
hFrame2->GetXaxis()->SetTitle("Charged-particle multiplicity");
hFrame2->GetXaxis()->CenterTitle(true);
hFrame2->GetYaxis()->SetTitle("Fraction of events");
hFrame2->GetYaxis()->CenterTitle(true);
hFrame2->GetYaxis()->SetTitleOffset(1.5);
hFrame2->Draw("");
hFrame2->GetXaxis()->SetNdivisions(312);
hFrame2->GetYaxis()->SetNdivisions(305);
/*
TH1 *hFrame2 = new TH2D("hFrame2","",1,-0.5,150.5,1,0,0.05);
hFrame2->SetDirectory(0);
hFrame2->SetStats(0);
hFrame2->SetFillColor(1);
hFrame2->SetFillStyle(0);
hFrame2->SetLineStyle(0);
hFrame2->SetMarkerStyle(20);
hFrame2->SetMarkerSize(1.5);
hFrame2->GetXaxis()->SetTitle("Charged-particle multiplicity");
hFrame2->GetXaxis()->CenterTitle(true);
hFrame2->GetXaxis()->SetNdivisions(312);
hFrame2->GetXaxis()->SetLabelFont(42);
hFrame2->GetXaxis()->SetLabelOffset(0.01);
hFrame2->GetXaxis()->SetLabelSize(0.045);
hFrame2->GetXaxis()->SetTitleSize(0.055);
hFrame2->GetXaxis()->SetTitleFont(42);
hFrame2->GetYaxis()->SetTitle("Fraction of events");
hFrame2->GetYaxis()->CenterTitle(true);
hFrame2->GetYaxis()->SetLabelFont(42);
hFrame2->GetYaxis()->SetLabelOffset(0.01);
hFrame2->GetYaxis()->SetLabelSize(0.045);
hFrame2->GetYaxis()->SetTitleSize(0.055);
hFrame2->GetYaxis()->SetTitleOffset(1.5);
hFrame2->GetYaxis()->SetTitleFont(42);
hFrame2->GetZaxis()->SetLabelFont(42);
hFrame2->GetZaxis()->SetLabelSize(0.045);
hFrame2->GetZaxis()->SetTitleFont(42);
hFrame2->Draw("");
*/
TH1 *diffrac = new TH1D("diffrac","diffrac",200,0,200);
diffrac->SetBinContent(1,0.0004697663);
diffrac->SetBinContent(2,0.008010118);
diffrac->SetBinContent(3,0.0127921);
diffrac->SetBinContent(4,0.01698988);
diffrac->SetBinContent(5,0.02012166);
diffrac->SetBinContent(6,0.022341);
diffrac->SetBinContent(7,0.02315105);
diffrac->SetBinContent(8,0.02518068);
diffrac->SetBinContent(9,0.02668032);
diffrac->SetBinContent(10,0.02875512);
diffrac->SetBinContent(11,0.03089617);
diffrac->SetBinContent(12,0.0324741);
diffrac->SetBinContent(13,0.03311853);
diffrac->SetBinContent(14,0.03265478);
diffrac->SetBinContent(15,0.03213081);
diffrac->SetBinContent(16,0.03054987);
diffrac->SetBinContent(17,0.0283245);
diffrac->SetBinContent(18,0.02640026);
diffrac->SetBinContent(19,0.02394001);
diffrac->SetBinContent(20,0.02234401);
diffrac->SetBinContent(21,0.02026921);
diffrac->SetBinContent(22,0.01865213);
diffrac->SetBinContent(23,0.01720369);
diffrac->SetBinContent(24,0.01639665);
diffrac->SetBinContent(25,0.01546013);
//.........这里部分代码省略.........
示例6: makePlots
//.........这里部分代码省略.........
////////////////////
/// deltaPhiBin
name = "deltaPhiBin";
TCanvas * deltaPhiBin = new TCanvas(name, name);
deltaPhiBin->cd();
TH1* dphibin = d2->Get(name);
dphibin->SetLineWidth(2);
dphibin->Draw("text");
dphibin->Draw("same");
deltaPhiBin->SaveAs( name + ".png" );
////////////////////
/// deltaPhi
name = "deltaPhi";
TCanvas * deltaPhi = new TCanvas(name, name);
deltaPhi->cd();
TH1* dphi = d2->Get(name);
dphi->SetLineWidth(2);
dphi->Draw();
deltaPhi->SaveAs( name + ".png" );
////////////////////
/// deltaPhiDt
name = "deltaPhiDt";
TCanvas * deltaPhiDt = new TCanvas(name, name);
deltaPhiDt->cd();
TH1* dphiDt = d005->Get(name);
dphiDt->SetLineWidth(2);
dphiDt->Draw();
deltaPhiDt->SaveAs( name + ".png" );
/////////////////////////
/// rpcInHitsPerDtseg
name = "rpcInHitsPerDtseg";
TCanvas * rpcInHitsPerDtseg = new TCanvas(name, name);
rpcInHitsPerDtseg->SetGridy();
rpcInHitsPerDtseg->SetLogy();
rpcInHitsPerDtseg->cd();
TH1* rpcin = d005->Get(name);
rpcin->SetLineWidth(2);
rpcin->Draw();
rpcInHitsPerDtseg->SaveAs( name + "_dphi0.05.png" );
/////////////////////////
/// rpcOutHitsPerDtseg
name = "rpcOutHitsPerDtseg";
TCanvas * rpcOutHitsPerDtseg = new TCanvas(name, name);
rpcOutHitsPerDtseg->SetGridy();
rpcOutHitsPerDtseg->SetLogy();
rpcOutHitsPerDtseg->cd();
TH1* rpcout = d005->Get(name);
rpcout->SetLineWidth(2);
rpcout->Draw();
rpcOutHitsPerDtseg->SaveAs( name + "_dphi0.05.png" );
////////////////////
/// dtQuality_st1
name = "dtQuality_st1";
TCanvas * dtQuality_st1 = new TCanvas(name, name);
dtQuality_st1->SetGridx();
dtQuality_st1->SetGridy();
dtQuality_st1->cd();
// dtQuality_st1->SetLogz();
TH1* qual_st1 = d005->Get(name);
qual_st1->GetZaxis()->SetRangeUser( 0., 1. );
qual_st1->SetStats( 0 );
qual_st1->Draw("colztext");
dtQuality_st1->SaveAs( name + "_dphi0.05.png" );
////////////////////
/// dtQuality_st2
name = "dtQuality_st2";
TCanvas * dtQuality_st2 = new TCanvas(name, name);
dtQuality_st2->SetGridx();
dtQuality_st2->SetGridy();
dtQuality_st2->cd();
// dtQuality_st2->SetLogz();
TH1* qual_st2 = d005->Get(name);
qual_st2->GetZaxis()->SetRangeUser( 0., 1. );
qual_st2->SetStats( 0 );
qual_st2->Draw("colztext");
dtQuality_st2->SaveAs( name + "_dphi0.05.png" );
////////////////////
/// dtQualityNew
name = "dtQualityNew";
TCanvas * dtQualityNew = new TCanvas(name, name);
dtQualityNew->SetGridx();
dtQualityNew->SetGridy();
dtQualityNew->cd();
// dtQualityNew->SetLogz();
TH1* qualNew = d005->Get(name);
qualNew->GetZaxis()->SetRangeUser( 0., 0.5 );
qualNew->SetStats( 0 );
qualNew->Draw("colztext");
dtQualityNew->SaveAs( name + "_dphi0.05.png" );
}