本文整理汇总了C++中TPad::SetFillColor方法的典型用法代码示例。如果您正苦于以下问题:C++ TPad::SetFillColor方法的具体用法?C++ TPad::SetFillColor怎么用?C++ TPad::SetFillColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPad
的用法示例。
在下文中一共展示了TPad::SetFillColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: greyscale
void greyscale()
{
TCanvas *c = new TCanvas("grey", "Grey Scale", 500, 500);
c->SetBorderMode(0);
Int_t n = 200; // tunable parameter
Float_t n1 = 1./n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
TBox *b = new TBox(n1*j, n1*(n-1-i), n1*(j+1), n1*(n-i));
Float_t grey = Float_t(i*n+j)/(n*n);
b->SetFillColor(TColor::GetColor(grey, grey, grey));
b->Draw();
}
}
TPad *p = new TPad("p","p",0.3, 0.3, 0.7,0.7);
const char *guibackground = gEnv->GetValue("Gui.BackgroundColor", "");
p->SetFillColor(TColor::GetColor(guibackground));
p->Draw();
p->cd();
TText *t = new TText(0.5, 0.5, "GUI Background Color");
t->SetTextAlign(22);
t->SetTextSize(.09);
t->Draw();
c->SetEditable(kFALSE);
}
示例2: highlight1
void highlight1()
{
TCanvas *ch = new TCanvas("ch", "ch", 0, 0, 700, 500);
const Int_t n = 500;
Double_t x[n], y[n];
TH1F *h[n];
for (Int_t i = 0; i < n; i++) {
h[i] = new TH1F(TString::Format("h_%02d", i), "", 100, -3.0, 3.0);
// in practice gaus need reset parameters
h[i]->FillRandom("gaus", 1000);
h[i]->Fit("gaus", "Q");
h[i]->SetMaximum(250); // for n > 200
x[i] = i;
y[i] = h[i]->GetFunction("gaus")->GetParameter(2);
}
TGraph *g = new TGraph(n, x, y);
g->SetMarkerStyle(6);
for (Int_t i = 0; i < n; i++) g->AddHighlight(i, h[i]);
g->Draw("AP");
g->SetHighlight();
TPad *ph = new TPad("ph", "ph", 0.3, 0.4, 1.0, 1.0);
ph->SetFillColor(kBlue - 10);
ph->Draw();
ph->cd();
TText *info = new TText(0.5, 0.5, "please move the mouse over the graph");
info->SetTextAlign(22);
info->Draw();
ch->cd();
TGraph::SetHighlightPad(ph);
}
示例3: DrawGraph
void DrawGraph(string name, TGraphErrors* graph)
{
TCanvas* canvas = new TCanvas(name.c_str(),"",1200,900);
canvas->SetFillColor(kWhite);
canvas->cd();
TPad* pad = new TPad();
// left right bottom top
pad->SetMargin(0.15,0.05,0.15,0.05);
pad->SetTicks(1,1);
pad->SetFillColor(kWhite);
pad->Draw();
pad->cd();
TGraphErrors* oldgraph = graph;
graph = new TGraphErrors(*graph);
delete oldgraph;
float textsize = 0.055;
graph->SetMinimum(0);
graph->SetMaximum(100);
graph->SetTitle("");
graph->GetXaxis()->SetTitle("#it{m}(#it{K^{#plus}K^{#minus}}) [MeV/#it{c}^{2}]");
graph->GetYaxis()->SetTitle("Efficiency [%]");
graph->SetLineColor(kBlack);
graph->SetLineWidth(1);
graph->SetMarkerSize(1);
graph->SetMarkerStyle(8);
graph->SetMarkerColor(kBlack);
graph->Draw("AP");
graph->GetXaxis()->SetTitleSize(textsize*1.2);
graph->GetYaxis()->SetTitleSize(textsize*1.2);
graph->GetXaxis()->SetLabelSize(textsize);
graph->GetYaxis()->SetLabelSize(textsize);
graph->GetXaxis()->SetTitleFont(132);
graph->GetYaxis()->SetTitleFont(132);
graph->GetXaxis()->SetLabelFont(132);
graph->GetYaxis()->SetLabelFont(132);
graph->GetYaxis()->CenterTitle();
double _blurbx = 0.75;
double _blurby = 0.80;
string _blurbtext = "#splitline{LHCb}{#scale[0.75]{Preliminary}}";
TLatex* _blurb = new TLatex(_blurbx,_blurby,_blurbtext.c_str());
_blurb->SetTextFont(132);
_blurb->SetTextColor(1);
_blurb->SetNDC(kTRUE);
_blurb->SetTextAlign(11);
_blurb->SetTextSize(0.07);
_blurb->Draw();
canvas->SaveAs((name+".pdf").c_str());
canvas->Write();
}
示例4: Error
/**
* Draw the Poisson estimate of the occupancy in a given ring.
*
* @param p List
* @param d Detector
* @param r Ring
*
* @return The occupancy (in percent)
*
* @deprecated Use QATrender instead
* @ingroup pwglf_forward_scripts_qa
*/
Double_t
DrawRingOccupancy(TList* p, UShort_t d, Char_t r)
{
if (!p) return 0;
TList* ring = static_cast<TList*>(p->FindObject(Form("FMD%d%c",d,r)));
if (!ring) {
Error("DrawOccupancy", "List FMD%d%c not found in %s",d,r,p->GetName());
return 0;
}
TH1* corr = static_cast<TH1*>(ring->FindObject("occupancy"));
if (!corr) {
Error("DrawRingOccupancy", "Histogram occupancy not found in FMD%d%c",
d, r);
return 0;
}
corr->Rebin(4);
TPad* pad = static_cast<TPad*>(gPad);
pad->SetGridy();
pad->SetGridx();
pad->SetLogy();
pad->SetFillColor(0);
pad->SetRightMargin(0.01);
#if 0
if (d == 3) {
pad->SetPad(pad->GetXlowNDC(), pad->GetYlowNDC(), .99,
pad->GetYlowNDC()+pad->GetHNDC());
pad->SetRightMargin(0.15);
}
#endif
corr->Draw("hist");
TLatex* ltx = new TLatex(.95, .95, Form("FMD%d%c", d, r));
ltx->SetNDC();
ltx->SetTextAlign(33);
ltx->SetTextSize(.08);
ltx->Draw();
return corr->GetMean();
}
示例5: set_box
void root_util::set_box(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax,
Int_t lstyle, Double_t lwidth, Double_t lcolor, Double_t fcolor,
Int_t fptn, Char_t *loctype, Int_t gnum, Int_t xonly, Int_t yonly){
//cout << pad_size <<endl;
Int_t clen = clst.size();
//cout << clen<<endl;
Int_t cnum = gnum / pad_size;
cout << "fcolor"<< fcolor<<endl;
Int_t pad_num = gnum % pad_size + 1;
//cout << pad_num<<endl;
//cout << xmin <<endl;
//cout << xmax <<endl;
//cout << ymin <<endl;
//cout << ymax <<endl;
TPad *b;
//b = new TEllipse(xmin, ymin, xmin, ymax);
b = new TPad("box","box", xmin, ymin, xmax, ymax);
b->SetFillColor(fcolor);
clst[cnum]->cd(pad_num);
b->Draw();
// clst[cnum]->UseCurrentStyle();
}
示例6: markerwarning
void markerwarning()
{
const int Nph = 14;
double np_ph[Nph] = {353.4,300.2,254.3,215.2,181.0,151.3,125.2,102.7, 83.3, 66.7, 52.5, 40.2, 30.2, 22.0};
double nc_ph[Nph] = {3.890,3.734,3.592,3.453,3.342,3.247,3.151,3.047,2.965,2.858,2.701,2.599,2.486,2.328};
double npe_ph[Nph] = {10.068,9.004,8.086,7.304,6.620,6.026,5.504,5.054,4.666,4.334,4.050,3.804,3.604,3.440};
double nce_ph[Nph] = {0.235,0.217,0.210,0.206,0.213,0.223,0.239,0.260,0.283,0.318,0.356,0.405,0.465,0.545};
const int Nbr = 6;
double np_br[Nbr] = {357.0,306.0,239.0,168.0,114.0, 73.0};
double nc_br[Nbr] = {3.501,3.275,3.155,3.060,3.053,3.014};
double npe_br[Nbr] = {8.000,11.000,10.000,9.000,9.000,8.000};
double nce_br[Nbr] = {0.318,0.311,0.306,0.319,0.370,0.429};
TGraphErrors *phUP = new TGraphErrors(Nph,np_ph,nc_ph,npe_ph,nce_ph);
TGraphErrors *phDN = new TGraphErrors(Nph,np_ph,nc_ph,npe_ph,nce_ph);
TGraphErrors *brUP = new TGraphErrors(Nbr,np_br,nc_br,npe_br,nce_br);
TGraphErrors *brDN = new TGraphErrors(Nbr,np_br,nc_br,npe_br,nce_br);
float Top_margin = 0.;
float Left_margin = 0.025;
float Right_margin = 0.005;
float maxPlotPart = 395;
float Marker_Size = 1.3;
int Marker_Style = 8;
float Et_200_Min = 0.71;
float Et_200_Max = 3.80;
float Et_130_Min = 1.21;
float Et_130_Max = 3.29;
float Nc_200_Min = 1.31;
float Nc_200_Max = 4.30;
float Nc_130_Min = 1.51;
float Nc_130_Max = 3.89;
TCanvas *canvasNc = new TCanvas("canvasNc", "Multiplicity",630,10,600,500);
gStyle->SetOptStat(0);
canvasNc->SetFillColor(10);
canvasNc->SetBorderSize(0);
// Primitives in Nc200 pad
TPad *padNcUP = new TPad("padNcUP","200 GeV",0.07,0.60,1.,1.00);
padNcUP->Draw();
padNcUP->cd();
padNcUP->SetFillColor(10);
padNcUP->SetFrameFillColor(10);
padNcUP->SetBorderSize(0);
padNcUP->SetLeftMargin(Left_margin);
padNcUP->SetRightMargin(Right_margin);
padNcUP->SetTopMargin(Top_margin+0.005);
padNcUP->SetBottomMargin(0.00);
TH1F* frameNcUP = new TH1F("frameNcUP","",100,0,maxPlotPart);
frameNcUP->GetYaxis()->SetLabelOffset(0.005);
frameNcUP->GetYaxis()->SetLabelSize(0.10);
frameNcUP->SetMinimum(Nc_200_Min);
frameNcUP->SetMaximum(Nc_200_Max);
frameNcUP->SetNdivisions(505,"Y");
frameNcUP->SetNdivisions(505,"X");
frameNcUP->Draw();
brUP->SetMarkerStyle(22);
brUP->SetMarkerSize (2.0);
brUP->Draw("P");
phDN->SetMarkerStyle(23);
phDN->SetMarkerSize (2);
phDN->Draw("P");
canvasNc->cd();
// Primitives in Nc130 pad
TPad *padNcDN = new TPad("padNcDN","130 GeV",0.07,0.02,1.,0.60);
padNcDN->Draw();
padNcDN->cd();
padNcDN->SetFillColor(10);
padNcDN->SetFrameFillColor(10);
padNcDN->SetBorderSize(0);
padNcDN->SetLeftMargin(Left_margin);
padNcDN->SetRightMargin(Right_margin);
padNcDN->SetTopMargin(Top_margin+0.005);
padNcDN->SetBottomMargin(0.30);
TH1F* frameNcDN = new TH1F("frameNcDN","",100,0,maxPlotPart);
frameNcDN->GetYaxis()->SetLabelOffset(0.005);
frameNcDN->GetYaxis()->SetLabelSize(0.07);
frameNcDN->GetXaxis()->SetLabelOffset(0.005);
frameNcDN->GetXaxis()->SetLabelSize(0.07);
frameNcDN->SetMinimum(Nc_200_Min);
frameNcDN->SetMaximum(Nc_200_Max);
frameNcDN->SetNdivisions(505,"Y");
frameNcDN->SetNdivisions(505,"X");
frameNcDN->Draw();
brDN->SetMarkerStyle(23);
brDN->SetMarkerSize (2.0);
brDN->Draw("P");
//.........这里部分代码省略.........
示例7: wmj_fit_stack
void wmj_fit_stack()
{
//=========Macro generated from canvas: default_Canvas/defaultCanvas
//========= (Tue May 3 07:35:30 2016) by ROOT version6.04/10
TCanvas *default_Canvas = new TCanvas("default_Canvas", "defaultCanvas",0,0,700,500);
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
default_Canvas->SetHighLightColor(2);
default_Canvas->Range(0,0,1,1);
default_Canvas->SetFillColor(0);
default_Canvas->SetBorderMode(0);
default_Canvas->SetBorderSize(2);
default_Canvas->SetTickx(1);
default_Canvas->SetTicky(1);
default_Canvas->SetLeftMargin(0.14);
default_Canvas->SetRightMargin(0.05);
default_Canvas->SetTopMargin(0.05);
default_Canvas->SetBottomMargin(0.16);
default_Canvas->SetFrameLineWidth(2);
default_Canvas->SetFrameBorderMode(0);
// ------------>Primitives in pad: upperPad
TPad *upperPad = new TPad("upperPad", "upperPad",0.005,0.05,0.995,0.995);
upperPad->Draw();
upperPad->cd();
upperPad->Range(-0.1730123,-5358.989,1.06279,32919.5);
upperPad->SetFillColor(0);
upperPad->SetFillStyle(4000);
upperPad->SetBorderMode(0);
upperPad->SetBorderSize(2);
upperPad->SetTickx(1);
upperPad->SetTicky(1);
upperPad->SetLeftMargin(0.14);
upperPad->SetRightMargin(0.05);
upperPad->SetTopMargin(0.05);
upperPad->SetBottomMargin(0.14);
upperPad->SetFrameLineWidth(2);
upperPad->SetFrameBorderMode(0);
upperPad->SetFrameLineWidth(2);
upperPad->SetFrameBorderMode(0);
Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fx3005[20] = {
0.025,
0.075,
0.125,
0.175,
0.225,
0.275,
0.325,
0.375,
0.425,
0.475,
0.525,
0.575,
0.625,
0.675,
0.725,
0.775,
0.825,
0.875,
0.925,
0.975};
Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fy3005[20] = {
0,
0,
9,
26,
118,
315,
881,
1812,
3086,
4575,
5856,
6537,
6824,
6348,
5662,
4769,
4941,
6726,
13179,
28019};
Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_felx3005[20] = {
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
0.025,
//.........这里部分代码省略.........
示例8: if
//.........这里部分代码省略.........
eEPadSubs[1]=(TPad*) tempPad->GetPad(1);
eEPadSubs[2]=(TPad*) tempPad->GetPad(2);
TPad* allBasePads[10]={titlePad,pTPadSubs[0],pTPadSubs[1],pTPadSubs[2],eEPadSubs[0],eEPadSubs[1],eEPadSubs[2],pEPadSubs[0],pEPadSubs[1],pEPadSubs[2]};
for (int i = 1;i< 10;i++)
{
allBasePads[i]->SetGrid(1,1);
allBasePads[i]->SetTickx(1);
allBasePads[i]->SetTicky(1);
}
pTPadSubs[0]->SetMargin(0.13,0.1,.1,0.1);
pEPadSubs[0]->SetMargin(0.13,0.1,.1,0.1);
eEPadSubs[0]->SetMargin(0.13,0.1,.1,0.1);
pTPadSubs[1]->SetMargin(0.1,0.1,.1,0.1);
pEPadSubs[1]->SetMargin(0.1,0.1,.1,0.1);
eEPadSubs[1]->SetMargin(0.1,0.1,.1,0.1);
pTPadSubs[2]->SetMargin(0.1,0.1,.1,0.1);
pEPadSubs[2]->SetMargin(0.1,0.1,.1,0.1);
eEPadSubs[2]->SetMargin(0.1,0.1,.1,0.1);
//Plot pT
pTPadSubs[0]->cd(); drawPlot(detType, PLOTVAR_PT,PLOT_COMP);
pTPadSubs[1]->cd(); drawPlot(detType, PLOTVAR_PT,PLOT_RESID);
pTPadSubs[2]->cd(); drawPlot(detType, PLOTVAR_PT,PLOT_NORMRESID);
//Plot eE
eEPadSubs[0]->cd(); drawPlot(detType, PLOTVAR_EE,PLOT_COMP);
eEPadSubs[1]->cd(); drawPlot(detType, PLOTVAR_EE,PLOT_RESID);
eEPadSubs[2]->cd(); drawPlot(detType, PLOTVAR_EE,PLOT_NORMRESID);
//Plot pE
pEPadSubs[0]->cd(); drawPlot(detType, PLOTVAR_PE,PLOT_COMP);
pEPadSubs[1]->cd(); drawPlot(detType, PLOTVAR_PE,PLOT_RESID);
pEPadSubs[2]->cd(); drawPlot(detType, PLOTVAR_PE,PLOT_NORMRESID);
}
else
{
TPad* allBasePads[4]={titlePad,pTPad,eEPad,pEPad};
for (int i = 1;i< 4;i++)
{
allBasePads[i]->SetGrid(1,1);
allBasePads[i]->SetTickx(1);
allBasePads[i]->SetTicky(1);
}
pTPad->SetMargin(0.13,0.1,.1,0.1);
pEPad->SetMargin(0.13,0.1,.1,0.1);
eEPad->SetMargin(0.13,0.1,.1,0.1);
pTPad->cd(); drawPlot(detType, PLOTVAR_PT,PLOT_COMP);
eEPad->cd(); drawPlot(detType, PLOTVAR_EE,PLOT_COMP);
pEPad->cd(); drawPlot(detType, PLOTVAR_PE,PLOT_COMP);
}
mainPad->SetFillColor(kGray);
///Make Title box
titlePad->cd();
titlePad->SetFillColor(kGray);
TPaveText* titleBox = makeTitleBox( detType);
titleBox->Draw();
TString coTypeString;
if(detType==DET_EP)
{
coTypeString="EP";
}
else if(detType==DET_EPG)
{
coTypeString="EPG";
}
else if(detType==DET_EPBG)
{
coTypeString="EPBG";
}
TString imagePath=GRAPHS_DIR;
imagePath+="layouts/PlotLayout";
if(numMC>0) imagePath+="_MC";
for (int i = 0;i< numMC;i++)
{
imagePath+=TString("_")+mc[i]->GetName();
}
if(numExp>0) imagePath+="_Exp";
for (int i = 0;i< numExp;i++)
{
imagePath+=TString("_")+exp[i]->GetName();
}
imagePath+="_"+coTypeString+"_EPPlots.pdf";
theCanvas->SaveAs(imagePath);
delete theCanvas;
clearPlotHists();
}
示例9: CrossSectionRatio
//.........这里部分代码省略.........
yratiocrossFONLLsysthigh[i] = ycrosssysthigh[i]/yFONLL[i];
yratiocrossFONLLsystlow[i] = ycrosssystlow[i]/yFONLL[i];
yFONLLrelunclow[i] = gaeBplusReference->GetErrorYlow(i)/yFONLL[i];
yFONLLrelunchigh[i] = gaeBplusReference->GetErrorYhigh(i)/yFONLL[i];
yunity[i] = yFONLL[i]/yFONLL[i];
hYieldTriggerCorrectedFONLLnorm->SetBinContent(i+1,hYieldTriggerCorrectedFONLLnorm->GetBinContent(i+1)/yFONLL[i]);
hYieldTriggerCorrectedFONLLnorm->SetBinError(i+1,hYieldTriggerCorrectedFONLLnorm->GetBinError(i+1)/yFONLL[i]);
hDcandidatesTriggerCorrectedFONLLnorm->SetBinContent(i+1,hDcandidatesTriggerCorrectedFONLLnorm->GetBinContent(i+1)/yFONLL[i]);
hDcandidatesTriggerCorrectedFONLLnorm->SetBinError(i+1,hDcandidatesTriggerCorrectedFONLLnorm->GetBinError(i+1)/yFONLL[i]);
hYieldNoTriggerCorrectedFONLLnorm->SetBinContent(i+1,hYieldNoTriggerCorrectedFONLLnorm->GetBinContent(i+1)/yFONLL[i]);
hYieldNoTriggerCorrectedFONLLnorm->SetBinError(i+1,hYieldNoTriggerCorrectedFONLLnorm->GetBinError(i+1)/yFONLL[i]);
hDcandidatesNoTriggerCorrectedFONLLnorm->SetBinContent(i+1,hDcandidatesNoTriggerCorrectedFONLLnorm->GetBinContent(i+1)/yFONLL[i]);
hDcandidatesNoTriggerCorrectedFONLLnorm->SetBinError(i+1,hDcandidatesNoTriggerCorrectedFONLLnorm->GetBinError(i+1)/yFONLL[i]);
}
TGraphAsymmErrors* gaeCrossSyst = new TGraphAsymmErrors(nBins,xr,ycross,xrlow,xrhigh,ycrosssystlow,ycrosssysthigh);
gaeCrossSyst->SetName("gaeCrossSyst");
gaeCrossSyst->SetMarkerStyle(20);
gaeCrossSyst->SetMarkerSize(0.8);
TGraphAsymmErrors* gaeRatioCrossFONLLstat = new TGraphAsymmErrors(nBins,xr,yratiocrossFONLL,xrlow,xrhigh,yratiocrossFONLLstat,yratiocrossFONLLstat);
gaeRatioCrossFONLLstat->SetName("gaeRatioCrossFONLLstat");
gaeRatioCrossFONLLstat->SetMarkerStyle(20);
gaeRatioCrossFONLLstat->SetMarkerSize(0.8);
TGraphAsymmErrors* gaeRatioCrossFONLLsyst= new TGraphAsymmErrors(nBins,xr,yratiocrossFONLL,xrlow,xrhigh,yratiocrossFONLLsystlow,yratiocrossFONLLsysthigh);
gaeRatioCrossFONLLsyst->SetName("gaeRatioCrossFONLLsyst");
gaeRatioCrossFONLLsyst->SetLineWidth(2);
gaeRatioCrossFONLLsyst->SetLineColor(1);
gaeRatioCrossFONLLsyst->SetFillColor(2);
gaeRatioCrossFONLLsyst->SetFillStyle(0);
TGraphAsymmErrors* gaeRatioCrossFONLLunity = new TGraphAsymmErrors(nBins,xr,yunity,xrlow,xrhigh,yFONLLrelunclow,yFONLLrelunchigh);
gaeRatioCrossFONLLunity->SetName("gaeRatioCrossFONLLunity");
gaeRatioCrossFONLLunity->SetLineWidth(2);
gaeRatioCrossFONLLunity->SetLineColor(2);
gaeRatioCrossFONLLunity->SetFillColor(2);
gaeRatioCrossFONLLunity->SetFillStyle(3002);
TCanvas* cSigma = new TCanvas("cSigma","",600,750);
cSigma->SetFrameBorderMode(0);
cSigma->SetFrameBorderMode(0);
cSigma->Range(-1.989924,-0.2917772,25.49622,2.212202);
cSigma->SetFillColor(0);
cSigma->SetBorderMode(0);
cSigma->SetBorderSize(2);
cSigma->SetLeftMargin(0.1451613);
cSigma->SetRightMargin(0.05443548);
cSigma->SetTopMargin(0.08474576);
cSigma->SetBottomMargin(0.1165254);
cSigma->SetFrameBorderMode(0);
cSigma->SetFrameBorderMode(0);
cSigma->cd();
TPad* pSigma = new TPad("pSigma","",0,0.25,1,1);
pSigma->SetFillColor(0);
pSigma->SetBorderMode(0);
pSigma->SetBorderSize(2);
pSigma->SetLeftMargin(0.1451613);
pSigma->SetRightMargin(0.05443548);
pSigma->SetTopMargin(0.08474576);
pSigma->SetBottomMargin(0);
pSigma->SetLogy();
示例10: variables
// input: - Input file (result from TMVA),
// - normal/decorrelated/PCA
// - use of TMVA plotting TStyle
void variables( TString fin = "TMVA.root", TString dirName = "InputVariables_Id", TString title = "TMVA Input Variables",
Bool_t isRegression = kFALSE, Bool_t useTMVAStyle = kTRUE )
{
TString outfname = dirName;
outfname.ToLower(); outfname.ReplaceAll( "input", "" );
// set style and remove existing canvas'
TMVAGlob::Initialize( useTMVAStyle );
// obtain shorter histogram title
TString htitle = title;
htitle.ReplaceAll("variables ","variable");
htitle.ReplaceAll("and target(s)","");
htitle.ReplaceAll("(training sample)","");
// checks if file with name "fin" is already open, and if not opens one
TFile* file = TMVAGlob::OpenFile( fin );
TDirectory* dir = (TDirectory*)file->Get( dirName );
if (dir==0) {
cout << "No information about " << title << " available in directory " << dirName << " of file " << fin << endl;
return;
}
dir->cd();
// how many plots are in the directory?
Int_t noPlots = TMVAGlob::GetNumberOfInputVariables( dir ) +
TMVAGlob::GetNumberOfTargets( dir );
// define Canvas layout here!
// default setting
Int_t xPad; // no of plots in x
Int_t yPad; // no of plots in y
Int_t width; // size of canvas
Int_t height;
switch (noPlots) {
case 1:
xPad = 1; yPad = 1; width = 550; height = 0.90*width; break;
case 2:
xPad = 2; yPad = 1; width = 600; height = 0.50*width; break;
case 3:
xPad = 3; yPad = 1; width = 900; height = 0.4*width; break;
case 4:
xPad = 2; yPad = 2; width = 600; height = width; break;
default:
// xPad = 3; yPad = 2; width = 800; height = 0.55*width; break;
xPad = 1; yPad = 1; width = 550; height = 0.90*width; break;
}
Int_t noPadPerCanv = xPad * yPad ;
// counter variables
Int_t countCanvas = 0;
Int_t countPad = 0;
// loop over all objects in directory
TCanvas* canv = 0;
TKey* key = 0;
Bool_t createNewFig = kFALSE;
TIter next(dir->GetListOfKeys());
while ((key = (TKey*)next())) {
if (key->GetCycle() != 1) continue;
if (!TString(key->GetName()).Contains("__Signal") &&
!(isRegression && TString(key->GetName()).Contains("__Regression"))) continue;
// make sure, that we only look at histograms
TClass *cl = gROOT->GetClass(key->GetClassName());
if (!cl->InheritsFrom("TH1")) continue;
TH1 *sig = (TH1*)key->ReadObj();
TString hname(sig->GetName());
//normalize to 1
NormalizeHist(sig);
// create new canvas
if (countPad%noPadPerCanv==0) {
++countCanvas;
canv = new TCanvas( Form("canvas%d", countCanvas), title,
countCanvas*50+50, countCanvas*20, width, height );
canv->Divide(xPad,yPad);
canv->SetFillColor(kWhite);
canv->Draw();
}
TPad* cPad = (TPad*)canv->cd(countPad++%noPadPerCanv+1);
cPad->SetFillColor(kWhite);
// find the corredponding backgrouns histo
TString bgname = hname;
bgname.ReplaceAll("__Signal","__Background");
TH1 *bgd = (TH1*)dir->Get(bgname);
if (bgd == NULL) {
cout << "ERROR!!! couldn't find background histo for" << hname << endl;
exit;
}
//normalize to 1
//.........这里部分代码省略.........
示例11: GE11sEfficiencyScan
//.........这里部分代码省略.........
TGraphErrors *gr_V = new TGraphErrors(V_Efficiency.size());
for(unsigned int i=0;i<V_Efficiency.size();i++)
{
gr_GIF->SetPoint(i, GIF_MeanPosOfSector[i], GIF_Efficiency[i]);
gr_GIF->SetPointError(i,0, GIF_EfficiencyError[i]);
gr_IV->SetPoint(i, IV_MeanPosOfSector[i], IV_Efficiency[i]);
gr_IV->SetPointError(i,0, IV_EfficiencyError[i]);
gr_V->SetPoint(i, V_MeanPosOfSector[i], V_Efficiency[i]);
gr_V->SetPointError(i,0, V_EfficiencyError[i]);
}
gr_GIF->SetMarkerColor(kBlue);
gr_GIF->SetLineColor(kBlue);
gr_GIF->SetMarkerStyle(21);
gr_GIF->GetXaxis()->SetTitle("dist (mm)");
gr_GIF->GetYaxis()->SetTitle("Efficiency");
gr_GIF->GetYaxis()->SetRangeUser(0,1.2);
gr_GIF->SetTitle("Efficiency Scan");
gr_GIF->Draw("ACP");
gr_IV->SetMarkerColor(kGreen-6);
gr_IV->SetLineColor(kGreen);
gr_IV->SetMarkerStyle(21);
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);
示例12: makePlot
void makePlot(double canvasSizeX, double canvasSizeY,
TH1* histogramTTH,
TH1* histogramData,
TH1* histogramTT,
TH1* histogramTTV,
TH1* histogramEWK,
TH1* histogramRares,
TH1* histogramBgrSum,
TH1* histogramBgrUncertainty,
const std::string& xAxisTitle, double xAxisOffset,
bool useLogScale, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset,
const std::string& outputFileName)
{
TH1* histogramTTH_density = 0;
if ( histogramTTH ) {
if ( histogramData ) checkCompatibleBinning(histogramTTH, histogramData);
histogramTTH_density = divideHistogramByBinWidth(histogramTTH);
}
TH1* histogramData_density = 0;
if ( histogramData ) {
histogramData_density = divideHistogramByBinWidth(histogramData);
}
TH1* histogramTT_density = 0;
if ( histogramTT ) {
if ( histogramData ) checkCompatibleBinning(histogramTT, histogramData);
histogramTT_density = divideHistogramByBinWidth(histogramTT);
}
TH1* histogramTTV_density = 0;
if ( histogramTTV ) {
if ( histogramData ) checkCompatibleBinning(histogramTTV, histogramData);
histogramTTV_density = divideHistogramByBinWidth(histogramTTV);
}
TH1* histogramEWK_density = 0;
if ( histogramEWK ) {
if ( histogramData ) checkCompatibleBinning(histogramEWK, histogramData);
histogramEWK_density = divideHistogramByBinWidth(histogramEWK);
}
TH1* histogramRares_density = 0;
if ( histogramRares ) {
if ( histogramData ) checkCompatibleBinning(histogramRares, histogramData);
histogramRares_density = divideHistogramByBinWidth(histogramRares);
}
TH1* histogramBgrSum_density = 0;
if ( histogramBgrSum ) {
if ( histogramData ) checkCompatibleBinning(histogramBgrSum, histogramData);
histogramBgrSum_density = divideHistogramByBinWidth(histogramBgrSum);
}
TH1* histogramBgrUncertainty_density = 0;
if ( histogramBgrUncertainty ) {
if ( histogramData ) checkCompatibleBinning(histogramBgrUncertainty, histogramData);
histogramBgrUncertainty_density = divideHistogramByBinWidth(histogramBgrUncertainty);
}
TCanvas* canvas = new TCanvas("canvas", "", canvasSizeX, canvasSizeY);
canvas->SetFillColor(10);
canvas->SetFillStyle(4000);
canvas->SetFillColor(10);
canvas->SetTicky();
canvas->SetBorderSize(2);
canvas->SetLeftMargin(0.12);
canvas->SetBottomMargin(0.12);
TPad* topPad = new TPad("topPad", "topPad", 0.00, 0.35, 1.00, 1.00);
topPad->SetFillColor(10);
topPad->SetTopMargin(0.065);
topPad->SetLeftMargin(0.15);
topPad->SetBottomMargin(0.03);
topPad->SetRightMargin(0.05);
topPad->SetLogy(useLogScale);
TPad* bottomPad = new TPad("bottomPad", "bottomPad", 0.00, 0.00, 1.00, 0.35);
bottomPad->SetFillColor(10);
bottomPad->SetTopMargin(0.02);
bottomPad->SetLeftMargin(0.15);
bottomPad->SetBottomMargin(0.31);
bottomPad->SetRightMargin(0.05);
bottomPad->SetLogy(false);
canvas->cd();
topPad->Draw();
topPad->cd();
TAxis* xAxis_top = histogramData_density->GetXaxis();
xAxis_top->SetTitle(xAxisTitle.data());
xAxis_top->SetTitleOffset(xAxisOffset);
xAxis_top->SetLabelColor(10);
xAxis_top->SetTitleColor(10);
TAxis* yAxis_top = histogramData_density->GetYaxis();
yAxis_top->SetTitle(yAxisTitle.data());
yAxis_top->SetTitleOffset(yAxisOffset);
yAxis_top->SetTitleSize(0.085);
yAxis_top->SetLabelSize(0.05);
yAxis_top->SetTickLength(0.04);
TLegend* legend = new TLegend(0.66, 0.45, 0.94, 0.92, NULL, "brNDC");
legend->SetFillStyle(0);
legend->SetBorderSize(0);
legend->SetFillColor(10);
legend->SetTextSize(0.055);
//.........这里部分代码省略.........
示例13: plot
void plot(int mass) {
double myQCDRelUncert = 0.038;
double myEWKRelUncert = 0.131;
double myFakesRelUncert = 0.238;
double delta = 1.4;
double br = 0.05;
bool debug = false;
bool log = false;
double ymin = 0.001;
double ymax = 48;
static bool bMessage = false;
if (!bMessage) {
cout << "Values used as relative uncertainty (please check):" << endl;
cout << " QCD: " << myQCDRelUncert << endl;
cout << " EWK genuine tau: " << myEWKRelUncert << endl;
cout << " EWK fake tau: " << myFakesRelUncert << endl << endl;
bMessage = true;
}
cout << "Processing mass point: " << mass << " GeV/c2" << endl;
gStyle->SetOptFit(1);
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
gStyle->SetTitleFont(43, "xyz");
gStyle->SetTitleSize(33, "xyz");
gStyle->SetLabelFont(43, "xyz");
gStyle->SetLabelSize(27, "xyz");
//std::string infile = "EPS_data_nodeltaphi/hplus_100.root";
//std::string infile = "EPS_data_deltaphi160/hplus_100.root";
std::stringstream s;
s << "lands_histograms_hplushadronic_m" << mass << ".root";
std::string infile = s.str();
// Canvas
TCanvas *myCanvas = new TCanvas("myCanvas", "",0,0,600,600);
myCanvas->SetHighLightColor(2);
myCanvas->Range(0,0,1,1);
myCanvas->SetFillColor(0);
myCanvas->SetBorderMode(0);
myCanvas->SetBorderSize(2);
if (log)
myCanvas->SetLogy();
myCanvas->SetTickx(1);
myCanvas->SetTicky(1);
myCanvas->SetLeftMargin(0.16);
myCanvas->SetRightMargin(0.05);
myCanvas->SetTopMargin(0.05);
myCanvas->SetBottomMargin(0.08);
myCanvas->SetFrameFillStyle(0);
myCanvas->SetFrameBorderMode(0);
myCanvas->SetFrameFillStyle(0);
myCanvas->SetFrameBorderMode(0);
myCanvas->cd();
Int_t ci;
TFile* f = TFile::Open(infile.c_str());
s.str("");
s << "HW" << mass << "_1";
TH1* hw = (TH1*)f->Get(s.str().c_str());
s.str("");
s << "HH" << mass << "_1";
TH1* hh = (TH1*)f->Get(s.str().c_str());
TH1* data = (TH1*)f->Get("data_obs");
data->SetLineWidth(2);
data->SetMarkerStyle(20);
data->SetMarkerSize(1.2);
TH1* ewktau = (TH1*)f->Get("EWK_Tau");
ci = TColor::GetColor("#993399");
ewktau->SetFillColor(ci);
ewktau->SetLineWidth(0);
TH1* ewkDY = (TH1*)f->Get("EWK_DYx");
TH1* ewkVV = (TH1*)f->Get("EWK_VVx");
ewktau->Add(ewkDY);
ewktau->Add(ewkVV);
//TH1* qcd = (TH1*)f->Get("QCDInv");
TH1* qcd = (TH1*)f->Get("QCD");
ci = TColor::GetColor("#ffcc33");
qcd->SetFillColor(ci);
qcd->SetLineWidth(0);
TH1* fakett = (TH1*)f->Get("fake_tt");
ci = TColor::GetColor("#669900");
fakett->SetFillColor(ci);
fakett->SetLineWidth(0);
TH1* fakeW = (TH1*)f->Get("fake_W");
ci = TColor::GetColor("#cc3300");
fakeW->SetFillColor(ci);
fakeW->SetLineWidth(0);
TH1* faket = (TH1*)f->Get("fake_t");
TH1F *hFrame = new TH1F("hFrame","",20,0,400);
hFrame->SetMinimum(ymin);
if (log)
hFrame->SetMaximum(ymax*1.5);
else
//.........这里部分代码省略.........
示例14: DrawBoosted
void DrawBoosted(TString VAR, float XMIN, float XMAX, int REBIN, TString XTITLE)
{
gROOT->ForceStyle();
const int N = 7;
float XSEC[N] = {1.74e+6,3.67e+5,2.94e+4,6.524e+03,1.064e+03,121.5,2.542e+01};
TString SAMPLE[N] = {
"QCD_HT200to300",
"QCD_HT300to500",
"QCD_HT500to700",
"QCD_HT700to1000",
"QCD_HT1000to1500",
"QCD_HT1500to2000",
"QCD_HT2000toInf"
};
TFile *inf[N];
TH1F *h0[N],*h1[N];
TH1F *hQCD0,*hQCD1;
TCanvas *can = new TCanvas("Boosted","Boosted",900,600);
can->cd(1);
can->SetBottomMargin(0.3);
//can->SetRightMargin(0.15);
for(int k=0;k<N;k++) {
inf[k] = TFile::Open("Histo_"+SAMPLE[k]+".root");
h0[k] = (TH1F*)inf[k]->Get("hadtopBoost/h_"+VAR+"_Cut_ctl");
h0[k]->Sumw2();
h0[k]->Rebin(REBIN);
h1[k] = (TH1F*)inf[k]->Get("hadtopBoost/h_"+VAR+"_Cut_sig");
h1[k]->Sumw2();
h1[k]->Rebin(REBIN);
h0[k]->Scale(XSEC[k]/((TH1F*)inf[k]->Get("hadtopBoost/TriggerPass"))->GetBinContent(1));
h1[k]->Scale(XSEC[k]/((TH1F*)inf[k]->Get("hadtopBoost/TriggerPass"))->GetBinContent(1));
cout<<SAMPLE[k]<<": "<<h0[k]->GetEntries()<<" "<<h0[k]->Integral()<<endl;
if (k == 0) {
hQCD0 = (TH1F*)h0[k]->Clone();
hQCD1 = (TH1F*)h1[k]->Clone();
}
if (k > 0) {
hQCD0->Add(h0[k]);
hQCD1->Add(h1[k]);
}
}
hQCD0->Scale(1/hQCD0->Integral());
hQCD1->Scale(1/hQCD1->Integral());
double max1 = TMath::Max(hQCD0->GetBinContent(hQCD0->GetMaximumBin()),hQCD1->GetBinContent(hQCD1->GetMaximumBin()));
hQCD0->SetMaximum(1.2*max1);
hQCD0->SetMinimum(1e-4);
hQCD0->GetXaxis()->SetLabelSize(0.0);
hQCD0->GetXaxis()->SetRangeUser(XMIN,XMAX);
hQCD0->Draw("HIST");
hQCD1->Draw("sameE");
TLegend *leg = new TLegend(0.6,0.7,0.9,0.9);
leg->SetHeader("QCD Closure");
leg->SetBorderSize(0);
leg->SetTextFont(42);
leg->SetTextSize(0.05);
leg->AddEntry(hQCD1,"Signal sample","P");
leg->AddEntry(hQCD0,"Control sample","F");
leg->Draw();
TH1F *hRatio = (TH1F*)hQCD1->Clone("Ratio");
hRatio->Divide(hQCD0);
hRatio->SetLineColor(kBlack);
hRatio->SetMarkerColor(kBlack);
TPad* pad = new TPad("pad", "pad", 0., 0., 1., 1.);
pad->SetTopMargin(0.7);
//pad->SetRightMargin(0.15);
pad->SetFillColor(0);
pad->SetFillStyle(0);
pad->Draw();
pad->cd(0);
gPad->SetGridy();
hRatio->GetXaxis()->SetTitle(XTITLE);
hRatio->GetXaxis()->SetRangeUser(XMIN,XMAX);
hRatio->GetYaxis()->SetNdivisions(505);
hRatio->GetYaxis()->SetRangeUser(0,2);
hRatio->GetYaxis()->SetLabelSize(0.04);
hRatio->Draw();
hRatio->Draw("same");
}
示例15: Loop
//.........这里部分代码省略.........
hAccTimesEffEB->Divide(hGenEvts);
hAccTimesEffEE->Divide(hGenEvts);
hAccTimesEffEle->Divide(hGenEvts);
hAccTimesEffEleEB->Divide(hGenEvts);
hAccTimesEffEleEE->Divide(hGenEvts);
hAccTimesEffMu->Divide(hGenEvts);
hAccTimesEffNoTrg->Divide(hGenEvts);
//hAccTimesEffNoTrgEB->Divide(hGenEvts);
//hAccTimesEffNoTrgEE->Divide(hGenEvts);
hAccTimesEffNoTrgEle->Divide(hGenEvts);
hAccTimesEffNoTrgEleEB->Divide(hGenEvts);
hAccTimesEffNoTrgEleEE->Divide(hGenEvts);
hAccTimesEffNoTrgMu->Divide(hGenEvts);
hEffAftTrg->Divide(hTrgEvts);
hEffAftTrgEle->Divide(hTrgEvts);
hEffAftTrgEleEB->Divide(hTrgEvts);
hEffAftTrgEleEE->Divide(hTrgEvts);
hEffAftTrgMu->Divide(hTrgEvts);
hTrgRecoVsReco->Divide(hRecoNoTrgEvts);
//hTrgRecoVsRecoEB->Divide(hRecoNoTrgEvtsEB);
//hTrgRecoVsRecoEE->Divide(hRecoNoTrgEvtsEE);
hTrgRecoVsRecoEle->Divide(hRecoNoTrgEleEvts);
hTrgRecoVsRecoEleEB->Divide(hRecoNoTrgEleEvtsEB);
hTrgRecoVsRecoEleEE->Divide(hRecoNoTrgEleEvtsEE);
hTrgRecoVsRecoMu->Divide(hRecoNoTrgMuEvts);
// plot
TCanvas *accTimesEffPlot = new TCanvas("accTimesEffPlot", "acc x eff", 100, 100, 600, 600);
TPad *accTimesEffPad = new TPad("accTimesEffPad", "acc x eff pad", 0., 0., 1., 1.);
accTimesEffPad->SetBottomMargin(0.12);
accTimesEffPad->SetBorderMode(0);
accTimesEffPad->SetBorderSize(2);
accTimesEffPad->SetFrameBorderMode(0);
accTimesEffPad->SetFillColor(0);
accTimesEffPad->SetFrameFillColor(0);
accTimesEffPad->SetLeftMargin(0.11);
accTimesEffPad->SetRightMargin(0.09);
accTimesEffPad->SetTopMargin(0.08);
accTimesEffPad->SetTickx(1);
accTimesEffPad->SetTicky(1);
accTimesEffPad->Draw();
accTimesEffPad->cd();
gStyle->SetTitleFont(font);
gStyle->SetLabelFont(font);
gStyle->SetLegendFont(font);
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
gStyle->SetOptFit(1111);
gStyle->SetTitleXOffset(1.);
gStyle->SetTitleYOffset(1.3);
gPad->SetTicks(1, 1);
gPad->SetGrid(1, 1);
TH1F* hAccTimesEff2 = (TH1F*)hAccTimesEff->Clone("hAccTimesEff2");
TF1 *fitFunc = new TF1("fitFunc", "[0] + [1]/ (x + [2]) + [3]*x", 10., 5010.);
//TF1 *fitFuncEB = new TF1("fitFuncEB", "[0] + [1]/ (x + [2])", 10., 5010.);
TF1 *fitFuncEB = new TF1("fitFuncEB", "[0] + [1]/ (x + [2]) + [3]*x", 10., 5010.);
TF1 *fitFuncEE = new TF1("fitFuncEE", "[0] + [1]/ (x*x + [2])", 10., 5010.);
fitFunc->SetLineColor(kBlue);
fitFuncEB->SetLineColor(kBlue);
fitFuncEE->SetLineColor(kBlue);
hAccTimesEff->Fit("fitFunc", "", "", 480., 5010.);
hAccTimesEffEB->Fit("fitFuncEB", "", "", 480., 5010.);
hAccTimesEffEE->Fit("fitFuncEE", "", "", 480., 5010.);