Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooAbsTestStatistic.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*****************************************************************************
0002  * Project: RooFit                                                           *
0003  * Package: RooFitCore                                                       *
0004  *    File: $Id: RooAbsGoodnessOfFit.h,v 1.15 2007/05/11 09:11:30 verkerke Exp $
0005  * Authors:                                                                  *
0006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
0007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
0008  *                                                                           *
0009  * Copyright (c) 2000-2005, Regents of the University of California          *
0010  *                          and Stanford University. All rights reserved.    *
0011  *                                                                           *
0012  * Redistribution and use in source and binary forms,                        *
0013  * with or without modification, are permitted according to the terms        *
0014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
0015  *****************************************************************************/
0016 #ifndef ROO_ABS_TEST_STATISTIC
0017 #define ROO_ABS_TEST_STATISTIC
0018 
0019 // We can't print deprecation warnings when including headers in cling, because
0020 // this will be done automatically anyway.
0021 #ifdef __CLING__
0022 #ifndef ROOFIT_BUILDS_ITSELF
0023 // These warnings should only be suppressed when building ROOT itself!
0024 #warning "Including RooAbsTestStatistic.h is deprecated, and this header will be removed in ROOT v6.34: it is an implementation detail that should not be part of the public user interface"
0025 #else
0026 // If we are builting RooFit itself, this will serve as a reminder to actually
0027 // remove this deprecate public header. Here is now this needs to be done:
0028 //    1. Move this header file from inc/ to src/
0029 //    2. Remove the LinkDef entry, ClassDefOverride, and ClassImpl macros for
0030 //       this class
0031 //    3. If there are are tests using this class in the test/ directory, change
0032 //       the include to use a relative path the moved header file in the src/
0033 //       directory, e.g. #include <RemovedInterface.h> becomes #include
0034 //       "../src/RemovedInterface.h"
0035 //    4. Remove this ifndef-else-endif block from the header
0036 //    5. Remove the deprecation warning at the end of the class declaration
0037 #include <RVersion.h>
0038 #if ROOT_VERSION_CODE >= ROOT_VERSION(6, 34, 00)
0039 #error "Please remove this deprecated public interface."
0040 #endif
0041 #endif
0042 #endif
0043 
0044 #include "RooAbsReal.h"
0045 #include "RooSetProxy.h"
0046 #include "RooRealProxy.h"
0047 #include "TStopwatch.h"
0048 #include "Math/Util.h"
0049 
0050 #include <string>
0051 #include <vector>
0052 
0053 class RooArgSet ;
0054 class RooAbsData ;
0055 class RooAbsReal ;
0056 class RooSimultaneous ;
0057 class RooRealMPFE ;
0058 
0059 class RooAbsTestStatistic ;
0060 typedef RooAbsData* pRooAbsData ;
0061 typedef RooRealMPFE* pRooRealMPFE ;
0062 
0063 class RooAbsTestStatistic : public RooAbsReal {
0064     friend class RooRealMPFE;
0065 public:
0066 
0067   struct Configuration {
0068     /// Stores the configuration parameters for RooAbsTestStatistic.
0069     std::string rangeName;
0070     std::string addCoefRangeName;
0071     int nCPU = 1;
0072     RooFit::MPSplit interleave = RooFit::BulkPartition;
0073     bool verbose = true;
0074     bool splitCutRange = false;
0075     bool cloneInputData = true;
0076     double integrateOverBinsPrecision = -1.;
0077     bool binnedL = false;
0078     bool takeGlobalObservablesFromData = false;
0079   };
0080 
0081   // Constructors, assignment etc
0082   RooAbsTestStatistic(const char *name, const char *title, RooAbsReal& real, RooAbsData& data,
0083                       const RooArgSet& projDeps, Configuration const& cfg);
0084   RooAbsTestStatistic(const RooAbsTestStatistic& other, const char* name=nullptr);
0085   ~RooAbsTestStatistic() override;
0086   virtual RooAbsTestStatistic* create(const char *name, const char *title, RooAbsReal& real, RooAbsData& data,
0087                                       const RooArgSet& projDeps, Configuration const& cfg) = 0;
0088 
0089   void constOptimizeTestStatistic(ConstOpCode opcode, bool doAlsoTrackingOpt=true) override ;
0090 
0091   virtual double combinedValue(RooAbsReal** gofArray, Int_t nVal) const = 0 ;
0092   virtual double globalNormalization() const {
0093     // Default value of global normalization factor is 1.0
0094     return 1.0 ;
0095   }
0096 
0097   bool setData(RooAbsData& data, bool cloneData=true) override ;
0098 
0099   void enableOffsetting(bool flag) override ;
0100   bool isOffsetting() const override { return _doOffset ; }
0101   double offset() const override { return _offset.Sum() ; }
0102   virtual double offsetCarry() const { return _offset.Carry(); }
0103 
0104   enum GOFOpMode { SimMaster,MPMaster,Slave } ;
0105   GOFOpMode operMode() const {
0106      // Return test statistic operation mode of this instance (SimMaster, MPMaster or Slave)
0107      return _gofOpMode ;
0108   }
0109 
0110 protected:
0111 
0112   void printCompactTreeHook(std::ostream& os, const char* indent="") override ;
0113 
0114   bool redirectServersHook(const RooAbsCollection& newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive) override ;
0115   double evaluate() const override ;
0116 
0117   virtual double evaluatePartition(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const = 0 ;
0118   virtual double getCarry() const;
0119 
0120   // Overridden in cache-optimized test statistic
0121   virtual void runRecalculateCache(std::size_t /*firstEvent*/, std::size_t /*lastEvent*/, std::size_t /*stepSize*/) const {}
0122 
0123   void setMPSet(Int_t setNum, Int_t numSets) ;
0124   void setSimCount(Int_t simCount) {
0125     // Store total number of components p.d.f. of a RooSimultaneous in this component test statistic
0126     _simCount = simCount ;
0127   }
0128 
0129   void setEventCount(Int_t nEvents) {
0130     // Store total number of events in this component test statistic
0131     _nEvents = nEvents ;
0132   }
0133 
0134   Int_t numSets() const {
0135     // Return total number of sets for parallel calculation
0136     return _numSets ;
0137   }
0138   Int_t setNum() const {
0139     // Return parallel calculation set number for this instance
0140     return _setNum ;
0141   }
0142 
0143   RooSetProxy _paramSet ;          ///< Parameters of the test statistic (=parameters of the input function)
0144 
0145 
0146   // Original arguments
0147   RooAbsReal* _func = nullptr;          ///< Pointer to original input function
0148   RooAbsData* _data = nullptr;          ///< Pointer to original input dataset
0149   const RooArgSet* _projDeps = nullptr; ///< Pointer to set with projected observables
0150   std::string _rangeName ;              ///< Name of range in which to calculate test statistic
0151   std::string _addCoefRangeName ;       ///< Name of reference to be used for RooAddPdf components
0152   bool _splitRange = false;           ///< Split rangeName in RooSimultaneous index labels if true
0153   Int_t _simCount = 1;                  ///< Total number of component p.d.f.s in RooSimultaneous (if any)
0154   bool _verbose = false;              ///< Verbose messaging if true
0155 
0156   virtual bool setDataSlave(RooAbsData& /*data*/, bool /*cloneData*/=true, bool /*ownNewDataAnyway*/=false) { return true ; }
0157 
0158   //private:
0159 
0160 
0161   virtual bool processEmptyDataSets() const { return true ; }
0162 
0163   bool initialize() ;
0164   void initSimMode(RooSimultaneous* pdf, RooAbsData* data, const RooArgSet* projDeps, std::string const& rangeName, std::string const& addCoefRangeName) ;
0165   void initMPMode(RooAbsReal* real, RooAbsData* data, const RooArgSet* projDeps, std::string const& rangeName, std::string const& addCoefRangeName) ;
0166 
0167   mutable bool _init = false;   ///<! Is object initialized
0168   GOFOpMode _gofOpMode = Slave;   ///< Operation mode of test statistic instance
0169 
0170   Int_t _nEvents = 0;             ///< Total number of events in test statistic calculation
0171   Int_t       _setNum = 0;        ///< Partition number of this instance in parallel calculation mode
0172   Int_t       _numSets = 1;       ///< Total number of partitions in parallel calculation mode
0173   Int_t       _extSet = 0;        ///<! Number of designated set to calculated extended term
0174 
0175   // Simultaneous mode data
0176   std::vector<std::unique_ptr<RooAbsTestStatistic>> _gofArray; ///<! Array of sub-contexts representing part of the combined test statistic
0177 
0178   // Parallel mode data
0179   Int_t          _nCPU = 1;            ///<  Number of processors to use in parallel calculation mode
0180   pRooRealMPFE*  _mpfeArray = nullptr; ///<! Array of parallel execution frond ends
0181 
0182   RooFit::MPSplit _mpinterl = RooFit::BulkPartition;  ///< Use interleaving strategy rather than N-wise split for partitioning of dataset for multiprocessor-split
0183   bool         _doOffset = false;                   ///< Apply interval value offset to control numeric precision?
0184   const bool  _takeGlobalObservablesFromData = false; ///< If the global observable values are taken from data
0185   mutable ROOT::Math::KahanSum<double> _offset {0.0}; ///<! Offset as KahanSum to avoid loss of precision
0186   mutable double _evalCarry = 0.0;                  ///<! carry of Kahan sum in evaluatePartition
0187 
0188   ClassDefOverride(RooAbsTestStatistic,0) // Abstract base class for real-valued test statistics
0189 
0190 #ifndef ROOFIT_BUILDS_ITSELF
0191 } R__DEPRECATED(6,34, "RooAbsTestStatistic is a RooFit implementation detail that should not be instantiated in user code.");
0192 #else
0193 };
0194 #endif
0195 
0196 #endif