@@ -568,13 +568,16 @@ cacheutils::CachingAddNLL::setup_()
568568
569569 multiPdfs_.clear ();
570570 for (auto &itp : pdfs_) {
571- bool isMultiPdf = itp->pdf ()->IsA ()->InheritsFrom (RooMultiPdf::Class ());
572- if (isMultiPdf) {
573- const RooMultiPdf *mpdf = dynamic_cast <const RooMultiPdf*>(itp->pdf ());
574- multiPdfs_.push_back (std::make_pair (mpdf, itp.get ()));
575- }
571+ if (auto * mpdf = dynamic_cast <const RooMultiPdf*>(itp->pdf ())) {
572+ multiPdfs_.emplace_back (mpdf, itp.get ());
573+ }
574+ if (auto * hist = dynamic_cast <const CMSHistSum*>(itp->pdf ())) {
575+ histSums_.emplace_back (hist);
576+ }
577+ if (auto * hist = dynamic_cast <const CMSHistErrorPropagator*>(itp->pdf ())) {
578+ histErrorPropagators_.emplace_back (hist);
579+ }
576580 }
577-
578581}
579582
580583void
@@ -789,27 +792,21 @@ cacheutils::CachingAddNLL::setData(const RooAbsData &data)
789792}
790793
791794void cacheutils::CachingAddNLL::propagateData () {
792- for (auto const & funci : pdfs_) {
793- if ( auto pdf = dynamic_cast <CMSHistErrorPropagator const *>(funci->pdf ()); pdf != nullptr ) {
794- pdf->setData (*data_);
795- }
796- else if ( auto pdf = dynamic_cast <CMSHistSum const *>(funci->pdf ()); pdf != nullptr ) {
797- pdf->setData (*data_);
798- }
799- }
795+ for (auto * hist : histErrorPropagators_) {
796+ hist->setData (*data_);
797+ }
798+ for (auto * hist : histSums_) {
799+ hist->setData (*data_);
800+ }
800801}
801802
802-
803803void cacheutils::CachingAddNLL::setAnalyticBarlowBeeston (bool flag) {
804- for (auto const & funci : pdfs_) {
805- if ( auto pdf = dynamic_cast <CMSHistErrorPropagator const *>(funci->pdf ()); pdf != nullptr ) {
806- pdf->setAnalyticBarlowBeeston (flag);
807- }
808- if ( auto pdf = dynamic_cast <CMSHistSum const *>(funci->pdf ()); pdf != nullptr ) {
809- pdf->setAnalyticBarlowBeeston (flag);
810- }
811-
812- }
804+ for (auto * hist : histErrorPropagators_) {
805+ hist->setAnalyticBarlowBeeston (flag);
806+ }
807+ for (auto * hist : histSums_) {
808+ hist->setAnalyticBarlowBeeston (flag);
809+ }
813810}
814811
815812cacheutils::CachingSimNLL::CachingSimNLL (RooSimultaneous *pdf, RooAbsData *data, const RooArgSet *nuis) :
0 commit comments