Logo ROOT  
Reference Guide
RooAbsTestStatistic.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooAbsGoodnessOfFit.h,v 1.15 2007/05/11 09:11:30 verkerke Exp $
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 #ifndef ROO_ABS_TEST_STATISTIC
17 #define ROO_ABS_TEST_STATISTIC
18 
19 #include "RooAbsReal.h"
20 #include "RooSetProxy.h"
21 #include "RooRealProxy.h"
22 #include "TStopwatch.h"
23 #include <string>
24 #include <vector>
25 
26 class RooArgSet ;
27 class RooAbsData ;
28 class RooAbsReal ;
29 class RooSimultaneous ;
30 class RooRealMPFE ;
31 
32 class RooAbsTestStatistic ;
36 
38  friend class RooRealMPFE;
39 public:
40 
41  // Constructors, assignment etc
43  RooAbsTestStatistic(const char *name, const char *title, RooAbsReal& real, RooAbsData& data,
44  const RooArgSet& projDeps, const char* rangeName=0, const char* addCoefRangeName=0,
45  Int_t nCPU=1, RooFit::MPSplit interleave=RooFit::BulkPartition, Bool_t verbose=kTRUE, Bool_t splitCutRange=kTRUE) ;
46  RooAbsTestStatistic(const RooAbsTestStatistic& other, const char* name=0);
47  virtual ~RooAbsTestStatistic();
48  virtual RooAbsTestStatistic* create(const char *name, const char *title, RooAbsReal& real, RooAbsData& data,
49  const RooArgSet& projDeps, const char* rangeName=0, const char* addCoefRangeName=0,
50  Int_t nCPU=1, RooFit::MPSplit interleave=RooFit::BulkPartition, Bool_t verbose=kTRUE, Bool_t splitCutRange=kFALSE, Bool_t binnedL=kFALSE) = 0 ;
51 
52  virtual void constOptimizeTestStatistic(ConstOpCode opcode, Bool_t doAlsoTrackingOpt=kTRUE) ;
53 
54  virtual Double_t combinedValue(RooAbsReal** gofArray, Int_t nVal) const = 0 ;
55  virtual Double_t globalNormalization() const {
56  // Default value of global normalization factor is 1.0
57  return 1.0 ;
58  }
59 
60  Bool_t setData(RooAbsData& data, Bool_t cloneData=kTRUE) ;
61 
62  void enableOffsetting(Bool_t flag) ;
63  Bool_t isOffsetting() const { return _doOffset ; }
64  virtual Double_t offset() const { return _offset ; }
65  virtual Double_t offsetCarry() const { return _offsetCarry; }
66 
67 protected:
68 
69  virtual void printCompactTreeHook(std::ostream& os, const char* indent="") ;
70 
71  virtual Bool_t redirectServersHook(const RooAbsCollection& newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive) ;
72  virtual Double_t evaluate() const ;
73 
74  virtual Double_t evaluatePartition(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const = 0 ;
75  virtual Double_t getCarry() const;
76 
78  void setSimCount(Int_t simCount) {
79  // Store total number of components p.d.f. of a RooSimultaneous in this component test statistic
80  _simCount = simCount ;
81  }
82 
83  void setEventCount(Int_t nEvents) {
84  // Store total number of events in this component test statistic
85  _nEvents = nEvents ;
86  }
87 
88  Int_t numSets() const {
89  // Return total number of sets for parallel calculation
90  return _numSets ;
91  }
92  Int_t setNum() const {
93  // Return parallel calculation set number for this instance
94  return _setNum ;
95  }
96 
97  RooSetProxy _paramSet ; // Parameters of the test statistic (=parameters of the input function)
98 
100  GOFOpMode operMode() const {
101  // Return test statistic operation mode of this instance (SimMaster, MPMaster or Slave)
102  return _gofOpMode ;
103  }
104 
105  // Original arguments
106  RooAbsReal* _func ; // Pointer to original input function
107  RooAbsData* _data ; // Pointer to original input dataset
108  const RooArgSet* _projDeps ; // Pointer to set with projected observables
109  std::string _rangeName ; // Name of range in which to calculate test statistic
110  std::string _addCoefRangeName ; // Name of reference to be used for RooAddPdf components
111  Bool_t _splitRange ; // Split rangeName in RooSimultaneous index labels if true
112  Int_t _simCount ; // Total number of component p.d.f.s in RooSimultaneous (if any)
113  Bool_t _verbose ; // Verbose messaging if true
114 
115  virtual Bool_t setDataSlave(RooAbsData& /*data*/, Bool_t /*cloneData*/=kTRUE, Bool_t /*ownNewDataAnyway*/=kFALSE) { return kTRUE ; }
116 
117  //private:
118 
119 
120  virtual Bool_t processEmptyDataSets() const { return kTRUE ; }
121 
122  Bool_t initialize() ;
123  void initSimMode(RooSimultaneous* pdf, RooAbsData* data, const RooArgSet* projDeps, const char* rangeName, const char* addCoefRangeName) ;
124  void initMPMode(RooAbsReal* real, RooAbsData* data, const RooArgSet* projDeps, const char* rangeName, const char* addCoefRangeName) ;
125 
126  mutable Bool_t _init ; //! Is object initialized
127  GOFOpMode _gofOpMode ; // Operation mode of test statistic instance
128 
129  Int_t _nEvents ; // Total number of events in test statistic calculation
130  Int_t _setNum ; // Partition number of this instance in parallel calculation mode
131  Int_t _numSets ; // Total number of partitions in parallel calculation mode
132  Int_t _extSet ; //! Number of designated set to calculated extended term
133 
134  // Simultaneous mode data
135  Int_t _nGof ; // Number of sub-contexts
136  pRooAbsTestStatistic* _gofArray ; //! Array of sub-contexts representing part of the combined test statistic
137  std::vector<RooFit::MPSplit> _gofSplitMode ; //! GOF MP Split mode specified by component (when Auto is active)
138 
139  // Parallel mode data
140  Int_t _nCPU ; // Number of processors to use in parallel calculation mode
141  pRooRealMPFE* _mpfeArray ; //! Array of parallel execution frond ends
142 
143  RooFit::MPSplit _mpinterl ; // Use interleaving strategy rather than N-wise split for partioning of dataset for multiprocessor-split
144  Bool_t _doOffset ; // Apply interval value offset to control numeric precision?
145  mutable Double_t _offset ; //! Offset
146  mutable Double_t _offsetCarry; //! avoids loss of precision
147  mutable Double_t _evalCarry; //! carry of Kahan sum in evaluatePartition
148 
149  ClassDef(RooAbsTestStatistic,2) // Abstract base class for real-valued test statistics
150 
151 };
152 
153 #endif
pRooRealMPFE
RooRealMPFE * pRooRealMPFE
Definition: RooAbsTestStatistic.h:35
RooAbsTestStatistic::_offsetCarry
Double_t _offsetCarry
Offset.
Definition: RooAbsTestStatistic.h:146
RooRealMPFE
RooRealMPFE is the multi-processor front-end for parallel calculation of RooAbsReal objects.
Definition: RooRealMPFE.h:30
RooAbsTestStatistic::create
virtual RooAbsTestStatistic * create(const char *name, const char *title, RooAbsReal &real, RooAbsData &data, const RooArgSet &projDeps, const char *rangeName=0, const char *addCoefRangeName=0, Int_t nCPU=1, RooFit::MPSplit interleave=RooFit::BulkPartition, Bool_t verbose=kTRUE, Bool_t splitCutRange=kFALSE, Bool_t binnedL=kFALSE)=0
RooAbsTestStatistic::_init
Bool_t _init
Definition: RooAbsTestStatistic.h:126
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooAbsReal.h
RooAbsTestStatistic::operMode
GOFOpMode operMode() const
Definition: RooAbsTestStatistic.h:100
RooAbsTestStatistic::setEventCount
void setEventCount(Int_t nEvents)
Definition: RooAbsTestStatistic.h:83
RooAbsTestStatistic::_data
RooAbsData * _data
Definition: RooAbsTestStatistic.h:107
RooAbsTestStatistic::_mpfeArray
pRooRealMPFE * _mpfeArray
Definition: RooAbsTestStatistic.h:141
RooAbsData
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:46
RooAbsTestStatistic::RooAbsTestStatistic
RooAbsTestStatistic()
Default constructor.
Definition: RooAbsTestStatistic.cxx:64
RooAbsTestStatistic::_gofOpMode
GOFOpMode _gofOpMode
Is object initialized
Definition: RooAbsTestStatistic.h:127
RooAbsTestStatistic::_gofSplitMode
std::vector< RooFit::MPSplit > _gofSplitMode
Array of sub-contexts representing part of the combined test statistic.
Definition: RooAbsTestStatistic.h:137
RooSetProxy
RooSetProxy is the concrete proxy for RooArgSet objects.
Definition: RooSetProxy.h:23
TStopwatch.h
RooAbsTestStatistic::_nEvents
Int_t _nEvents
Definition: RooAbsTestStatistic.h:129
RooAbsTestStatistic::_nGof
Int_t _nGof
Number of designated set to calculated extended term.
Definition: RooAbsTestStatistic.h:135
RooAbsTestStatistic::setDataSlave
virtual Bool_t setDataSlave(RooAbsData &, Bool_t=kTRUE, Bool_t=kFALSE)
Definition: RooAbsTestStatistic.h:115
RooAbsTestStatistic::constOptimizeTestStatistic
virtual void constOptimizeTestStatistic(ConstOpCode opcode, Bool_t doAlsoTrackingOpt=kTRUE)
Forward constant term optimization management calls to component test statistics.
Definition: RooAbsTestStatistic.cxx:420
RooFit::MPSplit
MPSplit
Definition: RooGlobalFunc.h:70
RooAbsTestStatistic::offsetCarry
virtual Double_t offsetCarry() const
Definition: RooAbsTestStatistic.h:65
indent
static void indent(ostringstream &buf, int indent_level)
Definition: TClingCallFunc.cxx:87
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
RooAbsTestStatistic::_offset
Double_t _offset
Definition: RooAbsTestStatistic.h:145
RooAbsTestStatistic::printCompactTreeHook
virtual void printCompactTreeHook(std::ostream &os, const char *indent="")
Add extra information on component test statistics when printing itself as part of a tree structure.
Definition: RooAbsTestStatistic.cxx:396
RooSetProxy.h
RooAbsTestStatistic::_evalCarry
Double_t _evalCarry
avoids loss of precision
Definition: RooAbsTestStatistic.h:147
RooAbsTestStatistic::getCarry
virtual Double_t getCarry() const
Definition: RooAbsTestStatistic.cxx:716
bool
RooAbsTestStatistic::_rangeName
std::string _rangeName
Definition: RooAbsTestStatistic.h:109
RooAbsTestStatistic::_splitRange
Bool_t _splitRange
Definition: RooAbsTestStatistic.h:111
RooAbsTestStatistic
RooAbsTestStatistic is the abstract base class for all test statistics.
Definition: RooAbsTestStatistic.h:37
RooAbsTestStatistic::_projDeps
const RooArgSet * _projDeps
Definition: RooAbsTestStatistic.h:108
RooAbsTestStatistic::processEmptyDataSets
virtual Bool_t processEmptyDataSets() const
Definition: RooAbsTestStatistic.h:120
RooAbsTestStatistic::setData
Bool_t setData(RooAbsData &data, Bool_t cloneData=kTRUE)
Change dataset that is used to given one.
Definition: RooAbsTestStatistic.cxx:625
RooAbsTestStatistic::_gofArray
pRooAbsTestStatistic * _gofArray
Definition: RooAbsTestStatistic.h:136
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
RooAbsTestStatistic::offset
virtual Double_t offset() const
Definition: RooAbsTestStatistic.h:64
RooAbsTestStatistic::_mpinterl
RooFit::MPSplit _mpinterl
Array of parallel execution frond ends.
Definition: RooAbsTestStatistic.h:143
RooAbsTestStatistic::setNum
Int_t setNum() const
Definition: RooAbsTestStatistic.h:92
RooAbsTestStatistic::GOFOpMode
GOFOpMode
Definition: RooAbsTestStatistic.h:99
RooRealProxy.h
RooAbsCollection
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
Definition: RooAbsCollection.h:30
RooAbsTestStatistic::combinedValue
virtual Double_t combinedValue(RooAbsReal **gofArray, Int_t nVal) const =0
RooAbsTestStatistic::Slave
@ Slave
Definition: RooAbsTestStatistic.h:99
RooAbsTestStatistic::_doOffset
Bool_t _doOffset
Definition: RooAbsTestStatistic.h:144
RooAbsTestStatistic::isOffsetting
Bool_t isOffsetting() const
Definition: RooAbsTestStatistic.h:63
RooFit::BulkPartition
@ BulkPartition
Definition: RooGlobalFunc.h:70
RooAbsTestStatistic::_nCPU
Int_t _nCPU
GOF MP Split mode specified by component (when Auto is active)
Definition: RooAbsTestStatistic.h:140
pRooAbsData
RooAbsData * pRooAbsData
Definition: RooAbsTestStatistic.h:34
RooAbsTestStatistic::~RooAbsTestStatistic
virtual ~RooAbsTestStatistic()
Destructor.
Definition: RooAbsTestStatistic.cxx:219
Double_t
double Double_t
Definition: RtypesCore.h:59
RooAbsTestStatistic::_addCoefRangeName
std::string _addCoefRangeName
Definition: RooAbsTestStatistic.h:110
RooAbsTestStatistic::SimMaster
@ SimMaster
Definition: RooAbsTestStatistic.h:99
RooAbsTestStatistic::evaluate
virtual Double_t evaluate() const
Calculate and return value of test statistic.
Definition: RooAbsTestStatistic.cxx:244
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
RooAbsTestStatistic::redirectServersHook
virtual Bool_t redirectServersHook(const RooAbsCollection &newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive)
Forward server redirect calls to component test statistics.
Definition: RooAbsTestStatistic.cxx:369
RooAbsTestStatistic::numSets
Int_t numSets() const
Definition: RooAbsTestStatistic.h:88
name
char name[80]
Definition: TGX11.cxx:110
RooAbsTestStatistic::enableOffsetting
void enableOffsetting(Bool_t flag)
Definition: RooAbsTestStatistic.cxx:683
RooAbsTestStatistic::globalNormalization
virtual Double_t globalNormalization() const
Definition: RooAbsTestStatistic.h:55
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
RooAbsTestStatistic::setSimCount
void setSimCount(Int_t simCount)
Definition: RooAbsTestStatistic.h:78
pRooAbsTestStatistic
RooAbsTestStatistic * pRooAbsTestStatistic
Definition: RooAbsTestStatistic.h:32
RooAbsTestStatistic::evaluatePartition
virtual Double_t evaluatePartition(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const =0
RooAbsTestStatistic::initMPMode
void initMPMode(RooAbsReal *real, RooAbsData *data, const RooArgSet *projDeps, const char *rangeName, const char *addCoefRangeName)
Initialize multi-processor calculation mode.
Definition: RooAbsTestStatistic.cxx:464
RooAbsTestStatistic::MPMaster
@ MPMaster
Definition: RooAbsTestStatistic.h:99
RooAbsTestStatistic::_func
RooAbsReal * _func
Definition: RooAbsTestStatistic.h:106
RooSimultaneous
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
Definition: RooSimultaneous.h:37
RooAbsArg::ConstOpCode
ConstOpCode
Definition: RooAbsArg.h:392
RooAbsTestStatistic::_numSets
Int_t _numSets
Definition: RooAbsTestStatistic.h:131
RooAbsTestStatistic::_extSet
Int_t _extSet
Definition: RooAbsTestStatistic.h:132
RooAbsTestStatistic::_simCount
Int_t _simCount
Definition: RooAbsTestStatistic.h:112
RooAbsTestStatistic::_setNum
Int_t _setNum
Definition: RooAbsTestStatistic.h:130
RooAbsTestStatistic::initSimMode
void initSimMode(RooSimultaneous *pdf, RooAbsData *data, const RooArgSet *projDeps, const char *rangeName, const char *addCoefRangeName)
Initialize simultaneous p.d.f processing mode.
Definition: RooAbsTestStatistic.cxx:499
RooAbsTestStatistic::setMPSet
void setMPSet(Int_t setNum, Int_t numSets)
Set MultiProcessor set number identification of this instance.
Definition: RooAbsTestStatistic.cxx:444
RooAbsTestStatistic::_paramSet
RooSetProxy _paramSet
Definition: RooAbsTestStatistic.h:97
RooAbsTestStatistic::initialize
Bool_t initialize()
One-time initialization of the test statistic.
Definition: RooAbsTestStatistic.cxx:351
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
int
RooAbsTestStatistic::_verbose
Bool_t _verbose
Definition: RooAbsTestStatistic.h:113