Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooAbsDataStore.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$
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_DATA_STORE
0017 #define ROO_ABS_DATA_STORE
0018 
0019 #include "Rtypes.h"
0020 #include "RooArgSet.h"
0021 #include "RooAbsData.h"
0022 
0023 #include <string_view>
0024 #include "TNamed.h"
0025 
0026 #include <list>
0027 #include <vector>
0028 
0029 class RooAbsArg ;
0030 class RooArgList ;
0031 class TTree ;
0032 
0033 
0034 class RooAbsDataStore : public TNamed, public RooPrintable {
0035 public:
0036 
0037   RooAbsDataStore() {}
0038   RooAbsDataStore(RooStringView name, RooStringView title, const RooArgSet& vars)
0039     : TNamed(name,title), _vars{vars} {}
0040   RooAbsDataStore(const RooAbsDataStore& other, const char* newname=nullptr)
0041     : RooAbsDataStore(other, other._vars, newname) {}
0042   RooAbsDataStore(const RooAbsDataStore& other, const RooArgSet& vars, const char* newname=nullptr)
0043     : TNamed(other), RooPrintable(other), _vars{vars}, _doDirtyProp{other._doDirtyProp}
0044   {
0045     if(newname) SetName(newname);
0046   }
0047 
0048   virtual RooAbsDataStore* clone(const char* newname=nullptr) const = 0 ;
0049   virtual RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=nullptr) const = 0 ;
0050 
0051   virtual std::unique_ptr<RooAbsDataStore> reduce(RooStringView name, RooStringView title,
0052                                   const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
0053                                   std::size_t nStart, std::size_t nStop) = 0 ;
0054 
0055   // Write current row
0056   virtual Int_t fill() = 0 ;
0057 
0058   // Retrieve a row
0059   virtual const RooArgSet* get(Int_t index) const = 0 ;
0060   virtual const RooArgSet* get() const { return &_vars ; }
0061   virtual double weight() const = 0 ;
0062 
0063   virtual double weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const = 0 ;
0064   virtual void weightError(double& lo, double& hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const = 0 ;
0065 
0066   double weight(Int_t index) const {
0067     get(index) ;
0068     return weight() ;
0069   }
0070   virtual bool isWeighted() const = 0 ;
0071 
0072   /// Retrieve batches for all observables in this data store.
0073   virtual RooAbsData::RealSpans getBatches(std::size_t first, std::size_t len) const = 0;
0074   virtual RooAbsData::CategorySpans getCategoryBatches(std::size_t /*first*/, std::size_t /*len*/) const {
0075     std::cerr << "This functionality is not yet implemented for this data store." << std::endl;
0076     throw std::logic_error("getCategoryBatches() not implemented in RooAbsDataStore.");
0077     return {};
0078   }
0079   virtual std::span<const double> getWeightBatch(std::size_t first, std::size_t len) const = 0;
0080 
0081   // Change observable name
0082   virtual bool changeObservableName(const char* from, const char* to) =0 ;
0083 
0084   // Add one or more columns
0085   virtual RooAbsArg* addColumn(RooAbsArg& var, bool adjustRange=true) = 0 ;
0086   RooArgSet* addColumns(const RooArgList& varList);
0087 
0088   // Merge column-wise
0089   virtual RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) = 0 ;
0090 
0091   // Add rows
0092   virtual void append(RooAbsDataStore& other)= 0 ;
0093 
0094   // General & bookkeeping methods
0095   virtual Int_t numEntries() const = 0 ;
0096   virtual double sumEntries() const { return 0 ; } ;
0097   virtual void reset() = 0 ;
0098 
0099   // Buffer redirection routines used in inside RooAbsOptTestStatistics
0100   virtual void attachBuffers(const RooArgSet& extObs) = 0 ;
0101   virtual void resetBuffers() = 0 ;
0102 
0103   virtual void setExternalWeightArray(const double* /*arrayWgt*/, const double* /*arrayWgtErrLo*/, const double* /*arrayWgtErrHi*/, const double* /*arraySumW2*/) {} ;
0104 
0105   // Printing interface (human readable)
0106   inline void Print(Option_t *options= nullptr) const override {
0107     // Print contents on stdout
0108     printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
0109   }
0110 
0111   /// Print name of dataset
0112   void printName(std::ostream& os) const override { os << GetName(); }
0113   /// Print title of dataset
0114   void printTitle(std::ostream& os) const override { os << GetTitle(); }
0115   void printClassName(std::ostream& os) const override ;
0116   void printArgs(std::ostream& os) const override;
0117   /// Print value of the dataset, i.e. the sum of weights contained in the dataset
0118   void printValue(std::ostream& os) const override { os << numEntries() << " entries" ; }
0119   void printMultiline(std::ostream& os, Int_t content, bool verbose, TString indent) const override;
0120 
0121   /// Define default print options, for a given print style
0122   int defaultPrintContents(Option_t* /*opt*/) const override { return kName|kClassName|kArgs|kValue ; }
0123 
0124 
0125   // Constant term  optimizer interface
0126   virtual void cacheArgs(const RooAbsArg* cacheOwner, RooArgSet& varSet, const RooArgSet* nset=nullptr, bool skipZeroWeights=false) = 0 ;
0127   virtual const RooAbsArg* cacheOwner() = 0 ;
0128   virtual void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) = 0 ;
0129   virtual void setArgStatus(const RooArgSet& set, bool active) = 0 ;
0130   const RooArgSet& cachedVars() const { return _cachedVars ; }
0131   virtual void resetCache() = 0 ;
0132   virtual void recalculateCache(const RooArgSet* /*proj*/, Int_t /*firstEvent*/, Int_t /*lastEvent*/, Int_t /*stepSize*/, bool /* skipZeroWeights*/) {} ;
0133 
0134   virtual void setDirtyProp(bool flag) { _doDirtyProp = flag ; }
0135   bool dirtyProp() const { return _doDirtyProp ; }
0136 
0137   virtual void checkInit() const {} ;
0138 
0139   virtual bool hasFilledCache() const { return false ; }
0140 
0141   virtual const TTree* tree() const { return nullptr ; }
0142   virtual void dump() {}
0143 
0144   virtual void loadValues(const RooAbsDataStore *tds, const RooFormulaVar* select=nullptr, const char* rangeName=nullptr,
0145       std::size_t nStart=0, std::size_t nStop = std::numeric_limits<std::size_t>::max()) = 0 ;
0146 
0147   virtual void forceCacheUpdate() {} ;
0148 
0149  protected:
0150 
0151   RooArgSet _vars;
0152   RooArgSet _cachedVars;
0153 
0154   bool _doDirtyProp = true; ///< Switch do (de)activate dirty state propagation when loading a data point
0155 
0156   ClassDefOverride(RooAbsDataStore,1) // Abstract Data Storage class
0157 };
0158 
0159 
0160 #endif