本文整理汇总了C++中TH1D::SetLabelSize方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1D::SetLabelSize方法的具体用法?C++ TH1D::SetLabelSize怎么用?C++ TH1D::SetLabelSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1D
的用法示例。
在下文中一共展示了TH1D::SetLabelSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strcpy
plotClasses(const char* canvas, const char* title,
int nClasses, const char classes[][200],
const int* events, const double* weights)
{
char evtitle[200], wttitle[200];
strcpy(evtitle,title);
strcpy(wttitle,title);
strcat(evtitle,": Events");
strcat(wttitle,": Weights");
TCanvas *c
= new TCanvas(canvas,"SPR Input Classes",200,10,600,400);
gStyle->SetPalette(1);
int maxEv = TMath::MaxElement(nClasses,events);
double maxWt = TMath::MaxElement(nClasses,weights);
TPad* pad1 = new TPad("events", evtitle,0,0,1.,0.5);
TPad* pad2 = new TPad("weights",wttitle,0,0.5,1.,1.);
pad1->Draw();
pad2->Draw();
// events
pad1->cd();
TH1I* hev = new TH1I("events",evtitle,nClasses,0,nClasses);
for( int i=0;i<nClasses;i++ )
hev->Fill(classes[i],events[i]);
hev->LabelsDeflate("X");
hev->SetLabelSize(0.06,"X");
hev->SetLabelSize(0.1,"X");
hev->SetLabelSize(0.1,"Y");
hev->SetLineColor(4);
hev->SetFillColor(4);
hev->SetBarWidth(0.8);
hev->SetBarOffset(0.1);
TAxis* yaxis1 = hev->GetYaxis();
yaxis1->SetRangeUser(0.,1.1*maxEv);
hev->Draw("B");
// weights
pad2->cd();
TH1D* hwt = new TH1D("weights",wttitle,nClasses,0,nClasses);
for( int i=0;i<nClasses;i++ )
hwt->Fill(classes[i],weights[i]);
hwt->LabelsDeflate("X");
hwt->SetLabelSize(0.06,"X");
hwt->SetLabelSize(0.1,"X");
hwt->SetLabelSize(0.1,"Y");
hwt->SetLineColor(3);
hwt->SetFillColor(3);
hwt->SetBarWidth(0.8);
hwt->SetBarOffset(0.1);
TAxis* yaxis2 = hwt->GetYaxis();
yaxis2->SetRangeUser(0.,1.1*maxWt);
hwt->Draw("B");
}
示例2: slopevscentrality
//.........这里部分代码省略.........
double star_sysplus[] = { 3.152323796820371, 1.1348034014753392, 0.6881948851887814, 0.3091, 0.3775553601791398, 0.6362180836788593, 0.39244649316817704, 1.060086081410373, 4.931994052105091 };
double xsysstar[] = {1,1,1,1,1,1,1,1,1};
for(i=0;i<9;i++){
star_sysminus[i]/=100;
star_sysplus[i]/=100;
}
gStyle->SetLegendFont(42);
TGraphErrors* slopevscent = new TGraphErrors(6,x_centrality,y_slope,NULL,statErr);
TGraphErrors* ALICE = new TGraphErrors(8,x_alice,y_alice,NULL,alice_statErrors);
TGraphErrors* STAR = new TGraphErrors(9,x_star,y_star,NULL,star_statErrors);
TGraphAsymmErrors* ALICE_sys = new TGraphAsymmErrors(8, x_alice, y_alice, xsysalice, xsysalice, alice_sysminus, alice_sysplus);
TGraphAsymmErrors* STAR_sys = new TGraphAsymmErrors(9, x_star, y_star, xsysstar, xsysstar, star_sysminus, star_sysplus);
slopevscent -> SetMarkerStyle(20);
slopevscent -> SetMarkerColor(kBlack);
ALICE -> SetMarkerStyle(25);
ALICE -> SetMarkerColor(kRed);
ALICE -> SetLineColor(kRed);
STAR -> SetMarkerStyle(kOpenStar);
STAR -> SetMarkerColor(kBlue);
STAR -> SetLineColor(kBlue);
TH1D* base = new TH1D("base","base",1,0,100);
base->GetYaxis()->SetRangeUser(0.00,0.06);
base->GetXaxis()->SetTitle("Centrality(%)");
base->GetYaxis()->SetTitle("Slope parameter(v_{2})");
base->GetXaxis()->CenterTitle();
base->GetYaxis()->CenterTitle();
base->SetTitleSize (0.040,"X");
base->SetTitleOffset(1.4,"X");
base->SetTitleFont (42,"X");
base->SetLabelOffset(0.006,"X");
base->SetLabelSize (0.040,"X");
base->SetLabelFont (42 ,"X");
base->SetTitleSize (0.040,"Y");
base->SetTitleOffset(2.2,"Y");
base->SetTitleFont (42,"Y");
base->SetLabelOffset(0.006,"Y");
base->SetLabelSize (0.040,"Y");
base->SetLabelFont (42 ,"Y");
base->SetLineWidth(0);
TCanvas* c3 = MakeCanvas("c3","c3");
TLatex* text_a = makeLatex("CMS pPb #sqrt{s_{NN}}=5.02TeV",0.25,0.85) ;
TLatex* text_b = makeLatex("185 #leq N_{trk}^{offline} < 260",0.25,0.80) ;
TLatex* text_c = makeLatex("0.3 < p_{T} < 3 GeV/c",0.25,0.85) ;
TLatex* text_d = makeLatex("|#Delta#eta| > 2",0.25,0.80) ;
text_a->SetTextFont(42);
text_b->SetTextFont(42);
text_c->SetTextFont(42);
text_d->SetTextFont(42);
slopevscent->SetFillStyle(0);
slopevscent->SetFillColor(0);
slopevscent->SetFillStyle(0);
slopevscent->SetFillColor(0);
gStyle->SetOptTitle(0);
TLegend* leg = new TLegend(.58,.70,.93,.90);
leg->SetLineColor(kWhite);
leg->SetFillColor(0);
leg->SetFillStyle(0);
leg->AddEntry(slopevscent, "CMS, Pb-Pb 5.02TeV","p");
leg->AddEntry(ALICE, "ALICE, Pb-Pb 2.76TeV","p");
leg->AddEntry(STAR, "STAR, Au-Au 200GeV","p");
//leg->AddEntry(gr_neg, "neg","p");
c3->cd();
base->Draw("");
ALICE->Draw("PSame");
STAR->Draw("PSame");
slopevscent->Draw("PSame");
// STAR_sys->Draw("2Same");
leg->DrawClone("PSame");
// text_c->DrawClone("Same");
// text_d->DrawClone("Same");
//Define a linear function
//SaveCanvas(c3,"pics","slopevscent_comparison");
}
示例3: DrawComparison
TCanvas* DrawComparison(TH1D* prediction, TH1D* selection, TString Title, TString LumiTitle, TString xTitle, bool isData)
{
double MinX = selection->GetXaxis()->GetXmin();
double MaxX = selection->GetXaxis()->GetXmax();
double MaxY = selection->GetMaximum();
double YRangeMax = MaxY;
TString titlePrediction;
TString titleSelection;
TString RatioTitle;
if( isData ){
titlePrediction = "Data";
titleSelection = "MC";
RatioTitle = "(Data-MC)/MC";
}
else {
titlePrediction = "Data-driven Pred. from MC";
titleSelection = "MC Expectation";
RatioTitle = "(Pred-MC)/MC";
}
//static Int_t c_LightBrown = TColor::GetColor( "#D9D9CC" );
static Int_t c_LightGray = TColor::GetColor( "#DDDDDD" );
prediction->SetAxisRange(MinX, MaxX, "X");
prediction->GetYaxis()->SetRangeUser(0.005, YRangeMax);
prediction->SetMarkerStyle(20);
prediction->SetMarkerSize(0.9);
prediction->SetMarkerColor(kBlack);
prediction->SetXTitle(xTitle);
prediction->SetYTitle("Events");
selection->SetAxisRange(MinX, MaxX, "X");
selection->GetYaxis()->SetRangeUser(0.05, YRangeMax);
// selection->SetFillColor(c_LightBrown);
selection->SetFillColor(c_LightGray);
selection->SetTitle("");
selection->SetXTitle(xTitle);
selection->SetYTitle("Events");
TCanvas *c = new TCanvas("ca", "Comparison and ratio of two histos", 700, 700);
TPad *pad1 = new TPad("pad1a", "pad1a", 0, 0.35, 1, 1);
//pad1->SetLogy();
pad1->SetBottomMargin(0);
pad1->Draw();
pad1->cd();
selection->DrawCopy("hist");
prediction->Draw("same");
selection->SetFillColor(kAzure-3);
selection->SetFillStyle(3354);
selection->DrawCopy("e2same");
selection->SetFillStyle(1001);
// selection->SetFillColor(c_LightBrown);
selection->SetFillColor(c_LightGray);
TLegend* leg1 = new TLegend(0.48, 0.63, 0.95, 0.83);
leg1->SetFillStyle(0);
leg1->SetLineStyle(1);
leg1->SetTextFont(42);
leg1->SetTextSize(0.04);
leg1->AddEntry(selection, titleSelection, "lf");
leg1->AddEntry(prediction, titlePrediction, "lep");
leg1->Draw("same");
TPaveText* pt = new TPaveText(0.11, 0.98, 0.95, 0.86, "NDC");
pt->SetBorderSize(0);
pt->SetFillStyle(0);
pt->SetTextAlign(12);
pt->SetTextSize(0.045);
pt->AddText(Title);
pt->AddText(LumiTitle);
pt->Draw();
c->cd();
TPad *pad2 = new TPad("pad2a", "pad2a", 0, 0, 1, 0.35);
pad2->SetTopMargin(0);
pad2->Draw();
pad2->cd();
TH1D* r = new TH1D(*selection);
r->SetTitle("");
r->SetLabelSize(0.08, "XYZ");
r->SetLabelOffset(0.01, "XYZ");
r->SetTitleSize(0.09, "XYZ");
r->SetTitleOffset(0.65, "Y");
r->SetTickLength(0.05);
r->SetYTitle(RatioTitle);
r->SetStats(0);
r->SetMarkerStyle(20);
r->SetMarkerSize(0.9);
r->SetMarkerColor(kBlack);
r->Reset();
r->Add(prediction, 1);
r->Add(selection, -1);
r->Divide(selection);
r->SetMaximum(1.2);
r->SetMinimum(-1.2);
r->Draw("ep");
TLine l;
l.DrawLine(MinX, 0., MaxX, 0.);
c->cd();
return c;
}
示例4: ratioCutFlowPlot
void CutFlow::ratioCutFlowPlot(TH1D* data, THStack *hs, AllSamples samples, Variable variable){
//draw histos with ratio plot
float r = 0.3;
float epsilon = 0.02;
TCanvas *c2 = new TCanvas("Plot","Plot",635, 600);
c2->SetFillColor(0);
c2->SetFrameFillStyle(0);
TPad *pad1 = new TPad("pad1","pad1",0,r-epsilon,1,1);
pad1->SetBottomMargin(epsilon);
c2->cd();
pad1->Draw();
pad1->cd();
hs->Draw("hist");
hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.3);
hs->GetXaxis()->SetLimits(variable.minX, variable.maxX);
hs->GetXaxis()->SetTitle(variable.xTitle); hs->GetXaxis()->SetTitleSize(0.05);
hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05);
if(Globals::addHashErrors){
TH1D* hashErrs = hashErrors(samples, variable);
hashErrs->Draw("same e2");
}
data->Draw("E same");
//data->SetMarkerStyle(20);
data->SetMarkerSize(0.5);
TLegend* leg = legend(samples);
leg->Draw();
TText* textChan = doChan(0.12,0.96);
textChan->Draw();
TText* textPrelim = doPrelim(0.58,0.96);
textPrelim->Draw();
TPad *pad2 = new TPad("pad2","pad2",0,0,1,r*(1-epsilon));
pad2->SetTopMargin(0);
pad2->SetFrameFillStyle(4000);
pad2->SetBottomMargin(0.4);
c2->cd();
pad2->Draw();
pad2->cd();
TH1D * allMC = allMChisto(samples, variable);
TH1D * ratio = (TH1D*)data->Clone("ratio plot");
ratio->Sumw2();
ratio->SetStats(0);
cout << "ratio bins: " << ratio->GetNbinsX() << endl;
cout << "all mc bins: " << allMC->GetNbinsX() << endl;
ratio->Divide(allMC);
ratio->SetMaximum(2);
ratio->SetMinimum(0.);
setBinLabels(hs, ratio);
// Will need to see if this works in other situations
ratio->SetLabelSize(0.1, "X");
ratio->SetTitleOffset(0.5, "Y");
ratio->SetTitleOffset(0.8, "X");
ratio->GetYaxis()->SetTitle("data/MC");ratio->GetYaxis()->SetTitleSize(0.1);
ratio->GetXaxis()->SetTitle(variable.xTitle);ratio->GetXaxis()->SetTitleSize(0.15);
ratio->Draw("ep");
TLine *line = new TLine(variable.minX,1,variable.maxX,1);
line->Draw();
pad1->cd();
pad1->SetLogy();
c2->SaveAs("Plots/ControlPlots/"+objName+"/Log/"+variable.name+"_ratio.png");
c2->SaveAs("Plots/ControlPlots/"+objName+"/Log/"+variable.name+"_ratio.pdf");
delete c2;
delete leg;
delete textChan;
delete textPrelim;
}
示例5: figure2_0_generator
//.........这里部分代码省略.........
sum = v2_pos[i] + v2_neg[i];
variance_diff = (4*v2_neg[i]*v2_neg[i]*variance_pos)/(sum*sum*sum*sum)+(4*v2_pos[i]*v2_pos[i]*variance_neg)/(sum*sum*sum*sum);
//error bars
cout << "xcoord " << x[i] << endl;
err_pos[i] = sqrt(variance_pos);
err_neg[i] = sqrt(variance_neg);
err_diff[i] = sqrt(variance_diff);
}
gStyle->SetLegendFont(42);
TH1D* base = new TH1D("base","base",1,-0.15,0.15);
//pPb
//base->GetYaxis()->SetRangeUser(0.065, 0.075);
base->GetYaxis()->SetRangeUser(0.065, 0.075);
//PbPb
//base->GetYaxis()->SetRangeUser(0.093, 0.103);
base->GetXaxis()->SetTitle("Observed A_{ch}");
base->GetYaxis()->SetTitle("v_{2}{2}");
base->GetXaxis()->CenterTitle();
base->GetYaxis()->CenterTitle();
base->SetTitleSize (0.040,"X");
base->SetTitleOffset(1.4,"X");
base->SetTitleFont (42,"X");
base->SetLabelOffset(0.006,"X");
base->SetLabelSize (0.040,"X");
base->SetLabelFont (42 ,"X");
base->SetTitleSize (0.040,"Y");
base->SetTitleOffset(2.2,"Y");
base->SetTitleFont (42,"Y");
base->SetLabelOffset(0.006,"Y");
base->SetLabelSize (0.040,"Y");
base->SetLabelFont (42 ,"Y");
base->SetLineWidth(0);
TH1D* base2 = new TH1D("base2","base2",1,-0.15,0.15);
base2->GetYaxis()->SetRangeUser(-0.03, 0.03);
base2->GetXaxis()->SetTitle("Observed A_{ch}");
base2->GetYaxis()->SetTitle(" (v^{#minus}_{2} #minus v^{#plus}_{2})/(v^{#minus}_{2} #plus v^{#plus}_{2}) ");
base2->GetXaxis()->CenterTitle();
base2->GetYaxis()->CenterTitle();
base2->SetTitleSize (0.040,"X");
base2->SetTitleOffset(1.4,"X");
base2->SetTitleFont (42,"X");
base2->SetLabelOffset(0.006,"X");
base2->SetLabelSize (0.040,"X");
base2->SetLabelFont (42 ,"X");
base2->SetTitleSize (0.040,"Y");
base2->SetTitleOffset(2.0,"Y");
base2->SetTitleFont (42,"Y");
base2->SetLabelOffset(0.006,"Y");
base2->SetLabelSize (0.040,"Y");
base2->SetLabelFont (42 ,"Y");
base2->SetLineWidth(0);
TFile *rebinned = new TFile("~/Summer2016/root_forgraphs/figure2_0.root","RECREATE");
示例6: TCanvas
//################################################################################################################################
TCanvas *drawRatioPlotWithPurity(TH1D *prediction, TH1D *sr, TString xTitle, TString filename, double purity, bool LowECaloRegion){
TCanvas *c = new TCanvas("c"+filename,"c",0,0,500,500);
c->cd();
float y = 0.3;
TPad *pad1 = new TPad("pad1", "Control Plots 1", 0.01, y, 0.99, 0.99);
TPad *padRatio = new TPad("rp1", "Ratio1", 0.01, 0.01, 0.99, y-0.01);
TH1D *ratio = 0;
ratio = (TH1D*) sr->Clone();
ratio->Divide(prediction);
ratio->GetYaxis()->SetTitle((TString) sr->GetName() + "/" + (TString) prediction->GetName());
ratio->SetTitle("");
ratio->SetLabelSize(0.1,"X");
ratio->SetLabelSize(0.1,"Y");
ratio->SetTitleOffset(0.5,"Y");
ratio->SetTitleSize(0.11,"Y");
ratio->SetLineColor(kBlack);
ratio->SetMarkerColor(kBlack);
padRatio->cd();
ratio->GetYaxis()->SetRangeUser(0,2);
ratio->Draw();
// Draw line at one!
float xmin = ratio->GetXaxis()->GetXmin();
float xmax = ratio->GetXaxis()->GetXmax();
TLine *line = new TLine(xmin,1,xmax,1);
line->SetLineWidth(2);
line->Draw("same");
padRatio->Modified();
TLegend *leg = new TLegend(0.5,0.8,0.85,0.9);
leg->AddEntry(sr,sr->GetName(),"l");
leg->AddEntry(prediction,prediction->GetName(),"pel");
pad1->cd();
//pad1->SetLogy();
sr->SetLineColor(kRed);
sr->SetMarkerColor(kRed);
prediction->SetLineColor(kBlack);
prediction->SetMarkerColor(kBlack);
sr->SetTitle("");
prediction->SetTitle("");
prediction->GetXaxis()->SetTitle(xTitle);
sr->GetXaxis()->SetTitle(xTitle);
prediction->SetTitleSize(0.07,"X");
prediction->GetXaxis()->SetTitleOffset(0.7);
sr->SetTitleSize(0.07,"X");
sr->GetXaxis()->SetTitleOffset(0.7);
prediction->Draw("e");
sr->Draw("e same");
double maximum =prediction->GetMaximum()*1.2;
double minimum = 0.00001;
if(sr->GetMinimum()!=0) minimum=sr->GetMinimum()*0.9;
if(prediction->GetMinimum()!=0) minimum=prediction->GetMinimum()*0.9;
if(sr->GetMaximum()>prediction->GetMaximum()){
maximum=sr->GetMaximum()*1.2;
}
//leg->Draw("same");
//***********************
TLatex* info = new TLatex();
info->SetTextFont(132);
info-> SetNDC();
info->SetTextSize(0.06);
TString AuxString = Form("Purity of fakes in CR = %4.1f ",purity*100);
//info->DrawLatex(0.4,0.7,AuxString);
TLatex* info1 = new TLatex();
info1->SetTextFont(132);
info1-> SetNDC();
info1->SetTextSize(0.06);
if(LowECaloRegion) AuxString = "E_{calo}<10GeV";
else AuxString = "E_{calo}>10GeV";
//info1->DrawLatex(0.2,0.82,AuxString);
//***********************
// Draw both pads to canvas
c->cd();
pad1->Draw();
padRatio->SetGridy();
c -> SetBottomMargin(0.55);
//c->Modified();
padRatio->Draw();
c->SaveAs(filename);
//.........这里部分代码省略.........
开发者ID:telenz,项目名称:HighDeDx-DisappTrks-PostProcessing-ExclusiveBins,代码行数:101,代码来源:a1_fakeRatesFromData.C
示例7: figure2_0_generate
//.........这里部分代码省略.........
gr_diff->Write();
/*
gr_pos->RemovePoint(0);
gr_pos->RemovePoint(5);
gr_neg->RemovePoint(0);
gr_neg->RemovePoint(5);
gr_diff->RemovePoint(0);
gr_diff->RemovePoint(5);
*/
gStyle->SetLegendFont(42);
TH1D* base = new TH1D("base","base",1,-0.20,0.20);
//pPb
//base->GetYaxis()->SetRangeUser(0.065, 0.075);
base->GetYaxis()->SetRangeUser(0.06, 0.12);
//PbPb
//base->GetYaxis()->SetRangeUser(0.093, 0.103);
base->GetXaxis()->SetTitle("Observed A_{ch}");
base->GetYaxis()->SetTitle("v_{2}{2}");
base->GetXaxis()->CenterTitle();
base->GetYaxis()->CenterTitle();
base->SetTitleSize (0.040,"X");
base->SetTitleOffset(1.4,"X");
base->SetTitleFont (42,"X");
base->SetLabelOffset(0.006,"X");
base->SetLabelSize (0.040,"X");
base->SetLabelFont (42 ,"X");
base->SetTitleSize (0.040,"Y");
base->SetTitleOffset(2.2,"Y");
base->SetTitleFont (42,"Y");
base->SetLabelOffset(0.006,"Y");
base->SetLabelSize (0.040,"Y");
base->SetLabelFont (42 ,"Y");
base->SetLineWidth(0);
TH1D* base2 = new TH1D("base2","base2",1,-0.2,0.2);
base2->GetYaxis()->SetRangeUser(-0.03, 0.03);
base2->GetXaxis()->SetTitle("Observed A_{ch}");
base2->GetYaxis()->SetTitle(" (v^{#minus}_{2} #minus v^{#plus}_{2})/(v^{#minus}_{2} #plus v^{#plus}_{2}) ");
base2->GetXaxis()->CenterTitle();
base2->GetYaxis()->CenterTitle();
base2->SetTitleSize (0.040,"X");
base2->SetTitleOffset(1.4,"X");
base2->SetTitleFont (42,"X");
base2->SetLabelOffset(0.006,"X");
base2->SetLabelSize (0.040,"X");
base2->SetLabelFont (42 ,"X");
base2->SetTitleSize (0.040,"Y");
base2->SetTitleOffset(2.0,"Y");
base2->SetTitleFont (42,"Y");
base2->SetLabelOffset(0.006,"Y");
base2->SetLabelSize (0.040,"Y");
base2->SetLabelFont (42 ,"Y");
base2->SetLineWidth(0);
示例8: doControlPlotsMET
//.........这里部分代码省略.........
data->Draw("E same");
data->SetMarkerStyle(20);
hs->GetXaxis()->SetLimits(MinX, MaxX);
hs->GetXaxis()->SetTitle(Xtitle); hs->GetXaxis()->SetTitleSize(0.05);
hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05);
TLegend *tleg2;
tleg2 = new TLegend(0.7, 0.6, 0.8, 0.9);
tleg2->SetTextSize(0.04);
tleg2->SetBorderSize(0);
tleg2->SetFillColor(10);
tleg2->AddEntry(data , "2012 data", "lpe");
tleg2->AddEntry(ttgamma , "t#bar{t}#gamma", "lf");
if(inclTop == false){
tleg2->AddEntry(tt_sig , "t#bar{t}#gamma (MG)", "lf");
tleg2->AddEntry(tt_lep , "t#bar{t} l #rightarrow #gamma (MG)", "lf");
tleg2->AddEntry(tt , "t#bar{t} fake (MG)", "lf");
}else{
tleg2->AddEntry(tt , "t#bar{t}", "lf");
}
tleg2->AddEntry(T_tW, "Single Top" , "lf");
// tleg2->AddEntry(Tbar_tW, "anti-single-tW" , "lf");
tleg2->AddEntry(DY1 , "Z+Jets", "lf");
// tleg2->AddEntry(DY2 , "DYJetsToLL", "lf");
tleg2->AddEntry(ZZ, "Diboson", "lf");
// tleg2->AddEntry(WW, "WW", "lf");
// tleg2->AddEntry(WZ , "WZ", "lf");
tleg2->AddEntry(wjets , "W+Jets", "lf");
tleg2->AddEntry(QCD_all, "QCD", "lf");
tleg2->Draw("same");
TText* textPrelim = doPrelim(0.20, 0.96, Cut, Obj);
textPrelim->Draw();
c1->cd();
if(logPlot == true){
c1->SetLogy();
}
TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.3);
pad2->SetTopMargin(0);
pad2->SetBottomMargin(0.4);
pad2->Draw();
pad2->cd();
TH1D * ratio = (TH1D*)data->Clone("ratio plot");
//ratio->Sumw2();
ratio->SetStats(0);
ratio->Divide(allMC);
ratio->SetMinimum(0);
ratio->SetMaximum(2);
ratio->SetFillColor(kBlack);
ratio->SetFillStyle(3354);
ratio->SetMarkerSize(0.);
cout << "width: " << ratio->GetBinWidth(1) << std::endl;
if(MaxX <= 0.1){
ratio->SetAxisRange(MinX, MaxX);
}else{
ratio->SetAxisRange(MinX, MaxX-ratio->GetBinWidth(1));
}
ratio->SetLabelSize(0.1, "X");
ratio->SetTitleOffset(0.5, "Y");
ratio->GetYaxis()->SetTitle("data/MC");ratio->GetYaxis()->SetTitleSize(0.1);
ratio->GetXaxis()->SetTitle(Xtitle);ratio->GetXaxis()->SetTitleSize(0.15);
ratio->Draw("ep");
TLine *line;
if(MaxX <= 0.1){
line = new TLine(MinX,1,MaxX,1);
}else{
line = new TLine(MinX,1,MaxX-ratio->GetBinWidth(1),1);
}
line->Draw();
TString plotName("plots/Control/"+ Obj + Cut + Type + Next );
if(logPlot == true){
plotName += Variable+"ge1b_Log.pdf";
}else{
plotName += Variable+"ge1b";
}
c1->SaveAs(plotName+".pdf");
c1->SaveAs(plotName+".png");
delete c1;
}
}
示例9: getResHist
TH1D* getResHist(const string& inFileName, const string& histName,
double minResRatio) {
cout<<"Creating histogram for "<<inFileName<<endl;
// Get the hit-to-lpc residual for residuals > 30% of maximum residual
int nR = 120;
double rMin = 0.0;
double rMax = 600.0;
TH1D* theHist = new TH1D(histName.c_str(), "", nR, rMin, rMax);
theHist->SetDirectory(0);
theHist->SetXTitle("Hit-to-lpc residuals #delta r' larger than 30% of #delta r_{max} (mm)");
theHist->GetYaxis()->SetTicks("+");
theHist->GetYaxis()->SetLabelOffset(-0.03);
theHist->SetTitleOffset(1.25, "Y");
theHist->GetXaxis()->CenterTitle(kTRUE);
theHist->SetTitleSize(0.045, "X");
theHist->SetLabelSize(0.045, "X");
theHist->SetLabelSize(0.05, "Y");
TFile* theFile = TFile::Open(inFileName.c_str(), "read");
TTree* lpcTree = dynamic_cast<TTree*>(theFile->Get("lpcTree"));
vector<double>* hitResiduals = 0;
lpcTree->SetBranchAddress("hitResiduals", &hitResiduals);
int nEntries = lpcTree->GetEntries();
for (int i = 0; i < nEntries; i++) {
// Get the residual info
lpcTree->GetEntry(i);
// Sort the vector of hit residuals for this lpc cluster
std::sort(hitResiduals->begin(), hitResiduals->end());
// Get the maximum residual
int nResiduals = hitResiduals->size();
double maxResidual = (*hitResiduals)[nResiduals-1];
// Only consider hit residuals that are larger than minResidual
double minResidual = minResRatio*maxResidual;
double nPassRes(0.0), nTotRes(0.0);
for (int j = 0; j < nResiduals; j++) {
double resValue = (*hitResiduals)[j];
if (resValue > minResidual) {
// We have a residual distance that is large enough
theHist->Fill(resValue);
}
} // Loop over residuals
}
// Normalise the histogram
double scale(1.0);
double integral = theHist->Integral();
if (integral > 0.0) {scale = 1.0/integral;}
theHist->Scale(scale);
theFile->Close();
return theHist;
}
示例10: CumulantErrGraph_v2_normalized
//.........这里部分代码省略.........
err_pos[i] = sqrt(variance_pos);
err_neg[i] = sqrt(variance_neg);
err_diff[i] = sqrt(variance_diff);
}
cout << low << upp << endl;
for(i=0;i<NAchBins;i++){
cout << x[i] << ", ";
}
cout << endl << "v2" << endl;
for(i=0;i<NAchBins;i++){
cout << v2_diff[i] << ", ";
}
cout << endl << "v2 error" <<endl;
for(i=0;i<NAchBins;i++){
cout << "error is: " << err_pos[i] << endl;
}
gStyle->SetLegendFont(42);
TH1D* base = new TH1D("base","base",1,-0.3,0.3);
//pPb
//base->GetYaxis()->SetRangeUser(0.065, 0.075);
//PbPb
base->GetYaxis()->SetRangeUser(0.018, 0.03);
base->GetXaxis()->SetTitle("Observed A_{ch}");
base->GetYaxis()->SetTitle("v_{3}{2}");
base->GetXaxis()->CenterTitle();
base->GetYaxis()->CenterTitle();
base->SetTitleSize (0.040,"X");
base->SetTitleOffset(1.4,"X");
base->SetTitleFont (42,"X");
base->SetLabelOffset(0.006,"X");
base->SetLabelSize (0.040,"X");
base->SetLabelFont (42 ,"X");
base->SetTitleSize (0.040,"Y");
base->SetTitleOffset(2.2,"Y");
base->SetTitleFont (42,"Y");
base->SetLabelOffset(0.006,"Y");
base->SetLabelSize (0.040,"Y");
base->SetLabelFont (42 ,"Y");
base->SetLineWidth(0);
TH1D* base2 = new TH1D("base2","base2",1,-0.4,0.4);
base2->GetYaxis()->SetRangeUser(-0.06, 0.06);
base2->GetXaxis()->SetTitle("Observed A_{ch}");
base2->GetYaxis()->SetTitle(" #frac{ v_{3}^{#minus} #minus v_{3}^{#plus} }{ v_{3}^{#minus} #plus v_{3}^{#plus} } ");
base2->GetXaxis()->CenterTitle();
base2->GetYaxis()->CenterTitle();
base2->SetTitleSize (0.040,"X");
base2->SetTitleOffset(1.4,"X");
base2->SetTitleFont (42,"X");
base2->SetLabelOffset(0.006,"X");
base2->SetLabelSize (0.040,"X");
base2->SetLabelFont (42 ,"X");
base2->SetTitleSize (0.040,"Y");
base2->SetTitleOffset(2.0,"Y");
base2->SetTitleFont (42,"Y");
base2->SetLabelOffset(0.006,"Y");
base2->SetLabelSize (0.040,"Y");
base2->SetLabelFont (42 ,"Y");
base2->SetLineWidth(0);
TFile *rebinned = new TFile("~/Summer2016/root_forgraphs/figure2_1.root","RECREATE");
示例11: EstimateBg_76X
//.........这里部分代码省略.........
TLegend *leg = (TLegend*)can->GetListOfPrimitives()->At(can->GetListOfPrimitives()->GetEntries()-1);
leg->SetX1(0.35); leg->SetX2(0.65); leg->SetY1(0.6);
// Add ratio plot
int y1 = 350;
int y2 = 150;
int mid2 = 10;
can->Divide(1,2);
// Pad 1 (80+500+20 x 40+500)
TVirtualPad* p = can->cd(1);
p->SetPad(0,(y2+60+mid2)/(y1+y2+100.0+mid2),1,1);
p->SetTopMargin(40.0/(y1+40));
p->SetBottomMargin(0);
p->SetRightMargin(0.05);
p->SetLogy(1);
h_side->GetYaxis()->SetRangeUser(1.00001e-4,1e4);
h_side->Draw("HIST");
h_signal->Draw("SAMEHISTE1");
leg->Draw();
// Pad 2 (80+500+20 x 200+60)
p = can->cd(2);
p->SetGrid(0,1);
p->SetPad(0,0,1,(y2+60+mid2)/(y1+y2+100.0+mid2));
p->SetTopMargin(((float)mid2)/(y2+60+mid2));
p->SetBottomMargin(60.0/(y2+60+mid2));
p->SetRightMargin(0.05);
TH1D* ratio = (TH1D*)h_signal->Clone();
TH1D* div = (TH1D*)h_side->Clone();
//ratio->Scale(1/ratio->GetSumOfWeights());
double sum_bins_ratio = iMethod==0 ? ratio->Integral():
ratio->Integral(ratio->FindBin(R_CUT_LOW),ratio->FindBin(Rranges_ABCD[iMethod][3]));
ratio->Scale(1/sum_bins_ratio);
ratio->SetTitleSize(32.0/(y2+60+mid2),"xyz");
ratio->SetLabelSize(20.0/(y2+60+mid2),"xyz");
//ratio->Scale(1/div->GetSumOfWeights());
double sum_bins_div = iMethod==0 ? div->Integral():
div->Integral(div->FindBin(R_CUT_LOW),div->FindBin(Rranges_ABCD[iMethod][3]));
div->Scale(1/sum_bins_div);
ratio->Divide(div);
//ratio->GetYaxis()->SetRangeUser(0,2);
ratio->GetXaxis()->SetTitleOffset(0.7);
ratio->GetYaxis()->SetNdivisions(305);
ratio->GetYaxis()->SetTitle("Ratio (Norm.)");
ratio->GetYaxis()->SetTitleOffset(0.4);
ratio->SetTitleSize(24.0/(y2+60+mid2),"y");
ratio->SetTitle("");
ratio->SetMarkerStyle(20);
ratio->SetMarkerColor(1);
ratio->SetLineColor(1);
ratio->GetYaxis()->SetRangeUser(0,4);
ratio->Draw("PE1");
TLine* l = new TLine(ratio->GetXaxis()->GetXmin(), 1, ratio->GetXaxis()->GetXmax(), 1);
l->SetLineWidth(2);
//l->SetLineColor(2);
l->SetLineStyle(2);
l->Draw();
gPad->Update();
// Fit ratio
//TF1 *fit_ratio;
//if (iMethod==1) {
// fit_ratio = new TF1("fit_ratio","pol0", Rranges_ABCD[iMethod][0], Rranges_ABCD[iMethod][1]);
// fit_ratio->SetLineColor(1);
// ratio->Fit("fit_ratio","RE");
// fit_ratio->SetRange(Rranges_ABCD[iMethod][0], Rranges_ABCD[iMethod][2]);
// fit_ratio->Draw("SAME");
//}
示例12: CombineCentralitiesForDirectory
void CombineCentralitiesForDirectory(TString pairType, TDirectory *dataDir)
{
// Gather the cfs and counts to combine centrality bins
vector<TString> centBins010 = {"05", "510"};
vector<TString> centBins1030 = {"1015", "1520", "2025", "2530"};
vector<TString> centBins3050 = {"3035", "3540", "4045", "4550"};
vector<TString> finalCentBins = {"010", "1030", "3050"};
vector<vector<TString> > centBins;
centBins.push_back(centBins010);
centBins.push_back(centBins1030);
centBins.push_back(centBins3050);
TDirectory *mergeDir = dataDir->GetDirectory("Merged");
if(!mergeDir) {
cout<<"Merge directory does not exist. Cannot merge."<<endl;
return;
}
//For each merge group, get the necessary CFs and counts
for(UInt_t iMerge = 0; iMerge < centBins.size(); iMerge++) {
vector<TH1D*> cfs;
vector<Double_t> counts;
Double_t totalCounts = 0;
for(UInt_t iCF = 0; iCF < centBins[iMerge].size(); iCF++) {
TString cfName = "CF" + pairType + centBins[iMerge][iCF];
TH1D *cf = (TH1D*)mergeDir->Get(cfName);
if(!cf) {
cout<<"Could not find CF named "<<cfName<<" in "<<mergeDir->GetName()<<endl;
return;
}
cfs.push_back(cf);
TString countName = "Count" + pairType + centBins[iMerge][iCF];
TVectorD *count = (TVectorD*) mergeDir->Get(countName);
totalCounts += count[0](0);
counts.push_back(count[0](0));
}
// Finally, combine the CFs
TH1D *combinedCF = CombineCFs(cfs, counts);
if (!combinedCF) {
cout << "Combine CF returned nothing. Continuing loop."
<<endl;
continue;
}
TVectorD finalCount(1);
finalCount[0] = totalCounts;
// Set names
TString combinedCFName = "CF" + pairType + finalCentBins[iMerge];
TString combinedCountName = "Count" + pairType + finalCentBins[iMerge];
combinedCF->SetName(combinedCFName);
combinedCF->SetTitle(combinedCFName);
// Set axis ranges
combinedCF->SetAxisRange(0.9, 1.1, "Y");
combinedCF->SetAxisRange(0., .5, "X");
combinedCF->SetLabelSize(0.05, "X");
combinedCF->SetLabelSize(0.05, "Y");
combinedCF->SetTitleSize(0.05, "X");
combinedCF->SetNdivisions(505, "X");
combinedCF->SetNdivisions(505, "Y");
cout<<"Writing combined CF "<<combinedCF->GetName()
<<" to "<<mergeDir->GetName()<<endl;
combinedCF->SetDirectory(0);
mergeDir->cd();
combinedCF->Write(combinedCF->GetName(), TObject::kOverwrite);
finalCount.Write(combinedCountName, TObject::kOverwrite);
}
}
示例13: TCanvas
TCanvas *drawRatioPlot(TH1D *prediction, TH1D *sr, TString xTitle, TString filename){
TCanvas *c = new TCanvas("c"+filename,"c",0,0,500,500);
float y = 0.3;
TPad *pad1 = new TPad("pad1", "Control Plots 1", 0.01, y, 0.99, 0.99);
TPad *padRatio = new TPad("rp1", "Ratio1", 0.01, 0.01, 0.99, y-0.01);
TH1D *ratio = 0;
//ratio = (TH1D*) sr->Clone();
//ratio->Divide(prediction);
ratio = (TH1D*) prediction->Clone();
ratio->Divide(sr);
for(int i=1; i<=ratio->GetNbinsX();i++){
cout<<"Scaling Factor in "<<i<<". bin ="<<ratio->GetBinContent(i)<<" +/- "<<ratio->GetBinError(i)<<endl;
}
ratio->GetYaxis()->SetTitle("Pred/Bkg");
ratio->SetTitle("");
ratio->SetLabelSize(0.1,"X");
ratio->SetLabelSize(0.1,"Y");
ratio->SetTitleOffset(0.5,"Y");
ratio->SetTitleSize(0.15,"Y");
padRatio->cd();
//ratio->GetYaxis()->SetRangeUser(0,2);
ratio->Draw();
// Draw line at one!
float xmin = ratio->GetXaxis()->GetXmin();
float xmax = ratio->GetXaxis()->GetXmax();
TLine *line = new TLine(xmin,1,xmax,1);
line->SetLineWidth(2);
line->Draw("same");
padRatio->Modified();
TLegend *leg = new TLegend(0.6,0.8,0.9,0.9);
leg->AddEntry(sr,"bkg","l");
leg->AddEntry(prediction,"bkg prediction","pel");
pad1->cd();
pad1->SetLogy();
sr->SetLineColor(kRed);
sr->SetMarkerColor(kRed);
sr->SetMarkerStyle(20);
sr->SetTitle("");
prediction->SetMarkerStyle(20);
prediction->SetTitle("");
prediction->GetXaxis()->SetTitle(xTitle);
sr->GetXaxis()->SetTitle(xTitle);
prediction->SetTitleSize(0.07,"X");
prediction->GetXaxis()->SetTitleOffset(0.7);
sr->SetTitleSize(0.07,"X");
sr->GetXaxis()->SetTitleOffset(0.7);
prediction->Draw("e");
sr->Draw("e same");
double maximum =prediction->GetMaximum()*2.5;
double minimum = 0.00001;
if(sr->GetMinimum()!=0) minimum=sr->GetMinimum()*0.5;
if(prediction->GetMinimum()!=0) minimum=prediction->GetMinimum()*0.5;
if(sr->GetMaximum()>prediction->GetMaximum()){
maximum=sr->GetMaximum()*2.5;
}
prediction->GetYaxis()->SetRangeUser(minimum,maximum);
leg->Draw("same");
// Draw both pads to canvas
c->cd();
pad1->Draw();
padRatio->SetGridy();
padRatio->Draw();
c->SaveAs(filename);
return c;
}
示例14: ALICE_Comparison
//.........这里部分代码省略.........
//negative
cmean = c2_neg[i][0] -> GetMean();
v2_neg[i] = sqrt(cmean);
errmean = c2_neg[i][0] -> GetMeanError();
variance_neg = (errmean*errmean)/(4*cmean);
//difference
v2_diff[i] = (v2_neg[i] - v2_pos[i])/(v2_neg[i] + v2_pos[i]);
sum = v2_pos[i] + v2_neg[i];
variance_diff = (4*v2_neg[i]*v2_neg[i]*variance_pos)/(sum*sum*sum*sum)+(4*v2_pos[i]*v2_pos[i]*variance_neg)/(sum*sum*sum*sum);
//error bars
err_pos[i] = sqrt(variance_pos);
err_neg[i] = sqrt(variance_neg);
err_diff[i] = sqrt(variance_diff);
}
gStyle->SetLegendFont(42);
TH1D* base = new TH1D("base","base",1,-0.2,0.2);
//pPb
base->GetYaxis()->SetRangeUser(0.10, 0.11);
base->GetXaxis()->SetTitle("Observed A_{ch}");
base->GetYaxis()->SetTitle("v_{2}{SP}");
base->GetXaxis()->CenterTitle();
base->GetYaxis()->CenterTitle();
base->SetTitleSize (0.040,"X");
base->SetTitleOffset(1.4,"X");
base->SetTitleFont (42,"X");
base->SetLabelOffset(0.006,"X");
base->SetLabelSize (0.040,"X");
base->SetLabelFont (42 ,"X");
base->SetTitleSize (0.040,"Y");
base->SetTitleOffset(2.2,"Y");
base->SetTitleFont (42,"Y");
base->SetLabelOffset(0.006,"Y");
base->SetLabelSize (0.040,"Y");
base->SetLabelFont (42 ,"Y");
base->SetLineWidth(0);
TH1D* base2 = new TH1D("base2","base2",1,-0.2,0.2);
base2->GetYaxis()->SetRangeUser(-0.05, 0.05);
base2->GetXaxis()->SetTitle("Observed A_{ch}");
base2->GetYaxis()->SetTitle(" (v^{#minus}_{2} #minus v^{#plus}_{2})/(v^{#minus}_{2} #plus v^{#plus}_{2}) ");
base2->GetXaxis()->CenterTitle();
base2->GetYaxis()->CenterTitle();
base2->SetTitleSize (0.040,"X");
base2->SetTitleOffset(1.4,"X");
base2->SetTitleFont (42,"X");
base2->SetLabelOffset(0.006,"X");
base2->SetLabelSize (0.040,"X");
base2->SetLabelFont (42 ,"X");
base2->SetTitleSize (0.040,"Y");
base2->SetTitleOffset(2.0,"Y");
base2->SetTitleFont (42,"Y");
base2->SetLabelOffset(0.006,"Y");
base2->SetLabelSize (0.040,"Y");
base2->SetLabelFont (42 ,"Y");
base2->SetLineWidth(0);
cout << v2_pos[0] << endl;
示例15: CumulantErrGraph_v2_allgraphs_cent
//.........这里部分代码省略.........
sum = v2_pos[i] + v2_neg[i];
variance_diff = (4*v2_neg[i]*v2_neg[i]*variance_pos)/(sum*sum*sum*sum)+(4*v2_pos[i]*v2_pos[i]*variance_neg)/(sum*sum*sum*sum);
//error bars
cout << "xcoord " << x[i] << endl;
err_pos[i] = sqrt(variance_pos);
err_neg[i] = sqrt(variance_neg);
err_diff[i] = sqrt(variance_diff);
}
gStyle->SetLegendFont(42);
TH1D* base = new TH1D("base","base",1,-0.12,0.12);
//pPb
//base->GetYaxis()->SetRangeUser(0.065, 0.075);
base->GetYaxis()->SetRangeUser(range_start, range_end);
//PbPb
//base->GetYaxis()->SetRangeUser(0.093, 0.103);
base->GetXaxis()->SetTitle("Corrected A_{ch}");
base->GetYaxis()->SetTitle("v_{2}{2}");
base->GetXaxis()->CenterTitle();
base->GetYaxis()->CenterTitle();
base->SetTitleSize (0.040,"X");
base->SetTitleOffset(1.4,"X");
base->SetTitleFont (42,"X");
base->SetLabelOffset(0.006,"X");
base->SetLabelSize (0.040,"X");
base->SetLabelFont (42 ,"X");
base->SetTitleSize (0.040,"Y");
base->SetTitleOffset(2.2,"Y");
base->SetTitleFont (42,"Y");
base->SetLabelOffset(0.006,"Y");
base->SetLabelSize (0.040,"Y");
base->SetLabelFont (42 ,"Y");
base->SetLineWidth(0);
TH1D* base2 = new TH1D("base2","base2",1,-0.12,0.12);
base2->GetYaxis()->SetRangeUser(-0.03, 0.03);
base2->GetXaxis()->SetTitle("Corrected A_{ch}");
base2->GetYaxis()->SetTitle(" (v^{#minus}_{2} #minus v^{#plus}_{2})/(v^{#minus}_{2} #plus v^{#plus}_{2}) ");
base2->GetXaxis()->CenterTitle();
base2->GetYaxis()->CenterTitle();
base2->SetTitleSize (0.040,"X");
base2->SetTitleOffset(1.4,"X");
base2->SetTitleFont (42,"X");
base2->SetLabelOffset(0.006,"X");
base2->SetLabelSize (0.040,"X");
base2->SetLabelFont (42 ,"X");
base2->SetTitleSize (0.040,"Y");
base2->SetTitleOffset(2.0,"Y");
base2->SetTitleFont (42,"Y");
base2->SetLabelOffset(0.006,"Y");
base2->SetLabelSize (0.040,"Y");
base2->SetLabelFont (42 ,"Y");
base2->SetLineWidth(0);
TFile *rebinned = new TFile(Form("~/Summer2016/root_forgraphs/v2_cent_%d_%d.root",mult_start[num],mult_end[num]),"RECREATE");