Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooCompositeDataStore.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_COMPOSITE_DATA_STORE
0017 #define ROO_COMPOSITE_DATA_STORE
0018 
0019 #include "RooAbsDataStore.h"
0020 
0021 #include <map>
0022 #include <string>
0023 #include <vector>
0024 #include <list>
0025 
0026 class RooAbsArg ;
0027 class RooArgList ;
0028 class RooFormulaVar ;
0029 class RooArgSet ;
0030 class RooCategory ;
0031 
0032 
0033 class RooCompositeDataStore : public RooAbsDataStore {
0034 public:
0035 
0036   RooCompositeDataStore() ;
0037 
0038   // Ctors from DataStore
0039   RooCompositeDataStore(RooStringView name, RooStringView title, const RooArgSet& vars, RooCategory& indexCat, std::map<std::string,RooAbsDataStore*> const& inputData) ;
0040 
0041   // Empty constructor.
0042   RooAbsDataStore* clone(const char* newname=nullptr) const override { return new RooCompositeDataStore(*this,newname) ; }
0043   RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=nullptr) const override { return new RooCompositeDataStore(*this,vars,newname) ; }
0044 
0045   std::unique_ptr<RooAbsDataStore> reduce(RooStringView name, RooStringView title,
0046                           const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
0047                           std::size_t nStart, std::size_t nStop) override;
0048 
0049   RooCompositeDataStore(const RooCompositeDataStore& other, const char* newname=nullptr) ;
0050   RooCompositeDataStore(const RooCompositeDataStore& other, const RooArgSet& vars, const char* newname=nullptr) ;
0051 
0052   ~RooCompositeDataStore() override ;
0053 
0054   void dump() override ;
0055 
0056   // Write current row
0057   Int_t fill() override ;
0058 
0059   double sumEntries() const override ;
0060 
0061   // Retrieve a row
0062   using RooAbsDataStore::get ;
0063   const RooArgSet* get(Int_t index) const override ;
0064   using RooAbsDataStore::weight ;
0065   double weight() const override ;
0066   double weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const override ;
0067   void weightError(double& lo, double& hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const override ;
0068   bool isWeighted() const override ;
0069 
0070   // Change observable name
0071   bool changeObservableName(const char* from, const char* to) override ;
0072 
0073   // Add one column
0074   RooAbsArg* addColumn(RooAbsArg& var, bool adjustRange=true) override ;
0075 
0076   // Merge column-wise
0077   RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) override ;
0078 
0079   RooCategory* index() { return _indexCat ; }
0080 
0081   // Add rows
0082   void append(RooAbsDataStore& other) override ;
0083 
0084   // General & bookkeeping methods
0085   Int_t numEntries() const override ;
0086   void reset() override ;
0087 
0088   // Buffer redirection routines used in inside RooAbsOptTestStatistics
0089   void attachBuffers(const RooArgSet& extObs) override ;
0090   void resetBuffers() override ;
0091 
0092   // Constant term  optimizer interface
0093   void cacheArgs(const RooAbsArg* owner, RooArgSet& varSet, const RooArgSet* nset=nullptr, bool skipZeroWeights=false) override ;
0094   const RooAbsArg* cacheOwner() override { return nullptr ; }
0095   void setArgStatus(const RooArgSet& set, bool active) override ;
0096   void resetCache() override ;
0097 
0098   void recalculateCache(const RooArgSet* /*proj*/, Int_t /*firstEvent*/, Int_t /*lastEvent*/, Int_t /*stepSize*/, bool /*skipZeroWeights*/) override ;
0099   bool hasFilledCache() const override ;
0100 
0101   void loadValues(const RooAbsDataStore *tds, const RooFormulaVar* select=nullptr, const char* rangeName=nullptr,
0102       std::size_t nStart=0, std::size_t nStop = std::numeric_limits<std::size_t>::max()) override;
0103 
0104   void forceCacheUpdate() override ;
0105 
0106   RooAbsData::RealSpans getBatches(std::size_t first, std::size_t len) const override {
0107     //TODO
0108     std::cerr << "This functionality is not yet implemented for composite data stores." << std::endl;
0109     throw std::logic_error("getBatches() not implemented for RooCompositeDataStore.");
0110     (void)first; (void)len;
0111     return {};
0112   }
0113   std::span<const double> getWeightBatch(std::size_t first, std::size_t len) const override;
0114 
0115 
0116  protected:
0117 
0118   void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) override ;
0119 
0120   std::map<Int_t,RooAbsDataStore*> _dataMap ;
0121   RooCategory* _indexCat = nullptr;
0122   mutable RooAbsDataStore* _curStore = nullptr; ///<! Datastore associated with current event
0123   mutable Int_t _curIndex = 0; ///<! Index associated with current event
0124   mutable std::unique_ptr<std::vector<double>> _weightBuffer; ///<! Buffer for weights in case a batch of values is requested.
0125   bool _ownComps = false; ///<!
0126 
0127   ClassDefOverride(RooCompositeDataStore,1) // Composite Data Storage class
0128 };
0129 
0130 
0131 #endif