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