// @(#)root/roostats:$Id$
// Author: Kyle Cranmer, George Lewis 
/*************************************************************************
 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////////
//
// BEGIN_HTML
// Class RooBarlowBeestonLL implements the profile likelihood estimator for
// a given likelihood and set of parameters of interest. The value return by 
// RooBarlowBeestonLL is the input likelihood nll minimized w.r.t all nuisance parameters
// (which are all parameters except for those listed in the constructor) minus
// the -log(L) of the best fit. Note that this function is slow to evaluate
// as a MIGRAD minimization step is executed for each function evaluation
// END_HTML
//

#include <stdexcept>
#include <math.h>

#include "Riostream.h" 

#include "RooFit.h"
#include "RooStats/HistFactory/RooBarlowBeestonLL.h" 
#include "RooAbsReal.h" 
#include "RooAbsData.h" 
//#include "RooMinuit.h"
#include "RooMsgService.h"
#include "RooRealVar.h"
#include "RooMsgService.h"
#include "RooNLLVar.h"

#include "RooStats/RooStatsUtils.h"
#include "RooProdPdf.h"
#include "RooCategory.h"
#include "RooSimultaneous.h"
#include "RooArgList.h"
#include "RooAbsCategoryLValue.h"

#include "RooStats/HistFactory/ParamHistFunc.h"
#include "RooStats/HistFactory/HistFactoryModelUtils.h"

using namespace std ;

ClassImp(RooStats::HistFactory::RooBarlowBeestonLL) 


//_____________________________________________________________________________ 
 RooStats::HistFactory::RooBarlowBeestonLL::RooBarlowBeestonLL() : 
   RooAbsReal("RooBarlowBeestonLL","RooBarlowBeestonLL"), 
   _nll(), 
//   _obs("paramOfInterest","Parameters of interest",this), 
//  _par("nuisanceParam","Nuisance parameters",this,kFALSE,kFALSE),
  _pdf(NULL), _data(NULL)
{ 
  // Default constructor 
  // Should only be used by proof. 
  //  _piter = _par.createIterator() ; 
  //  _oiter = _obs.createIterator() ; 
} 


//_____________________________________________________________________________
RooStats::HistFactory::RooBarlowBeestonLL::RooBarlowBeestonLL(const char *name, const char *title, 
				       RooAbsReal& nllIn /*, const RooArgSet& observables*/) :
  RooAbsReal(name,title), 
  _nll("input","-log(L) function",this,nllIn),
  //  _obs("paramOfInterest","Parameters of interest",this),
  //  _par("nuisanceParam","Nuisance parameters",this,kFALSE,kFALSE),
  _pdf(NULL), _data(NULL)
{ 
  // Constructor of profile likelihood given input likelihood nll w.r.t
  // the given set of variables. The input log likelihood is minimized w.r.t
  // to all other variables of the likelihood at each evaluation and the
  // value of the global log likelihood minimum is always subtracted.

  // Determine actual parameters and observables
  /*
  RooArgSet* actualObs = nllIn.getObservables(observables) ;
  RooArgSet* actualPars = nllIn.getParameters(observables) ;

  _obs.add(*actualObs) ;
  _par.add(*actualPars) ;

  delete actualObs ;
  delete actualPars ;

  _piter = _par.createIterator() ;
  _oiter = _obs.createIterator() ;
  */
} 



//_____________________________________________________________________________
RooStats::HistFactory::RooBarlowBeestonLL::RooBarlowBeestonLL(const RooBarlowBeestonLL& other, const char* name) :  
  RooAbsReal(other,name), 
  _nll("nll",this,other._nll),
  //  _obs("obs",this,other._obs),
  //  _par("par",this,other._par),
  _pdf(NULL), _data(NULL),
  _paramFixed(other._paramFixed)
{ 
  // Copy constructor

  //  _piter = _par.createIterator() ;
  //  _oiter = _obs.createIterator() ;

  // _paramAbsMin.addClone(other._paramAbsMin) ;
  // _obsAbsMin.addClone(other._obsAbsMin) ;
    
} 



//_____________________________________________________________________________
RooStats::HistFactory::RooBarlowBeestonLL::~RooBarlowBeestonLL()
{
  // Destructor

  // Delete instance of minuit if it was ever instantiated
  // if (_minuit) {
  //   delete _minuit ;
  // }

  
  //delete _piter ;
  //delete _oiter ;
}


//_____________________________________________________________________________
void RooStats::HistFactory::RooBarlowBeestonLL::BarlowCache::SetBinCenter() const {
  TIterator* iter = bin_center->createIterator() ;
  RooRealVar* var;
  while((var=(RooRealVar*)iter->Next())) {
    RooRealVar* target = (RooRealVar*) observables->find(var->GetName()) ;
    target->setVal(var->getVal()) ;
  }
  delete iter;
}


