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

Public Member Functions | |
| ISpectrumInterpolator () | |
| virtual | ~ISpectrumInterpolator () |
| void | AddInputSpectra (std::vector< double > shift, std::vector< TH1 * > spectra) |
| Add input data to the interpolation. | |
| std::vector< TH1 * > | GetInputSpectra (std::vector< double > shift) const |
| Find a set of spectra previously provided to AddInputSpectra. | |
| std::vector< TH1 * > | GetInterpolatedSpectra (std::vector< double > shift) |
| void | WriteResources () const |
| Write out all the spectra given to AddInputSpectra(). | |
Protected Member Functions | |
| std::vector< TH1 * > | GetNominal () const |
| virtual std::vector< TH1 * > | InterpolateHists (const std::vector< ShiftInfo > &hs, const std::vector< double > &shift) const |
| Evaluates shifted spectra based on interpolating multiple sets of input spectra. | |
| virtual TMatrixD | FindCoeffs (const std::vector< std::vector< double > > &xs, const std::vector< double > &x) const =0 |
| Do the bulk of the work. | |
Protected Attributes | |
| std::vector< ShiftInfo > | shifted |
|
|
Definition at line 22 of file NCSpectrumInterpolator.h. 00022 {}
|
|
|
Definition at line 40 of file NCSpectrumInterpolator.cxx. References shifted. 00041 {
00042 for(unsigned int n = 0; n < shifted.size(); ++n)
00043 for(unsigned int m = 0; m < shifted[n].spectra.size(); ++m)
00044 delete shifted[n].spectra[m];
00045 }
|
|
||||||||||||
|
Add input data to the interpolation.
Definition at line 48 of file NCSpectrumInterpolator.cxx. References shifted. Referenced by NCExtrapolation::InitializeInterpolator(). 00050 {
00051 for(unsigned int n = 0; n < shifted.size(); ++n){
00052 if(shifted[n].shift == shift){
00053 assert(0 && "We already added spectra at this shift");
00054 // shifted[n].spectra.insert(shifted[n].spectra.end(),
00055 // spectra.begin(), spectra.end());
00056 // return;
00057 }
00058 }
00059
00060 // Didn't find a matching one so make a new one
00061 shifted.push_back(ShiftInfo(shift, spectra));
00062 }
|
|
||||||||||||
|
Do the bulk of the work.
Implemented in NC::SpectrumInterpolatorFancy, NC::SpectrumInterpolatorSimple, and NC::SpectrumInterpolatorSimplest. Referenced by InterpolateHists(). |
|
|
Find a set of spectra previously provided to AddInputSpectra. Returns an empty vector if shift doesn't match Definition at line 66 of file NCSpectrumInterpolator.cxx. References NC::Utility::CloneFast(), NC::ISpectrumInterpolator::ShiftInfo::shift, shifted, and NC::ISpectrumInterpolator::ShiftInfo::spectra. Referenced by NCExtrapolation::InitializeInterpolator(). 00067 {
00068 vector<TH1*> ret;
00069
00070 for(unsigned int n = 0; n < shifted.size(); ++n){
00071 const ShiftInfo& sn = shifted[n];
00072 if(sn.shift == shift){
00073 ret.reserve(sn.spectra.size());
00074 for(unsigned int n = 0; n < sn.spectra.size(); ++n)
00075 ret.push_back(CloneFast(sn.spectra[n]));
00076 return ret;
00077 }
00078 }
00079
00080 return ret; // empty
00081 }
|
|
|
For a given set of shifts, return the interpolated spectra based on the input given to AddInputSpectra() Definition at line 43 of file NCSpectrumInterpolator.h. Referenced by NCExtrapolationPID::FindSpectraForPars(), NCExtrapolationFarNear::FindSpectraForPars(), NCExtrapolationBeamMatrix::FindSpectraForPars(), NCExtrapolationBeamMatrix::WriteResources(), and NCExtrapolationPID::WriteSpectra(). 00044 {
00045 return InterpolateHists(shifted, shift);
00046 }
|
|
|
Definition at line 294 of file NCSpectrumInterpolator.cxx. References shifted. 00295 {
00296 for(unsigned int n = 0; n < shifted.size(); ++n){
00297 if(shifted[n].IsNominal()) return shifted[n].spectra;
00298 }
00299 assert(0 && "No nominal spectrum exists");
00300 }
|
|
||||||||||||
|
Evaluates shifted spectra based on interpolating multiple sets of input spectra.
Definition at line 85 of file NCSpectrumInterpolator.cxx. References NC::Utility::AddFast(), NC::Utility::CloneFast(), and FindCoeffs(). 00087 {
00088 assert(!hs.empty());
00089
00090 vector<vector<double> > xs;
00091 xs.reserve(hs.size());
00092 for(unsigned int n = 0; n < hs.size(); ++n) xs.push_back(hs[n].shift);
00093
00094 const TMatrixD coeffs = FindCoeffs(xs, shift);
00095
00096 const unsigned int I = hs[0].spectra.size();
00097 vector<TH1*> ret;
00098 ret.reserve(I);
00099 for(unsigned int i = 0; i < I; ++i){
00100 // Get the correct binning
00101 TH1* h = CloneFast(hs[0].spectra[i]);
00102 h->Reset();
00103
00104 const unsigned int J = hs.size();
00105
00106 for(unsigned int j = 0; j < J; ++j)
00107 AddFast(h, hs[j].spectra[i], coeffs(0, j));
00108
00109 ret.push_back(h);
00110 } // end for i
00111
00112 return ret;
00113 }
|
|
|
Write out all the spectra given to AddInputSpectra().
Definition at line 234 of file NCSpectrumInterpolator.cxx. References max, min, MSG, s(), and shifted. Referenced by NCExtrapolation::WriteResources(). 00235 {
00236 MSG("NCISpectrumInterpolator",
00237 Msg::kInfo) << "NC::ISpectrumInterpolator::WriteResources()" << endl;
00238
00239 const int N = int(shifted.size());
00240 if(N == 0) return;
00241 const int M = int(shifted[0].spectra.size());
00242
00243 // Go through all the plots, find the maximum range and extend by 10%
00244 // then clamp to the range 0.5-2.0
00245 double min = FLT_MAX;
00246 double max = FLT_MIN;
00247 for(int n = 0; n < N; ++n){
00248 for(int m = 0; m < M; ++m){
00249 TH1* s = shifted[n].spectra[m];
00250 if(s->GetMinimum(0) < min) min = s->GetMinimum(0);
00251 if(s->GetMaximum() > max) max = s->GetMaximum();
00252 }
00253 }
00254 max = 1+(max-1)*1.1;
00255 min = 1-(1-min)*1.1;
00256 if(max > 2) max = 2;
00257 if(min < 0.5) min = 0.5;
00258
00259 for(int n = 0; n < N; ++n){
00260 for(int m = 0; m < M; ++m){
00261 TH1* s = shifted[n].spectra[m];
00262 s->SetMinimum(min);
00263 s->SetMaximum(max);
00264 s->Write();
00265 }
00266 }
00267
00268 TCanvas canv("all_spectra_canv");
00269 // Try dividing as a square. If this isn't big enough then expand
00270 // horizontally. If still not then also expand vertically.
00271 int X = int(TMath::Sqrt(N*M));
00272 int Y = int(TMath::Sqrt(N*M));
00273 if(X*Y < N*M) ++X;
00274 if(X*Y < N*M) ++Y;
00275 canv.Divide(X, Y);
00276
00277 for(int n = 0; n < N; ++n){
00278 for(int m = 0; m < M; ++m){
00279 canv.cd(M*n+m+1);
00280 TH1* s = shifted[n].spectra[m];
00281 s->SetTitle(s->GetName());
00282 if(s->GetXaxis()->GetXmin() == 0 && s->GetXaxis()->GetXmax() == 120)
00283 s->GetXaxis()->SetRangeUser(0, 19.5);
00284 if(s->GetDimension() == 2) s->Draw("colz"); else s->Draw();
00285 }
00286 }
00287 canv.Write();
00288
00289 MSG("NCISpectrumInterpolator",
00290 Msg::kInfo) << "Done writing interpolator resources" << endl;
00291 }
|
|
|
Definition at line 106 of file NCSpectrumInterpolator.h. Referenced by AddInputSpectra(), GetInputSpectra(), GetNominal(), WriteResources(), and ~ISpectrumInterpolator(). |
1.3.9.1