#include <NCSpectrumInterpolator.h>
Inheritance diagram for NC::SpectrumInterpolatorSimplest:

Protected Member Functions | |
| virtual TMatrixD | FindCoeffs (const std::vector< std::vector< double > > &xs, const std::vector< double > &x) const |
| Do the bulk of the work. | |
|
||||||||||||
|
Do the bulk of the work.
Implements NC::ISpectrumInterpolator. Definition at line 477 of file NCSpectrumInterpolator.cxx. 00478 {
00479 const unsigned int N = xs.size(); // number of input points
00480 TMatrixD ret(1, N);
00481
00482 const unsigned int D = TMath::Min(x.size(), xs[0].size());
00483
00484 // If there is more than one point, and no dimensions, then they'll all be
00485 // picked as nominal. Go find out why your systematic shift is empty.
00486 // (perhaps because we don't support fitting the systematic you're trying
00487 // to use).
00488 assert((N == 1 || D > 0) && "Empty shift");
00489
00490 int nominalIdx = -1;
00491
00492 for(unsigned int n = 0; n < N; ++n){ // for every point
00493 bool isNominal = true;
00494 double weight = 0;
00495 for(unsigned int d = 0; d < D; ++d){ // for every dimension
00496 if(xs[n][d] != 0) isNominal = false;
00497 if((xs[n][d] < 0 && x[d] < 0) ||
00498 (xs[n][d] > 0 && x[d] > 0)){
00499 assert(weight == 0); // No point should contribute more than once
00500 weight = x[d] / xs[n][d];
00501 } // end if
00502 } // end for d
00503 ret(0, n) = weight;
00504 if(isNominal){
00505 // Should only be one nominal point
00506 assert(nominalIdx == -1 && "Multiple nominal spectra");
00507 nominalIdx = n;
00508 }
00509 } // end for n
00510 assert(nominalIdx >= 0);
00511
00512 assert(ret(0, nominalIdx) == 0); // Nominal shouldn't have got weight
00513 double norm = 0;
00514 for(unsigned int n = 0; n < N; ++n) norm += ret(0, n);
00515 ret(0, nominalIdx) = 1-norm; // Make the total up to one
00516
00517 // cout << x << " -> " << ret << endl;
00518
00519 return ret;
00520 }
|
1.3.9.1