//_____________________________________________________________________________
void RooStats::HistFactory::RooBarlowBeestonLL::initializeBarlowCache() {

  bool verbose=false;

  if(!_data) {
    std::cout << "Error: Must initialize data before initializing cache" << std::endl;
    throw std::runtime_error("Uninitialized Data");    
  }
  if(!_pdf) {
    std::cout << "Error: Must initialize model pdf before initializing cache" << std::endl;
    throw std::runtime_error("Uninitialized model pdf");    
  }

  // Get the data bin values for all channels and bins
  std::map< std::string, std::vector<double> > ChannelBinDataMap;
  getDataValuesForObservables( ChannelBinDataMap, _data, _pdf );

  // Get a list of constraint terms
  RooArgList obsTerms;
  RooArgList constraints;
  RooArgSet* obsSet = _pdf->getObservables(*_data);
  FactorizeHistFactoryPdf(*obsSet, *_pdf, obsTerms, constraints);

  if( obsTerms.getSize() == 0 ) {
    std::cout << "Error: Found no observable terms with pdf: " << _pdf->GetName()
	      << " using dataset: " << _data->GetName() << std::endl;
    return;
  }
  if( constraints.getSize() == 0 ) {
    std::cout << "Error: Found no constraint terms with pdf: " << _pdf->GetName()
	      << " using dataset: " << _data->GetName() << std::endl;
    return;
  }

  /*
  // Get the channels for this pdf
  RooArgSet* channels = new RooArgSet();
  RooArgSet* channelsWithConstraints = new RooArgSet();
  getChannelsFromModel( _pdf, channels, channelsWithConstraints );
  */
  
  // Loop over the channels
  RooSimultaneous* simPdf = (RooSimultaneous*) _pdf;
  RooCategory* channelCat = (RooCategory*) (&simPdf->indexCat());
  TIterator* iter = channelCat->typeIterator() ;
  RooCatType* tt = NULL;
  while((tt=(RooCatType*) iter->Next())) {
    /*
      std::string ChannelName = tt->GetName();
      
      HHChannel_hh_edit
      
      TIterator* iter_channels = channelsWithConstraints->createIterator();
      RooAbsPdf* channelPdf=NULL;
      while(( channelPdf=(RooAbsPdf*)iter_channels->Next()  )) {
      
      std::string channel_name = RooStats::channelNameFromPdf( channelPdf );
    */

    // Warning: channel cat name is not necesarily the same name
    // as the pdf's (for example, if someone does edits)
    RooAbsPdf* channelPdf = simPdf->getPdf(tt->GetName());
    std::string channel_name = channelPdf->GetName();

    // First, we check if this channel uses Stat Uncertainties:
    RooArgList* gammas = new RooArgList();
    ParamHistFunc* param_func=NULL;
    bool hasStatUncert = getStatUncertaintyFromChannel( channelPdf, param_func, gammas );
    if( ! hasStatUncert ) {
      if(verbose) {
	std::cout << "Channel: " << channel_name
		  << " doesn't have statistical uncertainties"
		  << std::endl;
      }
      continue;
    }
    else {
      if(verbose) std::cout << "Found ParamHistFunc: " << param_func->GetName() << std::endl;
    }

    // Now, loop over the bins in this channel
    // To Do: Check that the index convention
    // still works for 2-d (ie matches the
    // convention in ParamHistFunc, etc)
    int num_bins = param_func->numBins();
  
    // Initialize the vector to the number of bins, allowing
    // us to skip gamma's if they are constant

    std::vector<BarlowCache> temp_cache( num_bins );
    bool channel_has_stat_uncertainty=false;

    for( Int_t bin_index = 0; bin_index < num_bins; ++bin_index ) {

      // Create a cache object
      BarlowCache cache;

      // Get the gamma for this bin, and skip if it's constant
      RooRealVar* gamma_stat = &(param_func->getParameter(bin_index));
      if( gamma_stat->isConstant() ) {
	if(verbose) std::cout << "Ignoring constant gamma: " << gamma_stat->GetName() << std::endl;
	continue;
      }
      else {
	cache.hasStatUncert=true;
	channel_has_stat_uncertainty=true;
	cache.gamma = gamma_stat;
	_statUncertParams.insert( gamma_stat->GetName() );
      }

      // Store a snapshot of the bin center
      RooArgSet* bin_center = (RooArgSet*) param_func->get( bin_index )->snapshot();
      cache.bin_center = bin_center;
      cache.observables = obsSet;

      cache.binVolume = param_func->binVolume();

      // Delete this part, simply a comment
      RooArgList obs_list( *(cache.bin_center) );

      // Get the gamma's constraint term
      RooAbsReal* pois_mean = NULL;
      RooRealVar* tau = NULL;
      getStatUncertaintyConstraintTerm( &constraints, gamma_stat, pois_mean, tau );
      if( !tau || !pois_mean ) {
	std::cout << "Failed to find pois mean or tau parameter for " << gamma_stat->GetName() << std::endl;
      }
      else {
	if(verbose) std::cout << "Found pois mean and tau for parameter: " << gamma_stat->GetName()
			      << " tau: " << tau->GetName() << " " << tau->getVal()
			      << " pois_mean: " << pois_mean->GetName() << " " << pois_mean->getVal()
			      << std::endl;
      }

      cache.tau = tau;
      cache.nom_pois_mean = pois_mean;

      // Get the RooRealSumPdf
      RooAbsPdf* sum_pdf = getSumPdfFromChannel( channelPdf );
      if( sum_pdf == NULL )  {
	std::cout << "Failed to find RooRealSumPdf in channel " <<  channel_name
		  << ", therefor skipping this channel for analytic uncertainty minimization"
		  << std::endl;
	channel_has_stat_uncertainty=false;
	break;
      }
      cache.sumPdf = sum_pdf;

      // And set the data value for this bin
      if( ChannelBinDataMap.find(channel_name) == ChannelBinDataMap.end() ) {
	std::cout << "Error: channel with name: " << channel_name
		  << " not found in BinDataMap" << std::endl;
	throw runtime_error("BinDataMap");
      }
      double nData = ChannelBinDataMap[channel_name].at(bin_index);
      cache.nData = nData;
      
      temp_cache.at(bin_index) = cache;
      //_barlowCache[channel_name].at(bin_index) = cache;

    } // End: Loop over bins
    
    if( channel_has_stat_uncertainty ) {
      std::cout << "Adding channel: " << channel_name
		<< " to the barlow cache" << std::endl;
      _barlowCache[channel_name] = temp_cache;
    }
    

  } // End: Loop over channels



  // Successfully initialized the cache
  // Printing some info
  /*
  std::map< std::string, std::vector< BarlowCache > >::iterator iter_cache;
  for( iter_cache = _barlowCache.begin(); iter_cache != _barlowCache.end(); ++iter_cache ) {
    
    std::string channel_name = (*iter_cache).first;
    std::vector< BarlowCache >& channel_cache = (*iter_cache).second;


    for( unsigned int i = 0; i < channel_cache.size(); ++i ) {
      BarlowCache& bin_cache = channel_cache.at(i);


      RooRealVar* gamma = bin_cache.gamma;
      RooRealVar* tau = bin_cache.tau;
      RooAbsReal* pois_mean = bin_cache.nom_pois_mean;
      RooAbsPdf* sum_pdf = (RooAbsPdf*) bin_cache.sumPdf;
      double binVolume = bin_cache.binVolume;


      if( !bin_cache.hasStatUncert ) {
	std::cout << "Barlow Cache for Channel: " << channel_name
		  << " Bin: " << i
		  << " NO STAT UNCERT" 
		  << std::endl;
      }
      else {
      std::cout << "Barlow Cache for Channel: " << channel_name
		<< " Bin: " << i
		<< " gamma: " << gamma->GetName()
		<< " tau: " << tau->GetName()
		<< " pois_mean: " << pois_mean->GetName()
		<< " sum_pdf: " << sum_pdf->GetName()
		<< " binVolume: " << binVolume
		<< std::endl;
      }

    }
  }
  */

}


//_____________________________________________________________________________
RooArgSet* RooStats::HistFactory::RooBarlowBeestonLL::getParameters(const RooArgSet* depList, Bool_t stripDisconnected) const {

  RooArgSet* allArgs = RooAbsArg::getParameters( depList, stripDisconnected );

  TIterator* iter_args = allArgs->createIterator();
  RooRealVar* arg;
  while((arg=(RooRealVar*)iter_args->Next())) {
    std::string arg_name = arg->GetName();

    // If there is a gamma in the name,
    // strip it from the list of dependencies

    if( _statUncertParams.find(arg_name.c_str()) != _statUncertParams.end() ) {
      allArgs->remove( *arg, kTRUE );
    }

  }

  return allArgs;

}


/*
//_____________________________________________________________________________
const RooArgSet& RooStats::HistFactory::RooBarlowBeestonLL::bestFitParams() const 
{
  validateAbsMin() ;
  return _paramAbsMin ;
}


//_____________________________________________________________________________
const RooArgSet& RooStats::HistFactory::RooBarlowBeestonLL::bestFitObs() const 
{
  validateAbsMin() ;
  return _obsAbsMin ;
}
*/



//_____________________________________________________________________________
/*
RooAbsReal* RooStats::HistFactory::RooBarlowBeestonLL::createProfile(const RooArgSet& paramsOfInterest) 
{
  // Optimized implementation of createProfile for profile likelihoods.
  // Return profile of original function in terms of stated parameters 
  // of interest rather than profiling recursively.

  return nll().createProfile(paramsOfInterest) ;
}
*/


/*
void RooStats::HistFactory::RooBarlowBeestonLL::FactorizePdf(const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &obsTerms, RooArgList &constraints) const {
  // utility function to factorize constraint terms from a pdf
  // (from G. Petrucciani)
  const std::type_info & id = typeid(pdf);
  if (id == typeid(RooProdPdf)) {
    RooProdPdf *prod = dynamic_cast<RooProdPdf *>(&pdf);
    RooArgList list(prod->pdfList());
    for (int i = 0, n = list.getSize(); i < n; ++i) {
      RooAbsPdf *pdfi = (RooAbsPdf *) list.at(i);
      FactorizePdf(observables, *pdfi, obsTerms, constraints);
    }
  } else if (id == typeid(RooSimultaneous) ) {    //|| id == typeid(RooSimultaneousOpt)) {
    RooSimultaneous *sim  = dynamic_cast<RooSimultaneous *>(&pdf);
    RooAbsCategoryLValue *cat = (RooAbsCategoryLValue *) sim->indexCat().Clone();
    for (int ic = 0, nc = cat->numBins((const char *)0); ic < nc; ++ic) {
      cat->setBin(ic);
      FactorizePdf(observables, *sim->getPdf(cat->getLabel()), obsTerms, constraints);
    }
    delete cat;
  } else if (pdf.dependsOn(observables)) {
    if (!obsTerms.contains(pdf)) obsTerms.add(pdf);
  } else {
    if (!constraints.contains(pdf)) constraints.add(pdf);
  }
}
*/                                         



