NC::ISpectrumInterpolator Class Reference

#include <NCSpectrumInterpolator.h>

Inheritance diagram for NC::ISpectrumInterpolator:
NC::SpectrumInterpolatorFancy NC::SpectrumInterpolatorSimple NC::SpectrumInterpolatorSimplest

List of all members.

Classes

struct  ShiftInfo

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< ShiftInfofShifted

Detailed Description

Definition at line 19 of file NCSpectrumInterpolator.h.


Constructor & Destructor Documentation

NC::ISpectrumInterpolator::ISpectrumInterpolator (  )  [inline]

Definition at line 22 of file NCSpectrumInterpolator.h.

00022 {}

NC::ISpectrumInterpolator::~ISpectrumInterpolator (  )  [virtual]

Definition at line 40 of file NCSpectrumInterpolator.cxx.

References fShifted, Munits::m, and n.

00041 {
00042   for(unsigned int n = 0; n < fShifted.size(); ++n)
00043     for(unsigned int m = 0; m < fShifted[n].spectra.size(); ++m)
00044       delete fShifted[n].spectra[m];
00045 }


Member Function Documentation

void NC::ISpectrumInterpolator::AddInputSpectra ( std::vector< double >  shift,
std::vector< TH1 * >  spectra 
)

Add input data to the interpolation.

Parameters:
shift The shifts used
spectra The spectra produced at these shifts

The contents of spectra are now owned by the class, and will be deleted on its destruction.

Definition at line 48 of file NCSpectrumInterpolator.cxx.

References fShifted, and n.

Referenced by NCExtrapolation::InitializeInterpolator().

00050 {
00051   for(unsigned int n = 0; n < fShifted.size(); ++n){
00052     if(fShifted[n].shift == shift){
00053       assert(0 && "We already added spectra at this shift");
00054       //      fShifted[n].spectra.insert(fShifted[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   fShifted.push_back(ShiftInfo(shift, spectra));
00062 }

virtual TMatrixD NC::ISpectrumInterpolator::FindCoeffs ( const std::vector< std::vector< double > > &  xs,
const std::vector< double > &  x 
) const [protected, pure virtual]
std::vector<TH1*> NC::ISpectrumInterpolator::GetInputSpectra ( std::vector< double >  shift  )  const

Find a set of spectra previously provided to AddInputSpectra.

Returns an empty vector if shift doesn't match

Referenced by NCExtrapolation::InitializeInterpolator().

std::vector<TH1*> NC::ISpectrumInterpolator::GetInterpolatedSpectra ( std::vector< double >  shift  )  [inline]

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.

References fShifted, and InterpolateHists().

Referenced by NCExtrapolationBeamMatrix::WriteResources().

00044   {
00045     return InterpolateHists(fShifted, shift);
00046   }

vector< TH1 * > NC::ISpectrumInterpolator::GetNominal (  )  const [protected]

Definition at line 294 of file NCSpectrumInterpolator.cxx.

References fShifted.

00295 {
00296   for(unsigned int n = 0; n < fShifted.size(); ++n){
00297     if(fShifted[n].IsNominal()) return fShifted[n].spectra;
00298   }
00299   assert(0 && "No nominal spectrum exists");
00300 }

virtual std::vector<TH1*> NC::ISpectrumInterpolator::InterpolateHists ( const std::vector< ShiftInfo > &  hs,
const std::vector< double > &  shift 
) const [protected, virtual]

Evaluates shifted spectra based on interpolating multiple sets of input spectra.

Parameters:
hs A collection of $ \geq3^d $ ShiftInfo's
shift The d-dimensional shift to interpolate to
Returns:
The interpolated histograms, caller is responsible for deletion
See also:
InterpolateMultiPoints

Referenced by GetInterpolatedSpectra().

void NC::ISpectrumInterpolator::WriteResources (  )  const

Write out all the spectra given to AddInputSpectra().

Definition at line 234 of file NCSpectrumInterpolator.cxx.

References fShifted, Msg::kInfo, Munits::m, max, min, and MSG.

Referenced by NCExtrapolation::WriteResources().

00235 {
00236   MSG("NCISpectrumInterpolator",
00237       Msg::kInfo) << "NC::ISpectrumInterpolator::WriteResources()" << endl;
00238 
00239   const int N = int(fShifted.size());
00240   if(N == 0) return;
00241   const int M = int(fShifted[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 = fShifted[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 = fShifted[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 = fShifted[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 }


Member Data Documentation


The documentation for this class was generated from the following files:

Generated on 18 Oct 2018 for loon by  doxygen 1.6.1