ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 * @(#)root/roofitcore:$Id: RooAddModel.cxx 28259 2009-04-16 16:21:16Z wouter $
 * 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)             *
 *****************************************************************************/

//////////////////////////////////////////////////////////////////////////////
// 
// RooAddModel is an efficient implementation of a sum of PDFs of the form 
//
//  c_1*PDF_1 + c_2*PDF_2 + ... c_n*PDF_n 
//
// or 
//
//  c_1*PDF_1 + c_2*PDF_2 + ... (1-sum(c_1...c_n-1))*PDF_n 
//
// The first form is for extended likelihood fits, where the
// expected number of events is Sum(i) c_i. The coefficients c_i
// can either be explicitly provided, or, if all components support
// extended likelihood fits, they can be calculated the contribution
// of each PDF to the total number of expected events.
//
// In the second form, the sum of the coefficients is enforced to be one,
// and the coefficient of the last PDF is calculated from that condition.
//
// RooAddPdf relies on each component PDF to be normalized and will perform 
// no normalization other than calculating the proper last coefficient c_n, if requested.
// An (enforced) condition for this assuption is that each PDF_i is independent
// of each coefficient_i.
//
// 

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

#include "TIterator.h"
#include "TIterator.h"
#include "TList.h"
#include "RooAddModel.h"
#include "RooDataSet.h"
#include "RooRealProxy.h"
#include "RooPlot.h"
#include "RooRealVar.h"
#include "RooAddGenContext.h"
#include "RooRealConstant.h"
#include "RooNameReg.h"
#include "RooMsgService.h"

#include "Riostream.h"



ClassImp(RooAddModel)
;


//_____________________________________________________________________________
RooAddModel::RooAddModel() :
  _refCoefNorm("!refCoefNorm","Reference coefficient normalization set",this,kFALSE,kFALSE),
  _refCoefRangeName(0),
  _codeReg(10),
  _snormList(0)
{
  _pdfIter   = _pdfList.createIterator() ;
  _coefIter  = _coefList.createIterator() ;

  _coefCache = new Double_t[10] ;
  _coefErrCount = _errorCount ;
}



//_____________________________________________________________________________
RooAddModel::RooAddModel(const char *name, const char *title, const RooArgList& inPdfList, const RooArgList& inCoefList, Bool_t ownPdfList) :
  RooResolutionModel(name,title,((RooResolutionModel*)inPdfList.at(0))->convVar()),
  _refCoefNorm("!refCoefNorm","Reference coefficient normalization set",this,kFALSE,kFALSE),
  _refCoefRangeName(0),
  _projectCoefs(kFALSE),
  _projCacheMgr(this,10),
  _intCacheMgr(this,10),
  _codeReg(10),
  _pdfList("!pdfs","List of PDFs",this),
  _coefList("!coefficients","List of coefficients",this),
  _haveLastCoef(kFALSE),
  _allExtendable(kFALSE)
{ 
  // Generic constructor from list of PDFs and list of coefficients.
  // Each pdf list element (i) is paired with coefficient list element (i).
  // The number of coefficients must be either equal to the number of PDFs,
  // in which case extended MLL fitting is enabled, or be one less.
  //
  // All PDFs must inherit from RooAbsPdf. All coefficients must inherit from RooAbsReal

  if (inPdfList.getSize()>inCoefList.getSize()+1) {
    coutE(InputArguments) << "RooAddModel::RooAddModel(" << GetName() 
			  << ") number of pdfs and coefficients inconsistent, must have Npdf=Ncoef or Npdf=Ncoef+1" << endl ;
    assert(0) ;
  }

  _pdfIter  = _pdfList.createIterator() ;
  _coefIter = _coefList.createIterator() ;
 
  // Constructor with N PDFs and N or N-1 coefs
  TIterator* pdfIter = inPdfList.createIterator() ;
  TIterator* coefIter = inCoefList.createIterator() ;
  RooAbsPdf* pdf ;
  RooAbsReal* coef ;

  while((coef = (RooAbsPdf*)coefIter->Next())) {
    pdf = (RooAbsPdf*) pdfIter->Next() ;
    if (!pdf) {
      coutE(InputArguments) << "RooAddModel::RooAddModel(" << GetName() 
			    << ") number of pdfs and coefficients inconsistent, must have Npdf=Ncoef or Npdf=Ncoef+1" << endl ;
      assert(0) ;
    }
    if (!dynamic_cast<RooAbsReal*>(coef)) {
      coutE(InputArguments) << "RooAddModel::RooAddModel(" << GetName() << ") coefficient " << coef->GetName() << " is not of type RooAbsReal, ignored" << endl ;
      continue ;
    }
    if (!dynamic_cast<RooAbsReal*>(pdf)) {
      coutE(InputArguments) << "RooAddModel::RooAddModel(" << GetName() << ") pdf " << pdf->GetName() << " is not of type RooAbsPdf, ignored" << endl ;
      continue ;
    }
    _pdfList.add(*pdf) ;
    _coefList.add(*coef) ;    
  }

  pdf = (RooAbsPdf*) pdfIter->Next() ;
  if (pdf) {
    if (!dynamic_cast<RooAbsReal*>(pdf)) {
      coutE(InputArguments) << "RooAddModel::RooAddModel(" << GetName() << ") last pdf " << coef->GetName() << " is not of type RooAbsPdf, fatal error" << endl ;
      assert(0) ;
    }
    _pdfList.add(*pdf) ;  
  } else {
    _haveLastCoef=kTRUE ;
  }

  delete pdfIter ;
  delete coefIter  ;

  _coefCache = new Double_t[_pdfList.getSize()] ;
  _coefErrCount = _errorCount ;

  if (ownPdfList) {
    _ownedComps.addOwned(_pdfList) ;
  }

}



//_____________________________________________________________________________
RooAddModel::RooAddModel(const RooAddModel& other, const char* name) :
  RooResolutionModel(other,name),
  _refCoefNorm("!refCoefNorm",this,other._refCoefNorm),
  _refCoefRangeName((TNamed*)other._refCoefRangeName),
  _projectCoefs(other._projectCoefs),
  _projCacheMgr(other._projCacheMgr,this),
  _intCacheMgr(other._intCacheMgr,this),
  _codeReg(other._codeReg),
  _pdfList("!pdfs",this,other._pdfList),
  _coefList("!coefficients",this,other._coefList),
  _haveLastCoef(other._haveLastCoef),
  _allExtendable(other._allExtendable)
{
  // Copy constructor

  _pdfIter  = _pdfList.createIterator() ;
  _coefIter = _coefList.createIterator() ;
  _coefCache = new Double_t[_pdfList.getSize()] ;
  _coefErrCount = _errorCount ;
}



//_____________________________________________________________________________
RooAddModel::~RooAddModel()
{
  // Destructor

  delete _pdfIter ;
  delete _coefIter ;

  if (_coefCache) delete[] _coefCache ;
}



//_____________________________________________________________________________
void RooAddModel::fixCoefNormalization(const RooArgSet& refCoefNorm) 
{
  // By default the interpretation of the fraction coefficients is
  // performed in the contextual choice of observables. This makes the
  // shape of the p.d.f explicitly dependent on the choice of
  // observables. This method instructs RooAddPdf to freeze the
  // interpretation of the coefficients to be done in the given set of
  // observables. If frozen, fractions are automatically transformed
  // from the reference normalization set to the contextual normalization
  // set by ratios of integrals

  if (refCoefNorm.getSize()==0) {
    _projectCoefs = kFALSE ;
    return ;
  }
  _projectCoefs = kTRUE ;  

  _refCoefNorm.removeAll() ;
  _refCoefNorm.add(refCoefNorm) ;

  _projCacheMgr.reset() ;
}



//_____________________________________________________________________________
void RooAddModel::fixCoefRange(const char* rangeName)
{
  // By default the interpretation of the fraction coefficients is
  // performed in the default range. This make the shape of a RooAddPdf
  // explicitly dependent on the range of the observables. To allow
  // a range independent definition of the fraction this function
  // instructs RooAddPdf to freeze its interpretation in the given
  // named range. If the current normalization range is different
  // from the reference range, the appropriate fraction coefficients
  // are automically calculation from the reference fractions using
  // ratios if integrals

  _refCoefRangeName = (TNamed*)RooNameReg::ptr(rangeName) ;
  if (_refCoefRangeName) _projectCoefs = kTRUE ;
}



