Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooAbsTestStatistic.h
Go to the documentation of this file.
1/// \cond ROOFIT_INTERNAL
2
3/*
4 * Project: RooFit
5 *
6 * Copyright (c) 2024, CERN
7 *
8 * Redistribution and use in source and binary forms,
9 * with or without modification, are permitted according to the terms
10 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
11 */
12
13#ifndef ROO_ABS_TEST_STATISTIC
14#define ROO_ABS_TEST_STATISTIC
15
16#include "RooAbsReal.h"
17#include "RooSetProxy.h"
18#include "RooRealProxy.h"
19#include "Math/Util.h"
20
21#include <string>
22#include <vector>
23
24class RooArgSet ;
25class RooAbsData ;
26class RooAbsReal ;
27class RooSimultaneous ;
28class RooRealMPFE ;
29
31typedef RooAbsData* pRooAbsData ;
32typedef RooRealMPFE* pRooRealMPFE ;
33
34class RooAbsTestStatistic : public RooAbsReal {
35 friend class RooRealMPFE;
36public:
37
38 struct Configuration {
39 /// Stores the configuration parameters for RooAbsTestStatistic.
40 std::string rangeName;
41 std::string addCoefRangeName;
42 int nCPU = 1;
44 bool verbose = true;
45 bool splitCutRange = false;
46 bool cloneInputData = true;
47 double integrateOverBinsPrecision = -1.;
48 bool binnedL = false;
50 };
51
52 // Constructors, assignment etc
53 RooAbsTestStatistic(const char *name, const char *title, RooAbsReal& real, RooAbsData& data,
54 const RooArgSet& projDeps, Configuration const& cfg);
55 RooAbsTestStatistic(const RooAbsTestStatistic& other, const char* name=nullptr);
56 ~RooAbsTestStatistic() override;
57 virtual RooAbsTestStatistic* create(const char *name, const char *title, RooAbsReal& real, RooAbsData& data,
58 const RooArgSet& projDeps, Configuration const& cfg) = 0;
59
60 virtual double combinedValue(RooAbsReal** gofArray, Int_t nVal) const = 0 ;
61 virtual double globalNormalization() const {
62 // Default value of global normalization factor is 1.0
63 return 1.0 ;
64 }
65
66 bool setData(RooAbsData& data, bool cloneData=true) override ;
67
68 void enableOffsetting(bool flag) override ;
69 bool isOffsetting() const override { return _doOffset ; }
70 double offset() const override { return _offset.Sum() ; }
71 virtual double offsetCarry() const { return _offset.Carry(); }
72
74 GOFOpMode operMode() const {
75 // Return test statistic operation mode of this instance (SimMaster, MPMaster or Slave)
76 return _gofOpMode ;
77 }
78
79protected:
80
81 void printCompactTreeHook(std::ostream& os, const char* indent="") override ;
82
83 bool redirectServersHook(const RooAbsCollection& newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive) override ;
84 double evaluate() const override ;
85
86 virtual double evaluatePartition(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const = 0 ;
87 virtual double getCarry() const;
88
90 void setSimCount(Int_t simCount) {
91 // Store total number of components p.d.f. of a RooSimultaneous in this component test statistic
93 }
94
95 void setEventCount(Int_t nEvents) {
96 // Store total number of events in this component test statistic
97 _nEvents = nEvents ;
98 }
99
100 Int_t numSets() const {
101 // Return total number of sets for parallel calculation
102 return _numSets ;
103 }
104 Int_t setNum() const {
105 // Return parallel calculation set number for this instance
106 return _setNum ;
107 }
108
109 RooSetProxy _paramSet ; ///< Parameters of the test statistic (=parameters of the input function)
110
111
112 // Original arguments
113 RooAbsReal* _func = nullptr; ///< Pointer to original input function
114 RooAbsData* _data = nullptr; ///< Pointer to original input dataset
115 const RooArgSet* _projDeps = nullptr; ///< Pointer to set with projected observables
116 std::string _rangeName ; ///< Name of range in which to calculate test statistic
117 std::string _addCoefRangeName ; ///< Name of reference to be used for RooAddPdf components
118 bool _splitRange = false; ///< Split rangeName in RooSimultaneous index labels if true
119 Int_t _simCount = 1; ///< Total number of component p.d.f.s in RooSimultaneous (if any)
120 bool _verbose = false; ///< Verbose messaging if true
121
122 virtual bool setDataSlave(RooAbsData& /*data*/, bool /*cloneData*/=true, bool /*ownNewDataAnyway*/=false) { return true ; }
123
124 //private:
125
126
127 virtual bool processEmptyDataSets() const { return true ; }
128
129 bool initialize() ;
130 void initSimMode(RooSimultaneous* pdf, RooAbsData* data, const RooArgSet* projDeps, std::string const& rangeName, std::string const& addCoefRangeName) ;
131 void initMPMode(RooAbsReal* real, RooAbsData* data, const RooArgSet* projDeps, std::string const& rangeName, std::string const& addCoefRangeName) ;
132
133 mutable bool _init = false; ///<! Is object initialized
134 GOFOpMode _gofOpMode = Slave; ///< Operation mode of test statistic instance
135
136 Int_t _nEvents = 0; ///< Total number of events in test statistic calculation
137 Int_t _setNum = 0; ///< Partition number of this instance in parallel calculation mode
138 Int_t _numSets = 1; ///< Total number of partitions in parallel calculation mode
139 Int_t _extSet = 0; ///<! Number of designated set to calculated extended term
140
141 // Simultaneous mode data
142 std::vector<std::unique_ptr<RooAbsTestStatistic>> _gofArray; ///<! Array of sub-contexts representing part of the combined test statistic
143
144 // Parallel mode data
145 Int_t _nCPU = 1; ///< Number of processors to use in parallel calculation mode
146 pRooRealMPFE* _mpfeArray = nullptr; ///<! Array of parallel execution frond ends
147
148 RooFit::MPSplit _mpinterl = RooFit::BulkPartition; ///< Use interleaving strategy rather than N-wise split for partitioning of dataset for multiprocessor-split
149 bool _doOffset = false; ///< Apply interval value offset to control numeric precision?
150 const bool _takeGlobalObservablesFromData = false; ///< If the global observable values are taken from data
151 mutable ROOT::Math::KahanSum<double> _offset {0.0}; ///<! Offset as KahanSum to avoid loss of precision
152 mutable double _evalCarry = 0.0; ///<! carry of Kahan sum in evaluatePartition
153};
154
155#endif
156
157/// \endcond
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
static void indent(ostringstream &buf, int indent_level)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
char name[80]
Definition TGX11.cxx:142
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
Definition Util.h:141
Abstract container object that can hold multiple RooAbsArg objects.
Abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:55
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:63
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
@ BulkPartition
void evaluate(typename Architecture_t::Tensor_t &A, EActivationFunction f)
Apply the given activation function to each value in the given tensor A.
Definition Functions.h:98
void initialize(typename Architecture_t::Matrix_t &A, EInitialization m)
Definition Functions.h:282