本文整理汇总了C++中TGaxis::SetTitleOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ TGaxis::SetTitleOffset方法的具体用法?C++ TGaxis::SetTitleOffset怎么用?C++ TGaxis::SetTitleOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGaxis
的用法示例。
在下文中一共展示了TGaxis::SetTitleOffset方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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.);
}
示例2: anotherScale
ExtraAxis anotherScale (const TH1* refHist, double scale, int color, const char* title, double offset) {
ExtraAxis result;
double x0 = refHist->GetXaxis()->GetXmin();
double x1 = refHist->GetXaxis()->GetXmax();
double y0 = refHist->GetMinimum();
double y1 = refHist->GetMaximum();
// double y0 = refHist->GetYaxis()->GetXmin();
// double y1 = refHist->GetYaxis()->GetXmax();
double xoffset = exp (log(x0) - (log(x1) - log(x0))*offset);
TGaxis* axis = new TGaxis(xoffset, y0, xoffset, y1, y0*scale,y1*scale,510,"-GS");
axis->ImportAxisAttributes (refHist->GetXaxis());
axis->SetTitle(title);
axis->SetTextColor (color);
axis->SetLineColor (color);
axis->SetLineWidth (1);
axis->SetTextColor (color);
axis->SetLabelColor (color);
axis->SetLabelOffset (0.);
axis->SetTitleOffset (0.65);
axis->SetTickSize(0.015);
result.Add (axis);
TLine* line = new TLine (xoffset, y0, xoffset, y1);
line->SetLineColor (color);
line->SetLineWidth (2);
result.Add (line);
line = new TLine (x0, y0, xoffset, y0);
line->SetLineColor (kGray);
line->SetLineWidth (2);
result.Add (line);
line = new TLine (x0, y1, xoffset, y1);
line->SetLineColor (kGray);
line->SetLineWidth (2);
result.Add (line);
return result;
}
示例3: ntuAnalyzer
//.........这里部分代码省略.........
//book graphs and plots
TGraphErrors* totRateVsCut = new TGraphErrors();
totRateVsCut->SetMinimum(0);
TGraphErrors* pureRateVsCut450 = new TGraphErrors();
TGraphErrors* pureRateVsCut280 = new TGraphErrors();
//loops
int bin = 0;
for (int cut = 350; cut < 500; cut=cut+10)
{
int mjjPassed = 0;
int HT250Calo_Passed = 0;
int excl410_passed = 0;
int excl250_passed = 0;
for (Long64_t jentry=0; jentry<nentries;++jentry)
{
tt->GetEntry(jentry);
if (hltAccept->at(HT250Calo) == 1)
++HT250Calo_Passed;
//if (caloMjj > cut && !hltAccept->at(HT410PF))
if (caloMjj > cut && l1Accept->at(L1scenario) == 1 && hltAccept->at(HT410PF)==0)
++excl410_passed;
if (caloMjj > cut && l1Accept->at(L1scenario)==1 && hltAccept->at(HT250Calo)==0)
++excl250_passed;
if (caloMjj > cut && l1Accept->at(L1scenario)==1)
++mjjPassed;
// if (hltAccept->at(HT250Calo) == 0 && mjj > cut)
// std::cout << "ref trigger doesn't completely cover cut at " << cut << std::endl;
}
// float mjjTotalRate = (float)mjjPassed/(float)HT250Calo_Passed*HT250Calo_rate;
// float mjjPureRate = (float)exclPassed/(float)HT250Calo_Passed*HT250Calo_rate;
float sigmaMjjPassed = sqrt((float)mjjPassed);
float sigmaNentries = sqrt((float)nentries);
float sigmaExcl410_passed = sqrt((float)excl410_passed);
float sigmaExcl250_passed = sqrt((float)excl250_passed);
float mjjTotalRate = (float)mjjPassed/(float)nentries*PDRate;
float mjjTotalRateE = PDRate*sqrt(pow((sigmaMjjPassed/nentries),2)+pow((sigmaNentries*mjjPassed/nentries/nentries),2));
float mjj450_PureRate = (float)excl410_passed/(float)nentries*PDRate;
float mjj450_PureRateE = PDRate*sqrt(pow((sigmaExcl410_passed/nentries),2)+pow((sigmaNentries*excl410_passed/nentries/nentries),2));
float mjj280_PureRate = (float)excl250_passed/(float)nentries*PDRate;
float mjj280_PureRateE = PDRate*sqrt(pow((sigmaExcl250_passed/nentries),2)+pow((sigmaNentries*excl250_passed/nentries/nentries),2));
totRateVsCut->SetPoint(bin,cut,mjjTotalRate);
totRateVsCut->SetPointError(bin,0.,mjjTotalRateE);
pureRateVsCut450->SetPoint(bin,cut,mjj450_PureRate);
pureRateVsCut450->SetPointError(bin,0.,mjj450_PureRateE);
pureRateVsCut280->SetPoint(bin,cut,mjj280_PureRate);
pureRateVsCut280->SetPointError(bin,0.,mjj280_PureRateE);
++bin;
}
//plotting and styling
TLegend* leg = new TLegend(0.62, 0.78, 0.83, 0.89);
leg->AddEntry(totRateVsCut,"total rate","P");
leg->AddEntry(pureRateVsCut450,"pure rate wrt HT410PF","P");
leg->AddEntry(pureRateVsCut280,"pure rate wrt HT250Calo","P");
totRateVsCut->SetTitle("Rate Ref");
totRateVsCut->GetXaxis()->SetTitle("Mjj cut threshold [GeV]");
totRateVsCut->GetYaxis()->SetTitle("Rate @4E33 [Hz]");
pureRateVsCut450->SetMarkerColor(kRed);
pureRateVsCut450->SetLineColor(kRed);
pureRateVsCut280->SetMarkerColor(kOrange+1);
pureRateVsCut280->SetLineColor(kOrange+1);
TCanvas* c4 = new TCanvas();
c4->cd();
totRateVsCut->Draw("AP");
pureRateVsCut450->Draw("P,sames");
pureRateVsCut280->Draw("P,sames");
leg->Draw("sames");
c4->Update();
TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),gPad->GetUxmax(), gPad->GetUymax(),
(totRateVsCut->GetYaxis()->GetBinLowEdge(1))*lumiScaleFactor,
(totRateVsCut->GetYaxis()->GetBinLowEdge(totRateVsCut->GetYaxis()->GetNbins())+totRateVsCut->GetYaxis()->GetBinWidth(1))*lumiScaleFactor,510,"+L");
c4->SetTicky(0);
axis->SetLineColor(kRed);
axis->SetLabelColor(kRed);
axis->SetTextColor(kRed);
axis->SetTitleOffset(1.3);
axis->SetLabelSize(0.03);
axis->SetTitle("Rate @1E34 [Hz]");
axis->Draw();
return 0;
}
示例4: rate
//.........这里部分代码省略.........
++excl_mjjHltPassed;
}
float HTT240rate = (float)HTT240Passed/(float)nentries*PDRate;
//std::cout << "HTT240rate = " << HTT240rate << std::endl;
float sigmaNentries = sqrt((float)nentries);
float sigmaMjjHltPassed = sqrt((float)mjjHltPassed);
float excl_sigmaMjjHltPassed = sqrt((float)excl_mjjHltPassed);
float sigmaMjjL1Passed = sqrt((float)mjjL1Passed);
float excl_sigmaMjjL1Passed = sqrt((float)excl_mjjL1Passed);
float mjjHltRate = (float)mjjHltPassed/(float)nentries*PDRate;
float mjjHltRateE = PDRate*sqrt(pow((sigmaMjjHltPassed/nentries),2)+pow((sigmaNentries*mjjHltPassed/nentries/nentries),2));
float excl_mjjHltRate = (float)excl_mjjHltPassed/(float)nentries*PDRate;
float excl_mjjHltRateE = PDRate*sqrt(pow((excl_sigmaMjjHltPassed/nentries),2)+pow((sigmaNentries*excl_mjjHltPassed/nentries/nentries),2));
float mjjL1Rate = (float)mjjL1Passed/(float)nentries*PDRate;
float mjjL1RateE = PDRate*sqrt(pow((sigmaMjjL1Passed/nentries),2)+pow((sigmaNentries*mjjL1Passed/nentries/nentries),2));
float excl_mjjL1Rate = (float)excl_mjjL1Passed/(float)nentries*PDRate;
float excl_mjjL1RateE = PDRate*sqrt(pow((excl_sigmaMjjL1Passed/nentries),2)+pow((sigmaNentries*excl_mjjL1Passed/nentries/nentries),2));
totHltRateVsCut->SetPoint(bin,cut,mjjHltRate);
totHltRateVsCut->SetPointError(bin,0.,mjjHltRateE);
pureHltRateVsCut->SetPoint(bin,cut,excl_mjjHltRate);
pureHltRateVsCut->SetPointError(bin,0.,excl_mjjHltRateE);
totL1RateVsCut->SetPoint(bin,cut,mjjL1Rate);
totL1RateVsCut->SetPointError(bin,0.,mjjL1RateE);
pureL1RateVsCut->SetPoint(bin,cut,excl_mjjL1Rate);
pureL1RateVsCut->SetPointError(bin,0.,excl_mjjL1RateE);
++bin;
}
//plotting and styling
TLegend* legHlt = new TLegend(0.62, 0.78, 0.83, 0.89);
legHlt->AddEntry(totHltRateVsCut,"hlt total rate","P");
legHlt->AddEntry(pureHltRateVsCut,"hlt pure rate wrt HT250","P");
TLegend* legL1 = new TLegend(0.62, 0.78, 0.83, 0.89);
legL1->AddEntry(totL1RateVsCut,"l1 total rate","P");
legL1->AddEntry(pureL1RateVsCut,"l1 pure rate wrt HTT240","P");
totHltRateVsCut->GetXaxis()->SetTitle("Mjj cut threshold [GeV]");
totHltRateVsCut->GetYaxis()->SetTitle("Rate @7E33 [Hz]");
totHltRateVsCut->SetMarkerColor(kRed);
pureHltRateVsCut->SetMarkerColor(kOrange+1);
totL1RateVsCut->GetXaxis()->SetTitle("Mjj cut threshold [GeV]");
totL1RateVsCut->GetYaxis()->SetTitle("Rate @7E33 [Hz]");
totL1RateVsCut->SetMarkerColor(kBlue);
totL1RateVsCut->SetMarkerColor(kAzure);
TCanvas* c4 = new TCanvas();
c4->cd();
totHltRateVsCut->Draw("AP");
pureHltRateVsCut->Draw("P,sames");
legHlt->Draw("sames");
c4->Update();
TGaxis *axisHlt = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),gPad->GetUxmax(), gPad->GetUymax(),
(totHltRateVsCut->GetYaxis()->GetBinLowEdge(1))*lumiScaleFactor,
(totHltRateVsCut->GetYaxis()->GetBinLowEdge(totHltRateVsCut->GetYaxis()->GetNbins())+totHltRateVsCut->GetYaxis()->GetBinWidth(1))*lumiScaleFactor,510,"+L");
c4->SetTicky(0);
axisHlt->SetLineColor(kRed);
axisHlt->SetLabelColor(kRed);
axisHlt->SetTextColor(kRed);
axisHlt->SetTitleOffset(1.3);
axisHlt->SetLabelSize(0.03);
axisHlt->SetTitle("Rate @1E34 [Hz]");
axisHlt->Draw();
c4->Print("rates/hltRate.pdf","pdf");
TCanvas* c5 = new TCanvas();
c5->cd();
totL1RateVsCut->Draw("AP");
pureL1RateVsCut->Draw("P,sames");
legL1->Draw("sames");
c5->Update();
TGaxis *axisL1 = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),gPad->GetUxmax(), gPad->GetUymax(),
(totL1RateVsCut->GetYaxis()->GetBinLowEdge(1))*lumiScaleFactor,
(totL1RateVsCut->GetYaxis()->GetBinLowEdge(totL1RateVsCut->GetYaxis()->GetNbins())+totL1RateVsCut->GetYaxis()->GetBinWidth(1))*lumiScaleFactor,510,"+L");
c5->SetTicky(0);
axisL1->SetLineColor(kRed);
axisL1->SetLabelColor(kRed);
axisL1->SetTextColor(kRed);
axisL1->SetTitleOffset(1.3);
axisL1->SetLabelSize(0.03);
axisL1->SetTitle("Rate @1E34 [Hz]");
axisL1->Draw();
c5->Print("rates/l1Rate.pdf","pdf");
return 0;
}
示例5: PlotPotential2D
//.........这里部分代码省略.........
C->cd(0);
char pname[16];
sprintf(pname,"pad_%i",1);
pad[0] = (TPad*) gROOT->FindObject(pname);
pad[0]->Draw();
pad[0]->cd(); // <---------------------------------------------- Top Plot ---------
if(opt.Contains("logz")) {
pad[0]->SetLogz(1);
} else {
pad[0]->SetLogz(0);
}
pad[0]->SetFrameLineWidth(3);
pad[0]->SetTickx(1);
// Re-range:
for(Int_t i=0; i<Nspecies; i++) {
if(!hDen2D[i]) continue;
hDen2D[i]->GetYaxis()->SetRangeUser(yMin -(factor-1)*yRange, yMax);
}
TH2F *hFrame = (TH2F*) gROOT->FindObject("hFrame1");
if(hFrame) delete hFrame;
hFrame = (TH2F*) hDen2D[0]->Clone("hFrame1");
hFrame->Reset();
hFrame->SetLabelFont(42,"xyz");
hFrame->SetTitleFont(42,"xyz");
hFrame->GetYaxis()->SetNdivisions(505);
hFrame->GetYaxis()->SetLabelSize(0.085);
hFrame->GetYaxis()->SetTitleSize(0.09);
hFrame->GetYaxis()->SetTitleOffset(0.7);
hFrame->GetYaxis()->SetTickLength(0.02);
hFrame->GetXaxis()->SetLabelOffset(999.);
hFrame->GetXaxis()->SetTitleOffset(999.);
hFrame->GetXaxis()->SetTickLength(0.04);
// Frame asymmetry:
hFrame->Draw("col");
// hDen2D[0]->GetZaxis()->SetNdivisions(505);
// Injected electrons if any
if(Nspecies>=3) {
if(hDen2D[2]) {
exHot->Draw();
hDen2D[2]->Draw("colz same");
}
}
// Plasma
hDen2D[0]->GetZaxis()->SetTitleFont(42);
exPlasma->Draw();
hDen2D[0]->Draw("colz same");
// Beam driver.
if(hDen2D[1]) {
// hDen2D[1]->GetZaxis()->SetNdivisions(505);
exElec->Draw();
hDen2D[1]->Draw("colz same");
}
{
示例6: PlotDensity1D
//.........这里部分代码省略.........
C->Update();
TLine *line0 = new TLine(hDen1D[0]->GetXaxis()->GetXmin(),
(gPad->GetUymin()+gPad->GetUymax())/2.,
hDen1D[0]->GetXaxis()->GetXmax(),
(gPad->GetUymin()+gPad->GetUymax())/2.);
line0->SetLineColor(kGray+1);
line0->SetLineStyle(2);
line0->Draw();
Float_t rightmax = 2.5 * hDen1D[1]->GetMaximum();
Float_t slope = (gPad->GetUymax() - gPad->GetUymin())/rightmax;
for(Int_t i=0;i<hDen1D[1]->GetNbinsX();i++) {
hDen1D[1]->SetBinContent(i+1,hDen1D[1]->GetBinContent(i+1)*slope + Min);
}
hDen1D[1]->SetLineWidth(2);
hDen1D[1]->SetLineColor(beamC);
hDen1D[1]->Draw("same C");
// hTest->Draw("same");
//draw an axis on the right side
TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),gPad->GetUxmax(),
gPad->GetUymax(),0,rightmax,505,"+L");
axis->SetLineWidth(1);
axis->SetLineColor(beamC);
axis->SetLabelColor(beamC);
if(opt.Contains("units") && n0)
axis->SetTitle("#LTn_{b}#GT [10^{15}/cm^{3}]");
else
axis->SetTitle("#LTn_{b}#GT [n_{0}]");
axis->CenterTitle();
axis->SetTitleColor(beamC);
axis->SetTitleOffset(1.2);
axis->Draw();
// Longitudinal Electric field
Float_t factor = 1.5;
Float_t rightmin = factor * hE1D[0]->GetMinimum();
rightmax = factor * hE1D[0]->GetMaximum();
if(hE1D[1]) {
if(hE1D[1]->GetMaximum() > hE1D[0]->GetMaximum())
rightmax = factor * hE1D[1]->GetMaximum();
}
if(rightmax > TMath::Abs(rightmin)) rightmin = -rightmax;
else rightmax = - rightmin;
slope = (gPad->GetUymax() - gPad->GetUymin())/(rightmax-rightmin);
for(Int_t i=0;i<hE1D[0]->GetNbinsX();i++) {
hE1D[0]->SetBinContent(i+1,(hE1D[0]->GetBinContent(i+1)-rightmin)*slope + Min);
}
hE1D[0]->SetLineStyle(1);
hE1D[0]->SetLineWidth(2);
hE1D[0]->SetLineColor(fieldC);
hE1D[0]->Draw("same C");
// Transverse field
for(Int_t i=0;i<hE1D[1]->GetNbinsX();i++) {
hE1D[1]->SetBinContent(i+1,(hE1D[1]->GetBinContent(i+1)-rightmin)*slope + Min);
}
hE1D[1]->SetLineStyle(2);
hE1D[1]->SetLineWidth(1);
hE1D[1]->SetLineColor(fieldC);
hE1D[1]->Draw("same C");
//draw an axis on the right side
Float_t rightmargin = 0.08;
Float_t ux = gPad->PixeltoX(gPad->UtoPixel(1-rightmargin));
TGaxis *axisE = new TGaxis(ux,gPad->GetUymin(),ux,
gPad->GetUymax(),rightmin,rightmax,505,"+L");
axisE->SetLineWidth(1);
axisE->SetLineColor(fieldC);
axisE->SetLabelColor(fieldC);
axisE->SetTitleColor(fieldC);
if(opt.Contains("units") && n0)
axisE->SetTitle("E [GV/m]");
else
axisE->SetTitle("E [E_{0}]");
axisE->CenterTitle();
axisE->SetTitleOffset(0.8);
axisE->Draw();
textTime->Draw();
textRange->Draw();
C->cd();
// Print to a file
PlasmaGlob::imgconv(C,fOutName,opt);
// ---------------------------------------------------------
}
示例7: PlotField1D
//.........这里部分代码省略.........
if(yEMaxPos[i][j]>maxPhase)
maxPhase = yEMaxPos[i][j];
if(yEMaxPos[i][j]<minPhase)
minPhase = yEMaxPos[i][j];
if(yEMaxValue[i][j]>maxField)
maxField = yEMaxValue[i][j];
if(yEMaxValue[i][j]<minField)
minField = yEMaxValue[i][j];
}
}
Float_t margin = (maxPhase - minPhase)/10;
gEMaxPos[0]->GetYaxis()->SetRangeUser(minPhase-margin,maxPhase+margin);
gEMaxPos[0]->GetYaxis()->CenterTitle();
gEMaxPos[0]->GetXaxis()->CenterTitle();
gEMaxPos[0]->SetLineColor(phaseC);
gEMaxPos[0]->SetMarkerColor(phaseC);
gEMaxPos[0]->SetLineWidth(3);
gEMaxPos[0]->SetMarkerStyle(20);
gEMaxPos[0]->SetMarkerSize(1.4);
gEMaxPos[0]->Draw("APC");
if(Nfields>1) {
gEMaxPos[1]->SetLineStyle(1);
gEMaxPos[1]->SetLineColor(phaseC);
gEMaxPos[1]->SetMarkerColor(phaseC);
gEMaxPos[1]->SetLineWidth(1);
gEMaxPos[1]->SetMarkerStyle(24);
gEMaxPos[1]->SetMarkerSize(1.4);
gEMaxPos[1]->Draw("PC");
}
// Emax value
// New axis first:
C->Update(); // Needed for the axis!
margin = (maxField - minField)/10;
if (margin==0) margin = 1;
Float_t rightmin = minField-margin;
Float_t rightmax = maxField+margin;
Float_t slope = (gPad->GetUymax() - gPad->GetUymin())/(rightmax-rightmin);
TGaxis *axisEmax = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),gPad->GetUxmax(),
gPad->GetUymax(),rightmin,rightmax,505,"+L");
axisEmax->SetLineWidth(1);
axisEmax->SetLineColor(fieldC);
axisEmax->SetLabelColor(fieldC);
axisEmax->SetTitleColor(fieldC);
if(opt.Contains("units") && n0)
axisEmax->SetTitle("E_{min} [GV/m]");
else
axisEmax->SetTitle("E_{min} [E_{0}]");
axisEmax->CenterTitle();
axisEmax->SetTitleSize(0.05);
axisEmax->SetTitleOffset(1.2);
axisEmax->SetLabelSize(0.05);
axisEmax->SetLabelOffset(0.006);
axisEmax->Draw();
// Adjust the TGraph
Double_t *x = gEMaxValue[0]->GetX();
Double_t *y = gEMaxValue[0]->GetY();
for(Int_t i=0;i<gEMaxValue[0]->GetN();i++) {
gEMaxValue[0]->SetPoint(i,x[i],(y[i]-rightmin)*slope + gPad->GetUymin());
}
gEMaxValue[0]->SetLineColor(fieldC);
gEMaxValue[0]->SetMarkerColor(fieldC);
gEMaxValue[0]->SetLineWidth(3);
gEMaxValue[0]->SetMarkerStyle(20);
gEMaxValue[0]->SetMarkerSize(1.4);
gEMaxValue[0]->Draw("PC");
if(Nfields>1) {
x = gEMaxValue[1]->GetX();
y = gEMaxValue[1]->GetY();
for(Int_t i=0;i<gEMaxValue[1]->GetN();i++) {
gEMaxValue[1]->SetPoint(i,x[i],(y[i]-rightmin)*slope + gPad->GetUymin());
}
gEMaxValue[1]->SetLineColor(fieldC);
gEMaxValue[1]->SetMarkerColor(fieldC);
gEMaxValue[1]->SetLineWidth(1);
gEMaxValue[1]->SetMarkerStyle(24);
gEMaxValue[1]->SetMarkerSize(1.4);
gEMaxValue[1]->Draw("PC");
}
// Emax value
// New axis first:
C->Update(); // Needed for the axis!
C->cd();
ifile->Close();
// Print to a file
PlasmaGlob::imgconv(C,fOutName,opt);
// ---------------------------------------------------------
}