/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooAbsGenContext.h,v 1.15 2007/05/11 09:11:30 verkerke Exp $
 * 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_GEN_CONTEXT
#define ROO_ABS_GEN_CONTEXT

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

class RooDataSet;

class RooAbsGenContext : public TNamed, public RooPrintable {
public:
  RooAbsGenContext(const RooAbsPdf &model, const RooArgSet &vars, const RooDataSet *prototype= 0, const RooArgSet* auxProto=0,
		   Bool_t _verbose= kFALSE) ;
  virtual ~RooAbsGenContext();
  
  virtual RooDataSet *generate(Double_t nEvents= 0, Bool_t skipInit=kFALSE, Bool_t extendedMode=kFALSE);

  Bool_t isValid() const { 
    // If true generator context is in a valid state
    return _isValid; 
  }

  inline void setVerbose(Bool_t verbose= kTRUE) { 
    // Set/clear verbose messaging
    _verbose= verbose; 
  }
  inline Bool_t isVerbose() const { 
    // If true verbose messaging is active
    return _verbose; 
  }

  virtual void setProtoDataOrder(Int_t* lut) ;

   inline virtual void Print(Option_t *options= 0) const {
     // Print context information on stdout
     printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
  }

  virtual void attach(const RooArgSet& params) ;

  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 ;
  virtual void printMultiline(std::ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const;

  virtual Int_t defaultPrintContents(Option_t* opt) const ;
  virtual StyleOption defaultPrintStyle(Option_t* opt) const ;

  virtual void setExpectedData(Bool_t) {} ;

protected:

  virtual RooDataSet* createDataSet(const char* name, const char* title, const RooArgSet& obs) ;

  friend class RooConvGenContext ;
  friend class RooProdGenContext ;
  friend class RooAddGenContext ;
  friend class RooSimGenContext ;
  friend class RooSimSplitGenContext ;
  friend class RooEffGenContext ;

  virtual void initGenerator(const RooArgSet &theEvent);
  virtual void generateEvent(RooArgSet &theEvent, Int_t remaining) = 0;

  void resampleData(Double_t& ratio) ;

  const RooDataSet *_prototype; // Pointer to prototype dataset
  RooArgSet *_theEvent;         // Pointer to observable event being generated
  Bool_t _isValid;              // Is context in valid state?
  Bool_t _verbose;              // Verbose messaging?
  UInt_t _expectedEvents;       // Number of expected events from extended p.d.f
  RooArgSet _protoVars;         // Prototype observables
  Int_t _nextProtoIndex;        // Next prototype event to load according to LUT
  RooAbsPdf::ExtendMode _extendMode ;  // Extended mode capabilities of p.d.f.
  Int_t* _protoOrder ;          // LUT with traversal order of prototype data
  TString _normRange ;          // Normalization range of pdf

  RooDataSet* _genData ;        //! Data being generated

  ClassDef(RooAbsGenContext,0) // Abstract context for generating a dataset from a PDF
};

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