//_____________________________________________________________________________
RooResolutionModel* RooAddModel::convolution(RooFormulaVar* inBasis, RooAbsArg* owner) const
{
  // Instantiate a clone of this resolution model representing a convolution with given
  // basis function. The owners object name is incorporated in the clones name
  // to avoid multiple convolution objects with the same name in complex PDF structures.
  //
  // RooAddModel will clone all the component models to create a composite convolution object

  // Check that primary variable of basis functions is our convolution variable  
  if (inBasis->findServer(0) != x.absArg()) {
    coutE(InputArguments) << "RooAddModel::convolution(" << GetName() 
			  << ") convolution parameter of basis function and PDF don't match" << endl ;
    ccoutE(InputArguments) << "basis->findServer(0) = " << inBasis->findServer(0) << " " << inBasis->findServer(0)->GetName() << endl ;
    ccoutE(InputArguments) << "x.absArg()           = " << x.absArg() << " " << x.absArg()->GetName() << endl ;
    inBasis->Print("v") ;
    return 0 ;
  }

  TString newName(GetName()) ;
  newName.Append("_conv_") ;
  newName.Append(inBasis->GetName()) ;
  newName.Append("_[") ;
  newName.Append(owner->GetName()) ;
  newName.Append("]") ;

  TString newTitle(GetTitle()) ;
  newTitle.Append(" convoluted with basis function ") ;
  newTitle.Append(inBasis->GetName()) ;

  _pdfIter->Reset() ;
  RooResolutionModel* model ;
  RooArgList modelList ;
  while((model = (RooResolutionModel*)_pdfIter->Next())) {       
    // Create component convolution
    RooResolutionModel* conv = model->convolution(inBasis,owner) ;    
    modelList.add(*conv) ;
  }

  _coefIter->Reset() ;
  RooAbsReal* coef ;
  RooArgList theCoefList ;  
  while((coef = (RooAbsReal*)_coefIter->Next())) {
    theCoefList.add(*coef) ;
  }
    
  RooAddModel* convSum = new RooAddModel(newName,newTitle,modelList,theCoefList,kTRUE) ;
  convSum->changeBasis(inBasis) ;
  return convSum ;
}



//_____________________________________________________________________________
Int_t RooAddModel::basisCode(const char* name) const 
{
  // Return code for basis function representing by 'name' string.
  // The basis code of the first component model will be returned,
  // if the basis is supported by all components. Otherwise 0
  // is returned

  TIterator* mIter = _pdfList.createIterator() ;
  RooResolutionModel* model ;
  Bool_t first(kTRUE), code(0) ;
    while((model = (RooResolutionModel*)mIter->Next())) {
      Int_t subCode = model->basisCode(name) ;
      if (first) {
	code = subCode ;
      } else if (subCode==0) {
	code = 0 ;
      }
  }
  delete mIter ;

  return code ;
}



//_____________________________________________________________________________
RooAddModel::CacheElem* RooAddModel::getProjCache(const RooArgSet* nset, const RooArgSet* iset, const char* rangeName) const
{
  // Retrieve cache element with for calculation of p.d.f value with normalization set nset and integrated over iset
  // in range 'rangeName'. If cache element does not exist, create and fill it on the fly. The cache contains
  // suplemental normalization terms (in case not all added p.d.f.s have the same observables), projection
  // integrals to calculated transformed fraction coefficients when a frozen reference frame is provided
  // and projection integrals for similar transformations when a frozen reference range is provided.

  // Check if cache already exists 
  CacheElem* cache = (CacheElem*) _projCacheMgr.getObj(nset,iset,0,RooNameReg::ptr(rangeName)) ;
  if (cache) {
    return cache ;
  }

  //Create new cache 
  cache = new CacheElem ;

  // *** PART 1 : Create supplemental normalization list ***

  // Retrieve the combined set of dependents of this PDF ;
  RooArgSet *fullDepList = getObservables(nset) ;
  if (iset) {
    fullDepList->remove(*iset,kTRUE,kTRUE) ;
  }    

  // Fill with dummy unit RRVs for now
  _pdfIter->Reset() ;
  _coefIter->Reset() ;
  RooAbsPdf* pdf ;
  RooAbsReal* coef ;
  while((pdf=(RooAbsPdf*)_pdfIter->Next())) {    
    coef=(RooAbsPdf*)_coefIter->Next() ;

    // Start with full list of dependents
    RooArgSet supNSet(*fullDepList) ;

    // Remove PDF dependents
    RooArgSet* pdfDeps = pdf->getObservables(nset) ;
    if (pdfDeps) {
      supNSet.remove(*pdfDeps,kTRUE,kTRUE) ;
      delete pdfDeps ; 
    }

    // Remove coef dependents
    RooArgSet* coefDeps = coef ? coef->getObservables(nset) : 0 ;
    if (coefDeps) {
      supNSet.remove(*coefDeps,kTRUE,kTRUE) ;
      delete coefDeps ;
    }
    
    RooAbsReal* snorm ;
    TString name(GetName()) ;
    name.Append("_") ;
    name.Append(pdf->GetName()) ;
    name.Append("_SupNorm") ;
    if (supNSet.getSize()>0) {
      snorm = new RooRealIntegral(name,"Supplemental normalization integral",RooRealConstant::value(1.0),supNSet) ;
    } else {
      snorm = new RooRealVar(name,"Unit Supplemental normalization integral",1.0) ;
    }
    cache->_suppNormList.addOwned(*snorm) ;
  }

  delete fullDepList ;
    
  if (_verboseEval>1) {
    cxcoutD(Caching) << "RooAddModel::syncSuppNormList(" << GetName() << ") synching supplemental normalization list for norm" << (nset?*nset:RooArgSet()) << endl ;
    if (dologD(Caching)) {
      cache->_suppNormList.Print("v") ;
    }
  }


  // *** PART 2 : Create projection coefficients ***

  // If no projections required stop here
  if (!_projectCoefs || _basis!=0 ) {
    _projCacheMgr.setObj(nset,iset,cache,RooNameReg::ptr(rangeName)) ;
    return cache ;
  }


  // Reduce iset/nset to actual dependents of this PDF
  RooArgSet* nset2 = nset ? getObservables(nset) : new RooArgSet() ;

  // Check if requested transformation is not identity 
  if (!nset2->equals(_refCoefNorm) || _refCoefRangeName !=0 || rangeName !=0 ) {
    
    coutI(Caching)  << "RooAddModel::syncCoefProjList(" << GetName() << ") creating coefficient projection integrals" << endl ;
    ccoutI(Caching) << "  from current normalization: "  ; nset2->Print("1") ;
    ccoutI(Caching) << "          with current range: " << (rangeName?rangeName:"<none>") << endl ;
    ccoutI(Caching) << "  to reference normalization: "  ; _refCoefNorm.Print("1") ; 
    ccoutI(Caching) << "        with reference range: " << (_refCoefRangeName?RooNameReg::str(_refCoefRangeName):"<none>") << endl ;
    
    // Recalculate projection integrals of PDFs 
    _pdfIter->Reset() ;
    RooAbsPdf* thePdf ;

    while((thePdf=(RooAbsPdf*)_pdfIter->Next())) {

      // Calculate projection integral
      RooAbsReal* pdfProj ;
      if (!nset2->equals(_refCoefNorm)) {
	pdfProj = thePdf->createIntegral(*nset2,_refCoefNorm) ;
	pdfProj->setOperMode(operMode()) ;
      } else {
	TString name(GetName()) ;
	name.Append("_") ;
	name.Append(thePdf->GetName()) ;
	name.Append("_ProjectNorm") ;
	pdfProj = new RooRealVar(name,"Unit Projection normalization integral",1.0) ;
      }

      cache->_projList.addOwned(*pdfProj) ;

      // Calculation optional supplemental normalization term
      RooArgSet supNormSet(_refCoefNorm) ;
      RooArgSet* deps = thePdf->getParameters(RooArgSet()) ;
      supNormSet.remove(*deps,kTRUE,kTRUE) ;
      delete deps ;

      RooAbsReal* snorm ;
      TString name(GetName()) ;
      name.Append("_") ;
      name.Append(thePdf->GetName()) ;
      name.Append("_ProjSupNorm") ;
      if (supNormSet.getSize()>0) {
	snorm = new RooRealIntegral(name,"Projection Supplemental normalization integral",
				    RooRealConstant::value(1.0),supNormSet) ;
      } else {
	snorm = new RooRealVar(name,"Unit Projection Supplemental normalization integral",1.0) ;
      }
      cache->_suppProjList.addOwned(*snorm) ;

      // Calculate reference range adjusted projection integral
      RooAbsReal* rangeProj1 ;
      if (_refCoefRangeName && _refCoefNorm.getSize()>0) {
	rangeProj1 = thePdf->createIntegral(_refCoefNorm,_refCoefNorm,RooNameReg::str(_refCoefRangeName)) ;
	rangeProj1->setOperMode(operMode()) ;
      } else {
	TString theName(GetName()) ;
	theName.Append("_") ;
	theName.Append(thePdf->GetName()) ;
	theName.Append("_RangeNorm1") ;
	rangeProj1 = new RooRealVar(theName,"Unit range normalization integral",1.0) ;
      }
      cache->_refRangeProjList.addOwned(*rangeProj1) ;
      

      // Calculate range adjusted projection integral
      RooAbsReal* rangeProj2 ;
      if (rangeName && _refCoefNorm.getSize()>0) {
	rangeProj2 = thePdf->createIntegral(_refCoefNorm,_refCoefNorm,rangeName) ;
	rangeProj2->setOperMode(operMode()) ;
      } else {
	TString theName(GetName()) ;
	theName.Append("_") ;
	theName.Append(thePdf->GetName()) ;
	theName.Append("_RangeNorm2") ;
	rangeProj2 = new RooRealVar(theName,"Unit range normalization integral",1.0) ;
      }
      cache->_rangeProjList.addOwned(*rangeProj2) ;

    }               

  }

  delete nset2 ;

  _projCacheMgr.setObj(nset,iset,cache,RooNameReg::ptr(rangeName)) ;

  return cache ;
}



