コード例 #1
0
void UL_significance_Hybrid(Model* model,int n_toys,int random_seed=0,double sig=1){
  cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
  cout<<"Calculating significance with the Hybrid method"<<endl;
  cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
  
  //set the random seed
  RooRandom::randomGenerator()->SetSeed(random_seed);
    
   //get the calculator
  HybridCalculatorOriginal myhc(*model->get_data(),*model->get_sb_likelihood(),*model->get_b_likelihood());
  
  //for numbercounting experiments
  myhc.PatchSetExtended(false);
  
  //set likelihood ratio as the test statistics
  myhc.SetTestStatistic(1);
  
  //define the systematics to be used
  if (model->get_nuisance_set()) {
    myhc.UseNuisance(true);
    myhc.SetNuisancePdf(*model->get_nuisance_prior_pdf());
    myhc.SetNuisanceParameters(*model->get_nuisance_set());
  } else {
    myhc.UseNuisance(false);                            
  }
  
  //define the number of toys to be done
  myhc.SetNumberOfToys(n_toys);

  //RooArgSet* poi= model->get_POI_set();
  //  poi->first()->Set(sig);
  RooRealVar* firstPOI = (RooRealVar*) model->get_POI_set()->first();
  firstPOI->setVal(sig);

  //get the Hypotestresult
  HybridResult* hcResult = myhc.GetHypoTest();
  double significance = hcResult->Significance();
  double CLS= hcResult->CLs();
  double CLB= hcResult->CLb();
  double CLsplusb= hcResult->CLsplusb();
  double CLSerror= hcResult->CLsError(); 
  



  cout<<"POI: "<<sig<<endl;
  cout <<"significance:" << significance<<endl;
  cout<<"CLs: "<<CLS<<endl;
  cout<<"CLb: "<<CLB<<endl;
  cout<<"CLsplusb: "<<CLsplusb<<endl;
  cout<<"CLserror: "<<CLSerror<<endl;

  HybridPlot* plot=hcResult->GetPlot("hcPlot","p Values Plot",100);
  TCanvas *c1=new TCanvas;
  plot->Draw();
  c1->SaveAs("hybrid_REsult");
  
}