99 fOneSided(false), fOneSidedDiscovery(false), fNominalAsimov(nominalAsimov),
101 fNLLObs(0), fNLLAsimov(0),
110 assert(nullSnapshot);
116 oocoutI((
TObject*)0,InputArguments) <<
"AsymptotiCalculator: Minimum of POI is " << muNull->
getMin() <<
" corresponds to null snapshot - default configuration is one-sided discovery formulae " << std::endl;
136 oocoutP((
TObject*)0,Eval) <<
"AsymptoticCalculator::Initialize...." << std::endl;
141 oocoutE((
TObject*)0,InputArguments) <<
"AsymptoticCalculator::Initialize - ModelConfig has not a pdf defined" << std::endl;
146 oocoutE((
TObject*)0,InputArguments) <<
"AsymptoticCalculator::Initialize - data set has not been defined" << std::endl;
154 if (!poi || poi->
getSize() == 0) {
155 oocoutE((
TObject*)0,InputArguments) <<
"AsymptoticCalculator::Initialize - ModelConfig has not POI defined." << endl;
159 oocoutW((
TObject*)0,InputArguments) <<
"AsymptoticCalculator::Initialize - ModelConfig has more than one POI defined \n\t"
160 <<
"The asymptotic calculator works for only one POI - consider as POI only the first parameter"
167 if(nullSnapshot == NULL || nullSnapshot->
getSize() == 0) {
168 oocoutE((
TObject*)0,InputArguments) <<
"AsymptoticCalculator::Initialize - Null model needs a snapshot. Set using modelconfig->SetSnapshot(poi)." << endl;
191 oocoutP((
TObject*)0,Eval) <<
"AsymptoticCalculator::Initialize - Find best unconditional NLL on observed data" << endl;
205 if(altSnapshot == NULL || altSnapshot->
getSize() == 0) {
206 oocoutE((
TObject*)0,InputArguments) <<
"Alt (Background) model needs a snapshot. Set using modelconfig->SetSnapshot(poi)." << endl;
212 oocoutP((
TObject*)0,Eval) <<
"AsymptoticCalculator: Building Asimov data Set" << endl;
222 if (data.IsA() == RooDataHist::Class() ) {
225 oocoutW((
TObject*)0,InputArguments) <<
"AsymptoticCalculator: number of bins in " << xobs->
GetName() <<
" are different than data bins "
226 <<
" set the same data bins " << data.
numEntries() <<
" in range "
227 <<
" [ " << xobs->
getMin() <<
" , " << xobs->
getMax() <<
" ]" << std::endl;
235 oocoutI((
TObject*)0,InputArguments) <<
"AsymptoticCalculator: Asimov data will be generated using fitted nuisance parameter values" << endl;
243 oocoutI((
TObject*)0,InputArguments) <<
"AsymptoticCalculator: Asimovdata set will be generated using nominal (current) nuisance parameter values" << endl;
244 nominalParams.
assign(poiAlt);
249 oocoutE((
TObject*)0,InputArguments) <<
"AsymptoticCalculator: Error : Asimov data set could not be generated " << endl;
271 oocoutP((
TObject*)0,Eval) <<
"AsymptoticCalculator::Initialize Find best conditional NLL on ASIMOV data set for given alt POI ( " <<
280 globObs.
assign(globObsSnapshot);
283 if (prevBins > 0 && xobs) xobs->
setBins(prevBins);
304 if (condObs) conditionalObs.
add(*condObs);
306 if (globObs) globalObs.
add(*globObs);
318 if (poiSet && poiSet->
getSize() > 0) {
324 paramsSetConstant.
add(*poiVar);
327 std::cout <<
"Model with more than one POI are not supported - ignore extra parameters, consider only first one" << std::endl;
356 bool skipFit = (nllParams.
getSize() == 0);
363 int minimPrintLevel = verbose;
371 tol = std::max(tol,1.0);
381 std::cout <<
"AsymptoticCalculator::EvaluateNLL ........ using " << minimizer <<
" / " << algorithm
382 <<
" with strategy " << strategy <<
" and tolerance " << tol << std::endl;
385 for (
int tries = 1, maxtries = 4; tries <= maxtries; ++tries) {
387 status = minim.
minimize(minimizer, algorithm);
393 printf(
" ----> Doing a re-scan first\n");
398 printf(
" ----> trying with strategy = 1\n");
405 printf(
" ----> trying with improve\n");
406 minimizer =
"Minuit";
407 algorithm =
"migradimproved";
416 result = minim.
save();
430 oocoutE((
TObject*)0,Fitting) <<
"FIT FAILED !- return a NaN NLL " << std::endl;
435 if (result)
delete result;
442 std::cout <<
"AsymptoticCalculator::EvaluateNLL - value = " << val;
445 std::cout <<
" for poi fixed at = " << muTest;
448 std::cout <<
"\tfit time : ";
452 std::cout << std::endl;
482 oocoutE((
TObject*)0,InputArguments) <<
"AsymptoticCalculator::GetHypoTest - Error initializing Asymptotic calculator - return NULL result " << endl;
488 oocoutE((
TObject*)0,InputArguments) <<
"AsymptoticCalculator::GetHypoTest - Asimov data set has not been generated - return NULL result " << endl;
501 assert(nullSnapshot && nullSnapshot->
getSize() > 0);
508 oocoutW((
TObject*)0,InputArguments) <<
"AsymptoticCalculator::GetHypoTest: snapshot has more than one POI - assume as POI first parameter " << std::endl;
518 assert(muHat &&
"no best fit parameter defined");
520 assert(muTest &&
"poi snapshot is not existing");
525 std::cout << std::endl;
526 oocoutI((
TObject*)0,Eval) <<
"AsymptoticCalculator::GetHypoTest: - perform an hypothesis test for POI ( " << muTest->
GetName() <<
" ) = " << muTest->
getVal() << std::endl;
527 oocoutP((
TObject*)0,Eval) <<
"AsymptoticCalculator::GetHypoTest - Find best conditional NLL on OBSERVED data set ..... " << std::endl;
533 double qmu = 2.*(condNLL -
fNLLObs);
538 oocoutP((
TObject*)0,Eval) <<
"\t OBSERVED DATA : qmu = " << qmu <<
" condNLL = " << condNLL <<
" uncond " <<
fNLLObs << std::endl;
546 oocoutW((
TObject*)0,Minimization) <<
"AsymptoticCalculator: Found a negative value of the qmu - retry to do the unconditional fit "
549 oocoutW((
TObject*)0,Minimization) <<
"AsymptoticCalculator: unconditional fit failed before - retry to do it now "
556 oocoutW((
TObject*)0,Minimization) <<
"AsymptoticCalculator: Found a better unconditional minimum "
557 <<
" old NLL = " <<
fNLLObs <<
" old muHat " << muHat->
getVal() << std::endl;
569 oocoutW((
TObject*)0,Minimization) <<
"AsymptoticCalculator: New minimum found for "
570 <<
" NLL = " <<
fNLLObs <<
" muHat " << muHat->
getVal() << std::endl;
576 oocoutP((
TObject*)0,Eval) <<
"After unconditional refit, new qmu value is " << qmu << std::endl;
582 oocoutE((
TObject*)0,Minimization) <<
"AsymptoticCalculator: qmu is still < 0 for mu = "
583 << muTest->
getVal() <<
" return a dummy result "
588 oocoutE((
TObject*)0,Minimization) <<
"AsymptoticCalculator: failure in fitting for qmu or qmuA "
589 << muTest->
getVal() <<
" return a dummy result "
613 if (verbose > 0)
oocoutP((
TObject*)0,Eval) <<
"AsymptoticCalculator::GetHypoTest -- Find best conditional NLL on ASIMOV data set .... " << std::endl;
621 oocoutP((
TObject*)0,Eval) <<
"\t ASIMOV data qmu_A = " << qmu_A <<
" condNLL = " << condNLL_A <<
" uncond " <<
fNLLAsimov << std::endl;
626 oocoutW((
TObject*)0,Minimization) <<
"AsymptoticCalculator: Found a negative value of the qmu Asimov- retry to do the unconditional fit "
629 oocoutW((
TObject*)0,Minimization) <<
"AsymptoticCalculator: Fit failed for unconditional the qmu Asimov- retry unconditional fit "
636 oocoutW((
TObject*)0,Minimization) <<
"AsymptoticCalculator: Found a better unconditional minimum for Asimov data set"
642 oocoutW((
TObject*)0,Minimization) <<
"AsymptoticCalculator: New minimum found for "
647 oocoutP((
TObject*)0,Eval) <<
"After unconditional Asimov refit, new qmu_A value is " << qmu_A << std::endl;
653 oocoutE((
TObject*)0,Minimization) <<
"AsymptoticCalculator: qmu_A is still < 0 for mu = "
654 << muTest->
getVal() <<
" return a dummy result "
659 oocoutE((
TObject*)0,Minimization) <<
"AsymptoticCalculator: failure in fitting for qmu or qmuA "
660 << muTest->
getVal() <<
" return a dummy result "
667 globObs.
assign(globObsSnapshot);
679 bool useQTilde =
false;
690 oocoutI((
TObject*)0,InputArguments) <<
"Minimum of POI is " << muTest->
getMin() <<
" corresponds to alt snapshot - using qtilde asymptotic formulae " << std::endl;
693 oocoutI((
TObject*)0,InputArguments) <<
"Minimum of POI is " << muTest->
getMin() <<
" is different to alt snapshot " << muAlt->
getVal()
694 <<
" - using standard q asymptotic formulae " << std::endl;
704 oocoutI((
TObject*)0,Eval) <<
"Using one-sided qmu - setting qmu to zero muHat = " << muHat->
getVal()
705 <<
" muTest = " << muTest->
getVal() << std::endl;
711 oocoutI((
TObject*)0,Eval) <<
"Using one-sided discovery qmu - setting qmu to zero muHat = " << muHat->
getVal()
712 <<
" muTest = " << muTest->
getVal() << std::endl;
718 if (qmu < 0 && qmu > -tol) qmu = 0;
719 if (qmu_A < 0 && qmu_A > -tol) qmu_A = 0;
726 double pnull = -1, palt = -1;
731 double sqrtqmu = (qmu > 0) ? std::sqrt(qmu) : 0;
732 double sqrtqmu_A = (qmu_A > 0) ? std::sqrt(qmu_A) : 0;
739 oocoutI((
TObject*)0,Eval) <<
"Using one-sided limit asymptotic formula (qmu)" << endl;
741 oocoutI((
TObject*)0,Eval) <<
"Using one-sided discovery asymptotic formula (q0)" << endl;
748 if (verbose > 2)
oocoutI((
TObject*)0,Eval) <<
"Using two-sided asymptotic formula (tmu)" << endl;
758 if ( qmu > qmu_A && (qmu_A > 0 || qmu > tol) ) {
759 if (verbose > 2)
oocoutI((
TObject*)0,Eval) <<
"Using qmu_tilde (qmu is greater than qmu_A)" << endl;
767 if ( qmu > qmu_A && (qmu_A > 0 || qmu > tol) ) {
768 if (verbose > 2)
oocoutI((
TObject*)0,Eval) <<
"Using tmu_tilde (qmu is greater than qmu_A)" << endl;
780 string resultname =
"HypoTestAsymptotic_result";
786 <<
"poi = " << muTest->
getVal() <<
" qmu = " << qmu <<
" qmu_A = " << qmu_A
787 <<
" sigma = " << muTest->
getVal()/sqrtqmu_A
788 <<
" CLsplusb = " << pnull <<
" CLb = " << palt <<
" CLs = " << res->
CLs() << std::endl;
796 fOffset(offset), fPval(pval), fCase(icase) {}
813 if (!useCls)
return clsplusb;
815 return (clb == 0) ? -1 : clsplusb / clb;
830 bool ret = brf.
Solve();
832 oocoutE((
TObject*)0,Eval) <<
"Error finding expected p-values - return -1" << std::endl;
835 double sqrttmu_A = brf.
Root();
843 oocoutE((
TObject*)0,Eval) <<
"Error finding expected p-values - return -1" << std::endl;
870 if (debug) cout <<
"looping on observable " <<
v->GetName() << endl;
871 for (
int i = 0; i <
v->getBins(); ++i) {
873 if (index < obs.
getSize() -1) {
875 double prevBinVolume = binVolume;
876 binVolume *=
v->getBinWidth(i);
877 FillBins(pdf, obs, data, index, binVolume, ibin);
879 binVolume = prevBinVolume;
884 double totBinVolume = binVolume *
v->getBinWidth(i);
885 double fval = pdf.
getVal(&obstmp)*totBinVolume;
888 if (fval*expectedEvents <= 0)
890 if (fval*expectedEvents < 0) {
892 <<
"AsymptoticCalculator::" << __func__
893 <<
"(): Detected a bin with negative expected events! Please check your inputs." << endl;
897 <<
"AsymptoticCalculator::" << __func__
898 <<
"(): Detected a bin with zero expected events- skip it" << endl;
903 data.
add(obs, fval*expectedEvents);
906 cout <<
"bin " << ibin <<
"\t";
907 for (
int j=0; j < obs.
getSize(); ++j) { cout <<
" " << ((
RooRealVar&) obs[j]).getVal(); }
908 cout <<
" w = " << fval*expectedEvents;
919 cout <<
"ending loop on .. " <<
v->GetName() << endl;
934 if (!
a->dependsOn(obs))
continue;
940 }
else if ((gaus =
dynamic_cast<RooGaussian *
>(
a)) != 0) {
948 oocoutE((
TObject*)0,InputArguments) <<
"Illegal term in counting model: "
949 <<
"the PDF " <<
a->GetName()
950 <<
" depends on the observables, but is not a Poisson, Gaussian or Product"
972 const char * pdfName = pdf.IsA()->
GetName();
977 oocoutF((
TObject*)0,Generation) <<
"AsymptoticCalculator::SetObsExpected( " << pdfName <<
" ) : Has two observables ?? " << endl;
982 oocoutF((
TObject*)0,Generation) <<
"AsymptoticCalculator::SetObsExpected( " << pdfName <<
" ) : Observable is not a RooRealVar??" << endl;
986 if (!
a->isConstant() ) {
988 oocoutE((
TObject*)0,Generation) <<
"AsymptoticCalculator::SetObsExpected( " << pdfName <<
" ) : Has two non-const arguments " << endl;
993 oocoutF((
TObject*)0,Generation) <<
"AsymptoticCalculator::SetObsExpected( " << pdfName <<
" ) : Expected is not a RooAbsReal??" << endl;
1000 oocoutF((
TObject*)0,Generation) <<
"AsymptoticCalculator::SetObsExpected( " << pdfName <<
" ) : No observable?" << endl;
1004 oocoutF((
TObject*)0,Generation) <<
"AsymptoticCalculator::SetObsExpected( " << pdfName <<
" ) : No observable?" << endl;
1011 std::cout <<
"SetObsToExpected : setting " << myobs->
GetName() <<
" to expected value " << myexp->
getVal() <<
" of " << myexp->
GetName() << std::endl;
1029 std::cout <<
"generate counting Asimov data for pdf of type " << pdf.IsA()->
GetName() << std::endl;
1034 }
else if ((pois =
dynamic_cast<RooPoisson *
>(&pdf)) != 0) {
1038 }
else if ((gaus =
dynamic_cast<RooGaussian *
>(&pdf)) != 0) {
1041 oocoutE((
TObject*)0,InputArguments) <<
"A counting model pdf must be either a RooProdPdf or a RooPoisson or a RooGaussian" << endl;
1050 std::string(
"CountingAsimovData") + std::to_string(icat), obs);
1073 obsAndWeight.
add(weightVar);
1078 asimovData =
new RooDataSet(std::string(
"AsimovData") + std::to_string(icat),
1079 std::string(
"combAsimovData") + std::to_string(icat),
1091 if (printLevel >= 2) {
1092 cout <<
"Generating Asimov data for pdf " << pdf.
GetName() << endl;
1093 cout <<
"list of observables " << endl;
1098 double binVolume = 1;
1100 FillBins(pdf, obsList, *asimovData, obsIndex, binVolume, nbins);
1101 if (printLevel >= 2)
1102 cout <<
"filled from " << pdf.
GetName() <<
" " << nbins <<
" nbins " <<
" volume is " << binVolume << endl;
1120 if (printLevel >= 1)
1122 asimovData->
Print();
1126 cout <<
"sum entries is nan"<<endl;
1144 unique_ptr<RooRealVar> weightVar (
new RooRealVar(
"binWeightAsimov",
"binWeightAsimov", 1, 0, 1.E30 ));
1146 if (printLevel > 1) cout <<
" Generate Asimov data for observables"<<endl;
1154 std::map<std::string, RooDataSet*> asimovDataMap;
1158 int nrIndices = channelCat.
numTypes();
1159 if( nrIndices == 0 ) {
1160 oocoutW((
TObject*)0,Generation) <<
"Simultaneous pdf does not contain any categories." << endl;
1162 for (
int i=0;i<nrIndices;i++){
1167 assert(pdftmp != 0);
1177 if (!dataSinglePdf) {
1178 oocoutE((
TObject*)0,Generation) <<
"Error generating an Asimov data set for pdf " << pdftmp->
GetName() << endl;
1184 <<
" was already defined. It will be overridden. The faulty category definitions follow:" << endl;
1185 channelCat.
Print(
"V");
1193 dataSinglePdf->
Print();
1199 obsAndWeight.
add(*weightVar);
1205 for (
auto &element : asimovDataMap) {
1206 delete element.second;
1240 std::cout <<
"MakeAsimov: Setting poi " << tmpPar->
GetName() <<
" to a constant value = " << tmpPar->
getVal() << std::endl;
1241 paramsSetConstant.
add(*tmpPar);
1245 bool hasFloatParams =
false;
1250 if (constrainParams.
getSize() > 0) hasFloatParams =
true;
1258 if ( rrv != 0 && rrv->
isConstant() == false ) { hasFloatParams =
true;
break; }
1261 if (hasFloatParams) {
1267 std::cout <<
"MakeAsimov: doing a conditional fit for finding best nuisance values " << std::endl;
1268 minimPrintLevel = verbose;
1270 std::cout <<
"POI values:\n"; poi.
Print(
"v");
1272 std::cout <<
"Nuis param values:\n";
1273 constrainParams.
Print(
"v");
1287 std::vector<RooCmdArg> args;
1299 for (
auto& arg : args) {
1303 if (verbose>0) { std::cout <<
"fit time "; tw2.
Print();}
1307 std::cout <<
"Nuisance parameters after fit for asimov dataset: " << std::endl;
1325 allParams->
assign(*genPoiValues);
1356 if (allParamValues.
getSize() > 0) {
1358 allVars->
assign(allParamValues);
1367 std::cout <<
"Generated Asimov data for observables "; (model.
GetObservables() )->Print();
1370 std::cout <<
"--- Asimov data values \n";
1374 std::cout <<
"--- Asimov data numEntries = " << asimov->
numEntries() <<
" sumOfEntries = " << asimov->
sumEntries() << std::endl;
1376 std::cout <<
"\ttime for generating : "; tw.
Print();
1396 std::cout <<
"Generating Asimov data for global observables " << std::endl;
1410 oocoutW((
TObject*)0,Generation) <<
"AsymptoticCalculator::MakeAsimovData: model does not have nuisance parameters but has global observables"
1411 <<
" set global observables to model values " << endl;
1412 asimovGlobObs.
assign(gobs);
1418 if (nuispdf.get() == 0) {
1419 oocoutF((
TObject*)0,Generation) <<
"AsymptoticCalculator::MakeAsimovData: model has nuisance parameters and global obs but no nuisance pdf "
1430 pdfList.
add(*nuispdf.get());
1435 assert(cterm &&
"AsimovUtils: a factor of the nuisance pdf is not a Pdf!");
1438 if (
typeid(*cterm) ==
typeid(
RooUniform))
continue;
1440 std::unique_ptr<RooArgSet> cpars(cterm->
getParameters(&gobs));
1442 if (cgobs->getSize() > 1) {
1443 oocoutE((
TObject*)0,Generation) <<
"AsymptoticCalculator::MakeAsimovData: constraint term " << cterm->
GetName()
1444 <<
" has multiple global observables -cannot generate - skip it" << std::endl;
1447 else if (cgobs->getSize() == 0) {
1448 oocoutW((
TObject*)0,Generation) <<
"AsymptoticCalculator::MakeAsimovData: constraint term " << cterm->
GetName()
1449 <<
" has no global observables - skip it" << std::endl;
1457 if (cpars->getSize() != 1) {
1458 oocoutE((
TObject*)0,Generation) <<
"AsymptoticCalculator::MakeAsimovData:constraint term "
1459 << cterm->
GetName() <<
" has multiple floating params - cannot generate - skip it " << std::endl;
1463 bool foundServer =
false;
1466 TClass * cClass = cterm->IsA();
1467 if (verbose > 2) std::cout <<
"Constraint " << cterm->
GetName() <<
" of type " << cClass->
GetName() << std::endl;
1468 if ( cClass != RooGaussian::Class() && cClass != RooPoisson::Class() &&
1469 cClass != RooGamma::Class() && cClass != RooLognormal::Class() &&
1470 cClass != RooBifurGauss::Class() ) {
1472 oocoutW((
TObject*)0,Generation) <<
"AsymptoticCalculator::MakeAsimovData:constraint term "
1473 << cterm->
GetName() <<
" of type " << className
1474 <<
" is a non-supported type - result might be not correct " << std::endl;
1478 if (cClass == RooPoisson::Class() ) {
1490 if ( cClass != RooGamma::Class() ) {
1491 oocoutE((
TObject*)0,Generation) <<
"AsymptoticCalculator::MakeAsimovData:constraint term "
1492 << cterm->
GetName() <<
" has no direct dependence on global observable- cannot generate it " << std::endl;
1502 if ( cClass == RooGamma::Class() ) {
1510 if (thetaGamma == 0) {
1511 oocoutI((
TObject*)0,Generation) <<
"AsymptoticCalculator::MakeAsimovData:constraint term "
1512 << cterm->
GetName() <<
" is a Gamma distribution and no server named theta is found. Assume that the Gamma scale is 1 " << std::endl;
1516 std::cout <<
"Gamma constraint has a scale " << thetaGamma->
GetName() <<
" = " << thetaGamma->
getVal() << std::endl;
1522 if (verbose > 2) std::cout <<
"Loop on constraint server term " << a2->
GetName() << std::endl;
1528 oocoutE((
TObject*)0,Generation) <<
"AsymptoticCalculator::MakeAsimovData:constraint term "
1529 << cterm->
GetName() <<
" constraint term has more server depending on nuisance- cannot generate it " <<
1531 foundServer =
false;
1534 if (thetaGamma && thetaGamma->
getVal() > 0)
1541 std::cout <<
"setting global observable "<< rrv.
GetName() <<
" to value " << rrv.
getVal()
1542 <<
" which comes from " << rrv2->
GetName() << std::endl;
1547 oocoutE((
TObject*)0,Generation) <<
"AsymptoticCalculator::MakeAsimovData - can't find nuisance for constraint term - global observables will not be set to Asimov value " << cterm->
GetName() << std::endl;
1548 std::cerr <<
"Parameters: " << std::endl;
1550 std::cerr <<
"Observables: " << std::endl;
1564 gobs.
assign(snapGlobalObsData);
1567 std::cout <<
"Generated Asimov data for global observables ";
1568 if (verbose == 1) gobs.
Print();
1572 std::cout <<
"\nGlobal observables for data: " << std::endl;
1574 std::cout <<
"\nGlobal observables for asimov: " << std::endl;
1575 asimovGlobObs.
Print(
"V");
TRObject operator()(const T1 &t1) const
Class for finding the root of a one dimensional function using the Brent algorithm.
double Root() const
Returns root value.
bool Solve(int maxIter=100, double absTol=1E-8, double relTol=1E-10)
Returns the X value corresponding to the function value fy for (xmin<x<xmax).
bool SetFunction(const ROOT::Math::IGenFunction &f, double xlow, double xup)
Sets the function for the rest of the algorithms.
static int DefaultPrintLevel()
static double DefaultTolerance()
static const std::string & DefaultMinimizerType()
static const std::string & DefaultMinimizerAlgo()
static int DefaultStrategy()
Template class to wrap any C++ callable object which takes one argument i.e.
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Given a set of possible observables, return the observables that this PDF depends on.
Bool_t dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
Test whether we depend on (ie, are served by) any object in the specified collection.
virtual void Print(Option_t *options=0) const
Print the object to the defaultPrintStream().
RooFIter serverMIterator() const
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
RooArgSet * getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
Bool_t isConstant() const
Check if the "Constant" attribute is set.
RooAbsArg * findServer(const char *name) const
Return server of this with name name. Returns nullptr if not found.
virtual const char * getCurrentLabel() const
Return label string of current state.
Int_t numTypes(const char *=0) const
Return number of types defined (in range named rangeName if rangeName!=0)
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
Bool_t contains(const RooAbsArg &var) const
Check if collection contains an argument with the same name as var.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
RooAbsArg * first() const
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
RooLinkedListIter iterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual const RooArgSet * get() const
virtual Double_t sumEntries() const =0
Return effective number of entries in dataset, i.e., sum all weights.
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
virtual void add(const RooArgSet &row, Double_t weight=1, Double_t weightError=0)=0
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
virtual RooAbsReal * createNLL(RooAbsData &data, const RooLinkedList &cmdList)
Construct representation of -log(L) of PDFwith given dataset.
virtual RooFitResult * fitTo(RooAbsData &data, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none())
Fit PDF to given dataset.
Bool_t canBeExtended() const
If true, PDF can provide extended likelihood term.
virtual Double_t expectedEvents(const RooArgSet *nset) const
Return expected number of events to be used in calculation of extended likelihood.
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
virtual Int_t getBins(const char *name=0) const
Get number of bins of currently defined range.
void setConstant(Bool_t value=kTRUE)
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
static void setHideOffset(Bool_t flag)
static Bool_t hideOffset()
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
RooCategory is an object to represent discrete states.
virtual value_type getCurrentIndex() const override final
Return current index.
virtual Bool_t setIndex(Int_t index, bool printError=true) override
Set value by specifying the index code of the desired state.
RooDataSet is a container class to hold unbinned data.
virtual Double_t sumEntries() const override
Return effective number of entries in dataset, i.e., sum all weights.
virtual void add(const RooArgSet &row, Double_t weight=1.0, Double_t weightError=0) override
Add a data point, with its coordinates specified in the 'data' argset, to the data set.
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
RooAbsArg * next()
Return next element or nullptr if at end.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Double_t minNll() const
Return minimized -log(L) value.
A wrapper around TIterator derivatives.
TObject * Next() override
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
virtual void Add(TObject *arg)
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
void setEvalErrorWall(Bool_t flag)
RooFitResult * save(const char *name=0, const char *title=0)
Save and return a RooFitResult snapshot of current minimizer status.
Int_t minimize(const char *type, const char *alg=0)
Minimise the function passed in the constructor.
void setEps(Double_t eps)
Change MINUIT epsilon.
Int_t setPrintLevel(Int_t newLevel)
Change the MINUIT internal printing level.
void optimizeConst(Int_t flag)
If flag is true, perform constant term optimization on function being minimized.
void setStrategy(Int_t strat)
Change MINUIT strategy to istrat.
static RooMsgService & instance()
Return reference to singleton instance.
void setGlobalKillBelow(RooFit::MsgLevel level)
RooFit::MsgLevel globalKillBelow() const
void setNoRounding(bool flag=kTRUE)
Switch off/on rounding of x to the nearest integer.
RooProdPdf is an efficient implementation of a product of PDFs of the form.
const RooArgList & pdfList() const
RooRealVar represents a variable that can be changed from the outside.
void setBins(Int_t nBins, const char *name=0)
Create a uniform binning under name 'name' for this variable.
Double_t getError() const
virtual void setVal(Double_t value)
Set value of variable to 'value'.
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
const RooAbsCategoryLValue & indexCat() const
RooAbsPdf * getPdf(const char *catName) const
Return the p.d.f associated with the given index category name.
Hypothesis Test Calculator based on the asymptotic formulae for the profile likelihood ratio.
static RooAbsData * GenerateAsimovDataSinglePdf(const RooAbsPdf &pdf, const RooArgSet &obs, const RooRealVar &weightVar, RooCategory *channelCat=0)
Compute the asimov data set for an observable of a pdf.
virtual HypoTestResult * GetHypoTest() const
re-implement HypoTest computation using the asymptotic
static double GetExpectedPValues(double pnull, double palt, double nsigma, bool usecls, bool oneSided=true)
function given the null and the alt p value - return the expected one given the N - sigma value
static RooAbsData * MakeAsimovData(RooAbsData &data, const ModelConfig &model, const RooArgSet &poiValues, RooArgSet &globObs, const RooArgSet *genPoiValues=0)
Make Asimov data.
static bool SetObsToExpected(RooAbsPdf &pdf, const RooArgSet &obs)
set observed value to the expected one works for Gaussian, Poisson or LogNormal assumes mean paramete...
static void SetPrintLevel(int level)
set print level (static function)
static RooAbsData * GenerateAsimovData(const RooAbsPdf &pdf, const RooArgSet &observables)
generate the asimov data for the observables (not the global ones) need to deal with the case of a si...
static RooAbsData * GenerateCountingAsimovData(RooAbsPdf &pdf, const RooArgSet &obs, const RooRealVar &weightVar, RooCategory *channelCat=0)
Generate counting Asimov data for the case when the pdf cannot be extended.
int fUseQTilde
flag to check if calculator is initialized
AsymptoticCalculator(RooAbsData &data, const ModelConfig &altModel, const ModelConfig &nullModel, bool nominalAsimov=false)
constructor for asymptotic calculator from Data set and ModelConfig
static void FillBins(const RooAbsPdf &pdf, const RooArgList &obs, RooAbsData &data, int &index, double &binVolume, int &ibin)
fill bins by looping recursively on observables
static double EvaluateNLL(RooAbsPdf &pdf, RooAbsData &data, const RooArgSet *condObs, const RooArgSet *globObs, const RooArgSet *poiSet=0)
bool Initialize() const
initialize the calculator by performing a global fit and make the Asimov data set
Common base class for the Hypothesis Test Calculators.
const ModelConfig * GetNullModel(void) const
const ModelConfig * GetAlternateModel(void) const
const RooAbsData * GetData(void) const
HypoTestResult is a base class for results from hypothesis tests.
virtual Double_t CLs() const
is simply (not a method, but a quantity)
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
const RooArgSet * GetConditionalObservables() const
get RooArgSet for conditional observables (return NULL if not existing)
const RooArgSet * GetGlobalObservables() const
get RooArgSet for global observables (return NULL if not existing)
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return NULL if not existing)
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return NULL if not existing)
const RooArgSet * GetObservables() const
get RooArgSet for observables (return NULL if not existing)
const RooArgSet * GetSnapshot() const
get RooArgSet for parameters for a particular hypothesis (return NULL if not existing)
RooAbsPdf * GetPdf() const
get model PDF (return NULL if pdf has not been specified or does not exist)
TClass instances represent classes, structs and namespaces in the ROOT type system.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Print(Option_t *option="") const
Print the real and cpu time passed between the start and stop events.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
RooCmdArg WeightVar(const char *name, Bool_t reinterpretAsWeight=kFALSE)
RooCmdArg Index(RooCategory &icat)
RooCmdArg Import(const char *state, TH1 &histo)
RooCmdArg EvalErrorWall(Bool_t flag)
RooCmdArg Constrain(const RooArgSet ¶ms)
RooCmdArg Strategy(Int_t code)
RooCmdArg GlobalObservables(Args_t &&... argsOrArgSet)
RooCmdArg Hesse(Bool_t flag=kTRUE)
RooCmdArg CloneData(Bool_t flag)
RooCmdArg PrintLevel(Int_t code)
RooCmdArg Offset(Bool_t flag=kTRUE)
RooCmdArg ConditionalObservables(Args_t &&... argsOrArgSet)
Create a RooCmdArg to declare conditional observables.
RooCmdArg Minimizer(const char *type, const char *alg=0)
double normal_cdf_c(double x, double sigma=1, double x0=0)
Complement of the cumulative distribution function of the normal (Gaussian) distribution (upper tail)...
double normal_cdf(double x, double sigma=1, double x0=0)
Cumulative distribution function of the normal (Gaussian) distribution (lower tail).
double normal_quantile(double z, double sigma)
Inverse ( ) of the cumulative distribution function of the lower tail of the normal (Gaussian) distri...
double normal_quantile_c(double z, double sigma)
Inverse ( ) of the cumulative distribution function of the upper tail of the normal (Gaussian) distri...
MsgLevel
Verbosity level for RooMsgService::StreamConfig in RooMsgService.
Namespace for the RooStats classes.
bool SetAllConstant(const RooAbsCollection &coll, bool constant=true)
void RemoveConstantParameters(RooArgSet *set)
RooAbsPdf * MakeNuisancePdf(RooAbsPdf &pdf, const RooArgSet &observables, const char *name)
RooStatsConfig & GetGlobalRooStatsConfig()
Retrieve the config object which can be used to set flags for things like offsetting the likelihood o...
bool IsNLLOffset()
Test of RooStats should by default offset NLL calculations.
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754
PaltFunction(double offset, double pval, int icase)