本文整理汇总了C++中TH2::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ TH2::Add方法的具体用法?C++ TH2::Add怎么用?C++ TH2::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH2
的用法示例。
在下文中一共展示了TH2::Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IslandLoss
void IslandLoss()
{
/*****************************************************************/
// Prepare the canvas
gStyle->SetOptStat("");
TCanvas *canvas = (TCanvas *) gROOT->GetListOfCanvases()->At(0);
canvas->Clear();
/*****************************************************************/
TH2 *hExpected = (TH2 *)gDirectory->Get("hExpectedNumberOfIslands");
TH2 *hActual = (TH2 *)gDirectory->Get("hNumberOfIslands");
if (hExpected && hActual)
{
TVirtualPad *pad = canvas->cd(1);
hExpected->Add(hActual, -1);
hExpected->SetTitle("Difference between Expected Number of TPulseIslands and Actual Number of TPulseIslands");
hExpected->GetXaxis()->SetRange(9,9);
hExpected->GetYaxis()->SetRangeUser(0, 1200);
hExpected->Draw("COLZ");
}
}
示例2: profileDistributions
void profileDistributions(TString dist)
{
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
gStyle->SetPalette(1);
TFile *inF=TFile::Open("~/work/top_539/plotter.root");
TFile *inSystF=TFile::Open("~/work/top_539/plotter_syst.root");
bool isPhi(dist.Contains("phi"));
TString profs[]={dist,
dist+"toward",
dist+"transverse",
dist+"away"};
const size_t nprofs= isPhi ? 1 : sizeof(profs)/sizeof(TString);
Int_t colors[]={1,kBlue,kRed,kGreen-3};
TString cats[]={"inclusive","away","transverse","toward"};
/*
TFile *inNomF=inF;
TString nomTTbar="t#bar{t}";
TString nomTTbarTitle="MG+PY";
//TString systList[]={"t#bar{t}systmcatnlo"};
//TString systLabels[]={"[email protected]+HW"};
//TString systList[]={"t#bar{t}systq2down","t#bar{t}systq2up"};
//TString systLabels[]={"-Q^{2}","+Q^{2}"};
//TString systList[]={"t#bar{t}systmepsdown","t#bar{t}systmepsup"};
// TString systLabels[]={"-ME-PS","+ME-PS"};
*/
TFile *inNomF=inSystF;
TString nomTTbar="t#bar{t}systtunep11";
TString nomTTbarTitle="P11";
TString systList[]={"t#bar{t}systtunep11nocr","t#bar{t}systtunep11tev"};
TString systLabels[]={"P11-noCR","P11TeV"};
Int_t systColors[]={1,kAzure,kRed-6,kGreen+3};
const size_t nSysts=sizeof(systList)/sizeof(TString);
TString ch[]={"emu"};
const size_t nch=sizeof(ch)/sizeof(TString);
for(size_t ich=0; ich<nch; ich++)
{
TCanvas *c=new TCanvas("c"+ch[ich]+dist,"c"+ch[ich]+dist,800,800); c->SetTopMargin(0); c->SetBottomMargin(0);
c->Divide(1,nprofs);
TCanvas *cratios=new TCanvas("cratios"+ch[ich]+dist,"cratios"+ch[ich]+dist,800,800); cratios->SetTopMargin(0); cratios->SetBottomMargin(0);
cratios->Divide(1,nprofs);
TCanvas *cproj=new TCanvas("cproj"+ch[ich]+dist,"cproj"+ch[ich]+dist,600,600);
TLegend *dataprojLeg=new TLegend(0.5,0.9,0.6,0.7,"Data","brNDC");
TLegend *mcprojLeg=new TLegend(0.7,0.9,0.92,0.7,"MC","brNDC");
for(size_t i=0; i<nprofs; i++)
{
TH2 *bckgMC = (TH2 *) inF->Get("Z#rightarrow ll/"+ch[ich]+"_"+profs[i]);
bckgMC->Add( (TH2 *) inF->Get("VV/"+ch[ich]+"_"+profs[i]) );
bckgMC->Add( (TH2 *) inF->Get("Single top/"+ch[ich]+"_"+profs[i]) );
bckgMC->Add( (TH2 *) inF->Get("W+jets-multijets/"+ch[ich]+"_"+profs[i]) );
//build the total MC with signal alternatives
TH2 *MC = (TH2 *) inNomF->Get(nomTTbar+"/"+ch[ich]+"_"+profs[i]) ;
Double_t totalTTbar(MC->Integral());
MC->Add(bckgMC);
MC->SetDirectory(0);
MC->Sumw2();
std::vector<TH2 *> systMC;
for(size_t isyst=0; isyst<nSysts; isyst++)
{
TH2F *h=(TH2F *)inSystF->Get(systList[isyst]+"/"+ch[ich]+"_"+profs[i]) ;
h->Scale(totalTTbar/h->Integral());
h->Add(bckgMC);
h->Sumw2();
h->SetDirectory(0);
systMC.push_back(h);
}
//get the data
TH2 *Data = (TH2 *) inF->Get("data/"+ch[ich]+"_"+profs[i]);
Data->SetDirectory(0);
Data->Sumw2();
TGraphErrors *MCProf = new TGraphErrors(MC->ProfileX()); MCProf->SetMarkerStyle(24); MCProf->SetFillStyle(0); MCProf->SetName(ch[ich]+profs[i]+"mc");
TGraphErrors *DataProf = new TGraphErrors(Data->ProfileX()); DataProf->SetMarkerStyle(20); DataProf->SetFillStyle(0); DataProf->SetName(ch[ich]+profs[i]+"data");
//build data/MC scale factors
std::vector<TGraphErrors *> data2mcProfs;
for(size_t isyst=0; isyst<=systMC.size(); isyst++)
{
//.........这里部分代码省略.........