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 "Math/Util.h"
24 
25 #include <string>
26 #include <vector>
27 
28 class RooArgSet ;
29 class RooAbsData ;
30 class RooAbsReal ;
31 class RooSimultaneous ;
32 class RooRealMPFE ;
33 
34 class RooAbsTestStatistic ;
38 
40  friend class RooRealMPFE;
41 public:
42 
43  struct Configuration {
44  /// Stores the configuration parameters for RooAbsTestStatistic.
45  std::string rangeName = "";
46  std::string addCoefRangeName = "";
47  int nCPU = 1;
49  bool verbose = true;
50  bool splitCutRange = false;
51  bool cloneInputData = true;
53  bool binnedL = false;
54  };
55 
56  // Constructors, assignment etc
58  RooAbsTestStatistic(const char *name, const char *title, RooAbsReal& real, RooAbsData& data,
59  const RooArgSet& projDeps, Configuration const& cfg);
60  RooAbsTestStatistic(const RooAbsTestStatistic& other, const char* name=0);
61  virtual ~RooAbsTestStatistic();
62  virtual RooAbsTestStatistic* create(const char *name, const char *title, RooAbsReal& real, RooAbsData& data,
63  const RooArgSet& projDeps, Configuration const& cfg) = 0;
64 
65  virtual void constOptimizeTestStatistic(ConstOpCode opcode, Bool_t doAlsoTrackingOpt=kTRUE) ;
66 
67  virtual Double_t combinedValue(RooAbsReal** gofArray, Int_t nVal) const = 0 ;
68  virtual Double_t globalNormalization() const {
69  // Default value of global normalization factor is 1.0
70  return 1.0 ;
71  }
72 
73  Bool_t setData(RooAbsData& data, Bool_t cloneData=kTRUE) ;
74 
75  void enableOffsetting(Bool_t flag) ;
76  Bool_t isOffsetting() const { return _doOffset ; }
77  virtual Double_t offset() const { return _offset.Sum() ; }
78  virtual Double_t offsetCarry() const { return _offset.Carry(); }
79 
80 protected:
81 
82  virtual void printCompactTreeHook(std::ostream& os, const char* indent="") ;
83 
84  virtual Bool_t redirectServersHook(const RooAbsCollection& newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive) ;
85  virtual Double_t evaluate() const ;
86 
87  virtual Double_t evaluatePartition(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const = 0 ;
88  virtual Double_t getCarry() const;
89 
91  void setSimCount(Int_t simCount) {
92  // Store total number of components p.d.f. of a RooSimultaneous in this component test statistic
93  _simCount = simCount ;
94  }
95 
96  void setEventCount(Int_t nEvents) {
97  // Store total number of events in this component test statistic
98  _nEvents = nEvents ;
99  }
100 
101  Int_t numSets() const {
102  // Return total number of sets for parallel calculation
103  return _numSets ;
104  }
105  Int_t setNum() const {
106  // Return parallel calculation set number for this instance
107  return _setNum ;
108  }
109 
110  RooSetProxy _paramSet ; // Parameters of the test statistic (=parameters of the input function)
111 
113  GOFOpMode operMode() const {
114  // Return test statistic operation mode of this instance (SimMaster, MPMaster or Slave)
115  return _gofOpMode ;
116  }
117 
118  // Original arguments
119  RooAbsReal* _func = nullptr; // Pointer to original input function
120  RooAbsData* _data = nullptr; // Pointer to original input dataset
121  const RooArgSet* _projDeps = nullptr; // Pointer to set with projected observables
122  std::string _rangeName ; // Name of range in which to calculate test statistic
123  std::string _addCoefRangeName ; // Name of reference to be used for RooAddPdf components
124  Bool_t _splitRange = false; // Split rangeName in RooSimultaneous index labels if true
125  Int_t _simCount = 1; // Total number of component p.d.f.s in RooSimultaneous (if any)
126  Bool_t _verbose = false; // Verbose messaging if true
127 
128  virtual Bool_t setDataSlave(RooAbsData& /*data*/, Bool_t /*cloneData*/=kTRUE, Bool_t /*ownNewDataAnyway*/=kFALSE) { return kTRUE ; }
129 
130  //private:
131 
132 
133  virtual Bool_t processEmptyDataSets() const { return kTRUE ; }
134 
135  Bool_t initialize() ;
136  void initSimMode(RooSimultaneous* pdf, RooAbsData* data, const RooArgSet* projDeps, std::string const& rangeName, std::string const& addCoefRangeName) ;
137  void initMPMode(RooAbsReal* real, RooAbsData* data, const RooArgSet* projDeps, std::string const& rangeName, std::string const& addCoefRangeName) ;
138 
139  mutable Bool_t _init = false; //! Is object initialized
140  GOFOpMode _gofOpMode = Slave; // Operation mode of test statistic instance
141 
142  Int_t _nEvents = 0; // Total number of events in test statistic calculation
143  Int_t _setNum = 0; // Partition number of this instance in parallel calculation mode
144  Int_t _numSets = 1; // Total number of partitions in parallel calculation mode
145  Int_t _extSet = 0; //! Number of designated set to calculated extended term
146 
147  // Simultaneous mode data
148  Int_t _nGof = 0 ; // Number of sub-contexts
149  pRooAbsTestStatistic* _gofArray = nullptr; //! Array of sub-contexts representing part of the combined test statistic
150  std::vector<RooFit::MPSplit> _gofSplitMode ; //! GOF MP Split mode specified by component (when Auto is active)
151 
152  // Parallel mode data
153  Int_t _nCPU = 1; // Number of processors to use in parallel calculation mode
154  pRooRealMPFE* _mpfeArray = nullptr; //! Array of parallel execution frond ends
155 
156  RooFit::MPSplit _mpinterl = RooFit::BulkPartition; // Use interleaving strategy rather than N-wise split for partioning of dataset for multiprocessor-split
157  Bool_t _doOffset = false; // Apply interval value offset to control numeric precision?
158  mutable ROOT::Math::KahanSum<double> _offset = 0.0; //! Offset as KahanSum to avoid loss of precision
159  mutable Double_t _evalCarry = 0.0; //! carry of Kahan sum in evaluatePartition
160 
161  ClassDef(RooAbsTestStatistic,2) // Abstract base class for real-valued test statistics
162 
163 };
164 
165 #endif
Util.h
pRooRealMPFE
RooRealMPFE * pRooRealMPFE
Definition: RooAbsTestStatistic.h:37
RooRealMPFE
RooRealMPFE is the multi-processor front-end for parallel calculation of RooAbsReal objects.
Definition: RooRealMPFE.h:30
RooAbsTestStatistic::_init
Bool_t _init
Definition: RooAbsTestStatistic.h:139
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
RooAbsReal.h
RooAbsTestStatistic::operMode
GOFOpMode operMode() const
Definition: RooAbsTestStatistic.h:113
RooAbsTestStatistic::setEventCount
void setEventCount(Int_t nEvents)
Definition: RooAbsTestStatistic.h:96
RooAbsTestStatistic::_data
RooAbsData * _data
Definition: RooAbsTestStatistic.h:120
RooAbsTestStatistic::_mpfeArray
pRooRealMPFE * _mpfeArray
Definition: RooAbsTestStatistic.h:154
RooAbsData
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:49
RooAbsTestStatistic::RooAbsTestStatistic
RooAbsTestStatistic()
Definition: RooAbsTestStatistic.h:57
RooAbsTestStatistic::_gofOpMode
GOFOpMode _gofOpMode
Is object initialized
Definition: RooAbsTestStatistic.h:140
RooAbsTestStatistic::_gofSplitMode
std::vector< RooFit::MPSplit > _gofSplitMode
Array of sub-contexts representing part of the combined test statistic.
Definition: RooAbsTestStatistic.h:150
RooAbsTestStatistic::Configuration::cloneInputData
bool cloneInputData
Definition: RooAbsTestStatistic.h:51
RooSetProxy
RooSetProxy is the concrete proxy for RooArgSet objects.
Definition: RooSetProxy.h:23
TStopwatch.h
RooAbsTestStatistic::_nEvents
Int_t _nEvents
Definition: RooAbsTestStatistic.h:142
RooAbsTestStatistic::_nGof
Int_t _nGof
Number of designated set to calculated extended term.
Definition: RooAbsTestStatistic.h:148
RooAbsTestStatistic::Configuration::rangeName
std::string rangeName
Stores the configuration parameters for RooAbsTestStatistic.
Definition: RooAbsTestStatistic.h:45
RooAbsTestStatistic::setDataSlave
virtual Bool_t setDataSlave(RooAbsData &, Bool_t=kTRUE, Bool_t=kFALSE)
Definition: RooAbsTestStatistic.h:128
RooAbsTestStatistic::constOptimizeTestStatistic
virtual void constOptimizeTestStatistic(ConstOpCode opcode, Bool_t doAlsoTrackingOpt=kTRUE)
Forward constant term optimization management calls to component test statistics.
Definition: RooAbsTestStatistic.cxx:359
RooFit::MPSplit
MPSplit
Definition: RooGlobalFunc.h:63
RooAbsTestStatistic::Configuration::verbose
bool verbose
Definition: RooAbsTestStatistic.h:49
RooAbsTestStatistic::offsetCarry
virtual Double_t offsetCarry() const
Definition: RooAbsTestStatistic.h:78
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::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:335
RooSetProxy.h
RooAbsTestStatistic::_evalCarry
Double_t _evalCarry
Offset as KahanSum to avoid loss of precision.
Definition: RooAbsTestStatistic.h:159
RooAbsTestStatistic::getCarry
virtual Double_t getCarry() const
Definition: RooAbsTestStatistic.cxx:681
bool
RooAbsTestStatistic::Configuration::addCoefRangeName
std::string addCoefRangeName
Definition: RooAbsTestStatistic.h:46
RooAbsTestStatistic::_rangeName
std::string _rangeName
Definition: RooAbsTestStatistic.h:122
RooAbsTestStatistic::_splitRange
Bool_t _splitRange
Definition: RooAbsTestStatistic.h:124
RooAbsTestStatistic
RooAbsTestStatistic is the abstract base class for all test statistics.
Definition: RooAbsTestStatistic.h:39
RooAbsTestStatistic::_projDeps
const RooArgSet * _projDeps
Definition: RooAbsTestStatistic.h:121
RooAbsTestStatistic::processEmptyDataSets
virtual Bool_t processEmptyDataSets() const
Definition: RooAbsTestStatistic.h:133
RooAbsTestStatistic::Configuration::interleave
RooFit::MPSplit interleave
Definition: RooAbsTestStatistic.h:48
RooAbsTestStatistic::initMPMode
void initMPMode(RooAbsReal *real, RooAbsData *data, const RooArgSet *projDeps, std::string const &rangeName, std::string const &addCoefRangeName)
Initialize multi-processor calculation mode.
Definition: RooAbsTestStatistic.cxx:403
RooAbsTestStatistic::setData
Bool_t setData(RooAbsData &data, Bool_t cloneData=kTRUE)
Change dataset that is used to given one.
Definition: RooAbsTestStatistic.cxx:590
RooAbsTestStatistic::_gofArray
pRooAbsTestStatistic * _gofArray
Definition: RooAbsTestStatistic.h:149
RooAbsTestStatistic::_offset
ROOT::Math::KahanSum< double > _offset
Definition: RooAbsTestStatistic.h:158
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
RooAbsTestStatistic::offset
virtual Double_t offset() const
Definition: RooAbsTestStatistic.h:77
RooAbsTestStatistic::_mpinterl
RooFit::MPSplit _mpinterl
Array of parallel execution frond ends.
Definition: RooAbsTestStatistic.h:156
RooAbsTestStatistic::setNum
Int_t setNum() const
Definition: RooAbsTestStatistic.h:105
RooAbsTestStatistic::GOFOpMode
GOFOpMode
Definition: RooAbsTestStatistic.h:112
RooRealProxy.h
RooAbsCollection
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
Definition: RooAbsCollection.h:31
RooAbsTestStatistic::Configuration
Definition: RooAbsTestStatistic.h:43
RooAbsTestStatistic::combinedValue
virtual Double_t combinedValue(RooAbsReal **gofArray, Int_t nVal) const =0
RooAbsTestStatistic::Slave
@ Slave
Definition: RooAbsTestStatistic.h:112
RooAbsTestStatistic::_doOffset
Bool_t _doOffset
Definition: RooAbsTestStatistic.h:157
RooAbsTestStatistic::isOffsetting
Bool_t isOffsetting() const
Definition: RooAbsTestStatistic.h:76
RooFit::BulkPartition
@ BulkPartition
Definition: RooGlobalFunc.h:63
RooAbsTestStatistic::_nCPU
Int_t _nCPU
GOF MP Split mode specified by component (when Auto is active)
Definition: RooAbsTestStatistic.h:153
pRooAbsData
RooAbsData * pRooAbsData
Definition: RooAbsTestStatistic.h:36
RooAbsTestStatistic::~RooAbsTestStatistic
virtual ~RooAbsTestStatistic()
Destructor.
Definition: RooAbsTestStatistic.cxx:153
RooAbsTestStatistic::create
virtual RooAbsTestStatistic * create(const char *name, const char *title, RooAbsReal &real, RooAbsData &data, const RooArgSet &projDeps, Configuration const &cfg)=0
Double_t
double Double_t
Definition: RtypesCore.h:59
RooAbsTestStatistic::_addCoefRangeName
std::string _addCoefRangeName
Definition: RooAbsTestStatistic.h:123
RooAbsTestStatistic::SimMaster
@ SimMaster
Definition: RooAbsTestStatistic.h:112
RooAbsTestStatistic::Configuration::nCPU
int nCPU
Definition: RooAbsTestStatistic.h:47
RooAbsTestStatistic::evaluate
virtual Double_t evaluate() const
Calculate and return value of test statistic.
Definition: RooAbsTestStatistic.cxx:178
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:308
ROOT::Math::KahanSum::Sum
T Sum() const
Definition: Util.h:217
RooAbsTestStatistic::numSets
Int_t numSets() const
Definition: RooAbsTestStatistic.h:101
name
char name[80]
Definition: TGX11.cxx:110
RooAbsTestStatistic::enableOffsetting
void enableOffsetting(Bool_t flag)
Definition: RooAbsTestStatistic.cxx:649
RooAbsTestStatistic::globalNormalization
virtual Double_t globalNormalization() const
Definition: RooAbsTestStatistic.h:68
RooAbsTestStatistic::setSimCount
void setSimCount(Int_t simCount)
Definition: RooAbsTestStatistic.h:91
pRooAbsTestStatistic
RooAbsTestStatistic * pRooAbsTestStatistic
Definition: RooAbsTestStatistic.h:34
RooAbsTestStatistic::evaluatePartition
virtual Double_t evaluatePartition(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const =0
RooAbsTestStatistic::Configuration::integrateOverBinsPrecision
double integrateOverBinsPrecision
Definition: RooAbsTestStatistic.h:52
RooAbsTestStatistic::initSimMode
void initSimMode(RooSimultaneous *pdf, RooAbsData *data, const RooArgSet *projDeps, std::string const &rangeName, std::string const &addCoefRangeName)
Initialize simultaneous p.d.f processing mode.
Definition: RooAbsTestStatistic.cxx:451
RooAbsTestStatistic::MPMaster
@ MPMaster
Definition: RooAbsTestStatistic.h:112
RooAbsTestStatistic::_func
RooAbsReal * _func
Definition: RooAbsTestStatistic.h:119
RooSimultaneous
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
Definition: RooSimultaneous.h:37
RooAbsArg::ConstOpCode
ConstOpCode
Definition: RooAbsArg.h:386
RooAbsTestStatistic::Configuration::binnedL
bool binnedL
Definition: RooAbsTestStatistic.h:53
ROOT::Math::KahanSum< double >
RooAbsTestStatistic::Configuration::splitCutRange
bool splitCutRange
Definition: RooAbsTestStatistic.h:50
RooAbsTestStatistic::_numSets
Int_t _numSets
Definition: RooAbsTestStatistic.h:144
ROOT::Math::KahanSum::Carry
T Carry() const
Definition: Util.h:232
RooAbsTestStatistic::_extSet
Int_t _extSet
Definition: RooAbsTestStatistic.h:145
RooAbsTestStatistic::_simCount
Int_t _simCount
Definition: RooAbsTestStatistic.h:125
RooAbsTestStatistic::_setNum
Int_t _setNum
Definition: RooAbsTestStatistic.h:143
RooAbsTestStatistic::setMPSet
void setMPSet(Int_t setNum, Int_t numSets)
Set MultiProcessor set number identification of this instance.
Definition: RooAbsTestStatistic.cxx:383
RooAbsTestStatistic::_paramSet
RooSetProxy _paramSet
Definition: RooAbsTestStatistic.h:110
RooAbsTestStatistic::initialize
Bool_t initialize()
One-time initialization of the test statistic.
Definition: RooAbsTestStatistic.cxx:290
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:33
int
RooAbsTestStatistic::_verbose
Bool_t _verbose
Definition: RooAbsTestStatistic.h:126