Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
HistFactorySimultaneous.cxx
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * @(#)root/roofitcore:$Id$
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 
17 //////////////////////////////////////////////////////////////////////////////
18 /** \class RooStats::HistFactory::HistFactorySimultaneous
19  * \ingroup HistFactory
20  * RooSimultaneous facilitates simultaneous fitting of multiple PDFs
21  * to subsets of a given dataset.
22  *
23  * The class takes an index category, which is interpreted as
24  * the data subset indicator, and a list of PDFs, each associated
25  * with a state of the index category. RooSimultaneous always returns
26  * the value of the PDF that is associated with the current value
27  * of the index category
28  *
29  * Extended likelihood fitting is supported if all components support
30  * extended likelihood mode. The expected number of events by a RooSimultaneous
31  * is that of the component p.d.f. selected by the index category
32  *
33  */
34 
35 
36 #include "RooNLLVar.h"
37 
40 
41 using namespace std ;
42 
43 ClassImp(RooStats::HistFactory::HistFactorySimultaneous);
44 ;
45 
46 
47 ////////////////////////////////////////////////////////////////////////////////
48 
49 RooStats::HistFactory::HistFactorySimultaneous::HistFactorySimultaneous(const char *name, const char *title,
50  RooAbsCategoryLValue& inIndexCat) :
51  RooSimultaneous(name, title, inIndexCat ) {}
52 
53 
54 ////////////////////////////////////////////////////////////////////////////////
55 
56 RooStats::HistFactory::HistFactorySimultaneous::HistFactorySimultaneous(const char *name, const char *title,
57  const RooArgList& inPdfList, RooAbsCategoryLValue& inIndexCat) :
58  RooSimultaneous(name, title, inPdfList, inIndexCat) {}
59 
60 
61 ////////////////////////////////////////////////////////////////////////////////
62 
63 RooStats::HistFactory::HistFactorySimultaneous::HistFactorySimultaneous(const char *name, const char *title,
64  map<string,RooAbsPdf*> pdfMap, RooAbsCategoryLValue& inIndexCat) :
65  RooSimultaneous(name, title, pdfMap, inIndexCat) {}
66 
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 
70 RooStats::HistFactory::HistFactorySimultaneous::HistFactorySimultaneous(const HistFactorySimultaneous& other, const char* name) :
71  RooSimultaneous(other, name) {}
72 
73 ////////////////////////////////////////////////////////////////////////////////
74 
75 RooStats::HistFactory::HistFactorySimultaneous::HistFactorySimultaneous(const RooSimultaneous& other, const char* name) :
76  RooSimultaneous(other, name) {}
77 
78 ////////////////////////////////////////////////////////////////////////////////
79 /// Destructor
80 
81 RooStats::HistFactory::HistFactorySimultaneous::~HistFactorySimultaneous()
82 {
83 }
84 
85 
86 ////////////////////////////////////////////////////////////////////////////////
87 
88 RooAbsReal* RooStats::HistFactory::HistFactorySimultaneous::createNLL(RooAbsData& data,
89  const RooCmdArg& arg1, const RooCmdArg& arg2,
90  const RooCmdArg& arg3, const RooCmdArg& arg4,
91  const RooCmdArg& arg5, const RooCmdArg& arg6,
92  const RooCmdArg& arg7, const RooCmdArg& arg8) {
93  // Probably not necessary because createNLL is virtual...
94 
95  RooLinkedList l ;
96  l.Add((TObject*)&arg1) ; l.Add((TObject*)&arg2) ;
97  l.Add((TObject*)&arg3) ; l.Add((TObject*)&arg4) ;
98  l.Add((TObject*)&arg5) ; l.Add((TObject*)&arg6) ;
99  l.Add((TObject*)&arg7) ; l.Add((TObject*)&arg8) ;
100  return createNLL(data,l) ;
101 
102 }
103 
104 
105 //_____________________________________________________________________________
106 
107 RooAbsReal* RooStats::HistFactory::HistFactorySimultaneous::createNLL(RooAbsData& data, const RooLinkedList& cmdList) {
108 
109  // We want to overload the method createNLL so it return
110  // a RooBarlow-Beeston NLL function, which can be used
111  // in HistFactory to minimize statistical uncertainty analytically
112  //
113  // The only problem is one of ownership
114  // This HistFactorySimultaneous and the RooAbsData& data must
115  // exist for as long as the RooBarlowBeestonLL does
116  //
117  // This could be solved if we instead refer to the cloned
118  // pdf's and data set in the nll that we create here, but
119  // it's unclear how to do so
120  //
121  // Also, check for ownership/memory issue with the newly created nll
122  // and whether RooBarlowBeestonLL owns it, etc
123 
124  // Create a standard nll
125  RooNLLVar* nll = (RooNLLVar*) RooSimultaneous::createNLL( data, cmdList );
126 
127  RooBarlowBeestonLL* bbnll = new RooBarlowBeestonLL("bbnll", "bbnll", *nll); //, *observables);
128  bbnll->setPdf( this );
129  bbnll->setDataset( &data );
130  bbnll->initializeBarlowCache();
131 
132  return bbnll;
133 
134 }