/*****************************************************************************
 * 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 RooAcceptReject is a generic toy monte carlo generator implement
// the accept/reject sampling technique on any positively valued function.
// The RooAcceptReject generator is used by the various generator context
// classes to take care of generation of observables for which p.d.fs
// do not define internal methods
// END_HTML
//


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

#include "RooAcceptReject.h"
#include "RooAcceptReject.h"
#include "RooAbsReal.h"
#include "RooCategory.h"
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooRandom.h"
#include "RooErrorHandler.h"

#include "TString.h"
#include "TIterator.h"
#include "RooMsgService.h"
#include "TClass.h"
#include "TFoam.h"
#include "RooRealBinding.h"
#include "RooNumGenFactory.h"
#include "RooNumGenConfig.h"

#include <assert.h>

using namespace std;

ClassImp(RooAcceptReject)
  ;


//_____________________________________________________________________________
void RooAcceptReject::registerSampler(RooNumGenFactory& fact)
{
  // Register RooIntegrator1D, is parameters and capabilities with RooNumIntFactory 
  RooRealVar nTrial0D("nTrial0D","Number of trial samples for cat-only generation",100,0,1e9) ;
  RooRealVar nTrial1D("nTrial1D","Number of trial samples for 1-dim generation",1000,0,1e9) ;
  RooRealVar nTrial2D("nTrial2D","Number of trial samples for 2-dim generation",100000,0,1e9) ;
  RooRealVar nTrial3D("nTrial3D","Number of trial samples for N-dim generation",10000000,0,1e9) ;

  RooAcceptReject* proto = new RooAcceptReject ;
  fact.storeProtoSampler(proto,RooArgSet(nTrial0D,nTrial1D,nTrial2D,nTrial3D)) ;
}



//_____________________________________________________________________________
RooAcceptReject::RooAcceptReject(const RooAbsReal &func, const RooArgSet &genVars, const RooNumGenConfig& config, Bool_t verbose, const RooAbsReal* maxFuncVal) :
  RooAbsNumGenerator(func,genVars,verbose,maxFuncVal), _nextCatVar(0), _nextRealVar(0)
{
  // Initialize an accept-reject generator for the specified distribution function,
  // which must be non-negative but does not need to be normalized over the
  // variables to be generated, genVars. The function and its dependents are
  // cloned and so will not be disturbed during the generation process.

  _minTrialsArray[0] = static_cast<Int_t>(config.getConfigSection("RooAcceptReject").getRealValue("nTrial0D")) ;
  _minTrialsArray[1] = static_cast<Int_t>(config.getConfigSection("RooAcceptReject").getRealValue("nTrial1D")) ;
  _minTrialsArray[2] = static_cast<Int_t>(config.getConfigSection("RooAcceptReject").getRealValue("nTrial2D")) ;
  _minTrialsArray[3] = static_cast<Int_t>(config.getConfigSection("RooAcceptReject").getRealValue("nTrial3D")) ;

  _realSampleDim = _realVars.getSize() ;
  TIterator* iter = _catVars.createIterator() ;
  RooAbsCategory* cat ;
  _catSampleMult = 1 ;
  while((cat=(RooAbsCategory*)iter->Next())) {
    _catSampleMult *=  cat->numTypes() ;
  }
  delete iter ;


  // calculate the minimum number of trials needed to estimate our integral and max value
  if (!_funcMaxVal) {

    if(_realSampleDim > 3) {
      _minTrials= _minTrialsArray[3]*_catSampleMult;
      coutW(Generation) << fName << "::" << ClassName() << ": WARNING: generating " << _realSampleDim
			<< " variables with accept-reject may not be accurate" << endl;
    }
    else {
      _minTrials= _minTrialsArray[_realSampleDim]*_catSampleMult;
    }
    if (_realSampleDim > 1) {
       coutW(Generation) << "RooAcceptReject::ctor(" << fName 
                         << ") WARNING: performing accept/reject sampling on a p.d.f in " 
                         << _realSampleDim << " dimensions without prior knowledge on maximum value "
                         << "of p.d.f. Determining maximum value by taking " << _minTrials 
                         << " trial samples. If p.d.f contains sharp peaks smaller than average "
                         << "distance between trial sampling points these may be missed and p.d.f. "
                         << "may be sampled incorrectly." << endl ;
    }
  } else {
    // No trials needed if we know the maximum a priori
    _minTrials=0 ;
  }

  // Need to fix some things here
  if (_minTrials>10000) {
    coutW(Generation) << "RooAcceptReject::ctor(" << fName << "): WARNING: " << _minTrials << " trial samples requested by p.d.f for " 
		      << _realSampleDim << "-dimensional accept/reject sampling, this may take some time" << endl ;
  }

  // print a verbose summary of our configuration, if requested
  if(_verbose) {
    coutI(Generation) << fName << "::" << ClassName() << ":" << endl
		      << "  Initializing accept-reject generator for" << endl << "    ";
    _funcClone->printStream(ccoutI(Generation),kName,kSingleLine);
    if (_funcMaxVal) {
      ccoutI(Generation) << "  Function maximum provided, no trial sampling performed" << endl ;
    } else {
      ccoutI(Generation) << "  Real sampling dimension is " << _realSampleDim << endl;
      ccoutI(Generation) << "  Category sampling multiplier is " << _catSampleMult << endl ;
      ccoutI(Generation) << "  Min sampling trials is " << _minTrials << endl;
    }
    if (_catVars.getSize()>0) {
      ccoutI(Generation) << "  Will generate category vars "<< _catVars << endl ;
    }
    if (_realVars.getSize()>0) {
      ccoutI(Generation) << "  Will generate real vars " << _realVars << endl ;
    }
  }
  // create iterators for the new sets
  _nextCatVar= _catVars.createIterator();
  _nextRealVar= _realVars.createIterator();
  assert(0 != _nextCatVar && 0 != _nextRealVar);

  // initialize our statistics
  _maxFuncVal= 0;
  _funcSum= 0;
  _totalEvents= 0;
  _eventsUsed= 0;
}



//_____________________________________________________________________________
RooAcceptReject::~RooAcceptReject() 
{
  // Destructor
  delete _nextCatVar;
  delete _nextRealVar;
}



//_____________________________________________________________________________
const RooArgSet *RooAcceptReject::generateEvent(UInt_t remaining, Double_t& resampleRatio) 
{
  // Return a pointer to a generated event. The caller does not own the event and it
  // will be overwritten by a subsequent call. The input parameter 'remaining' should
  // contain your best guess at the total number of subsequent events you will request.

  // are we actually generating anything? (the cache always contains at least our function value)
  const RooArgSet *event= _cache->get();
  if(event->getSize() == 1) return event;

  if (!_funcMaxVal) {
    // Generation with empirical maximum determination

    // first generate enough events to get reasonable estimates for the integral and
    // maximum function value

    while(_totalEvents < _minTrials) {
      addEventToCache();

      // Limit cache size to 1M events
      if (_cache->numEntries()>1000000) {
	coutI(Generation) << "RooAcceptReject::generateEvent: resetting event cache" << endl ;
	_cache->reset() ;
	_eventsUsed = 0 ;
      }
    }
    
    event= 0;
    Double_t oldMax2(_maxFuncVal);
    while(0 == event) {
      // Use any cached events first
      if (_maxFuncVal>oldMax2) {
	cxcoutD(Generation) << "RooAcceptReject::generateEvent maxFuncVal has changed, need to resample already accepted events by factor" 
			    << oldMax2 << "/" << _maxFuncVal << "=" << oldMax2/_maxFuncVal << endl ;	
	resampleRatio=oldMax2/_maxFuncVal ;
      }
      event= nextAcceptedEvent();
      if(event) break;
      // When we have used up the cache, start a new cache and add
      // some more events to it.      
      _cache->reset();
      _eventsUsed= 0;
      // Calculate how many more events to generate using our best estimate of our efficiency.
      // Always generate at least one more event so we don't get stuck.
      if(_totalEvents*_maxFuncVal <= 0) {
	coutE(Generation) << "RooAcceptReject::generateEvent: cannot estimate efficiency...giving up" << endl;
	return 0;
      }

      Double_t eff= _funcSum/(_totalEvents*_maxFuncVal);
      Long64_t extra= 1 + (Long64_t)(1.05*remaining/eff);
      cxcoutD(Generation) << "RooAcceptReject::generateEvent: adding " << extra << " events to the cache, eff = " << eff << endl;
      Double_t oldMax(_maxFuncVal);
      while(extra--) {
	addEventToCache();
	if((_maxFuncVal > oldMax)) {
	  cxcoutD(Generation) << "RooAcceptReject::generateEvent: estimated function maximum increased from "
			      << oldMax << " to " << _maxFuncVal << endl;
	  oldMax = _maxFuncVal ;
	  // Trim cache here
	}
      }
    }

    // Limit cache size to 1M events
    if (_eventsUsed>1000000) {
      _cache->reset() ;
      _eventsUsed = 0 ;
    }

  } else {
    // Generation with a priori maximum knowledge
    _maxFuncVal = _funcMaxVal->getVal() ;
    
    // Generate enough trials to produce a single accepted event
    event = 0 ;
    while(0==event) {
      addEventToCache() ;
      event = nextAcceptedEvent() ;
    }

  }
  return event;
}



//_____________________________________________________________________________
const RooArgSet *RooAcceptReject::nextAcceptedEvent() 
{
  // Scan through events in the cache which have not been used yet,
  // looking for the first accepted one which is added to the specified
  // container. Return a pointer to the accepted event, or else zero
  // if we use up the cache before we accept an event. The caller does
  // not own the event and it will be overwritten by a subsequent call.

  const RooArgSet *event = 0;
  while((event= _cache->get(_eventsUsed))) {    
    _eventsUsed++ ;
    // accept this cached event?
    Double_t r= RooRandom::uniform();
    if(r*_maxFuncVal > _funcValPtr->getVal()) {
      //cout << " event number " << _eventsUsed << " has been rejected" << endl ;
      continue;
    }
    //cout << " event number " << _eventsUsed << " has been accepted" << endl ;
    // copy this event into the output container
    if(_verbose && (_eventsUsed%1000==0)) {
      cerr << "RooAcceptReject: accepted event (used " << _eventsUsed << " of "
	   << _cache->numEntries() << " so far)" << endl;
    }
    break;
  }  
  //cout << "accepted event " << _eventsUsed << " of " << _cache->numEntries() << endl ;
  return event;
}



//_____________________________________________________________________________
void RooAcceptReject::addEventToCache() 
{
  // Add a trial event to our cache and update our estimates
  // of the function maximum value and integral.

  // randomize each discrete argument
  _nextCatVar->Reset();
  RooCategory *cat = 0;
  while((cat= (RooCategory*)_nextCatVar->Next())) cat->randomize();

  // randomize each real argument
  _nextRealVar->Reset();
  RooRealVar *real = 0;
  while((real= (RooRealVar*)_nextRealVar->Next())) real->randomize();

  // calculate and store our function value at this new point
  Double_t val= _funcClone->getVal();
  _funcValPtr->setVal(val);

  // Update the estimated integral and maximum value. Increase our
  // maximum estimate slightly to give a safety margin with a
  // corresponding loss of efficiency.
  if(val > _maxFuncVal) _maxFuncVal= 1.05*val;
  _funcSum+= val;

  // fill a new entry in our cache dataset for this point
  _cache->fill();
  _totalEvents++;

  if (_verbose &&_totalEvents%10000==0) {
    cerr << "RooAcceptReject: generated " << _totalEvents << " events so far." << endl ;
  }

}

Double_t RooAcceptReject::getFuncMax() 
{
  // Empirically determine maximum value of function by taking a large number
  // of samples. The actual number depends on the number of dimensions in which
  // the sampling occurs

  // Generate the minimum required number of samples for a reliable maximum estimate
  while(_totalEvents < _minTrials) {
    addEventToCache();

    // Limit cache size to 1M events
    if (_cache->numEntries()>1000000) {
      coutI(Generation) << "RooAcceptReject::getFuncMax: resetting event cache" << endl ;
      _cache->reset() ;
      _eventsUsed = 0 ;
    }
  }  

  return _maxFuncVal ;
}

 RooAcceptReject.cxx:1
 RooAcceptReject.cxx:2
 RooAcceptReject.cxx:3
 RooAcceptReject.cxx:4
 RooAcceptReject.cxx:5
 RooAcceptReject.cxx:6
 RooAcceptReject.cxx:7
 RooAcceptReject.cxx:8
 RooAcceptReject.cxx:9
 RooAcceptReject.cxx:10
 RooAcceptReject.cxx:11
 RooAcceptReject.cxx:12
 RooAcceptReject.cxx:13
 RooAcceptReject.cxx:14
 RooAcceptReject.cxx:15
 RooAcceptReject.cxx:16
 RooAcceptReject.cxx:17
 RooAcceptReject.cxx:18
 RooAcceptReject.cxx:19
 RooAcceptReject.cxx:20
 RooAcceptReject.cxx:21
 RooAcceptReject.cxx:22
 RooAcceptReject.cxx:23
 RooAcceptReject.cxx:24
 RooAcceptReject.cxx:25
 RooAcceptReject.cxx:26
 RooAcceptReject.cxx:27
 RooAcceptReject.cxx:28
 RooAcceptReject.cxx:29
 RooAcceptReject.cxx:30
 RooAcceptReject.cxx:31
 RooAcceptReject.cxx:32
 RooAcceptReject.cxx:33
 RooAcceptReject.cxx:34
 RooAcceptReject.cxx:35
 RooAcceptReject.cxx:36
 RooAcceptReject.cxx:37
 RooAcceptReject.cxx:38
 RooAcceptReject.cxx:39
 RooAcceptReject.cxx:40
 RooAcceptReject.cxx:41
 RooAcceptReject.cxx:42
 RooAcceptReject.cxx:43
 RooAcceptReject.cxx:44
 RooAcceptReject.cxx:45
 RooAcceptReject.cxx:46
 RooAcceptReject.cxx:47
 RooAcceptReject.cxx:48
 RooAcceptReject.cxx:49
 RooAcceptReject.cxx:50
 RooAcceptReject.cxx:51
 RooAcceptReject.cxx:52
 RooAcceptReject.cxx:53
 RooAcceptReject.cxx:54
 RooAcceptReject.cxx:55
 RooAcceptReject.cxx:56
 RooAcceptReject.cxx:57
 RooAcceptReject.cxx:58
 RooAcceptReject.cxx:59
 RooAcceptReject.cxx:60
 RooAcceptReject.cxx:61
 RooAcceptReject.cxx:62
 RooAcceptReject.cxx:63
 RooAcceptReject.cxx:64
 RooAcceptReject.cxx:65
 RooAcceptReject.cxx:66
 RooAcceptReject.cxx:67
 RooAcceptReject.cxx:68
 RooAcceptReject.cxx:69
 RooAcceptReject.cxx:70
 RooAcceptReject.cxx:71
 RooAcceptReject.cxx:72
 RooAcceptReject.cxx:73
 RooAcceptReject.cxx:74
 RooAcceptReject.cxx:75
 RooAcceptReject.cxx:76
 RooAcceptReject.cxx:77
 RooAcceptReject.cxx:78
 RooAcceptReject.cxx:79
 RooAcceptReject.cxx:80
 RooAcceptReject.cxx:81
 RooAcceptReject.cxx:82
 RooAcceptReject.cxx:83
 RooAcceptReject.cxx:84
 RooAcceptReject.cxx:85
 RooAcceptReject.cxx:86
 RooAcceptReject.cxx:87
 RooAcceptReject.cxx:88
 RooAcceptReject.cxx:89
 RooAcceptReject.cxx:90
 RooAcceptReject.cxx:91
 RooAcceptReject.cxx:92
 RooAcceptReject.cxx:93
 RooAcceptReject.cxx:94
 RooAcceptReject.cxx:95
 RooAcceptReject.cxx:96
 RooAcceptReject.cxx:97
 RooAcceptReject.cxx:98
 RooAcceptReject.cxx:99
 RooAcceptReject.cxx:100
 RooAcceptReject.cxx:101
 RooAcceptReject.cxx:102
 RooAcceptReject.cxx:103
 RooAcceptReject.cxx:104
 RooAcceptReject.cxx:105
 RooAcceptReject.cxx:106
 RooAcceptReject.cxx:107
 RooAcceptReject.cxx:108
 RooAcceptReject.cxx:109
 RooAcceptReject.cxx:110
 RooAcceptReject.cxx:111
 RooAcceptReject.cxx:112
 RooAcceptReject.cxx:113
 RooAcceptReject.cxx:114
 RooAcceptReject.cxx:115
 RooAcceptReject.cxx:116
 RooAcceptReject.cxx:117
 RooAcceptReject.cxx:118
 RooAcceptReject.cxx:119
 RooAcceptReject.cxx:120
 RooAcceptReject.cxx:121
 RooAcceptReject.cxx:122
 RooAcceptReject.cxx:123
 RooAcceptReject.cxx:124
 RooAcceptReject.cxx:125
 RooAcceptReject.cxx:126
 RooAcceptReject.cxx:127
 RooAcceptReject.cxx:128
 RooAcceptReject.cxx:129
 RooAcceptReject.cxx:130
 RooAcceptReject.cxx:131
 RooAcceptReject.cxx:132
 RooAcceptReject.cxx:133
 RooAcceptReject.cxx:134
 RooAcceptReject.cxx:135
 RooAcceptReject.cxx:136
 RooAcceptReject.cxx:137
 RooAcceptReject.cxx:138
 RooAcceptReject.cxx:139
 RooAcceptReject.cxx:140
 RooAcceptReject.cxx:141
 RooAcceptReject.cxx:142
 RooAcceptReject.cxx:143
 RooAcceptReject.cxx:144
 RooAcceptReject.cxx:145
 RooAcceptReject.cxx:146
 RooAcceptReject.cxx:147
 RooAcceptReject.cxx:148
 RooAcceptReject.cxx:149
 RooAcceptReject.cxx:150
 RooAcceptReject.cxx:151
 RooAcceptReject.cxx:152
 RooAcceptReject.cxx:153
 RooAcceptReject.cxx:154
 RooAcceptReject.cxx:155
 RooAcceptReject.cxx:156
 RooAcceptReject.cxx:157
 RooAcceptReject.cxx:158
 RooAcceptReject.cxx:159
 RooAcceptReject.cxx:160
 RooAcceptReject.cxx:161
 RooAcceptReject.cxx:162
 RooAcceptReject.cxx:163
 RooAcceptReject.cxx:164
 RooAcceptReject.cxx:165
 RooAcceptReject.cxx:166
 RooAcceptReject.cxx:167
 RooAcceptReject.cxx:168
 RooAcceptReject.cxx:169
 RooAcceptReject.cxx:170
 RooAcceptReject.cxx:171
 RooAcceptReject.cxx:172
 RooAcceptReject.cxx:173
 RooAcceptReject.cxx:174
 RooAcceptReject.cxx:175
 RooAcceptReject.cxx:176
 RooAcceptReject.cxx:177
 RooAcceptReject.cxx:178
 RooAcceptReject.cxx:179
 RooAcceptReject.cxx:180
 RooAcceptReject.cxx:181
 RooAcceptReject.cxx:182
 RooAcceptReject.cxx:183
 RooAcceptReject.cxx:184
 RooAcceptReject.cxx:185
 RooAcceptReject.cxx:186
 RooAcceptReject.cxx:187
 RooAcceptReject.cxx:188
 RooAcceptReject.cxx:189
 RooAcceptReject.cxx:190
 RooAcceptReject.cxx:191
 RooAcceptReject.cxx:192
 RooAcceptReject.cxx:193
 RooAcceptReject.cxx:194
 RooAcceptReject.cxx:195
 RooAcceptReject.cxx:196
 RooAcceptReject.cxx:197
 RooAcceptReject.cxx:198
 RooAcceptReject.cxx:199
 RooAcceptReject.cxx:200
 RooAcceptReject.cxx:201
 RooAcceptReject.cxx:202
 RooAcceptReject.cxx:203
 RooAcceptReject.cxx:204
 RooAcceptReject.cxx:205
 RooAcceptReject.cxx:206
 RooAcceptReject.cxx:207
 RooAcceptReject.cxx:208
 RooAcceptReject.cxx:209
 RooAcceptReject.cxx:210
 RooAcceptReject.cxx:211
 RooAcceptReject.cxx:212
 RooAcceptReject.cxx:213
 RooAcceptReject.cxx:214
 RooAcceptReject.cxx:215
 RooAcceptReject.cxx:216
 RooAcceptReject.cxx:217
 RooAcceptReject.cxx:218
 RooAcceptReject.cxx:219
 RooAcceptReject.cxx:220
 RooAcceptReject.cxx:221
 RooAcceptReject.cxx:222
 RooAcceptReject.cxx:223
 RooAcceptReject.cxx:224
 RooAcceptReject.cxx:225
 RooAcceptReject.cxx:226
 RooAcceptReject.cxx:227
 RooAcceptReject.cxx:228
 RooAcceptReject.cxx:229
 RooAcceptReject.cxx:230
 RooAcceptReject.cxx:231
 RooAcceptReject.cxx:232
 RooAcceptReject.cxx:233
 RooAcceptReject.cxx:234
 RooAcceptReject.cxx:235
 RooAcceptReject.cxx:236
 RooAcceptReject.cxx:237
 RooAcceptReject.cxx:238
 RooAcceptReject.cxx:239
 RooAcceptReject.cxx:240
 RooAcceptReject.cxx:241
 RooAcceptReject.cxx:242
 RooAcceptReject.cxx:243
 RooAcceptReject.cxx:244
 RooAcceptReject.cxx:245
 RooAcceptReject.cxx:246
 RooAcceptReject.cxx:247
 RooAcceptReject.cxx:248
 RooAcceptReject.cxx:249
 RooAcceptReject.cxx:250
 RooAcceptReject.cxx:251
 RooAcceptReject.cxx:252
 RooAcceptReject.cxx:253
 RooAcceptReject.cxx:254
 RooAcceptReject.cxx:255
 RooAcceptReject.cxx:256
 RooAcceptReject.cxx:257
 RooAcceptReject.cxx:258
 RooAcceptReject.cxx:259
 RooAcceptReject.cxx:260
 RooAcceptReject.cxx:261
 RooAcceptReject.cxx:262
 RooAcceptReject.cxx:263
 RooAcceptReject.cxx:264
 RooAcceptReject.cxx:265
 RooAcceptReject.cxx:266
 RooAcceptReject.cxx:267
 RooAcceptReject.cxx:268
 RooAcceptReject.cxx:269
 RooAcceptReject.cxx:270
 RooAcceptReject.cxx:271
 RooAcceptReject.cxx:272
 RooAcceptReject.cxx:273
 RooAcceptReject.cxx:274
 RooAcceptReject.cxx:275
 RooAcceptReject.cxx:276
 RooAcceptReject.cxx:277
 RooAcceptReject.cxx:278
 RooAcceptReject.cxx:279
 RooAcceptReject.cxx:280
 RooAcceptReject.cxx:281
 RooAcceptReject.cxx:282
 RooAcceptReject.cxx:283
 RooAcceptReject.cxx:284
 RooAcceptReject.cxx:285
 RooAcceptReject.cxx:286
 RooAcceptReject.cxx:287
 RooAcceptReject.cxx:288
 RooAcceptReject.cxx:289
 RooAcceptReject.cxx:290
 RooAcceptReject.cxx:291
 RooAcceptReject.cxx:292
 RooAcceptReject.cxx:293
 RooAcceptReject.cxx:294
 RooAcceptReject.cxx:295
 RooAcceptReject.cxx:296
 RooAcceptReject.cxx:297
 RooAcceptReject.cxx:298
 RooAcceptReject.cxx:299
 RooAcceptReject.cxx:300
 RooAcceptReject.cxx:301
 RooAcceptReject.cxx:302
 RooAcceptReject.cxx:303
 RooAcceptReject.cxx:304
 RooAcceptReject.cxx:305
 RooAcceptReject.cxx:306
 RooAcceptReject.cxx:307
 RooAcceptReject.cxx:308
 RooAcceptReject.cxx:309
 RooAcceptReject.cxx:310
 RooAcceptReject.cxx:311
 RooAcceptReject.cxx:312
 RooAcceptReject.cxx:313
 RooAcceptReject.cxx:314
 RooAcceptReject.cxx:315
 RooAcceptReject.cxx:316
 RooAcceptReject.cxx:317
 RooAcceptReject.cxx:318
 RooAcceptReject.cxx:319
 RooAcceptReject.cxx:320
 RooAcceptReject.cxx:321
 RooAcceptReject.cxx:322
 RooAcceptReject.cxx:323
 RooAcceptReject.cxx:324
 RooAcceptReject.cxx:325
 RooAcceptReject.cxx:326
 RooAcceptReject.cxx:327
 RooAcceptReject.cxx:328
 RooAcceptReject.cxx:329
 RooAcceptReject.cxx:330
 RooAcceptReject.cxx:331
 RooAcceptReject.cxx:332
 RooAcceptReject.cxx:333
 RooAcceptReject.cxx:334
 RooAcceptReject.cxx:335
 RooAcceptReject.cxx:336
 RooAcceptReject.cxx:337
 RooAcceptReject.cxx:338
 RooAcceptReject.cxx:339
 RooAcceptReject.cxx:340
 RooAcceptReject.cxx:341
 RooAcceptReject.cxx:342
 RooAcceptReject.cxx:343
 RooAcceptReject.cxx:344
 RooAcceptReject.cxx:345
 RooAcceptReject.cxx:346
 RooAcceptReject.cxx:347