48 while ( xbin < 0 || xbin >=
nBinsX - 1 ) {
52 xbin = 2 * (
nBinsX - 1 ) - xbin - 1;
54 while ( ybin < 0 || ybin >=
nBinsY - 1 ) {
58 ybin = 2 * (
nBinsY - 1 ) - ybin - 1;
61 return h.GetBinContent( 1 + xbin, 1 + ybin );
66 return 0.5 * (
histcont( h, xbin + 1, ybin ) -
histcont( h, xbin - 1, ybin ) );
71 return 0.5 * (
histcont( h, xbin, ybin + 1 ) -
histcont( h, xbin, ybin - 1 ) );
76 return 0.5 * (
histcont( h, xbin - 1, ybin - 1 ) -
histcont( h, xbin + 1, ybin - 1 ) +
81 nBinsX( 1 + h.GetNbinsX() ),
82 nBinsY( 1 + h.GetNbinsY() ),
83 binSizeX( h.GetXaxis()->GetBinWidth( 1 ) ),
84 binSizeY( h.GetYaxis()->GetBinWidth( 1 ) ),
85 xmin( h.GetXaxis()->GetBinCenter( 1 ) - binSizeX ),
86 xmax( h.GetXaxis()->GetBinCenter( nBinsX - 1 ) + binSizeX ),
87 ymin( h.GetYaxis()->GetBinCenter( 1 ) - binSizeY ),
88 ymax( h.GetYaxis()->GetBinCenter( nBinsY - 1 ) + binSizeY ),
89 coeffs( CoeffRecLen * nBinsX * nBinsY )
91 const TAxis* xaxis = h.GetXaxis();
92 const TAxis* yaxis = h.GetYaxis();
94 for ( Int_t i = 1; i <
nBinsX; ++i ) {
95 if ( std::abs( xaxis->GetBinWidth( i ) /
binSizeX - 1. ) > 1e-9 ) {
96 std::cerr <<
"ERROR in Lau2DCubicSpline constructor : the histogram has variable bin sizes."
98 gSystem->Exit( EXIT_FAILURE );
101 for ( Int_t i = 1; i <
nBinsY; ++i ) {
102 if ( std::abs( yaxis->GetBinWidth( i ) /
binSizeY - 1. ) > 1e-9 ) {
103 std::cerr <<
"ERROR in Lau2DCubicSpline constructor : the histogram has variable bin sizes."
105 gSystem->Exit( EXIT_FAILURE );
112 for ( Int_t j = -1; j <
nBinsY - 1; ++j ) {
113 for ( Int_t i = -1; i <
nBinsX - 1; ++i ) {
114 const Double_t rhs[NCoeff] = {
141 coeff( 1 + i, 1 + j, 15 ) = rhs[0];
142 coeff( 1 + i, 1 + j, 14 ) = rhs[4];
143 coeff( 1 + i, 1 + j, 13 ) = 3. * ( -rhs[0] + rhs[1] ) - 2. * rhs[4] - rhs[5];
144 coeff( 1 + i, 1 + j, 12 ) = 2. * ( rhs[0] - rhs[1] ) + rhs[4] + rhs[5];
146 coeff( 1 + i, 1 + j, 11 ) = rhs[8];
147 coeff( 1 + i, 1 + j, 10 ) = rhs[12];
148 coeff( 1 + i, 1 + j, 9 ) = 3. * ( -rhs[8] + rhs[9] ) - 2. * rhs[12] - rhs[13];
149 coeff( 1 + i, 1 + j, 8 ) = 2. * ( rhs[8] - rhs[9] ) + rhs[12] + rhs[13];
151 coeff( 1 + i, 1 + j, 7 ) = 3. * ( -rhs[0] + rhs[2] ) - 2. * rhs[8] - rhs[10];
152 coeff( 1 + i, 1 + j, 6 ) = 3. * ( -rhs[4] + rhs[6] ) - 2. * rhs[12] - rhs[14];
153 coeff( 1 + i, 1 + j, 5 ) = 9. * ( rhs[0] - rhs[1] - rhs[2] + rhs[3] ) +
154 6. * ( rhs[4] - rhs[6] + rhs[8] - rhs[9] ) + 4. * rhs[12] +
155 3. * ( rhs[5] - rhs[7] + rhs[10] - rhs[11] ) +
156 2. * ( rhs[13] + rhs[14] ) + rhs[15];
157 coeff( 1 + i, 1 + j, 4 ) = 6. * ( -rhs[0] + rhs[1] + rhs[2] - rhs[3] ) +
158 4. * ( -rhs[8] + rhs[9] ) +
159 3. * ( -rhs[4] - rhs[5] + rhs[6] + rhs[7] ) +
160 2. * ( -rhs[10] + rhs[11] - rhs[12] - rhs[13] ) - rhs[14] -
163 coeff( 1 + i, 1 + j, 3 ) = 2. * ( rhs[0] - rhs[2] ) + rhs[8] + rhs[10];
164 coeff( 1 + i, 1 + j, 2 ) = 2. * ( rhs[4] - rhs[6] ) + rhs[12] + rhs[14];
165 coeff( 1 + i, 1 + j, 1 ) = 6. * ( -rhs[0] + rhs[1] + rhs[2] - rhs[3] ) +
166 4. * ( -rhs[4] + rhs[6] ) +
167 3. * ( -rhs[8] + rhs[9] - rhs[10] + rhs[11] ) +
168 2. * ( -rhs[5] + rhs[7] - rhs[12] - rhs[14] ) - rhs[13] -
170 coeff( 1 + i, 1 + j, 0 ) = 4. * ( rhs[0] - rhs[1] - rhs[2] + rhs[3] ) +
171 2. * ( rhs[4] + rhs[5] - rhs[6] - rhs[7] + rhs[8] - rhs[9] +
172 rhs[10] - rhs[11] ) +
173 rhs[12] + rhs[13] + rhs[14] + rhs[15];
178 for ( Int_t k = 0; k < NCoeff; ++k )
179 sum +=
coeff( 1 + i, 1 + j, k ) / Double_t( ( 4 - ( k % 4 ) ) * ( 4 - ( k / 4 ) ) );
180 coeff( 1 + i, 1 + j, NCoeff ) = sum;
188 if ( x <= xmin || x >=
xmax || y <= ymin || y >=
ymax || x != x || y != y )
194 const Double_t xlo = Double_t(
nBinsX - binx ) / Double_t(
nBinsX ) *
xmin +
196 const Double_t ylo = Double_t(
nBinsY - biny ) / Double_t(
nBinsY ) *
ymin +
199 const Double_t hx = ( x - xlo ) /
binSizeX;
200 const Double_t hy = ( y - ylo ) /
binSizeY;
202 const Double_t hxton[4] = { hx * hx * hx, hx * hx, hx, 1. };
203 const Double_t hyton[4] = { hy * hy * hy, hy * hy, hy, 1. };
205 Double_t retVal = 0.;
206 for ( Int_t k = 0; k < NCoeff; ++k )
207 retVal +=
coeff( binx, biny, k ) * hxton[k % 4] * hyton[k / 4];
220 return evalX( x1, x2, y1 );
222 return evalY( x1, y1, y2 );
223 return evalXY( x1, x2, y1, y2 );
229 if ( x1 != x1 || x2 != x2 || y != y )
234 const Double_t ylo = Double_t(
nBinsY - biny ) / Double_t(
nBinsY ) *
ymin +
237 const Double_t hy = ( y - ylo ) /
binSizeY;
239 const Double_t hyton[4] = { hy * hy * hy, hy * hy, hy, 1. };
242 for ( Int_t binx = 0; binx <
nBinsX; ++binx ) {
244 const Double_t xhi = Double_t(
nBinsX - binx - 1 ) / Double_t(
nBinsX ) *
xmin +
245 Double_t( binx + 1 ) / Double_t(
nBinsX ) *
xmax;
248 const Double_t xlo = Double_t(
nBinsX - binx ) / Double_t(
nBinsX ) *
xmin +
253 const Double_t a = ( ( xlo > x1 ) ? 0. : ( x1 - xlo ) ) /
binSizeX;
256 const Double_t hxton[4] = { 0.25 * ( b * b * b * b - a * a * a * a ),
257 ( b * b * b - a * a * a ) / 3.,
258 0.5 * ( b * b - a * a ),
261 for ( Int_t k = 0; k < NCoeff; ++k )
262 lsum +=
coeff( binx, biny, k ) * hxton[k % 4] * hyton[k / 4];
272 if ( x != x || y1 != y1 || y2 != y2 )
277 const Double_t xlo = Double_t(
nBinsX - binx ) / Double_t(
nBinsX ) *
xmin +
280 const Double_t hx = ( x - xlo ) /
binSizeX;
282 const Double_t hxton[4] = { hx * hx * hx, hx * hx, hx, 1. };
285 for ( Int_t biny = 0; biny <
nBinsY; ++biny ) {
287 const Double_t yhi = Double_t(
nBinsY - biny - 1 ) / Double_t(
nBinsY ) *
ymin +
288 Double_t( biny + 1 ) / Double_t(
nBinsY ) *
ymax;
291 const Double_t ylo = Double_t(
nBinsY - biny ) / Double_t(
nBinsY ) *
ymin +
296 const Double_t a = ( ( ylo > y1 ) ? 0. : ( y1 - ylo ) ) /
binSizeY;
299 const Double_t hyton[4] = { 0.25 * ( b * b * b * b - a * a * a * a ),
300 ( b * b * b - a * a * a ) / 3.,
301 0.5 * ( b * b - a * a ),
304 for ( Int_t k = 0; k < NCoeff; ++k )
305 lsum +=
coeff( binx, biny, k ) * hxton[k % 4] * hyton[k / 4];
315 if ( x1 != x1 || x2 != x2 || y1 != y1 || y2 != y2 )
319 for ( Int_t biny = 0; biny <
nBinsY; ++biny ) {
321 const Double_t yhi = Double_t(
nBinsY - biny - 1 ) / Double_t(
nBinsY ) *
ymin +
322 Double_t( biny + 1 ) / Double_t(
nBinsY ) *
ymax;
325 const Double_t ylo = Double_t(
nBinsY - biny ) / Double_t(
nBinsY ) *
ymin +
330 const Double_t ay = ( ( ylo > y1 ) ? 0. : ( y1 - ylo ) ) /
binSizeY;
332 const Bool_t yFullyContained = std::abs( by - ay - 1.0 ) < 1e-15;
334 const Double_t hyton[4] = { 0.25 * ( by * by * by * by - ay * ay * ay * ay ),
335 ( by * by * by - ay * ay * ay ) / 3.,
336 0.5 * ( by * by - ay * ay ),
338 for ( Int_t binx = 0; binx <
nBinsX; ++binx ) {
340 const Double_t xhi = Double_t(
nBinsX - binx - 1 ) / Double_t(
nBinsX ) *
xmin +
341 Double_t( binx + 1 ) / Double_t(
nBinsX ) *
xmax;
344 const Double_t xlo = Double_t(
nBinsX - binx ) / Double_t(
nBinsX ) *
xmin +
349 const Double_t ax = ( ( xlo > x1 ) ? 0. : ( x1 - xlo ) ) /
binSizeX;
351 const Bool_t xFullyContained = std::abs( bx - ax - 1.0 ) < 1e-15;
352 if ( xFullyContained && yFullyContained ) {
354 sum +=
coeff( binx, biny, NCoeff );
358 const Double_t hxton[4] = { 0.25 * ( bx * bx * bx * bx - ax * ax * ax * ax ),
359 ( bx * bx * bx - ax * ax * ax ) / 3.,
360 0.5 * ( bx * bx - ax * ax ),
365 for ( Int_t k = 0; k < NCoeff; ++k )
366 lsum +=
coeff( binx, biny, k ) * hxton[k % 4] * hyton[k / 4];