#include "RooRealVar.h" #include "RooDataSet.h" #include #include "RooFormulaVar.h" #include "RooAddPdf.h" #include "RooExponential.h" #include "RooGaussModel.h" #include "TCanvas.h" #include "TAxis.h" #include "RooPlot.h" #include "TTree.h" #include "TCut.h" #include "TMath.h" #include "TFile.h" #include "TCanvas.h" #include "RooHist.h" #include "RooGenericPdf.h" #include "RooTruthModel.h" #include "RooGaussian.h" #include "RooDecay.h" #include "RooProdPdf.h" #include "RooCBShape.h" #include "RooEffProd.h" #include "iostream" #include #include #include "iomanip" #include "RooFitResult.h" #include "RooGamma.h" using namespace std; using namespace RooFit; void testweight(){ TFile* smalltree_f=new TFile("Reduced_small-bskkMc.root"); TTree* reduced_tree = (TTree*)smalltree_f->Get("events"); double events_0 = 0; Double_t m_t, tau_t,m,tau,treco_t,trecoe_t; Int_t chan_t,chan; reduced_tree->SetBranchAddress("m",&m_t); reduced_tree->SetBranchAddress("treco", &treco_t); reduced_tree->SetBranchAddress("chan", &chan_t); double entries = reduced_tree->GetEntries(); RooRealVar* mass=new RooRealVar("mass","M(B^{0}_{s})[GeV/c^{2}]",4.9,5.9); RooRealVar* treco3d=new RooRealVar("treco3d","t_{reco}[ps]",1.5,12.5) ; RooRealVar* trecoe3d=new RooRealVar("trecoe3d","terr[ps]",0.013,0.26); RooRealVar* Weight=new RooRealVar("Weight"," Weight",0,1E5); RooArgList varlist(*mass,*treco3d); varlist.add(*Weight); RooDataSet* datap=new RooDataSet("datap","ntple candidates",varlist , "Weight"); vector yields, counts; double scale_factor=0.156; for (int j = 0; j < entries; j++) { reduced_tree->GetEntry(j); if (m_t < 4.90 || m_t > 5.90) continue; // skip outside range if(chan_t==0){ events_0++; } } counts.push_back(events_0); yields.push_back(scale_factor); cout<<"count"<GetEntry(j); if (m_t < 4.90 || m_t > 5.90) continue; // skip outside range if (chan_t != 0)continue; if(treco_t<1.5)continue; mass->setVal(m_t); treco3d->setVal(treco_t); Weight->setVal(1); Weight->setVal(yields[0] / counts[0]); datap->add(varlist, Weight->getVal()); } cout<<"entry "<numEntries()<<" weight "<sumEntries()<fitTo(*datap,Save(),Minos()); fitp->Print(); RooPlot* pmase=treco3d->frame(Title(" peak treco"),Bins(40)); datap->plotOn(pmase); decay_peak1->plotOn(pmase); pmase->Draw(); }