/*****************************************************************************
 * Project: RooFit                                                           *
 *                                                                           *
  * This code was autogenerated by RooClassFactory                            * 
 *****************************************************************************/

#ifndef ROOMOMENTMORPH
#define ROOMOMENTMORPH

#include "RooAbsPdf.h"
#include "RooRealProxy.h"
#include "RooCategoryProxy.h"
#include "RooAbsReal.h"
#include "RooAbsCategory.h"
#include "RooSetProxy.h"
#include "RooListProxy.h"
#include "RooArgList.h"

#include "TMatrixD.h"
#include "TVectorD.h"

#include <vector>
#include <string>
class RooChangeTracker ;

class RooMomentMorph : public RooAbsPdf {
public:

  enum Setting { Linear, NonLinear, NonLinearPosFractions, NonLinearLinFractions, SineLinear } ;

  RooMomentMorph() ;

  RooMomentMorph(const char *name, const char *title, RooAbsReal& _m, const RooArgList& varList,
	       const RooArgList& pdfList, const RooArgList& mrefList, Setting setting = NonLinearPosFractions);
  RooMomentMorph(const char *name, const char *title, RooAbsReal& _m, const RooArgList& varList,
	       const RooArgList& pdfList, const TVectorD& mrefpoints, Setting setting = NonLinearPosFractions );
  RooMomentMorph(const RooMomentMorph& other, const char* name=0) ;
  virtual TObject* clone(const char* newname) const { return new RooMomentMorph(*this,newname); }
  virtual ~RooMomentMorph();

  void     setMode(const Setting& setting) { _setting = setting; }

  void useHorizontalMorphing(bool val) { _useHorizMorph = val; }

  virtual Bool_t selfNormalized() const { 
    // P.d.f is self normalized
    return kTRUE ; 
  }

  virtual Double_t getVal(const RooArgSet* set=0) const ;
  RooAbsPdf* sumPdf(const RooArgSet* nset) ;


protected:

  class CacheElem : public RooAbsCacheElement {
  public:
    CacheElem(RooAbsPdf& sumPdf, RooChangeTracker& tracker, const RooArgList& flist) : _sumPdf(&sumPdf), _tracker(&tracker) { _frac.add(flist) ; } ;
    void operModeHook(RooAbsArg::OperMode) {};
    virtual ~CacheElem() ; 
    virtual RooArgList containedArgs(Action) ;
    RooAbsPdf* _sumPdf ;
    RooChangeTracker* _tracker ; 
    RooArgList _frac ;

    RooRealVar* frac(Int_t i ) ;
    const RooRealVar* frac(Int_t i ) const ; 
    void calculateFractions(const RooMomentMorph& self, Bool_t verbose=kTRUE) const;
  } ;
  mutable RooObjCacheManager _cacheMgr ; //! The cache manager
  mutable RooArgSet* _curNormSet ; //! Current normalization set

  friend class CacheElem ; // Cache needs to be able to clear _norm pointer

  Double_t evaluate() const ;

  void     initialize();
  CacheElem* getCache(const RooArgSet* nset) const ;

  inline   Int_t ij(const Int_t& i, const Int_t& j) const { return (i*_varList.getSize()+j); }
  int      idxmin(const double& m) const;
  int      idxmax(const double& m) const;

  RooRealProxy m ;
  RooSetProxy  _varList ;
  RooListProxy _pdfList ;
  mutable TVectorD* _mref;

  TIterator* _varItr ;   //! do not persist
  TIterator* _pdfItr ;   //!
  mutable TMatrixD* _M; //

  Setting _setting;

  bool _useHorizMorph;

  ClassDef(RooMomentMorph,3) // Your description goes here...
};
 
#endif


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