//_____________________________________________________________________________
void RooAddModel::updateCoefficients(CacheElem& cache, const RooArgSet* nset) const 
{
  // Update the coefficient values in the given cache element: calculate new remainder
  // fraction, normalize fractions obtained from extended ML terms to unity and
  // multiply these the various range and dimensional corrections needed in the
  // current use context

  // cxcoutD(ChangeTracking) << "RooAddModel::updateCoefficients(" << GetName() << ") update coefficients" << endl ;
  
  Int_t i ;

  // Straight coefficients
  if (_allExtendable) {
    
    // coef[i] = expectedEvents[i] / SUM(expectedEvents)
    Double_t coefSum(0) ;
    for (i=0 ; i<_pdfList.getSize() ; i++) {
      _coefCache[i] = ((RooAbsPdf*)_pdfList.at(i))->expectedEvents(_refCoefNorm.getSize()>0?&_refCoefNorm:nset) ;
      coefSum += _coefCache[i] ;
    }
    if (coefSum==0.) {
      coutW(Eval) << "RooAddModel::updateCoefCache(" << GetName() << ") WARNING: total number of expected events is 0" << endl ;
    } else {
      for (i=0 ; i<_pdfList.getSize() ; i++) {
	_coefCache[i] /= coefSum ;
      }			            
    }
    
  } else {
    if (_haveLastCoef) {
      
      // coef[i] = coef[i] / SUM(coef)
      Double_t coefSum(0) ;
      for (i=0 ; i<_coefList.getSize() ; i++) {
	_coefCache[i] = ((RooAbsPdf*)_coefList.at(i))->getVal(nset) ;
	coefSum += _coefCache[i] ;
      }		
      for (i=0 ; i<_coefList.getSize() ; i++) {
	_coefCache[i] /= coefSum ;
      }			
    } else {
      
      // coef[i] = coef[i] ; coef[n] = 1-SUM(coef[0...n-1])
      Double_t lastCoef(1) ;
      for (i=0 ; i<_coefList.getSize() ; i++) {
	_coefCache[i] = ((RooAbsPdf*)_coefList.at(i))->getVal(nset) ;
 	cxcoutD(Caching) << "SYNC: orig coef[" << i << "] = " << _coefCache[i] << endl ;
	lastCoef -= _coefCache[i] ;
      }			
      _coefCache[_coefList.getSize()] = lastCoef ;
      cxcoutD(Caching) << "SYNC: orig coef[" << _coefList.getSize() << "] = " << _coefCache[_coefList.getSize()] << endl ;
      
      
      // Warn about coefficient degeneration
      if ((lastCoef<-1e-05 || (lastCoef-1)>1e-5) && _coefErrCount-->0) {
	coutW(Eval) << "RooAddModel::updateCoefCache(" << GetName() 
		    << " WARNING: sum of PDF coefficients not in range [0-1], value=" 
		    << 1-lastCoef << endl ;
	if (_coefErrCount==0) {
	  coutW(Eval) << " (no more will be printed)" << endl  ;
	}
      } 
    }
  }

  

  // Stop here if not projection is required or needed
  if ((!_projectCoefs) || cache._projList.getSize()==0) {
    //     cout << "SYNC no projection required rangeName = " << (rangeName?rangeName:"<none>") << endl ;
    return ;
  }

  // Adjust coefficients for given projection
  Double_t coefSum(0) ;
  for (i=0 ; i<_pdfList.getSize() ; i++) {
    RooAbsPdf::globalSelectComp(kTRUE) ;    

    RooAbsReal* pp = ((RooAbsReal*)cache._projList.at(i)) ; 
    RooAbsReal* sn = ((RooAbsReal*)cache._suppProjList.at(i)) ; 
    RooAbsReal* r1 = ((RooAbsReal*)cache._refRangeProjList.at(i)) ;
    RooAbsReal* r2 = ((RooAbsReal*)cache._rangeProjList.at(i)) ;
    
    if (dologD(Eval)) {
      cxcoutD(Eval) << "pp = " << pp->GetName() << endl 
		    << "sn = " << sn->GetName() << endl 
		    << "r1 = " << r1->GetName() << endl 
		    << "r2 = " << r2->GetName() << endl ;
      r1->printStream(ccoutD(Eval),kName|kArgs|kValue,kSingleLine) ;
      r1->printCompactTree(ccoutD(Eval)) ;
    }

    Double_t proj = pp->getVal()/sn->getVal()*(r2->getVal()/r1->getVal()) ;  
    
    RooAbsPdf::globalSelectComp(kFALSE) ;

    _coefCache[i] *= proj ;
    coefSum += _coefCache[i] ;
  }
  for (i=0 ; i<_pdfList.getSize() ; i++) {
    _coefCache[i] /= coefSum ;
//     cout << "POST-SYNC coef[" << i << "] = " << _coefCache[i] << endl ;
  }
   

  
}



//_____________________________________________________________________________
Double_t RooAddModel::evaluate() const 
{
  // Calculate the current value
  const RooArgSet* nset = _normSet ; 
  CacheElem* cache = getProjCache(nset) ;

  updateCoefficients(*cache,nset) ;

  
  // Do running sum of coef/pdf pairs, calculate lastCoef.
  _pdfIter->Reset() ;
  _coefIter->Reset() ;
  RooAbsPdf* pdf ;

  Double_t snormVal ;
  Double_t value(0) ;
  Int_t i(0) ;
  while((pdf = (RooAbsPdf*)_pdfIter->Next())) {
    if (_coefCache[i]!=0.) {
      snormVal = nset ? ((RooAbsReal*)cache->_suppNormList.at(i))->getVal() : 1.0 ;
      Double_t pdfVal = pdf->getVal(nset) ;
      // Double_t pdfNorm = pdf->getNorm(nset) ;
      if (pdf->isSelectedComp()) {
	value += pdfVal*_coefCache[i]/snormVal ;
 	cxcoutD(Eval) << "RooAddModel::evaluate(" << GetName() << ")  value += [" 
 			<< pdf->GetName() << "] " << pdfVal << " * " << _coefCache[i] << " / " << snormVal << endl ;
      }
    }
    i++ ;
  }

  return value ;
}



//_____________________________________________________________________________
void RooAddModel::resetErrorCounters(Int_t resetValue)
{
  // Reset error counter to given value, limiting the number
  // of future error messages for this pdf to 'resetValue'
  RooAbsPdf::resetErrorCounters(resetValue) ;
  _coefErrCount = resetValue ;
}



//_____________________________________________________________________________
Bool_t RooAddModel::checkObservables(const RooArgSet* nset) const 
{
  // Check if PDF is valid for given normalization set.
  // Coeffient and PDF must be non-overlapping, but pdf-coefficient 
  // pairs may overlap each other

  Bool_t ret(kFALSE) ;

  _pdfIter->Reset() ;
  _coefIter->Reset() ;
  RooAbsReal* coef ;
  RooAbsReal* pdf ;
  while((coef=(RooAbsReal*)_coefIter->Next())) {
    pdf = (RooAbsReal*)_pdfIter->Next() ;
    if (pdf->observableOverlaps(nset,*coef)) {
      coutE(InputArguments) << "RooAddModel::checkObservables(" << GetName() << "): ERROR: coefficient " << coef->GetName() 
			    << " and PDF " << pdf->GetName() << " have one or more dependents in common" << endl ;
      ret = kTRUE ;
    }
  }
  
  return ret ;
}



