本文整理汇总了C++中RooDataSet::fillHistogram方法的典型用法代码示例。如果您正苦于以下问题:C++ RooDataSet::fillHistogram方法的具体用法?C++ RooDataSet::fillHistogram怎么用?C++ RooDataSet::fillHistogram使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RooDataSet
的用法示例。
在下文中一共展示了RooDataSet::fillHistogram方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(){
BaBarStyle p;
p.SetBaBarStyle();
//gROOT->SetStyle("Plain");
Bool_t doNorm = kTRUE;
Bool_t doComparison = kFALSE;
Bool_t doFract = kFALSE;
Bool_t doFit = kFALSE;
Bool_t doPlots = kFALSE;
//define DalitzSpace for generation
EvtPDL pdl;
pdl.readPDT("evt.pdl");
EvtDecayMode mode("D0 -> K- pi+ pi0");
EvtDalitzPlot dalitzSpace(mode);
RooRealVar m2Kpi_d0mass("m2Kpi_d0mass","m2Kpi_d0mass",1.,dalitzSpace.qAbsMin(EvtCyclic3::AB),dalitzSpace.qAbsMax(EvtCyclic3::AB));
RooRealVar m2Kpi0_d0mass("m2Kpi0_d0mass","m2Kpi0_d0mass",1.,dalitzSpace.qAbsMin(EvtCyclic3::AC),dalitzSpace.qAbsMax(EvtCyclic3::AC));
RooRealVar m2pipi0_d0mass("m2pipi0_d0mass","m2pipi0_d0mass",1.,dalitzSpace.qAbsMin(EvtCyclic3::BC),dalitzSpace.qAbsMax(EvtCyclic3::BC));
RooCategory D0flav("D0flav","D0flav");
D0flav.defineType("D0",-1);
D0flav.defineType("antiD0",1);
//this is just to plot the m23 pdf
Float_t total = pow(dalitzSpace.bigM(),2) + pow(dalitzSpace.mA(),2) + pow(dalitzSpace.mB(),2) + pow(dalitzSpace.mC(),2);
RooRealVar totalm("totalm","totalm",total);
RooFormulaVar mass13a("mass13a","@[email protected]@2",RooArgSet(totalm,m2Kpi_d0mass,m2pipi0_d0mass));
cout << "read the dataset" << endl;
TFile hello("DataSet_out_tmp.root");
gROOT->cd();
RooDataSet *data = (RooDataSet*)hello.Get("fulldata");
RooDataSet *data_1 = (RooDataSet*)data->reduce("D0flav == 1 && isWS == 0 && d0LifetimeErr < 0.5 && d0Lifetime > -2. && d0Lifetime < 4.");
RooDataSet *finaldata = (RooDataSet*)data_1->reduce("deltaMass > 0.1449 && deltaMass < 0.1459 && d0Mass > 1.8495 && d0Mass < 1.8795");
RooDataSet *leftdata = (RooDataSet*)(RooDataSet*)data_1->reduce("d0Mass > 1.74 && d0Mass < 1.79");
RooDataSet *rightdata = (RooDataSet*)data_1->reduce("d0Mass > 1.94 && d0Mass < 1.99");
//here we set the weights for the dataset
finaldata->setWeightVar(0);
leftdata->setWeightVar(0);
rightdata->setWeightVar(0);
//if you want to have a little dataset to test, uncomment next line and rename finaldata above
//RooDataSet *finaldata = finaldata_1->reduce(EventRange(1,1000));
cout << "*************************************************************" << endl;
cout << "The final data entry " << finaldata->numEntries() << endl;
cout << "*************************************************************" << endl;
//Construct signal pdf
string dirname = "configmaps/effmapping_RS_CP/";
RooKpipi0pdf *D0pdf = new RooKpipi0pdf("D0pdf","D0pdf",m2Kpi_d0mass,m2Kpi0_d0mass,&dalitzSpace,dirname,1);
RooKpipi0pdf *D0pdf23 = new RooKpipi0pdf("D0pdf23","D0pdf23",m2Kpi_d0mass,mass13a,&dalitzSpace,dirname,1);
if(doNorm) D0pdf->getManager()->calNorm();
//When we plot the 1D projection, need to calculate the 1D integral
//set the precision here
//cout << "config integrator " << endl;
RooNumIntConfig *cfg = RooAbsReal::defaultIntegratorConfig();
cfg->setEpsAbs(1E-3);
cfg->setEpsRel(1E-3);
cfg->method1D().setLabel("RooSegmentedIntegrator1D");
//cfg.getConfigSection("RooSegmentedIntegrator1D").setRealValue("numSeg",3);
//cfg->method1D()->Print("v");
D0pdf->setIntegratorConfig(*cfg);
D0pdf23->setIntegratorConfig(*cfg);
cout << "about to init" << endl;
m2Kpi_d0mass.setBins(150);
m2Kpi0_d0mass.setBins(150);
m2pipi0_d0mass.setBins(150);
//background description
//RooBkg combdalitz("combdalitz","combdalitz",m2Kpi_d0mass,m2Kpi0_d0mass,&dalitzSpace);
//RooBkg combdalitz23("combdalitz23","combdalitz23",m2Kpi_d0mass,mass13a,&dalitzSpace);
RooRealVar Nsig("Nsig","Nsig", 653962. + 2218.);
RooRealVar Nbkg("Nbkg","Nbkg", 2255. + 551.);
RooDataHist* dbdalitz = new RooDataHist("dbdalitz","dbdalitz",RooArgSet(m2Kpi_d0mass,m2Kpi0_d0mass),*finaldata);
RooDataHist* dbdalitz23 = new RooDataHist("dbdalitz23","dbdalitz23",RooArgSet(m2Kpi_d0mass,m2pipi0_d0mass),*finaldata);
////////////////////////////////////////
//background parametrization using sidebands histograms
////////////////////////////////////////
TH2F *lefth = m2Kpi_d0mass.createHistogram("lefth",m2Kpi0_d0mass);
leftdata->fillHistogram(lefth,RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass));
TH2F *righth = m2Kpi_d0mass.createHistogram("righth",m2Kpi0_d0mass);
rightdata->fillHistogram(righth,RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass));
TH2F *lefth23 = m2Kpi_d0mass.createHistogram("lefth23",m2pipi0_d0mass);
leftdata->fillHistogram(lefth23,RooArgList(m2Kpi_d0mass,m2pipi0_d0mass));
TH2F *righth23 = m2Kpi_d0mass.createHistogram("righth23",m2pipi0_d0mass);
rightdata->fillHistogram(righth23,RooArgList(m2Kpi_d0mass,m2pipi0_d0mass));
//.........这里部分代码省略.........
示例2: main
//.........这里部分代码省略.........
RooGaussModel gm3("gm3","gauss model 3",d0Lifetime,bias,d0LifetimeErr,one,scalefact3) ;
//RooTruthModel gm("gm","truth model",d0Lifetime);
RooRealVar N1("N1","N1",0.0052);
RooRealVar N2("N2","N2",0.179);
RooFormulaVar f2("f2","f2","([email protected])*@1",RooArgList(N1,N2));
RooFormulaVar f3("f3","f3","([email protected])*([email protected])",RooArgList(N1,N2));
RooAddModel gm("gm","gm",RooArgList(gm2,gm3,gm1),RooArgList(f2,f3));
string dirname = "configmaps/effmapping_std/";
RooTimepdf TOTsigD0("TOTsigD0","TOTsigD0",d0Lifetime,m2Kpi_d0mass,m2Kpi0_d0mass,gm,&dalitzSpace,tau,c1p,c2p,-1,dirname);
RooTimepdf TOTsigantiD0("TOTsigantiD0","TOTsigantiD0",d0Lifetime,m2Kpi_d0mass,m2Kpi0_d0mass,gm,&dalitzSpace,tau,c1p,c2p,-1,dirname);
RooSimultaneous TOTTime("TOTTime","TOTTime",D0flav);
TOTTime.addPdf(TOTsigD0,"D0");
TOTTime.addPdf(TOTsigantiD0,"antiD0");
//////////////////////////
// BACKGROUND
/////////////////////////
TFile RSfile("DataSet_out_reduced_RS.root");
gROOT->cd();
RooDataSet *RSdata = (RooDataSet*)RSfile.Get("fulldata");
m2Kpi_d0mass.setBins(150);
m2Kpi0_d0mass.setBins(150);
d0Lifetime.setBins(70);
d0LifetimeErr.setBins(20);
/*
TH3F *mis_h = m2Kpi_d0mass.createHistogram("mis_h",m2Kpi0_d0mass,d0Lifetime,"");
RSdata->fillHistogram(mis_h,RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass,d0Lifetime));
mis_h->Sumw2();
RooDataHist *mis_hist = new RooDataHist("mis_hist","mis_hist",RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass,d0Lifetime),mis_h);
RooHistPdf Tot_mis("Tot_mis","Tot_mis",RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass,d0Lifetime),*mis_hist);
*/
TH3F *mis_hp = m2Kpi_d0mass.createHistogram("mis_hp",m2Kpi0_d0mass,d0Lifetime,"");
RSdata->fillHistogram(mis_hp,RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass,d0Lifetime),"D0flav == 1");
mis_hp->Sumw2();
RooDataHist *mis_histp = new RooDataHist("mis_histp","mis_histp",RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass,d0Lifetime),mis_hp);
RooHistPdf Tot_misp("Tot_misp","Tot_misp",RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass,d0Lifetime),*mis_histp);
TH3F *mis_hm = m2Kpi_d0mass.createHistogram("mis_hm",m2Kpi0_d0mass,d0Lifetime,"");
RSdata->fillHistogram(mis_hm,RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass,d0Lifetime),"D0flav == -1");
mis_hm->Sumw2();
RooDataHist *mis_histm = new RooDataHist("mis_histm","mis_histm",RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass,d0Lifetime),mis_hm);
RooHistPdf Tot_mism("Tot_mism","Tot_mism",RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass,d0Lifetime),*mis_histm);
RooSimultaneous Tot_mis("Tot_mis","Tot_mis",D0flav);
Tot_mis.addPdf(Tot_misp,"D0");
Tot_mis.addPdf(Tot_mism,"antiD0");
cout << "///////////////" << endl;
cout << "Sample of D0bar RS : " << mis_histp->numEntries(kTRUE) << endl;
cout << "Sample of D0 RS : " << mis_histm->numEntries(kTRUE) << endl;
cout << "///////////////" << endl;
m2Kpi_d0mass.setBins(10);
m2Kpi0_d0mass.setBins(10);
d0Lifetime.setBins(8);
d0LifetimeErr.setBins(10);
RooArgSet observ(d0Lifetime,m2Kpi_d0mass,m2Kpi0_d0mass);
RooArgSet tot_var(d0Lifetime,m2Kpi_d0mass,m2Kpi0_d0mass,d0LifetimeErr,D0flav);
示例3: main
//.........这里部分代码省略.........
RooGaussModel gm1("gm1","gauss model 1",d0Lifetime,bias,d0LifetimeErr,one,scalefact1) ;
RooGaussModel gm2("gm2","gauss model 2",d0Lifetime,bias,d0LifetimeErr,one,scalefact2) ;
RooGaussModel gm3("gm3","gauss model 3",d0Lifetime,bias,d0LifetimeErr,one,scalefact3) ;
RooRealVar N1("N1","N1",0.0052);
RooRealVar N2("N2","N2",0.179);
RooFormulaVar f2("f2","f2","([email protected])*@1",RooArgList(N1,N2));
RooFormulaVar f3("f3","f3","([email protected])*([email protected])",RooArgList(N1,N2));
RooAddModel gm("gm","gm",RooArgList(gm2,gm3,gm1),RooArgList(f2,f3));
string dirname = "configmaps/effmapping_" + name + "/";
RooTimepdf TOTsigD0("TOTsigD0","TOTsigD0",d0Lifetime,m2Kpi_d0mass,m2Kpi0_d0mass,gm,&dalitzSpace,tau,c1,c2,-1,dirname);
//RooTimepdf TOTsigantiD0("TOTsigantiD0","TOTsigantiD0",d0Lifetime,m2Kpi_d0mass,m2Kpi0_d0mass,gm,&dalitzSpace,tau,c1_unblind,c2_unblind,1);
//RooSimultaneous TOTTime("TOTTime","TOTTime",D0flav);
//TOTTime.addPdf(TOTsigD0,"D0");
//TOTTime.addPdf(TOTsigantiD0,"antiD0");
RooTimepdf TOTsigD023("TOTsigD023","TOTsigD023",d0Lifetime,m2Kpi_d0mass,mass13a,gm,&dalitzSpace,tau,c1,c2,-1,dirname);
//////////////////////////
// BACKGROUND
/////////////////////////
//Mistag parametrization
m2Kpi_d0mass.setBins(150);
m2Kpi0_d0mass.setBins(150);
m2pipi0_d0mass.setBins(150);
d0Lifetime.setBins(70);
TH3F *mis_h = m2Kpi_d0mass.createHistogram("mis_h",m2Kpi0_d0mass,d0Lifetime,"");
RSdata->fillHistogram(mis_h,RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass,d0Lifetime));
mis_h->Sumw2();
RooDataHist *mis_hist = new RooDataHist("mis_hist","mis_hist",RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass,d0Lifetime),mis_h);
RooHistPdf Tot_mis("Tot_mis","Tot_mis",RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass,d0Lifetime),*mis_hist);
TH3F *mis_h23 = m2Kpi_d0mass.createHistogram("mis_h",m2pipi0_d0mass,d0Lifetime,"");
RSdata->fillHistogram(mis_h23,RooArgList(m2Kpi_d0mass,m2pipi0_d0mass,d0Lifetime));
mis_h23->Sumw2();
RooDataHist *mis_hist23 = new RooDataHist("mis_hist23","mis_hist23",RooArgList(m2Kpi_d0mass,m2pipi0_d0mass,d0Lifetime),mis_h23);
RooHistPdf Tot_mis23("Tot_mis23","Tot_mis23",RooArgList(m2Kpi_d0mass,m2pipi0_d0mass,d0Lifetime),*mis_hist23);
m2Kpi_d0mass.setBins(10);
m2Kpi0_d0mass.setBins(10);
m2pipi0_d0mass.setBins(10);
d0Lifetime.setBins(8);
d0LifetimeErr.setBins(10);
RooArgSet observ(d0Lifetime,m2Kpi_d0mass,m2Kpi0_d0mass);
RooArgSet observ23(d0Lifetime,m2Kpi_d0mass,m2pipi0_d0mass);
RooArgSet tot_var(d0Lifetime,m2Kpi_d0mass,m2Kpi0_d0mass,d0LifetimeErr);
//combinatoric
RooDataSet *leftdata = (RooDataSet*)dataWS_2->reduce("d0Mass > 1.75 && d0Mass < 1.77");
RooDataSet *rightdata = (RooDataSet*)dataWS_2->reduce("d0Mass > 1.95 && d0Mass < 1.97");
RooDataSet *bkgdata = (RooDataSet*)dataWS_2->reduce("d0Mass > 1.95 || d0Mass < 1.77");
rightdata->setWeightVar(0);
leftdata->setWeightVar(0);
TH3F *lefth = m2Kpi_d0mass.createHistogram("lefth",m2Kpi0_d0mass,d0Lifetime,"");
leftdata->fillHistogram(lefth,RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass,d0Lifetime));
TH3F *righth = m2Kpi_d0mass.createHistogram("righth",m2Kpi0_d0mass,d0Lifetime,"");
rightdata->fillHistogram(righth,RooArgList(m2Kpi_d0mass,m2Kpi0_d0mass,d0Lifetime));
righth->Scale(lefth->Integral()/righth->Integral());