// RooAICRegistry is a utility class for operator p.d.f
// classes that keeps track of analytical integration codes and
// associated normalization and integration sets.
// END_HTML
#include "RooFit.h"
#include "RooAICRegistry.h"
#include "RooMsgService.h"
#include "RooArgSet.h"
#include "RooMsgService.h"
#include "Riostream.h"
using namespace std;
ClassImp(RooAICRegistry)
;
RooAICRegistry::RooAICRegistry(UInt_t size)
: _clArr(0), _asArr1(0), _asArr2(0), _asArr3(0), _asArr4(0)
{
_clArr.reserve(size);
_asArr1.reserve(size);
_asArr2.reserve(size);
_asArr3.reserve(size);
_asArr4.reserve(size);
}
RooAICRegistry::RooAICRegistry(const RooAICRegistry& other)
: _clArr(other._clArr), _asArr1(other._clArr.size(), 0), _asArr2(other._clArr.size(), 0),
_asArr3(other._clArr.size(), 0), _asArr4(other._clArr.size(), 0)
{
UInt_t size = other._clArr.size();
if (size) {
_asArr1.resize(size, 0);
_asArr2.resize(size, 0);
_asArr3.resize(size, 0);
_asArr4.resize(size, 0);
for(UInt_t i = 0; i < size; ++i) {
_asArr1[i] = other._asArr1[i] ? ((RooArgSet*)other._asArr1[i]->snapshot(kFALSE)) : 0;
_asArr2[i] = other._asArr2[i] ? ((RooArgSet*)other._asArr2[i]->snapshot(kFALSE)) : 0;
_asArr3[i] = other._asArr3[i] ? ((RooArgSet*)other._asArr3[i]->snapshot(kFALSE)) : 0;
_asArr4[i] = other._asArr4[i] ? ((RooArgSet*)other._asArr4[i]->snapshot(kFALSE)) : 0;
}
}
}
RooAICRegistry::~RooAICRegistry()
{
for (unsigned int i = 0; i < _clArr.size(); ++i) {
if (_asArr1[i]) delete _asArr1[i];
if (_asArr2[i]) delete _asArr2[i];
if (_asArr3[i]) delete _asArr3[i];
if (_asArr4[i]) delete _asArr4[i];
}
}
Int_t RooAICRegistry::store(const std::vector<Int_t>& codeList, RooArgSet* set1,
RooArgSet* set2, RooArgSet* set3, RooArgSet* set4)
{
for (UInt_t i = 0; i < _clArr.size(); ++i) {
Bool_t match(kTRUE) ;
match &= _clArr[i] == codeList;
if (_asArr1[i] && !set1) match=kFALSE ;
if (!_asArr1[i] && set1) match=kFALSE ;
if (_asArr2[i] && !set2) match=kFALSE ;
if (!_asArr2[i] && set2) match=kFALSE ;
if (_asArr3[i] && !set3) match=kFALSE ;
if (!_asArr3[i] && set3) match=kFALSE ;
if (_asArr4[i] && !set4) match=kFALSE ;
if (!_asArr4[i] && set4) match=kFALSE ;
if (_asArr1[i] && set1 && !set1->equals(*_asArr1[i])) match=kFALSE ;
if (_asArr2[i] && set2 && !set2->equals(*_asArr2[i])) match=kFALSE ;
if (_asArr3[i] && set3 && !set3->equals(*_asArr3[i])) match=kFALSE ;
if (_asArr4[i] && set4 && !set4->equals(*_asArr4[i])) match=kFALSE ;
if (match) {
if (set1) delete set1 ;
if (set2) delete set2 ;
if (set3) delete set3 ;
if (set4) delete set4 ;
return i ;
}
}
_clArr.push_back(codeList);
_asArr1.push_back(set1 ? (RooArgSet*)set1->snapshot(kFALSE) : 0);
_asArr2.push_back(set2 ? (RooArgSet*)set2->snapshot(kFALSE) : 0);
_asArr3.push_back(set3 ? (RooArgSet*)set3->snapshot(kFALSE) : 0);
_asArr4.push_back(set4 ? (RooArgSet*)set4->snapshot(kFALSE) : 0);
if (set1) delete set1 ;
if (set2) delete set2 ;
if (set3) delete set3 ;
if (set4) delete set4 ;
return _clArr.size() - 1;
}
const std::vector<Int_t>& RooAICRegistry::retrieve(Int_t masterCode) const
{
return _clArr[masterCode] ;
}
const std::vector<Int_t>& RooAICRegistry::retrieve(Int_t masterCode, pRooArgSet& set1) const
{
set1 = _asArr1[masterCode] ;
return _clArr[masterCode] ;
}
const std::vector<Int_t>& RooAICRegistry::retrieve
(Int_t masterCode, pRooArgSet& set1, pRooArgSet& set2) const
{
set1 = _asArr1[masterCode] ;
set2 = _asArr2[masterCode] ;
return _clArr[masterCode] ;
}
const std::vector<Int_t>& RooAICRegistry::retrieve
(Int_t masterCode, pRooArgSet& set1, pRooArgSet& set2, pRooArgSet& set3, pRooArgSet& set4) const
{
set1 = _asArr1[masterCode] ;
set2 = _asArr2[masterCode] ;
set3 = _asArr3[masterCode] ;
set4 = _asArr4[masterCode] ;
return _clArr[masterCode] ;
}