//_____________________________________________________________________________
Int_t RooAddModel::getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& analVars, 
					 const RooArgSet* normSet, const char* rangeName) const 
{

  if (_forceNumInt) return 0 ;

  // Declare that we can analytically integrate all requested observables
  analVars.add(allVars) ;

  // Retrieve (or create) the required component integral list
  Int_t code ;
  RooArgList *cilist ;
  getCompIntList(normSet,&allVars,cilist,code,rangeName) ;
  
  return code+1 ;
  
}



//_____________________________________________________________________________
void RooAddModel::getCompIntList(const RooArgSet* nset, const RooArgSet* iset, pRooArgList& compIntList, Int_t& code, const char* isetRangeName) const 
{
  // Check if this configuration was created before
  Int_t sterileIdx(-1) ;

  IntCacheElem* cache = (IntCacheElem*) _intCacheMgr.getObj(nset,iset,&sterileIdx,RooNameReg::ptr(isetRangeName)) ;
  if (cache) {
    code = _intCacheMgr.lastIndex() ;
    compIntList = &cache->_intList ;
    
    return ;
  }

  // Create containers for partial integral components to be generated
  cache = new IntCacheElem ;

  // Fill Cache
  _pdfIter->Reset() ;
  RooResolutionModel* model ;
  while ((model=(RooResolutionModel*)_pdfIter->Next())) {
    RooAbsReal* intPdf = model->createIntegral(*iset,nset,0,isetRangeName) ;
    cache->_intList.addOwned(*intPdf) ;
  }

  // Store the partial integral list and return the assigned code ;
  code = _intCacheMgr.setObj(nset,iset,(RooAbsCacheElement*)cache,RooNameReg::ptr(isetRangeName)) ;

  // Fill references to be returned
  compIntList = &cache->_intList ;
}



//_____________________________________________________________________________
Double_t RooAddModel::analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName) const 
{
  // Return analytical integral defined by given scenario code

  // No integration scenario
  if (code==0) {
    return getVal(normSet) ;
  }

  // Partial integration scenarios
  IntCacheElem* cache = (IntCacheElem*) _intCacheMgr.getObjByIndex(code-1) ;
  
  RooArgList* compIntList ;

  // If cache has been sterilized, revive this slot
  if (cache==0) {
    RooArgSet* vars = getParameters(RooArgSet()) ;
    RooArgSet* nset = _intCacheMgr.nameSet1ByIndex(code-1)->select(*vars) ;
    RooArgSet* iset = _intCacheMgr.nameSet2ByIndex(code-1)->select(*vars) ;

    Int_t code2(-1) ;
    getCompIntList(nset,iset,compIntList,code2,rangeName) ;

    delete vars ;
    delete nset ;
    delete iset ;
  } else {

    compIntList = &cache->_intList ;

  }

  // Calculate the current value
  const RooArgSet* nset = _normSet ; 
  CacheElem* pcache = getProjCache(nset) ;

  updateCoefficients(*pcache,nset) ;
  
  // Do running sum of coef/pdf pairs, calculate lastCoef.
  TIterator* compIntIter = compIntList->createIterator() ;
  _coefIter->Reset() ;
  RooAbsReal* pdfInt ;

  Double_t snormVal ;
  Double_t value(0) ;
  Int_t i(0) ;
  while((pdfInt = (RooAbsReal*)compIntIter->Next())) {
    if (_coefCache[i]!=0.) {
      snormVal = nset ? ((RooAbsReal*)pcache->_suppNormList.at(i))->getVal() : 1.0 ;
      Double_t intVal = pdfInt->getVal(nset) ;
      value += intVal*_coefCache[i]/snormVal ;
      cxcoutD(Eval) << "RooAddModel::evaluate(" << GetName() << ")  value += [" 
		      << pdfInt->GetName() << "] " << intVal << " * " << _coefCache[i] << " / " << snormVal << endl ;
    }
    i++ ;
  }

  delete compIntIter ;
  
  return value ;
  
}



//_____________________________________________________________________________
Double_t RooAddModel::expectedEvents(const RooArgSet* nset) const 
{  
  // Return the number of expected events, which is either the sum of all coefficients
  // or the sum of the components extended terms

  Double_t expectedTotal(0.0);
  RooAbsPdf* pdf ;
    
  if (_allExtendable) {
    
    // Sum of the extended terms
    _pdfIter->Reset() ;
    while((pdf = (RooAbsPdf*)_pdfIter->Next())) {      
      expectedTotal += pdf->expectedEvents(nset) ;
    }   
    
  } else {
    
    // Sum the coefficients
    _coefIter->Reset() ;
    RooAbsReal* coef ;
    while((coef=(RooAbsReal*)_coefIter->Next())) {
      expectedTotal += coef->getVal() ;
    }   
  }

  return expectedTotal;
}



//_____________________________________________________________________________
void RooAddModel::selectNormalization(const RooArgSet* depSet, Bool_t force) 
{
  // Interface function used by test statistics to freeze choice of observables
  // for interpretation of fraction coefficients

  if (!force && _refCoefNorm.getSize()!=0) {
    return ;
  }

  if (!depSet) {
    fixCoefNormalization(RooArgSet()) ;
    return ;
  }

  RooArgSet* myDepSet = getObservables(depSet) ;
  fixCoefNormalization(*myDepSet) ;
  delete myDepSet ;
}



//_____________________________________________________________________________
void RooAddModel::selectNormalizationRange(const char* rangeName, Bool_t force) 
{
  // Interface function used by test statistics to freeze choice of range
  // for interpretation of fraction coefficients

  if (!force && _refCoefRangeName) {
    return ;
  }

  fixCoefRange(rangeName) ;
}



//_____________________________________________________________________________
RooAbsGenContext* RooAddModel::genContext(const RooArgSet &vars, const RooDataSet *prototype, 
					const RooArgSet* auxProto, Bool_t verbose) const 
{
  // Return specialized context to efficiently generate toy events from RooAddPdfs

  return new RooAddGenContext(*this,vars,prototype,auxProto,verbose) ;
}



//_____________________________________________________________________________
Bool_t RooAddModel::isDirectGenSafe(const RooAbsArg& arg) const 
{
  // Direct generation is safe if all components say so
  _pdfIter->Reset() ;
  RooAbsPdf* pdf ;
  while((pdf=(RooAbsPdf*)_pdfIter->Next())) {
    if (!pdf->isDirectGenSafe(arg)) {
      return kFALSE ;
    }
  }
  return kTRUE ;
}



//_____________________________________________________________________________
Int_t RooAddModel::getGenerator(const RooArgSet& directVars, RooArgSet &/*generateVars*/, Bool_t /*staticInitOK*/) const
{
  // Return pseud-code that indicates if all components can do internal generation (1) or not (0)

  _pdfIter->Reset() ;
  RooAbsPdf* pdf ;
  while((pdf=(RooAbsPdf*)_pdfIter->Next())) {
    RooArgSet tmp ;
    if (pdf->getGenerator(directVars,tmp)==0) {
      return 0 ;
    }
  }
  return 1 ;  
}




//_____________________________________________________________________________
void RooAddModel::generateEvent(Int_t /*code*/)
{
  // This function should never be called as RooAddModel implements a custom generator context
  assert(0) ;
}




//_____________________________________________________________________________
RooArgList RooAddModel::CacheElem::containedArgs(Action) 
{
  // List all RooAbsArg derived contents in this cache element

  RooArgList allNodes;
  allNodes.add(_projList) ;
  allNodes.add(_suppProjList) ;
  allNodes.add(_refRangeProjList) ;
  allNodes.add(_rangeProjList) ;

  return allNodes ;
}



//_____________________________________________________________________________
RooArgList RooAddModel::IntCacheElem::containedArgs(Action) 
{
  // List all RooAbsArg derived contents in this cache element

  RooArgList allNodes(_intList) ;
  return allNodes ;
}


