/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id$
 * 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_ABS_NUM_GENERATOR
#define ROO_ABS_NUM_GENERATOR

#include "TNamed.h"
#include "RooPrintable.h"
#include "RooArgSet.h"
#include "RooArgList.h"

class RooAbsReal;
class RooRealVar;
class RooDataSet;
class RooRealBinding;
class RooNumGenConfig ;

class RooAbsNumGenerator : public TNamed, public RooPrintable {
public:
  RooAbsNumGenerator() : _cloneSet(0), _funcClone(0), _funcMaxVal(0), _verbose(kFALSE), _isValid(kFALSE), _funcValStore(0), _funcValPtr(0), _cache(0) {} ;
  RooAbsNumGenerator(const RooAbsReal &func, const RooArgSet &genVars, Bool_t verbose=kFALSE, const RooAbsReal* maxFuncVal=0);
  virtual RooAbsNumGenerator* clone(const RooAbsReal&, const RooArgSet& genVars, const RooArgSet& condVars, 
				    const RooNumGenConfig& config, Bool_t verbose=kFALSE, const RooAbsReal* maxFuncVal=0) const = 0 ;

  Bool_t isValid() const { 
    // If true, generator is in a valid state
    return _isValid; 
  }
  virtual ~RooAbsNumGenerator();

  inline void setVerbose(Bool_t verbose= kTRUE) {
    // If flag is true, verbose messaging will be active during generation
    _verbose= verbose; 
  }
  inline Bool_t isVerbose() const { 
    // Return status of verbose messaging flag
    return _verbose; 
  }

  virtual const RooArgSet *generateEvent(UInt_t remaining, Double_t& resampleRatio) = 0;
  virtual Double_t getFuncMax() { return 0 ; }

   inline virtual void Print(Option_t *options= 0) const {
     // ascii printing interface     
    printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
  }

  virtual void printName(std::ostream& os) const ;
  virtual void printTitle(std::ostream& os) const ;
  virtual void printClassName(std::ostream& os) const ;
  virtual void printArgs(std::ostream& os) const ;
  
  void attachParameters(const RooArgSet& vars) ;

  // Advertisement of capabilities
  virtual Bool_t canSampleCategories() const { return kFALSE ; }
  virtual Bool_t canSampleConditional() const { return kFALSE ; } // Must implement getFuncMax() 

protected:

  RooArgSet *_cloneSet;                // Set owning clone of input function
  RooAbsReal *_funcClone;              // Pointer to top level node of cloned function
  const RooAbsReal *_funcMaxVal ;      // Container for maximum function value
  RooArgSet _catVars,_realVars ;       // Sets of discrete and real valued observabeles
  Bool_t _verbose, _isValid;           // Verbose and valid flag
  RooRealVar *_funcValStore,*_funcValPtr; // RRVs storing function value in context and in output dataset

  RooDataSet *_cache;                  // Dataset holding generared values of observables

  ClassDef(RooAbsNumGenerator,0) // Abstract base class for numeric event generator algorithms
};

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