using namespace RooStats; using namespace RooFit; void poissonRuns(){ int nruns; int nON_tot=0; int nOFF_tot=0; double tON_tot=0; double tOFF_tot=0; double Q_tot=0; ifstream fin("data.txt"); fin>>nruns; int *runsID=new int[nruns]; int *nON=new int[nruns]; int *nOFF=new int[nruns]; double *tON=new double[nruns]; double *tOFF=new double[nruns]; double *Q=new double[nruns]; double *Qf=new double[nruns]; double *tR=new double[nruns]; //Toff-over-Ton ratio int m_nON,m_nOFF,m_run; double m_tON,m_tOFF,m_Q; int nruns_good=0; for (int ii=0;ii>m_run>>m_nON>>m_nOFF>>m_tON>>m_tOFF>>m_Q; if (m_Q!=0){ runsID[nruns_good]=m_run; nON[nruns_good]=(int)(m_nOFF*m_tON/m_tOFF); //A.C. nOFF[nruns_good]=m_nOFF; tON[nruns_good]=m_tON; tOFF[nruns_good]=m_tOFF; Q[nruns_good]=m_Q; tR[nruns_good]=tOFF[nruns_good]/tON[nruns_good]; //totals nON_tot+=nON[nruns_good]; nOFF_tot+=nOFF[nruns_good]; tON_tot+=tON[nruns_good]; tOFF_tot+=tOFF[nruns_good]; Q_tot+=Q[nruns_good]; nruns_good++; } } for (int ii=0;iisetVal(nOFF[ii]); w.var(Form("nb_%i",ii))->setConstant(true);//needed for being treated as global observables } //Set the observed nON observables for (int ii=0;iisetVal(nON[ii]); } //make data set with the namber of observed nsb events RooArgList nsb_obs("nsb_obs"); RooArgList nb_obs("nb_obs"); RooArgList b_obs("b_obs"); for (int ii=0;iiGetParametersOfInterest()->first(); poi->setVal(0); bModel->SetSnapshot(*poi); mc.Print(); cout<<"---------"<Print(); // import model in the workspace cout<<"Import MC"<setVal(nON_tot); // make data set with the namber of observed events RooDataSet data_tot("data_tot","",RooArgSet(*nsb_tot,nb_tot)); data_tot.add(RooArgSet(*nsb_tot,nb_tot)); w2.import(data_tot); w2.Print(); ModelConfig mc_tot("Smodel_tot",&w2); mc_tot.SetPdf(*w2.pdf("model_tot")); mc_tot.SetParametersOfInterest(*w2.var("s_tot")); mc_tot.SetObservables(RooArgList(*w2.var("nsb_tott"),*w2.var("nb_tot"))); // these are needed for the hypothesis tests mc_tot.SetSnapshot(*w2.var("s_tot")); mc_tot.SetNuisanceParameters(*w2.var("b_tot")); //construct the B hypo (s=0) RooStats::ModelConfig* bModel_tot = (RooStats::ModelConfig*) mc_tot.Clone("Bmodel_tot") ; RooRealVar* poi_tot = (RooRealVar*) bModel_tot->GetParametersOfInterest()->first(); poi_tot->setVal(0); bModel_tot->SetSnapshot(*poi_tot); mc_tot.Print(); cout<<"---------"<Print(); // import model in the workspace w2.import(mc_tot); w2.import(*bModel_tot); TString fileName = "poissonRuns.out_separate.root"; // write workspace in the file (recreate file if already existing) w.writeToFile(fileName, true); TString fileName_tot = "poissonRuns.out_tot.root"; // write workspace in the file (recreate file if already existing) w2.writeToFile(fileName_tot, true); }