void MakeSpinPlots::getFitValues(TString tag,TString mcName){ std::cout << tag << std::endl; //Data_RSG125_FULLFIT_Nsig double sig = ws->var(Form("Data_%s_FULLFIT_Nsig",mcName.Data()))->getVal(); double sige = ws->var(Form("Data_%s_FULLFIT_Nsig",mcName.Data()))->getError(); double fsig = ws->var(Form("Data_%s_FULLFIT_%s_fsig",mcName.Data(),tag.Data()))->getVal(); std::cout << sig*fsig << " +- " << sige*fsig <<std::endl; //double bkg = ws->var(Form("Data_%s_FULLFIT_Nbkg",mcName.Data()))->getVal(); //double bkge = ws->var(Form("Data_%s_FULLFIT_Nbkg",mcName.Data()))->getError(); double bkg = ws->var(Form("Data_%s_FULLFIT_%s_Nbkg",mcName.Data(),tag.Data()))->getVal(); double bkge = ws->var(Form("Data_%s_FULLFIT_%s_Nbkg",mcName.Data(),tag.Data()))->getError(); //std::cout << bkg*fbkg << " +- " << bkge*fbkg <<std::endl; double mean = ws->var(Form("%s_FIT_%s_mean",mcName.Data(),tag.Data()))->getVal(); double meane= ws->var(Form("%s_FIT_%s_mean",mcName.Data(),tag.Data()))->getError(); std::cout << mean << " +- " << meane <<std::endl; double sigEff = ws->var(Form("%s_FIT_%s_sigmaEff",mcName.Data(),tag.Data()))->getVal(); double sigEffE = 0; std::cout << sigEff << " +- " << sigEffE <<std::endl; //Data_BKGFIT_EB_0_bkgModel RooAbsPdf * bkgPdf = ws->pdf(Form("Data_BKGFIT_%s_bkgModel",tag.Data())); std::cout << bkgPdf <<std::endl; RooRealVar range("range","",mean-sigEff,mean+sigEff); RooRealVar all("all","",ws->var("mass")->getMin(),ws->var("mass")->getMax()); double BkgInRange = bkgPdf->createIntegral(range)->getVal()/bkgPdf->createIntegral(all)->getVal()*bkg; double BkgInRangeE = bkgPdf->createIntegral(range)->getVal()/bkgPdf->createIntegral(all)->getVal()*bkge; tPair lbl(mcName,tag); nSignal[lbl] = dPair(sig*fsig,sige*fsig); nBackground[lbl] = dPair(bkg,bkge); fitMean[lbl] = dPair(mean,meane); fitSigEff[lbl] = dPair(sigEff,sigEffE); fitBkg1Sigma[lbl] = dPair(BkgInRange,BkgInRangeE); }
RooDataSet * getDataAndFrac(TString name, TString q2name, TreeReader * mydata, TCut cut, RooRealVar * MM, double * frac, Str2VarMap jpsiPars, double *outnsig) { RooRealVar * cosThetaL = new RooRealVar("cosThetaL","cosThetaL",0.,-1.,1.); RooRealVar * cosThetaB = new RooRealVar("cosThetaB","cosThetaB",0.,-1.,1.); TCut massCut = "Lb_MassConsLambda > 5590 && Lb_MassConsLambda < 5650"; Analysis * ana = new Analysis(name+"_mass"+q2name,"Lb",mydata,&cut,MM); ana->AddVariable("J_psi_1S_MM"); ana->AddVariable(cosThetaL); ana->AddVariable(cosThetaB); RooAbsPdf * mysig = stringToPdf("Gauss","sig",MM,jpsiPars); RooAbsPdf * mybkg = stringToPdf("Exp","bkgM",MM); RooRealVar * mynsig = new RooRealVar("mynsig","mynsig",50,0,100000); RooRealVar * mynbkg = new RooRealVar("mynbkg","mynbkg",10,0,100000); RooAbsPdf * Mmodel = new RooAddPdf("MassModel","MassModel",RooArgSet(*mysig,*mybkg),RooArgSet(*mynsig,*mynbkg)); ana->applyCuts(&cut); RooDataSet * data = ana->GetDataSet("-recalc"); Mmodel->fitTo(*data,Extended(kTRUE)); double sigBkg = mybkg->createIntegral(*MM,NormSet(*MM),Range("Signal"))->getVal(); double sig = mysig->createIntegral(*MM,NormSet(*MM),Range("Signal"))->getVal(); double nsig = mynsig->getVal(); double nbkg = mynbkg->getVal(); if(frac) { frac[0] = nsig*sig/(nsig*sig+nbkg*sigBkg); frac[1] = frac[0]*TMath::Sqrt( TMath::Power(mynsig->getError()/nsig,2) + TMath::Power(mynbkg->getError()/nbkg,2) ); } TCut mycut = cut + massCut; ana->applyCuts(&mycut); TCanvas * cc = new TCanvas(); GetFrame(MM,Mmodel,data,"-nochi2-plotAllComp",30,NULL,0,"cos#theta_{#Lambda}")->Draw(); cc->Print("M_"+name+"_"+q2name+".pdf"); if(*outnsig) *outnsig = nsig; return ana->GetDataSet("-recalc"); }
double NormalizedIntegral(RooAbsPdf & function, RooRealVar & integrationVar, double lowerLimit, double upperLimit){ integrationVar.setRange("integralRange",lowerLimit,upperLimit); RooAbsReal* integral = function.createIntegral(integrationVar,NormSet(integrationVar),Range("integralRange")); double normlizedIntegralValue = integral->getVal(); // cout<<normlizedIntegralValue<<endl; return normlizedIntegralValue; }