00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "RooFit.h"
00027
00028 #include "RooAICRegistry.h"
00029 #include "RooMsgService.h"
00030 #include "RooArgSet.h"
00031 #include "RooMsgService.h"
00032
00033 #include "Riostream.h"
00034
00035
00036 ClassImp(RooAICRegistry)
00037 ;
00038
00039
00040
00041 RooAICRegistry::RooAICRegistry(Int_t regSize) :
00042 _regSize(regSize), _clSize(0), _clArr(0), _asArr1(0), _asArr2(0), _asArr3(0), _asArr4(0)
00043 {
00044
00045 }
00046
00047
00048
00049
00050 RooAICRegistry::RooAICRegistry(const RooAICRegistry& other) :
00051 _regSize(other._regSize), _clSize(0), _clArr(0), _asArr1(0), _asArr2(0), _asArr3(0), _asArr4(0)
00052 {
00053
00054
00055
00056 if (other._clArr) {
00057 _clArr = new pInt_t[other._regSize] ;
00058 _asArr1 = new pRooArgSet[other._regSize] ;
00059 _asArr2 = new pRooArgSet[other._regSize] ;
00060 _asArr3 = new pRooArgSet[other._regSize] ;
00061 _asArr4 = new pRooArgSet[other._regSize] ;
00062 _clSize = new Int_t[other._regSize] ;
00063 Int_t i,j ;
00064 for (i=0 ; i<_regSize ; i++) {
00065 _clArr[i]=0 ;
00066 _clSize[i]=0 ;
00067 _asArr1[i]=0 ;
00068 _asArr2[i]=0 ;
00069 _asArr3[i]=0 ;
00070 _asArr4[i]=0 ;
00071 }
00072 i=0 ;
00073 while(other._clArr[i] && i<_regSize) {
00074 _clSize[i] = other._clSize[i] ;
00075 _asArr1[i] = other._asArr1[i] ? ((RooArgSet*)other._asArr1[i]->snapshot(kFALSE)) : 0 ;
00076 _asArr2[i] = other._asArr2[i] ? ((RooArgSet*)other._asArr2[i]->snapshot(kFALSE)) : 0 ;
00077 _asArr3[i] = other._asArr3[i] ? ((RooArgSet*)other._asArr3[i]->snapshot(kFALSE)) : 0 ;
00078 _asArr4[i] = other._asArr4[i] ? ((RooArgSet*)other._asArr4[i]->snapshot(kFALSE)) : 0 ;
00079 _clArr[i] = new Int_t[_clSize[i]] ;
00080 for (j=0 ; j<_clSize[i] ; j++) {
00081 _clArr[i][j] = other._clArr[i][j] ;
00082 }
00083 i++ ;
00084 }
00085 }
00086 }
00087
00088
00089
00090
00091 RooAICRegistry::~RooAICRegistry()
00092 {
00093
00094
00095
00096 if (_clArr) {
00097 Int_t i(0) ;
00098 while(_clArr[i] && i<_regSize) {
00099 delete[] _clArr[i] ;
00100 if (_asArr1[i]) delete _asArr1[i] ;
00101 if (_asArr2[i]) delete _asArr2[i] ;
00102 if (_asArr3[i]) delete _asArr3[i] ;
00103 if (_asArr4[i]) delete _asArr4[i] ;
00104 i++ ;
00105 }
00106 delete[] _clArr ;
00107 delete[] _clSize ;
00108 delete[] _asArr1 ;
00109 delete[] _asArr2 ;
00110 delete[] _asArr3 ;
00111 delete[] _asArr4 ;
00112 }
00113 }
00114
00115
00116
00117
00118 Int_t RooAICRegistry::store(Int_t* codeList, Int_t size, RooArgSet* set1, RooArgSet* set2, RooArgSet* set3, RooArgSet* set4)
00119 {
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 Int_t i,j ;
00131
00132
00133 if (!_clArr) {
00134 _clArr = new pInt_t[_regSize] ;
00135 _clSize = new Int_t[_regSize] ;
00136 _asArr1 = new pRooArgSet[_regSize] ;
00137 _asArr2 = new pRooArgSet[_regSize] ;
00138 _asArr3 = new pRooArgSet[_regSize] ;
00139 _asArr4 = new pRooArgSet[_regSize] ;
00140 for (i=0 ; i<_regSize ; i++) {
00141 _clArr[i] = 0 ;
00142 _clSize[i] = 0 ;
00143 _asArr1[i] = 0 ;
00144 _asArr2[i] = 0 ;
00145 _asArr3[i] = 0 ;
00146 _asArr4[i] = 0 ;
00147 }
00148 }
00149
00150
00151 for (i=0 ; i<_regSize ; i++) {
00152 if (_clArr[i]==0) {
00153
00154 _clArr[i] = new Int_t[size] ;
00155 _clSize[i] = size ;
00156 _asArr1[i] = set1 ? (RooArgSet*)set1->snapshot(kFALSE) : 0;
00157 _asArr2[i] = set2 ? (RooArgSet*)set2->snapshot(kFALSE) : 0;
00158 _asArr3[i] = set3 ? (RooArgSet*)set3->snapshot(kFALSE) : 0;
00159 _asArr4[i] = set4 ? (RooArgSet*)set4->snapshot(kFALSE) : 0;
00160 for (j=0 ; j<size ; j++) _clArr[i][j] = codeList[j] ;
00161
00162 if (set1) delete set1 ;
00163 if (set2) delete set2 ;
00164 if (set3) delete set3 ;
00165 if (set4) delete set4 ;
00166
00167 return i ;
00168 } else {
00169
00170
00171 Bool_t match(kTRUE) ;
00172
00173
00174 for (j=0 ; j<size ; j++) {
00175 if (_clArr[i][j] != codeList[j]) match=kFALSE ;
00176 }
00177
00178 if (_asArr1[i] && !set1) match=kFALSE ;
00179 if (!_asArr1[i] && set1) match=kFALSE ;
00180 if (_asArr2[i] && !set2) match=kFALSE ;
00181 if (!_asArr2[i] && set2) match=kFALSE ;
00182 if (_asArr3[i] && !set3) match=kFALSE ;
00183 if (!_asArr3[i] && set3) match=kFALSE ;
00184 if (_asArr4[i] && !set4) match=kFALSE ;
00185 if (!_asArr4[i] && set4) match=kFALSE ;
00186
00187
00188 if (_asArr1[i] && set1 && !set1->equals(*_asArr1[i])) match=kFALSE ;
00189 if (_asArr2[i] && set2 && !set2->equals(*_asArr2[i])) match=kFALSE ;
00190 if (_asArr3[i] && set3 && !set3->equals(*_asArr3[i])) match=kFALSE ;
00191 if (_asArr4[i] && set4 && !set4->equals(*_asArr4[i])) match=kFALSE ;
00192
00193 if (match) {
00194 if (set1) delete set1 ;
00195 if (set2) delete set2 ;
00196 if (set3) delete set3 ;
00197 if (set4) delete set4 ;
00198 return i ;
00199 }
00200 }
00201 }
00202
00203 oocoutF((TObject*)0,Caching) << "RooAICRegistry::store: ERROR: capacity exceeded" << endl ;
00204 assert(0) ;
00205 return 0 ;
00206 }
00207
00208
00209
00210
00211 const Int_t* RooAICRegistry::retrieve(Int_t masterCode) const
00212 {
00213
00214 return _clArr[masterCode] ;
00215 }
00216
00217
00218
00219
00220 const Int_t* RooAICRegistry::retrieve(Int_t masterCode, pRooArgSet& set1) const
00221 {
00222
00223
00224
00225 set1 = _asArr1[masterCode] ;
00226 return _clArr[masterCode] ;
00227 }
00228
00229
00230
00231
00232 const Int_t* RooAICRegistry::retrieve(Int_t masterCode, pRooArgSet& set1, pRooArgSet& set2) const
00233 {
00234
00235
00236
00237
00238 set1 = _asArr1[masterCode] ;
00239 set2 = _asArr2[masterCode] ;
00240 return _clArr[masterCode] ;
00241 }
00242
00243
00244
00245
00246 const Int_t* RooAICRegistry::retrieve(Int_t masterCode, pRooArgSet& set1, pRooArgSet& set2, pRooArgSet& set3, pRooArgSet& set4) const
00247 {
00248
00249
00250
00251
00252 set1 = _asArr1[masterCode] ;
00253 set2 = _asArr2[masterCode] ;
00254 set3 = _asArr3[masterCode] ;
00255 set4 = _asArr4[masterCode] ;
00256 return _clArr[masterCode] ;
00257 }