//_____________________________________________________________________________
Double_t RooStats::HistFactory::RooBarlowBeestonLL::evaluate() const 
{ 

  /*
  // Loop over the cached bins and channels
  RooArgSet* channels = new RooArgSet();
  RooArgSet* channelsWithConstraints = new RooArgSet();
  RooStats::getChannelsFromModel( _pdf, channels, channelsWithConstraints );

  // Loop over channels
  TIterator* iter_channels = channelsWithConstraints->createIterator();
  RooAbsPdf* channelPdf=NULL;
  while(( channelPdf=(RooAbsPdf*)iter_channels->Next()  )) {
    std::string channel_name = channelPdf->GetName(); //RooStats::channelNameFromPdf( channelPdf );
  */

  // Loop over the channels (keys to the map)
  //clock_t time_before_setVal, time_after_setVal;
  //time_before_setVal=clock();  
  std::map< std::string, std::vector< BarlowCache > >::iterator iter_cache;
  for( iter_cache = _barlowCache.begin(); iter_cache != _barlowCache.end(); ++iter_cache ) {
    
    std::string channel_name = (*iter_cache).first;
    std::vector< BarlowCache >& channel_cache = (*iter_cache).second;

    /* Slower way to find the channel vector:
    // Get the vector of bin uncertainty caches for this channel
    if( _barlowCache.find( channel_name ) == _barlowCache.end() ) {
      std::cout << "Error: channel: " << channel_name 
		<< " not found in barlow Cache" << std::endl; 
      throw runtime_error("Channel not in barlow cache");
    }

    std::vector< BarlowCache >& channel_cache = _barlowCache[ channel_name ];
    */

    // Loop over the bins in the cache
    // Set all gamma's to 0
    for( unsigned int i = 0; i < channel_cache.size(); ++i ) {
      BarlowCache& bin_cache = channel_cache.at(i);
      if( !bin_cache.hasStatUncert ) continue;
      RooRealVar* gamma = bin_cache.gamma;
      gamma->setVal(0.0);
    }
    std::vector< double > nu_b_vec( channel_cache.size() );
    for( unsigned int i = 0; i < channel_cache.size(); ++i ) {
      BarlowCache& bin_cache = channel_cache.at(i);
      if( !bin_cache.hasStatUncert ) continue;

      RooAbsPdf* sum_pdf = (RooAbsPdf*) bin_cache.sumPdf;
      RooArgSet* obsSet = bin_cache.observables;
      double binVolume = bin_cache.binVolume;

      bin_cache.SetBinCenter();
      double nu_b = sum_pdf->getVal(*obsSet)*sum_pdf->expectedEvents(*obsSet)*binVolume;
      nu_b_vec.at(i) = nu_b;
    }

    // Loop over the bins in the cache
    // Set all gamma's to 1
    for( unsigned int i = 0; i < channel_cache.size(); ++i ) {
      BarlowCache& bin_cache = channel_cache.at(i);
      if( !bin_cache.hasStatUncert ) continue;
      RooRealVar* gamma = bin_cache.gamma;
      gamma->setVal(1.0);
    }
    std::vector< double > nu_b_stat_vec( channel_cache.size() );
    for( unsigned int i = 0; i < channel_cache.size(); ++i ) {
      BarlowCache& bin_cache = channel_cache.at(i);
      if( !bin_cache.hasStatUncert ) continue;

      RooAbsPdf* sum_pdf = (RooAbsPdf*) bin_cache.sumPdf;
      RooArgSet* obsSet = bin_cache.observables;
      double binVolume = bin_cache.binVolume;
      
      bin_cache.SetBinCenter();
      double nu_b_stat = sum_pdf->getVal(*obsSet)*sum_pdf->expectedEvents(*obsSet)*binVolume - nu_b_vec.at(i);
      nu_b_stat_vec.at(i) = nu_b_stat;
    }
    //time_after_setVal=clock();  
    
    // Done with the first loops.
    // Now evaluating the function

    //clock_t time_before_eval, time_after_eval;

    // Loop over the bins in the cache
    //time_before_eval=clock();
    for( unsigned int i = 0; i < channel_cache.size(); ++i ) {
      
      BarlowCache& bin_cache = channel_cache.at(i);

      if( !bin_cache.hasStatUncert ) {
	//std::cout << "Bin: " << i << " of " << channel_cache.size() 
	//	  << " in channel: " << channel_name
	//	  << " doesn't have stat uncertainties" << std::endl;
	continue;
      }

      // Set the observable to the bin center
      bin_cache.SetBinCenter();

      // Get the cached objects
      RooRealVar* gamma = bin_cache.gamma;
      RooRealVar* tau = bin_cache.tau;
      RooAbsReal* pois_mean = bin_cache.nom_pois_mean;
      //RooAbsPdf* sum_pdf = (RooAbsPdf*) bin_cache.sumPdf;
      //RooArgSet* obsSet = bin_cache.observables;
      //double binVolume = bin_cache.binVolume;

      // Get the values necessary for
      // the analytic minimization
      double nu_b = nu_b_vec.at(i);
      double nu_b_stat = nu_b_stat_vec.at(i);

      double tau_val = tau->getVal();
      double nData = bin_cache.nData;
      double m_val = pois_mean->getVal();

      // Initialize the minimized value of gamma
      double gamma_hat_hat = 1.0;

      // Check that the quadratic term is > 0
      if(nu_b_stat > 0.00000001) {
	
	double A = nu_b_stat*nu_b_stat + tau_val*nu_b_stat;
	double B = nu_b*tau_val + nu_b*nu_b_stat - nData*nu_b_stat - m_val*nu_b_stat;
	double C = -1*m_val*nu_b;
	
	double discrim = B*B-4*A*C;
	
	if( discrim < 0 ) {
	  std::cout << "Warning: Discriminant (B*B - 4AC) < 0" << std::endl;
	  std::cout << "Warning: Taking B*B - 4*A*C == 0" << std::endl;
	  discrim=0;
	  //throw runtime_error("BarlowBeestonLL::evaluate() : B*B - 4AC < 0");
	}
	if( A <= 0 ) {
	  std::cout << "Warning: A <= 0" << std::endl;
	  throw runtime_error("BarlowBeestonLL::evaluate() : A < 0");
	}
	
	gamma_hat_hat = ( -1*B + TMath::Sqrt(discrim) ) / (2*A);
      }

      // If the quadratic term is 0, we simply
      // use a linear equation
      else {
	gamma_hat_hat = m_val/tau_val;
      }

      // Check for NAN
      if( TMath::IsNaN(gamma_hat_hat) ) { 
	std::cout << "ERROR: gamma hat hat is NAN" << std::endl;
	throw runtime_error("BarlowBeestonLL::evaluate() : gamma hat hat is NAN");
      }

      if( gamma_hat_hat <= 0 ) {
	std::cout << "WARNING: gamma hat hat <= 0.  Setting to 0" << std::endl;
	gamma_hat_hat = 0;
      }
      
      /*
      std::cout << "n: " << bin_cache.nData << " "
		<< "nu_stat: " << nu_b_stat << " "
		<< "nu: " << nu_b << " "
		<< "tau: " << tau->getVal() << " "
		<< "m: " << pois_mean->getVal() << " "
		<< "A: " << A << " "
		<< "B: " << B << " "
		<< "C: " << C << " "
		<< "gamma hat hat: " << gamma_hat_hat 
		<< std::endl;
      */

      gamma->setVal( gamma_hat_hat );

    }

    //time_after_eval=clock();

    //float time_setVal = ((float) time_after_setVal - (float) time_before_setVal) / ((float) CLOCKS_PER_SEC);
    //float time_eval   = ((float) time_after_eval - (float) time_before_eval) / ((float) CLOCKS_PER_SEC);

    /*
    std::cout << "Barlow timing for channel: " << channel_name
	      << " SetVal: " << time_setVal
	      << " Eval: " << time_eval
	      << std::endl;
    */
  } 


  return _nll;  

}



