/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 * @(#)root/roofitcore:$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)             *
 *****************************************************************************/

//////////////////////////////////////////////////////////////////////////////
//
// BEGIN_HTML
// Class RooGenContext implement a universal generator context for all
// RooAbsPdf classes that do not have or need a specialized generator
// context. This generator context queries the input p.d.f which observables
// it can generate internally and delegates generation of those observables
// to the p.d.f if it deems that safe. The other observables are generated
// use a RooAcceptReject sampling technique.
// END_HTML
//


#include "RooFit.h"
#include "RooMsgService.h"
#include "Riostream.h"

#include "RooGenContext.h"
#include "RooGenContext.h"
#include "RooAbsPdf.h"
#include "RooDataSet.h"
#include "RooRealIntegral.h"
#include "RooAcceptReject.h"
#include "RooRealVar.h"
#include "RooDataHist.h"
#include "RooErrorHandler.h"
#include "RooNumGenConfig.h"
#include "RooNumGenFactory.h"

#include "TString.h"
#include "TIterator.h"
#include "TClass.h"



using namespace std;

ClassImp(RooGenContext)
  ;



//_____________________________________________________________________________
RooGenContext::RooGenContext(const RooAbsPdf &model, const RooArgSet &vars,
			     const RooDataSet *prototype, const RooArgSet* auxProto,
			     Bool_t verbose, const RooArgSet* forceDirect) :  
  RooAbsGenContext(model,vars,prototype,auxProto,verbose),
  _cloneSet(0), _pdfClone(0), _acceptRejectFunc(0), _generator(0),
  _maxVar(0), _uniIter(0), _updateFMaxPerEvent(0) 
{
  // Initialize a new context for generating events with the specified
  // variables, using the specified PDF model. A prototype dataset (if provided)
  // is not cloned and still belongs to the caller. The contents and shape
  // of this dataset can be changed between calls to generate() as long as the
  // expected columns to be copied to the generated dataset are present.
  // Any argument supplied in the forceDirect RooArgSet are always offered
  // for internal generation to the p.d.f., even if this is deemed unsafe by
  // the logic of RooGenContext.

  cxcoutI(Generation) << "RooGenContext::ctor() setting up event generator context for p.d.f. " << model.GetName() 
			<< " for generation of observable(s) " << vars ;
  if (prototype) ccxcoutI(Generation) << " with prototype data for " << *prototype->get() ;
  if (auxProto && auxProto->getSize()>0)  ccxcoutI(Generation) << " with auxiliary prototypes " << *auxProto ;
  if (forceDirect && forceDirect->getSize()>0)  ccxcoutI(Generation) << " with internal generation forced for observables " << *forceDirect ;
  ccxcoutI(Generation) << endl ;


  // Clone the model and all nodes that it depends on so that this context
  // is independent of any existing objects.
  RooArgSet nodes(model,model.GetName());
  _cloneSet= (RooArgSet*) nodes.snapshot(kTRUE);
  if (!_cloneSet) {
    coutE(Generation) << "RooGenContext::RooGenContext(" << GetName() << ") Couldn't deep-clone PDF, abort," << endl ;
    RooErrorHandler::softAbort() ;
  }

  // Find the clone in the snapshot list
  _pdfClone = (RooAbsPdf*)_cloneSet->find(model.GetName());
  _pdfClone->setOperMode(RooAbsArg::ADirty,kTRUE) ;

  // Optionally fix RooAddPdf normalizations
  if (prototype&&_pdfClone->dependsOn(*prototype->get())) {
    RooArgSet fullNormSet(vars) ;
    fullNormSet.add(*prototype->get()) ;
    _pdfClone->fixAddCoefNormalization(fullNormSet) ;
  }
      
  // Analyze the list of variables to generate...
  _isValid= kTRUE;
  TIterator *iterator= vars.createIterator();
  TIterator *servers= _pdfClone->serverIterator();
  const RooAbsArg *tmp = 0;
  const RooAbsArg *arg = 0;
  while((_isValid && (tmp= (const RooAbsArg*)iterator->Next()))) {
    // is this argument derived?
    if(!tmp->isFundamental()) {
      coutE(Generation) << "RooGenContext::ctor(): cannot generate values for derived \""  << tmp->GetName() << "\"" << endl;
      _isValid= kFALSE;
      continue;
    }
    // lookup this argument in the cloned set of PDF dependents
    arg= (const RooAbsArg*)_cloneSet->find(tmp->GetName());
    if(0 == arg) {
      coutI(Generation) << "RooGenContext::ctor() WARNING model does not depend on \"" << tmp->GetName() 
			  << "\" which will have uniform distribution" << endl;
      _uniformVars.add(*tmp);
    }
    else {

      // does the model depend on this variable directly, ie, like "x" in
      // f(x) or f(x,g(x,y)) or even f(x,x) ?      
      const RooAbsArg *direct= arg ;
      if (forceDirect==0 || !forceDirect->find(direct->GetName())) {
	if (!_pdfClone->isDirectGenSafe(*arg)) {
	  cxcoutD(Generation) << "RooGenContext::ctor() observable " << arg->GetName() << " has been determined to be unsafe for internal generation" << endl;
	  direct=0 ;
	}
      }
      
      // does the model depend indirectly on this variable through an lvalue chain?	
      // otherwise, this variable will have to be generated with accept/reject
      if(direct) { 
	_directVars.add(*arg);
      } else {
	_otherVars.add(*arg);
      }
    }
  }
  delete servers;
  delete iterator;
  if(!isValid()) {
    coutE(Generation) << "RooGenContext::ctor() constructor failed with errors" << endl;
    return;
  }

  // At this point directVars are all variables that are safe to be generated directly
  //               otherVars are all variables that are _not_ safe to be generated directly
  if (_directVars.getSize()>0) {
    cxcoutD(Generation) << "RooGenContext::ctor() observables " << _directVars << " are safe for internal generator (if supported by p.d.f)" << endl ;
  }
  if (_otherVars.getSize()>0) {
    cxcoutD(Generation) << "RooGenContext::ctor() observables " << _otherVars << " are NOT safe for internal generator (if supported by p.d.f)" << endl ;
  }

  // If PDF depends on prototype data, direct generator cannot use static initialization
  // in initGenerator()
  Bool_t staticInitOK = !_pdfClone->dependsOn(_protoVars) ;
  if (!staticInitOK) {
    cxcoutD(Generation) << "RooGenContext::ctor() Model depends on supplied protodata observables, static initialization of internal generator will not be allowed" << endl ;
  }
  
  // Can the model generate any of the direct variables itself?
  RooArgSet generatedVars;
  if (_directVars.getSize()>0) {
    _code= _pdfClone->getGenerator(_directVars,generatedVars,staticInitOK);
    
    cxcoutD(Generation) << "RooGenContext::ctor() Model indicates that it can internally generate observables " 
			  << generatedVars << " with configuration identifier " << _code << endl ;
  } else {
    _code = 0 ;
  }

  // Move variables which cannot be generated into the list to be generated with accept/reject
  _directVars.remove(generatedVars);
  _otherVars.add(_directVars);

  // Update _directVars to only include variables that will actually be directly generated
  _directVars.removeAll();
  _directVars.add(generatedVars);

  cxcoutI(Generation) << "RooGenContext::ctor() Context will" ;
  if (_directVars.getSize()>0) ccxcoutI(Generation) << " let model internally generate observables " << _directVars ;
  if (_directVars.getSize()>0 && _otherVars.getSize()>0)  ccxcoutI(Generation) << " and" ;
  if (_otherVars.getSize()>0)  ccxcoutI(Generation) << " generate variables " << _otherVars << " with accept/reject sampling" ;
  if (_uniformVars.getSize()>0) ccxcoutI(Generation) << ", non-observable variables " << _uniformVars << " will be generated with flat distribution" ;
  ccxcoutI(Generation) << endl ;

  // initialize the accept-reject generator
  RooArgSet *depList= _pdfClone->getObservables(_theEvent);
  depList->remove(_otherVars);

  TString nname(_pdfClone->GetName()) ;
  nname.Append("_AccRej") ;
  TString ntitle(_pdfClone->GetTitle()) ;
  ntitle.Append(" (Accept/Reject)") ;
  

  RooArgSet* protoDeps = model.getObservables(_protoVars) ;
  

  if (_protoVars.getSize()==0) {

    // No prototype variables
    
    if(depList->getSize()==0) {
      // All variable are generated with accept-reject
      
      // Check if PDF supports maximum finding
      Int_t maxFindCode = _pdfClone->getMaxVal(_otherVars) ;
      if (maxFindCode != 0) {
	coutI(Generation) << "RooGenContext::ctor() no prototype data provided, all observables are generated with numerically and "
			      << "model supports analytical maximum findin:, can provide analytical pdf maximum to numeric generator" << endl ;
	Double_t maxVal = _pdfClone->maxVal(maxFindCode) / _pdfClone->getNorm(_theEvent) ;
	_maxVar = new RooRealVar("funcMax","function maximum",maxVal) ;
	cxcoutD(Generation) << "RooGenContext::ctor() maximum value returned by RooAbsPdf::maxVal() is " << maxVal << endl ;
      }
    }

    if (_otherVars.getSize()>0) {
      _pdfClone->getVal(&vars) ; // WVE debug
      _acceptRejectFunc= new RooRealIntegral(nname,ntitle,*_pdfClone,*depList,&vars);
      cxcoutI(Generation) << "RooGenContext::ctor() accept/reject sampling function is " << _acceptRejectFunc->GetName() << endl ;
    } else {
      _acceptRejectFunc = 0 ;
    }

  } else {

    // Generation _with_ prototype variable
    depList->remove(_protoVars,kTRUE,kTRUE) ;
    _acceptRejectFunc= (RooRealIntegral*) _pdfClone->createIntegral(*depList,vars) ;
    cxcoutI(Generation) << "RooGenContext::ctor() accept/reject sampling function is " << _acceptRejectFunc->GetName() << endl ;
    
    // Check if PDF supports maximum finding for the entire phase space
    RooArgSet allVars(_otherVars);
    allVars.add(_directVars);
    Int_t maxFindCode = _pdfClone->getMaxVal(allVars) ;
    if (maxFindCode != 0) {
      // Special case: PDF supports max-finding in otherVars, no need to scan other+proto space for maximum
      coutI(Generation) << "RooGenContext::ctor() prototype data provided, and "
                        << "model supports analytical maximum finding in the full phase space: " 
                        << "can provide analytical pdf maximum to numeric generator" << endl ;
      _maxVar = new RooRealVar("funcMax","function maximum",_pdfClone->maxVal(maxFindCode)) ;
    } else {
      maxFindCode = _pdfClone->getMaxVal(_otherVars) ;
      if (maxFindCode != 0) {
         _updateFMaxPerEvent = maxFindCode ;
         coutI(Generation) << "RooGenContext::ctor() prototype data provided, and "
                           << "model supports analytical maximum finding in the variables which are not"
                           << " internally generated. Can provide analytical pdf maximum to numeric "
                           << "generator" << endl;
         cxcoutD(Generation) << "RooGenContext::ctor() maximum value must be reevaluated for each "
                             << "event with configuration code " << maxFindCode << endl ;
         _maxVar = new RooRealVar("funcMax","function maximum",1) ;    
      }
    }

    if (!_maxVar) {
      
      // Regular case: First find maximum in other+proto space
      RooArgSet otherAndProto(_otherVars) ;

      otherAndProto.add(*protoDeps) ;
      
      if (_otherVars.getSize()>0) {      

	cxcoutD(Generation) << "RooGenContext::ctor() prototype data provided, observables are generated numericaly no " 
			      << "analytical estimate of maximum function value provided by model, must determine maximum value through initial sampling space "
			      << "of accept/reject observables plus prototype observables: " << otherAndProto << endl ;

	// Calculate maximum in other+proto space if there are any accept/reject generated observables
	RooAbsNumGenerator* maxFinder = RooNumGenFactory::instance().createSampler(*_acceptRejectFunc,otherAndProto,RooArgSet(_protoVars),
										   *model.getGeneratorConfig(),_verbose) ;
// 	RooAcceptReject maxFinder(*_acceptRejectFunc,otherAndProto,RooNumGenConfig::defaultConfig(),_verbose) ;
	Double_t max = maxFinder->getFuncMax() ;
	_maxVar = new RooRealVar("funcMax","function maximum",max) ;

	if (max==0) {	  
	  coutE(Generation) << "RooGenContext::ctor(" << model.GetName() 
			    << ") ERROR: generating conditional p.d.f. which requires prior knowledge of function maximum, " 
			    << "but chosen numeric generator (" << maxFinder->IsA()->GetName() << ") does not support maximum finding" << endl ;	
	  delete maxFinder ;	
	  throw string("RooGenContext::ctor()") ;	  
	}	
	delete maxFinder ;	

	cxcoutD(Generation) << "RooGenContext::ctor() maximum function value found through initial sampling is " << max << endl ;
      }
    }
      
  }

  if (_acceptRejectFunc && _otherVars.getSize()>0) {
    _generator = RooNumGenFactory::instance().createSampler(*_acceptRejectFunc,_otherVars,RooArgSet(_protoVars),*model.getGeneratorConfig(),_verbose,_maxVar) ;    
    cxcoutD(Generation) << "RooGenContext::ctor() creating MC sampling generator " << _generator->IsA()->GetName() << "  from function for observables " << _otherVars << endl ;
    //_generator= new RooAcceptReject(*_acceptRejectFunc,_otherVars,RooNumGenConfig::defaultConfig(),_verbose,_maxVar);
  } else {
    _generator = 0 ;
  }

  delete protoDeps ;
  delete depList;
  _otherVars.add(_uniformVars);
}


//_____________________________________________________________________________
RooGenContext::~RooGenContext() 
{
  // Destructor.

  // Clean up the cloned objects used in this context.
  delete _cloneSet;

  // Clean up our accept/reject generator
  if (_generator) delete _generator;
  if (_acceptRejectFunc) delete _acceptRejectFunc;
  if (_maxVar) delete _maxVar ;
  if (_uniIter) delete _uniIter ;
}



//_____________________________________________________________________________
void RooGenContext::attach(const RooArgSet& args) 
{
  // Attach the cloned model to the event buffer we will be filling.
  
  _pdfClone->recursiveRedirectServers(args,kFALSE);
  if (_acceptRejectFunc) {
    _acceptRejectFunc->recursiveRedirectServers(args,kFALSE) ; // WVE DEBUG
  }

  // Attach the RooAcceptReject generator the event buffer
  if (_generator) {
    _generator->attachParameters(args) ;
  }

}



//_____________________________________________________________________________
void RooGenContext::initGenerator(const RooArgSet &theEvent) 
{
  // Perform one-time initialization of the generator context

  RooFIter iter = theEvent.fwdIterator() ;
  RooAbsArg* arg ;
  while((arg=iter.next())) {
    arg->setOperMode(RooAbsArg::ADirty) ;
  }

  attach(theEvent) ;

  // Reset the cloned model's error counters.
  _pdfClone->resetErrorCounters();

  // Initialize the PDFs internal generator
  if (_directVars.getSize()>0) {
    cxcoutD(Generation) << "RooGenContext::initGenerator() initializing internal generator of model with code " << _code << endl ;
    _pdfClone->initGenerator(_code) ;
  }

  // Create iterator for uniform vars (if any)
  if (_uniformVars.getSize()>0) {
    _uniIter = _uniformVars.createIterator() ;
  }
}


//_____________________________________________________________________________
void RooGenContext::generateEvent(RooArgSet &theEvent, Int_t remaining) 
{
  // Generate one event. The 'remaining' integer is not used other than
  // for printing messages 

  if(_otherVars.getSize() > 0) {
    // call the accept-reject generator to generate its variables

    if (_updateFMaxPerEvent!=0) {
      Double_t max = _pdfClone->maxVal(_updateFMaxPerEvent)/_pdfClone->getNorm(_otherVars) ;
      cxcoutD(Generation) << "RooGenContext::initGenerator() reevaluation of maximum function value is required for each event, new value is  " << max << endl ;
      _maxVar->setVal(max) ;
    }

    if (_generator) {
      Double_t resampleRatio(1) ;
      const RooArgSet *subEvent= _generator->generateEvent(remaining,resampleRatio);
      if (resampleRatio<1) {
	coutI(Generation) << "RooGenContext::generateEvent INFO: accept/reject generator requests resampling of previously produced events by factor " 
			  << resampleRatio << " due to increased maximum weight" << endl ; 
	resampleData(resampleRatio) ;
      }
      if(0 == subEvent) {
	coutE(Generation) << "RooGenContext::generateEvent ERROR accept/reject generator failed" << endl ;
	return;
      }
      theEvent.assignValueOnly(*subEvent) ;
      //theEvent= *subEvent;
      
    }
  }

  // Use the model's optimized generator, if one is available.
  // The generator writes directly into our local 'event' since we attached it above.
  if(_directVars.getSize() > 0) {
    _pdfClone->generateEvent(_code);
  }

  // Generate uniform variables (non-dependents)  
  if (_uniIter) {
    _uniIter->Reset() ;
    RooAbsArg* uniVar ;
    while((uniVar=(RooAbsArg*)_uniIter->Next())) {
      RooAbsLValue* arglv = dynamic_cast<RooAbsLValue*>(uniVar) ;
      if (!arglv) {
	coutE(Generation) << "RooGenContext::generateEvent(" << GetName() << ") ERROR: uniform variable " << uniVar->GetName() << " is not an lvalue" << endl ;
	RooErrorHandler::softAbort() ;
      }
      arglv->randomize() ;
    }
    theEvent = _uniformVars ;
  }

}


//_____________________________________________________________________________
void RooGenContext::printMultiline(ostream &os, Int_t content, Bool_t verbose, TString indent) const
{
  // Printing interface

  RooAbsGenContext::printMultiline(os,content,verbose,indent);
  os << indent << " --- RooGenContext --- " << endl ;
  os << indent << "Using PDF ";
  _pdfClone->printStream(os,kName|kArgs|kClassName,kSingleLine,indent);
  
  if(verbose) {
    os << indent << "Use PDF generator for " << _directVars << endl ;
    os << indent << "Use MC sampling generator " << (_generator ? _generator->IsA()->GetName() : "<none>") << " for " << _otherVars << endl ;
    if (_protoVars.getSize()>0) {
      os << indent << "Prototype observables are " << _protoVars << endl ;
    }
  }
}
 RooGenContext.cxx:1
 RooGenContext.cxx:2
 RooGenContext.cxx:3
 RooGenContext.cxx:4
 RooGenContext.cxx:5
 RooGenContext.cxx:6
 RooGenContext.cxx:7
 RooGenContext.cxx:8
 RooGenContext.cxx:9
 RooGenContext.cxx:10
 RooGenContext.cxx:11
 RooGenContext.cxx:12
 RooGenContext.cxx:13
 RooGenContext.cxx:14
 RooGenContext.cxx:15
 RooGenContext.cxx:16
 RooGenContext.cxx:17
 RooGenContext.cxx:18
 RooGenContext.cxx:19
 RooGenContext.cxx:20
 RooGenContext.cxx:21
 RooGenContext.cxx:22
 RooGenContext.cxx:23
 RooGenContext.cxx:24
 RooGenContext.cxx:25
 RooGenContext.cxx:26
 RooGenContext.cxx:27
 RooGenContext.cxx:28
 RooGenContext.cxx:29
 RooGenContext.cxx:30
 RooGenContext.cxx:31
 RooGenContext.cxx:32
 RooGenContext.cxx:33
 RooGenContext.cxx:34
 RooGenContext.cxx:35
 RooGenContext.cxx:36
 RooGenContext.cxx:37
 RooGenContext.cxx:38
 RooGenContext.cxx:39
 RooGenContext.cxx:40
 RooGenContext.cxx:41
 RooGenContext.cxx:42
 RooGenContext.cxx:43
 RooGenContext.cxx:44
 RooGenContext.cxx:45
 RooGenContext.cxx:46
 RooGenContext.cxx:47
 RooGenContext.cxx:48
 RooGenContext.cxx:49
 RooGenContext.cxx:50
 RooGenContext.cxx:51
 RooGenContext.cxx:52
 RooGenContext.cxx:53
 RooGenContext.cxx:54
 RooGenContext.cxx:55
 RooGenContext.cxx:56
 RooGenContext.cxx:57
 RooGenContext.cxx:58
 RooGenContext.cxx:59
 RooGenContext.cxx:60
 RooGenContext.cxx:61
 RooGenContext.cxx:62
 RooGenContext.cxx:63
 RooGenContext.cxx:64
 RooGenContext.cxx:65
 RooGenContext.cxx:66
 RooGenContext.cxx:67
 RooGenContext.cxx:68
 RooGenContext.cxx:69
 RooGenContext.cxx:70
 RooGenContext.cxx:71
 RooGenContext.cxx:72
 RooGenContext.cxx:73
 RooGenContext.cxx:74
 RooGenContext.cxx:75
 RooGenContext.cxx:76
 RooGenContext.cxx:77
 RooGenContext.cxx:78
 RooGenContext.cxx:79
 RooGenContext.cxx:80
 RooGenContext.cxx:81
 RooGenContext.cxx:82
 RooGenContext.cxx:83
 RooGenContext.cxx:84
 RooGenContext.cxx:85
 RooGenContext.cxx:86
 RooGenContext.cxx:87
 RooGenContext.cxx:88
 RooGenContext.cxx:89
 RooGenContext.cxx:90
 RooGenContext.cxx:91
 RooGenContext.cxx:92
 RooGenContext.cxx:93
 RooGenContext.cxx:94
 RooGenContext.cxx:95
 RooGenContext.cxx:96
 RooGenContext.cxx:97
 RooGenContext.cxx:98
 RooGenContext.cxx:99
 RooGenContext.cxx:100
 RooGenContext.cxx:101
 RooGenContext.cxx:102
 RooGenContext.cxx:103
 RooGenContext.cxx:104
 RooGenContext.cxx:105
 RooGenContext.cxx:106
 RooGenContext.cxx:107
 RooGenContext.cxx:108
 RooGenContext.cxx:109
 RooGenContext.cxx:110
 RooGenContext.cxx:111
 RooGenContext.cxx:112
 RooGenContext.cxx:113
 RooGenContext.cxx:114
 RooGenContext.cxx:115
 RooGenContext.cxx:116
 RooGenContext.cxx:117
 RooGenContext.cxx:118
 RooGenContext.cxx:119
 RooGenContext.cxx:120
 RooGenContext.cxx:121
 RooGenContext.cxx:122
 RooGenContext.cxx:123
 RooGenContext.cxx:124
 RooGenContext.cxx:125
 RooGenContext.cxx:126
 RooGenContext.cxx:127
 RooGenContext.cxx:128
 RooGenContext.cxx:129
 RooGenContext.cxx:130
 RooGenContext.cxx:131
 RooGenContext.cxx:132
 RooGenContext.cxx:133
 RooGenContext.cxx:134
 RooGenContext.cxx:135
 RooGenContext.cxx:136
 RooGenContext.cxx:137
 RooGenContext.cxx:138
 RooGenContext.cxx:139
 RooGenContext.cxx:140
 RooGenContext.cxx:141
 RooGenContext.cxx:142
 RooGenContext.cxx:143
 RooGenContext.cxx:144
 RooGenContext.cxx:145
 RooGenContext.cxx:146
 RooGenContext.cxx:147
 RooGenContext.cxx:148
 RooGenContext.cxx:149
 RooGenContext.cxx:150
 RooGenContext.cxx:151
 RooGenContext.cxx:152
 RooGenContext.cxx:153
 RooGenContext.cxx:154
 RooGenContext.cxx:155
 RooGenContext.cxx:156
 RooGenContext.cxx:157
 RooGenContext.cxx:158
 RooGenContext.cxx:159
 RooGenContext.cxx:160
 RooGenContext.cxx:161
 RooGenContext.cxx:162
 RooGenContext.cxx:163
 RooGenContext.cxx:164
 RooGenContext.cxx:165
 RooGenContext.cxx:166
 RooGenContext.cxx:167
 RooGenContext.cxx:168
 RooGenContext.cxx:169
 RooGenContext.cxx:170
 RooGenContext.cxx:171
 RooGenContext.cxx:172
 RooGenContext.cxx:173
 RooGenContext.cxx:174
 RooGenContext.cxx:175
 RooGenContext.cxx:176
 RooGenContext.cxx:177
 RooGenContext.cxx:178
 RooGenContext.cxx:179
 RooGenContext.cxx:180
 RooGenContext.cxx:181
 RooGenContext.cxx:182
 RooGenContext.cxx:183
 RooGenContext.cxx:184
 RooGenContext.cxx:185
 RooGenContext.cxx:186
 RooGenContext.cxx:187
 RooGenContext.cxx:188
 RooGenContext.cxx:189
 RooGenContext.cxx:190
 RooGenContext.cxx:191
 RooGenContext.cxx:192
 RooGenContext.cxx:193
 RooGenContext.cxx:194
 RooGenContext.cxx:195
 RooGenContext.cxx:196
 RooGenContext.cxx:197
 RooGenContext.cxx:198
 RooGenContext.cxx:199
 RooGenContext.cxx:200
 RooGenContext.cxx:201
 RooGenContext.cxx:202
 RooGenContext.cxx:203
 RooGenContext.cxx:204
 RooGenContext.cxx:205
 RooGenContext.cxx:206
 RooGenContext.cxx:207
 RooGenContext.cxx:208
 RooGenContext.cxx:209
 RooGenContext.cxx:210
 RooGenContext.cxx:211
 RooGenContext.cxx:212
 RooGenContext.cxx:213
 RooGenContext.cxx:214
 RooGenContext.cxx:215
 RooGenContext.cxx:216
 RooGenContext.cxx:217
 RooGenContext.cxx:218
 RooGenContext.cxx:219
 RooGenContext.cxx:220
 RooGenContext.cxx:221
 RooGenContext.cxx:222
 RooGenContext.cxx:223
 RooGenContext.cxx:224
 RooGenContext.cxx:225
 RooGenContext.cxx:226
 RooGenContext.cxx:227
 RooGenContext.cxx:228
 RooGenContext.cxx:229
 RooGenContext.cxx:230
 RooGenContext.cxx:231
 RooGenContext.cxx:232
 RooGenContext.cxx:233
 RooGenContext.cxx:234
 RooGenContext.cxx:235
 RooGenContext.cxx:236
 RooGenContext.cxx:237
 RooGenContext.cxx:238
 RooGenContext.cxx:239
 RooGenContext.cxx:240
 RooGenContext.cxx:241
 RooGenContext.cxx:242
 RooGenContext.cxx:243
 RooGenContext.cxx:244
 RooGenContext.cxx:245
 RooGenContext.cxx:246
 RooGenContext.cxx:247
 RooGenContext.cxx:248
 RooGenContext.cxx:249
 RooGenContext.cxx:250
 RooGenContext.cxx:251
 RooGenContext.cxx:252
 RooGenContext.cxx:253
 RooGenContext.cxx:254
 RooGenContext.cxx:255
 RooGenContext.cxx:256
 RooGenContext.cxx:257
 RooGenContext.cxx:258
 RooGenContext.cxx:259
 RooGenContext.cxx:260
 RooGenContext.cxx:261
 RooGenContext.cxx:262
 RooGenContext.cxx:263
 RooGenContext.cxx:264
 RooGenContext.cxx:265
 RooGenContext.cxx:266
 RooGenContext.cxx:267
 RooGenContext.cxx:268
 RooGenContext.cxx:269
 RooGenContext.cxx:270
 RooGenContext.cxx:271
 RooGenContext.cxx:272
 RooGenContext.cxx:273
 RooGenContext.cxx:274
 RooGenContext.cxx:275
 RooGenContext.cxx:276
 RooGenContext.cxx:277
 RooGenContext.cxx:278
 RooGenContext.cxx:279
 RooGenContext.cxx:280
 RooGenContext.cxx:281
 RooGenContext.cxx:282
 RooGenContext.cxx:283
 RooGenContext.cxx:284
 RooGenContext.cxx:285
 RooGenContext.cxx:286
 RooGenContext.cxx:287
 RooGenContext.cxx:288
 RooGenContext.cxx:289
 RooGenContext.cxx:290
 RooGenContext.cxx:291
 RooGenContext.cxx:292
 RooGenContext.cxx:293
 RooGenContext.cxx:294
 RooGenContext.cxx:295
 RooGenContext.cxx:296
 RooGenContext.cxx:297
 RooGenContext.cxx:298
 RooGenContext.cxx:299
 RooGenContext.cxx:300
 RooGenContext.cxx:301
 RooGenContext.cxx:302
 RooGenContext.cxx:303
 RooGenContext.cxx:304
 RooGenContext.cxx:305
 RooGenContext.cxx:306
 RooGenContext.cxx:307
 RooGenContext.cxx:308
 RooGenContext.cxx:309
 RooGenContext.cxx:310
 RooGenContext.cxx:311
 RooGenContext.cxx:312
 RooGenContext.cxx:313
 RooGenContext.cxx:314
 RooGenContext.cxx:315
 RooGenContext.cxx:316
 RooGenContext.cxx:317
 RooGenContext.cxx:318
 RooGenContext.cxx:319
 RooGenContext.cxx:320
 RooGenContext.cxx:321
 RooGenContext.cxx:322
 RooGenContext.cxx:323
 RooGenContext.cxx:324
 RooGenContext.cxx:325
 RooGenContext.cxx:326
 RooGenContext.cxx:327
 RooGenContext.cxx:328
 RooGenContext.cxx:329
 RooGenContext.cxx:330
 RooGenContext.cxx:331
 RooGenContext.cxx:332
 RooGenContext.cxx:333
 RooGenContext.cxx:334
 RooGenContext.cxx:335
 RooGenContext.cxx:336
 RooGenContext.cxx:337
 RooGenContext.cxx:338
 RooGenContext.cxx:339
 RooGenContext.cxx:340
 RooGenContext.cxx:341
 RooGenContext.cxx:342
 RooGenContext.cxx:343
 RooGenContext.cxx:344
 RooGenContext.cxx:345
 RooGenContext.cxx:346
 RooGenContext.cxx:347
 RooGenContext.cxx:348
 RooGenContext.cxx:349
 RooGenContext.cxx:350
 RooGenContext.cxx:351
 RooGenContext.cxx:352
 RooGenContext.cxx:353
 RooGenContext.cxx:354
 RooGenContext.cxx:355
 RooGenContext.cxx:356
 RooGenContext.cxx:357
 RooGenContext.cxx:358
 RooGenContext.cxx:359
 RooGenContext.cxx:360
 RooGenContext.cxx:361
 RooGenContext.cxx:362
 RooGenContext.cxx:363
 RooGenContext.cxx:364
 RooGenContext.cxx:365
 RooGenContext.cxx:366
 RooGenContext.cxx:367
 RooGenContext.cxx:368
 RooGenContext.cxx:369
 RooGenContext.cxx:370
 RooGenContext.cxx:371
 RooGenContext.cxx:372
 RooGenContext.cxx:373
 RooGenContext.cxx:374
 RooGenContext.cxx:375
 RooGenContext.cxx:376
 RooGenContext.cxx:377
 RooGenContext.cxx:378
 RooGenContext.cxx:379
 RooGenContext.cxx:380
 RooGenContext.cxx:381
 RooGenContext.cxx:382
 RooGenContext.cxx:383
 RooGenContext.cxx:384
 RooGenContext.cxx:385
 RooGenContext.cxx:386
 RooGenContext.cxx:387
 RooGenContext.cxx:388
 RooGenContext.cxx:389
 RooGenContext.cxx:390
 RooGenContext.cxx:391
 RooGenContext.cxx:392
 RooGenContext.cxx:393
 RooGenContext.cxx:394
 RooGenContext.cxx:395
 RooGenContext.cxx:396
 RooGenContext.cxx:397
 RooGenContext.cxx:398
 RooGenContext.cxx:399
 RooGenContext.cxx:400
 RooGenContext.cxx:401
 RooGenContext.cxx:402
 RooGenContext.cxx:403
 RooGenContext.cxx:404
 RooGenContext.cxx:405
 RooGenContext.cxx:406
 RooGenContext.cxx:407
 RooGenContext.cxx:408
 RooGenContext.cxx:409
 RooGenContext.cxx:410
 RooGenContext.cxx:411
 RooGenContext.cxx:412
 RooGenContext.cxx:413
 RooGenContext.cxx:414
 RooGenContext.cxx:415
 RooGenContext.cxx:416
 RooGenContext.cxx:417
 RooGenContext.cxx:418
 RooGenContext.cxx:419
 RooGenContext.cxx:420
 RooGenContext.cxx:421
 RooGenContext.cxx:422
 RooGenContext.cxx:423
 RooGenContext.cxx:424
 RooGenContext.cxx:425
 RooGenContext.cxx:426
 RooGenContext.cxx:427
 RooGenContext.cxx:428
 RooGenContext.cxx:429
 RooGenContext.cxx:430
 RooGenContext.cxx:431
 RooGenContext.cxx:432
 RooGenContext.cxx:433
 RooGenContext.cxx:434
 RooGenContext.cxx:435
 RooGenContext.cxx:436
 RooGenContext.cxx:437
 RooGenContext.cxx:438
 RooGenContext.cxx:439
 RooGenContext.cxx:440
 RooGenContext.cxx:441
 RooGenContext.cxx:442
 RooGenContext.cxx:443
 RooGenContext.cxx:444
 RooGenContext.cxx:445
 RooGenContext.cxx:446
 RooGenContext.cxx:447
 RooGenContext.cxx:448
 RooGenContext.cxx:449
 RooGenContext.cxx:450
 RooGenContext.cxx:451
 RooGenContext.cxx:452