//_____________________________________________________________________________
void RooAddModel::printMetaArgs(ostream& os) const 
{
  // Customized printing of arguments of a RooAddModel to more intuitively reflect the contents of the
  // product operator construction

  _pdfIter->Reset() ;
  _coefIter->Reset() ;

  Bool_t first(kTRUE) ;
    
  os << "(" ;
  RooAbsArg* coef, *pdf ;
  while((coef=(RooAbsArg*)_coefIter->Next())) {
    if (!first) {
      os << " + " ;
    } else {
      first = kFALSE ;
    }
    pdf=(RooAbsArg*)_pdfIter->Next() ;
    os << coef->GetName() << " * " << pdf->GetName() ;
  }
  pdf = (RooAbsArg*) _pdfIter->Next() ;
  if (pdf) {
    os << " + [%] * " << pdf->GetName() ;
  }
  os << ") " ;    
}

 RooAddModel.cxx:1
 RooAddModel.cxx:2
 RooAddModel.cxx:3
 RooAddModel.cxx:4
 RooAddModel.cxx:5
 RooAddModel.cxx:6
 RooAddModel.cxx:7
 RooAddModel.cxx:8
 RooAddModel.cxx:9
 RooAddModel.cxx:10
 RooAddModel.cxx:11
 RooAddModel.cxx:12
 RooAddModel.cxx:13
 RooAddModel.cxx:14
 RooAddModel.cxx:15
 RooAddModel.cxx:16
 RooAddModel.cxx:17
 RooAddModel.cxx:18
 RooAddModel.cxx:19
 RooAddModel.cxx:20
 RooAddModel.cxx:21
 RooAddModel.cxx:22
 RooAddModel.cxx:23
 RooAddModel.cxx:24
 RooAddModel.cxx:25
 RooAddModel.cxx:26
 RooAddModel.cxx:27
 RooAddModel.cxx:28
 RooAddModel.cxx:29
 RooAddModel.cxx:30
 RooAddModel.cxx:31
 RooAddModel.cxx:32
 RooAddModel.cxx:33
 RooAddModel.cxx:34
 RooAddModel.cxx:35
 RooAddModel.cxx:36
 RooAddModel.cxx:37
 RooAddModel.cxx:38
 RooAddModel.cxx:39
 RooAddModel.cxx:40
 RooAddModel.cxx:41
 RooAddModel.cxx:42
 RooAddModel.cxx:43
 RooAddModel.cxx:44
 RooAddModel.cxx:45
 RooAddModel.cxx:46
 RooAddModel.cxx:47
 RooAddModel.cxx:48
 RooAddModel.cxx:49
 RooAddModel.cxx:50
 RooAddModel.cxx:51
 RooAddModel.cxx:52
 RooAddModel.cxx:53
 RooAddModel.cxx:54
 RooAddModel.cxx:55
 RooAddModel.cxx:56
 RooAddModel.cxx:57
 RooAddModel.cxx:58
 RooAddModel.cxx:59
 RooAddModel.cxx:60
 RooAddModel.cxx:61
 RooAddModel.cxx:62
 RooAddModel.cxx:63
 RooAddModel.cxx:64
 RooAddModel.cxx:65
 RooAddModel.cxx:66
 RooAddModel.cxx:67
 RooAddModel.cxx:68
 RooAddModel.cxx:69
 RooAddModel.cxx:70
 RooAddModel.cxx:71
 RooAddModel.cxx:72
 RooAddModel.cxx:73
 RooAddModel.cxx:74
 RooAddModel.cxx:75
 RooAddModel.cxx:76
 RooAddModel.cxx:77
 RooAddModel.cxx:78
 RooAddModel.cxx:79
 RooAddModel.cxx:80
 RooAddModel.cxx:81
 RooAddModel.cxx:82
 RooAddModel.cxx:83
 RooAddModel.cxx:84
 RooAddModel.cxx:85
 RooAddModel.cxx:86
 RooAddModel.cxx:87
 RooAddModel.cxx:88
 RooAddModel.cxx:89
 RooAddModel.cxx:90
 RooAddModel.cxx:91
 RooAddModel.cxx:92
 RooAddModel.cxx:93
 RooAddModel.cxx:94
 RooAddModel.cxx:95
 RooAddModel.cxx:96
 RooAddModel.cxx:97
 RooAddModel.cxx:98
 RooAddModel.cxx:99
 RooAddModel.cxx:100
 RooAddModel.cxx:101
 RooAddModel.cxx:102
 RooAddModel.cxx:103
 RooAddModel.cxx:104
 RooAddModel.cxx:105
 RooAddModel.cxx:106
 RooAddModel.cxx:107
 RooAddModel.cxx:108
 RooAddModel.cxx:109
 RooAddModel.cxx:110
 RooAddModel.cxx:111
 RooAddModel.cxx:112
 RooAddModel.cxx:113
 RooAddModel.cxx:114
 RooAddModel.cxx:115
 RooAddModel.cxx:116
 RooAddModel.cxx:117
 RooAddModel.cxx:118
 RooAddModel.cxx:119
 RooAddModel.cxx:120
 RooAddModel.cxx:121
 RooAddModel.cxx:122
 RooAddModel.cxx:123
 RooAddModel.cxx:124
 RooAddModel.cxx:125
 RooAddModel.cxx:126
 RooAddModel.cxx:127
 RooAddModel.cxx:128
 RooAddModel.cxx:129
 RooAddModel.cxx:130
 RooAddModel.cxx:131
 RooAddModel.cxx:132
 RooAddModel.cxx:133
 RooAddModel.cxx:134
 RooAddModel.cxx:135
 RooAddModel.cxx:136
 RooAddModel.cxx:137
 RooAddModel.cxx:138
 RooAddModel.cxx:139
 RooAddModel.cxx:140
 RooAddModel.cxx:141
 RooAddModel.cxx:142
 RooAddModel.cxx:143
 RooAddModel.cxx:144
 RooAddModel.cxx:145
 RooAddModel.cxx:146
 RooAddModel.cxx:147
 RooAddModel.cxx:148
 RooAddModel.cxx:149
 RooAddModel.cxx:150
 RooAddModel.cxx:151
 RooAddModel.cxx:152
 RooAddModel.cxx:153
 RooAddModel.cxx:154
 RooAddModel.cxx:155
 RooAddModel.cxx:156
 RooAddModel.cxx:157
 RooAddModel.cxx:158
 RooAddModel.cxx:159
 RooAddModel.cxx:160
 RooAddModel.cxx:161
 RooAddModel.cxx:162
 RooAddModel.cxx:163
 RooAddModel.cxx:164
 RooAddModel.cxx:165
 RooAddModel.cxx:166
 RooAddModel.cxx:167
 RooAddModel.cxx:168
 RooAddModel.cxx:169
 RooAddModel.cxx:170
 RooAddModel.cxx:171
 RooAddModel.cxx:172
 RooAddModel.cxx:173
 RooAddModel.cxx:174
 RooAddModel.cxx:175
 RooAddModel.cxx:176
 RooAddModel.cxx:177
 RooAddModel.cxx:178
 RooAddModel.cxx:179
 RooAddModel.cxx:180
 RooAddModel.cxx:181
 RooAddModel.cxx:182
 RooAddModel.cxx:183
 RooAddModel.cxx:184
 RooAddModel.cxx:185
 RooAddModel.cxx:186
 RooAddModel.cxx:187
 RooAddModel.cxx:188
 RooAddModel.cxx:189
 RooAddModel.cxx:190
 RooAddModel.cxx:191
 RooAddModel.cxx:192
 RooAddModel.cxx:193
 RooAddModel.cxx:194
 RooAddModel.cxx:195
 RooAddModel.cxx:196
 RooAddModel.cxx:197
 RooAddModel.cxx:198
 RooAddModel.cxx:199
 RooAddModel.cxx:200
 RooAddModel.cxx:201
 RooAddModel.cxx:202
 RooAddModel.cxx:203
 RooAddModel.cxx:204
 RooAddModel.cxx:205
 RooAddModel.cxx:206
 RooAddModel.cxx:207
 RooAddModel.cxx:208
 RooAddModel.cxx:209
 RooAddModel.cxx:210
 RooAddModel.cxx:211
 RooAddModel.cxx:212
 RooAddModel.cxx:213
 RooAddModel.cxx:214
 RooAddModel.cxx:215
 RooAddModel.cxx:216
 RooAddModel.cxx:217
 RooAddModel.cxx:218
 RooAddModel.cxx:219
 RooAddModel.cxx:220
 RooAddModel.cxx:221
 RooAddModel.cxx:222
 RooAddModel.cxx:223
 RooAddModel.cxx:224
 RooAddModel.cxx:225
 RooAddModel.cxx:226
 RooAddModel.cxx:227
 RooAddModel.cxx:228
 RooAddModel.cxx:229
 RooAddModel.cxx:230
 RooAddModel.cxx:231
 RooAddModel.cxx:232
 RooAddModel.cxx:233
 RooAddModel.cxx:234
 RooAddModel.cxx:235
 RooAddModel.cxx:236
 RooAddModel.cxx:237
 RooAddModel.cxx:238
 RooAddModel.cxx:239
 RooAddModel.cxx:240
 RooAddModel.cxx:241
 RooAddModel.cxx:242
 RooAddModel.cxx:243
 RooAddModel.cxx:244
 RooAddModel.cxx:245
 RooAddModel.cxx:246
 RooAddModel.cxx:247
 RooAddModel.cxx:248
 RooAddModel.cxx:249
 RooAddModel.cxx:250
 RooAddModel.cxx:251
 RooAddModel.cxx:252
 RooAddModel.cxx:253
 RooAddModel.cxx:254
 RooAddModel.cxx:255
 RooAddModel.cxx:256
 RooAddModel.cxx:257
 RooAddModel.cxx:258
 RooAddModel.cxx:259
 RooAddModel.cxx:260
 RooAddModel.cxx:261
 RooAddModel.cxx:262
 RooAddModel.cxx:263
 RooAddModel.cxx:264
 RooAddModel.cxx:265
 RooAddModel.cxx:266
 RooAddModel.cxx:267
 RooAddModel.cxx:268
 RooAddModel.cxx:269
 RooAddModel.cxx:270
 RooAddModel.cxx:271
 RooAddModel.cxx:272
 RooAddModel.cxx:273
 RooAddModel.cxx:274
 RooAddModel.cxx:275
 RooAddModel.cxx:276
 RooAddModel.cxx:277
 RooAddModel.cxx:278
 RooAddModel.cxx:279
 RooAddModel.cxx:280
 RooAddModel.cxx:281
 RooAddModel.cxx:282
 RooAddModel.cxx:283
 RooAddModel.cxx:284
 RooAddModel.cxx:285
 RooAddModel.cxx:286
 RooAddModel.cxx:287
 RooAddModel.cxx:288
 RooAddModel.cxx:289
 RooAddModel.cxx:290
 RooAddModel.cxx:291
 RooAddModel.cxx:292
 RooAddModel.cxx:293
 RooAddModel.cxx:294
 RooAddModel.cxx:295
 RooAddModel.cxx:296
 RooAddModel.cxx:297
 RooAddModel.cxx:298
 RooAddModel.cxx:299
 RooAddModel.cxx:300
 RooAddModel.cxx:301
 RooAddModel.cxx:302
 RooAddModel.cxx:303
 RooAddModel.cxx:304
 RooAddModel.cxx:305
 RooAddModel.cxx:306
 RooAddModel.cxx:307
 RooAddModel.cxx:308
 RooAddModel.cxx:309
 RooAddModel.cxx:310
 RooAddModel.cxx:311
 RooAddModel.cxx:312
 RooAddModel.cxx:313
 RooAddModel.cxx:314
 RooAddModel.cxx:315
 RooAddModel.cxx:316
 RooAddModel.cxx:317
 RooAddModel.cxx:318
 RooAddModel.cxx:319
 RooAddModel.cxx:320
 RooAddModel.cxx:321
 RooAddModel.cxx:322
 RooAddModel.cxx:323
 RooAddModel.cxx:324
 RooAddModel.cxx:325
 RooAddModel.cxx:326
 RooAddModel.cxx:327
 RooAddModel.cxx:328
 RooAddModel.cxx:329
 RooAddModel.cxx:330
 RooAddModel.cxx:331
 RooAddModel.cxx:332
 RooAddModel.cxx:333
 RooAddModel.cxx:334
 RooAddModel.cxx:335
 RooAddModel.cxx:336
 RooAddModel.cxx:337
 RooAddModel.cxx:338
 RooAddModel.cxx:339
 RooAddModel.cxx:340
 RooAddModel.cxx:341
 RooAddModel.cxx:342
 RooAddModel.cxx:343
 RooAddModel.cxx:344
 RooAddModel.cxx:345
 RooAddModel.cxx:346
 RooAddModel.cxx:347
 RooAddModel.cxx:348
 RooAddModel.cxx:349
 RooAddModel.cxx:350
 RooAddModel.cxx:351
 RooAddModel.cxx:352
 RooAddModel.cxx:353
 RooAddModel.cxx:354
 RooAddModel.cxx:355
 RooAddModel.cxx:356
 RooAddModel.cxx:357
 RooAddModel.cxx:358
 RooAddModel.cxx:359
 RooAddModel.cxx:360
 RooAddModel.cxx:361
 RooAddModel.cxx:362
 RooAddModel.cxx:363
 RooAddModel.cxx:364
 RooAddModel.cxx:365
 RooAddModel.cxx:366
 RooAddModel.cxx:367
 RooAddModel.cxx:368
 RooAddModel.cxx:369
 RooAddModel.cxx:370
 RooAddModel.cxx:371
 RooAddModel.cxx:372
 RooAddModel.cxx:373
 RooAddModel.cxx:374
 RooAddModel.cxx:375
 RooAddModel.cxx:376
 RooAddModel.cxx:377
 RooAddModel.cxx:378
 RooAddModel.cxx:379
 RooAddModel.cxx:380
 RooAddModel.cxx:381
 RooAddModel.cxx:382
 RooAddModel.cxx:383
 RooAddModel.cxx:384
 RooAddModel.cxx:385
 RooAddModel.cxx:386
 RooAddModel.cxx:387
 RooAddModel.cxx:388
 RooAddModel.cxx:389
 RooAddModel.cxx:390
 RooAddModel.cxx:391
 RooAddModel.cxx:392
 RooAddModel.cxx:393
 RooAddModel.cxx:394
 RooAddModel.cxx:395
 RooAddModel.cxx:396
 RooAddModel.cxx:397
 RooAddModel.cxx:398
 RooAddModel.cxx:399
 RooAddModel.cxx:400
 RooAddModel.cxx:401
 RooAddModel.cxx:402
 RooAddModel.cxx:403
 RooAddModel.cxx:404
 RooAddModel.cxx:405
 RooAddModel.cxx:406
 RooAddModel.cxx:407
 RooAddModel.cxx:408
 RooAddModel.cxx:409
 RooAddModel.cxx:410
 RooAddModel.cxx:411
 RooAddModel.cxx:412
 RooAddModel.cxx:413
 RooAddModel.cxx:414
 RooAddModel.cxx:415
 RooAddModel.cxx:416
 RooAddModel.cxx:417
 RooAddModel.cxx:418
 RooAddModel.cxx:419
 RooAddModel.cxx:420
 RooAddModel.cxx:421
 RooAddModel.cxx:422
 RooAddModel.cxx:423
 RooAddModel.cxx:424
 RooAddModel.cxx:425
 RooAddModel.cxx:426
 RooAddModel.cxx:427
 RooAddModel.cxx:428
 RooAddModel.cxx:429
 RooAddModel.cxx:430
 RooAddModel.cxx:431
 RooAddModel.cxx:432
 RooAddModel.cxx:433
 RooAddModel.cxx:434
 RooAddModel.cxx:435
 RooAddModel.cxx:436
 RooAddModel.cxx:437
 RooAddModel.cxx:438
 RooAddModel.cxx:439
 RooAddModel.cxx:440
 RooAddModel.cxx:441
 RooAddModel.cxx:442
 RooAddModel.cxx:443
 RooAddModel.cxx:444
 RooAddModel.cxx:445
 RooAddModel.cxx:446
 RooAddModel.cxx:447
 RooAddModel.cxx:448
 RooAddModel.cxx:449
 RooAddModel.cxx:450
 RooAddModel.cxx:451
 RooAddModel.cxx:452
 RooAddModel.cxx:453
 RooAddModel.cxx:454
 RooAddModel.cxx:455
 RooAddModel.cxx:456
 RooAddModel.cxx:457
 RooAddModel.cxx:458
 RooAddModel.cxx:459
 RooAddModel.cxx:460
 RooAddModel.cxx:461
 RooAddModel.cxx:462
 RooAddModel.cxx:463
 RooAddModel.cxx:464
 RooAddModel.cxx:465
 RooAddModel.cxx:466
 RooAddModel.cxx:467
 RooAddModel.cxx:468
 RooAddModel.cxx:469
 RooAddModel.cxx:470
 RooAddModel.cxx:471
 RooAddModel.cxx:472
 RooAddModel.cxx:473
 RooAddModel.cxx:474
 RooAddModel.cxx:475
 RooAddModel.cxx:476
 RooAddModel.cxx:477
 RooAddModel.cxx:478
 RooAddModel.cxx:479
 RooAddModel.cxx:480
 RooAddModel.cxx:481
 RooAddModel.cxx:482
 RooAddModel.cxx:483
 RooAddModel.cxx:484
 RooAddModel.cxx:485
 RooAddModel.cxx:486
 RooAddModel.cxx:487
 RooAddModel.cxx:488
 RooAddModel.cxx:489
 RooAddModel.cxx:490
 RooAddModel.cxx:491
 RooAddModel.cxx:492
 RooAddModel.cxx:493
 RooAddModel.cxx:494
 RooAddModel.cxx:495
 RooAddModel.cxx:496
 RooAddModel.cxx:497
 RooAddModel.cxx:498
 RooAddModel.cxx:499
 RooAddModel.cxx:500
 RooAddModel.cxx:501
 RooAddModel.cxx:502
 RooAddModel.cxx:503
 RooAddModel.cxx:504
 RooAddModel.cxx:505
 RooAddModel.cxx:506
 RooAddModel.cxx:507
 RooAddModel.cxx:508
 RooAddModel.cxx:509
 RooAddModel.cxx:510
 RooAddModel.cxx:511
 RooAddModel.cxx:512
 RooAddModel.cxx:513
 RooAddModel.cxx:514
 RooAddModel.cxx:515
 RooAddModel.cxx:516
 RooAddModel.cxx:517
 RooAddModel.cxx:518
 RooAddModel.cxx:519
 RooAddModel.cxx:520
 RooAddModel.cxx:521
 RooAddModel.cxx:522
 RooAddModel.cxx:523
 RooAddModel.cxx:524
 RooAddModel.cxx:525
 RooAddModel.cxx:526
 RooAddModel.cxx:527
 RooAddModel.cxx:528
 RooAddModel.cxx:529
 RooAddModel.cxx:530
 RooAddModel.cxx:531
 RooAddModel.cxx:532
 RooAddModel.cxx:533
 RooAddModel.cxx:534
 RooAddModel.cxx:535
 RooAddModel.cxx:536
 RooAddModel.cxx:537
 RooAddModel.cxx:538
 RooAddModel.cxx:539
 RooAddModel.cxx:540
 RooAddModel.cxx:541
 RooAddModel.cxx:542
 RooAddModel.cxx:543
 RooAddModel.cxx:544
 RooAddModel.cxx:545
 RooAddModel.cxx:546
 RooAddModel.cxx:547
 RooAddModel.cxx:548
 RooAddModel.cxx:549
 RooAddModel.cxx:550
 RooAddModel.cxx:551
 RooAddModel.cxx:552
 RooAddModel.cxx:553
 RooAddModel.cxx:554
 RooAddModel.cxx:555
 RooAddModel.cxx:556
 RooAddModel.cxx:557
 RooAddModel.cxx:558
 RooAddModel.cxx:559
 RooAddModel.cxx:560
 RooAddModel.cxx:561
 RooAddModel.cxx:562
 RooAddModel.cxx:563
 RooAddModel.cxx:564
 RooAddModel.cxx:565
 RooAddModel.cxx:566
 RooAddModel.cxx:567
 RooAddModel.cxx:568
 RooAddModel.cxx:569
 RooAddModel.cxx:570
 RooAddModel.cxx:571
 RooAddModel.cxx:572
 RooAddModel.cxx:573
 RooAddModel.cxx:574
 RooAddModel.cxx:575
 RooAddModel.cxx:576
 RooAddModel.cxx:577
 RooAddModel.cxx:578
 RooAddModel.cxx:579
 RooAddModel.cxx:580
 RooAddModel.cxx:581
 RooAddModel.cxx:582
 RooAddModel.cxx:583
 RooAddModel.cxx:584
 RooAddModel.cxx:585
 RooAddModel.cxx:586
 RooAddModel.cxx:587
 RooAddModel.cxx:588
 RooAddModel.cxx:589
 RooAddModel.cxx:590
 RooAddModel.cxx:591
 RooAddModel.cxx:592
 RooAddModel.cxx:593
 RooAddModel.cxx:594
 RooAddModel.cxx:595
 RooAddModel.cxx:596
 RooAddModel.cxx:597
 RooAddModel.cxx:598
 RooAddModel.cxx:599
 RooAddModel.cxx:600
 RooAddModel.cxx:601
 RooAddModel.cxx:602
 RooAddModel.cxx:603
 RooAddModel.cxx:604
 RooAddModel.cxx:605
 RooAddModel.cxx:606
 RooAddModel.cxx:607
 RooAddModel.cxx:608
 RooAddModel.cxx:609
 RooAddModel.cxx:610
 RooAddModel.cxx:611
 RooAddModel.cxx:612
 RooAddModel.cxx:613
 RooAddModel.cxx:614
 RooAddModel.cxx:615
 RooAddModel.cxx:616
 RooAddModel.cxx:617
 RooAddModel.cxx:618
 RooAddModel.cxx:619
 RooAddModel.cxx:620
 RooAddModel.cxx:621
 RooAddModel.cxx:622
 RooAddModel.cxx:623
 RooAddModel.cxx:624
 RooAddModel.cxx:625
 RooAddModel.cxx:626
 RooAddModel.cxx:627
 RooAddModel.cxx:628
 RooAddModel.cxx:629
 RooAddModel.cxx:630
 RooAddModel.cxx:631
 RooAddModel.cxx:632
 RooAddModel.cxx:633
 RooAddModel.cxx:634
 RooAddModel.cxx:635
 RooAddModel.cxx:636
 RooAddModel.cxx:637
 RooAddModel.cxx:638
 RooAddModel.cxx:639
 RooAddModel.cxx:640
 RooAddModel.cxx:641
 RooAddModel.cxx:642
 RooAddModel.cxx:643
 RooAddModel.cxx:644
 RooAddModel.cxx:645
 RooAddModel.cxx:646
 RooAddModel.cxx:647
 RooAddModel.cxx:648
 RooAddModel.cxx:649
 RooAddModel.cxx:650
 RooAddModel.cxx:651
 RooAddModel.cxx:652
 RooAddModel.cxx:653
 RooAddModel.cxx:654
 RooAddModel.cxx:655
 RooAddModel.cxx:656
 RooAddModel.cxx:657
 RooAddModel.cxx:658
 RooAddModel.cxx:659
 RooAddModel.cxx:660
 RooAddModel.cxx:661
 RooAddModel.cxx:662
 RooAddModel.cxx:663
 RooAddModel.cxx:664
 RooAddModel.cxx:665
 RooAddModel.cxx:666
 RooAddModel.cxx:667
 RooAddModel.cxx:668
 RooAddModel.cxx:669
 RooAddModel.cxx:670
 RooAddModel.cxx:671
 RooAddModel.cxx:672
 RooAddModel.cxx:673
 RooAddModel.cxx:674
 RooAddModel.cxx:675
 RooAddModel.cxx:676
 RooAddModel.cxx:677
 RooAddModel.cxx:678
 RooAddModel.cxx:679
 RooAddModel.cxx:680
 RooAddModel.cxx:681
 RooAddModel.cxx:682
 RooAddModel.cxx:683
 RooAddModel.cxx:684
 RooAddModel.cxx:685
 RooAddModel.cxx:686
 RooAddModel.cxx:687
 RooAddModel.cxx:688
 RooAddModel.cxx:689
 RooAddModel.cxx:690
 RooAddModel.cxx:691
 RooAddModel.cxx:692
 RooAddModel.cxx:693
 RooAddModel.cxx:694
 RooAddModel.cxx:695
 RooAddModel.cxx:696
 RooAddModel.cxx:697
 RooAddModel.cxx:698
 RooAddModel.cxx:699
 RooAddModel.cxx:700
 RooAddModel.cxx:701
 RooAddModel.cxx:702
 RooAddModel.cxx:703
 RooAddModel.cxx:704
 RooAddModel.cxx:705
 RooAddModel.cxx:706
 RooAddModel.cxx:707
 RooAddModel.cxx:708
 RooAddModel.cxx:709
 RooAddModel.cxx:710
 RooAddModel.cxx:711
 RooAddModel.cxx:712
 RooAddModel.cxx:713
 RooAddModel.cxx:714
 RooAddModel.cxx:715
 RooAddModel.cxx:716
 RooAddModel.cxx:717
 RooAddModel.cxx:718
 RooAddModel.cxx:719
 RooAddModel.cxx:720
 RooAddModel.cxx:721
 RooAddModel.cxx:722
 RooAddModel.cxx:723
 RooAddModel.cxx:724
 RooAddModel.cxx:725
 RooAddModel.cxx:726
 RooAddModel.cxx:727
 RooAddModel.cxx:728
 RooAddModel.cxx:729
 RooAddModel.cxx:730
 RooAddModel.cxx:731
 RooAddModel.cxx:732
 RooAddModel.cxx:733
 RooAddModel.cxx:734
 RooAddModel.cxx:735
 RooAddModel.cxx:736
 RooAddModel.cxx:737
 RooAddModel.cxx:738
 RooAddModel.cxx:739
 RooAddModel.cxx:740
 RooAddModel.cxx:741
 RooAddModel.cxx:742
 RooAddModel.cxx:743
 RooAddModel.cxx:744
 RooAddModel.cxx:745
 RooAddModel.cxx:746
 RooAddModel.cxx:747
 RooAddModel.cxx:748
 RooAddModel.cxx:749
 RooAddModel.cxx:750
 RooAddModel.cxx:751
 RooAddModel.cxx:752
 RooAddModel.cxx:753
 RooAddModel.cxx:754
 RooAddModel.cxx:755
 RooAddModel.cxx:756
 RooAddModel.cxx:757
 RooAddModel.cxx:758
 RooAddModel.cxx:759
 RooAddModel.cxx:760
 RooAddModel.cxx:761
 RooAddModel.cxx:762
 RooAddModel.cxx:763
 RooAddModel.cxx:764
 RooAddModel.cxx:765
 RooAddModel.cxx:766
 RooAddModel.cxx:767
 RooAddModel.cxx:768
 RooAddModel.cxx:769
 RooAddModel.cxx:770
 RooAddModel.cxx:771
 RooAddModel.cxx:772
 RooAddModel.cxx:773
 RooAddModel.cxx:774
 RooAddModel.cxx:775
 RooAddModel.cxx:776
 RooAddModel.cxx:777
 RooAddModel.cxx:778
 RooAddModel.cxx:779
 RooAddModel.cxx:780
 RooAddModel.cxx:781
 RooAddModel.cxx:782
 RooAddModel.cxx:783
 RooAddModel.cxx:784
 RooAddModel.cxx:785
 RooAddModel.cxx:786
 RooAddModel.cxx:787
 RooAddModel.cxx:788
 RooAddModel.cxx:789
 RooAddModel.cxx:790
 RooAddModel.cxx:791
 RooAddModel.cxx:792
 RooAddModel.cxx:793
 RooAddModel.cxx:794
 RooAddModel.cxx:795
 RooAddModel.cxx:796
 RooAddModel.cxx:797
 RooAddModel.cxx:798
 RooAddModel.cxx:799
 RooAddModel.cxx:800
 RooAddModel.cxx:801
 RooAddModel.cxx:802
 RooAddModel.cxx:803
 RooAddModel.cxx:804
 RooAddModel.cxx:805
 RooAddModel.cxx:806
 RooAddModel.cxx:807
 RooAddModel.cxx:808
 RooAddModel.cxx:809
 RooAddModel.cxx:810
 RooAddModel.cxx:811
 RooAddModel.cxx:812
 RooAddModel.cxx:813
 RooAddModel.cxx:814
 RooAddModel.cxx:815
 RooAddModel.cxx:816
 RooAddModel.cxx:817
 RooAddModel.cxx:818
 RooAddModel.cxx:819
 RooAddModel.cxx:820
 RooAddModel.cxx:821
 RooAddModel.cxx:822
 RooAddModel.cxx:823
 RooAddModel.cxx:824
 RooAddModel.cxx:825
 RooAddModel.cxx:826
 RooAddModel.cxx:827
 RooAddModel.cxx:828
 RooAddModel.cxx:829
 RooAddModel.cxx:830
 RooAddModel.cxx:831
 RooAddModel.cxx:832
 RooAddModel.cxx:833
 RooAddModel.cxx:834
 RooAddModel.cxx:835
 RooAddModel.cxx:836
 RooAddModel.cxx:837
 RooAddModel.cxx:838
 RooAddModel.cxx:839
 RooAddModel.cxx:840
 RooAddModel.cxx:841
 RooAddModel.cxx:842
 RooAddModel.cxx:843
 RooAddModel.cxx:844
 RooAddModel.cxx:845
 RooAddModel.cxx:846
 RooAddModel.cxx:847
 RooAddModel.cxx:848
 RooAddModel.cxx:849
 RooAddModel.cxx:850
 RooAddModel.cxx:851
 RooAddModel.cxx:852
 RooAddModel.cxx:853
 RooAddModel.cxx:854
 RooAddModel.cxx:855
 RooAddModel.cxx:856
 RooAddModel.cxx:857
 RooAddModel.cxx:858
 RooAddModel.cxx:859
 RooAddModel.cxx:860
 RooAddModel.cxx:861
 RooAddModel.cxx:862
 RooAddModel.cxx:863
 RooAddModel.cxx:864
 RooAddModel.cxx:865
 RooAddModel.cxx:866
 RooAddModel.cxx:867
 RooAddModel.cxx:868
 RooAddModel.cxx:869
 RooAddModel.cxx:870
 RooAddModel.cxx:871
 RooAddModel.cxx:872
 RooAddModel.cxx:873
 RooAddModel.cxx:874
 RooAddModel.cxx:875
 RooAddModel.cxx:876
 RooAddModel.cxx:877
 RooAddModel.cxx:878
 RooAddModel.cxx:879
 RooAddModel.cxx:880
 RooAddModel.cxx:881
 RooAddModel.cxx:882
 RooAddModel.cxx:883
 RooAddModel.cxx:884
 RooAddModel.cxx:885
 RooAddModel.cxx:886
 RooAddModel.cxx:887
 RooAddModel.cxx:888
 RooAddModel.cxx:889
 RooAddModel.cxx:890
 RooAddModel.cxx:891
 RooAddModel.cxx:892
 RooAddModel.cxx:893
 RooAddModel.cxx:894
 RooAddModel.cxx:895
 RooAddModel.cxx:896
 RooAddModel.cxx:897
 RooAddModel.cxx:898
 RooAddModel.cxx:899
 RooAddModel.cxx:900
 RooAddModel.cxx:901
 RooAddModel.cxx:902
 RooAddModel.cxx:903
 RooAddModel.cxx:904
 RooAddModel.cxx:905
 RooAddModel.cxx:906
 RooAddModel.cxx:907
 RooAddModel.cxx:908
 RooAddModel.cxx:909
 RooAddModel.cxx:910
 RooAddModel.cxx:911
 RooAddModel.cxx:912
 RooAddModel.cxx:913
 RooAddModel.cxx:914
 RooAddModel.cxx:915
 RooAddModel.cxx:916
 RooAddModel.cxx:917
 RooAddModel.cxx:918
 RooAddModel.cxx:919
 RooAddModel.cxx:920
 RooAddModel.cxx:921
 RooAddModel.cxx:922
 RooAddModel.cxx:923
 RooAddModel.cxx:924
 RooAddModel.cxx:925
 RooAddModel.cxx:926
 RooAddModel.cxx:927
 RooAddModel.cxx:928
 RooAddModel.cxx:929
 RooAddModel.cxx:930
 RooAddModel.cxx:931
 RooAddModel.cxx:932
 RooAddModel.cxx:933
 RooAddModel.cxx:934
 RooAddModel.cxx:935
 RooAddModel.cxx:936
 RooAddModel.cxx:937
 RooAddModel.cxx:938
 RooAddModel.cxx:939
 RooAddModel.cxx:940
 RooAddModel.cxx:941
 RooAddModel.cxx:942
 RooAddModel.cxx:943
 RooAddModel.cxx:944
 RooAddModel.cxx:945
 RooAddModel.cxx:946
 RooAddModel.cxx:947
 RooAddModel.cxx:948
 RooAddModel.cxx:949
 RooAddModel.cxx:950
 RooAddModel.cxx:951
 RooAddModel.cxx:952
 RooAddModel.cxx:953
 RooAddModel.cxx:954
 RooAddModel.cxx:955
 RooAddModel.cxx:956
 RooAddModel.cxx:957
 RooAddModel.cxx:958
 RooAddModel.cxx:959
 RooAddModel.cxx:960
 RooAddModel.cxx:961
 RooAddModel.cxx:962
 RooAddModel.cxx:963
 RooAddModel.cxx:964
 RooAddModel.cxx:965
 RooAddModel.cxx:966
 RooAddModel.cxx:967
 RooAddModel.cxx:968
 RooAddModel.cxx:969
 RooAddModel.cxx:970
 RooAddModel.cxx:971
 RooAddModel.cxx:972
 RooAddModel.cxx:973
 RooAddModel.cxx:974
 RooAddModel.cxx:975
 RooAddModel.cxx:976
 RooAddModel.cxx:977
 RooAddModel.cxx:978
 RooAddModel.cxx:979
 RooAddModel.cxx:980
 RooAddModel.cxx:981
 RooAddModel.cxx:982
 RooAddModel.cxx:983
 RooAddModel.cxx:984
 RooAddModel.cxx:985
 RooAddModel.cxx:986
 RooAddModel.cxx:987