RooAbsTestStatistic.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  *    File: $Id: RooAbsGoodnessOfFit.h,v 1.15 2007/05/11 09:11:30 verkerke Exp $
00005  * Authors:                                                                  *
00006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
00007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
00008  *                                                                           *
00009  * Copyright (c) 2000-2005, Regents of the University of California          *
00010  *                          and Stanford University. All rights reserved.    *
00011  *                                                                           *
00012  * Redistribution and use in source and binary forms,                        *
00013  * with or without modification, are permitted according to the terms        *
00014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00015  *****************************************************************************/
00016 #ifndef ROO_ABS_TEST_STATISTIC
00017 #define ROO_ABS_TEST_STATISTIC
00018 
00019 #include "Riosfwd.h"
00020 #include "RooAbsReal.h"
00021 #include "RooSetProxy.h"
00022 #include "RooRealProxy.h"
00023 #include <string>
00024 
00025 class RooArgSet ;
00026 class RooAbsData ;
00027 class RooAbsReal ;
00028 class RooSimultaneous ;
00029 class RooRealMPFE ;
00030 
00031 class RooAbsTestStatistic ;
00032 typedef RooAbsTestStatistic* pRooAbsTestStatistic ;
00033 typedef RooAbsData* pRooAbsData ;
00034 typedef RooRealMPFE* pRooRealMPFE ;
00035 
00036 class RooAbsTestStatistic : public RooAbsReal {
00037 public:
00038 
00039   // Constructors, assignment etc
00040   RooAbsTestStatistic() ;
00041   RooAbsTestStatistic(const char *name, const char *title, RooAbsReal& real, RooAbsData& data,
00042                       const RooArgSet& projDeps, const char* rangeName=0, const char* addCoefRangeName=0, 
00043                       Int_t nCPU=1, Bool_t interleave=kFALSE, Bool_t verbose=kTRUE, Bool_t splitCutRange=kTRUE) ;
00044   RooAbsTestStatistic(const RooAbsTestStatistic& other, const char* name=0);
00045   virtual ~RooAbsTestStatistic();
00046   virtual RooAbsTestStatistic* create(const char *name, const char *title, RooAbsReal& real, RooAbsData& data,
00047                                       const RooArgSet& projDeps, const char* rangeName=0, const char* addCoefRangeName=0, 
00048                                       Int_t nCPU=1, Bool_t interleave=kFALSE, Bool_t verbose=kTRUE, Bool_t splitCutRange=kFALSE) = 0 ;
00049 
00050   virtual void constOptimizeTestStatistic(ConstOpCode opcode) ;
00051 
00052   virtual Double_t combinedValue(RooAbsReal** gofArray, Int_t nVal) const = 0 ;
00053   virtual Double_t globalNormalization() const { 
00054     // Default value of global normalization factor is 1.0
00055     return 1.0 ; 
00056   }
00057 
00058 protected:
00059 
00060   virtual void printCompactTreeHook(ostream& os, const char* indent="") ;
00061 
00062   virtual Bool_t redirectServersHook(const RooAbsCollection& newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive) ;
00063   virtual Double_t evaluate() const ;
00064 
00065   virtual Double_t evaluatePartition(Int_t firstEvent, Int_t lastEvent, Int_t stepSize) const = 0 ;
00066 
00067   void setMPSet(Int_t setNum, Int_t numSets) ; 
00068   void setSimCount(Int_t simCount) { 
00069     // Store total number of components p.d.f. of a RooSimultaneous in this component test statistic
00070     _simCount = simCount ; 
00071   }
00072   
00073   void setEventCount(Int_t nEvents) { 
00074     // Store total number of events in this component test statistic
00075     _nEvents = nEvents ; 
00076   }
00077 
00078   Int_t numSets() const { 
00079     // Return total number of sets for parallel calculation
00080     return _numSets ; 
00081   }
00082   Int_t setNum() const { 
00083     // Return parallel calculation set number for this instance
00084     return _setNum ; 
00085   }
00086   
00087   RooSetProxy _paramSet ;          // Parameters of the test statistic (=parameters of the input function)
00088 
00089   enum GOFOpMode { SimMaster,MPMaster,Slave } ;
00090   GOFOpMode operMode() const { 
00091     // Return test statistic operation mode of this instance (SimMaster, MPMaster or Slave)
00092     return _gofOpMode ; 
00093   }
00094 
00095   // Original arguments
00096   RooAbsReal* _func ;              // Pointer to original input function
00097   RooAbsData* _data ;              // Pointer to original input dataset
00098   const RooArgSet* _projDeps ;     // Pointer to set with projected observables
00099   std::string _rangeName ;         // Name of range in which to calculate test statistic
00100   std::string _addCoefRangeName ;  // Name of reference to be used for RooAddPdf components
00101   Bool_t _splitRange ;             // Split rangeName in RooSimultaneous index labels if true
00102   Int_t _simCount ;                // Total number of component p.d.f.s in RooSimultaneous (if any)
00103   Bool_t _verbose ;                // Verbose messaging if true
00104 
00105 private:  
00106 
00107   virtual Bool_t processEmptyDataSets() const { return kTRUE ; }
00108 
00109   Bool_t initialize() ;
00110   void initSimMode(RooSimultaneous* pdf, RooAbsData* data, const RooArgSet* projDeps, const char* rangeName, const char* addCoefRangeName) ;    
00111   void initMPMode(RooAbsReal* real, RooAbsData* data, const RooArgSet* projDeps, const char* rangeName, const char* addCoefRangeName) ;
00112 
00113   mutable Bool_t _init ;          //! Is object initialized  
00114   GOFOpMode   _gofOpMode ;        // Operation mode of test statistic instance 
00115 
00116   Int_t       _nEvents ;          // Total number of events in test statistic calculation
00117   Int_t       _setNum ;           // Partition number of this instance in parallel calculation mode
00118   Int_t       _numSets ;          // Total number of partitions in parallel calculation mode
00119 
00120   // Simultaneous mode data
00121   Int_t          _nGof        ; // Number of sub-contexts 
00122   pRooAbsTestStatistic* _gofArray ; //! Array of sub-contexts representing part of the combined test statistic
00123 
00124   // Parallel mode data
00125   Int_t          _nCPU ;      //  Number of processors to use in parallel calculation mode
00126   pRooRealMPFE*  _mpfeArray ; //! Array of parallel execution frond ends
00127 
00128   Bool_t         _mpinterl ; // Use interleaving strategy rather than N-wise split for partioning of dataset for multiprocessor-split
00129 
00130   ClassDef(RooAbsTestStatistic,1) // Abstract base class for real-valued test statistics
00131 };
00132 
00133 #endif

Generated on Tue Jul 5 14:26:03 2011 for ROOT_528-00b_version by  doxygen 1.5.1