5 #include "RooAbsReal.h"
8 using namespace RooFit;
17 rangeYmin(1), rangeYmax(-1),
20 theYVar(
"theYVar",
"theYVar", this)
28 rangeYmin(1), rangeYmax(-1),
31 theYVar(
"theYVar",
"theYVar", this)
39 const std::vector<T>& inXList,
40 const std::vector<T>& inYList,
41 const std::vector<std::vector<T>>& inFcnList,
50 MELANCSplineCore(name, title, inXVar, inXList, inUseFloor, inFloorEval, inFloorInt),
51 rangeYmin(1), rangeYmax(-1),
52 bcBeginX(bcBeginX_), bcEndX(bcEndX_),
53 bcBeginY(bcBeginY_), bcEndY(bcEndY_),
54 theYVar(
"theYVar",
"theYVar", this, inYVar),
66 for (
int i=0; i<npoints; i++){
for (
int j=0; j<npoints; j++){ xAtrans[i][j]=xA.at(i).at(j); } }
70 coutE(InputArguments) <<
"MELANCSpline_2D_fast::interpolateFcn: Matrix xA could not be inverted. Something is wrong with the x coordinates of points!" << endl;
77 for (
int i=0; i<npoints; i++){
for (
int j=0; j<npoints; j++){ yAtrans[i][j]=yA.at(i).at(j); } }
81 coutE(InputArguments) <<
"MELANCSpline_2D_fast::interpolateFcn: Matrix yA could not be inverted. Something is wrong with the y coordinates of points!" << endl;
86 vector<vector<vector<MELANCSplineCore::T>>> coefsAlongY;
89 for (
unsigned int j=0; j<
npointsY(); j++){
92 nxbins=xcoefsAtYj.size();
93 npoldim=xcoefsAtYj.at(0).size();
94 for (
int ipow=0; ipow<npoldim; ipow++){
95 vector<vector<MELANCSplineCore::T>> dum_xycoefarray;
96 for (
int ix=0; ix<nxbins; ix++){
97 vector<MELANCSplineCore::T> dum_ycoefarray;
98 dum_xycoefarray.push_back(dum_ycoefarray);
100 coefsAlongY.push_back(dum_xycoefarray);
103 if (nxbins!=(
int)xcoefsAtYj.size() || npoldim!=(
int)xcoefsAtYj.at(0).size()){
104 coutE(InputArguments) <<
"MELANCSpline_2D_fast::interpolateFcn: nxbins!=(int)xcoefsAtYj.size() || npoldim!=(int)xcoefsAtYj.at(0).size()!" << endl;
107 for (
int ix=0; ix<nxbins; ix++){
108 for (
int ipow=0; ipow<npoldim; ipow++) coefsAlongY.at(ipow).at(ix).push_back(xcoefsAtYj.at(ix).at(ipow));
112 for (
int ix=0; ix<nxbins; ix++){
114 vector<vector<vector<MELANCSplineCore::T>>> xCoefs;
115 for (
int ic=0; ic<npoldim; ic++){
117 xCoefs.push_back(yCoefs);
137 rangeYmin(other.rangeYmin), rangeYmax(other.rangeYmax),
138 bcBeginX(other.bcBeginX), bcEndX(other.bcEndX),
139 bcBeginY(other.bcBeginY), bcEndY(other.bcEndY),
140 theYVar(
"theYVar", this, other.theYVar),
142 FcnList(other.FcnList),
143 kappaX(other.kappaX),
144 kappaY(other.kappaY),
145 coefficients(other.coefficients)
155 Int_t xbin=-1, xbinmin=-1, xbinmax=-1, ybin=-1, ybinmin=-1, ybinmax=-1;
157 if (code==0 || code%2!=0){
170 if (code==0 || code%3!=0){
186 (xbin>=0 && ix!=xbin)
188 (xbinmin>=0 && xbinmax>=xbinmin && !(xbinmin<=ix && ix<=xbinmax))
192 if (code>0 && code%2==0){
193 if (ix==xbinmin) txlow=txmin;
194 if (ix==xbinmax) txhigh=txmax;
199 if (code==0 || code%2!=0)
cout <<
"Evaluating tx=" << txhigh <<
" in bin " << ix << endl;
200 else cout <<
"Evaluating tx[" << txlow <<
", " << txhigh <<
"] in bin " << ix << endl;
204 vector<MELANCSplineCore::T> xCoefs;
205 for (
int ic=0; ic<(int)
coefficients.at(ix).size(); ic++){
206 const vector<vector<MELANCSplineCore::T>>& yCoefs =
coefficients.at(ix).at(ic);
211 for (
int iy=0; iy<(int)yCoefs.size(); iy++){
213 (ybin>=0 && iy!=ybin)
215 (ybinmin>=0 && ybinmax>=ybinmin && !(ybinmin<=iy && iy<=ybinmax))
219 if (code>0 && code%3==0){
220 if (iy==ybinmin) tylow=tymin;
221 if (iy==ybinmax) tyhigh=tymax;
226 if (code==0 || code%3!=0)
cout <<
"\tEvaluating ty=" << tyhigh <<
" in bin " << iy << endl;
227 else cout <<
"\tEvaluating ty[" << tylow <<
", " << tyhigh <<
"] in bin " << iy << endl;
235 xCoefs.push_back(theCoef);
250 vector<MELANCSplineCore::T>
const* coord;
251 if (whichDirection==0){
260 for (Int_t j=0; j<npoints-1; j++){
266 kappas.push_back(
kappa);
268 kappas.push_back(
kappa);
274 vector<MELANCSplineCore::T>
const* coord;
275 if (whichDirection==0){
284 if (npoints<=1) bin=0;
286 valjpo = coord->at(0);
287 for (Int_t j=0; j<npoints-1; j++){
289 valjpo = coord->at(j+1);
290 if (val<valjpo && val>=valj){ bin=j;
break; }
292 if (bin==-1 && val>=valjpo) bin=npoints-2;
293 else if (bin==-1) bin=0;
300 vector<MELANCSplineCore::T>
const* coord;
301 if (whichDirection==0) coord=&
XList;
303 return (val-coord->at(bin))*K;
307 vector<MELANCSplineCore::T> fcnList;
308 for (
unsigned int bin=0; bin<
npointsX(); bin++){ fcnList.push_back(
FcnList.at(ybin).at(bin)); }
323 if (_forceNumInt)
return 0;
327 RooArgSet Xdeps, Ydeps;
328 RooRealVar* rrv_x =
dynamic_cast<RooRealVar*
>(
theXVar.absArg());
329 RooRealVar* rrv_y =
dynamic_cast<RooRealVar*
>(
theYVar.absArg());
330 if (rrv_x==0)
theXVar.absArg()->leafNodeServerList(&Xdeps, 0,
true);
331 if (rrv_y==0)
theYVar.absArg()->leafNodeServerList(&Ydeps, 0,
true);
334 if (Ydeps.find(*rrv_x)==0 || rrv_y!=0){
335 if (matchArgs(allVars, analVars,
theXVar)) code*=2;
339 if (Xdeps.find(*rrv_y)==0 || rrv_x!=0){
340 if (matchArgs(allVars, analVars,
theYVar)) code*=3;
350 if (
verbosity>=
MELANCSplineCore::kError) coutE(Integration) <<
"MELANCSpline_2D_fast ERROR::MELANCSpline_2D_fast(" << GetName() <<
") integration returned " <<
value <<
" for code = " << code << endl;
359 if (whichDirection==0){
367 return (*(range[0])>*(range[1]) || (val>=*(range[0]) && val<=*(range[1])));
371 if (whichDirection==0){
385 if (whichDirection==0){
393 if (val<*(range[0])) val = *(range[0]);
394 if (val>*(range[1])) val = *(range[1]);