本文整理汇总了C++中TH1::GetYaxis方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1::GetYaxis方法的具体用法?C++ TH1::GetYaxis怎么用?C++ TH1::GetYaxis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1
的用法示例。
在下文中一共展示了TH1::GetYaxis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetTitle
void SetTitle(TH1& h, TString Xtitle, TString Ytitle, TString title){
h.GetXaxis()->SetTitle(Xtitle);
h.GetYaxis()->SetTitle(Ytitle);
h.GetXaxis()->CenterTitle();
h.GetYaxis()->CenterTitle();
h.SetTitle(title);
}
示例2: getHisto
// -----------------------------------------------------------------------------
//
TH1* getHisto( std::string nameFile,
std::string nameHist,
std::string Dirname,
int rebin ) {
std::string name = nameFile;
TFile* file = new TFile(name.c_str());
if (file) { std::cout << "Opened file: " << file->GetName() << std::endl; }
else {
std::cout << "Could not find file: " << name << std::endl;
return 0;
}
TDirectory* dir = (TDirectory*)file->Get(Dirname.c_str());
if (dir) { std::cout << "Opened dir: " << dir->GetName() << std::endl; }
else {
std::cout << "Could not find dir: " << Dirname << std::endl;
return 0;
}
int low = 375;
TH1* hist = 0;
if ( false || nameHist.find("HtMultiplicity_HT375") == std::string::npos ) {
hist = (TH1*)dir->Get(nameHist.c_str());
} else {
for ( uint ii = low; ii <= 975; ii+=100 ) {
std::stringstream tmp; tmp << "HtMultiplicity_HT" << ii << nameHist.substr(20);
if ( !hist ) {
dir->cd();
TH1D* temp = (TH1D*)dir->Get( "HtMultiplicity_HT375_aT0" );
//TH1D* temp = (TH1D*)file->Get( tmp.str().c_str() );
if (temp) { hist = (TH1D*)temp->Clone(); }
else { std::cout << "1 Unable to retrieve histo with name " << tmp.str() << std::endl; }
} else {
dir->cd();
TH1D* temp = (TH1D*)dir->Get( tmp.str().c_str() );
if (temp) { hist->Add( (TH1D*)temp ); }
else { std::cout << "2 Unable to retrieve histo with name " << tmp.str() << std::endl; }
}
}
}
if (hist) { std::cout << "Opened histo: " << hist->GetName() << std::endl; }
else {
std::cout << "Could not find histo: " << nameHist << std::endl;
return 0;
}
hist->SetLineWidth(3);
if ( rebin > 0 ) { hist->Rebin(rebin); }
hist->GetXaxis()->SetTitleSize(0.055);
hist->GetYaxis()->SetTitleSize(0.055);
hist->GetXaxis()->SetLabelSize(0.05);
hist->GetYaxis()->SetLabelSize(0.05);
hist->SetStats(kFALSE);
return hist;
}
示例3: Form
drawGraph( TGraph* gr, const Char_t* ytitle = 0 )
{
gr->Draw( "AP*" );
TH1* h = gr->GetHistogram( );
std::cout << gr->GetMean( ) << std::endl;
gr->Fit( "pol0", "Q", "SAME" );
TF1* fit = gr->GetFunction( "pol0" );
Double_t chi2 = fit->GetChisquare( );
Double_t par0 = fit->GetParameter( 0 );
Double_t err = fit->GetParError( 0 );
TLatex* l = new TLatex;
l->SetNDC( );
l->DrawLatex( 0.85, 0.80, Form( "#splitline{Entries = %i}{RMS = %2.3f}",
gr->GetN(), gr->GetMean(2)) );
TLatex* l2 = new TLatex;
l2->SetNDC( );
l2->DrawLatex( 0.85, 0.7, Form("#splitline{fit = %2.3f#pm%2.3f}{#chi^{2} = %2.3f}",
par0, chi2, err) );
// TLegend* leg = new TLegend( 0.8, 0.9, 0.95, 0.95 );
// leg->SetFillColor( kWhite );
// leg->SetBorderSize( 0 );
// leg->AddEntry( "gr", "CPU+AFAR+MBED+ATWD+AMPS", "P" );
// leg->Draw( );
if( h != 0 )
{
h->GetXaxis()->SetTimeFormat("%m/%d %H:%M");
h->GetXaxis()->SetNdivisions( 10, 10, 0 );
h->GetXaxis()->SetTimeDisplay( 1 );
h->GetXaxis()->SetTitle("Date / Time (UTC)");
h->GetXaxis()->SetLabelSize( 0.06 );
h->GetYaxis()->SetLabelSize(0.07);
h->GetYaxis()->SetTitleSize(0.06);
h->GetXaxis()->SetTitleSize(0.055);
h->GetYaxis()->SetTitleOffset( 0.9 );
h->GetXaxis()->SetTitleOffset( 0.9 );
h->SetMarkerSize( 5 );
if( ytitle != 0 )
{
h->GetYaxis()->SetTitle(ytitle);
}
}
if( gPad != 0 )
{
gPad->Update();
}
}
示例4: SetStyle
void SetStyle(TH1& h, double size, int color, int style, int fillstyle=0, int linestyle=1){
h.SetMarkerSize(size);
h.SetMarkerColor(color);
h.SetLineColor(color);
h.SetMarkerStyle(style);
h.SetFillStyle(fillstyle);
h.SetLineStyle(linestyle);
h.GetXaxis()->SetTitleFont(42);
h.GetYaxis()->SetTitleFont(42);
h.GetXaxis()->SetTitleSize(0.048);
h.GetYaxis()->SetTitleSize(0.048);
h.GetXaxis()->CenterTitle();
h.GetYaxis()->CenterTitle();
}
示例5: set
histoBook* histoBook::set( string param, string p1, string p2, string p3, string p4 ){
// force the param name to lowercase
transform(param.begin(), param.end(), param.begin(), ::tolower);
TH1* h = get( styling );
if ( h ){
if ( "title" == param ){
h->SetTitle( p1.c_str() );
} else if ( "x" == param ){
h->GetXaxis()->SetTitle( p1.c_str() );
} else if ( "y" == param ){
h->GetYaxis()->SetTitle( p1.c_str() );
} else if ( "legend" == param ){
if ( p2 == "")
p2="lpf";
legend->AddEntry( h, p1.c_str(), p2.c_str() );
legend->Draw();
} else if ( "draw" == param ){
drawOption = p1;
}
}
return this;
}
示例6: makeplotThree
void makeplotThree(TH1& hist1, TH1& hist2, TH1& hist3, const char* plotname, int log) {
hist1.SetLineColor(4);
hist1.SetMarkerColor(4);
hist3.SetLineColor(2);
hist3.SetMarkerColor(2);
gStyle->SetOptStat(0);
TCanvas* can = new TCanvas( plotname, plotname, 500, 500);
hist1.Draw( );
hist2.Draw( "same" );
hist3.Draw( "same" );
TLegend *leg = new TLegend(0.48,0.7,0.89,0.92);
leg->AddEntry( &hist1,"CaloJet","LP");
leg->AddEntry( &hist3,"PF Jet","LP");
leg->AddEntry( &hist2,"GenJet","L");
leg->SetFillColor(0);
leg->SetLineColor(0);
leg->Draw();
can->SetLogy( log );
if(log==2) {
can->SetLogy( 1 );
hist1.GetYaxis()->SetMoreLogLabels();
}
std::string plot("ratio-");
plot.append(plotname);
can->SaveAs( (plot+".eps").c_str() );
can->SaveAs( (plot+".gif").c_str() );
can->SaveAs( (plot+".root").c_str() );
// delete can;
cout << hist1.Integral() << endl;
}
示例7: makeplotTwo
void makeplotTwo(TH1& hist1, TH1& hist2, const char* plotname, int logy) {
hist1.SetLineColor(4);
hist1.SetMarkerColor(4);
gStyle->SetOptStat(0);
TCanvas* can = new TCanvas( plotname, plotname, 500, 500);
hist1.Draw( );
hist2.Draw( "same" );
TLegend *leg = new TLegend(0.55,0.8,0.89,0.92);
leg->AddEntry( &hist1,"Reconstructed","LP");
leg->AddEntry( &hist2,"Generated","L");
leg->SetFillColor(0);
leg->SetLineColor(0);
leg->Draw();
can->SetLogy( logy );
if(logy==2) hist1.GetYaxis()->SetMoreLogLabels();
std::string plot(cmEnergy);
plot.append(plotname);
can->SaveAs( (plot+".eps").c_str() );
can->SaveAs( (plot+".gif").c_str() );
can->SaveAs( (plot+".root").c_str() );
// delete can;
cout << hist1.Integral() << endl;
}
示例8: main
int main (int argc, char *argv[])
{
LineStream ls;
char *line;
char *pos;
Stringa buffer;
if (argc != 2) {
usage ("%s <file.intraOffsets>");
}
TH1 *his = new TH1D ("","Intra-read distribution",1000,0,1000);
TCanvas *canv = new TCanvas("","canvas",1200,400);
ls = ls_createFromFile (argv[1]);
while (line = ls_nextLine (ls)) {
his->Fill (atoi (line));
}
ls_destroy (ls);
his->Draw();
his->GetXaxis()->SetLabelSize (0.04);
his->GetYaxis()->SetLabelSize (0.04);
buffer = stringCreate (100);
pos = strchr (argv[1],'.');
if (pos == NULL) {
die ("Expected <file.intraOffsets>: %s",argv[1]);
}
*pos = '\0';
stringPrintf (buffer,"%s_intraDistribution.jpg",argv[1]);
canv->Print (string (buffer),"jpg");
stringDestroy (buffer);
return 0;
}
示例9: draw_delta
void plotter::draw_delta(TH1* hist_, TString file_name){
TH1* hist = (TH1*) hist_->Clone("hist");
TCanvas *c= new TCanvas("Particle Level","",600,600);
gPad->SetLeftMargin(0.15);
hist->SetTitle(file_name);
hist->GetXaxis()->SetTitle("Leading-jet mass [GeV]");
hist->GetYaxis()->SetTitle("#Delta events");
hist->GetYaxis()->SetTitleOffset(1.5);
hist->GetYaxis()->SetNdivisions(505);
hist->SetFillColor(810);
hist->SetLineColor(810);
hist->Draw("HIST");
gPad->RedrawAxis();
c->SaveAs(directory + file_name + ".pdf");
delete c;
}
示例10: getPlotData
void getPlotData() {
TH1 * h = (TH1*) m_file->Get(m_direc.c_str());
for (int i=0; i<h->GetXaxis()->GetNbins(); i++) {
m_xs.push_back(h->GetXaxis()->GetBinCenter(i));
m_ys.push_back(h->GetBinContent(i));
}
m_plot->m_xAxisTitle = std::string(h->GetXaxis()->GetTitle());
m_plot->m_yAxisTitle = std::string(h->GetYaxis()->GetTitle());
m_plot->m_title = std::string(h->GetTitle());
std::stringstream ssN, ssMu, ssSig, ssUF, ssOF;
ssN << std::setprecision(4) << h->GetEntries();
ssMu << std::setprecision(4) << h->GetMean();
ssSig << std::setprecision(4) << h->GetRMS();
ssUF << std::setprecision(4) << h->GetBinContent(0);
ssOF << std::setprecision(4) << h->GetBinContent(h->GetNbinsX() + 1);
m_statsTitles.push_back("N:");
m_statsTitles.push_back("mu:");
m_statsTitles.push_back("sig:");
m_statsTitles.push_back("UF:");
m_statsTitles.push_back("OF:");
m_statsValues.push_back(ssN.str());
m_statsValues.push_back(ssMu.str());
m_statsValues.push_back(ssSig.str());
m_statsValues.push_back(ssUF.str());
m_statsValues.push_back(ssOF.str());
}
示例11: UpdateHist
// show the histogram in first slot, try a Gaussian fit with given parameters
void PRadHistCanvas::UpdateHist(int index, TObject *tob, int range_min, int range_max)
{
--index;
if(index < 0 || index >= canvases.size())
return;
canvases[index]->cd();
canvases[index]->SetGrid();
gPad->SetLogy();
TH1 *hist = (TH1*)tob;
hist->GetXaxis()->SetRangeUser(hist->FindFirstBinAbove(0,1) - 10,
hist->FindLastBinAbove(0,1) + 10);
hist->GetXaxis()->SetLabelSize(HIST_LABEL_SIZE);
hist->GetYaxis()->SetLabelSize(HIST_LABEL_SIZE);
// try to fit gaussian in certain range
if(range_max > range_min
&& hist->Integral(range_min, range_max + 1) > 0)
{
TF1 *fit = new TF1("", "gaus", range_min, range_max);
fit->SetLineColor(kRed);
fit->SetLineWidth(2);
hist->Fit(fit,"qlR");
}
hist->SetFillColor(fillColors[index]);
hist->Draw();
canvases[index]->Refresh();
}
示例12: GetEffHist
// === FUNCTION ============================================================
// Name: TPlot::GetEffHist
// Description:
// ===========================================================================
TH1* TPlot::GetEffHist(std::string Eff, std::string det, std::string algo)
{
TH1* hNum = GetHist1D(listEff[Eff].first, det, algo);
TH1* hDem = GetHist1D(listEff[Eff].second, det, algo);
TH1* temp = (TH1*)hNum->Clone(Eff.c_str());
assert(hNum->GetNbinsX() == hDem->GetNbinsX());
for (int i = 0; i < hNum->GetNbinsX(); ++i)
{
double val = hNum->GetBinContent(i) / hDem->GetBinContent(i);
double valerr = val * sqrt( pow(hNum->GetBinError(i)/hNum->GetBinContent(i), 2) +
pow(hDem->GetBinError(i)/hDem->GetBinContent(i), 2) );
if (isnan(val)) { val = 0; valerr = 0; }
temp->SetBinContent(i, val);
temp->SetBinError(i, valerr);
std::cout << " bin " <<i <<" val " << val << std::endl;
}
//temp->Divide(hDem);
temp->GetYaxis()->SetTitle("Efficiency");
return temp;
} // ----- end of function TPlot::GetEffHist -----
示例13: ratioPlots
void ratioPlots( TCanvas* c1, TH1* h_r, TH1* h_i,
string xTitle, string yTitle, string savePath,
double fitMin=-100000, double fitMax=100000, bool doubleColFit=0 ){
double xMaximum = h_r->GetXaxis()->GetBinUpEdge(h_r->GetXaxis()->GetLast());
double xMinimum = h_r->GetXaxis()->GetBinLowEdge(h_r->GetXaxis()->GetFirst());
double yMaximum;
double yMinimum;
h_i->Sumw2();
h_r->Sumw2();
TLine* line1 = new TLine(xMinimum,1,xMaximum,1);
line1->SetLineColor(1);
line1->SetLineWidth(2);
line1->SetLineStyle(7);
TF1* fpol1 = new TF1("fpol1", "pol1", fitMin, fitMax);
fpol1->SetLineColor(2);
fpol1->SetLineWidth(3);
fpol1->SetLineStyle(7);
TH1* hRatio = (TH1*)h_r->Clone("clone_record");
hRatio->Divide(h_i);
yMaximum = hRatio->GetMaximum();
yMinimum = hRatio->GetMinimum(0);
hRatio->GetYaxis()->SetRangeUser(yMinimum/2.5,yMaximum+yMaximum/5);
hRatio->SetXTitle(xTitle.c_str());
hRatio->SetYTitle(yTitle.c_str());
hRatio->SetLineColor(9);
hRatio->SetLineWidth(2);
hRatio->SetMarkerStyle(8);
hRatio->Draw("e");
hRatio->Fit("fpol1", "L");
line1->Draw("SAME");
if(doubleColFit){
double p0=fpol1->GetParameter(0);
double p1=fpol1->GetParameter(1);
double endPoint=double(fitMax*p1)+p0;
double p1new=(endPoint-1)/(fitMax-fitMin);
char fun[100], text[100];
sprintf(fun,"x*(%f)+1",p1new);
sprintf(text,"Tangent: %f",p1new);
TF1* fnew = new TF1("fnew", fun, fitMin, fitMax);
fnew->SetLineColor(2);
fnew->SetLineWidth(3);
fnew->Draw("SAME");
TText* Title = new TText( fitMax/12, yMinimum, text);
Title->SetTextColor(2);
Title->SetTextSize(0.035);
Title->Draw("SAME");
}
c1->SaveAs(savePath.c_str());
c1->cd();
}
示例14: annconvergencetest
void annconvergencetest( TDirectory *lhdir )
{
TCanvas* c = new TCanvas( "MLPConvergenceTest", "MLP Convergence Test", 150, 0, 600, 580*0.8 );
TH1* estimatorHistTrain = (TH1*)lhdir->Get( "estimatorHistTrain" );
TH1* estimatorHistTest = (TH1*)lhdir->Get( "estimatorHistTest" );
Double_t m1 = estimatorHistTrain->GetMaximum();
Double_t m2 = estimatorHistTest ->GetMaximum();
Double_t max = TMath::Max( m1, m2 );
m1 = estimatorHistTrain->GetMinimum();
m2 = estimatorHistTest ->GetMinimum();
Double_t min = TMath::Min( m1, m2 );
estimatorHistTrain->SetMaximum( max + 0.1*(max - min) );
estimatorHistTrain->SetMinimum( min - 0.1*(max - min) );
estimatorHistTrain->SetLineColor( 2 );
estimatorHistTrain->SetLineWidth( 2 );
estimatorHistTrain->SetTitle( TString("MLP Convergence Test") );
estimatorHistTest->SetLineColor( 4 );
estimatorHistTest->SetLineWidth( 2 );
estimatorHistTrain->GetXaxis()->SetTitle( "Epochs" );
estimatorHistTrain->GetYaxis()->SetTitle( "Estimator" );
estimatorHistTrain->GetXaxis()->SetTitleOffset( 1.20 );
estimatorHistTrain->GetYaxis()->SetTitleOffset( 1.65 );
estimatorHistTrain->Draw();
estimatorHistTest ->Draw("same");
// need a legend
TLegend *legend= new TLegend( 1 - c->GetRightMargin() - 0.45, 1-c->GetTopMargin() - 0.20,
1 - c->GetRightMargin() - 0.05, 1-c->GetTopMargin() - 0.05 );
legend->AddEntry(estimatorHistTrain,"Training Sample","l");
legend->AddEntry(estimatorHistTest,"Test sample","l");
legend->Draw("same");
legend->SetMargin( 0.3 );
c->cd();
TMVAGlob::plot_logo(); // don't understand why this doesn't work ... :-(
c->Update();
TString fname = "plots/annconvergencetest";
TMVAGlob::imgconv( c, fname );
}
示例15: showGraph
void showGraph(double canvasSizeX, double canvasSizeY,
TGraph* graph,
bool useLogScaleX, double xMin, double xMax, const std::string& xAxisTitle, double xAxisOffset,
bool useLogScaleY, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset,
const std::string& outputFileName)
{
TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY);
canvas->SetFillColor(10);
canvas->SetBorderSize(2);
canvas->SetTopMargin(0.05);
canvas->SetLeftMargin(0.19);
canvas->SetBottomMargin(0.19);
canvas->SetRightMargin(0.05);
canvas->SetLogx(useLogScaleX);
canvas->SetLogy(useLogScaleY);
TH1* dummyHistogram = new TH1D("dummyHistogram", "dummyHistogram", 10, xMin, xMax);
dummyHistogram->SetTitle("");
dummyHistogram->SetStats(false);
dummyHistogram->SetMinimum(yMin);
dummyHistogram->SetMaximum(yMax);
dummyHistogram->Draw("axis");
TAxis* xAxis = dummyHistogram->GetXaxis();
xAxis->SetTitle(xAxisTitle.data());
xAxis->SetTitleOffset(xAxisOffset);
xAxis->SetTitleSize(0.065);
xAxis->SetLabelSize(0.055);
xAxis->SetLabelOffset(0.01);
xAxis->SetTickLength(0.055);
xAxis->SetNdivisions(505);
TAxis* yAxis = dummyHistogram->GetYaxis();
yAxis->SetTitle(yAxisTitle.data());
yAxis->SetTitleOffset(yAxisOffset);
yAxis->SetTitleSize(0.070);
yAxis->SetLabelSize(0.055);
yAxis->SetLabelOffset(0.01);
yAxis->SetTickLength(0.055);
yAxis->SetNdivisions(505);
graph->SetMarkerColor(1);
graph->SetLineColor(1);
graph->Draw("p");
canvas->Update();
size_t idx = outputFileName.find_last_of('.');
std::string outputFileName_plot = std::string(outputFileName, 0, idx);
if ( useLogScaleY ) outputFileName_plot.append("_log");
else outputFileName_plot.append("_linear");
if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data());
canvas->Print(std::string(outputFileName_plot).append(".png").data());
//canvas->Print(std::string(outputFileName_plot).append(".pdf").data());
//canvas->Print(std::string(outputFileName_plot).append(".root").data());
delete dummyHistogram;
delete canvas;
}