77int AsymptoticCalculator::fgPrintLevel = 1;
86void AsymptoticCalculator::SetPrintLevel(
int level) {
98 fOneSided(false), fOneSidedDiscovery(false), fNominalAsimov(nominalAsimov),
100 fNLLObs(0), fNLLAsimov(0),
109 assert(nullSnapshot);
115 oocoutI(
nullptr,
InputArguments) <<
"AsymptotiCalculator: Minimum of POI is " << muNull->
getMin() <<
" corresponds to null snapshot - default configuration is one-sided discovery formulae " << std::endl;
135 oocoutP(
nullptr,
Eval) <<
"AsymptoticCalculator::Initialize...." << std::endl;
140 oocoutE(
nullptr,
InputArguments) <<
"AsymptoticCalculator::Initialize - ModelConfig has not a pdf defined" << std::endl;
145 oocoutE(
nullptr,
InputArguments) <<
"AsymptoticCalculator::Initialize - data set has not been defined" << std::endl;
153 if (!poi || poi->
empty()) {
154 oocoutE(
nullptr,
InputArguments) <<
"AsymptoticCalculator::Initialize - ModelConfig has not POI defined." << endl;
157 if (poi->
size() > 1) {
158 oocoutW(
nullptr,
InputArguments) <<
"AsymptoticCalculator::Initialize - ModelConfig has more than one POI defined \n\t"
159 <<
"The asymptotic calculator works for only one POI - consider as POI only the first parameter"
166 if(nullSnapshot ==
nullptr || nullSnapshot->
empty()) {
167 oocoutE(
nullptr,
InputArguments) <<
"AsymptoticCalculator::Initialize - Null model needs a snapshot. Set using modelconfig->SetSnapshot(poi)." << endl;
190 oocoutP(
nullptr,
Eval) <<
"AsymptoticCalculator::Initialize - Find best unconditional NLL on observed data" << endl;
204 if(altSnapshot ==
nullptr || altSnapshot->
empty()) {
205 oocoutE(
nullptr,
InputArguments) <<
"Alt (Background) model needs a snapshot. Set using modelconfig->SetSnapshot(poi)." << endl;
211 oocoutP(
nullptr,
Eval) <<
"AsymptoticCalculator: Building Asimov data Set" << endl;
225 <<
" set the same data bins " <<
data.numEntries() <<
" in range "
226 <<
" [ " << xobs->
getMin() <<
" , " << xobs->
getMax() <<
" ]" << std::endl;
234 oocoutI(
nullptr,
InputArguments) <<
"AsymptoticCalculator: Asimov data will be generated using fitted nuisance parameter values" << endl;
242 oocoutI(
nullptr,
InputArguments) <<
"AsymptoticCalculator: Asimovdata set will be generated using nominal (current) nuisance parameter values" << endl;
243 nominalParams.
assign(poiAlt);
248 oocoutE(
nullptr,
InputArguments) <<
"AsymptoticCalculator: Error : Asimov data set could not be generated " << endl;
270 oocoutP(
nullptr,
Eval) <<
"AsymptoticCalculator::Initialize Find best conditional NLL on ASIMOV data set for given alt POI ( " <<
279 globObs.
assign(globObsSnapshot);
282 if (prevBins > 0 && xobs) xobs->
setBins(prevBins);
303 if (condObs) conditionalObs.
add(*condObs);
305 if (globObs) globalObs.
add(*globObs);
317 if (poiSet && !poiSet->
empty()) {
323 paramsSetConstant.
add(*poiVar);
325 if (poiSet->
size() > 1)
326 std::cout <<
"Model with more than one POI are not supported - ignore extra parameters, consider only first one" << std::endl;
355 bool skipFit = (nllParams.
empty());
370 tol = std::max(tol,1.0);
380 std::cout <<
"AsymptoticCalculator::EvaluateNLL ........ using " << minimizer <<
" / " << algorithm
381 <<
" with strategy " << strategy <<
" and tolerance " << tol << std::endl;
384 for (
int tries = 1, maxtries = 4; tries <= maxtries; ++tries) {
386 status = minim.
minimize(minimizer, algorithm);
392 printf(
" ----> Doing a re-scan first\n");
397 printf(
" ----> trying with strategy = 1\n");
404 printf(
" ----> trying with improve\n");
405 minimizer =
"Minuit";
406 algorithm =
"migradimproved";
429 oocoutE(
nullptr,
Fitting) <<
"FIT FAILED !- return a NaN NLL " << std::endl;
441 std::cout <<
"AsymptoticCalculator::EvaluateNLL - value = " << val;
444 std::cout <<
" for poi fixed at = " << muTest;
447 std::cout <<
"\tfit time : ";
451 std::cout << std::endl;
481 oocoutE(
nullptr,
InputArguments) <<
"AsymptoticCalculator::GetHypoTest - Error initializing Asymptotic calculator - return nullptr result " << endl;
487 oocoutE(
nullptr,
InputArguments) <<
"AsymptoticCalculator::GetHypoTest - Asimov data set has not been generated - return nullptr result " << endl;
500 assert(nullSnapshot && !nullSnapshot->
empty());
506 if (poiTest.
size() > 1) {
507 oocoutW(
nullptr,
InputArguments) <<
"AsymptoticCalculator::GetHypoTest: snapshot has more than one POI - assume as POI first parameter " << std::endl;
517 assert(muHat &&
"no best fit parameter defined");
519 assert(muTest &&
"poi snapshot is not existing");
524 std::cout << std::endl;
525 oocoutI(
nullptr,
Eval) <<
"AsymptoticCalculator::GetHypoTest: - perform an hypothesis test for POI ( " << muTest->
GetName() <<
" ) = " << muTest->
getVal() << std::endl;
526 oocoutP(
nullptr,
Eval) <<
"AsymptoticCalculator::GetHypoTest - Find best conditional NLL on OBSERVED data set ..... " << std::endl;
532 double qmu = 2.*(condNLL -
fNLLObs);
537 oocoutP(
nullptr,
Eval) <<
"\t OBSERVED DATA : qmu = " << qmu <<
" condNLL = " << condNLL <<
" uncond " <<
fNLLObs << std::endl;
545 oocoutW(
nullptr,
Minimization) <<
"AsymptoticCalculator: Found a negative value of the qmu - retry to do the unconditional fit "
548 oocoutW(
nullptr,
Minimization) <<
"AsymptoticCalculator: unconditional fit failed before - retry to do it now "
555 oocoutW(
nullptr,
Minimization) <<
"AsymptoticCalculator: Found a better unconditional minimum "
556 <<
" old NLL = " <<
fNLLObs <<
" old muHat " << muHat->
getVal() << std::endl;
569 <<
" NLL = " <<
fNLLObs <<
" muHat " << muHat->
getVal() << std::endl;
575 oocoutP(
nullptr,
Eval) <<
"After unconditional refit, new qmu value is " << qmu << std::endl;
582 << muTest->
getVal() <<
" return a dummy result "
587 oocoutE(
nullptr,
Minimization) <<
"AsymptoticCalculator: failure in fitting for qmu or qmuA "
588 << muTest->
getVal() <<
" return a dummy result "
612 if (
verbose > 0)
oocoutP(
nullptr,
Eval) <<
"AsymptoticCalculator::GetHypoTest -- Find best conditional NLL on ASIMOV data set .... " << std::endl;
620 oocoutP(
nullptr,
Eval) <<
"\t ASIMOV data qmu_A = " << qmu_A <<
" condNLL = " << condNLL_A <<
" uncond " <<
fNLLAsimov << std::endl;
625 oocoutW(
nullptr,
Minimization) <<
"AsymptoticCalculator: Found a negative value of the qmu Asimov- retry to do the unconditional fit "
628 oocoutW(
nullptr,
Minimization) <<
"AsymptoticCalculator: Fit failed for unconditional the qmu Asimov- retry unconditional fit "
635 oocoutW(
nullptr,
Minimization) <<
"AsymptoticCalculator: Found a better unconditional minimum for Asimov data set"
646 oocoutP(
nullptr,
Eval) <<
"After unconditional Asimov refit, new qmu_A value is " << qmu_A << std::endl;
653 << muTest->
getVal() <<
" return a dummy result "
658 oocoutE(
nullptr,
Minimization) <<
"AsymptoticCalculator: failure in fitting for qmu or qmuA "
659 << muTest->
getVal() <<
" return a dummy result "
666 globObs.
assign(globObsSnapshot);
678 bool useQTilde =
false;
689 oocoutI(
nullptr,
InputArguments) <<
"Minimum of POI is " << muTest->
getMin() <<
" corresponds to alt snapshot - using qtilde asymptotic formulae " << std::endl;
693 <<
" - using standard q asymptotic formulae " << std::endl;
703 oocoutI(
nullptr,
Eval) <<
"Using one-sided qmu - setting qmu to zero muHat = " << muHat->
getVal()
704 <<
" muTest = " << muTest->
getVal() << std::endl;
710 oocoutI(
nullptr,
Eval) <<
"Using one-sided discovery qmu - setting qmu to zero muHat = " << muHat->
getVal()
711 <<
" muTest = " << muTest->
getVal() << std::endl;
717 if (qmu < 0 && qmu > -tol) qmu = 0;
718 if (qmu_A < 0 && qmu_A > -tol) qmu_A = 0;
725 double pnull = -1, palt = -1;
730 double sqrtqmu = (qmu > 0) ?
std::sqrt(qmu) : 0;
731 double sqrtqmu_A = (qmu_A > 0) ?
std::sqrt(qmu_A) : 0;
738 oocoutI(
nullptr,
Eval) <<
"Using one-sided limit asymptotic formula (qmu)" << endl;
740 oocoutI(
nullptr,
Eval) <<
"Using one-sided discovery asymptotic formula (q0)" << endl;
747 if (
verbose > 2)
oocoutI(
nullptr,
Eval) <<
"Using two-sided asymptotic formula (tmu)" << endl;
757 if ( qmu > qmu_A && (qmu_A > 0 || qmu > tol) ) {
758 if (
verbose > 2)
oocoutI(
nullptr,
Eval) <<
"Using qmu_tilde (qmu is greater than qmu_A)" << endl;
766 if ( qmu > qmu_A && (qmu_A > 0 || qmu > tol) ) {
767 if (
verbose > 2)
oocoutI(
nullptr,
Eval) <<
"Using tmu_tilde (qmu is greater than qmu_A)" << endl;
779 string resultname =
"HypoTestAsymptotic_result";
785 <<
"poi = " << muTest->
getVal() <<
" qmu = " << qmu <<
" qmu_A = " << qmu_A
786 <<
" sigma = " << muTest->
getVal()/sqrtqmu_A
787 <<
" CLsplusb = " << pnull <<
" CLb = " << palt <<
" CLs = " << res->
CLs() << std::endl;
795 fOffset(
offset), fPval(pval), fCase(icase) {}
812 if (!useCls)
return clsplusb;
814 return (clb == 0) ? -1 : clsplusb / clb;
829 bool ret = brf.
Solve();
831 oocoutE(
nullptr,
Eval) <<
"Error finding expected p-values - return -1" << std::endl;
834 double sqrttmu_A = brf.
Root();
842 oocoutE(
nullptr,
Eval) <<
"Error finding expected p-values - return -1" << std::endl;
869 if (debug) cout <<
"looping on observable " <<
v->GetName() << endl;
870 for (
int i = 0; i <
v->getBins(); ++i) {
874 double prevBinVolume = binVolume;
875 binVolume *=
v->getBinWidth(i);
878 binVolume = prevBinVolume;
883 double totBinVolume = binVolume *
v->getBinWidth(i);
884 double fval = pdf.
getVal(&obstmp)*totBinVolume;
887 if (fval*expectedEvents <= 0)
889 if (fval*expectedEvents < 0) {
891 <<
"AsymptoticCalculator::" << __func__
892 <<
"(): Detected a bin with negative expected events! Please check your inputs." << endl;
896 <<
"AsymptoticCalculator::" << __func__
897 <<
"(): Detected a bin with zero expected events- skip it" << endl;
902 data.add(obs, fval*expectedEvents);
905 cout <<
"bin " << ibin <<
"\t";
906 for (
int j=0; j < obs.
getSize(); ++j) { cout <<
" " << ((
RooRealVar&) obs[j]).getVal(); }
907 cout <<
" w = " << fval*expectedEvents;
918 cout <<
"ending loop on .. " <<
v->GetName() << endl;
932 if (!
a->dependsOn(obs))
continue;
938 }
else if ((gaus =
dynamic_cast<RooGaussian *
>(
a)) != 0) {
947 <<
"Illegal term in counting model: "
949 <<
" depends on the observables, but is not a Poisson, Gaussian or Product"
976 oocoutF(
nullptr,
Generation) <<
"AsymptoticCalculator::SetObsExpected( " << pdfName <<
" ) : Has two observables ?? " << endl;
981 oocoutF(
nullptr,
Generation) <<
"AsymptoticCalculator::SetObsExpected( " << pdfName <<
" ) : Observable is not a RooRealVar??" << endl;
985 if (!
a->isConstant() ) {
987 oocoutE(
nullptr,
Generation) <<
"AsymptoticCalculator::SetObsExpected( " << pdfName <<
" ) : Has two non-const arguments " << endl;
992 oocoutF(
nullptr,
Generation) <<
"AsymptoticCalculator::SetObsExpected( " << pdfName <<
" ) : Expected is not a RooAbsReal??" << endl;
999 oocoutF(
nullptr,
Generation) <<
"AsymptoticCalculator::SetObsExpected( " << pdfName <<
" ) : No observable?" << endl;
1003 oocoutF(
nullptr,
Generation) <<
"AsymptoticCalculator::SetObsExpected( " << pdfName <<
" ) : No observable?" << endl;
1010 std::cout <<
"SetObsToExpected : setting " << myobs->
GetName() <<
" to expected value " << myexp->
getVal() <<
" of " << myexp->
GetName() << std::endl;
1028 std::cout <<
"generate counting Asimov data for pdf of type " << pdf.
ClassName() << std::endl;
1033 }
else if ((pois =
dynamic_cast<RooPoisson *
>(&pdf)) != 0) {
1037 }
else if ((gaus =
dynamic_cast<RooGaussian *
>(&pdf)) != 0) {
1040 oocoutE(
nullptr,
InputArguments) <<
"A counting model pdf must be either a RooProdPdf or a RooPoisson or a RooGaussian" << endl;
1049 std::string(
"CountingAsimovData") + std::to_string(icat), obs);
1072 obsAndWeight.
add(weightVar);
1077 asimovData =
new RooDataSet(std::string(
"AsimovData") + std::to_string(icat),
1078 std::string(
"combAsimovData") + std::to_string(icat),
1090 if (printLevel >= 2) {
1091 cout <<
"Generating Asimov data for pdf " << pdf.
GetName() << endl;
1092 cout <<
"list of observables " << endl;
1097 double binVolume = 1;
1099 FillBins(pdf, obsList, *asimovData, obsIndex, binVolume, nbins);
1100 if (printLevel >= 2)
1101 cout <<
"filled from " << pdf.
GetName() <<
" " << nbins <<
" nbins " <<
" volume is " << binVolume << endl;
1119 if (printLevel >= 1)
1121 asimovData->
Print();
1125 cout <<
"sum entries is nan"<<endl;
1143 unique_ptr<RooRealVar> weightVar (
new RooRealVar(
"binWeightAsimov",
"binWeightAsimov", 1, 0, 1.E30 ));
1145 if (printLevel > 1) cout <<
" Generate Asimov data for observables"<<endl;
1153 std::map<std::string, RooDataSet*> asimovDataMap;
1157 int nrIndices = channelCat.
numTypes();
1158 if( nrIndices == 0 ) {
1159 oocoutW(
nullptr,
Generation) <<
"Simultaneous pdf does not contain any categories." << endl;
1161 for (
int i=0;i<nrIndices;i++){
1166 assert(pdftmp != 0);
1176 if (!dataSinglePdf) {
1183 <<
" was already defined. It will be overridden. The faulty category definitions follow:" << endl;
1184 channelCat.
Print(
"V");
1192 dataSinglePdf->
Print();
1198 obsAndWeight.
add(*weightVar);
1204 for (
auto &element : asimovDataMap) {
1205 delete element.second;
1234 for (
auto *tmpPar : static_range_cast<RooRealVar *>(poi)) {
1235 tmpPar->setConstant();
1237 std::cout <<
"MakeAsimov: Setting poi " << tmpPar->
GetName() <<
" to a constant value = " << tmpPar->getVal() << std::endl;
1238 paramsSetConstant.
add(*tmpPar);
1242 bool hasFloatParams =
false;
1247 if (!constrainParams.
empty()) hasFloatParams =
true;
1252 for (
auto const *rrv : dynamic_range_cast<RooRealVar *>(*params)) {
1253 if ( rrv != 0 && rrv->isConstant() ==
false ) { hasFloatParams =
true;
break; }
1256 if (hasFloatParams) {
1262 std::cout <<
"MakeAsimov: doing a conditional fit for finding best nuisance values " << std::endl;
1265 std::cout <<
"POI values:\n"; poi.
Print(
"v");
1267 std::cout <<
"Nuis param values:\n";
1268 constrainParams.
Print(
"v");
1281 std::vector<RooCmdArg> args;
1293 for (
auto& arg : args) {
1297 if (
verbose>0) { std::cout <<
"fit time "; tw2.
Print();}
1301 std::cout <<
"Nuisance parameters after fit for asimov dataset: " << std::endl;
1319 allParams->
assign(*genPoiValues);
1350 if (!allParamValues.
empty()) {
1352 allVars->
assign(allParamValues);
1361 std::cout <<
"Generated Asimov data for observables "; (model.
GetObservables() )->
Print();
1364 std::cout <<
"--- Asimov data values \n";
1368 std::cout <<
"--- Asimov data numEntries = " << asimov->
numEntries() <<
" sumOfEntries = " << asimov->
sumEntries() << std::endl;
1370 std::cout <<
"\ttime for generating : "; tw.
Print();
1390 std::cout <<
"Generating Asimov data for global observables " << std::endl;
1404 oocoutW(
nullptr,
Generation) <<
"AsymptoticCalculator::MakeAsimovData: model does not have nuisance parameters but has global observables"
1405 <<
" set global observables to model values " << endl;
1406 asimovGlobObs.
assign(gobs);
1412 if (nuispdf.get() == 0) {
1413 oocoutF(
nullptr,
Generation) <<
"AsymptoticCalculator::MakeAsimovData: model has nuisance parameters and global obs but no nuisance pdf "
1424 pdfList.
add(*nuispdf.get());
1426 for (
auto *cterm : static_range_cast<RooAbsPdf *>(pdfList)) {
1428 "AsimovUtils: a factor of the nuisance pdf is not a Pdf!");
1430 if (!cterm->dependsOn(nuis))
continue;
1432 if (
typeid(*cterm) ==
typeid(
RooUniform))
continue;
1434 std::unique_ptr<RooArgSet> cpars(cterm->getParameters(&gobs));
1435 std::unique_ptr<RooArgSet> cgobs(cterm->getObservables(&gobs));
1436 if (cgobs->size() > 1) {
1437 oocoutE(
nullptr,
Generation) <<
"AsymptoticCalculator::MakeAsimovData: constraint term " << cterm->GetName()
1438 <<
" has multiple global observables -cannot generate - skip it" << std::endl;
1441 else if (cgobs->empty()) {
1443 <<
"AsymptoticCalculator::MakeAsimovData: constraint term " << cterm->GetName()
1444 <<
" has no global observables - skip it" << std::endl;
1452 if (cpars->size() != 1) {
1454 <<
"AsymptoticCalculator::MakeAsimovData:constraint term "
1455 << cterm->GetName() <<
" has multiple floating params - cannot generate - skip it " << std::endl;
1459 bool foundServer =
false;
1463 if (
verbose > 2) std::cout <<
"Constraint " << cterm->
GetName() <<
" of type " << cClass->
GetName() << std::endl;
1469 <<
"AsymptoticCalculator::MakeAsimovData:constraint term "
1470 << cterm->GetName() <<
" of type " << className
1471 <<
" is a non-supported type - result might be not correct " << std::endl;
1489 <<
"AsymptoticCalculator::MakeAsimovData:constraint term "
1490 << cterm->GetName() <<
" has no direct dependence on global observable- cannot generate it " << std::endl;
1501 RooFIter itc(cterm->serverMIterator() );
1508 if (thetaGamma == 0) {
1510 <<
"AsymptoticCalculator::MakeAsimovData:constraint term "
1511 << cterm->GetName() <<
" is a Gamma distribution and no server named theta is found. Assume that the Gamma scale is 1 " << std::endl;
1515 std::cout <<
"Gamma constraint has a scale " << thetaGamma->
GetName() <<
" = " << thetaGamma->
getVal() << std::endl;
1518 RooFIter iter2(cterm->serverMIterator() );
1521 if (
verbose > 2) std::cout <<
"Loop on constraint server term " << a2->
GetName() << std::endl;
1527 oocoutE(
nullptr,
Generation) <<
"AsymptoticCalculator::MakeAsimovData:constraint term "
1528 << cterm->GetName() <<
" constraint term has more server depending on nuisance- cannot generate it " <<
1530 foundServer =
false;
1533 if (thetaGamma && thetaGamma->
getVal() > 0)
1540 std::cout <<
"setting global observable "<< rrv.
GetName() <<
" to value " << rrv.
getVal()
1541 <<
" which comes from " << rrv2->
GetName() << std::endl;
1546 oocoutE(
nullptr,
Generation) <<
"AsymptoticCalculator::MakeAsimovData - can't find nuisance for constraint term - global observables will not be set to Asimov value " << cterm->GetName() << std::endl;
1547 std::cerr <<
"Parameters: " << std::endl;
1549 std::cerr <<
"Observables: " << std::endl;
1563 gobs.
assign(snapGlobalObsData);
1566 std::cout <<
"Generated Asimov data for global observables ";
1571 std::cout <<
"\nGlobal observables for data: " << std::endl;
1573 std::cout <<
"\nGlobal observables for asimov: " << std::endl;
1574 asimovGlobObs.
Print(
"V");
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
TRObject operator()(const T1 &t1) const
Class for finding the root of a one dimensional function using the Brent algorithm.
bool SetFunction(const ROOT::Math::IGenFunction &f, double xlow, double xup) override
Sets the function for the rest of the algorithms.
bool Solve(int maxIter=100, double absTol=1E-8, double relTol=1E-10) override
Returns the X value corresponding to the function value fy for (xmin<x<xmax).
double Root() const override
Returns root value.
static int DefaultPrintLevel()
static double DefaultTolerance()
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...
void Print(Option_t *options=nullptr) const override
Print the object to the defaultPrintStream().
bool dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=nullptr, bool valueOnly=false) const
Test whether we depend on (ie, are served by) any object in the specified collection.
bool isConstant() const
Check if the "Constant" attribute is set.
RooArgSet * getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
RooFIter serverMIterator() const
RooArgSet * getVariables(bool stripDisconnected=true) 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...
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 *=nullptr) const
Return number of types defined (in range named rangeName if rangeName!=nullptr)
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
bool contains(const RooAbsArg &var) const
Check if collection contains an argument with the same name as var.
Int_t getSize() const
Return the number of elements in the collection.
const char * GetName() const override
Returns name of object.
virtual bool add(const RooAbsArg &var, bool silent=false)
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...
Storage_t::size_type size() const
RooAbsArg * first() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual double sumEntries() const =0
Return effective number of entries in dataset, i.e., sum all weights.
virtual const RooArgSet * get() const
void Print(Option_t *options=nullptr) const override
Print TNamed name and title.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
virtual double expectedEvents(const RooArgSet *nset) const
Return expected number of events to be used in calculation of extended likelihood.
virtual RooAbsReal * createNLL(RooAbsData &data, const RooLinkedList &cmdList={})
Construct representation of -log(L) of PDF with given dataset.
virtual RooFitResult * fitTo(RooAbsData &data, const RooLinkedList &cmdList={})
Fit PDF to given dataset.
bool canBeExtended() const
If true, PDF can provide extended likelihood term.
virtual Int_t getBins(const char *name=nullptr) const
Get number of bins of currently defined range.
void setConstant(bool value=true)
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
static void setHideOffset(bool flag)
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.
bool setIndex(Int_t index, bool printError=true) override
Set value by specifying the index code of the desired state.
value_type getCurrentIndex() const final
Return current index.
RooDataSet is a container class to hold unbinned data.
double sumEntries() const override
Return effective number of entries in dataset, i.e., sum all weights.
void add(const RooArgSet &row, double weight, double weightError)
Add one ore more rows of data.
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.
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 optimizeConst(int flag)
If flag is true, perform constant term optimization on function being minimized.
RooFitResult * save(const char *name=nullptr, const char *title=nullptr)
Save and return a RooFitResult snapshot of current minimizer status.
void setEvalErrorWall(bool flag)
void setEps(double eps)
Change MINUIT epsilon.
void setPrintLevel(int newLevel)
Change the MINUIT internal printing level.
int minimize(const char *type, const char *alg=nullptr)
Minimise the function passed in the constructor.
void setStrategy(int 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=true)
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 setVal(double value) override
Set value of variable to 'value'.
void setBins(Int_t nBins, const char *name=nullptr)
Create a uniform binning under name 'name' for this variable.
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
RooAbsPdf * getPdf(RooStringView catName) const
Return the p.d.f associated with the given index category name.
const RooAbsCategoryLValue & indexCat() const
Hypothesis Test Calculator based on the asymptotic formulae for the profile likelihood ratio.
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 int fgPrintLevel
control print level (0 minimal, 1 normal, 2 debug)
static bool SetObsToExpected(RooAbsPdf &pdf, const RooArgSet &obs)
set observed value to the expected one works for Gaussian, Poisson or LogNormal assumes mean paramete...
RooArgSet fAsimovGlobObs
snapshot of Asimov global observables
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...
int fUseQTilde
flag to indicate if using qtilde or not (-1 (default based on RooRealVar)), 0 false,...
static RooAbsData * GenerateAsimovDataSinglePdf(const RooAbsPdf &pdf, const RooArgSet &obs, const RooRealVar &weightVar, RooCategory *channelCat=nullptr)
Compute the asimov data set for an observable of a pdf.
bool fIsInitialized
! flag to check if calculator is initialized
static double EvaluateNLL(RooAbsPdf &pdf, RooAbsData &data, const RooArgSet *condObs, const RooArgSet *globObs, const RooArgSet *poiSet=nullptr)
HypoTestResult * GetHypoTest() const override
re-implement HypoTest computation using the asymptotic
bool fOneSided
for one sided PL test statistic (upper limits)
RooArgSet fBestFitParams
snapshot of all best fitted Parameter values
AsymptoticCalculator(RooAbsData &data, const ModelConfig &altModel, const ModelConfig &nullModel, bool nominalAsimov=false)
constructor for asymptotic calculator from Data set and ModelConfig
static RooAbsData * GenerateCountingAsimovData(RooAbsPdf &pdf, const RooArgSet &obs, const RooRealVar &weightVar, RooCategory *channelCat=nullptr)
Generate counting Asimov data for the case when the pdf cannot be extended.
bool fOneSidedDiscovery
for one sided PL test statistic (for discovery)
RooAbsData * fAsimovData
asimov data set
RooArgSet fBestFitPoi
snapshot of best fitted POI values
static RooAbsData * MakeAsimovData(RooAbsData &data, const ModelConfig &model, const RooArgSet &poiValues, RooArgSet &globObs, const RooArgSet *genPoiValues=nullptr)
Make Asimov data.
static void FillBins(const RooAbsPdf &pdf, const RooArgList &obs, RooAbsData &data, int &index, double &binVolume, int &ibin)
fill bins by looping recursively on observables
bool fNominalAsimov
make Asimov at nominal parameter values
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 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 nullptr if not existing)
const RooArgSet * GetGlobalObservables() const
get RooArgSet for global observables (return nullptr if not existing)
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return nullptr if not existing)
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return nullptr if not existing)
const RooArgSet * GetObservables() const
get RooArgSet for observables (return nullptr if not existing)
const RooArgSet * GetSnapshot() const
get RooArgSet for parameters for a particular hypothesis (return nullptr if not existing)
RooAbsPdf * GetPdf() const
get model PDF (return nullptr if pdf has not been specified or does not exist)
TClass instances represent classes, structs and namespaces in the ROOT type system.
TClass * IsA() const override
const char * GetName() const override
Returns name of object.
virtual const char * GetName() const
Returns name of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Print(Option_t *option="") const override
Print the real and cpu time passed between the start and stop events.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
RooCmdArg Index(RooCategory &icat)
RooCmdArg WeightVar(const char *name="weight", bool reinterpretAsWeight=false)
RooCmdArg Import(const char *state, TH1 &histo)
RooCmdArg Offset(std::string const &mode)
RooCmdArg Constrain(const RooArgSet ¶ms)
RooCmdArg Minimizer(const char *type, const char *alg=nullptr)
RooCmdArg Hesse(bool flag=true)
RooCmdArg Strategy(Int_t code)
RooCmdArg GlobalObservables(Args_t &&... argsOrArgSet)
RooCmdArg EvalErrorWall(bool flag)
RooCmdArg PrintLevel(Int_t code)
RooCmdArg CloneData(bool flag)
RooCmdArg ConditionalObservables(Args_t &&... argsOrArgSet)
Create a RooCmdArg to declare conditional observables.
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...
void Print(std::ostream &os, const OptionType &opt)
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
MsgLevel
Verbosity level for RooMsgService::StreamConfig in RooMsgService.
Namespace for the RooStats classes.
bool SetAllConstant(const RooAbsCollection &coll, bool constant=true)
utility function to set all variable constant in a collection (from G.
void RemoveConstantParameters(RooArgSet *set)
RooAbsPdf * MakeNuisancePdf(RooAbsPdf &pdf, const RooArgSet &observables, const char *name)
extract constraint terms from pdf
RooStatsConfig & GetGlobalRooStatsConfig()
Retrieve the config object which can be used to set flags for things like offsetting the likelihood o...
bool IsNLLOffset()
function returning if the flag to check if the flag to use NLLOffset is set
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754.
PaltFunction(double offset, double pval, int icase)