本文整理汇总了C++中TAxis::SetLabelSize方法的典型用法代码示例。如果您正苦于以下问题:C++ TAxis::SetLabelSize方法的具体用法?C++ TAxis::SetLabelSize怎么用?C++ TAxis::SetLabelSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TAxis
的用法示例。
在下文中一共展示了TAxis::SetLabelSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TH2* RootWriter::CreateTH2(Histogram2D* h)
{
const Axis& xax = h->GetAxisX(), yax = h->GetAxisY();
const int xchannels = xax.GetBinCount();
const int ychannels = yax.GetBinCount();
TH2* mat = new TH2F( h->GetName().c_str(), h->GetTitle().c_str(),
xchannels, xax.GetLeft(), xax.GetRight(),
ychannels, yax.GetLeft(), yax.GetRight() );
mat->SetOption( "colz" );
mat->SetContour( 64 );
TAxis* rxax = mat->GetXaxis();
rxax->SetTitle(xax.GetTitle().c_str());
rxax->SetTitleSize(0.03);
rxax->SetLabelSize(0.03);
TAxis* ryax = mat->GetYaxis();
ryax->SetTitle(yax.GetTitle().c_str());
ryax->SetTitleSize(0.03);
ryax->SetLabelSize(0.03);
ryax->SetTitleOffset(1.3);
TAxis* zax = mat->GetZaxis();
zax->SetLabelSize(0.025);
for(int iy=0; iy<ychannels+2; ++iy)
for(int ix=0; ix<xchannels+2; ++ix)
mat->SetBinContent(ix, iy, h->GetBinContent(ix, iy));
mat->SetEntries( h->GetEntries() );
return mat;
}
示例2: SetAxis
//------------------------------------------------------------------------------
// SetAxis
//------------------------------------------------------------------------------
void SetAxis(TH1* hist,
TString xtitle,
TString ytitle,
Float_t size,
Float_t offset)
{
TAxis* xaxis = (TAxis*)hist->GetXaxis();
TAxis* yaxis = (TAxis*)hist->GetYaxis();
xaxis->SetLabelFont(42);
yaxis->SetLabelFont(42);
xaxis->SetTitleFont(42);
yaxis->SetTitleFont(42);
xaxis->SetLabelOffset(0.025);
yaxis->SetLabelOffset(0.025);
xaxis->SetTitleOffset(1.4);
yaxis->SetTitleOffset(offset);
xaxis->SetLabelSize(size);
yaxis->SetLabelSize(size);
xaxis->SetTitleSize(size);
yaxis->SetTitleSize(size);
xaxis->SetTitle(xtitle);
yaxis->SetTitle(ytitle);
xaxis->SetNdivisions(505);
yaxis->SetNdivisions(505);
yaxis->CenterTitle();
gPad->GetFrame()->DrawClone();
gPad->RedrawAxis();
}
示例3: residual_error
/*
double residual_error( double error_data, double pdf )
{
double chi2 = 0.;
if ( pdf > 0 )
chi2 += 2. * ( pdf - error_data );
if ( error_data > 0 && pdf > 0 )
chi2=(error_data/pdf);
//chi2 += 2. * error_data * log( error_data / error_pdf );
// return ( ( error_data >= pdf ) ? sqrt( chi2 ) : -sqrt( chi2 ) );
// return ( ( error_data >= pdf ) ? chi2 : chi2 );
return ( chi2 );
}
*/
TH1D* residualHist( const RooHist* rhist, const RooCurve* curve )
{
double r = 0.2;
double sr = 1. / r;
// Grab info from the histogram.
int n = rhist->GetN();
double* x = rhist->GetX();
double* y = rhist->GetY();
//rhist->Sumw2();
// double e;
// Create residual histogram.
double xMin = x[ 0 ];
double xMax = x[ n - 1 ];
TH1D* residuals_temp = new TH1D( "r", "", n, xMin, xMax );
double datum = 0.;
double pdf = 0.;
double error_data = 0.;
// Fill the histogram.
if ( curve )
for ( int bin = 0; bin < n; bin++ )
{
datum = y[ bin ];
pdf = curve->Eval( x[ bin ] );
error_data = rhist->GetErrorY(bin);
// error_pdf = curve->Eval( x[ bin ] );
residuals_temp->SetBinContent( bin + 1, residual( datum, pdf ) );
// residuals_temp->SetBinError ( bin + 1, residual_error( error_data, pdf ) );
residuals_temp->SetBinError ( bin + 1, error_data / pdf );
}
residuals_temp->SetMinimum ( -2. );
residuals_temp->SetMaximum ( 2. );
residuals_temp->SetStats ( false );
residuals_temp->SetMarkerStyle( 8 );
residuals_temp->SetMarkerSize ( .8 );
TAxis* xAxis = residuals_temp->GetXaxis();
xAxis->SetTickLength ( sr * xAxis->GetTickLength() );
xAxis->SetLabelSize ( sr * xAxis->GetLabelSize() );
xAxis->SetTitleSize ( sr * xAxis->GetTitleSize() );
xAxis->SetLabelOffset( sr * xAxis->GetLabelOffset() );
TAxis* yAxis = residuals_temp->GetYaxis();
//yAxis->SetNdivisions ( 500 );
//yAxis->SetLabelSize ( 10*sr * yAxis->GetLabelSize() );
yAxis->SetLabelSize ( 2.5 * yAxis->GetLabelSize() );
yAxis->SetTitle(" (DATA - FIT) / FIT");
yAxis->SetTitleSize ( 0.09 );
yAxis->SetTitleOffset( 0.35 );
return residuals_temp;
}
示例4: 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;
}
示例5: showHistograms
void showHistograms(double canvasSizeX, double canvasSizeY,
TH1* histogram,
double xMin, double xMax, const std::string& xAxisTitle, double xAxisOffset,
bool useLogScale, 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->SetLeftMargin(0.15);
canvas->SetBottomMargin(0.15);
canvas->SetLogy(useLogScale);
histogram->SetTitle("");
histogram->SetStats(true);
histogram->SetMinimum(yMin);
histogram->SetMaximum(yMax);
histogram->SetLineColor(1);
histogram->SetLineWidth(2);
histogram->SetMarkerColor(1);
histogram->SetMarkerStyle(20);
histogram->SetMarkerSize(1.5);
histogram->Draw("hist");
TAxis* xAxis = histogram->GetXaxis();
xAxis->SetRangeUser(xMin, xMax);
xAxis->SetTitle(xAxisTitle.data());
xAxis->SetTitleSize(0.060);
xAxis->SetTitleOffset(xAxisOffset);
xAxis->SetLabelSize(0.050);
xAxis->SetNdivisions(505);
TAxis* yAxis = histogram->GetYaxis();
yAxis->SetTitle(yAxisTitle.data());
yAxis->SetTitleSize(0.060);
yAxis->SetTitleOffset(yAxisOffset);
yAxis->SetLabelSize(0.050);
yAxis->SetNdivisions(505);
canvas->Update();
size_t idx = outputFileName.find_last_of('.');
std::string outputFileName_plot = std::string(outputFileName, 0, idx);
if ( useLogScale ) 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 canvas;
}
示例6: PrettyFonts
void PrettyFonts(TH1D* h){
TAxis * x = h->GetXaxis();
TAxis * y = h->GetYaxis();
x->SetTitleFont(132);
y->SetTitleFont(132);
x->SetTitleSize(0.06);
x->SetTitleOffset(1.05); //make the Title a little further from the axis
y->SetTitleOffset(1.05);
y->SetTitleSize(0.06);
x->SetLabelFont(132);
y->SetLabelFont(132);
x->SetLabelSize(0.06);
y->SetLabelSize(0.06);
}
示例7: DrawOne
THStack* DrawOne(TVirtualPad* p,
Double_t yr,
Bool_t top,
TDirectory* dir,
const char* name)
{
p->cd();
p->SetFillColor(0);
p->SetFillStyle(0);
p->SetLineColor(0);
p->SetRightMargin(0.01);
p->SetLeftMargin(0.12);
p->SetGridx();
if (top) p->SetBottomMargin(0.001);
else p->SetBottomMargin(0.2);
if (top) p->SetTopMargin(0.02);
else p->SetTopMargin(0.0001);
THStack* s = static_cast<THStack*>(dir->Get(name));
s->Draw("nostack");
Double_t sc = (top ? 1-yr : yr);
TAxis* ya = s->GetHistogram()->GetYaxis();
ya->SetLabelSize(1/sc*ya->GetLabelSize());
ya->SetTitleSize(1/sc*ya->GetTitleSize());
ya->SetTitleOffset(sc*(ya->GetTitleOffset()+.5));
ya->SetTitleFont(42);
ya->SetLabelFont(42);
TAxis* xa = s->GetHistogram()->GetXaxis();
xa->SetLabelSize(!top ? 1/yr*xa->GetLabelSize() : 0);
xa->SetTitleSize(!top ? 1/yr*xa->GetTitleSize() : 0);
xa->SetTitleOffset(yr*(xa->GetTitleOffset()+2));
xa->SetTitleFont(42);
xa->SetLabelFont(42);
p->Modified();
p->Update();
p->cd();
return s;
}
示例8: SetAxisLabels
void SetAxisLabels(TH1& hist, char* xtitle, char* ytitle="",
double xoffset=1.1, double yoffset=1.4) {
TAxis* x = hist.GetXaxis();
TAxis* y = hist.GetYaxis();
x->SetTitle(xtitle);
x->SetTitleSize(0.06);
x->SetLabelSize(0.05);
x->SetTitleOffset(xoffset);
x->SetNdivisions(505);
y->SetTitle(ytitle);
y->SetTitleSize(0.06);
y->SetLabelSize(0.05);
y->SetTitleOffset(yoffset);
y->SetNoExponent();
hist.SetLineWidth(2);
hist.SetMarkerStyle(20);
std::stringstream str;
str << "Events / " << (int) lumi << " pb^{-1} ";
std::string defYtitle = str.str();
if(ytitle=="") y->SetTitle( defYtitle.c_str() );
}
示例9: SetAxis
//------------------------------------------------------------------------------
// SetAxis
//------------------------------------------------------------------------------
void SetAxis(TH1* hist,
TString xtitle,
TString ytitle,
Float_t xoffset,
Float_t yoffset)
{
gPad->cd();
gPad->Update();
// See https://root.cern.ch/doc/master/classTAttText.html#T4
Float_t padw = gPad->XtoPixel(gPad->GetX2());
Float_t padh = gPad->YtoPixel(gPad->GetY1());
Float_t size = (padw < padh) ? padw : padh;
size = 20. / size; // Like this label size is always 20 pixels
TAxis* xaxis = (TAxis*)hist->GetXaxis();
TAxis* yaxis = (TAxis*)hist->GetYaxis();
xaxis->SetTitleOffset(xoffset);
yaxis->SetTitleOffset(yoffset);
xaxis->SetLabelSize(size);
yaxis->SetLabelSize(size);
xaxis->SetTitleSize(size);
yaxis->SetTitleSize(size);
xaxis->SetTitle(xtitle);
yaxis->SetTitle(ytitle);
yaxis->CenterTitle();
gPad->GetFrame()->DrawClone();
gPad->RedrawAxis();
}
示例10: plotPair
//==========================================
//==========================================
void plotPair(TH1F *h1,TH1F *h0 ) {
h1->Draw();
// edit fonts/sizes
TAxis *ax =h1->GetYaxis();
float ss=ax->GetTitleSize();
//printf("ss=%f\n",ss);
ax->SetTitleSize(2*ss);
ax->SetTitleOffset(0.5);
ax =h1->GetXaxis();
ax->SetTitleSize(1.5*ss);
ax->SetLabelSize(1.5*ss);
ax->SetTitleOffset(0.7);
// edit fonts/sizes DONE
gPad->Update();
//scale hint1 to the pad coordinates
Float_t rightmax = 1.1*h0->GetMaximum();
Float_t scale = gPad->GetUymax()/rightmax;
h0->Scale(scale);
h0->Draw("same");
//draw an axis on the right side
TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"-R");
int col=h0->GetLineColor();
axis->SetLineColor(col);
axis->SetTextColor(col);
axis->SetLabelColor(col);
axis ->SetTitle("LCP yield");
axis->SetTitleSize(2*ss);
axis->SetTitleOffset(.5);
axis->Draw();
TPaveStats *st =( TPaveStats *)gPad->GetPrimitive("stats");
st->SetX1NDC(0.35);
st->SetX2NDC(0.5);
st->SetY1NDC(0.7);
st->SetY2NDC(1.);
}
示例11: setHist
void LEPStyle::setHist()
{
_hist = new TH1F( "bidon", "bidon", 100, _xmin, _xmax );
_ax = _hist->GetXaxis();
_ay = _hist->GetYaxis();
_ax->SetTitle(_title);
_ax->SetNdivisions(_ndivx);
if( _logX )
{
_ax->SetMoreLogLabels();
}
_ax->SetLabelSize(_scale*0.060);
// _ax->SetLabelOffset(_scale*0.007);
_ax->SetTitleSize(_scale*0.070);
_ax->SetTitleOffset(0.9);
_ax->CenterTitle( _centerTitle );
_ay->SetNdivisions(0);
}
示例12: plot3
//.........这里部分代码省略.........
fitcph = 1.0 - fitsph;
if( (sphmin < fitsph) && (fitsph<sphmax) ) {
MMII(C1,C2,fitx,fitsph,fitcph,MZ,MW);
if(MZ < Mmin) { Mmin = MZ; cout << MZ << "\t" << sqrt(fitsph) << endl;}
}
}
}
}
// CREATE PLOTS /////////////////////////////////////////////////////////
NPplot->SetLineStyle(2);
NPplot->SetMarkerStyle(20);
NPplot->SetMarkerSize(0.4);
SMplot->SetMarkerStyle(20);
SMplot->SetMarkerSize(0.4);
if(strpltmd.compare("cos") == 0) {yMin = 0.0; yMax = 1.0;}
if(strpltmd.compare("sin") == 0) {yMin = 0.0; yMax = 1.0;}
if(strpltmd.compare("mmp") == 0) {xMin = 0.0; xMax = 5.0; yMin = 0.0; yMax = 5;}
TH1F* frame = MyC->DrawFrame(0.9*xMin,0.9*yMin,1.1*xMax,1.0*yMax);
frame->SetTitle(plottitle.c_str());
TAxis *xaxis = frame->GetXaxis();
TAxis *yaxis = frame->GetYaxis();
xaxis->SetTitle(xtitle.c_str());
xaxis->CenterTitle();
xaxis->SetTitleOffset(1.);
xaxis->SetDecimals();
xaxis->SetLabelSize(0.03);
xaxis->SetLabelOffset(0.01);
yaxis->SetTitle(ytitle.c_str());
yaxis->CenterTitle();
yaxis->SetTitleOffset(1.2);
yaxis->SetDecimals();
yaxis->SetLabelSize(0.03);
yaxis->SetLabelOffset(0.01);
TLegend *mmleg = new TLegend(mmlegxmin,mmlegymin,mmlegxmax,mmlegymax);
mmleg->AddEntry(NPplot,NPleg.c_str(),"l");
mmleg->AddEntry(SMplot,SMleg.c_str(),"l");
mmleg->SetTextSize(0.025);
mmleg->SetFillStyle(0);
if( (strfile.compare("uu-d") != 0) && (strfile.compare("nu-d") != 0) ) {
for(tphStep=0; tphStep<tphSteps; tphStep++){NPmrk[tphStep]->Draw(); SMmrk[tphStep]->Draw();}
}
Float_t xdummy[1] = {0.0}, ydummy[1] = {0.0};
TGraph *circle = new TGraph(1,xdummy,ydummy);
circle->SetMarkerStyle(24);
circle->SetMarkerColor(kGreen+1);
circle->SetMarkerSize(0.8);
TGraph *square = new TGraph(1,xdummy,ydummy);
square->SetMarkerStyle(25);
square->SetMarkerColor(kCyan+1);
square->SetMarkerSize(0.8);
示例13: write
void SampleDiagnostics::write() const
{
if (passedRate == 0) {
std::cerr << "WARNING : No accumulated rate for " << name << ". Maybe you just didn't run over it/them?" << std::endl;
return;
}
//.. Histogram output .......................................................
const Int_t numDatasets = static_cast<Int_t>(size());
const UInt_t numBins = numDatasets + 3;
TH2* hCorrelation = new TH2F("h_correlation_" + name, name, numBins, 0, numBins, numBins, 0, numBins);
TH2* hSharedRate = new TH2F("h_shared_rate_" + name, name, numBins, 0, numBins, numBins, 0, numBins);
//...........................................................................
Double_t overhead = 0;
Double_t overheadErr = 0;
for (Int_t iSet = 0, xBin = 1; iSet < numDatasets; ++iSet, ++xBin) {
const Dataset& dataset = at(iSet);
if (!dataset.isNewTrigger) {
overhead += dataset.rate;
overheadErr += dataset.rateUncertainty2; // I think this is over-estimating it because the values are NOT uncorrelated, but oh well
}
if (iSet == firstNewTrigger) ++xBin;
if (dataset.rate == 0) continue;
for (Int_t jSet = 0, yBin = 1; jSet <= numDatasets; ++jSet, ++yBin) {
if (jSet == firstNewTrigger) ++yBin;
if (jSet == numDatasets) ++yBin;
hCorrelation->SetBinContent (xBin, yBin, commonRates[iSet][jSet] / dataset.rate);
hCorrelation->SetBinError (xBin, yBin, ratioError(commonRates[iSet][jSet], commonRateUncertainties2[iSet][jSet], dataset.rate, dataset.rateUncertainty2));
hSharedRate ->SetBinContent (xBin, yBin, commonRates[iSet][jSet]);
hSharedRate ->SetBinError (xBin, yBin, TMath::Sqrt(commonRateUncertainties2[iSet][jSet]));
} // end loop over other datasets
// Rightmost column is the fraction of rate out of the total
hCorrelation->SetBinContent (numBins, xBin, dataset.rate / passedRate);
hCorrelation->SetBinError (numBins, xBin, ratioError(dataset.rate, dataset.rateUncertainty2, passedRate, passedRateUncertainty2));
hSharedRate ->SetBinContent (numBins, xBin, dataset.rate);
hSharedRate ->SetBinError (numBins, xBin, TMath::Sqrt(dataset.rateUncertainty2));
} // end loop over datasets
// Top-right cell is the total overhead for the _current_ datasets (not including new triggers)
hSharedRate ->SetBinContent (numBins, numBins, overhead);
hSharedRate ->SetBinError (numBins, numBins, TMath::Sqrt(overheadErr));
overheadErr = ratioError (overhead, overheadErr, passedRate, passedRateUncertainty2);
overhead /= passedRate; // Can only do this after error is computed
overhead -= 1;
hCorrelation->SetBinContent (numBins, numBins, overhead);
hCorrelation->SetBinError (numBins, numBins, overheadErr);
//...........................................................................
// Histogram format
hCorrelation->SetTitle (TString::Format("%s (overhead = %.3g%% #pm %.3g%%)" , hCorrelation->GetTitle(), 100*overhead, 100*overheadErr));
hSharedRate ->SetTitle (TString::Format("%s (total rate = %.3g #pm %.3g Hz)", hSharedRate ->GetTitle(), passedRate, TMath::Sqrt(passedRateUncertainty2)));
hCorrelation->SetZTitle ("(X #cap Y) / X"); hSharedRate->SetZTitle ("X #cap Y");
hCorrelation->SetOption ("colz"); hSharedRate->SetOption ("colz");
hCorrelation->SetStats (kFALSE); hSharedRate->SetStats (kFALSE);
hCorrelation->SetMinimum(0); hSharedRate->SetMinimum(0);
hCorrelation->SetMaximum(1);
std::vector<TAxis*> axes;
axes.push_back(hCorrelation->GetXaxis()); axes.push_back(hCorrelation->GetYaxis());
axes.push_back(hSharedRate ->GetXaxis()); axes.push_back(hSharedRate ->GetYaxis());
const UInt_t numAxes = axes.size();
for (UInt_t iAxis = 0; iAxis < numAxes; ++iAxis) {
TAxis* axis = axes[iAxis];
for (Int_t iSet = 0, bin = 1; iSet < numDatasets; ++iSet, ++bin) {
if (iSet == firstNewTrigger) ++bin;
axis->SetBinLabel(bin, at(iSet).name);
} // end loop over datasets
axis->SetLabelSize (0.04f);
axis->LabelsOption ("v");
axis->SetTitle (iAxis % 2 == 0 ? "X" : "Y");
} // end loop over axes to format
hCorrelation->GetXaxis()->SetBinLabel(numBins, "rate / total");
hCorrelation->GetYaxis()->SetBinLabel(numBins, "overlap / rate");
hSharedRate ->GetXaxis()->SetBinLabel(numBins, "rate");
hSharedRate ->GetYaxis()->SetBinLabel(numBins, "overlap");
if (gDirectory->GetDirectory("unnormalized") == 0)
gDirectory->mkdir("unnormalized");
gDirectory->cd("unnormalized"); hSharedRate ->Write();
gDirectory->cd("/"); hCorrelation->Write();
//...........................................................................
}
示例14: BkgDemo_Diplot
void BkgDemo_Diplot(TCanvas* c, TH1F** h, TLegend* l1, TLegend* l2){
//Make a split canvas, comparison of methods and tag above, bkg subtracted tag below
// printf("\nDo BkgDemo_Diplot for canvas %s\n",c->GetName());
// printf("integrals stage1: tag %f usb %f lsb %f\n",h[1]->Integral(),h[5]->Integral(),h[6]->Integral());
TLatex * TEX_CMSPrelim;
if(preliminary) TEX_CMSPrelim = new TLatex(0.177136,0.953368,"CMS Preliminary");
else TEX_CMSPrelim = new TLatex(0.177136,0.953368,"CMS");
PrettyLatex(TEX_CMSPrelim,0.03);
TLatex * TEX_E_TeV = new TLatex(0.800251,0.953368,"#sqrt{s} = 8 TeV");
PrettyLatex(TEX_E_TeV,0.03);
TLatex * TEX_lumi_fb = new TLatex(0.621859,0.953368,Form("#intL dt = %.1f fb^{-1}",Integrated_Luminosity_Data));
PrettyLatex(TEX_lumi_fb,0.03);
string sp1 = string(c->GetName())+"_p1";
string sp2 = string(c->GetName())+"_p2";
TPad *p1 = new TPad((char*)sp1.c_str(),"",0.,0.3,1.,1.);
p1->SetBottomMargin(0);
p1->cd();
// c->Divide(1,2);
// c->cd(1);
PrettyHist(h[3],kRed);
PrettyHist(h[5],kBlue);
PrettyHist(h[1]);
PrettyHist(h[6],kGreen);
//PrettyHist(h[3],kRed);
PrettyHist(h[7],kTeal);
PrettyBlock2(h[5],kBlue,3354,2);
//PrettyBlock(h[5],kBlue,string("//thatch"));//PrettyMarker(h[5],kBlue,4);
PrettyMarker(h[1]);
PrettyBlock2(h[6],kGreen,3345,2);
//PrettyBlock(h[6],kGreen,string("\\thatch"));//PrettyMarker(h[6],kGreen,4);
//PrettyMarker(h[3],kRed);
PrettyMarker(h[7],kTeal);
// h[5]->Scale(mHwidth/sidebandwidth);//lsb scaled
// h[6]->Scale(mHwidth/sidebandwidth);//usb scaled
// printf("integrals stage2: tag %f usb %f lsb %f\n",h[1]->Integral(),h[5]->Integral(),h[6]->Integral());
// printf("ranges maximi before setrange tag %f lsb %f, usb %f\n",h[1]->GetMaximum(),h[5]->GetMaximum(),h[6]->GetMaximum());
// printf("integrals stage3: tag %f usb %f lsb %f\n",h[1]->Integral(),h[5]->Integral(),h[6]->Integral());
// printf("ranges maximi before after tag %f lsb %f usb %f\n",h[1]->GetMaximum(),h[5]->GetMaximum(),h[6]->GetMaximum());
h[3]->SetFillStyle(0);//open rectangle
h[3]->SetLineColor(kRed);
h[3]->SetLineWidth(4);
h[6]->SetMinimum(0.0);
//float linmax = h[6]->GetMaximum();
//float linmin = h[6]->GetMinimum();
playNiceWithLegend(h[6],0.30,0.0);
playNiceWithLegend(h[3],0.30,0.0);
playNiceWithLegend(h[5],0.30,0.0);
playNiceWithLegend(h[1],0.30,0.0);
SameRange(h[3],h[1]);
SameRange(h[3],h[5],h[6]);
SameRange(h[3],h[1]);
h[3]->Draw("e2p");
h[5]->Draw("e2psame");
h[6]->Draw("e2psame");
h[3]->Draw("e2psame");
//if(showTag) h[1]->Draw("e1psame");//tag
TPad *p2 = new TPad((char*)sp2.c_str(),"",0.,0.125,1.,0.3);
p2->SetTopMargin(0);
p2->cd();
// c->cd(2);
TAxis * x = h[7]->GetXaxis();
TAxis * y = h[7]->GetYaxis();
float fontsize = 0.25;
float fontsizeY = 0.10;
x->SetTitleSize(fontsize);
y->SetTitleSize(fontsizeY);
x->SetLabelSize(fontsize);
y->SetLabelSize(fontsizeY);
h[7]->GetYaxis()->SetRangeUser(0.,2.);
h[7]->Draw("e1p");
TLine *OneLine = new TLine(x->GetXmin(),1.0,x->GetXmax(),1.0);
OneLine->SetLineColor(kBlack);
OneLine->SetLineWidth(2);
OneLine->SetLineStyle(7);//dashed.
OneLine->Draw("same");
h[7]->Draw("e1psame");
p1->cd();
// c->cd(1);
if(showTag) l1->AddEntry(h[1],"Higgs Mass Region");
TH1F * box = new TH1F("box","asdf",1,0,1);
box->SetMarkerColor(kRed);
box->SetMarkerStyle(25);
box->SetMarkerSize(2);
box->SetLineColor(0);
l1->AddEntry(box,"Data Driven Background");
l1->AddEntry(h[5],"Lower Mass Sideband");
l1->AddEntry(h[6], "Upper Mass Sideband");
l1->Draw("same");
TEX_CMSPrelim->Draw("same");
TEX_E_TeV->Draw("same");
TEX_lumi_fb->Draw("same");
p2->cd();
//c->cd(2);
l2->SetTextSize(fontsize*0.8);
l2->AddEntry(h[7],"Lower/Upper Sideband Ratio");
//.........这里部分代码省略.........
示例15: ratio
/*
* Main Function
*/
void ratio() {
gStyle->SetFrameLineWidth(1);
//Number of Measurements
const int NUM = 2;
//Measurements and uncertainties
// mean, -stat, +stat, -syst, +syst
double m[NUM][5] = {
0.98, 0.10, 0.10, 0.14, 0.14,
//1.33, 0.32, 0.32, 0.22, 0.22
1.26, 0.37, 0.37, 0.46, 0.46
};
//Theory and uncertainties
// mean, -uncert, +uncert
double t[NUM][3] = {
1.0, 0.114, 0.114,
1.0, 0.111, 0.111
};
// label text, sub-label text
// Note: TString does not work, b/c one cannot pass an array of TStrings
// as an argument to a function
char label[NUM][2][100] = {
"Z#gamma#gamma", "",
//"W#gamma#gamma", ""
"W#gamma#gamma (#mu)", ""
};
// format:
// # color, bgColor, fontSytle, linewidth, markerStyle
int aux[NUM][5] = {
1, 10, 42, 2, 20,
1, 10, 42, 2, 20
};
// determning the x size of the plot
double lowX = LOW_X;
double uppX = UPP_X;
TH2F* lft = new TH2F("lft", "", 50, lowX, uppX, 1, 0.0, 1.0);
// height = NUM*unitHeight + 2*spacers + 1*bottomMargin + 0.5*topMargin
const double unitHeight = 50.0; // even number
const double height = (double(NUM)+2.0)*unitHeight+100.0+30.0;
// how much to step each time to cover the vertical range of the histo in
// exactly NUM+2 steps
const double vstep = unitHeight/(height-100.0-30.0);
const double width = 800.0;
printf("Canvas: width=%d, height=%d\n",
TMath::Nint(width), TMath::Nint(height));
printf("Y-step = %6.4f\n", vstep);
// Set canvas and margins
TCanvas* canvas = new TCanvas("canvas", "canvas", 200, 0,
TMath::Nint(width), TMath::Nint(height));
canvas->SetFillColor(10);
canvas->SetRightMargin(20.0/width);
canvas->SetLeftMargin(20.0/width);
canvas->SetBottomMargin(56.0/height);
canvas->SetTopMargin(30.0/height);
canvas->Draw();
canvas->cd();
//printf("TopMargin : %6.4f\n", canvas->GetTopMargin());
//printf("BottomMargin: %6.4f\n", canvas->GetBottomMargin());
TAxis* xaxis = lft->GetXaxis();
TAxis* yaxis = lft->GetYaxis();
xaxis->CenterTitle(kTRUE);
xaxis->SetTitleSize(0.07);
xaxis->SetTitleFont(62);
xaxis->SetTitleOffset(1.1);
xaxis->SetNdivisions(6,5,0);
xaxis->SetLabelOffset(0.01);
xaxis->SetLabelSize(0.05);
xaxis->SetLabelFont(42);
yaxis->SetLabelSize(0.0);
yaxis->SetNdivisions(-1);
lft->SetXTitle("Cross Section Ratio #sigma_{Exp} / #sigma_{Theory}");
lft->SetYTitle("");
lft->SetStats(kFALSE);
lft->SetTitle("");
lft->Draw();
// Draw Theory Bands
for (int i=0; i!=NUM; ++i) {
drawTheory(i, t[i][0], t[i][1], t[i][2], vstep);
//.........这里部分代码省略.........