本文整理汇总了C++中TGaxis::SetLabelColor方法的典型用法代码示例。如果您正苦于以下问题:C++ TGaxis::SetLabelColor方法的具体用法?C++ TGaxis::SetLabelColor怎么用?C++ TGaxis::SetLabelColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGaxis
的用法示例。
在下文中一共展示了TGaxis::SetLabelColor方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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.);
}
示例3: 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();
}
示例4: 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;
}
示例5: makeEff
//.........这里部分代码省略.........
th1Eff->SetMinimum(0);
th1Eff->SetMaximum(1);
th1EffFull->SetMinimum(0);
th1EffFull->SetMaximum(1);
th1Eff->SetYTitle("efficiency");
th1EffFull->SetYTitle("efficiency");
th1Eff->SetTitle(Form("largest 15 Sign.(Num),%sGev",masspoint[massP].data()));
th1Eff->Draw();
th1Eff2->Draw("same");
Float_t rightmax = 2*th1Sign->GetBinContent(1);
//cout<<rightmax<<endl;
Float_t scale = gPad->GetUymax()/rightmax;
//hint1->SetLineColor(kRed);
th1Sign->Scale(scale);
//hint1->Draw("same");
//draw an axis on the right side
c1->Update();
th1Sign->Draw("same");
//leg->Clear();
//leg->AddEntry(th1Eff,"signal efficiency");
//leg->AddEntry(th1Eff2,"Bkg. efficiency");
//leg->SetY1(0.8335);
leg->Draw("same");
TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"+L");
axis->SetTitle("significance");
axis->SetTitleColor(4);
axis->SetLineColor(4);
axis->SetLabelColor(4);
axis->Draw();
c1->Print(Form("pdfPR/%s.pdf",output.data()));
th1EffFull->SetTitle(Form("all windows(Num),%sGev",masspoint[massP].data()));
th1EffFull->Draw();
th1Eff2Full->Draw("same");
c1->Update();
rightmax = 1.1*th1SignFull->GetBinContent(1);
scale = gPad->GetUymax()/rightmax;
th1SignFull->Scale(scale);
th1SignFull->Draw("Hist,same");
leg->Draw("same");
TGaxis *axis2 = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"+L");
axis2->SetTitle("significance");
axis2->SetTitleColor(4);
axis2->SetLineColor(4);
axis2->SetLabelColor(4);
axis2->Draw();
if(massP==12)c1->Print(Form("pdfPR/%s.pdf)",output.data()));
else c1->Print(Form("pdfPR/%s.pdf",output.data()));
}
示例6: 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());
}
示例7: 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;
}
示例8: 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;
}
示例9: if
//.........这里部分代码省略.........
// plot y range
float plotYMax;
float plotYMin;
if ( plotLegend && !arg->isQuickhack(22) ) {
if ( arg->plotlog ) { plotYMin = 1.e-3; plotYMax = 10.; }
else { plotYMin = 0.0 ; plotYMax = 1.3; }
}
else {
if ( arg->plotlog ) { plotYMin = 1.e-3; plotYMax = 1.0; }
else { plotYMin = 0.0 ; plotYMax = 1.0; }
}
// change if passed as option
plotYMin = arg->plotymin > 0. ? arg->plotymin : plotYMin;
plotYMax = arg->plotymax > 0. ? arg->plotymax : plotYMax;
haxes->GetYaxis()->SetRangeUser( plotYMin, plotYMax );
haxes->Draw("axissame");
g->SetHistogram(haxes);
TString drawOption = "";
if ( plotPoints ) drawOption += " pe";
else if ( filled ) drawOption += " F";
else drawOption += " L";
if ( first ) drawOption += " A";
g->Draw(drawOption);
//if ( drawOption.Contains("F") ) ((TGraph*)g->Clone())->Draw("L");
gPad->Update();
float ymin = gPad->GetUymin();
float ymax = gPad->GetUymax();
float xmin = gPad->GetUxmin();
float xmax = gPad->GetUxmax();
// for the angles, draw a new axis in units of degrees
if ( isAngle(s->getScanVar1()) ){
haxes->GetXaxis()->SetTitle(s->getScanVar1()->GetTitle() + TString(" [#circ]"));
haxes->GetXaxis()->SetNdivisions(0); // disable old axis
if ( last ){
// new top axis
TString chopt = "-U"; // - = downward ticks, U = unlabeled, http://root.cern.ch/root/html534/TGaxis.html
if ( !optimizeNdiv ) chopt += "N"; // n = no bin optimization
TGaxis *axist = new TGaxis(xmin, 1, xmax, 1, RadToDeg(xmin), RadToDeg(xmax), xndiv, chopt);
axist->SetName("axist");
axist->Draw();
// new bottom axis
float axisbMin = RadToDeg(xmin);
float axisbMax = RadToDeg(xmax);
if ( arg->isQuickhack(3) ){ ///< see documentation of --qh option in OptParser.cpp
axisbMin += 180.;
axisbMax += 180.;
}
chopt = ""; // - = downward ticks, U = unlabeled, http://root.cern.ch/root/html534/TGaxis.html
if ( !optimizeNdiv ) chopt += "N"; // n = no bin optimization
TGaxis *axisb = new TGaxis(xmin, ymin, xmax, ymin, axisbMin, axisbMax, xndiv, chopt);
axisb->SetName("axisb");
axisb->SetLabelFont(font);
axisb->SetLabelSize(labelsize);
axisb->Draw();
}
}
else
{
if ( last ){
// add top axis
TString chopt = "-U"; // - = downward ticks, U = unlabeled, http://root.cern.ch/root/html534/TGaxis.html
if ( !optimizeNdiv ) chopt += "N"; // n = no bin optimization
TGaxis *axist = new TGaxis(xmin, 1.0, xmax, 1.0, xmin, xmax, xndiv, chopt);
axist->SetName("axist");
axist->SetLineWidth(1);
axist->Draw();
}
}
if ( last )
{
// add right axis
TGaxis *axisr = 0;
if ( arg->plotlog ){
float f3min = 1e-3;
float f3max = (plotLegend && !arg->isQuickhack(22)) ? 10. : 1.;
TF1 *f3 = new TF1("f3","log10(x)",f3min,f3max);
axisr = new TGaxis(xmax, f3min, xmax, f3max, "f3", 510, "G+");
}
else{
axisr = new TGaxis(xmax, ymin, xmax, ymax, 0, (plotLegend && !arg->isQuickhack(22)) ? 1.3 : 1.0, 407, "+");
}
axisr->SetLabelSize(0);
axisr->SetLineWidth(1);
axisr->SetName("axisr");
axisr->SetLabelColor(kWhite);
axisr->SetTitleColor(kWhite);
axisr->Draw();
// redraw right axis as well because the 1-CL graph can cover the old one
haxes->Draw("axissame");
}
return g;
}
示例10: GE11sEfficiencyScan
//.........这里部分代码省略.........
gr_IV->Draw("sameCP");
gr_V->SetMarkerColor(kBlack);
gr_V->SetLineColor(kBlack);
gr_V->SetMarkerStyle(21);
gr_V->Draw("sameCP");
//create a transparent pad drawn on top of the main pad
c1->cd();
TPad *overlay = new TPad("overlay","",0,0,1,1);
overlay->SetFillStyle(4000);
overlay->SetFillColor(0);
overlay->SetFrameFillStyle(4000);
overlay->Draw();
overlay->cd();
// create second graph
//TGraphErrors* gr_GIF_Num = new TGraphErrors("data_noerror.dat","%lg %lg");
TGraphErrors *gr_GIF_Num = new TGraphErrors(GIF_Nevents.size());
TGraphErrors *gr_IV_Num = new TGraphErrors(IV_Nevents.size());
TGraphErrors *gr_V_Num = new TGraphErrors(V_Nevents.size());
for(unsigned int i=0;i<V_MeanPosOfSector.size();i++)
{
gr_GIF_Num->SetPoint(i,GIF_MeanPosOfSector[i],GIF_Nevents[i]);
gr_IV_Num->SetPoint(i,IV_MeanPosOfSector[i],IV_Nevents[i]);
gr_V_Num->SetPoint(i,V_MeanPosOfSector[i],V_Nevents[i]);
}
gr_GIF_Num->SetMarkerColor(kBlue);
gr_GIF_Num->SetLineColor(kBlue);
gr_GIF_Num->SetLineStyle(2);
gr_GIF_Num->SetLineWidth(3);
gr_GIF_Num->SetMarkerStyle(22);
gr_GIF_Num->SetName("gr_GIF_Num");
gr_IV_Num->SetMarkerColor(kGreen-6);
gr_IV_Num->SetLineColor(kGreen);
gr_IV_Num->SetMarkerStyle(22);
gr_IV_Num->SetLineStyle(2);
gr_IV_Num->SetLineWidth(3);
gr_IV_Num->SetName("gr_IV_Num");
gr_V_Num->SetMarkerColor(kBlack);
gr_V_Num->SetLineColor(kBlack);
gr_V_Num->SetMarkerStyle(22);
gr_V_Num->SetLineStyle(2);
gr_V_Num->SetLineWidth(3);
gr_V_Num->SetName("gr_V_Num");
Double_t xmin = pad->GetUxmin();
Double_t ymin = 0;
Double_t xmax = pad->GetUxmax();
Double_t ymax = 1550;
TH1F *hframe = overlay->DrawFrame(xmin,ymin,xmax,ymax);
hframe->GetXaxis()->SetLabelOffset(99);
hframe->GetYaxis()->SetLabelOffset(99);
hframe->Draw("Y+");
gr_GIF_Num->Draw("CPY+");
gr_IV_Num->Draw("CPY+");
gr_V_Num->Draw("CPY+");
//Draw the Legend
TLegend *leg = new TLegend(0.10,0.732,0.40,0.90);
leg->AddEntry(gr_GIF,"GE11_IV_GIF eff","LPE");
leg->AddEntry(gr_IV,"GE11_IV eff","LPE");
leg->AddEntry(gr_V,"GE11_V eff","LPE");
leg->AddEntry(gr_GIF_Num,"No of events_GE11_IV_GIF","LPE");
leg->AddEntry(gr_IV_Num,"No of events_GE11_IV","LPE");
leg->AddEntry(gr_V_Num,"No of events_GE11_V","LPE");
leg->Draw("same");
const char *runnum = RunName.c_str();
TLatex *t2a = new TLatex(0.00,0.94, runnum );
t2a->SetNDC();
t2a->SetTextFont(42);
t2a->SetTextSize(0.033);
t2a->SetTextAlign(13);
t2a->Draw("same");
//Draw an axis on the right side
TGaxis *axis = new TGaxis(xmax,ymin,xmax, ymax,ymin,ymax,510,"+L");
axis->SetLineColor(kRed);
axis->SetLabelColor(kRed);
axis->SetTitle("Approx. No. of Events");
axis->Draw();
string OutputFileName = "GE11_Efficiency_Scan_"+std::to_string(RunNumber)+".pdf";
const char *CharOutputFileName = OutputFileName.c_str();
c1->SaveAs(CharOutputFileName);
c1->Write();
//tree->Write();
//tree->Write("", TObject::kOverwrite);
f->Write();
}
示例11: 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;
}
示例12: PlotPotential2D
//.........这里部分代码省略.........
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);
textTime->SetTextFont(42);
textTime->AddText(ctext);
textTime->Draw();
// textDen->Draw();
// if(opt.Contains("units"))
// textWav->Draw();
示例13: PlotDensity1D
//.........这里部分代码省略.........
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);
}
hE1D[0]->SetLineStyle(1);
hE1D[0]->SetLineWidth(2);
hE1D[0]->SetLineColor(fieldC);
hE1D[0]->Draw("same C");
示例14: 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);
// ---------------------------------------------------------
}