本文整理汇总了C++中TH1D::SetStats方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1D::SetStats方法的具体用法?C++ TH1D::SetStats怎么用?C++ TH1D::SetStats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1D
的用法示例。
在下文中一共展示了TH1D::SetStats方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: plotTurnOn
void plotTurnOn(TTree* inttree, TString triggerpass, TString variable, TString varname, TString varlatex)
{
if(varname=="vtxprob")
{
BIN_MIN = 0;
BIN_MAX = 1;
}
else if(varname=="ffls3d")
{
BIN_MIN = 0;
BIN_MAX = 50;
}
else if(varname=="cosalpha")
{
BIN_MIN = 0.9;
BIN_MAX = 1;
}
TH1D* hAll = new TH1D(Form("h%s_%s_All",triggerpass.Data(),varname.Data()),Form(";%s;Probability",varlatex.Data()),BIN_NUM,BIN_MIN,BIN_MAX);
inttree->Project(Form("h%s_%s_All",triggerpass.Data(),varname.Data()),variable,prefilter);
TH1D* hMBseed = new TH1D(Form("h%s_%s_MBseed",triggerpass.Data(),varname.Data()),Form(";%s;Probability",varlatex.Data()),BIN_NUM,BIN_MIN,BIN_MAX);
inttree->Project(Form("h%s_%s_MBseed",triggerpass.Data(),varname.Data()),variable,Form("%s&&%s",prefilter.Data(),triggerpass.Data()));
//cout<<hAll->Integral()<<endl;
hAll->Scale(1./hAll->Integral());
hMBseed->Scale(1./hMBseed->Integral());
hAll->SetStats(0);
hMBseed->SetStats(0);
hAll->SetMaximum(hMBseed->GetMaximum()*1.3);
hAll->SetLineWidth(2);
hAll->SetLineColor(kBlue-7);
hAll->SetFillColor(kBlue-7);
hAll->SetFillStyle(3001);
hMBseed->SetLineWidth(2);
hMBseed->SetLineColor(kRed);
hMBseed->SetFillColor(kRed);
hMBseed->SetFillStyle(3004);
TCanvas* c = new TCanvas(Form("c%s_%s",triggerpass.Data(),varname.Data()),"",500,500);
hAll->Draw();
hMBseed->Draw("same");
TLatex* tex = new TLatex(0.18,0.96,triggerpass);
tex->SetNDC();
tex->SetTextFont(42);
tex->SetTextSize(0.04);
tex->Draw();
TLegend* leg = new TLegend(0.60,0.82,0.92,0.93);
leg->SetFillStyle(0);
leg->SetBorderSize(0);
leg->AddEntry(hAll,"all","f");
leg->AddEntry(hMBseed,"pass trigger","f");
leg->Draw();
c->SaveAs(Form("triggerturnonPlots/pthat%.0f/c%s_%s.pdf",pthat,triggerpass.Data(),varname.Data()));
}
示例2: drawDum
//__________________________________________________________________________
void drawDum(float min, float max, double drawXLabel)
{
TH1D *hdum = new TH1D("hdum","",20,0,1);
hdum->SetMaximum(max);
hdum->SetStats(0);
if(drawXLabel) hdum->SetXTitle("A_{J} = (E_{T}^{j1}-E_{T}^{j2})/(E_{T}^{j1}+E_{T}^{j2})");
hdum->GetXaxis()->SetLabelSize(20);
hdum->GetXaxis()->SetLabelFont(43);
hdum->GetXaxis()->SetTitleSize(22);
hdum->GetXaxis()->SetTitleFont(43);
hdum->GetXaxis()->SetTitleOffset(1.5);
hdum->GetXaxis()->CenterTitle();
hdum->GetXaxis()->SetNdivisions(905,true);
hdum->SetYTitle("Ratio");
hdum->GetYaxis()->SetLabelSize(20);
hdum->GetYaxis()->SetLabelFont(43);
hdum->GetYaxis()->SetTitleSize(20);
hdum->GetYaxis()->SetTitleFont(43);
hdum->GetYaxis()->SetTitleOffset(2.5);
hdum->GetYaxis()->CenterTitle();
hdum->SetAxisRange(0,0.2,"Y");
hdum->Draw("");
}
示例3: DrawPileupCorr
bool DrawPileupCorr(Str jetAlgo) {
JetCalibrationTool *theJES = new JetCalibrationTool(jetAlgo,_jesFile,false);
bool residual = theJES->JetAreaJES();
TH1D *temp = new TH1D("","",100,-5,5);
temp->SetXTitle("Jet #eta"); temp->SetYTitle("Jet offset at "+GetConstScale(jetAlgo)+"-scale [GeV]");
if (residual) temp->SetYTitle("Residual jet offset at "+GetConstScale(jetAlgo)+"-scale [GeV]");
temp->SetMinimum(-20); temp->SetMaximum(15); temp->SetStats(0);
if ( residual && theJES->ResidualOffsetCorr_Description() == "" ) return false;
Can->Clear(); temp->Draw();
for (int npv=0;npv<9;++npv) {
double NPV=(npv%3)*10, mu=(npv/3)*10;
if (NPV==0) NPV=1;
Graph *g = new Graph();
FormatGraph(g,npv);
for (int ieta=-50;ieta<50;++ieta) {
double eta=0.05 + 0.1*ieta;
double O = residual ? theJES->GetResidualOffset(eta,mu,NPV)/1000 :
theJES->GetOffset(eta,mu,NPV)/1000; // convert to GeV
g->SetPoint(g->GetN(),eta,O);
}
if (npv<4) DrawLabel(Form("N_{PV} = %.0f, #LT#mu#GT = %.0f",NPV,mu),0.18,0.35-0.04*npv,npv);
else DrawLabel(Form("N_{PV} = %.0f, #LT#mu#GT = %.0f",NPV,mu),0.48,0.35-0.04*(npv-4),npv);
g->Draw("P");
}
tex->SetNDC(); tex->SetTextAlign(12);
if (residual)
tex->DrawLatex(0.18,0.975,theJES->ResidualOffsetCorr_Description());
else
tex->DrawLatex(0.18,0.975,theJES->OffsetCorr_Description());
tex->DrawLatex(0.18,0.9,GetJetDesc(jetAlgo));
return true;
}
示例4: RunTest
void RunTest(const char* name, int numentries, int BufferSize) {
char title[200];
sprintf(title, "%d events, 10 branches, 10 floats in brunch, Basket size = %d", numentries, BufferSize*sizeof(Float_t)*10);
TH1D* histoRes = new TH1D(name, title, 10, 0.5, 10.5);
histoRes->GetXaxis()->SetTitle("Number of active branches");
histoRes->GetYaxis()->SetTitle("Real time (s)");
histoRes->SetDirectory(0);
histoRes->SetStats(kFALSE);
ProduceTree("TreeFile.root","TestTree", numentries, 0, 10, 10, BufferSize);
Float_t RealTime, CpuTime;
for(int ActiveBranches=1;ActiveBranches<=10;ActiveBranches++) {
ReadDummyTree();
cout << "Buffer size = " << BufferSize*sizeof(Float_t)*10 << " ActiveBranches = " << ActiveBranches << endl;
MakeDelay(10);
TestTree("TreeFile.root","TestTree", 10, 10, ActiveBranches, &RealTime, &CpuTime);
histoRes->SetBinContent(ActiveBranches, RealTime);
}
TCanvas* c1 = new TCanvas(TString(name)+"_canvas", title);
histoRes->Draw();
c1->SaveAs(TString(name)+".gif");
}
示例5: drawDum
void drawDum(float min, float max, double drawXLabel){
TH1D *hdum = new TH1D("h","",10,120,220);
hdum->SetMaximum(max);
hdum->SetStats(0);
if(drawXLabel) hdum->SetXTitle("(p_{T}^{j1}-p_{T}^{j2})/(p_{T}^{j1}+p_{T}^{j2})");
hdum->GetXaxis()->SetLabelSize(20);
hdum->GetXaxis()->SetLabelFont(43);
hdum->GetXaxis()->SetTitleSize(22);
hdum->GetXaxis()->SetTitleFont(43);
hdum->GetXaxis()->SetTitleOffset(1.5);
hdum->GetXaxis()->CenterTitle();
hdum->GetXaxis()->SetNdivisions(905,true);
hdum->SetYTitle("Event Fraction");
hdum->GetYaxis()->SetLabelSize(20);
hdum->GetYaxis()->SetLabelFont(43);
hdum->GetYaxis()->SetTitleSize(20);
hdum->GetYaxis()->SetTitleFont(43);
hdum->GetYaxis()->SetTitleOffset(2.5);
hdum->GetYaxis()->CenterTitle();
hdum->SetAxisRange(0,0.2,"Y");
hdum->Draw("");
}
示例6: RunTest
void RunTest(const char* name, const char* uselesstitle, int numentries, int BufferSize) {
TString title;
title += numentries;
title.Append(" events, 10 branches, 10 floats in brunch, Basket size = ");
title += ( BufferSize*10*10*4 );
TH1D* histoRes = new TH1D(name, title, 10, 0.5, 10.5);
histoRes->GetXaxis()->SetTitle("Number of active branches");
histoRes->GetYaxis()->SetTitle("Real time (s)");
histoRes->SetDirectory(0);
histoRes->SetStats(kFALSE);
ProduceTree("TreeFile.root","TestTree", numentries, 0, 10, 10, BufferSize);
Float_t RealTime, CpuTime;
for(int ActiveBranches=1;ActiveBranches<=10;ActiveBranches++) {
PurgeMemory();
cout << "Buffer size = " << BufferSize*sizeof(Float_t)*10 << " ActiveBranches = " << ActiveBranches << endl;
MakeDelay(5);
TestTree("TreeFile.root","TestTree", 10, 10, ActiveBranches, RealTime, CpuTime);
histoRes->SetBinContent(ActiveBranches, RealTime);
}
TCanvas* c1 = new TCanvas(TString(name)+"_canvas",title);
histoRes->Draw();
c1->SaveAs(TString(name)+".gif");
}
示例7: plotTurnOn
void plotTurnOn(TTree* inttree, TString triggerpass, TString variable, TString varname, TString varlatex, Int_t BIN_NUM, Double_t BIN_MIN, Double_t BIN_MAX, TString addcut="")
{
TLatex* tex = new TLatex(0.18,0.96,triggerpass);
tex->SetNDC();
tex->SetTextFont(42);
tex->SetTextSize(0.04);
TH1D* hinclusive = new TH1D(Form("hinclusive_%s_%s",triggerpass.Data(),varname.Data()),Form(";Matched reco D^{0} %s;Candidates",varlatex.Data()),BIN_NUM,BIN_MIN,BIN_MAX);
inttree->Project(Form("hinclusive_%s_%s",triggerpass.Data(),varname.Data()),variable,Form("%s%s",prefilter.Data(),addcut.Data()));
hinclusive->Sumw2();
if(triggerpass=="HLT_DmesonTrackingGlobalPt8_Dpt20_v1"||triggerpass=="HLT_DmesonPPTrackingGlobal_Dpt20_v1")
{
TCanvas* chinclusive = new TCanvas(Form("chinclusive_%s",varname.Data()),"",500,500);
hinclusive->Draw();
hinclusive->SetStats(0);
tex->Draw();
if(isPbPb) chinclusive->SaveAs(Form("triggerturnonPlots/pthat%.0f/MBseed/pbpb/chinclusive_%s.pdf",pthat,varname.Data()));
else chinclusive->SaveAs(Form("triggerturnonPlots/pthat%.0f/MBseed/pp/chinclusive_%s.pdf",pthat,varname.Data()));
}
TH2D* hempty = new TH2D(Form("hempty_%s_%s",triggerpass.Data(),varname.Data()),Form(";Matched reco D^{0} %s;Pass efficiency (ZB seed)",varlatex.Data()),BIN_NUM,BIN_MIN,BIN_MAX,10,0,1.2);
hempty->SetStats(0);
TH1D* hMBseed = new TH1D(Form("h%s_MBseed_%s",triggerpass.Data(),varname.Data()),"",BIN_NUM,BIN_MIN,BIN_MAX);
inttree->Project(Form("h%s_MBseed_%s",triggerpass.Data(),varname.Data()),variable,Form("%s%s&&%s",prefilter.Data(),addcut.Data(),triggerpass.Data()));
hMBseed->Sumw2();
TEfficiency* pEffMBseed = new TEfficiency(*hMBseed,*hinclusive);
TCanvas* cMBseed = new TCanvas(Form("c%s_MBseed_%s",triggerpass.Data(),varname.Data()),"",500,500);
hempty->Draw();
pEffMBseed->Draw("PSAME");
tex->Draw();
/*
if(isPbPb) cMBseed->SaveAs(Form("triggerturnonPlots/pthat%.0f/MBseed/pbpb/c%s_MBseed_%s.pdf",pthat,triggerpass.Data(),varname.Data()));
else cMBseed->SaveAs(Form("triggerturnonPlots/pthat%.0f/MBseed/pp/c%s_MBseed_%s.pdf",pthat,triggerpass.Data(),varname.Data()));
*/
cMBseed->SaveAs(Form("triggerturnonPlots/pthat%.0f/ZBseed/pp/c%s_MBseed_%s.pdf",pthat,triggerpass.Data(),varname.Data()));
}
示例8: hashErrors
TH1D* CutFlow::hashErrors(AllSamples samples, Variable variable){
TH1D * hashErrors = allMChisto(samples, variable);
hashErrors->SetFillColor(kBlack);
hashErrors->SetFillStyle(3354);
hashErrors->SetMarkerSize(0.);
hashErrors->SetStats(0);
return hashErrors;
}
示例9: nu_spect
void nu_spect(const std::string& filename) {
TFile* file = new TFile(filename.c_str(), "read");
TTree* tree = NULL;
file->GetObject("MARLEY_event_tree", tree);
if (!tree) {
std::cout << "MARLEY event tree not found" << '\n';
return;
}
marley::Event* ev = new marley::Event;
tree->SetBranchAddress("event", &ev);
size_t num_events = tree->GetEntries();
std::vector<double> E_vec;
for (size_t i = 0; i < num_events; ++i) {
tree->GetEntry(i);
E_vec.push_back(ev->projectile().total_energy());
if (i % 1000 == 0) std::cout << "Event " << i << '\n';
}
double E_max = -1e30;
double E_min = 1e30;
for (size_t k = 0; k < E_vec.size(); ++k) {
double e = E_vec.at(k);
if (e > E_max) E_max = e;
else if (e < E_min) E_min = e;
}
TString title_str;
TH1D* Es = new TH1D("nu_Es", "reacting neutrino spectrum", 100,
E_max, E_min);
for (size_t j = 0; j < E_vec.size(); ++j) {
Es->Fill(E_vec.at(j));
}
TCanvas* c = new TCanvas;
c->cd();
gStyle->SetOptStat();
Es->SetStats(true);
Es->SetLineColor(kBlue);
Es->SetLineWidth(2);
Es->Draw();
//c->SaveAs("nu_Es.pdf");
}
示例10: getYield
TH1D* getYield(TTree* nt, TString triggerpass, TString triggername, TString prescale, TString variable, TString varname, TString varlatex, Int_t BIN_NUM, Double_t BIN_MIN, Double_t BIN_MAX, TString addcut="")
{
TH1D* hDistrib = new TH1D(Form("h%s_Distrib_%s",triggername.Data(),varname.Data()),Form(";D %s;Event",varlatex.Data()),BIN_NUM,BIN_MIN,BIN_MAX);
nt->Project(Form("h%s_Distrib_%s",triggername.Data(),varname.Data()),Form("%s%s",variable.Data(),prescale.Data()),Form("%s%s%s",prefilter.Data(),addcut.Data(),triggerpass.Data()));
hDistrib->Sumw2();
TCanvas* cDistrib = new TCanvas(Form("c%s_Distrib_%s",triggername.Data(),varname.Data()),"",500,500);
hDistrib->Draw();
hDistrib->SetStats(0);
if(isPbPb) cDistrib->SaveAs(Form("triggerturnonPlots/data/pbpb/c%s_Distrib_%s.pdf",triggername.Data(),varname.Data()));
else cDistrib->SaveAs(Form("triggerturnonPlots/data/pp/c%s_Distrib_%s.pdf",triggername.Data(),varname.Data()));
return hDistrib;
}
示例11: savePlots2
void savePlots2(const std::string& canvasName, TH1D& dataPlot, TH1D& fitPlot,
TH1D& signalPlot, TH1D& bkgPlot) {
TCanvas c(canvasName.c_str(), canvasName.c_str()) ;
TPad mainPad("mainPad", "mainPad", 0., 0.2, 1., 1.) ;
mainPad.Draw() ;
TPad pullPad("pullPad", "pullPad", 0., 0., 1., 0.2) ;
pullPad.Draw() ;
mainPad.cd() ;
dataPlot.SetStats(true) ;
//dataPlot.SetOptStat(111111111);
dataPlot.SetLineWidth(2) ;
dataPlot.Draw() ;
fitPlot.SetLineWidth(2) ;
fitPlot.SetLineColor(kBlue) ;
fitPlot.Draw("same") ;
signalPlot.SetLineWidth(2) ;
signalPlot.SetLineColor(kGreen) ;
signalPlot.Draw("same") ;
bkgPlot.SetLineColor(kRed) ;
bkgPlot.SetLineWidth(2) ;
bkgPlot.Draw("same") ;
TLegend leg(0.6, 0.7, 0.9, 0.9) ;
leg.AddEntry(&dataPlot, "Data") ;
leg.AddEntry(&fitPlot, "Fit") ;
leg.AddEntry(&signalPlot, "Signal") ;
leg.AddEntry(&bkgPlot, "Background") ;
leg.SetFillStyle(0) ;
leg.SetBorderSize(0) ;
leg.Draw() ;
pullPad.cd() ;
pullPad.SetGridy() ;
TH1D* h_residuals(NULL), *h_pulls(NULL), *h_pullDistribution(NULL) ;
FitterTools::makePullPlot(dataPlot, fitPlot, h_residuals, h_pulls, h_pullDistribution) ;
h_pulls->Draw() ;
c.Write() ;
h_pulls->Write() ;
delete h_pulls ;
h_residuals->Write() ;
delete h_residuals ;
h_pullDistribution->Write() ;
delete h_pullDistribution ;
dataPlot.Write() ;
fitPlot.Write() ;
}
示例12: readHist
TH1D* readHist(TString nameHist,TString nameFile, int rebin)
{
TFile* file = new TFile(nameFile);
TH1D* hist = (TH1D*)file->Get(nameHist);
hist->GetSumw2();
// hist->SetLineWidth(2);
if(rebin>0) hist->Rebin(rebin);
hist->GetXaxis()->SetTitleSize(.055);
hist->GetYaxis()->SetTitleSize(.055);
hist->GetXaxis()->SetLabelSize(.05);
hist->GetYaxis()->SetLabelSize(.05);
hist->SetStats(kFALSE);
return hist;
}
示例13: GetDummyHist
TH1D* GetDummyHist(Float_t xmax, Float_t min, Float_t max,Char_t *xttl,Char_t *yttl) {
TH1D *dum;
dum = new TH1D("dum","",100,0.0,xmax);
//dum = new TH1D("dum","",100,0.2,xmax);
dum->SetMinimum(min);
dum->SetMaximum(max);
dum->SetStats(0);
dum->GetYaxis()->SetTitle(yttl);
dum->GetYaxis()->CenterTitle();
dum->GetXaxis()->SetTitle(xttl);
dum->GetXaxis()->CenterTitle();
return dum;
}
示例14: momResHist
TH1D* momResHist(TFile* f, int i) {
Double_t xbins[33] = {0,0.2,0.4,0.6,0.8,
1.0,1.6,2.2,2.8,3.4,
4.4,5.4,6.0,8.0,10.0,
12.0,14.0,18.0,22.0,26.0,
30.0,36.0,42.0,50.0,55.0,
60.0,70.0,80.0,100.0,120.0,
140.0,160.0,200.0};
TH3F *hRes3D = (TH3F*) f->Get("trkEffAnalyzer/hresStoR3D");
double feta = 2.4;
int binMaxEta = hRes3D->GetXaxis()->FindBin(feta);
int binMinEta = hRes3D->GetXaxis()->FindBin(-1.0*feta);
hRes3D->GetXaxis()->SetRange(binMinEta,binMaxEta);
TH2D *hRes2D = (TH2D*) hRes3D->Project3D("zy"); // zy: rec-> y axis, sim -> x axis
hRes2D->SetName("hRes2D");
hRes2D->FitSlicesY(0,0,-1,10);
TH1D *h1 = (TH1D*)gDirectory->Get("hRes2D_1");
TH1D *h2 = (TH1D*)gDirectory->Get("hRes2D_2");
h1->Rebin(32,Form("h1new%d",i),xbins);
h2->Rebin(32,Form("h2new%d",i),xbins);
TH1D* h1new = (TH1D*) gDirectory->Get(Form("h1new%d",i));
TH1D* h2new = (TH1D*) gDirectory->Get(Form("h2new%d",i));
TH1D *momres = (TH1D*) h2new->Clone("momres");
momres->SetName(Form("momres_%d",i));
momres->SetMaximum(0.15); momres->SetMinimum(0.0);
momres->SetTitle("Momentum resolution;p_{T} [GeV/c]");
momres->SetStats(0);
momres->SetMarkerStyle(20);
momres->Divide(h1new);
return momres;
}
示例15: Com
TCanvas* Com(TString plot,TString plot_dir,UInt_t rbin, TString xtitle, Double_t max, TString title){
gROOT->SetStyle("Plain");
gStyle->SetTitleFontSize(0.07);
TH1D *Sig = ((TH1D*)Sig->Get(plot_dir+"/"+plot))->Clone();
TH1D *Bkgd= ((TH1D*)Bkgd->Get(plot_dir+"/"+plot))->Clone();
Sig->Rebin(rbin);
Bkgd->Rebin(rbin);
Sig->Scale(1/(Sig->Integral()));
Bkgd->Scale(1/(Bkgd->Integral()));
//TLine *li =new TLine(0.55,0.,0.55,100000);
TCanvas* c = new TCanvas(plot_dir+plot,plot_dir+plot);
c->SetLogy();
TLegend *leg = new TLegend(0.5,0.8,0.99,0.99);
leg->SetFillColor(0);
leg->AddEntry(Sig,"Selected events","L");
leg->AddEntry(Bkgd,"Anti-selected events","L");
Sig->SetLineColor(kRed);
Sig->SetLineWidth(2);
Bkgd->SetLineColor(kBlue);
Bkgd->SetLineWidth(2);
Sig->Draw("EHIST");
Bkgd->Draw("HISTSAME");
leg->Draw("SAME");
// li->Draw("SAME");
Sig->SetTitle(title);
Sig->SetStats(kFALSE);
Sig->GetXaxis()->SetTitle(xtitle);
if (max == 999999){
}
else{
Sig->GetXaxis()->SetRangeUser(0.2,max);}
Sig->GetYaxis()->SetTitle("");
c->Update();
c->SaveAs(saving+"IDinv_Delta_"+plot_dir+plot+".png");
return c;
}