/*
//_____________________________________________________________________________
void RooStats::HistFactory::RooBarlowBeestonLL::validateAbsMin() const 
{
  // Check that parameters and likelihood value for 'best fit' are still valid. If not,
  // because the best fit has never been calculated, or because constant parameters have
  // changed value or parameters have changed const/float status, the minimum is recalculated

  // Check if constant status of any of the parameters have changed
  if (_absMinValid) {
    _piter->Reset() ;
    RooAbsArg* par ;
    while((par=(RooAbsArg*)_piter->Next())) {
      if (_paramFixed[par->GetName()] != par->isConstant()) {
	cxcoutI(Minimization) << "RooStats::HistFactory::RooBarlowBeestonLL::evaluate(" << GetName() << ") constant status of parameter " << par->GetName() << " has changed from " 
				<< (_paramFixed[par->GetName()]?"fixed":"floating") << " to " << (par->isConstant()?"fixed":"floating") 
				<< ", recalculating absolute minimum" << endl ;
	_absMinValid = kFALSE ;
	break ;
      }
    }
  }


  // If we don't have the absolute minimum w.r.t all observables, calculate that first
  if (!_absMinValid) {

    cxcoutI(Minimization) << "RooStats::HistFactory::RooBarlowBeestonLL::evaluate(" << GetName() << ") determining minimum likelihood for current configurations w.r.t all observable" << endl ;


    // Save current values of non-marginalized parameters
    RooArgSet* obsStart = (RooArgSet*) _obs.snapshot(kFALSE) ;

    // Start from previous global minimum 
    if (_paramAbsMin.getSize()>0) {
      const_cast<RooSetProxy&>(_par).assignValueOnly(_paramAbsMin) ;
    }
    if (_obsAbsMin.getSize()>0) {
      const_cast<RooSetProxy&>(_obs).assignValueOnly(_obsAbsMin) ;
    }

    // Find minimum with all observables floating
    const_cast<RooSetProxy&>(_obs).setAttribAll("Constant",kFALSE) ;  
    _minuit->migrad() ;

    // Save value and remember
    _absMin = _nll ;
    _absMinValid = kTRUE ;

    // Save parameter values at abs minimum as well
    _paramAbsMin.removeAll() ;

    // Only store non-constant parameters here!
    RooArgSet* tmp = (RooArgSet*) _par.selectByAttrib("Constant",kFALSE) ;
    _paramAbsMin.addClone(*tmp) ;
    delete tmp ;

    _obsAbsMin.addClone(_obs) ;

    // Save constant status of all parameters
    _piter->Reset() ;
    RooAbsArg* par ;
    while((par=(RooAbsArg*)_piter->Next())) {
      _paramFixed[par->GetName()] = par->isConstant() ;
    }
    
    if (dologI(Minimization)) {
      cxcoutI(Minimization) << "RooStats::HistFactory::RooBarlowBeestonLL::evaluate(" << GetName() << ") minimum found at (" ;

      RooAbsReal* arg ;
      Bool_t first=kTRUE ;
      _oiter->Reset() ;
      while ((arg=(RooAbsReal*)_oiter->Next())) {
	ccxcoutI(Minimization) << (first?"":", ") << arg->GetName() << "=" << arg->getVal() ;	
	first=kFALSE ;
      }      
      ccxcoutI(Minimization) << ")" << endl ;            
    }

    // Restore original parameter values
    const_cast<RooSetProxy&>(_obs) = *obsStart ;
    delete obsStart ;

  }
}
*/


