ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooCompositeDataStore.h 31258 2009-11-17 22:41:06Z wouter $
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
 *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
 *                                                                           *
 * Copyright (c) 2000-2005, Regents of the University of California          *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/
#ifndef ROO_COMPOSITE_DATA_STORE
#define ROO_COMPOSITE_DATA_STORE

#include "RooAbsDataStore.h" 
#include "TString.h"
#include <map>
#include <string>

class RooAbsArg ;
class RooArgList ;
class RooFormulaVar ;
class RooArgSet ;
class RooCategory ;


class RooCompositeDataStore : public RooAbsDataStore {
public:

  RooCompositeDataStore() ; 

  // Ctors from DataStore
  RooCompositeDataStore(const char* name, const char* title, const RooArgSet& vars, RooCategory& indexCat, std::map<std::string,RooAbsDataStore*> inputData) ;

  // Empty ctor
  virtual RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=0) const { return new RooCompositeDataStore(*this,vars,newname) ; }

  RooCompositeDataStore(const RooCompositeDataStore& other, const char* newname=0) ;
  RooCompositeDataStore(const RooCompositeDataStore& other, const RooArgSet& vars, const char* newname=0) ;
  virtual ~RooCompositeDataStore() ;


  // Write current row
  virtual Int_t fill() ;

  // Retrieve a row
  using RooAbsDataStore::get ;
  virtual const RooArgSet* get(Int_t index) const ;
  virtual Double_t weight() const ;
  virtual Double_t weight(Int_t index) const ;
  virtual Double_t weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const ;
  virtual void weightError(Double_t& lo, Double_t& hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const ; 
  virtual Bool_t isWeighted() const ;

  // Change observable name
  virtual Bool_t changeObservableName(const char* from, const char* to) ;
  
  // Add one or more columns
  virtual RooAbsArg* addColumn(RooAbsArg& var, Bool_t adjustRange=kTRUE) ;
  virtual RooArgSet* addColumns(const RooArgList& varList) ;

  // Merge column-wise
  RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) ;

  // Add rows 
  virtual void append(RooAbsDataStore& other) ;

  // General & bookkeeping methods
  virtual Bool_t valid() const ;
  virtual Int_t numEntries() const ;
  virtual void reset() ;
  
  // Constant term  optimizer interface
  virtual void cacheArgs(const RooAbsArg* owner, RooArgSet& varSet, const RooArgSet* nset=0) ;
  virtual const RooAbsArg* cacheOwner() { return 0 ; }
  virtual void setArgStatus(const RooArgSet& set, Bool_t active) ;
  virtual void resetCache() ;
  
 protected:

  void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) ;

  std::map<std::string,RooAbsDataStore*> _dataMap ;
  RooCategory* _indexCat ;
  mutable RooAbsDataStore* _curStore ; //! Datastore associated with current event
  mutable Int_t _curIndex ; //! Index associated with current event

  ClassDef(RooCompositeDataStore,1) // Composite Data Storage class
};


#endif
 RooCompositeDataStore.h:1
 RooCompositeDataStore.h:2
 RooCompositeDataStore.h:3
 RooCompositeDataStore.h:4
 RooCompositeDataStore.h:5
 RooCompositeDataStore.h:6
 RooCompositeDataStore.h:7
 RooCompositeDataStore.h:8
 RooCompositeDataStore.h:9
 RooCompositeDataStore.h:10
 RooCompositeDataStore.h:11
 RooCompositeDataStore.h:12
 RooCompositeDataStore.h:13
 RooCompositeDataStore.h:14
 RooCompositeDataStore.h:15
 RooCompositeDataStore.h:16
 RooCompositeDataStore.h:17
 RooCompositeDataStore.h:18
 RooCompositeDataStore.h:19
 RooCompositeDataStore.h:20
 RooCompositeDataStore.h:21
 RooCompositeDataStore.h:22
 RooCompositeDataStore.h:23
 RooCompositeDataStore.h:24
 RooCompositeDataStore.h:25
 RooCompositeDataStore.h:26
 RooCompositeDataStore.h:27
 RooCompositeDataStore.h:28
 RooCompositeDataStore.h:29
 RooCompositeDataStore.h:30
 RooCompositeDataStore.h:31
 RooCompositeDataStore.h:32
 RooCompositeDataStore.h:33
 RooCompositeDataStore.h:34
 RooCompositeDataStore.h:35
 RooCompositeDataStore.h:36
 RooCompositeDataStore.h:37
 RooCompositeDataStore.h:38
 RooCompositeDataStore.h:39
 RooCompositeDataStore.h:40
 RooCompositeDataStore.h:41
 RooCompositeDataStore.h:42
 RooCompositeDataStore.h:43
 RooCompositeDataStore.h:44
 RooCompositeDataStore.h:45
 RooCompositeDataStore.h:46
 RooCompositeDataStore.h:47
 RooCompositeDataStore.h:48
 RooCompositeDataStore.h:49
 RooCompositeDataStore.h:50
 RooCompositeDataStore.h:51
 RooCompositeDataStore.h:52
 RooCompositeDataStore.h:53
 RooCompositeDataStore.h:54
 RooCompositeDataStore.h:55
 RooCompositeDataStore.h:56
 RooCompositeDataStore.h:57
 RooCompositeDataStore.h:58
 RooCompositeDataStore.h:59
 RooCompositeDataStore.h:60
 RooCompositeDataStore.h:61
 RooCompositeDataStore.h:62
 RooCompositeDataStore.h:63
 RooCompositeDataStore.h:64
 RooCompositeDataStore.h:65
 RooCompositeDataStore.h:66
 RooCompositeDataStore.h:67
 RooCompositeDataStore.h:68
 RooCompositeDataStore.h:69
 RooCompositeDataStore.h:70
 RooCompositeDataStore.h:71
 RooCompositeDataStore.h:72
 RooCompositeDataStore.h:73
 RooCompositeDataStore.h:74
 RooCompositeDataStore.h:75
 RooCompositeDataStore.h:76
 RooCompositeDataStore.h:77
 RooCompositeDataStore.h:78
 RooCompositeDataStore.h:79
 RooCompositeDataStore.h:80
 RooCompositeDataStore.h:81
 RooCompositeDataStore.h:82
 RooCompositeDataStore.h:83
 RooCompositeDataStore.h:84
 RooCompositeDataStore.h:85
 RooCompositeDataStore.h:86
 RooCompositeDataStore.h:87
 RooCompositeDataStore.h:88
 RooCompositeDataStore.h:89
 RooCompositeDataStore.h:90
 RooCompositeDataStore.h:91
 RooCompositeDataStore.h:92
 RooCompositeDataStore.h:93
 RooCompositeDataStore.h:94
 RooCompositeDataStore.h:95
 RooCompositeDataStore.h:96