Skip to content

Commit 1df3a9f

Browse files
guitargeekanigamova
authored andcommitted
Remove optional hiding of constants and constraints
Originally added in 2019 by @gpetrucc in #576. I quote that PR: ``` It is possible that already setting maskChannels=2 and SIMNLL_GROUPCONSTRAINTS=N make the gain from hideConstant and maskConstraints redundant in practice but I haven't tested since I developed them in the order they're listed here. ``` I think this is indeed the case. Maybe it would be good to check if removing these options indeed has relevant effect on performance, because reducing the number of these RooFit hacks helps to converge between Combine and upstream RooFit.
1 parent a3c4cd6 commit 1df3a9f

File tree

4 files changed

+1
-32
lines changed

4 files changed

+1
-32
lines changed

docs/part3/nonstandard.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,6 @@ As expected, the curve obtained by allowing the `pdf_index` to float (labelled "
568568

569569
In general, the performance of <span style="font-variant:small-caps;">Combine</span> can be improved when using the discrete profiling method by including the option `--X-rtd MINIMIZER_freezeDisassociatedParams`. This will stop parameters not associated to the current PDF from floating in the fits. Additionally, you can include the following options:
570570

571-
- `--X-rtd MINIMIZER_multiMin_hideConstants`: hide the constant terms in the likelihood when recreating the minimizer
572-
- `--X-rtd MINIMIZER_multiMin_maskConstraints`: hide the constraint terms during the discrete minimization process
573571
- `--X-rtd MINIMIZER_multiMin_maskChannels=<choice>` mask the channels that are not needed from the NLL:
574572
- `<choice> 1`: keeps unmasked all channels that are participating in the discrete minimization.
575573
- `<choice> 2`: keeps unmasked only the channel whose index is being scanned at the moment.

interface/CachingNLL.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,6 @@ class CachingSimNLL : public RooAbsReal {
182182
static void forceUnoptimizedConstraints() { optimizeContraints_ = false; }
183183
void setChannelMasks(RooArgList const& args);
184184
void setAnalyticBarlowBeeston(bool flag);
185-
void setHideConstants(bool flag) { hideConstants_ = flag; }
186-
void setMaskConstraints(bool flag) ;
187185
void setMaskNonDiscreteChannels(bool mask) ;
188186
friend class CachingAddNLL;
189187
// trap this call, since we don't care about propagating it to the sub-components
@@ -194,7 +192,6 @@ class CachingSimNLL : public RooAbsReal {
194192
const RooAbsData *dataOriginal_;
195193
const RooArgSet *nuis_;
196194
RooSetProxy params_, catParams_;
197-
bool hideConstants_ = false;
198195
RooArgSet piecesForCloning_;
199196
std::unique_ptr<RooSimultaneous> factorizedPdf_;
200197
std::vector<RooAbsPdf *> constrainPdfs_;
@@ -214,7 +211,6 @@ class CachingSimNLL : public RooAbsReal {
214211
std::vector<double> constrainZeroPointsFastPoisson_;
215212
std::vector<RooAbsReal*> channelMasks_;
216213
std::vector<bool> internalMasks_;
217-
bool maskConstraints_ = false;
218214
RooArgSet activeParameters_, activeCatParameters_;
219215
double maskingOffset_ = 0; // offset to ensure that interal or constraint masking doesn't change NLL value
220216
double maskingOffsetZero_ = 0; // and associated zero point

src/CachingNLL.cc

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,7 @@ cacheutils::CachingSimNLL::CachingSimNLL(const CachingSimNLL &other, const char
838838
nuis_(other.nuis_),
839839
params_("params","parameters",this),
840840
catParams_("catParams","Category parameters",this),
841-
hideConstants_(other.hideConstants_),
842841
internalMasks_(other.internalMasks_),
843-
maskConstraints_(other.maskConstraints_),
844842
maskingOffset_(other.maskingOffset_),
845843
maskingOffsetZero_(other.maskingOffsetZero_)
846844
{
@@ -1047,7 +1045,7 @@ cacheutils::CachingSimNLL::evaluate() const
10471045
ret += nllval;
10481046
}
10491047
}
1050-
if (!maskConstraints_ && (!constrainPdfs_.empty() || !constrainPdfsFast_.empty() || !constrainPdfsFastPoisson_.empty() || !constrainPdfGroups_.empty())) {
1048+
if (!constrainPdfs_.empty() || !constrainPdfsFast_.empty() || !constrainPdfsFastPoisson_.empty() || !constrainPdfGroups_.empty()) {
10511049
DefaultAccumulator<double> ret2 = 0;
10521050
/// ============= GENERIC CONSTRAINTS =========
10531051
for (std::size_t i = 0; i < constrainPdfs_.size(); ++i) {
@@ -1244,7 +1242,6 @@ cacheutils::CachingSimNLL::getParameters(const RooArgSet* depList, Bool_t stripD
12441242
ret = new RooArgSet(activeParameters_);
12451243
ret->add(activeCatParameters_);
12461244
}
1247-
if (hideConstants_) RooStats::RemoveConstantParameters(ret);
12481245
return ret;
12491246
}
12501247
#else
@@ -1259,20 +1256,10 @@ bool cacheutils::CachingSimNLL::getParameters(const RooArgSet* depList,
12591256
outputSet.add(activeParameters_);
12601257
outputSet.add(activeCatParameters_);
12611258
}
1262-
if (hideConstants_) RooStats::RemoveConstantParameters(&outputSet);
12631259
return true;
12641260
}
12651261
#endif
12661262

1267-
void cacheutils::CachingSimNLL::setMaskConstraints(bool flag) {
1268-
double nllBefore = evaluate();
1269-
maskConstraints_ = flag;
1270-
double nllAfter = evaluate();
1271-
maskingOffset_ += (nllBefore - nllAfter);
1272-
//printf("CachingSimNLL: setMaskConstraints(%d): nll before %.12g, nll after %.12g (diff %.12g), new maskingOffset %.12g, check = %.12g\n",
1273-
// int(flag), nllBefore, nllAfter, (nllBefore-nllAfter), maskingOffset_, evaluate() - nllBefore);
1274-
}
1275-
12761263
void cacheutils::CachingSimNLL::setMaskNonDiscreteChannels(bool mask) {
12771264
double nllBefore = evaluate();
12781265
internalMasks_.clear(); // reset

src/CascadeMinimizer.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,6 @@ bool CascadeMinimizer::minimize(int verbose, bool cascade)
515515

516516
bool CascadeMinimizer::multipleMinimize(const RooArgSet &reallyCleanParameters, bool& ret, double& minimumNLL, int verbose, bool cascade,int mode, std::vector<std::vector<bool> >&contributingIndeces){
517517
static bool freezeDisassParams = runtimedef::get(std::string("MINIMIZER_freezeDisassociatedParams"));
518-
static bool hideConstants = freezeDisassParams && runtimedef::get(std::string("MINIMIZER_multiMin_hideConstants"));
519-
static bool maskConstraints = freezeDisassParams && runtimedef::get(std::string("MINIMIZER_multiMin_maskConstraints"));
520518
static int maskChannels = freezeDisassParams ? runtimedef::get(std::string("MINIMIZER_multiMin_maskChannels")) : 0;
521519
cacheutils::CachingSimNLL *simnll = dynamic_cast<cacheutils::CachingSimNLL *>(&nll_);
522520

@@ -583,11 +581,6 @@ bool CascadeMinimizer::multipleMinimize(const RooArgSet &reallyCleanParameters,
583581
if (maskChannels && simnll) {
584582
simnll->setMaskNonDiscreteChannels(true);
585583
}
586-
if (hideConstants && simnll) {
587-
simnll->setHideConstants(true);
588-
if (maskConstraints) simnll->setMaskConstraints(true);
589-
minimizer_.reset(); // will be recreated when needed by whoever needs it
590-
}
591584

592585
std::vector<std::vector<int> > myCombos;
593586

@@ -725,11 +718,6 @@ bool CascadeMinimizer::multipleMinimize(const RooArgSet &reallyCleanParameters,
725718
if (maskChannels && simnll) {
726719
simnll->setMaskNonDiscreteChannels(false);
727720
}
728-
if (hideConstants && simnll) {
729-
simnll->setHideConstants(false);
730-
if (maskConstraints) simnll->setMaskConstraints(false);
731-
minimizer_.reset(); // will be recreated when needed by whoever needs it
732-
}
733721

734722

735723
return newDiscreteMinimum;

0 commit comments

Comments
 (0)