本文整理汇总了C++中TGaxis类的典型用法代码示例。如果您正苦于以下问题:C++ TGaxis类的具体用法?C++ TGaxis怎么用?C++ TGaxis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TGaxis类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: twoscales
void twoscales()
{
TCanvas *c1 = new TCanvas("c1","hists with different scales",600,400);
//create/fill draw h1
gStyle->SetOptStat(kFALSE);
TH1F *h1 = new TH1F("h1","my histogram",100,-3,3);
Int_t i;
for (i=0;i<10000;i++) h1->Fill(gRandom->Gaus(0,1));
h1->Draw();
c1->Update();
//create hint1 filled with the bins integral of h1
TH1F *hint1 = new TH1F("hint1","h1 bins integral",100,-3,3);
Float_t sum = 0;
for (i=1;i<=100;i++) {
sum += h1->GetBinContent(i);
hint1->SetBinContent(i,sum);
}
//scale hint1 to the pad coordinates
Float_t rightmax = 1.1*hint1->GetMaximum();
Float_t scale = gPad->GetUymax()/rightmax;
hint1->SetLineColor(kRed);
hint1->Scale(scale);
hint1->Draw("same");
//draw an axis on the right side
TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"+L");
axis->SetLineColor(kRed);
axis->SetLabelColor(kRed);
axis->Draw();
}
示例2: xyplot
void xyplot()
{
TCanvas *c = new TCanvas("c","XY plot",200,10,700,500);
// Remove the frame
c->SetFillColor(kWhite);
c->SetFrameLineColor(kWhite);
c->SetFrameBorderMode(0);
// Define and draw a curve the frame
const Int_t n = 4;
Double_t x[n] = {-1, -3, -9, 3};
Double_t y[n] = {-1000, 900, 300, 300};
gr = new TGraph(n,x,y);
gr->SetTitle("XY plot");
gr->SetMinimum(-1080);
gr->SetMaximum(1080);
gr->SetLineColor(kRed);
gr->Draw("AC*");
// Remove the frame's axis
gr->GetHistogram()->GetYaxis()->SetTickLength(0);
gr->GetHistogram()->GetXaxis()->SetTickLength(0);
gr->GetHistogram()->GetYaxis()->SetLabelSize(0);
gr->GetHistogram()->GetXaxis()->SetLabelSize(0);
gr->GetHistogram()->GetXaxis()->SetAxisColor(0);
gr->GetHistogram()->GetYaxis()->SetAxisColor(0);
gPad->Update();
// Draw orthogonal axis system centered at (0,0).
// Draw the Y axis. Note the 4th label is erased with SetLabelAttributes
TGaxis *yaxis = new TGaxis(0, gPad->GetUymin(),
0, gPad->GetUymax(),
gPad->GetUymin(),gPad->GetUymax(),6,"+LN");
yaxis->ChangeLabel(4,-1,0.);
yaxis->Draw();
// Draw the Y-axis title.
TLatex *ytitle = new TLatex(-0.5,gPad->GetUymax(),"Y axis");
ytitle->Draw();
ytitle->SetTextSize(0.03);
ytitle->SetTextAngle(90.);
ytitle->SetTextAlign(31);
// Draw the X axis
TGaxis *xaxis = new TGaxis(gPad->GetUxmin(), 0,
gPad->GetUxmax(), 0,
gPad->GetUxmin(),gPad->GetUxmax(),510,"+L");
xaxis->Draw();
// Draw the X axis title.
TLatex *xtitle = new TLatex(gPad->GetUxmax(),-200.,"X axis");
xtitle->Draw();
xtitle->SetTextAlign(31);
xtitle->SetTextSize(0.03);
}
示例3: ReverseXAxis
ReverseXAxis (TGraphAsymmErrors *g, double size)
{
// Remove the current axis
g->GetXaxis()->SetLabelOffset(999);
g->GetXaxis()->SetTickLength(0);
// Redraw the new axis
gPad->Update();
g->GetYaxis()->SetTitle("Event Selection Efficiency");
TGaxis *newaxis = new TGaxis(gPad->GetUxmax(),
gPad->GetUymin(),
gPad->GetUxmin(),
gPad->GetUymin(),
g->GetXaxis()->GetXmin(),
g->GetXaxis()->GetXmax(),
510,"-");
newaxis->SetLabelOffset(-0.04);
newaxis->SetTitle("Centrality");
newaxis->SetTitleFont(42);
newaxis->SetTitleSize(size);
newaxis->SetLabelSize(size);
newaxis->CenterTitle();
newaxis->SetLabelFont(42);
newaxis->Draw();
}
示例4: transpad
// Example of a canvas showing two histograms with different scales.
// The second histogram is drawn in a transparent pad
void transpad() {
TCanvas *c1 = new TCanvas("c1","transparent pad",200,10,700,500);
TPad *pad1 = new TPad("pad1","",0,0,1,1);
TPad *pad2 = new TPad("pad2","",0,0,1,1);
pad2->SetFillStyle(4000); //will be transparent
pad1->Draw();
pad1->cd();
TH1F *h1 = new TH1F("h1","h1",100,-3,3);
TH1F *h2 = new TH1F("h2","h2",100,-3,3);
TRandom r;
for (Int_t i=0;i<100000;i++) {
Double_t x1 = r.Gaus(-1,0.5);
Double_t x2 = r.Gaus(1,1.5);
if (i <1000) h1->Fill(x1);
h2->Fill(x2);
}
h1->Draw();
pad1->Update(); //this will force the generation of the "stats" box
TPaveStats *ps1 = (TPaveStats*)h1->GetListOfFunctions()->FindObject("stats");
ps1->SetX1NDC(0.4); ps1->SetX2NDC(0.6);
pad1->Modified();
c1->cd();
//compute the pad range with suitable margins
Double_t ymin = 0;
Double_t ymax = 2000;
Double_t dy = (ymax-ymin)/0.8; //10 per cent margins top and bottom
Double_t xmin = -3;
Double_t xmax = 3;
Double_t dx = (xmax-xmin)/0.8; //10 per cent margins left and right
pad2->Range(xmin-0.1*dx,ymin-0.1*dy,xmax+0.1*dx,ymax+0.1*dy);
pad2->Draw();
pad2->cd();
h2->SetLineColor(kRed);
h2->Draw("sames");
pad2->Update();
TPaveStats *ps2 = (TPaveStats*)h2->GetListOfFunctions()->FindObject("stats");
ps2->SetX1NDC(0.65); ps2->SetX2NDC(0.85);
ps2->SetTextColor(kRed);
// draw axis on the right side of the pad
TGaxis *axis = new TGaxis(xmax,ymin,xmax,ymax,ymin,ymax,50510,"+L");
axis->SetLabelColor(kRed);
axis->Draw();
}
示例5: ReverseXAxis
void ReverseXAxis (TH1 *h)
{
h->GetXaxis()->SetLabelOffset(999);
h->GetXaxis()->SetTickLength(0);
gPad->Update();
TGaxis *newaxis = new TGaxis(gPad->GetUxmax(),
gPad->GetUymin(),
gPad->GetUxmin(),
gPad->GetUymin(),
h->GetXaxis()->GetXmin(),
h->GetXaxis()->GetXmax(),
510,"-");
newaxis->SetLabelOffset(-0.03);
newaxis->SetTitle("X[cm]");
newaxis->CenterTitle(1);
newaxis->Draw();
}
示例6: drawLabels
void drawLabels(){
TLatex l;
l.SetTextSize(0.04);
l.DrawLatex(500,50,"-z");
l.DrawLatex(500,1430,"+z");
l.DrawLatex(900,330,"TIB L1");
l.DrawLatex(900,1000,"TIB L2");
l.DrawLatex(1300,330,"TIB L3");
l.DrawLatex(1300,1000,"TIB L4");
l.DrawLatex(1700,330,"TOB L1");
l.DrawLatex(1700,1000,"TOB L2");
l.DrawLatex(2100,330,"TOB L3");
l.DrawLatex(2100,1000,"TOB L4");
l.DrawLatex(2500,330,"TOB L5");
l.DrawLatex(2500,1000,"TOB L6");
TArrow arx(2900,1190,2900,1350,0.01,"|>");
l.DrawLatex(2915,1350,"x");
TArrow ary(2900,1190,2790,1190,0.01,"|>");
l.DrawLatex(2790,1210,"y");
TArrow arz(2790,373,2790,672,0.01,"|>");
l.DrawLatex(2820,667,"z");
TArrow arphi(2790,511,2447,511,0.01,"|>");
l.DrawLatex(2433,520,"#Phi");
arx.SetLineWidth(3);
ary.SetLineWidth(3);
arz.SetLineWidth(3);
arphi.SetLineWidth(3);
arx.Draw();
ary.Draw();
arz.Draw();
arphi.Draw();
//FIXME : when tkmaps with taxis in color palette, introduce this
TGaxis* axis = new TGaxis(3060,hmin,3060,hmax,0,100,510,"+L");
axis->SetLabelSize(0.02);
axis->Draw();
canvas->Update();
}
示例7: 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.);
}
示例8: draw_sigvsback
//.........这里部分代码省略.........
legend->AddEntry(hist_sig, (sig_label+": "+to_string_with_precision(hist_sig->Integral())+" events").c_str());
legend->AddEntry(hist_back, (back_label+": "+to_string_with_precision(hist_back->Integral())+" events").c_str());
*/
legend->AddEntry(hist_sig, (sig_label).c_str());
legend->AddEntry(hist_back, (back_label).c_str());
canvas = new TCanvas(cname.c_str());
TPad * pad_base = new TPad();
pad_base->Draw();
pad_base->SetFillColor(0);
double ymin_base = hist_sig->GetYaxis()->GetXmin();
double ymax_base = hist_sig->GetYaxis()->GetXmax();
double dy_base = (ymax_base-ymin_base)/0.8;
double xmin_base = hist_sig->GetXaxis()->GetXmin();
double xmax_base = hist_sig->GetXaxis()->GetXmax();
double dx_base = (xmax_base-xmin_base)/0.8;
pad_base->Range(xmin_base-0.1*dx_base,ymin_base-0.1*dy_base,xmax_base+0.1*dx_base,ymax_base+0.1*dy_base);
pad_base->cd();
hist_back->Draw();
hist_sig->Draw("same");
if(!significance && !efficiency) legend->Draw();
//////
hist_sig->Scale(run_pot / signal_pot);
hist_back->Scale(run_pot / background_pot);
//////
TGraph * graph_sig = nullptr;
TPad * pad_sig = nullptr;
if(significance) {
graph_sig = getgraphsig(hist_sig, hist_back, forwards);
canvas->cd();
pad_sig = new TPad();
pad_sig->SetFillStyle(4000);
double ymin = graph_sig->GetYaxis()->GetXmin();
double ymax = graph_sig->GetYaxis()->GetXmax();
double dy = (ymax-ymin)/0.8;
double xmax = 0;
double ytemp = 0;
graph_sig->GetPoint(graph_sig->GetN()-1, xmax, ytemp);
pad_sig->Range(xmin_base-0.1*dx_base,ymin-0.1*dy,xmax_base+0.1*dx_base,ymax+0.1*dy);
pad_sig->Draw();
pad_sig->cd();
graph_sig->Draw("samep");
TGaxis * axis = new TGaxis(xmax_base,ymin,xmax_base,ymax,ymin,ymax, 510, "+L");
axis->SetLabelColor(graph_sig->GetMarkerColor());
axis->SetLabelSize(0.03);
axis->Draw();
legend->AddEntry(graph_sig, "Significance");
if(!efficiency) legend->Draw();
}
TGraph * graph_eff = nullptr;
TPad * pad_eff = nullptr;
if(efficiency) {
graph_eff = getgrapheff(hist_sig, forwards);
canvas->cd();
pad_eff = new TPad();
pad_eff->SetFillStyle(4000);
double ymin = graph_eff->GetYaxis()->GetXmin();
double ymax = graph_eff->GetYaxis()->GetXmax();
double dy = (ymax-ymin)/0.8;
double xmax = 0;
double ytemp = 0;
graph_eff->GetPoint(graph_eff->GetN()-1, xmax, ytemp);
pad_eff->Range(xmin_base-0.1*dx_base,ymin-0.1*dy,xmax_base+0.1*dx_base,ymax+0.1*dy);
pad_eff->Draw();
pad_eff->cd();
graph_eff->Draw("samep");
double axis_offset = 0;
if(significance) axis_offset = 1./14*xmax;
TGaxis * axis = new TGaxis(xmax_base+axis_offset,ymin,xmax_base+axis_offset,ymax,ymin,ymax, 510, "+L");
axis->SetLabelColor(graph_eff->GetMarkerColor());
axis->SetLabelSize(0.03);
axis->Draw();
legend->AddEntry(graph_eff, "Efficiency");
legend->Draw();
}
hist_sig->Scale(signal_pot / run_pot);
hist_sig->Scale(1. / hist_sig->Integral());
hist_back->Scale(background_pot / run_pot);
hist_back->Scale(1. / hist_back->Integral());
double const ymin_hist = 0;
double ymax_hist = hist_sig->GetMaximum();
if(hist_back->GetMaximum() > ymax_hist) ymax_hist = hist_back->GetMaximum();
hist_back->GetYaxis()->SetRangeUser(ymin_hist, 1.1*ymax_hist);
canvas->Write();
delete canvas;
delete hist_sig;
delete hist_back;
delete legend;
if(graph_sig) delete graph_sig;
if(graph_eff) delete graph_eff;
}
示例9: drawmat_DBD
//.........这里部分代码省略.........
hmat[ihist] = new TH1F(hname[ihist],"",nbin,xmin,xmax);
//// ensure proper errors
// hmat[ihist]->Sumw2();
hmat[ihist]->SetLineColor(color[ihist]);
hmat[ihist]->SetLineWidth(3);
hmat[ihist]->SetTitle(";#theta / degrees;X_{0}");
}
// read tree
TFile* file = new TFile ( FILEN ) ;
TTree* tree = (TTree *) file->Get("ntuple");
if (!tree) {
cout << "ERROR: Couldn't open tree ntuple on file: "<< FILEN << endl;
return 1;
}
tree->SetBranchAddress("itheta", &itheta);
tree->SetBranchAddress("nrecal", &nrecal);
tree->SetBranchAddress("nrset", &nrset);
tree->SetBranchAddress("nrtpc", &nrtpc);
tree->SetBranchAddress("nrtpc_i", &nrtpc_i);
tree->SetBranchAddress("nrsit", &nrsit);
tree->SetBranchAddress("nrvxd", &nrvxd);
int entries = tree->GetEntries();
cout << "tree has " << entries << " entries" << endl;
// event loop
for (int ievt = 0; ievt < entries; ++ievt) {
tree->GetEntry(ievt);
if (itheta < 4.45) continue;
hmat[0]->Fill(-itheta,nrecal);
hmat[1]->Fill(-itheta,nrset);
hmat[2]->Fill(-itheta,nrtpc);
if( itheta > 8. )
hmat[3]->Fill(-itheta,nrtpc_i);
hmat[4]->Fill(-itheta,nrsit);
hmat[5]->Fill(-itheta,nrvxd);
hmat[6]->Fill(-itheta,1);
}
// for (int ibin = 0; ibin < nbin+1; ++ibin) {
// cout << "Bin " << ibin << " has " << hmat[4]->GetBinContent(ibin) << " entries" << endl;
// }
c1 = new TCanvas("c1","c1",600,600);
bool first = true ;
#define _include_Ecal 0
#if _include_Ecal
for (int ihist = 0; ihist < nhist-1; ihist++) {
#else
for (int ihist = 1; ihist < nhist-1; ihist++) {
#endif
// average double counts
hmat[ihist]->Divide( hmat[nhist-1] );
if( first ) {
hmat[ihist]->Draw( "" );
// --------- change axis labels from minus to plus --------
c1->Update() ;
TF1 *f1 = new TF1("f1","-x",0,90);
hmat[ihist]->GetXaxis()->SetLabelOffset(99);
Double_t x_min = c1->GetUxmin();
Double_t x_max = c1->GetUxmax();
Double_t y_min = c1->GetUymin();
//std::cout << "x_min " << x_min << " x_max " << x_max << " y_min " << y_min << std::endl ;
TGaxis *axis = new TGaxis( x_min, y_min, x_max, y_min, "f1", 5);
axis->SetLabelSize( 0.06 );
axis->SetLabelFont( 42 );
axis->Draw();
// -----end: change axis labels from minus to plus --------
first = false ;
} else {
hmat[ihist]->Draw( "same" );
}
leg->AddEntry(hmat[ihist],htitle[ihist],"L");
}
leg->Draw();
std::string pdfFile( std::string( FILEN ) + std::string( ".pdf" ) ) ;
c1->Print( pdfFile.c_str() ) ;
}
示例10: composeTrackAnalysisbyAssociator
//.........这里部分代码省略.........
double maxY = 40;
TCanvas* myCanvas = new TCanvas("Canvas", "Canvas", 800, 600);
myCanvas->cd();
TPad* myPad = new TPad("Pad", "Pad", 0, 0, 1, 1);
myPad->Draw();
myPad->cd();
((TH1D*)(myParticleHist->At(0)))->SetStats(0);
((TH1D*)(myParticleHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev");
((TH1D*)(myParticleHist->At(0)))->GetXaxis()->CenterTitle(1);
((TH1D*)(myParticleHist->At(0)))->Draw();
for(int Index = 0; Index < FileNumber; Index++) {
((TH1D*)(mySTAHist->At(Index)))->SetStats(0);
((TH1D*)(mySTAHist->At(Index)))->SetLineColor(kRed+Index);
((TH1D*)(mySTAHist->At(Index)))->Draw("same");
}
TLegend *STALeg = new TLegend(0.6,0.1,0.9,0.3);
STALeg->SetBorderSize(1);
TString LegKey = "ParticleTrack";
STALeg->AddEntry(myParticleHist->At(0), LegKey, "lpf");
for(int Index = 0; Index < FileNumber; Index++) {
LegKey = TypeName[Index];
STALeg->AddEntry(mySTAHist->At(Index), LegKey, "lpf");
}
STALeg->Draw();
string SaveName = OutputPlotNamepreFix + "_STA2simPt" + OutputPlotNameFix;
myCanvas->SaveAs(SaveName.c_str());
myPad->Clear();
myPad->Update();
double YScale = myPad->GetUymax() / 110.;
((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev");
((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->CenterTitle(1);
((TH1D*)(myEfficiencyHist->At(0)))->SetStats(0);
((TH1D*)(myEfficiencyHist->At(0)))->Scale(YScale);
((TH1D*)(myEfficiencyHist->At(0)))->SetLineColor(kRed);
((TH1D*)(myEfficiencyHist->At(0)))->Draw("same,ah");
for(int Index = 1; Index < FileNumber; Index++) {
((TH1D*)(myEfficiencyHist->At(Index)))->SetStats(0);
((TH1D*)(myEfficiencyHist->At(Index)))->Scale(YScale);
((TH1D*)(myEfficiencyHist->At(Index)))->SetLineColor(kRed+Index);
((TH1D*)(myEfficiencyHist->At(Index)))->Draw("same,ah");
}
myPad->Update();
if(debug) cout << "Y: " << myPad->GetUymax() << endl;
double YAxisMinValue=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetXmin();
double YAxisMaxValue=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetXmax();
int YAxisNBins=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetNbins();
TGaxis* YAxis = new TGaxis(myPad->GetUxmin(), myPad->GetUymin(), myPad->GetUxmin(), myPad->GetUymax(), 0, 110, 510, "-R");
YAxis->SetLineColor(kGreen);
YAxis->SetLabelColor(kGreen);
YAxis->SetTitle("Efficiency of STA for simPts");
YAxis->CenterTitle(1);
YAxis->Draw();
double XAxisMinValue=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetXmin();
double XAxisMaxValue=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetXmax();
int XAxisNBins=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetNbins();
TGaxis* XAxis = new TGaxis(myPad->GetUxmin(), myPad->GetUymin(), myPad->GetUxmax(), myPad->GetUymin(), XAxisMinValue, XAxisMaxValue, 510, "+L");
XAxis->SetTitle("simPt/Gev");
XAxis->CenterTitle(1);
XAxis->Draw();
TLegend *EffLeg = new TLegend(0.1,0.9,0.4,1.0);
EffLeg->SetBorderSize(1);
for(int Index = 0; Index < FileNumber; Index++) {
TString LegKey = TypeName[Index];
EffLeg->AddEntry(myEfficiencyHist->At(Index), LegKey, "lpf");
}
EffLeg->Draw();
string SaveName = OutputPlotNamepreFix + "_Eff2simPt" + OutputPlotNameFix;
myCanvas->SaveAs(SaveName.c_str());
((TH1D*)(myDeltaPtHist->At(0)))->SetStats(0);
((TH1D*)(myDeltaPtHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev");
((TH1D*)(myDeltaPtHist->At(0)))->GetXaxis()->CenterTitle(1);
((TH1D*)(myDeltaPtHist->At(0)))->GetYaxis()->SetTitle("deltPt/simPt");
((TH1D*)(myDeltaPtHist->At(0)))->GetYaxis()->CenterTitle(1);
((TH1D*)(myDeltaPtHist->At(0)))->SetLineColor(kRed);
((TH1D*)(myDeltaPtHist->At(0)))->Draw("");
for(int Index = 1; Index < FileNumber; Index++) {
((TH1D*)(myDeltaPtHist->At(Index)))->SetStats(0);
//((TH1D*)(myDeltaPtHist->At(Index)))->GetXaxis()->SetTitle("simPt/Gev");
//((TH1D*)(myDeltaPtHist->At(Index)))->GetXaxis()->CenterTitle(1);
//((TH1D*)(myDeltaPtHist->At(Index)))->GetYaxis()->SetTitle("deltPt/simPt");
//((TH1D*)(myDeltaPtHist->At(Index)))->GetYaxis()->CenterTitle(1);
((TH1D*)(myDeltaPtHist->At(Index)))->SetLineColor(kRed+Index);
((TH1D*)(myDeltaPtHist->At(Index)))->Draw("same");
//SaveName = OutputPlotNamepreFix + TypeName[Index] + "DeltaPt" + OutputPlotNameFix;
//myCanvas->SaveAs(SaveName.c_str());
}
TLegend *PtLeg = new TLegend(0.6,0.8,0.9,0.9);
PtLeg->SetBorderSize(1);
for(int Index = 0; Index < FileNumber; Index++) {
TString LegKey = TypeName[Index];
PtLeg->AddEntry(myDeltaPtHist->At(Index), LegKey, "lpf");
}
PtLeg->Draw();
SaveName = OutputPlotNamepreFix + "_DeltaPt" + OutputPlotNameFix;
myCanvas->SaveAs(SaveName.c_str());
}
示例11: PlotPotential2D
//.........这里部分代码省略.........
// Plasma on-axis density:
// hDen1D[0]->SetLineWidth(2);
// hDen1D[0]->SetLineColor(kGray+1);
// // // PlasmaGlob::SetH1Style(hDen1D[0],1);
// hDen1D[0]->Draw("same C");
if(opt.Contains("curr")) {
hCur1D[1]->SetLineWidth(2);
hCur1D[1]->SetLineColor(PlasmaGlob::elecLine);
hCur1D[1]->Draw("same C");
} else {
hDen1D[1]->SetLineWidth(2);
hDen1D[1]->SetLineColor(PlasmaGlob::elecLine);
// hDen1D[1]->Draw("same C");
}
if(Nspecies>=3) {
if(hDen1D[2]) {
if(opt.Contains("curr")) {
hCur1D[2]->SetLineWidth(2);
hCur1D[2]->SetLineColor(kOrange+8);
hCur1D[2]->Draw("same C");
} else {
hDen1D[2]->SetLineWidth(2);
hDen1D[2]->SetLineColor(kOrange+8);
// hDen1D[2]->Draw("same C");
}
}
}
// Current axis
TGaxis *axis = NULL;
if(opt.Contains("curr")) {
axis = new TGaxis(xMax-xRange/6.0,yMin - (factor-1)*yRange,
xMax-xRange/6.0,yaxismax,
0.001,curmax,503,"+LS");
axis->SetLineWidth(1);
axis->SetLineColor(kGray+3);//PlasmaGlob::elecLine);
axis->SetLabelColor(kGray+3);//PlasmaGlob::elecLine);
axis->SetLabelSize(0.06);
axis->SetLabelOffset(0.01);
axis->SetLabelFont(42);
axis->SetTitleColor(kGray+3);//PlasmaGlob::elecLine);
axis->SetTitleSize(0.06);
axis->SetTitleOffset(0.6);
axis->SetTitleFont(42);
axis->SetTickSize(0.03);
axis->SetTitle("I [kA]");
axis->CenterTitle();
axis->SetNdivisions(505);
axis->Draw();
}
TPaveText *textTime = new TPaveText(xMax - 0.3*xRange, yMax-0.15*yRange, xMax-0.1, yMax-0.05*yRange);
//x2-0.17,y2-0.12,x2-0.02,y2-0.02,"NDC");
PlasmaGlob::SetPaveTextStyle(textTime,32);
char ctext[128];
if(opt.Contains("units") && n0)
sprintf(ctext,"z = %5.1f #mum", Time * skindepth / PUnits::um);
else
sprintf(ctext,"t = %5.1f #omega_{p}^{-1}",Time);
示例12: ZinvEstimate
//.........这里部分代码省略.........
legP->AddEntry(gr_mcPred,"Zinv MC Pred ","P");
legP->AddEntry(gr_estimated,"Estimated(from #gamma +Jets)","P");
char TMgname1[100];
TMultiGraph *TMg_1D[2];
for(int k0=0;k0<2;k0++){
sprintf(TMgname1,"TMg_1D%i",k0);
TMg_1D[k0]=new TMultiGraph();
}
for(int j0=0;j0<2;j0++){
TMg_1D[j0]->SetMinimum(0.01);
TMg_1D[j0]->SetMaximum(2000);
}
TMg_1D[0]->SetTitle(" ;ith Bin ; Events ");
TMg_1D[0]->Add(gr_mcPred);
TMg_1D[0]->Add(gr_estimated);
TMg_1D[0]->Draw("AP");
TMg_1D[0]->GetXaxis()->SetLimits(0.5,18.5);
tpa->Draw();
pCMS->Draw();
legP->Draw();
TGaxis *axis = new TGaxis( -5, 20, -5, 220, 20,220,510,"");
axis->SetLabelFont(43); // Absolute font size in pixel (precision 3)
axis->SetLabelSize(15);
axis->Draw();
cPredVsEstimated->cd();
TPad *pad2 = new TPad("pad2", "pad2", 0, 0.05, 1, 0.3);
pad2->SetTopMargin(0);
pad2->SetBottomMargin(0.2);
pad2->SetGridy(); // vertical grid
pad2->Draw();
pad2->cd(); // pad2 becomes the current pad
TH1F *h3 = (TH1F*)h_NZinv18binC->Clone("h3");
h3->SetLineColor(kBlack);
h3->SetMinimum(-1); // Define Y ..
h3->SetMaximum(3); // .. range
h3->Sumw2();
h3->SetStats(0); // No statistics on lower plot
h3->Divide(ZinvEstimate);
h3->SetMarkerStyle(21);
h3->SetMarkerColor(1);
h3->Draw("ep"); // Draw the r
h3->GetXaxis()->SetTitle("ith Bin"); // Remove the ratio title
// Y axis ratio plot settings
h3->GetYaxis()->SetTitle("Pred/Est");
h3->GetYaxis()->SetNdivisions(505);
示例13: PlotDensity1D
//.........这里部分代码省略.........
C->cd(0);
gPad->SetFrameLineWidth(2);
hDen1D[0]->SetLineColor(plasmaC);
hDen1D[0]->SetLineWidth(1);
hDen1D[0]->Draw("C");
hDen1D[0]->GetYaxis()->CenterTitle();
hDen1D[0]->GetXaxis()->CenterTitle();
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);
}
示例14: drawintlen_DBD
//.........这里部分代码省略.........
// int color[nhist] = {9,8,2,38,1};
int color[nhist] = {8,2,38,1,9};
TString option[nhist];
option[0] = "same";
option[1] = "same";
option[2] = "";
option[3] = "";
option[4] = "";
// TLegend *leg = new TLegend (0.25, 0.6, 0.5, 0.85);
TLegend *leg = new TLegend (0.25, 0.3, 0.6, 0.55);
leg->SetFillStyle(0);
// stuff for histograms
TH1F* hmat[nhist];
for (int ihist = 0; ihist < nhist; ihist++) {
hmat[ihist] = new TH1F(hname[ihist],"",nbin,xmin,xmax);
//// ensure proper errors
// hmat[ihist]->Sumw2();
hmat[ihist]->SetLineColor(color[ihist]);
hmat[ihist]->SetLineWidth(3);
hmat[ihist]->SetTitle(";#theta / degrees;Interaction Lengths");
}
// read tree
TFile* file = new TFile ( FILEN ) ;
TTree* tree = (TTree *) file->Get("ntuple");
if (!tree) {
cout << "ERROR: Couldn't open tree ntuple on file: "<< FILEN << endl;
return 1;
}
tree->SetBranchAddress("theta", &theta);
tree->SetBranchAddress("thedeg",&thedeg);
tree->SetBranchAddress("nlset", &nlset);
tree->SetBranchAddress("nlecal", &nlecal);
tree->SetBranchAddress("nlhcal", &nlhcal);
tree->SetBranchAddress("nlcoil", &nlcoil);
tree->SetBranchAddress("nlyoke", &nlyoke);
int entries = tree->GetEntries();
cout << "tree has " << entries << " entries" << endl;
// event loop
for (int ievt = 0; ievt < entries; ++ievt) {
tree->GetEntry(ievt);
//, if (thedeg < 4.41) continue; // ???
hmat[0]->Fill(-thedeg,nlecal);
hmat[1]->Fill(-thedeg,nlhcal);
hmat[2]->Fill(-thedeg,nlcoil);
hmat[3]->Fill(-thedeg,nlyoke);
hmat[4]->Fill(-thedeg,1);
}
// for (int ibin = 0; ibin < nbin+1; ++ibin) {
// cout << "Bin " << ibin << " has " << hmat[4]->GetBinContent(ibin) << " entries" << endl;
// }
c1 = new TCanvas("c1","c1",600,600);
hmat[2]->GetYaxis()->SetRangeUser(0.,14.) ;
// for (int ihist = 0; ihist < nhist-2; ihist++) {
for (int ihist = nhist-3 ; ihist >=0 ; --ihist) {
// average double counts
hmat[ihist]->Divide( hmat[4] ) ;
// draw
hmat[ihist]->Draw(option[ihist]);
if( ihist == nhist-3 ){
c1->Update() ;
TF1 *f1 = new TF1("f1","-x",0,90);
hmat[ihist]->GetXaxis()->SetLabelOffset(99);
Double_t x_min = c1->GetUxmin();
Double_t x_max = c1->GetUxmax();
Double_t y_min = c1->GetUymin();
//std::cout << "x_min " << x_min << " x_max " << x_max << " y_min " << y_min << std::endl ;
TGaxis *axis = new TGaxis( x_min, y_min, x_max, y_min, "f1", 5);
axis->SetLabelSize( 0.06 );
axis->SetLabelFont( 42 );
axis->Draw();
}
leg->AddEntry(hmat[ihist],htitle[ihist],"L");
}
leg->Draw();
std::string pdfFile( std::string( FILEN ) + std::string( ".pdf" ) ) ;
c1->Print( pdfFile.c_str() ) ;
}
示例15: 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;
}