//_____________________________________________________________________________
Bool_t RooStats::HistFactory::RooBarlowBeestonLL::redirectServersHook(const RooAbsCollection& /*newServerList*/, Bool_t /*mustReplaceAll*/, 
					 Bool_t /*nameChange*/, Bool_t /*isRecursive*/) 
{ 
  /*
  if (_minuit) {
    delete _minuit ;
    _minuit = 0 ;
  }
  */
  return kFALSE ;
} 


 RooBarlowBeestonLL.cxx:1
 RooBarlowBeestonLL.cxx:2
 RooBarlowBeestonLL.cxx:3
 RooBarlowBeestonLL.cxx:4
 RooBarlowBeestonLL.cxx:5
 RooBarlowBeestonLL.cxx:6
 RooBarlowBeestonLL.cxx:7
 RooBarlowBeestonLL.cxx:8
 RooBarlowBeestonLL.cxx:9
 RooBarlowBeestonLL.cxx:10
 RooBarlowBeestonLL.cxx:11
 RooBarlowBeestonLL.cxx:12
 RooBarlowBeestonLL.cxx:13
 RooBarlowBeestonLL.cxx:14
 RooBarlowBeestonLL.cxx:15
 RooBarlowBeestonLL.cxx:16
 RooBarlowBeestonLL.cxx:17
 RooBarlowBeestonLL.cxx:18
 RooBarlowBeestonLL.cxx:19
 RooBarlowBeestonLL.cxx:20
 RooBarlowBeestonLL.cxx:21
 RooBarlowBeestonLL.cxx:22
 RooBarlowBeestonLL.cxx:23
 RooBarlowBeestonLL.cxx:24
 RooBarlowBeestonLL.cxx:25
 RooBarlowBeestonLL.cxx:26
 RooBarlowBeestonLL.cxx:27
 RooBarlowBeestonLL.cxx:28
 RooBarlowBeestonLL.cxx:29
 RooBarlowBeestonLL.cxx:30
 RooBarlowBeestonLL.cxx:31
 RooBarlowBeestonLL.cxx:32
 RooBarlowBeestonLL.cxx:33
 RooBarlowBeestonLL.cxx:34
 RooBarlowBeestonLL.cxx:35
 RooBarlowBeestonLL.cxx:36
 RooBarlowBeestonLL.cxx:37
 RooBarlowBeestonLL.cxx:38
 RooBarlowBeestonLL.cxx:39
 RooBarlowBeestonLL.cxx:40
 RooBarlowBeestonLL.cxx:41
 RooBarlowBeestonLL.cxx:42
 RooBarlowBeestonLL.cxx:43
 RooBarlowBeestonLL.cxx:44
 RooBarlowBeestonLL.cxx:45
 RooBarlowBeestonLL.cxx:46
 RooBarlowBeestonLL.cxx:47
 RooBarlowBeestonLL.cxx:48
 RooBarlowBeestonLL.cxx:49
 RooBarlowBeestonLL.cxx:50
 RooBarlowBeestonLL.cxx:51
 RooBarlowBeestonLL.cxx:52
 RooBarlowBeestonLL.cxx:53
 RooBarlowBeestonLL.cxx:54
 RooBarlowBeestonLL.cxx:55
 RooBarlowBeestonLL.cxx:56
 RooBarlowBeestonLL.cxx:57
 RooBarlowBeestonLL.cxx:58
 RooBarlowBeestonLL.cxx:59
 RooBarlowBeestonLL.cxx:60
 RooBarlowBeestonLL.cxx:61
 RooBarlowBeestonLL.cxx:62
 RooBarlowBeestonLL.cxx:63
 RooBarlowBeestonLL.cxx:64
 RooBarlowBeestonLL.cxx:65
 RooBarlowBeestonLL.cxx:66
 RooBarlowBeestonLL.cxx:67
 RooBarlowBeestonLL.cxx:68
 RooBarlowBeestonLL.cxx:69
 RooBarlowBeestonLL.cxx:70
 RooBarlowBeestonLL.cxx:71
 RooBarlowBeestonLL.cxx:72
 RooBarlowBeestonLL.cxx:73
 RooBarlowBeestonLL.cxx:74
 RooBarlowBeestonLL.cxx:75
 RooBarlowBeestonLL.cxx:76
 RooBarlowBeestonLL.cxx:77
 RooBarlowBeestonLL.cxx:78
 RooBarlowBeestonLL.cxx:79
 RooBarlowBeestonLL.cxx:80
 RooBarlowBeestonLL.cxx:81
 RooBarlowBeestonLL.cxx:82
 RooBarlowBeestonLL.cxx:83
 RooBarlowBeestonLL.cxx:84
 RooBarlowBeestonLL.cxx:85
 RooBarlowBeestonLL.cxx:86
 RooBarlowBeestonLL.cxx:87
 RooBarlowBeestonLL.cxx:88
 RooBarlowBeestonLL.cxx:89
 RooBarlowBeestonLL.cxx:90
 RooBarlowBeestonLL.cxx:91
 RooBarlowBeestonLL.cxx:92
 RooBarlowBeestonLL.cxx:93
 RooBarlowBeestonLL.cxx:94
 RooBarlowBeestonLL.cxx:95
 RooBarlowBeestonLL.cxx:96
 RooBarlowBeestonLL.cxx:97
 RooBarlowBeestonLL.cxx:98
 RooBarlowBeestonLL.cxx:99
 RooBarlowBeestonLL.cxx:100
 RooBarlowBeestonLL.cxx:101
 RooBarlowBeestonLL.cxx:102
 RooBarlowBeestonLL.cxx:103
 RooBarlowBeestonLL.cxx:104
 RooBarlowBeestonLL.cxx:105
 RooBarlowBeestonLL.cxx:106
 RooBarlowBeestonLL.cxx:107
 RooBarlowBeestonLL.cxx:108
 RooBarlowBeestonLL.cxx:109
 RooBarlowBeestonLL.cxx:110
 RooBarlowBeestonLL.cxx:111
 RooBarlowBeestonLL.cxx:112
 RooBarlowBeestonLL.cxx:113
 RooBarlowBeestonLL.cxx:114
 RooBarlowBeestonLL.cxx:115
 RooBarlowBeestonLL.cxx:116
 RooBarlowBeestonLL.cxx:117
 RooBarlowBeestonLL.cxx:118
 RooBarlowBeestonLL.cxx:119
 RooBarlowBeestonLL.cxx:120
 RooBarlowBeestonLL.cxx:121
 RooBarlowBeestonLL.cxx:122
 RooBarlowBeestonLL.cxx:123
 RooBarlowBeestonLL.cxx:124
 RooBarlowBeestonLL.cxx:125
 RooBarlowBeestonLL.cxx:126
 RooBarlowBeestonLL.cxx:127
 RooBarlowBeestonLL.cxx:128
 RooBarlowBeestonLL.cxx:129
 RooBarlowBeestonLL.cxx:130
 RooBarlowBeestonLL.cxx:131
 RooBarlowBeestonLL.cxx:132
 RooBarlowBeestonLL.cxx:133
 RooBarlowBeestonLL.cxx:134
 RooBarlowBeestonLL.cxx:135
 RooBarlowBeestonLL.cxx:136
 RooBarlowBeestonLL.cxx:137
 RooBarlowBeestonLL.cxx:138
 RooBarlowBeestonLL.cxx:139
 RooBarlowBeestonLL.cxx:140
 RooBarlowBeestonLL.cxx:141
 RooBarlowBeestonLL.cxx:142
 RooBarlowBeestonLL.cxx:143
 RooBarlowBeestonLL.cxx:144
 RooBarlowBeestonLL.cxx:145
 RooBarlowBeestonLL.cxx:146
 RooBarlowBeestonLL.cxx:147
 RooBarlowBeestonLL.cxx:148
 RooBarlowBeestonLL.cxx:149
 RooBarlowBeestonLL.cxx:150
 RooBarlowBeestonLL.cxx:151
 RooBarlowBeestonLL.cxx:152
 RooBarlowBeestonLL.cxx:153
 RooBarlowBeestonLL.cxx:154
 RooBarlowBeestonLL.cxx:155
 RooBarlowBeestonLL.cxx:156
 RooBarlowBeestonLL.cxx:157
 RooBarlowBeestonLL.cxx:158
 RooBarlowBeestonLL.cxx:159
 RooBarlowBeestonLL.cxx:160
 RooBarlowBeestonLL.cxx:161
 RooBarlowBeestonLL.cxx:162
 RooBarlowBeestonLL.cxx:163
 RooBarlowBeestonLL.cxx:164
 RooBarlowBeestonLL.cxx:165
 RooBarlowBeestonLL.cxx:166
 RooBarlowBeestonLL.cxx:167
 RooBarlowBeestonLL.cxx:168
 RooBarlowBeestonLL.cxx:169
 RooBarlowBeestonLL.cxx:170
 RooBarlowBeestonLL.cxx:171
 RooBarlowBeestonLL.cxx:172
 RooBarlowBeestonLL.cxx:173
 RooBarlowBeestonLL.cxx:174
 RooBarlowBeestonLL.cxx:175
 RooBarlowBeestonLL.cxx:176
 RooBarlowBeestonLL.cxx:177
 RooBarlowBeestonLL.cxx:178
 RooBarlowBeestonLL.cxx:179
 RooBarlowBeestonLL.cxx:180
 RooBarlowBeestonLL.cxx:181
 RooBarlowBeestonLL.cxx:182
 RooBarlowBeestonLL.cxx:183
 RooBarlowBeestonLL.cxx:184
 RooBarlowBeestonLL.cxx:185
 RooBarlowBeestonLL.cxx:186
 RooBarlowBeestonLL.cxx:187
 RooBarlowBeestonLL.cxx:188
 RooBarlowBeestonLL.cxx:189
 RooBarlowBeestonLL.cxx:190
 RooBarlowBeestonLL.cxx:191
 RooBarlowBeestonLL.cxx:192
 RooBarlowBeestonLL.cxx:193
 RooBarlowBeestonLL.cxx:194
 RooBarlowBeestonLL.cxx:195
 RooBarlowBeestonLL.cxx:196
 RooBarlowBeestonLL.cxx:197
 RooBarlowBeestonLL.cxx:198
 RooBarlowBeestonLL.cxx:199
 RooBarlowBeestonLL.cxx:200
 RooBarlowBeestonLL.cxx:201
 RooBarlowBeestonLL.cxx:202
 RooBarlowBeestonLL.cxx:203
 RooBarlowBeestonLL.cxx:204
 RooBarlowBeestonLL.cxx:205
 RooBarlowBeestonLL.cxx:206
 RooBarlowBeestonLL.cxx:207
 RooBarlowBeestonLL.cxx:208
 RooBarlowBeestonLL.cxx:209
 RooBarlowBeestonLL.cxx:210
 RooBarlowBeestonLL.cxx:211
 RooBarlowBeestonLL.cxx:212
 RooBarlowBeestonLL.cxx:213
 RooBarlowBeestonLL.cxx:214
 RooBarlowBeestonLL.cxx:215
 RooBarlowBeestonLL.cxx:216
 RooBarlowBeestonLL.cxx:217
 RooBarlowBeestonLL.cxx:218
 RooBarlowBeestonLL.cxx:219
 RooBarlowBeestonLL.cxx:220
 RooBarlowBeestonLL.cxx:221
 RooBarlowBeestonLL.cxx:222
 RooBarlowBeestonLL.cxx:223
 RooBarlowBeestonLL.cxx:224
 RooBarlowBeestonLL.cxx:225
 RooBarlowBeestonLL.cxx:226
 RooBarlowBeestonLL.cxx:227
 RooBarlowBeestonLL.cxx:228
 RooBarlowBeestonLL.cxx:229
 RooBarlowBeestonLL.cxx:230
 RooBarlowBeestonLL.cxx:231
 RooBarlowBeestonLL.cxx:232
 RooBarlowBeestonLL.cxx:233
 RooBarlowBeestonLL.cxx:234
 RooBarlowBeestonLL.cxx:235
 RooBarlowBeestonLL.cxx:236
 RooBarlowBeestonLL.cxx:237
 RooBarlowBeestonLL.cxx:238
 RooBarlowBeestonLL.cxx:239
 RooBarlowBeestonLL.cxx:240
 RooBarlowBeestonLL.cxx:241
 RooBarlowBeestonLL.cxx:242
 RooBarlowBeestonLL.cxx:243
 RooBarlowBeestonLL.cxx:244
 RooBarlowBeestonLL.cxx:245
 RooBarlowBeestonLL.cxx:246
 RooBarlowBeestonLL.cxx:247
 RooBarlowBeestonLL.cxx:248
 RooBarlowBeestonLL.cxx:249
 RooBarlowBeestonLL.cxx:250
 RooBarlowBeestonLL.cxx:251
 RooBarlowBeestonLL.cxx:252
 RooBarlowBeestonLL.cxx:253
 RooBarlowBeestonLL.cxx:254
 RooBarlowBeestonLL.cxx:255
 RooBarlowBeestonLL.cxx:256
 RooBarlowBeestonLL.cxx:257
 RooBarlowBeestonLL.cxx:258
 RooBarlowBeestonLL.cxx:259
 RooBarlowBeestonLL.cxx:260
 RooBarlowBeestonLL.cxx:261
 RooBarlowBeestonLL.cxx:262
 RooBarlowBeestonLL.cxx:263
 RooBarlowBeestonLL.cxx:264
 RooBarlowBeestonLL.cxx:265
 RooBarlowBeestonLL.cxx:266
 RooBarlowBeestonLL.cxx:267
 RooBarlowBeestonLL.cxx:268
 RooBarlowBeestonLL.cxx:269
 RooBarlowBeestonLL.cxx:270
 RooBarlowBeestonLL.cxx:271
 RooBarlowBeestonLL.cxx:272
 RooBarlowBeestonLL.cxx:273
 RooBarlowBeestonLL.cxx:274
 RooBarlowBeestonLL.cxx:275
 RooBarlowBeestonLL.cxx:276
 RooBarlowBeestonLL.cxx:277
 RooBarlowBeestonLL.cxx:278
 RooBarlowBeestonLL.cxx:279
 RooBarlowBeestonLL.cxx:280
 RooBarlowBeestonLL.cxx:281
 RooBarlowBeestonLL.cxx:282
 RooBarlowBeestonLL.cxx:283
 RooBarlowBeestonLL.cxx:284
 RooBarlowBeestonLL.cxx:285
 RooBarlowBeestonLL.cxx:286
 RooBarlowBeestonLL.cxx:287
 RooBarlowBeestonLL.cxx:288
 RooBarlowBeestonLL.cxx:289
 RooBarlowBeestonLL.cxx:290
 RooBarlowBeestonLL.cxx:291
 RooBarlowBeestonLL.cxx:292
 RooBarlowBeestonLL.cxx:293
 RooBarlowBeestonLL.cxx:294
 RooBarlowBeestonLL.cxx:295
 RooBarlowBeestonLL.cxx:296
 RooBarlowBeestonLL.cxx:297
 RooBarlowBeestonLL.cxx:298
 RooBarlowBeestonLL.cxx:299
 RooBarlowBeestonLL.cxx:300
 RooBarlowBeestonLL.cxx:301
 RooBarlowBeestonLL.cxx:302
 RooBarlowBeestonLL.cxx:303
 RooBarlowBeestonLL.cxx:304
 RooBarlowBeestonLL.cxx:305
 RooBarlowBeestonLL.cxx:306
 RooBarlowBeestonLL.cxx:307
 RooBarlowBeestonLL.cxx:308
 RooBarlowBeestonLL.cxx:309
 RooBarlowBeestonLL.cxx:310
 RooBarlowBeestonLL.cxx:311
 RooBarlowBeestonLL.cxx:312
 RooBarlowBeestonLL.cxx:313
 RooBarlowBeestonLL.cxx:314
 RooBarlowBeestonLL.cxx:315
 RooBarlowBeestonLL.cxx:316
 RooBarlowBeestonLL.cxx:317
 RooBarlowBeestonLL.cxx:318
 RooBarlowBeestonLL.cxx:319
 RooBarlowBeestonLL.cxx:320
 RooBarlowBeestonLL.cxx:321
 RooBarlowBeestonLL.cxx:322
 RooBarlowBeestonLL.cxx:323
 RooBarlowBeestonLL.cxx:324
 RooBarlowBeestonLL.cxx:325
 RooBarlowBeestonLL.cxx:326
 RooBarlowBeestonLL.cxx:327
 RooBarlowBeestonLL.cxx:328
 RooBarlowBeestonLL.cxx:329
 RooBarlowBeestonLL.cxx:330
 RooBarlowBeestonLL.cxx:331
 RooBarlowBeestonLL.cxx:332
 RooBarlowBeestonLL.cxx:333
 RooBarlowBeestonLL.cxx:334
 RooBarlowBeestonLL.cxx:335
 RooBarlowBeestonLL.cxx:336
 RooBarlowBeestonLL.cxx:337
 RooBarlowBeestonLL.cxx:338
 RooBarlowBeestonLL.cxx:339
 RooBarlowBeestonLL.cxx:340
 RooBarlowBeestonLL.cxx:341
 RooBarlowBeestonLL.cxx:342
 RooBarlowBeestonLL.cxx:343
 RooBarlowBeestonLL.cxx:344
 RooBarlowBeestonLL.cxx:345
 RooBarlowBeestonLL.cxx:346
 RooBarlowBeestonLL.cxx:347
 RooBarlowBeestonLL.cxx:348
 RooBarlowBeestonLL.cxx:349
 RooBarlowBeestonLL.cxx:350
 RooBarlowBeestonLL.cxx:351
 RooBarlowBeestonLL.cxx:352
 RooBarlowBeestonLL.cxx:353
 RooBarlowBeestonLL.cxx:354
 RooBarlowBeestonLL.cxx:355
 RooBarlowBeestonLL.cxx:356
 RooBarlowBeestonLL.cxx:357
 RooBarlowBeestonLL.cxx:358
 RooBarlowBeestonLL.cxx:359
 RooBarlowBeestonLL.cxx:360
 RooBarlowBeestonLL.cxx:361
 RooBarlowBeestonLL.cxx:362
 RooBarlowBeestonLL.cxx:363
 RooBarlowBeestonLL.cxx:364
 RooBarlowBeestonLL.cxx:365
 RooBarlowBeestonLL.cxx:366
 RooBarlowBeestonLL.cxx:367
 RooBarlowBeestonLL.cxx:368
 RooBarlowBeestonLL.cxx:369
 RooBarlowBeestonLL.cxx:370
 RooBarlowBeestonLL.cxx:371
 RooBarlowBeestonLL.cxx:372
 RooBarlowBeestonLL.cxx:373
 RooBarlowBeestonLL.cxx:374
 RooBarlowBeestonLL.cxx:375
 RooBarlowBeestonLL.cxx:376
 RooBarlowBeestonLL.cxx:377
 RooBarlowBeestonLL.cxx:378
 RooBarlowBeestonLL.cxx:379
 RooBarlowBeestonLL.cxx:380
 RooBarlowBeestonLL.cxx:381
 RooBarlowBeestonLL.cxx:382
 RooBarlowBeestonLL.cxx:383
 RooBarlowBeestonLL.cxx:384
 RooBarlowBeestonLL.cxx:385
 RooBarlowBeestonLL.cxx:386
 RooBarlowBeestonLL.cxx:387
 RooBarlowBeestonLL.cxx:388
 RooBarlowBeestonLL.cxx:389
 RooBarlowBeestonLL.cxx:390
 RooBarlowBeestonLL.cxx:391
 RooBarlowBeestonLL.cxx:392
 RooBarlowBeestonLL.cxx:393
 RooBarlowBeestonLL.cxx:394
 RooBarlowBeestonLL.cxx:395
 RooBarlowBeestonLL.cxx:396
 RooBarlowBeestonLL.cxx:397
 RooBarlowBeestonLL.cxx:398
 RooBarlowBeestonLL.cxx:399
 RooBarlowBeestonLL.cxx:400
 RooBarlowBeestonLL.cxx:401
 RooBarlowBeestonLL.cxx:402
 RooBarlowBeestonLL.cxx:403
 RooBarlowBeestonLL.cxx:404
 RooBarlowBeestonLL.cxx:405
 RooBarlowBeestonLL.cxx:406
 RooBarlowBeestonLL.cxx:407
 RooBarlowBeestonLL.cxx:408
 RooBarlowBeestonLL.cxx:409
 RooBarlowBeestonLL.cxx:410
 RooBarlowBeestonLL.cxx:411
 RooBarlowBeestonLL.cxx:412
 RooBarlowBeestonLL.cxx:413
 RooBarlowBeestonLL.cxx:414
 RooBarlowBeestonLL.cxx:415
 RooBarlowBeestonLL.cxx:416
 RooBarlowBeestonLL.cxx:417
 RooBarlowBeestonLL.cxx:418
 RooBarlowBeestonLL.cxx:419
 RooBarlowBeestonLL.cxx:420
 RooBarlowBeestonLL.cxx:421
 RooBarlowBeestonLL.cxx:422
 RooBarlowBeestonLL.cxx:423
 RooBarlowBeestonLL.cxx:424
 RooBarlowBeestonLL.cxx:425
 RooBarlowBeestonLL.cxx:426
 RooBarlowBeestonLL.cxx:427
 RooBarlowBeestonLL.cxx:428
 RooBarlowBeestonLL.cxx:429
 RooBarlowBeestonLL.cxx:430
 RooBarlowBeestonLL.cxx:431
 RooBarlowBeestonLL.cxx:432
 RooBarlowBeestonLL.cxx:433
 RooBarlowBeestonLL.cxx:434
 RooBarlowBeestonLL.cxx:435
 RooBarlowBeestonLL.cxx:436
 RooBarlowBeestonLL.cxx:437
 RooBarlowBeestonLL.cxx:438
 RooBarlowBeestonLL.cxx:439
 RooBarlowBeestonLL.cxx:440
 RooBarlowBeestonLL.cxx:441
 RooBarlowBeestonLL.cxx:442
 RooBarlowBeestonLL.cxx:443
 RooBarlowBeestonLL.cxx:444
 RooBarlowBeestonLL.cxx:445
 RooBarlowBeestonLL.cxx:446
 RooBarlowBeestonLL.cxx:447
 RooBarlowBeestonLL.cxx:448
 RooBarlowBeestonLL.cxx:449
 RooBarlowBeestonLL.cxx:450
 RooBarlowBeestonLL.cxx:451
 RooBarlowBeestonLL.cxx:452
 RooBarlowBeestonLL.cxx:453
 RooBarlowBeestonLL.cxx:454
 RooBarlowBeestonLL.cxx:455
 RooBarlowBeestonLL.cxx:456
 RooBarlowBeestonLL.cxx:457
 RooBarlowBeestonLL.cxx:458
 RooBarlowBeestonLL.cxx:459
 RooBarlowBeestonLL.cxx:460
 RooBarlowBeestonLL.cxx:461
 RooBarlowBeestonLL.cxx:462
 RooBarlowBeestonLL.cxx:463
 RooBarlowBeestonLL.cxx:464
 RooBarlowBeestonLL.cxx:465
 RooBarlowBeestonLL.cxx:466
 RooBarlowBeestonLL.cxx:467
 RooBarlowBeestonLL.cxx:468
 RooBarlowBeestonLL.cxx:469
 RooBarlowBeestonLL.cxx:470
 RooBarlowBeestonLL.cxx:471
 RooBarlowBeestonLL.cxx:472
 RooBarlowBeestonLL.cxx:473
 RooBarlowBeestonLL.cxx:474
 RooBarlowBeestonLL.cxx:475
 RooBarlowBeestonLL.cxx:476
 RooBarlowBeestonLL.cxx:477
 RooBarlowBeestonLL.cxx:478
 RooBarlowBeestonLL.cxx:479
 RooBarlowBeestonLL.cxx:480
 RooBarlowBeestonLL.cxx:481
 RooBarlowBeestonLL.cxx:482
 RooBarlowBeestonLL.cxx:483
 RooBarlowBeestonLL.cxx:484
 RooBarlowBeestonLL.cxx:485
 RooBarlowBeestonLL.cxx:486
 RooBarlowBeestonLL.cxx:487
 RooBarlowBeestonLL.cxx:488
 RooBarlowBeestonLL.cxx:489
 RooBarlowBeestonLL.cxx:490
 RooBarlowBeestonLL.cxx:491
 RooBarlowBeestonLL.cxx:492
 RooBarlowBeestonLL.cxx:493
 RooBarlowBeestonLL.cxx:494
 RooBarlowBeestonLL.cxx:495
 RooBarlowBeestonLL.cxx:496
 RooBarlowBeestonLL.cxx:497
 RooBarlowBeestonLL.cxx:498
 RooBarlowBeestonLL.cxx:499
 RooBarlowBeestonLL.cxx:500
 RooBarlowBeestonLL.cxx:501
 RooBarlowBeestonLL.cxx:502
 RooBarlowBeestonLL.cxx:503
 RooBarlowBeestonLL.cxx:504
 RooBarlowBeestonLL.cxx:505
 RooBarlowBeestonLL.cxx:506
 RooBarlowBeestonLL.cxx:507
 RooBarlowBeestonLL.cxx:508
 RooBarlowBeestonLL.cxx:509
 RooBarlowBeestonLL.cxx:510
 RooBarlowBeestonLL.cxx:511
 RooBarlowBeestonLL.cxx:512
 RooBarlowBeestonLL.cxx:513
 RooBarlowBeestonLL.cxx:514
 RooBarlowBeestonLL.cxx:515
 RooBarlowBeestonLL.cxx:516
 RooBarlowBeestonLL.cxx:517
 RooBarlowBeestonLL.cxx:518
 RooBarlowBeestonLL.cxx:519
 RooBarlowBeestonLL.cxx:520
 RooBarlowBeestonLL.cxx:521
 RooBarlowBeestonLL.cxx:522
 RooBarlowBeestonLL.cxx:523
 RooBarlowBeestonLL.cxx:524
 RooBarlowBeestonLL.cxx:525
 RooBarlowBeestonLL.cxx:526
 RooBarlowBeestonLL.cxx:527
 RooBarlowBeestonLL.cxx:528
 RooBarlowBeestonLL.cxx:529
 RooBarlowBeestonLL.cxx:530
 RooBarlowBeestonLL.cxx:531
 RooBarlowBeestonLL.cxx:532
 RooBarlowBeestonLL.cxx:533
 RooBarlowBeestonLL.cxx:534
 RooBarlowBeestonLL.cxx:535
 RooBarlowBeestonLL.cxx:536
 RooBarlowBeestonLL.cxx:537
 RooBarlowBeestonLL.cxx:538
 RooBarlowBeestonLL.cxx:539
 RooBarlowBeestonLL.cxx:540
 RooBarlowBeestonLL.cxx:541
 RooBarlowBeestonLL.cxx:542
 RooBarlowBeestonLL.cxx:543
 RooBarlowBeestonLL.cxx:544
 RooBarlowBeestonLL.cxx:545
 RooBarlowBeestonLL.cxx:546
 RooBarlowBeestonLL.cxx:547
 RooBarlowBeestonLL.cxx:548
 RooBarlowBeestonLL.cxx:549
 RooBarlowBeestonLL.cxx:550
 RooBarlowBeestonLL.cxx:551
 RooBarlowBeestonLL.cxx:552
 RooBarlowBeestonLL.cxx:553
 RooBarlowBeestonLL.cxx:554
 RooBarlowBeestonLL.cxx:555
 RooBarlowBeestonLL.cxx:556
 RooBarlowBeestonLL.cxx:557
 RooBarlowBeestonLL.cxx:558
 RooBarlowBeestonLL.cxx:559
 RooBarlowBeestonLL.cxx:560
 RooBarlowBeestonLL.cxx:561
 RooBarlowBeestonLL.cxx:562
 RooBarlowBeestonLL.cxx:563
 RooBarlowBeestonLL.cxx:564
 RooBarlowBeestonLL.cxx:565
 RooBarlowBeestonLL.cxx:566
 RooBarlowBeestonLL.cxx:567
 RooBarlowBeestonLL.cxx:568
 RooBarlowBeestonLL.cxx:569
 RooBarlowBeestonLL.cxx:570
 RooBarlowBeestonLL.cxx:571
 RooBarlowBeestonLL.cxx:572
 RooBarlowBeestonLL.cxx:573
 RooBarlowBeestonLL.cxx:574
 RooBarlowBeestonLL.cxx:575
 RooBarlowBeestonLL.cxx:576
 RooBarlowBeestonLL.cxx:577
 RooBarlowBeestonLL.cxx:578
 RooBarlowBeestonLL.cxx:579
 RooBarlowBeestonLL.cxx:580
 RooBarlowBeestonLL.cxx:581
 RooBarlowBeestonLL.cxx:582
 RooBarlowBeestonLL.cxx:583
 RooBarlowBeestonLL.cxx:584
 RooBarlowBeestonLL.cxx:585
 RooBarlowBeestonLL.cxx:586
 RooBarlowBeestonLL.cxx:587
 RooBarlowBeestonLL.cxx:588
 RooBarlowBeestonLL.cxx:589
 RooBarlowBeestonLL.cxx:590
 RooBarlowBeestonLL.cxx:591
 RooBarlowBeestonLL.cxx:592
 RooBarlowBeestonLL.cxx:593
 RooBarlowBeestonLL.cxx:594
 RooBarlowBeestonLL.cxx:595
 RooBarlowBeestonLL.cxx:596
 RooBarlowBeestonLL.cxx:597
 RooBarlowBeestonLL.cxx:598
 RooBarlowBeestonLL.cxx:599
 RooBarlowBeestonLL.cxx:600
 RooBarlowBeestonLL.cxx:601
 RooBarlowBeestonLL.cxx:602
 RooBarlowBeestonLL.cxx:603
 RooBarlowBeestonLL.cxx:604
 RooBarlowBeestonLL.cxx:605
 RooBarlowBeestonLL.cxx:606
 RooBarlowBeestonLL.cxx:607
 RooBarlowBeestonLL.cxx:608
 RooBarlowBeestonLL.cxx:609
 RooBarlowBeestonLL.cxx:610
 RooBarlowBeestonLL.cxx:611
 RooBarlowBeestonLL.cxx:612
 RooBarlowBeestonLL.cxx:613
 RooBarlowBeestonLL.cxx:614
 RooBarlowBeestonLL.cxx:615
 RooBarlowBeestonLL.cxx:616
 RooBarlowBeestonLL.cxx:617
 RooBarlowBeestonLL.cxx:618
 RooBarlowBeestonLL.cxx:619
 RooBarlowBeestonLL.cxx:620
 RooBarlowBeestonLL.cxx:621
 RooBarlowBeestonLL.cxx:622
 RooBarlowBeestonLL.cxx:623
 RooBarlowBeestonLL.cxx:624
 RooBarlowBeestonLL.cxx:625
 RooBarlowBeestonLL.cxx:626
 RooBarlowBeestonLL.cxx:627
 RooBarlowBeestonLL.cxx:628
 RooBarlowBeestonLL.cxx:629
 RooBarlowBeestonLL.cxx:630
 RooBarlowBeestonLL.cxx:631
 RooBarlowBeestonLL.cxx:632
 RooBarlowBeestonLL.cxx:633
 RooBarlowBeestonLL.cxx:634
 RooBarlowBeestonLL.cxx:635
 RooBarlowBeestonLL.cxx:636
 RooBarlowBeestonLL.cxx:637
 RooBarlowBeestonLL.cxx:638
 RooBarlowBeestonLL.cxx:639
 RooBarlowBeestonLL.cxx:640
 RooBarlowBeestonLL.cxx:641
 RooBarlowBeestonLL.cxx:642
 RooBarlowBeestonLL.cxx:643
 RooBarlowBeestonLL.cxx:644
 RooBarlowBeestonLL.cxx:645
 RooBarlowBeestonLL.cxx:646
 RooBarlowBeestonLL.cxx:647
 RooBarlowBeestonLL.cxx:648
 RooBarlowBeestonLL.cxx:649
 RooBarlowBeestonLL.cxx:650
 RooBarlowBeestonLL.cxx:651
 RooBarlowBeestonLL.cxx:652
 RooBarlowBeestonLL.cxx:653
 RooBarlowBeestonLL.cxx:654
 RooBarlowBeestonLL.cxx:655
 RooBarlowBeestonLL.cxx:656
 RooBarlowBeestonLL.cxx:657
 RooBarlowBeestonLL.cxx:658
 RooBarlowBeestonLL.cxx:659
 RooBarlowBeestonLL.cxx:660
 RooBarlowBeestonLL.cxx:661
 RooBarlowBeestonLL.cxx:662
 RooBarlowBeestonLL.cxx:663
 RooBarlowBeestonLL.cxx:664
 RooBarlowBeestonLL.cxx:665
 RooBarlowBeestonLL.cxx:666
 RooBarlowBeestonLL.cxx:667
 RooBarlowBeestonLL.cxx:668
 RooBarlowBeestonLL.cxx:669
 RooBarlowBeestonLL.cxx:670
 RooBarlowBeestonLL.cxx:671
 RooBarlowBeestonLL.cxx:672
 RooBarlowBeestonLL.cxx:673
 RooBarlowBeestonLL.cxx:674
 RooBarlowBeestonLL.cxx:675
 RooBarlowBeestonLL.cxx:676
 RooBarlowBeestonLL.cxx:677
 RooBarlowBeestonLL.cxx:678
 RooBarlowBeestonLL.cxx:679
 RooBarlowBeestonLL.cxx:680
 RooBarlowBeestonLL.cxx:681
 RooBarlowBeestonLL.cxx:682
 RooBarlowBeestonLL.cxx:683
 RooBarlowBeestonLL.cxx:684
 RooBarlowBeestonLL.cxx:685
 RooBarlowBeestonLL.cxx:686
 RooBarlowBeestonLL.cxx:687
 RooBarlowBeestonLL.cxx:688
 RooBarlowBeestonLL.cxx:689
 RooBarlowBeestonLL.cxx:690
 RooBarlowBeestonLL.cxx:691
 RooBarlowBeestonLL.cxx:692
 RooBarlowBeestonLL.cxx:693
 RooBarlowBeestonLL.cxx:694
 RooBarlowBeestonLL.cxx:695
 RooBarlowBeestonLL.cxx:696
 RooBarlowBeestonLL.cxx:697
 RooBarlowBeestonLL.cxx:698
 RooBarlowBeestonLL.cxx:699
 RooBarlowBeestonLL.cxx:700
 RooBarlowBeestonLL.cxx:701
 RooBarlowBeestonLL.cxx:702
 RooBarlowBeestonLL.cxx:703
 RooBarlowBeestonLL.cxx:704
 RooBarlowBeestonLL.cxx:705
 RooBarlowBeestonLL.cxx:706
 RooBarlowBeestonLL.cxx:707
 RooBarlowBeestonLL.cxx:708
 RooBarlowBeestonLL.cxx:709
 RooBarlowBeestonLL.cxx:710
 RooBarlowBeestonLL.cxx:711
 RooBarlowBeestonLL.cxx:712
 RooBarlowBeestonLL.cxx:713
 RooBarlowBeestonLL.cxx:714
 RooBarlowBeestonLL.cxx:715
 RooBarlowBeestonLL.cxx:716
 RooBarlowBeestonLL.cxx:717
 RooBarlowBeestonLL.cxx:718
 RooBarlowBeestonLL.cxx:719
 RooBarlowBeestonLL.cxx:720
 RooBarlowBeestonLL.cxx:721
 RooBarlowBeestonLL.cxx:722
 RooBarlowBeestonLL.cxx:723
 RooBarlowBeestonLL.cxx:724
 RooBarlowBeestonLL.cxx:725
 RooBarlowBeestonLL.cxx:726
 RooBarlowBeestonLL.cxx:727
 RooBarlowBeestonLL.cxx:728
 RooBarlowBeestonLL.cxx:729
 RooBarlowBeestonLL.cxx:730
 RooBarlowBeestonLL.cxx:731
 RooBarlowBeestonLL.cxx:732
 RooBarlowBeestonLL.cxx:733
 RooBarlowBeestonLL.cxx:734
 RooBarlowBeestonLL.cxx:735
 RooBarlowBeestonLL.cxx:736
 RooBarlowBeestonLL.cxx:737
 RooBarlowBeestonLL.cxx:738
 RooBarlowBeestonLL.cxx:739
 RooBarlowBeestonLL.cxx:740
 RooBarlowBeestonLL.cxx:741
 RooBarlowBeestonLL.cxx:742
 RooBarlowBeestonLL.cxx:743
 RooBarlowBeestonLL.cxx:744
 RooBarlowBeestonLL.cxx:745
 RooBarlowBeestonLL.cxx:746
 RooBarlowBeestonLL.cxx:747
 RooBarlowBeestonLL.cxx:748
 RooBarlowBeestonLL.cxx:749
 RooBarlowBeestonLL.cxx:750
 RooBarlowBeestonLL.cxx:751
 RooBarlowBeestonLL.cxx:752
 RooBarlowBeestonLL.cxx:753
 RooBarlowBeestonLL.cxx:754
 RooBarlowBeestonLL.cxx:755