本文整理汇总了C++中TGaxis::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ TGaxis::Draw方法的具体用法?C++ TGaxis::Draw怎么用?C++ TGaxis::Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGaxis
的用法示例。
在下文中一共展示了TGaxis::Draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: TGaxis
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();
}
示例3: 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();
}
示例4: 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.);
}
示例5: 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();
}
示例6: 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();
}
示例7: 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();
}
示例8: draw_sigvsback
void draw_sigvsback(std::string const & cname,
std::string const & dr,
std::string const & binning,
std::string const & we_sig,
std::string const & sig_label,
std::string const & we_back,
std::string const & back_label,
std::string const & op = "",
std::string const & title = "",
std::string const & xtitle = "",
std::string const & ytitle = "",
bool const significance = false,
bool const efficiency = false,
bool const forwards = false) {
TString hname_sig = "h_sig";
TString draw_str_sig = "";
draw_str_sig += dr;
draw_str_sig += ">>";
draw_str_sig += hname_sig;
draw_str_sig += binning;
TString hname_back = "h_back";
TString draw_str_back = "";
draw_str_back += dr;
draw_str_back += ">>";
draw_str_back += hname_back;
draw_str_back += binning;
TCanvas * canvas = new TCanvas("temp");
if(tree2)
tree2->Draw(draw_str_sig.Data(),
we_sig.c_str(),
op.c_str());
else
tree->Draw(draw_str_sig.Data(),
we_sig.c_str(),
op.c_str());
delete canvas;
canvas = new TCanvas("temp");
tree->Draw(draw_str_back.Data(),
we_back.c_str(),
op.c_str());
delete canvas;
TH1F * hist_sig = (TH1F*)gDirectory->Get(hname_sig.Data());
TH1F * hist_back = (TH1F*)gDirectory->Get(hname_back.Data());
if(hist_sig->GetEntries() == 0)
std::cout << "draw_sigvsback: No signal for selection: \"" << we_sig << "\"\n";
if(hist_back->GetEntries() == 0)
std::cout << "draw_sigvsback: No background for selection: \"" << we_back << "\"\n";
hist_back->SetStats(0);
hist_back->SetTitle(title.c_str());
hist_back->GetXaxis()->SetTitle(xtitle.c_str());
hist_back->GetXaxis()->CenterTitle();
hist_back->GetYaxis()->SetTitle(ytitle.c_str());
hist_back->GetYaxis()->CenterTitle();
hist_sig->SetLineColor(kRed);
hist_back->SetLineColor(kBlue);
TLegend * legend = new TLegend(0.6, 0.9, 0.9, 0.6);
/*
legend->SetHeader(("Total: "+to_string_with_precision(hist_sig->Integral()+hist_back->Integral())+" events").c_str());
((TLegendEntry*)legend->GetListOfPrimitives()->First())->SetTextAlign(22);
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();
//.........这里部分代码省略.........
示例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: 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;
}
示例11: PlotPotential2D
//.........这里部分代码省略.........
hV1D->SetBinContent(j, hV1D->GetBinContent(j) - Vmin -trapPotential);
}
}
Vmin = hV1D->GetMinimum();
Float_t Vmax = hV1D->GetMaximum();
// Dynamic potential palette
const Int_t potPNRGBs = 5;
const Int_t potPNCont = 64;
Float_t zeroPos = -Vmin/(Vmax-Vmin);
Double_t potPStops[potPNRGBs] = { 0.00, zeroPos-3.0/potPNCont,zeroPos, zeroPos+3.0/potPNCont, 1.00 };
Double_t potPRed[potPNRGBs] = { 0.518, 0.965, 0.90, 0.498, 0.106 };
Double_t potPGreen[potPNRGBs] = { 0.078, 0.925, 0.90, 0.718, 0.078 };
Double_t potPBlue[potPNRGBs] = { 0.106, 0.353, 0.90, 0.780, 0.518 };
PPalette * potentialPalette = (PPalette*) gROOT->FindObject("rbow2inv");
potentialPalette->CreateGradientColorTable(potPNRGBs, potPStops,
potPRed, potPGreen, potPBlue, potPNCont);
// Extract contours
TCanvas* c = new TCanvas("c","Contour List",0,0,600,600);
c->cd();
// Potential
TH2F *hV2Dc = (TH2F*) hV2D->Clone("hV2Dc");
const Int_t Ncontours = 25;
Double_t contours[Ncontours];
for(Int_t i=0; i<Ncontours; i++) {
contours[i] = i*(trapPotential/5.0) - trapPotential;
}
hV2Dc->SetContour(Ncontours, contours);
hV2Dc->Draw("cont list");
c->Update();
TObjArray *contsV2D = (TObjArray*) gROOT->GetListOfSpecials()->FindObject("contours");
TClonesArray graphsV2D("TGraph",Ncontours);
{
Int_t ncontours = contsV2D->GetSize();
TList* clist = NULL;
Int_t nGraphs = 0;
TGraph *gr = NULL;
for(Int_t i = 0; i < ncontours; i++) {
if(i==0) continue;
clist = (TList*) contsV2D->At(i);
for(Int_t j = 0 ; j < clist->GetSize(); j++) {
gr = (TGraph*) clist->At(j);
if(!gr) continue;
gr->SetLineWidth(1);
gr->SetLineColor(kGray+1);
if( !((i)%5) ) {
gr->SetLineWidth(2);
gr->SetLineColor(kGray+2);
}
new(graphsV2D[nGraphs]) TGraph(*gr) ;
nGraphs++;
}
}
}
// Ion probability
示例12: ZinvEstimate
//.........这里部分代码省略.........
}//trigger pass
}//Filling Yield(N_Obsereved) in Data
}//Data
//trigger efficiency
///////////////////////////defining legend
char Legname1[100];
TLegend *leg[24];
for(int k0=0;k0<24;k0++){
sprintf(Legname1,"leg_1D%i",k0);
leg[k0]=new TLegend(0.5,0.7,0.80,0.89);
leg[k0]->SetTextFont(62);
leg[k0]->SetLineColor(1);
leg[k0]->SetLineStyle(1);
leg[k0]->SetLineWidth(3);
leg[k0]->SetFillColor(0);
leg[k0]->SetFillStyle(1001);
leg[k0]->SetShadowColor(0);
leg[k0]->SetDrawOption(0);
leg[k0]->SetBorderSize(0);
leg[k0]->SetTextSize(0.03);
}
///////////////////////////////ZinvMC Yield
//TCanvas *ZinvMCYield=new TCanvas("ZinvMC","ZinvMC");
//ZinvMCYield->SetLogy();
h_NZinv18bin->Sumw2();
h_NZinv18bin->SetFillColor(1);
h_NZinv18bin->SetFillStyle(1000);
h_NZinv18bin->GetXaxis()->SetTitle("bin Number");
h_NZinv18bin->GetYaxis()->SetTitle("Z/Gamma Ratio");
//h_NZinv18bin->Draw("hist");
//////////////////////////////////////////////Calculating Zgamma Ratio start
TPaveText *tpav1 = new TPaveText(0.1956522,0.6247818,0.729097,0.8970332,"brNDC");
tpav1->SetBorderSize(0);
tpav1->SetFillStyle(0);
tpav1->SetTextAlign(11);
tpav1->SetTextFont(42);
tpav1->SetTextSize(0.04);
tpav1->AddText("HT >500");
tpav1->AddText("#gamma p_{T} > 100 ");
tpav1->AddText("NJets >=4");
tpav1->AddText("MHT>200");
tpav1->AddText("Btags=0");
tpav1->AddText("#Delta #Phi_{1,2,3,4}>(0.5,0.5,0.3,0.3)");
TPaveText *pCMS1 = new TPaveText(0.132107,0.9308003,0.8327759,0.9923583,"brNDC");
示例13: PlotDensity1D
//.........这里部分代码省略.........
sprintf(ctext,"Z = %5.1f mm", 1e3 * skindepth * Time);
else
sprintf(ctext,"T = %5.1f 1/#omega_{p}",Time);
textTime->AddText(ctext);
TPaveText *textRange = new TPaveText(0.13,0.87,0.38,0.92,"NDC");
PlasmaGlob::SetPaveTextStyle(textRange,12);
textRange->SetTextColor(kGray+2);
if(opt.Contains("units") && n0)
sprintf(ctext,"%5.3f < y < %5.3f mm",ymin,ymax);
else
sprintf(ctext,"%5.3f < y < %5.3f c/#omega_{p}",ymin,ymax);
textRange->AddText(ctext);
// Actual Plotting!
// ------------------------------------------------------------
// Output file
TString fOutName = Form("./%s/Plots/Density1D/Density1D",sim.Data());
fOutName += Form("-%s_%i",sim.Data(),time);
// Colors
Int_t plasmaC = kGray+1;
Int_t beamC = kAzure-5;
Int_t fieldC = kOrange+10;
Int_t fieldCb = kGray+1;
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);
示例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: composeTrackAnalysisbyAssociator
//.........这里部分代码省略.........
TH1D* DeltaPtHist = DeltaPtmaxPurity2simPtHist->ProjectionY("DeltaPt", PtIndex, PtIndex, "o");
double DeltaPtMean = DeltaPtHist->GetMean();
double DeltaPtRMS = DeltaPtHist->GetRMS();
DeltaPt2simPtHist->SetBinContent(PtIndex, DeltaPtMean);
DeltaPt2simPtHist->SetBinError(PtIndex, DeltaPtRMS);
TH1D* DeltaPhiHist = DeltaPhimaxPurity2simPtHist->ProjectionY("DeltaPhi", PtIndex, PtIndex, "o");
double DeltaPhiMean = DeltaPhiHist->GetMean();
double DeltaPhiRMS = DeltaPhiHist->GetRMS();
DeltaPhi2simPtHist->SetBinContent(PtIndex, DeltaPhiMean);
DeltaPhi2simPtHist->SetBinError(PtIndex, DeltaPhiRMS);
TH1D* DeltaEtaHist = DeltaEtamaxPurity2simPtHist->ProjectionY("DeltaEta", PtIndex, PtIndex, "o");
double DeltaEtaMean = DeltaEtaHist->GetMean();
double DeltaEtaRMS = DeltaEtaHist->GetRMS();
DeltaEta2simPtHist->SetBinContent(PtIndex, DeltaEtaMean);
DeltaEta2simPtHist->SetBinError(PtIndex, DeltaEtaRMS);
}
myEfficiencyHist->AddLast(Efficiency2simPtHist);
myParticleHist->AddLast(Particle2simPtHist);
mySTAHist->AddLast(STA2simPtHist);
myChargeCheckHist->AddLast(InverseChargeRato2simPtHist);
myDeltaPtHist->AddLast(DeltaPt2simPtHist);
}
double minX = 0;
double minY = 0;
double maxX = 110;
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");