本文整理汇总了C++中TPaveStats::SetName方法的典型用法代码示例。如果您正苦于以下问题:C++ TPaveStats::SetName方法的具体用法?C++ TPaveStats::SetName怎么用?C++ TPaveStats::SetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPaveStats
的用法示例。
在下文中一共展示了TPaveStats::SetName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resizeStatBox
// Resize any histograms (they all inherit from h1) stat box. Uses NDC coordinates (e.g. 0.65, 0.5)
bool resizeStatBox( TCanvas *c1, TH1* h1, float x1, float y1, float x2=-1, float y2=-1,
TString newname = "", int color = -1, TString oldname = "", int iDebug = 0 )
{
if( !c1 || !h1 ) {cerr<<"Null pointer given to resizeStatBox!"<<endl; return 0;}
c1->Update();
if( oldname.Length() <= 0 ) oldname = "stats";
if( iDebug > 20 ) print_list_of_functions( *h1 );
TPaveStats *stats = (TPaveStats*) h1->FindObject( oldname );
if( iDebug ) cout<<"Found old name (\""<<oldname<<"\"? "<<( stats != 0 )<<endl;
if( (!stats) && newname.Length() > 0 ){ // maybe it was already renamed
stats = (TPaveStats*) h1->FindObject( newname );
if( iDebug ) cout<<"Found new name (\""<<newname<<"\"? "<<(stats != 0)<<endl;
}
if( !stats ) {cerr<<"Can't find stat box"<<endl; return 0;}
stats->SetX1NDC( x1 );
stats->SetY1NDC( y1 );
if( x2 >= 0 ) stats->SetX2NDC( x2 );
if( y2 >= 0 ) stats->SetY2NDC( y2 );
if( newname.Length() > 0 ) {
stats->SetName( newname );
if( iDebug ) cout<<"SetName to "<<newname<<endl;
}
if( color != -1 ) stats->SetTextColor (color);
stats->Draw(); // maybe, just maybe, this will finally make them appear every time, even with draw "same"
return 1;
}
示例2: relocateStatBox
// ---------------------------------------------------------------------------------------------
// The SLAC version
bool relocateStatBox (float x1, float y1, float x2=-1, float y2=-1, TString newname = "")
{
TPaveStats *st = (TPaveStats*)gPad->GetPrimitive("stats");
if (0 == st) {cerr<<"Can't find stat box in pad"<<endl; return 0;}
if (newname.Length() > 0) st->SetName(newname);
st->SetX1NDC(x1);
if (x2 != -1) st->SetX2NDC(x2);
st->SetY1NDC(y1);
if (y2 != -1) st->SetY2NDC(y2);
st->Draw();
return 1;
}
示例3: plot_PbPb_fit_ratio_eff
void plot_PbPb_fit_ratio_eff()
{
//=========Macro generated from canvas: Fit/Fit on Efficiency Ratio
//========= (Mon Aug 29 17:39:14 2016) by ROOT version6.02/10
TCanvas *Fit = new TCanvas("Fit", "Fit on Efficiency Ratio",0,0,800,500);
gStyle->SetOptFit(1);
Fit->Range(1.625,-0.3125,55.375,2.8125);
Fit->SetFillColor(0);
Fit->SetBorderMode(0);
Fit->SetBorderSize(2);
Fit->SetFrameBorderMode(0);
Fit->SetFrameBorderMode(0);
Double_t xAxis1[6] = {7, 10, 15, 20, 30, 50};
TH1D *PbPb_fit1 = new TH1D("PbPb_fit1","",5, xAxis1);
PbPb_fit1->SetBinContent(1,0.8304669);
PbPb_fit1->SetBinContent(2,0.8392248);
PbPb_fit1->SetBinContent(3,0.8551938);
PbPb_fit1->SetBinContent(4,0.8559738);
PbPb_fit1->SetBinContent(5,0.8749088);
PbPb_fit1->SetBinError(1,0.06688803);
PbPb_fit1->SetBinError(2,0.03626477);
PbPb_fit1->SetBinError(3,0.03301156);
PbPb_fit1->SetBinError(4,0.02217037);
PbPb_fit1->SetBinError(5,0.01963207);
PbPb_fit1->SetMinimum(0);
PbPb_fit1->SetMaximum(2.5);
PbPb_fit1->SetEntries(2335.214);
TF1 *myfit1 = new TF1("myfit","pow(10,[0]+[1]*x+x*x*[2])+pow(10,[3]*x*x+[4]*x*x*x+[5])",2,100);
myfit1->SetFillColor(19);
myfit1->SetFillStyle(0);
myfit1->SetMarkerStyle(20);
myfit1->SetLineColor(2);
myfit1->SetLineWidth(2);
myfit1->SetChisquare(5.134234e-08);
myfit1->SetNDF(0);
myfit1->GetXaxis()->SetLabelFont(42);
myfit1->GetXaxis()->SetLabelSize(0.035);
myfit1->GetXaxis()->SetTitleSize(0.035);
myfit1->GetXaxis()->SetTitleFont(42);
myfit1->GetYaxis()->SetLabelFont(42);
myfit1->GetYaxis()->SetLabelSize(0.035);
myfit1->GetYaxis()->SetTitleSize(0.035);
myfit1->GetYaxis()->SetTitleFont(42);
myfit1->SetParameter(0,-0.1325891);
myfit1->SetParError(0,0.07303413);
myfit1->SetParLimits(0,0,0);
myfit1->SetParameter(1,-0.004821085);
myfit1->SetParError(1,0.00252747);
myfit1->SetParLimits(1,0,0);
myfit1->SetParameter(2,0.0001629026);
myfit1->SetParError(2,6.139007e-05);
myfit1->SetParLimits(2,0,0);
myfit1->SetParameter(3,0.001400688);
myfit1->SetParError(3,0.0009400359);
myfit1->SetParLimits(3,0,0);
myfit1->SetParameter(4,-4.985927e-05);
myfit1->SetParError(4,3.268586e-05);
myfit1->SetParLimits(4,0,0);
myfit1->SetParameter(5,-0.9198558);
myfit1->SetParError(5,0.3015603);
myfit1->SetParLimits(5,0,0);
PbPb_fit1->GetListOfFunctions()->Add(myfit1);
TPaveStats *ptstats = new TPaveStats(0.558,0.6,0.9,0.9,"brNDC");
ptstats->SetName("stats");
ptstats->SetBorderSize(1);
ptstats->SetFillColor(0);
ptstats->SetTextAlign(12);
ptstats->SetTextFont(42);
TText *AText = ptstats->AddText("PbPb_fit");
AText->SetTextSize(0.01971428);
AText = ptstats->AddText("Entries = 2335 ");
AText = ptstats->AddText("Mean = 20.89");
AText = ptstats->AddText("RMS = 11.16");
AText = ptstats->AddText("Underflow = 0");
AText = ptstats->AddText("Overflow = 0");
AText = ptstats->AddText("Integral = 4.256");
AText = ptstats->AddText("#chi^{2} / ndf = 5.134e-08 / 0");
AText = ptstats->AddText("p0 = -0.1326 #pm 0.0730 ");
AText = ptstats->AddText("p1 = -0.004821 #pm 0.002527 ");
AText = ptstats->AddText("p2 = 0.0001629 #pm 0.0000614 ");
AText = ptstats->AddText("p3 = 0.001401 #pm 0.000940 ");
AText = ptstats->AddText("p4 = -4.986e-05 #pm 3.269e-05 ");
AText = ptstats->AddText("p5 = -0.9199 #pm 0.3016 ");
ptstats->SetOptStat(1111111);
ptstats->SetOptFit(111);
ptstats->Draw();
PbPb_fit1->GetListOfFunctions()->Add(ptstats);
ptstats->SetParent(PbPb_fit1);
Int_t ci; // for color index setting
TColor *color; // for color definition with alpha
ci = TColor::GetColor("#000099");
PbPb_fit1->SetLineColor(ci);
PbPb_fit1->SetMarkerStyle(20);
PbPb_fit1->GetXaxis()->SetTitle("Gen p_{T}(GeV)");
PbPb_fit1->GetXaxis()->CenterTitle(true);
PbPb_fit1->GetXaxis()->SetLabelFont(42);
//.........这里部分代码省略.........
示例4: c
//.........这里部分代码省略.........
hist__1__1->SetBinContent(56,4531);
hist__1__1->SetBinContent(57,4598);
hist__1__1->SetBinContent(58,4456);
hist__1__1->SetBinContent(59,4341);
hist__1__1->SetBinContent(60,4654);
hist__1__1->SetBinContent(61,4672);
hist__1__1->SetBinContent(62,4511);
hist__1__1->SetBinContent(63,4446);
hist__1__1->SetBinContent(64,4356);
hist__1__1->SetBinContent(65,4380);
hist__1__1->SetBinContent(66,4383);
hist__1__1->SetBinContent(67,4469);
hist__1__1->SetBinContent(68,4606);
hist__1__1->SetBinContent(69,4563);
hist__1__1->SetBinContent(70,4413);
hist__1__1->SetBinContent(71,4701);
hist__1__1->SetBinContent(72,4643);
hist__1__1->SetBinContent(73,4427);
hist__1__1->SetBinContent(74,3933);
hist__1__1->SetBinContent(75,3939);
hist__1__1->SetBinContent(76,4093);
hist__1__1->SetBinContent(77,3913);
hist__1__1->SetBinContent(78,4026);
hist__1__1->SetBinContent(79,3843);
hist__1__1->SetBinContent(80,3641);
hist__1__1->SetBinContent(81,3916);
hist__1__1->SetBinContent(82,4042);
hist__1__1->SetBinContent(83,3798);
hist__1__1->SetBinContent(84,3601);
hist__1__1->SetBinContent(85,3249);
hist__1__1->SetBinContent(86,3146);
hist__1__1->SetBinContent(87,3199);
hist__1__1->SetBinContent(88,3035);
hist__1__1->SetBinContent(89,3021);
hist__1__1->SetBinContent(90,2861);
hist__1__1->SetBinContent(91,2848);
hist__1__1->SetBinContent(92,2819);
hist__1__1->SetBinContent(93,2744);
hist__1__1->SetBinContent(94,2542);
hist__1__1->SetBinContent(95,2198);
hist__1__1->SetBinContent(96,1717);
hist__1__1->SetBinContent(97,1743);
hist__1__1->SetBinContent(98,1585);
hist__1__1->SetBinContent(99,1504);
hist__1__1->SetBinContent(100,1475);
hist__1__1->SetBinContent(101,12137);
hist__1__1->SetEntries(397426);
TPaveStats *ptstats = new TPaveStats(0.78,0.775,0.98,0.935,"brNDC");
ptstats->SetName("stats");
ptstats->SetBorderSize(1);
ptstats->SetFillColor(0);
ptstats->SetTextAlign(12);
ptstats->SetTextFont(42);
TText *AText = ptstats->AddText("hist__1");
AText->SetTextSize(0.0368);
AText = ptstats->AddText("Entries = 397426 ");
AText = ptstats->AddText("Mean = -0.08411");
AText = ptstats->AddText("Std Dev = 66.16");
ptstats->SetOptStat(1111);
ptstats->SetOptFit(0);
ptstats->Draw();
hist__1__1->GetListOfFunctions()->Add(ptstats);
ptstats->SetParent(hist__1__1);
Int_t ci; // for color index setting
TColor *color; // for color definition with alpha
ci = 926;
color = new TColor(ci, 0, 0, 1, " ", 0.273);
hist__1__1->SetFillColor(ci);
hist__1__1->SetLineColor(4);
hist__1__1->SetLineWidth(2);
hist__1__1->GetXaxis()->SetTitle("#DeltaY [cm]");
hist__1__1->GetXaxis()->SetLabelFont(42);
hist__1__1->GetXaxis()->SetLabelSize(0.05);
hist__1__1->GetXaxis()->SetTitleSize(0.05);
hist__1__1->GetXaxis()->SetTitleOffset(0.93);
hist__1__1->GetXaxis()->SetTitleFont(22);
hist__1__1->GetYaxis()->SetLabelFont(42);
hist__1__1->GetYaxis()->SetLabelSize(0.05);
hist__1__1->GetYaxis()->SetTitleSize(0.035);
hist__1__1->GetYaxis()->SetTitleFont(42);
hist__1__1->GetZaxis()->SetLabelFont(42);
hist__1__1->GetZaxis()->SetLabelSize(0.035);
hist__1__1->GetZaxis()->SetTitleSize(0.035);
hist__1__1->GetZaxis()->SetTitleFont(42);
hist__1__1->Draw("");
TPaveText *pt = new TPaveText(0.15,0.9368947,0.85,0.995,"blNDC");
pt->SetName("title");
pt->SetBorderSize(0);
pt->SetFillColor(0);
pt->SetFillStyle(0);
pt->SetTextFont(42);
AText = pt->AddText("Difference in PMT-constructed position and mc-truth start position");
pt->Draw();
c->Modified();
c->cd();
c->SetSelected(c);
}
示例5: initial_z_diff
//.........这里部分代码省略.........
hist__1->SetBinContent(52,21828);
hist__1->SetBinContent(53,17254);
hist__1->SetBinContent(54,13388);
hist__1->SetBinContent(55,10171);
hist__1->SetBinContent(56,7452);
hist__1->SetBinContent(57,5752);
hist__1->SetBinContent(58,4452);
hist__1->SetBinContent(59,3522);
hist__1->SetBinContent(60,2826);
hist__1->SetBinContent(61,2449);
hist__1->SetBinContent(62,2170);
hist__1->SetBinContent(63,1855);
hist__1->SetBinContent(64,1635);
hist__1->SetBinContent(65,1515);
hist__1->SetBinContent(66,1393);
hist__1->SetBinContent(67,1344);
hist__1->SetBinContent(68,1279);
hist__1->SetBinContent(69,1232);
hist__1->SetBinContent(70,1248);
hist__1->SetBinContent(71,1277);
hist__1->SetBinContent(72,1226);
hist__1->SetBinContent(73,1247);
hist__1->SetBinContent(74,1229);
hist__1->SetBinContent(75,1187);
hist__1->SetBinContent(76,1265);
hist__1->SetBinContent(77,1253);
hist__1->SetBinContent(78,1269);
hist__1->SetBinContent(79,1210);
hist__1->SetBinContent(80,1055);
hist__1->SetBinContent(81,914);
hist__1->SetBinContent(82,761);
hist__1->SetBinContent(83,632);
hist__1->SetBinContent(84,515);
hist__1->SetBinContent(85,450);
hist__1->SetBinContent(86,356);
hist__1->SetBinContent(87,264);
hist__1->SetBinContent(88,227);
hist__1->SetBinContent(89,176);
hist__1->SetBinContent(90,127);
hist__1->SetBinContent(91,134);
hist__1->SetBinContent(92,85);
hist__1->SetBinContent(93,60);
hist__1->SetBinContent(94,47);
hist__1->SetBinContent(95,29);
hist__1->SetBinContent(96,31);
hist__1->SetBinContent(97,18);
hist__1->SetBinContent(98,14);
hist__1->SetBinContent(99,12);
hist__1->SetBinContent(100,12);
hist__1->SetBinContent(101,63);
hist__1->SetEntries(289897);
TPaveStats *ptstats = new TPaveStats(0.78,0.775,0.98,0.935,"brNDC");
ptstats->SetName("stats");
ptstats->SetBorderSize(1);
ptstats->SetFillColor(0);
ptstats->SetTextAlign(12);
ptstats->SetTextFont(42);
TText *AText = ptstats->AddText("hist");
AText->SetTextSize(0.0368);
AText = ptstats->AddText("Entries = 289897 ");
AText = ptstats->AddText("Mean = 0.6888");
AText = ptstats->AddText("Std Dev = 33.12");
ptstats->SetOptStat(1111);
ptstats->SetOptFit(0);
ptstats->Draw();
hist__1->GetListOfFunctions()->Add(ptstats);
ptstats->SetParent(hist__1);
Int_t ci; // for color index setting
TColor *color; // for color definition with alpha
ci = TColor::GetColor("#000099");
hist__1->SetLineColor(ci);
hist__1->GetXaxis()->SetTitle("#DeltaZ [cm]");
hist__1->GetXaxis()->SetLabelFont(42);
hist__1->GetXaxis()->SetLabelSize(0.035);
hist__1->GetXaxis()->SetTitleSize(0.035);
hist__1->GetXaxis()->SetTitleFont(42);
hist__1->GetYaxis()->SetLabelFont(42);
hist__1->GetYaxis()->SetLabelSize(0.035);
hist__1->GetYaxis()->SetTitleSize(0.035);
hist__1->GetYaxis()->SetTitleFont(42);
hist__1->GetZaxis()->SetLabelFont(42);
hist__1->GetZaxis()->SetLabelSize(0.035);
hist__1->GetZaxis()->SetTitleSize(0.035);
hist__1->GetZaxis()->SetTitleFont(42);
hist__1->Draw("");
TPaveText *pt = new TPaveText(0.15,0.9368947,0.85,0.995,"blNDC");
pt->SetName("title");
pt->SetBorderSize(0);
pt->SetFillColor(0);
pt->SetFillStyle(0);
pt->SetTextFont(42);
AText = pt->AddText("Difference in PMT-constructed position and mc-truth start position");
pt->Draw();
c->Modified();
c->cd();
c->SetSelected(c);
}
示例6: FitDijetMass_Data
void FitDijetMass_Data() {
TFile *inf = new TFile("MassResults_ak7calo.root");
TH1F *hCorMassDen = (TH1F*) inf->Get("DiJetMass");
hCorMassDen->SetXTitle("Corrected Dijet Mass (GeV)");
hCorMassDen->SetYTitle("Events/GeV");
hCorMassDen->GetYaxis()->SetTitleOffset(1.5);
hCorMassDen->SetMarkerStyle(20);
hCorMassDen->GetXaxis()->SetRangeUser(120.,900.);
gROOT->ProcessLine(".L tdrstyle.C");
setTDRStyle();
tdrStyle->SetErrorX(0.5);
tdrStyle->SetPadRightMargin(0.08);
tdrStyle->SetLegendBorderSize(0);
gStyle->SetOptFit(1111);
tdrStyle->SetOptStat(0);
TCanvas* c2 = new TCanvas("c2","DijetMass", 500, 500);
/////// perform 4 parameters fit
TF1 *func = new TF1("func", "[0]*((1-x/7000.+[3]*(x/7000)^2)^[1])/(x^[2])",
100., 1000.);
func->SetParameter(0, 1.0e+08);
func->SetParameter(1, -1.23);
func->SetParameter(2, 4.13);
func->SetParameter(3, 1.0);
func->SetLineColor(4);
func->SetLineWidth(3);
TVirtualFitter::SetMaxIterations( 10000 );
TVirtualFitter *fitter;
TMatrixDSym* cov_matrix;
int fitStatus = hCorMassDen->Fit("func","LLI","",130.0, 800.0); // QCD fit
TH1F *hFitUncertainty = hCorMassDen->Clone("hFitUncertainty");
hFitUncertainty->SetLineColor(5);
hFitUncertainty->SetFillColor(5);
hFitUncertainty->SetMarkerColor(5);
if (fitStatus == 0) {
fitter = TVirtualFitter::GetFitter();
double* m_elements = fitter->GetCovarianceMatrix();
cov_matrix = new TMatrixDSym( func->GetNumberFreeParameters(),m_elements);
cov_matrix->Print();
double x, y, e;
for(int i=0;i<hFitUncertainty->GetNbinsX();i++)
{
x = hFitUncertainty->GetBinCenter(i+1);
y = func->Eval(x);
e = QCDFitUncertainty( func, *cov_matrix, x);
hFitUncertainty->SetBinContent(i+1,y);
hFitUncertainty->SetBinError(i+1,e);
}
}
hCorMassDen->Draw("ep");
gPad->Update();
TPaveStats *st = (TPaveStats*)hCorMassDen->FindObject("stats");
st->SetName("stats1");
st->SetX1NDC(0.3); //new x start position
st->SetX2NDC(0.6); //new x end position
st->SetTextColor(4);
hCorMassDen->GetListOfFunctions()->Add(st);
/////// perform 2 parameters fit
TF1 *func2 = new TF1("func2", "[0]*(1-x/7000.)/(x^[1])", 100., 1000.);
func2->SetParameter(0, 10000.);
func2->SetParameter(1, 5.0);
func2->SetLineWidth(3);
fitStatus = hCorMassDen->Fit("func2","LLI","",130.0, 800.0); // QCD fit
TH1F *hFitUncertainty2 = hCorMassDen->Clone("hFitUncertainty2");
hFitUncertainty2->SetLineColor(kGray);
hFitUncertainty2->SetFillColor(kGray);
hFitUncertainty2->SetMarkerColor(kGray);
if (fitStatus == 0) {
fitter = TVirtualFitter::GetFitter();
double* m_elements = fitter->GetCovarianceMatrix();
cov_matrix = new TMatrixDSym( func2->GetNumberFreeParameters(),m_elements);
cov_matrix->Print();
double x, y, e;
for(int i=0;i<hFitUncertainty2->GetNbinsX();i++)
{
x = hFitUncertainty2->GetBinCenter(i+1);
y = func2->Eval(x);
e = QCDFitUncertainty( func2, *cov_matrix, x);
hFitUncertainty2->SetBinContent(i+1,y);
hFitUncertainty2->SetBinError(i+1,e);
//.........这里部分代码省略.........
示例7: BSA_InCoherent_t
void BSA_InCoherent_t()
{
//=========Macro generated from canvas: c17/Incoherent channe
//========= (Tue Aug 21 12:00:26 2018) by ROOT version6.09/01
TCanvas *c17 = new TCanvas("c17", "Incoherent channe",0,0,1200,400);
gStyle->SetOptFit(1);
c17->Range(0,0,1,1);
c17->SetFillColor(0);
c17->SetBorderMode(0);
c17->SetBorderSize(2);
c17->SetLeftMargin(0.025);
c17->SetRightMargin(0.02325581);
c17->SetFrameBorderMode(0);
// ------------>Primitives in pad: c17_1
TPad *c17_1 = new TPad("c17_1", "Incoherent channe_1",0,0,0.262936,0.9);
c17_1->Draw();
c17_1->cd();
c17_1->Range(-32.86883,-0.4888889,353.6809,0.4);
c17_1->SetFillColor(0);
c17_1->SetBorderMode(0);
c17_1->SetBorderSize(2);
c17_1->SetGridx();
c17_1->SetGridy();
c17_1->SetRightMargin(0);
c17_1->SetTopMargin(0);
c17_1->SetFrameBorderMode(0);
c17_1->SetFrameBorderMode(0);
TMultiGraph *multigraph = new TMultiGraph();
multigraph->SetName("");
multigraph->SetTitle("0.05<-t<0.21 [GeV^{2}/c^{2}]");
Double_t Graph_fx1154[9] = {
21.59954,
59.03178,
96.06391,
141.7703,
179.2242,
222.8541,
259.5793,
303.38,
337.8675};
Double_t Graph_fy1154[9] = {
0.1020231,
0.03114899,
0.2309077,
0.1341245,
0.01684177,
-0.1267998,
-0.2824572,
-0.2260703,
-0.0186068};
Double_t Graph_fex1154[9] = {
0,
0,
0,
0,
0,
0,
0,
0,
0};
Double_t Graph_fey1154[9] = {
0.04242532,
0.05165487,
0.05483741,
0.07646672,
0.1006626,
0.09089962,
0.05905575,
0.04462244,
0.05521722};
TGraphErrors *gre = new TGraphErrors(9,Graph_fx1154,Graph_fy1154,Graph_fex1154,Graph_fey1154);
gre->SetName("Graph");
gre->SetTitle("Graph");
gre->SetFillColor(1);
Int_t ci; // for color index setting
TColor *color; // for color definition with alpha
ci = TColor::GetColor("#00ff00");
gre->SetMarkerColor(ci);
gre->SetMarkerStyle(21);
TH1F *Graph_Graph1154 = new TH1F("Graph_Graph1154","Graph",100,0,369.4943);
Graph_Graph1154->SetMinimum(-0.4042387);
Graph_Graph1154->SetMaximum(0.3484709);
Graph_Graph1154->SetDirectory(0);
Graph_Graph1154->SetStats(0);
ci = TColor::GetColor("#000099");
Graph_Graph1154->SetLineColor(ci);
Graph_Graph1154->GetXaxis()->SetLabelFont(42);
Graph_Graph1154->GetXaxis()->SetLabelSize(0.035);
Graph_Graph1154->GetXaxis()->SetTitleSize(0.035);
Graph_Graph1154->GetXaxis()->SetTitleFont(42);
Graph_Graph1154->GetYaxis()->SetLabelFont(42);
Graph_Graph1154->GetYaxis()->SetLabelSize(0.035);
Graph_Graph1154->GetYaxis()->SetTitleSize(0.035);
Graph_Graph1154->GetYaxis()->SetTitleFont(42);
//.........这里部分代码省略.........
示例8: hw1
int hw1(){
//define landau formula
TF1* myf = new TF1("mylandau",landauf,-3,10,3);
myf->SetParameters(1.0,2,1);
//get ready to initial hist
/*
const int num = 3;
string histvName[num] = {"ld_1e2","ld_1e3","ld_1e4"};
string histvTitle[num] = {"Landau 100 entris","Landau 1000 entris","Landau 10000 entris"};
int histEntries[num] = {100,1000,10000};
//new hist and fill them
TCanvas* canvas = new TCanvas("myc","HW1",800,600);
TMultiGraph* mg = new TMultiGraph();
for(int i = 0;i<num;i++){
TH1F* tmp=new TH1F(histvName[i].c_str(),histvTitle[i].c_str(),100,-3,10);
tmp->FillRandom("mylandau",histEntries[i]);
}
gDirectory->Get(histvName[2])->Draw("e");
gDirectory->Get(histvName[1])->Draw("esame");
gDirectory->Get(histvName[0])->Draw("esame");
*/
TCanvas* canvas = new TCanvas("myc","HW1",800,600);
TH1F* h1 = new TH1F("h1","Landau 100 entries",15,-3,10);
TH1F* h2 = new TH1F("h2","Landau 1000 entries",60,-3,10);
TH1F* h3 = new TH1F("h3","Landau 10000 entries",200,-3,10);
h1->FillRandom("mylandau",100);
h2->FillRandom("mylandau",1000);
h3->FillRandom("mylandau",10000);
h3->GetXaxis()->SetTitle("x");
h3->GetXaxis()->CenterTitle(true);
h3->GetYaxis()->SetTitle("Entries");
h3->GetYaxis()->CenterTitle(true);
h3->SetStats(kFALSE);
TF1* fit3 = new TF1("fit3",landauf,-3,10,3);
fit3->SetParameters(1.0,2,1);
h3->SetMarkerColor(kRed);
h3->SetLineColor(kRed);
fit3->SetLineColor(kRed+2);
h3->Fit("fit3","q","e");
TF1* fit2 = new TF1("fit2",landauf,-3,10,3);
fit2->SetParameters(1.0,2,1);
h2->SetMarkerColor(kBlue);
h2->SetLineColor(kBlue);
fit2->SetLineColor(kBlue+2);
h2->Fit("fit2","q","esame");
TF1* fit1 = new TF1("fit1",landauf,-3,10,3);
fit1->SetParameters(1.0,2,1);
h1->SetMarkerColor(kGreen);
h1->SetLineColor(kGreen);
fit1->SetLineColor(kGreen+2);
h1->Fit("fit1","q","esame");
double h1M = h1->GetMean();
double h1R = h1->GetRMS();
double h1S = h1->GetSkewness();
double h2M = h2->GetMean();
double h2R = h2->GetRMS();
double h2S = h2->GetSkewness();
double h3M = h3->GetMean();
double h3R = h3->GetRMS();
double h3S = h3->GetSkewness();
cout<<setprecision(4);
cout<<"+----+--------+--------+--------+"<<endl;
cout<<"|hist| Mean | RMS |skewness|"<<endl;
cout<<"+----+--------+--------+--------+"<<endl;
cout<<"+ 1 |"<<setw(8)<<h1M<<"|"<<setw(8)<<h1R<<"|"<<setw(8)<<h1S<<"|"<<endl;
cout<<"+----+--------+--------+--------+"<<endl;
cout<<"+ 2 |"<<setw(8)<<h2M<<"|"<<setw(8)<<h2R<<"|"<<setw(8)<<h2S<<"|"<<endl;
cout<<"+----+--------+--------+--------+"<<endl;
cout<<"+ 3 |"<<setw(8)<<h3M<<"|"<<setw(8)<<h3R<<"|"<<setw(8)<<h3S<<"|"<<endl;
cout<<"+----+--------+--------+--------+"<<endl;
TPaveStats *ptstats = new TPaveStats(0.5747126,0.6334746,0.9353448,0.934322,"brNDC");
ptstats->SetName("stats");
ptstats->SetBorderSize(1);
ptstats->SetFillColor(0);
ptstats->SetLineWidth(2);
ptstats->SetTextAlign(12);
ptstats->SetTextFont(132);
ptstats->AddText(" hist Mean RMS skewness ");
ostringstream os;
cout<<setprecision(4);
os<<" 1 "<<setw(8)<<h1M<<" "<<setw(8)<<h1R<<" "<<setw(8)<<h1S<<" ";
ptstats->AddText(os.str().c_str());
os.str(string());
os<<" 2 "<<setw(8)<<h2M<<" "<<setw(8)<<h2R<<" "<<setw(8)<<h2S<<" ";
ptstats->AddText(os.str().c_str());
os.str(string());
os<<" 3 "<<setw(8)<<h3M<<" "<<setw(8)<<h3R<<" "<<setw(8)<<h3S<<" ";
ptstats->AddText(os.str().c_str());
ptstats->SetOptStat(0);
ptstats->SetOptFit(111);
//.........这里部分代码省略.........
示例9: main
void main() {
TFile *f1 = new TFile("TA2Cristina_Compton.root");
TTree *t1 = (TTree*)f1->Get("TA2CristinaTree");
TFile *f2 = new TFile("TA2Cristina_Pi0.root");
TTree *t2 = (TTree*)f2->Get("TA2CristinaTree");
gStyle->SetOptStat(1111);
c1 = new TCanvas("c1","Compton (Left) and Pi0 (Right)");
c1->Divide(2,3);
c1->cd(1);
t1->Draw("PhotonEnergyDifference:PhotonEnergy");
c1->cd(2);
t2->Draw("PhotonEnergyDifference:PhotonEnergy");
c1->cd(3);
t1->Draw("PhotonEnergyDifference:PhotonTheta");
c1->cd(4);
t2->Draw("PhotonEnergyDifference:PhotonTheta");
c1->cd(5);
t1->Draw("PhotonEnergyDifference:PhotonPhi");
c1->cd(6);
t2->Draw("PhotonEnergyDifference:PhotonPhi");
c2 = new TCanvas("c2","Compton (Left) and Pi0 (Right)");
c2->Divide(2,3);
c2->cd(1);
t1->Draw("PhotonEnergyDifference:ProtonEnergy","NProton>0");
c2->cd(2);
t2->Draw("PhotonEnergyDifference:ProtonEnergy","NProton>0");
c2->cd(3);
t1->Draw("PhotonEnergyDifference:ProtonTheta","NProton>0");
c2->cd(4);
t2->Draw("PhotonEnergyDifference:ProtonTheta","NProton>0");
c2->cd(5);
t1->Draw("PhotonEnergyDifference:ProtonPhi","NProton>0");
c2->cd(6);
t2->Draw("PhotonEnergyDifference:ProtonPhi","NProton>0");
c3 = new TCanvas("c3","Compton and Pi0");
c3->cd();
t1->Draw("PhotonEnergyDifference:PhotonTheta");
// --------------------------------------------------------------------------------
c4 = new TCanvas("c4","Compton and Pi0");
c4->cd();
t2->SetMarkerColor(kBlue+2);
t1->SetMarkerColor(kRed);
t2->Draw("PhotonEnergyDifference:PhotonTheta>>Pi0(180, 0, 180, 120, 180, 300)");
TH2F *Pi0 = (TH2F*)gDirectory->Get("Pi0");
t1->Draw("PhotonEnergyDifference:PhotonTheta>>Compton(180, 0, 180, 120, 180, 300)");
TH2F *Compton = (TH2F*)gDirectory->Get("Compton");
gStyle->SetStatTextColor(kBlue+2);
Pi0->Draw();
c4->Update();
TPaveStats *stats =(TPaveStats*)c4->GetPrimitive("stats");
stats->SetName("h1stats");
stats->SetY1NDC(.508);
stats->SetY2NDC(.75);
gStyle->SetStatTextColor(kRed);
Compton->Draw("sames");
// -------------------------------------------------------------------
c5 = new TCanvas("c5","Compton and Pi0");
c5->cd();
t2->SetMarkerColor(kBlue+2);
t1->SetMarkerColor(kRed);
t2->Draw("PhotonEnergyDifference:PhotonTheta>>Pi0_1(180, 0, 180, 120, 180, 300)","PhotonEnergy<150");
TH2F *Pi0_1 = (TH2F*)gDirectory->Get("Pi0_1");
t1->Draw("PhotonEnergyDifference:PhotonTheta>>Compton_1(180, 0, 180, 120, 180, 300)","PhotonEnergy<150");
TH2F *Compton_1 = (TH2F*)gDirectory->Get("Compton_1");
gStyle->SetStatTextColor(kBlue+2);
Pi0_1->Draw();
c5->Update();
TPaveStats *stats =(TPaveStats*)c5->GetPrimitive("stats");
stats->SetName("h1stats");
//.........这里部分代码省略.........
示例10: BSA_InCoherent_xB
void BSA_InCoherent_xB()
{
//=========Macro generated from canvas: c16/Incoherent channe
//========= (Tue Aug 21 12:00:25 2018) by ROOT version6.09/01
TCanvas *c16 = new TCanvas("c16", "Incoherent channe",0,0,1200,400);
gStyle->SetOptFit(1);
c16->Range(0,0,1,1);
c16->SetFillColor(0);
c16->SetBorderMode(0);
c16->SetBorderSize(2);
c16->SetLeftMargin(0.025);
c16->SetRightMargin(0.02325581);
c16->SetFrameBorderMode(0);
// ------------>Primitives in pad: c16_1
TPad *c16_1 = new TPad("c16_1", "Incoherent channe_1",0,0,0.262936,0.9);
c16_1->Draw();
c16_1->cd();
c16_1->Range(-29.34641,-0.4888889,350.2581,0.4);
c16_1->SetFillColor(0);
c16_1->SetBorderMode(0);
c16_1->SetBorderSize(2);
c16_1->SetGridx();
c16_1->SetGridy();
c16_1->SetRightMargin(0);
c16_1->SetTopMargin(0);
c16_1->SetFrameBorderMode(0);
c16_1->SetFrameBorderMode(0);
TMultiGraph *multigraph = new TMultiGraph();
multigraph->SetName("");
multigraph->SetTitle("0.12<x_{B}<0.21 ");
Double_t Graph_fx1134[9] = {
24.14331,
62.70082,
96.14623,
141.7289,
180.8857,
220.5862,
258.7856,
303.3336,
334.7288};
Double_t Graph_fy1134[9] = {
0.1330996,
-0.03883743,
0.1388413,
0.2120595,
0.03749243,
-0.09129921,
-0.1273289,
-0.1643618,
0.03103783};
Double_t Graph_fex1134[9] = {
0,
0,
0,
0,
0,
0,
0,
0,
0};
Double_t Graph_fey1134[9] = {
0.07077824,
0.06445297,
0.05939535,
0.06833722,
0.08559024,
0.08401363,
0.06136237,
0.05845869,
0.08718727};
TGraphErrors *gre = new TGraphErrors(9,Graph_fx1134,Graph_fy1134,Graph_fex1134,Graph_fey1134);
gre->SetName("Graph");
gre->SetTitle("Graph");
gre->SetFillColor(1);
Int_t ci; // for color index setting
TColor *color; // for color definition with alpha
ci = TColor::GetColor("#00ff00");
gre->SetMarkerColor(ci);
gre->SetMarkerStyle(21);
TH1F *Graph_Graph1134 = new TH1F("Graph_Graph1134","Graph",100,0,365.7873);
Graph_Graph1134->SetMinimum(-0.2731422);
Graph_Graph1134->SetMaximum(0.3307184);
Graph_Graph1134->SetDirectory(0);
Graph_Graph1134->SetStats(0);
ci = TColor::GetColor("#000099");
Graph_Graph1134->SetLineColor(ci);
Graph_Graph1134->GetXaxis()->SetLabelFont(42);
Graph_Graph1134->GetXaxis()->SetLabelSize(0.035);
Graph_Graph1134->GetXaxis()->SetTitleSize(0.035);
Graph_Graph1134->GetXaxis()->SetTitleFont(42);
Graph_Graph1134->GetYaxis()->SetLabelFont(42);
Graph_Graph1134->GetYaxis()->SetLabelSize(0.035);
Graph_Graph1134->GetYaxis()->SetTitleSize(0.035);
Graph_Graph1134->GetYaxis()->SetTitleFont(42);
//.........这里部分代码省略.........
示例11: TCanvas
//.........这里部分代码省略.........
hist__1->SetBinContent(52,17962);
hist__1->SetBinContent(53,14130);
hist__1->SetBinContent(54,10947);
hist__1->SetBinContent(55,8303);
hist__1->SetBinContent(56,6081);
hist__1->SetBinContent(57,4643);
hist__1->SetBinContent(58,3602);
hist__1->SetBinContent(59,2825);
hist__1->SetBinContent(60,2235);
hist__1->SetBinContent(61,1955);
hist__1->SetBinContent(62,1716);
hist__1->SetBinContent(63,1461);
hist__1->SetBinContent(64,1266);
hist__1->SetBinContent(65,1191);
hist__1->SetBinContent(66,1098);
hist__1->SetBinContent(67,1054);
hist__1->SetBinContent(68,999);
hist__1->SetBinContent(69,957);
hist__1->SetBinContent(70,982);
hist__1->SetBinContent(71,980);
hist__1->SetBinContent(72,932);
hist__1->SetBinContent(73,910);
hist__1->SetBinContent(74,873);
hist__1->SetBinContent(75,812);
hist__1->SetBinContent(76,785);
hist__1->SetBinContent(77,748);
hist__1->SetBinContent(78,649);
hist__1->SetBinContent(79,593);
hist__1->SetBinContent(80,459);
hist__1->SetBinContent(81,400);
hist__1->SetBinContent(82,321);
hist__1->SetBinContent(83,244);
hist__1->SetBinContent(84,198);
hist__1->SetBinContent(85,180);
hist__1->SetBinContent(86,147);
hist__1->SetBinContent(87,93);
hist__1->SetBinContent(88,73);
hist__1->SetBinContent(89,50);
hist__1->SetBinContent(90,43);
hist__1->SetBinContent(91,37);
hist__1->SetBinContent(92,22);
hist__1->SetBinContent(93,15);
hist__1->SetBinContent(94,10);
hist__1->SetBinContent(95,7);
hist__1->SetBinContent(96,7);
hist__1->SetBinContent(97,3);
hist__1->SetBinContent(98,2);
hist__1->SetBinContent(99,3);
hist__1->SetBinContent(100,3);
hist__1->SetBinContent(101,28);
hist__1->SetEntries(227323);
TPaveStats *ptstats = new TPaveStats(0.78,0.775,0.98,0.935,"brNDC");
ptstats->SetName("stats");
ptstats->SetBorderSize(1);
ptstats->SetFillColor(0);
ptstats->SetTextAlign(12);
ptstats->SetTextFont(42);
TText *AText = ptstats->AddText("hist");
AText->SetTextSize(0.0368);
AText = ptstats->AddText("Entries = 227323 ");
AText = ptstats->AddText("Mean = 0.5797");
AText = ptstats->AddText("Std Dev = 28.66");
ptstats->SetOptStat(1111);
ptstats->SetOptFit(0);
ptstats->Draw();
hist__1->GetListOfFunctions()->Add(ptstats);
ptstats->SetParent(hist__1);
Int_t ci; // for color index setting
TColor *color; // for color definition with alpha
ci = TColor::GetColor("#000099");
hist__1->SetLineColor(ci);
hist__1->GetXaxis()->SetTitle("#DeltaZ [cm]");
hist__1->GetXaxis()->SetLabelFont(42);
hist__1->GetXaxis()->SetLabelSize(0.035);
hist__1->GetXaxis()->SetTitleSize(0.035);
hist__1->GetXaxis()->SetTitleFont(42);
hist__1->GetYaxis()->SetLabelFont(42);
hist__1->GetYaxis()->SetLabelSize(0.035);
hist__1->GetYaxis()->SetTitleSize(0.035);
hist__1->GetYaxis()->SetTitleFont(42);
hist__1->GetZaxis()->SetLabelFont(42);
hist__1->GetZaxis()->SetLabelSize(0.035);
hist__1->GetZaxis()->SetTitleSize(0.035);
hist__1->GetZaxis()->SetTitleFont(42);
hist__1->Draw("");
TPaveText *pt = new TPaveText(0.3779599,0.9368947,0.6220401,0.995,"blNDC");
pt->SetName("title");
pt->SetBorderSize(0);
pt->SetFillColor(0);
pt->SetFillStyle(0);
pt->SetTextFont(42);
AText = pt->AddText("Worry Later");
pt->Draw();
c->Modified();
c->cd();
c->SetSelected(c);
}
示例12: QCDHT_cutflow_weighted
void QCDHT_cutflow_weighted()
{
//=========Macro generated from canvas: c1/c1
//========= (Wed Feb 24 17:48:49 2016) by ROOT version6.02/05
TCanvas *c1 = new TCanvas("c1", "c1",65,52,700,500);
c1->Range(-1.25,-2351156,16.25,2.11604e+07);
c1->SetFillColor(0);
c1->SetBorderMode(0);
c1->SetBorderSize(2);
c1->SetFrameBorderMode(0);
c1->SetFrameBorderMode(0);
TH1D *cutflow1 = new TH1D("cutflow1","cut flow",14,0.5,14.5);
cutflow1->SetBinContent(1,1.791357e+07);
cutflow1->SetBinContent(2,1.791357e+07);
cutflow1->SetBinContent(3,1.482016e+07);
cutflow1->SetBinContent(4,1.397007e+07);
cutflow1->SetBinContent(5,8159947);
cutflow1->SetBinContent(6,1368453);
cutflow1->SetBinContent(7,12035.83);
cutflow1->SetBinContent(8,10653.79);
cutflow1->SetBinContent(9,4100.401);
cutflow1->SetBinContent(10,4323.004);
cutflow1->SetBinContent(11,1820.803);
cutflow1->SetBinContent(12,374.2397);
cutflow1->SetBinContent(13,35.33991);
cutflow1->SetBinContent(14,214.6597);
cutflow1->SetEntries(1.137194e+08);
TPaveStats *ptstats = new TPaveStats(0.78,0.775,0.98,0.935,"brNDC");
ptstats->SetName("stats");
ptstats->SetBorderSize(1);
ptstats->SetFillColor(0);
ptstats->SetTextAlign(12);
ptstats->SetTextFont(42);
TText *AText = ptstats->AddText("cutflow");
AText->SetTextSize(0.0368);
AText = ptstats->AddText("Entries = 1.137194e+08");
AText = ptstats->AddText("Mean = 0");
AText = ptstats->AddText("RMS = 0");
ptstats->SetOptStat(1111);
ptstats->SetOptFit(0);
ptstats->Draw();
cutflow1->GetListOfFunctions()->Add(ptstats);
ptstats->SetParent(cutflow1);
Int_t ci; // for color index setting
TColor *color; // for color definition with alpha
ci = TColor::GetColor("#000099");
cutflow1->SetLineColor(ci);
cutflow1->GetXaxis()->SetBinLabel(1,"All");
cutflow1->GetXaxis()->SetBinLabel(2,"Trigger");
cutflow1->GetXaxis()->SetBinLabel(3,"p_{T}");
cutflow1->GetXaxis()->SetBinLabel(4,"|#eta|");
cutflow1->GetXaxis()->SetBinLabel(5,"|#Delta#eta|");
cutflow1->GetXaxis()->SetBinLabel(6,"M(jet_{0},jet(1))");
cutflow1->GetXaxis()->SetBinLabel(7,"M(jets)");
cutflow1->GetXaxis()->SetBinLabel(8,"#tau_{21}");
cutflow1->GetXaxis()->SetBinLabel(9,"0b");
cutflow1->GetXaxis()->SetBinLabel(10,"1b");
cutflow1->GetXaxis()->SetBinLabel(11,"2b");
cutflow1->GetXaxis()->SetBinLabel(12,"3b");
cutflow1->GetXaxis()->SetBinLabel(13,"4b");
cutflow1->GetXaxis()->SetBinLabel(14,"3b+HPHP");
cutflow1->GetXaxis()->SetLabelFont(42);
cutflow1->GetXaxis()->SetLabelSize(0.035);
cutflow1->GetXaxis()->SetTitleSize(0.035);
cutflow1->GetXaxis()->SetTitleFont(42);
cutflow1->GetYaxis()->SetLabelFont(42);
cutflow1->GetYaxis()->SetLabelSize(0.035);
cutflow1->GetYaxis()->SetTitleSize(0.035);
cutflow1->GetYaxis()->SetTitleFont(42);
cutflow1->GetZaxis()->SetLabelFont(42);
cutflow1->GetZaxis()->SetLabelSize(0.035);
cutflow1->GetZaxis()->SetTitleSize(0.035);
cutflow1->GetZaxis()->SetTitleFont(42);
cutflow1->Draw("");
TPaveText *pt = new TPaveText(0.4246264,0.94,0.5753736,0.995,"blNDC");
pt->SetName("title");
pt->SetBorderSize(0);
pt->SetFillColor(0);
pt->SetFillStyle(0);
pt->SetTextFont(42);
AText = pt->AddText("cut flow");
pt->Draw();
c1->Modified();
c1->cd();
c1->SetSelected(c1);
}
示例13: readMCPerform
//.........这里部分代码省略.........
TLegend *leg3 = new TLegend(0.2, 0.7, 0.4, 0.9);
leg3->AddEntry(fHistNCandDzero, "Dzero", "l");
leg3->AddEntry(fHistNCandDplus, "Dplus", "l");
if (drawOnlyDzerDplus == 0)
leg3->AddEntry(fHistNCandDstar, "Dstar", "l");
if (drawOnlyDzerDplus == 0)
leg3->AddEntry(fHistNCandDs, "Ds", "l");
if (drawOnlyDzerDplus == 0)
leg3->AddEntry(fHistNCandLc, "Lc", "l");
TLegend *leg4 = new TLegend(0.7, 0.7, 0.9, 0.9);
leg4->AddEntry(fHistNCandDzero, "Dzero", "l");
leg4->AddEntry(fHistNCandDplus, "Dplus", "l");
if (drawOnlyDzerDplus == 0)
leg4->AddEntry(fHistNCandDstar, "Dstar", "l");
if (drawOnlyDzerDplus == 0)
leg4->AddEntry(fHistNCandDs, "Ds", "l");
if (drawOnlyDzerDplus == 0)
leg4->AddEntry(fHistNCandLc, "Lc", "l");
TCanvas *c0_1 = new TCanvas("c0_1", "c0_1", 500, 500);
hnGenD->SetTitle("number of generated D mesons");
hnGenD->Draw();
c0_1->SaveAs("plotDgen.png");
TCanvas *c0_2 = new TCanvas("c0_2", "c0_2", 500, 500);
c0_2->SetLogy();
fHistNCandDs->SetTitle("Candidates passing filtering cuts");
fHistNCandDs->Draw("");
c0_2->Update();
TPaveStats *stats = (TPaveStats *)c0_2->GetPrimitive("stats");
stats->SetName("h1stats");
stats->SetY1NDC(0.5);
stats->SetY2NDC(0.35);
c0_2->Update();
fHistNCandDplus->Draw("sames");
c0_2->Update();
TPaveStats *stats2 = (TPaveStats *)c0_2->GetPrimitive("stats");
stats2->SetName("h2stats");
stats2->SetY1NDC(0.8);
stats2->SetY2NDC(.65);
c0_2->Update();
fHistNCandDstar->Draw("sames");
c0_2->Update();
TPaveStats *stats3 = (TPaveStats *)c0_2->GetPrimitive("stats");
stats3->SetName("h3stats");
stats3->SetY1NDC(0.65);
stats3->SetY2NDC(.5);
c0_2->Update();
fHistNCandDzero->Draw("sames");
c0_2->Update();
TPaveStats *stats4 = (TPaveStats *)c0_2->GetPrimitive("stats");
stats4->SetName("h4stats");
stats4->SetY1NDC(0.95);
stats4->SetY2NDC(.8);
c0_2->Update();
fHistNCandLc->Draw("sames");
c0_2->Update();
TPaveStats *stats5 = (TPaveStats *)c0_2->GetPrimitive("stats");
stats5->SetName("h1stats");
示例14: x_dist_cuts
//.........这里部分代码省略.........
hist__1->SetBinContent(52,13155);
hist__1->SetBinContent(53,10318);
hist__1->SetBinContent(54,7953);
hist__1->SetBinContent(55,6143);
hist__1->SetBinContent(56,4420);
hist__1->SetBinContent(57,3422);
hist__1->SetBinContent(58,2687);
hist__1->SetBinContent(59,2027);
hist__1->SetBinContent(60,1643);
hist__1->SetBinContent(61,1359);
hist__1->SetBinContent(62,1189);
hist__1->SetBinContent(63,1057);
hist__1->SetBinContent(64,929);
hist__1->SetBinContent(65,840);
hist__1->SetBinContent(66,792);
hist__1->SetBinContent(67,759);
hist__1->SetBinContent(68,719);
hist__1->SetBinContent(69,673);
hist__1->SetBinContent(70,702);
hist__1->SetBinContent(71,769);
hist__1->SetBinContent(72,693);
hist__1->SetBinContent(73,728);
hist__1->SetBinContent(74,719);
hist__1->SetBinContent(75,698);
hist__1->SetBinContent(76,729);
hist__1->SetBinContent(77,695);
hist__1->SetBinContent(78,732);
hist__1->SetBinContent(79,692);
hist__1->SetBinContent(80,620);
hist__1->SetBinContent(81,592);
hist__1->SetBinContent(82,525);
hist__1->SetBinContent(83,463);
hist__1->SetBinContent(84,407);
hist__1->SetBinContent(85,357);
hist__1->SetBinContent(86,300);
hist__1->SetBinContent(87,229);
hist__1->SetBinContent(88,192);
hist__1->SetBinContent(89,154);
hist__1->SetBinContent(90,113);
hist__1->SetBinContent(91,123);
hist__1->SetBinContent(92,73);
hist__1->SetBinContent(93,55);
hist__1->SetBinContent(94,41);
hist__1->SetBinContent(95,27);
hist__1->SetBinContent(96,27);
hist__1->SetBinContent(97,18);
hist__1->SetBinContent(98,14);
hist__1->SetBinContent(99,8);
hist__1->SetBinContent(100,11);
hist__1->SetBinContent(101,55);
hist__1->SetEntries(173117);
TPaveStats *ptstats = new TPaveStats(0.78,0.775,0.98,0.935,"brNDC");
ptstats->SetName("stats");
ptstats->SetBorderSize(1);
ptstats->SetFillColor(0);
ptstats->SetTextAlign(12);
ptstats->SetTextFont(42);
TText *AText = ptstats->AddText("hist");
AText->SetTextSize(0.0368);
AText = ptstats->AddText("Entries = 173117 ");
AText = ptstats->AddText("Mean = 0.6933");
AText = ptstats->AddText("Std Dev = 34.33");
ptstats->SetOptStat(1111);
ptstats->SetOptFit(0);
ptstats->Draw();
hist__1->GetListOfFunctions()->Add(ptstats);
ptstats->SetParent(hist__1);
Int_t ci; // for color index setting
TColor *color; // for color definition with alpha
ci = TColor::GetColor("#000099");
hist__1->SetLineColor(ci);
hist__1->GetXaxis()->SetTitle("#DeltaZ [cm]");
hist__1->GetXaxis()->SetLabelFont(42);
hist__1->GetXaxis()->SetLabelSize(0.035);
hist__1->GetXaxis()->SetTitleSize(0.035);
hist__1->GetXaxis()->SetTitleFont(42);
hist__1->GetYaxis()->SetLabelFont(42);
hist__1->GetYaxis()->SetLabelSize(0.035);
hist__1->GetYaxis()->SetTitleSize(0.035);
hist__1->GetYaxis()->SetTitleFont(42);
hist__1->GetZaxis()->SetLabelFont(42);
hist__1->GetZaxis()->SetLabelSize(0.035);
hist__1->GetZaxis()->SetTitleSize(0.035);
hist__1->GetZaxis()->SetTitleFont(42);
hist__1->Draw("");
TPaveText *pt = new TPaveText(0.3779599,0.9368947,0.6220401,0.995,"blNDC");
pt->SetName("title");
pt->SetBorderSize(0);
pt->SetFillColor(0);
pt->SetFillStyle(0);
pt->SetTextFont(42);
AText = pt->AddText("Worry Later");
pt->Draw();
c->Modified();
c->cd();
c->SetSelected(c);
}
示例15: CompHist
void CompHist(TH1 *h1, TH1 *href, int run1, int runref) {
if (!h1 || !href || h1->Integral()==0 || href->Integral()==0) return;
// first check if both histograms are compatible
Stat_t s[TH1F::kNstat];
h1->GetStats(s);// s[1] sum of squares of weights, s[0] sum of weights
Double_t sumBinContent1 = s[0];
Double_t effEntries1 = (s[1] ? s[0] * s[0] / s[1] : 0.0);
href->GetStats(s);// s[1] sum of squares of weights, s[0] sum of weights
Double_t sumBinContent2 = s[0];
Double_t effEntries2 = (s[1] ? s[0] * s[0] / s[1] : 0.0);
float pval_chi2=1, pval_ks=1,pval_ad=1;
bool iswt = (sumBinContent1==0 || effEntries1==0 || sumBinContent2==0 || effEntries2==0 || TMath::Abs(sumBinContent1 - effEntries1) != 0 || TMath::Abs(sumBinContent2 - effEntries2) != 0);
if (iswt) {
// weighted histograms
pval_chi2 = h1->Chi2Test(href,"WW");
// pval_ks = h1->KolmogorovTest(href);
} else {
// unweighted histograms
pval_ks = h1->KolmogorovTest(href);
pval_ad = h1->AndersonDarlingTest(href);
// double int1 = h1->Integral();
// double intref = href->Integral();
// if (int1==0 || intref==0) return;
// h1->Scale(1./int1);
// href->Scale(1./intref);
// pval_chi2 = h1->Chi2Test(href,"NORM UU");
}
if (pval_chi2>minpval && pval_ks>minpval) return;
// looks like we have a discrepancy! let's plot the histograms and print the output
cout << h1->GetTitle() << ": p-val(chi2) = " << pval_chi2 << ", p-val(KS) = " << pval_ks << ", pval_ad = " << pval_ad << endl;
TCanvas *c1 = new TCanvas();
href->SetLineColor(kRed);
href->SetMarkerColor(kRed);
if (!iswt) href->DrawNormalized();
else href->Draw();
c1->Update();
// Retrieve the stat box
TPaveStats *ps = (TPaveStats*)c1->GetPrimitive("stats");
ps->SetName("statsref");
ps->SetTextColor(kRed);
ps->SetX1NDC(0.8);
ps->SetX2NDC(1.);
ps->SetY1NDC(0.6);
ps->SetY2NDC(0.8);
h1->SetLineColor(kBlack);
h1->SetMarkerColor(kBlack);
if (!iswt) h1->DrawNormalized("sames");
else h1->Draw("sames");
c1->Update();
TPaveStats *psref = (TPaveStats*)c1->GetPrimitive("stats");
psref->SetName("stats1");
psref->SetX1NDC(0.8);
psref->SetX2NDC(1.);
psref->SetY1NDC(0.8);
psref->SetY2NDC(1.);
c1->Modified();
c1->Update();
TLatex *txt = new TLatex();
if (!iswt) txt->DrawLatexNDC(0.02,0.02,Form("p(KS) = %f, p(AD) = %f",pval_ks,pval_ad));
else txt->DrawLatexNDC(0.02,0.02,Form("p(#chi^{2}) = %f",pval_chi2));
c1->SaveAs(Form("%s_%i_%i.png",h1->GetName(),run1,runref));
delete c1;
}