Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions roofit/hs3/src/JSONFactories_HistFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1412,8 +1412,7 @@ class HistFactoryStreamer_ProdPdf : public RooFit::JSONIO::Exporter {
{
std::vector<RooAbsPdf *> constraints;
RooRealSumPdf *sumpdf = nullptr;
for (RooAbsArg *v : prodpdf->pdfList()) {
RooAbsPdf *pdf = static_cast<RooAbsPdf *>(v);
for (auto *pdf : static_range_cast<RooAbsPdf *>(prodpdf->pdfList())) {
auto thispdf = dynamic_cast<RooRealSumPdf *>(pdf);
if (thispdf) {
if (!sumpdf)
Expand Down
3 changes: 1 addition & 2 deletions roofit/hs3/src/JSONFactories_RooFitCore.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,7 @@ class ParamHistFuncFactory : public RooFit::JSONIO::Importer {

// Now build the final list following the order in varList
RooArgList vars;
for (int i = 0; i < varList.getSize(); ++i) {
const auto *refVar = dynamic_cast<RooRealVar *>(varList.at(i));
for (auto *refVar : dynamic_range_cast<RooRealVar *>(varList)) {
if (!refVar)
continue;

Expand Down
7 changes: 3 additions & 4 deletions roofit/roofit/src/RooJeffreysPrior.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ double RooJeffreysPrior::evaluate() const
auto& pdf = _nominal.arg();
RooAbsPdf* clonePdf = static_cast<RooAbsPdf*>(pdf.cloneTree());
std::unique_ptr<RooArgSet> vars{clonePdf->getParameters(_obsSet)};
for (auto varTmp : *vars) {
auto& var = static_cast<RooRealVar&>(*varTmp);
auto range = var.getRange();
for (auto* var : static_range_cast<RooRealVar*>(*vars)) {
auto range = var->getRange();
double span = range.second - range.first;
var.setRange(range.first - 0.1*span, range.second + 0.1 * span);
var->setRange(range.first - 0.1*span, range.second + 0.1 * span);
}

cacheElm = new CacheElem;
Expand Down
62 changes: 20 additions & 42 deletions roofit/roofit/src/RooLagrangianMorphFunc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,7 @@ void setOwnerRecursive(TFolder *theFolder)
theFolder->SetOwner();
// And also need to set up ownership for nested folders
auto subdirs = theFolder->GetListOfFolders();
for (auto *subdir : *subdirs) {
auto thisfolder = dynamic_cast<TFolder *>(subdir);
for (auto *thisfolder : dynamic_range_cast<TFolder *>(*subdirs)) {
if (thisfolder) {
// no explicit deletion here, will be handled by parent
setOwnerRecursive(thisfolder);
Expand Down Expand Up @@ -678,8 +677,7 @@ inline bool setParam(RooRealVar *p, double val, bool force)
template <class T1, class T2>
inline bool setParams(const T2 &args, T1 val)
{
for (auto itr : args) {
RooRealVar *param = dynamic_cast<RooRealVar *>(itr);
for (auto *param : dynamic_range_cast<RooRealVar *>(args)) {
if (!param)
continue;
setParam(param, val, true);
Expand All @@ -696,8 +694,7 @@ inline bool
setParams(const std::map<const std::string, T1> &point, const T2 &args, bool force = false, T1 defaultVal = 0)
{
bool ok = true;
for (auto itr : args) {
RooRealVar *param = dynamic_cast<RooRealVar *>(itr);
for (auto *param : dynamic_range_cast<RooRealVar *>(args)) {
if (!param || param->isConstant())
continue;
ok = setParam(param, defaultVal, force) && ok;
Expand Down Expand Up @@ -725,8 +722,7 @@ inline bool setParams(TH1 *hist, const T &args, bool force = false)
{
bool ok = true;

for (auto itr : args) {
RooRealVar *param = dynamic_cast<RooRealVar *>(itr);
for (auto *param : dynamic_range_cast<RooRealVar *>(args)) {
if (!param)
continue;
ok = setParam(param, 0., force) && ok;
Expand All @@ -752,8 +748,7 @@ template <class T>
inline RooLagrangianMorphFunc::ParamSet getParams(const T &parameters)
{
RooLagrangianMorphFunc::ParamSet retval;
for (auto itr : parameters) {
RooRealVar *param = dynamic_cast<RooRealVar *>(itr);
for (auto *param : dynamic_range_cast<RooRealVar *>(parameters)) {
if (!param)
continue;
retval[param->GetName()] = param->getVal();
Expand Down Expand Up @@ -977,9 +972,7 @@ inline void fillFeynmanDiagram(FeynmanDiagram &diagram, const std::vector<List *
for (auto const &vertex : vertices) {
std::vector<bool> vertexCouplings(ncouplings, false);
int idx = -1;
RooAbsReal *coupling;
for (auto citr : couplings) {
coupling = dynamic_cast<RooAbsReal *>(citr);
for (auto *coupling : dynamic_range_cast<RooAbsReal *>(couplings)) {
idx++;
if (!coupling) {
std::cerr << "encountered invalid list of couplings in vertex!" << std::endl;
Expand Down Expand Up @@ -1120,20 +1113,17 @@ FormulaList buildFormulas(const char *mfname, const RooLagrangianMorphFunc::Para
std::cerr << "internal error, number of operators inconsistent!" << std::endl;
}

RooAbsReal *obj0;
int idx = 0;

for (auto itr1 : couplings) {
obj0 = dynamic_cast<RooAbsReal *>(itr1);
for (auto *obj0 : dynamic_range_cast<RooAbsReal *>(couplings)) {
if (obj0->getVal() != 0) {
couplingsZero[idx] = false;
}
idx++;
}
}

for (auto itr2 : flags) {
auto obj1 = dynamic_cast<RooAbsReal *>(itr2);
for (auto *obj1 : dynamic_range_cast<RooAbsReal *>(flags)) {
int nZero = 0;
int nNonZero = 0;
for (auto sampleit : inputFlags) {
Expand Down Expand Up @@ -1203,8 +1193,7 @@ FormulaList buildFormulas(const char *mfname, const RooLagrangianMorphFunc::Para
// check and apply flags
bool removedByFlag = false;

for (auto itr : flags) {
auto obj = dynamic_cast<RooAbsReal *>(itr);
for (auto *obj : dynamic_range_cast<RooAbsReal *>(flags)) {
if (!obj)
continue;
TString sval(obj->getStringAttribute("NewPhysics"));
Expand Down Expand Up @@ -1411,10 +1400,8 @@ class RooLagrangianMorphFunc::CacheElem : public RooAbsCacheElement {
// set all vars to value stored in input file
setParams(sampleit.second, operators, true);
bool first = true;
RooAbsReal *obj;

for (auto itr : _couplings) {
obj = dynamic_cast<RooAbsReal *>(itr);
for (auto *obj : dynamic_range_cast<RooAbsReal *>(_couplings)) {
if (!first)
std::cerr << ", ";
oocxcoutW((TObject *)nullptr, Eval) << obj->GetName() << "=" << obj->getVal();
Expand Down Expand Up @@ -1953,8 +1940,8 @@ RooLagrangianMorphFunc::RooLagrangianMorphFunc(const RooLagrangianMorphFunc &oth
{
for (size_t j = 0; j < other._diagrams.size(); ++j) {
std::vector<RooListProxy *> diagram;
for (size_t i = 0; i < other._diagrams[j].size(); ++i) {
RooListProxy *list = new RooListProxy(other._diagrams[j][i]->GetName(), this, *(other._diagrams[j][i]));
for (auto *elem : other._diagrams[j]) {
RooListProxy *list = new RooListProxy(elem->GetName(), this, *elem);
diagram.push_back(list);
}
_diagrams.push_back(diagram);
Expand Down Expand Up @@ -2158,8 +2145,7 @@ RooProduct *RooLagrangianMorphFunc::getSumElement(const char *name) const
prodname.Append("_");
prodname.Append(this->GetName());

for (auto itr : *args) {
RooProduct *prod = dynamic_cast<RooProduct *>(itr);
for (auto *prod : dynamic_range_cast<RooProduct *>(*args)) {
if (!prod)
continue;
TString sname(prod->GetName());
Expand Down Expand Up @@ -2215,11 +2201,9 @@ void RooLagrangianMorphFunc::printSampleWeights() const

void RooLagrangianMorphFunc::randomizeParameters(double z)
{
RooRealVar *obj;
TRandom3 r;

for (auto itr : _operators) {
obj = dynamic_cast<RooRealVar *>(itr);
for (auto *obj : dynamic_range_cast<RooRealVar *>(_operators)) {
double val = obj->getVal();
if (obj->isConstant())
continue;
Expand Down Expand Up @@ -2504,8 +2488,7 @@ RooLagrangianMorphFunc::ParamSet RooLagrangianMorphFunc::getMorphParameters(cons

void RooLagrangianMorphFunc::setParameters(const RooArgList *list)
{
for (auto itr : *list) {
RooRealVar *param = dynamic_cast<RooRealVar *>(itr);
for (auto *param : dynamic_range_cast<RooRealVar *>(*list)) {
if (!param)
continue;
this->setParameter(param->GetName(), param->getVal());
Expand Down Expand Up @@ -2562,8 +2545,7 @@ TH1 *RooLagrangianMorphFunc::createTH1(const std::string &name, bool correlateEr
double val = 0;
double unc2 = 0;
double unc = 0;
for (auto itr : *args) {
RooProduct *prod = dynamic_cast<RooProduct *>(itr);
for (auto *prod : dynamic_range_cast<RooProduct *>(*args)) {
if (!prod)
continue;
RooAbsArg *phys = prod->components().find(Form("phys_%s", prod->GetName()));
Expand Down Expand Up @@ -2595,8 +2577,7 @@ int RooLagrangianMorphFunc::countContributingFormulas() const
if (!mf)
coutE(InputArguments) << "unable to retrieve morphing function" << std::endl;
std::unique_ptr<RooArgSet> args{mf->getComponents()};
for (auto itr : *args) {
RooProduct *prod = dynamic_cast<RooProduct *>(itr);
for (auto *prod : dynamic_range_cast<RooProduct *>(*args)) {
if (prod->getVal() != 0) {
nFormulas++;
}
Expand Down Expand Up @@ -2721,8 +2702,7 @@ const RooArgList *RooLagrangianMorphFunc::getCouplingSet() const
RooLagrangianMorphFunc::ParamSet RooLagrangianMorphFunc::getCouplings() const
{
RooLagrangianMorphFunc::ParamSet couplings;
for (auto obj : *(this->getCouplingSet())) {
RooAbsReal *var = dynamic_cast<RooAbsReal *>(obj);
for (auto *var : dynamic_range_cast<RooAbsReal *>(*(this->getCouplingSet()))) {
if (!var)
continue;
const std::string name(var->GetName());
Expand Down Expand Up @@ -2847,8 +2827,7 @@ double RooLagrangianMorphFunc::expectedUncertainty() const
void RooLagrangianMorphFunc::printParameters() const
{
// print the parameters and their current values
for (auto obj : _operators) {
RooRealVar *param = static_cast<RooRealVar *>(obj);
for (auto *param : static_range_cast<RooRealVar *>(_operators)) {
if (!param)
continue;
param->Print();
Expand All @@ -2860,8 +2839,7 @@ void RooLagrangianMorphFunc::printParameters() const

void RooLagrangianMorphFunc::printFlags() const
{
for (auto flag : _flags) {
RooRealVar *param = static_cast<RooRealVar *>(flag);
for (auto *param : static_range_cast<RooRealVar *>(_flags)) {
if (!param)
continue;
param->Print();
Expand Down
7 changes: 3 additions & 4 deletions roofit/roofit/src/RooLegacyExpPoly.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ double RooLegacyExpPoly::evaluateLog() const
const double x = _x;
double xpow = std::pow(x, lowestOrder);
double retval = 0;
for (size_t i = 0; i < sz; ++i) {
retval += coefs[i] * xpow;
for (double coef : coefs) {
retval += coef * xpow;
xpow *= x;
}

Expand Down Expand Up @@ -158,9 +158,8 @@ void RooLegacyExpPoly::adjustLimits()
if (x) {
const double xmax = x->getMax();
double xmaxpow = std::pow(xmax, lowestOrder);
for (size_t i = 0; i < sz; ++i) {
for (auto *coef : dynamic_range_cast<RooRealVar *>(_coefList)) {
double thismax = max / xmaxpow;
RooRealVar *coef = dynamic_cast<RooRealVar *>(this->_coefList.at(i));
if (coef) {
coef->setVal(thismax);
coef->setMax(thismax);
Expand Down
4 changes: 2 additions & 2 deletions roofit/roofit/src/RooMultiBinomial.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ double RooMultiBinomial::evaluate() const
// Calculate efficiency for combination of accept/reject categories
// put equal to zero if combination of only zeros AND chosen to be invisible

for (int i=0; i<effFuncListSize; ++i) {
_effVal=_effVal*effValue[i];
for (double ev : effValue) {
_effVal=_effVal*ev;
if (notVisible && _ignoreNonVisible){
_effVal=0;
}
Expand Down
8 changes: 4 additions & 4 deletions roofit/roofit/src/RooNDKeysPdf.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1179,10 +1179,10 @@ double RooNDKeysPdf::analyticalIntegral(Int_t code, const char* rangeName) const
norm = bi->nEventsBMSW;
if (norm<0.) norm=0.;

for (Int_t i=0; i<Int_t(bi->sIdcs.size()); ++i) {
for (Int_t sIdx : bi->sIdcs) {
double prob=1.;
const vector<double>& x = _dataPts[bi->sIdcs[i]];
const vector<double>& weight = (*_weights)[_idx[bi->sIdcs[i]]];
const vector<double>& x = _dataPts[sIdx];
const vector<double>& weight = (*_weights)[_idx[sIdx]];

vector<double> chi(_nDim,100.);

Expand All @@ -1202,7 +1202,7 @@ double RooNDKeysPdf::analyticalIntegral(Int_t code, const char* rangeName) const
}
}

norm += prob * _wMap.at(_idx[bi->sIdcs[i]]);
norm += prob * _wMap.at(_idx[sIdx]);
}

cxcoutD(Eval) << "RooNDKeysPdf::analyticalIntegral() : Final normalization : " << norm << " " << bi->nEventsBW << std::endl;
Expand Down
7 changes: 3 additions & 4 deletions roofit/roofitcore/src/FitHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,7 @@ std::unique_ptr<RooAbsReal> createNLL(RooAbsPdf &pdf, RooAbsData &data, const Ro
// Create range with name 'fit' with above limits on all observables
RooArgSet obs;
pdf.getObservables(data.get(), obs);
for (auto arg : obs) {
RooRealVar *rrv = dynamic_cast<RooRealVar *>(arg);
for (auto *rrv : dynamic_range_cast<RooRealVar *>(obs)) {
if (rrv)
rrv->setRange("fit", rangeLo, rangeHi);
}
Expand Down Expand Up @@ -1040,8 +1039,8 @@ std::unique_ptr<RooAbsReal> createChi2(RooAbsReal &real, RooDataHist &data, cons
const double rangeHi = pc.getDouble("rangeHi");
RooArgSet obs;
real.getObservables(data.get(), obs);
for (auto arg : obs) {
if (auto *rrv = dynamic_cast<RooRealVar *>(arg)) {
for (auto *rrv : dynamic_range_cast<RooRealVar *>(obs)) {
if (rrv) {
rrv->setRange("fit", rangeLo, rangeHi);
}
}
Expand Down
6 changes: 2 additions & 4 deletions roofit/roofitcore/src/RooAbsAnaConvPdf.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ bool RooAbsAnaConvPdf::changeModel(const RooResolutionModel& newModel)
{
RooArgList newConvSet ;
bool allOK(true) ;
for (auto convArg : _convSet) {
auto conv = static_cast<RooResolutionModel*>(convArg);
for (auto *conv : static_range_cast<RooResolutionModel*>(_convSet)) {

// Build new resolution model
std::unique_ptr<RooResolutionModel> newConv{newModel.convolution(const_cast<RooFormulaVar*>(&conv->basis()),this)};
Expand Down Expand Up @@ -330,8 +329,7 @@ double RooAbsAnaConvPdf::evaluate() const
double result(0) ;

Int_t index(0) ;
for (auto convArg : _convSet) {
auto conv = static_cast<RooAbsPdf*>(convArg);
for (auto *conv : static_range_cast<RooAbsPdf*>(_convSet)) {
double coef = coefficient(index++) ;
if (coef!=0.) {
const double c = conv->getVal(nullptr);
Expand Down
Loading
Loading