ROOT logo
// @(#)root/roostats:$Id: RooStatsUtils.cxx 41754 2011-11-03 16:21:13Z rdm $
// Author: Kyle Cranmer   28/07/2008

/*************************************************************************
 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

/////////////////////////////////////////
// RooStats
//
// namespace for classes and functions of the RooStats package
/////////////////////////////////////////
#include "Rtypes.h"

#if !defined(R__ALPHA) && !defined(R__SOLARIS) && !defined(R__ACC) && !defined(R__FBSD)
NamespaceImp(RooStats)
#endif


#include "RooProdPdf.h"
#include "RooSimultaneous.h"
#include "RooStats/ModelConfig.h"
#include "RooStats/RooStatsUtils.h"
#include <typeinfo>

// this file is only for the documentation of RooStats namespace

namespace RooStats { 



 void FactorizePdf(const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &obsTerms, RooArgList &constraints) {
   // utility function to factorize constraint terms from a pdf 
   // (from G. Petrucciani)
   const std::type_info & id = typeid(pdf);
   if (id == typeid(RooProdPdf)) {
      RooProdPdf *prod = dynamic_cast<RooProdPdf *>(&pdf);
      RooArgList list(prod->pdfList());
      for (int i = 0, n = list.getSize(); i < n; ++i) {
         RooAbsPdf *pdfi = (RooAbsPdf *) list.at(i);
            FactorizePdf(observables, *pdfi, obsTerms, constraints);
         }
      } else if (id == typeid(RooSimultaneous) ) {    //|| id == typeid(RooSimultaneousOpt)) {
         RooSimultaneous *sim  = dynamic_cast<RooSimultaneous *>(&pdf);
         RooAbsCategoryLValue *cat = (RooAbsCategoryLValue *) sim->indexCat().Clone();
         for (int ic = 0, nc = cat->numBins((const char *)0); ic < nc; ++ic) {
            cat->setBin(ic);
            FactorizePdf(observables, *sim->getPdf(cat->getLabel()), obsTerms, constraints);
         }
         delete cat;
      } else if (pdf.dependsOn(observables)) {
         if (!obsTerms.contains(pdf)) obsTerms.add(pdf);
      } else {
         if (!constraints.contains(pdf)) constraints.add(pdf);
      }
   }


   void FactorizePdf(RooStats::ModelConfig &model, RooAbsPdf &pdf, RooArgList &obsTerms, RooArgList &constraints) {
      // utility function to factorize constraint terms from a pdf 
      // (from G. Petrucciani)
      return FactorizePdf(*model.GetObservables(), pdf, obsTerms, constraints);
   }


   RooAbsPdf * MakeNuisancePdf(RooAbsPdf &pdf, const RooArgSet &observables, const char *name) { 
      // make a nuisance pdf by factorizing out all constraint terms in a common pdf 
      RooArgList obsTerms, constraints;
      FactorizePdf(observables, pdf, obsTerms, constraints);
      return new RooProdPdf(name,"", constraints);
   }

   RooAbsPdf * MakeNuisancePdf(const RooStats::ModelConfig &model, const char *name) { 
      // make a nuisance pdf by factorizing out all constraint terms in a common pdf 
      return MakeNuisancePdf(*model.GetPdf(), *model.GetObservables(), name);
   }






}
 RooStatsUtils.cxx:1
 RooStatsUtils.cxx:2
 RooStatsUtils.cxx:3
 RooStatsUtils.cxx:4
 RooStatsUtils.cxx:5
 RooStatsUtils.cxx:6
 RooStatsUtils.cxx:7
 RooStatsUtils.cxx:8
 RooStatsUtils.cxx:9
 RooStatsUtils.cxx:10
 RooStatsUtils.cxx:11
 RooStatsUtils.cxx:12
 RooStatsUtils.cxx:13
 RooStatsUtils.cxx:14
 RooStatsUtils.cxx:15
 RooStatsUtils.cxx:16
 RooStatsUtils.cxx:17
 RooStatsUtils.cxx:18
 RooStatsUtils.cxx:19
 RooStatsUtils.cxx:20
 RooStatsUtils.cxx:21
 RooStatsUtils.cxx:22
 RooStatsUtils.cxx:23
 RooStatsUtils.cxx:24
 RooStatsUtils.cxx:25
 RooStatsUtils.cxx:26
 RooStatsUtils.cxx:27
 RooStatsUtils.cxx:28
 RooStatsUtils.cxx:29
 RooStatsUtils.cxx:30
 RooStatsUtils.cxx:31
 RooStatsUtils.cxx:32
 RooStatsUtils.cxx:33
 RooStatsUtils.cxx:34
 RooStatsUtils.cxx:35
 RooStatsUtils.cxx:36
 RooStatsUtils.cxx:37
 RooStatsUtils.cxx:38
 RooStatsUtils.cxx:39
 RooStatsUtils.cxx:40
 RooStatsUtils.cxx:41
 RooStatsUtils.cxx:42
 RooStatsUtils.cxx:43
 RooStatsUtils.cxx:44
 RooStatsUtils.cxx:45
 RooStatsUtils.cxx:46
 RooStatsUtils.cxx:47
 RooStatsUtils.cxx:48
 RooStatsUtils.cxx:49
 RooStatsUtils.cxx:50
 RooStatsUtils.cxx:51
 RooStatsUtils.cxx:52
 RooStatsUtils.cxx:53
 RooStatsUtils.cxx:54
 RooStatsUtils.cxx:55
 RooStatsUtils.cxx:56
 RooStatsUtils.cxx:57
 RooStatsUtils.cxx:58
 RooStatsUtils.cxx:59
 RooStatsUtils.cxx:60
 RooStatsUtils.cxx:61
 RooStatsUtils.cxx:62
 RooStatsUtils.cxx:63
 RooStatsUtils.cxx:64
 RooStatsUtils.cxx:65
 RooStatsUtils.cxx:66
 RooStatsUtils.cxx:67
 RooStatsUtils.cxx:68
 RooStatsUtils.cxx:69
 RooStatsUtils.cxx:70
 RooStatsUtils.cxx:71
 RooStatsUtils.cxx:72
 RooStatsUtils.cxx:73
 RooStatsUtils.cxx:74
 RooStatsUtils.cxx:75
 RooStatsUtils.cxx:76
 RooStatsUtils.cxx:77
 RooStatsUtils.cxx:78
 RooStatsUtils.cxx:79
 RooStatsUtils.cxx:80
 RooStatsUtils.cxx:81
 RooStatsUtils.cxx:82
 RooStatsUtils.cxx:83
 RooStatsUtils.cxx:84
 RooStatsUtils.cxx:85
 RooStatsUtils.cxx:86
 RooStatsUtils.cxx:87