NuMatrix2D Class Reference

#include <NuMatrix2D.h>

Inheritance diagram for NuMatrix2D:
NuMatrix

List of all members.

Public Member Functions

 NuMatrix2D ()
 NuMatrix2D (const TH2D &spectrum)
 The spectrum-only constructor.
 NuMatrix2D (Double_t POT)
 The POT-only constructor.
 NuMatrix2D (const TH2D &spectrum, Double_t POT)
 The spectrum *and* POT constructor.
 NuMatrix2D (const NuMatrix2D &original)
NuMatrix2Doperator= (const NuMatrix2D &orig)
virtual ~NuMatrix2D ()
Double_t StatsLikelihood (const NuMatrix *with) const
 Checks the passed object is a NuMatrix2D then returns the log-likelihood difference.
Double_t StatsLikelihood (const NuMatrix2D *with) const
 Compares two 2D histograms and returns the log-likelihood difference.
virtual void ScaleToPOT (Double_t new_POT)
virtual TH1 * Spectrum (void) const
 Returns a pointer to the built in data storage.
virtual Bool_t Complete () const
 Returns true if the spectrum is properly configured.
virtual void Draw (Option_t *option="")
virtual NuMatrix2DCopy (void) const
 Makes a 'deep copy' - every subclass should implement this.
virtual void Scale (Double_t value)
 Scales the Matrix, without changing the POT.
virtual void Divide (const NuMatrix &correction)
 Make a correction by Dividing.
virtual void Divide (const NuMatrix2D &correction)
 Make a correction by Dividing.
virtual void Divide (const TH1 &correction, const Option_t *option="")
virtual void Divide (const TGraph &correction)
virtual void Multiply (const NuMatrix &correction)
 Make a correction by Multiplying.
virtual void Multiply (const NuMatrix2D &correction)
 Make a correction by Multiplying.
virtual void Multiply (const TH1 &correction, const Option_t *option="")
virtual void Multiply (const TGraph &correction)
virtual void Add (const NuMatrix &correction, Bool_t addpot=false)
 Functions for addition and subtraction.
virtual void Add (const NuMatrix2D &correction, Bool_t addpot=false)
 Functions for addition and subtraction.
virtual void Subtract (const NuMatrix &correction)
virtual void Subtract (const NuMatrix2D &correction)
virtual void RecoToTrue (const TH2D &correction)
virtual void TrueToReco (const TH2D &correction)
virtual void ExtrapolateNDToFD (const TH2D &beammatrix)
virtual void SetValue (Double_t val)
virtual Int_t Write (const TString &name) const
 Writes to the current file.
virtual void Read (TFile *f, const TString &name)
virtual TH2 * Spectrum (void)
 Returns a TH1 object representing the data the spectrum holds. Or zero.
virtual void SetSpectrum (const TH2D &spectrum)
virtual void Oscillate (const Double_t dm2, const Double_t sn2)
virtual void DecayCC (double, double, double)
virtual void DecayNC (double, double)
virtual void DecayMuToTau (double, double, double)
virtual void Decohere (double, double, double)

Protected Member Functions

 ClassDef (NuMatrix2D, 0)

Protected Attributes

TH2D * fSpectrum
 The 2D data storage.

Detailed Description

Definition at line 12 of file NuMatrix2D.h.


Constructor & Destructor Documentation

NuMatrix2D::NuMatrix2D (  ) 

Definition at line 25 of file NuMatrix2D.cxx.

Referenced by Copy().

00025                        : NuMatrix(), fSpectrum(0)
00026 {
00027 
00028 }

NuMatrix2D::NuMatrix2D ( const TH2D &  spectrum  ) 

The spectrum-only constructor.

Definition at line 37 of file NuMatrix2D.cxx.

References fSpectrum.

00037                                            : NuMatrix(0), fSpectrum(0)
00038 {
00039   fSpectrum = new TH2D(spectrum);
00040 }

NuMatrix2D::NuMatrix2D ( Double_t  POT  ) 

The POT-only constructor.

Definition at line 31 of file NuMatrix2D.cxx.

00031                                    : NuMatrix(POT), fSpectrum(0)
00032 {
00033 
00034 }

NuMatrix2D::NuMatrix2D ( const TH2D &  spectrum,
Double_t  POT 
)

The spectrum *and* POT constructor.

Definition at line 43 of file NuMatrix2D.cxx.

References fSpectrum.

00043                                                          : NuMatrix(POT), fSpectrum(0)
00044 {
00045   fSpectrum = new TH2D(spectrum);
00046 }

NuMatrix2D::NuMatrix2D ( const NuMatrix2D original  ) 

Definition at line 49 of file NuMatrix2D.cxx.

References fSpectrum.

00049                                                  : NuMatrix(original), fSpectrum(0)
00050 {
00051   fSpectrum = new TH2D(*original.fSpectrum);
00052 }

NuMatrix2D::~NuMatrix2D (  )  [virtual]

Definition at line 71 of file NuMatrix2D.cxx.

References fSpectrum.

00072 {
00073   if (fSpectrum) delete fSpectrum; fSpectrum = 0;
00074 }


Member Function Documentation

void NuMatrix2D::Add ( const NuMatrix2D correction,
Bool_t  addpot = false 
) [virtual]

Functions for addition and subtraction.

Implements NuMatrix.

Definition at line 239 of file NuMatrix2D.cxx.

References fSpectrum, NuMatrix::GetPOT(), NuMatrix::ResetPOT(), and Spectrum().

00240 {
00241   // If we don't have a spectrum, copy it
00242   if (!fSpectrum) {
00243     fSpectrum = new TH2D(*dynamic_cast<TH2D*>(with.Spectrum()));
00244   } else {
00245     // Just add it
00246     fSpectrum->Add(with.Spectrum());
00247   }
00248   // Add the POT if this is requested
00249   if (addpot) ResetPOT(GetPOT()+with.GetPOT());
00250 }

void NuMatrix2D::Add ( const NuMatrix correction,
Bool_t  addpot = false 
) [virtual]

Functions for addition and subtraction.

Definition at line 226 of file NuMatrix2D.cxx.

References Msg::kWarning, and MSG.

00227 {
00228   // Convert the NuMatrix to a NuMatrix1D
00229   const NuMatrix2D *other = dynamic_cast<const NuMatrix2D*>(&with);
00230   if (other == 0) {
00231     MSG("NuMatrix2D",Msg::kWarning) << "Attempting to add a NuMatrix2D to something other than a NuMatrix2D" << endl;
00232   }
00233 
00234   this->Add(*other, addpot);
00235 }

NuMatrix2D::ClassDef ( NuMatrix2D  ,
 
) [protected]
virtual Bool_t NuMatrix2D::Complete (  )  const [inline, virtual]

Returns true if the spectrum is properly configured.

Implements NuMatrix.

Definition at line 41 of file NuMatrix2D.h.

References fSpectrum.

00041 { return fSpectrum; }

virtual NuMatrix2D* NuMatrix2D::Copy ( void   )  const [inline, virtual]

Makes a 'deep copy' - every subclass should implement this.

Implements NuMatrix.

Definition at line 52 of file NuMatrix2D.h.

References NuMatrix2D().

00052 { return new NuMatrix2D(*this); }

virtual void NuMatrix2D::DecayCC ( double  ,
double  ,
double   
) [inline, virtual]

Definition at line 98 of file NuMatrix2D.h.

00098 {assert(0 && "Not implemented");}

virtual void NuMatrix2D::DecayMuToTau ( double  ,
double  ,
double   
) [inline, virtual]

Definition at line 100 of file NuMatrix2D.h.

00100 {assert(0 && "Not implemented");}

virtual void NuMatrix2D::DecayNC ( double  ,
double   
) [inline, virtual]

Definition at line 99 of file NuMatrix2D.h.

00099 {assert(0 && "Not implemented");}

virtual void NuMatrix2D::Decohere ( double  ,
double  ,
double   
) [inline, virtual]

Definition at line 101 of file NuMatrix2D.h.

00101 {assert(0 && "Not implemented");}

void NuMatrix2D::Divide ( const TGraph &  correction  )  [virtual]

Implements NuMatrix.

Definition at line 178 of file NuMatrix2D.cxx.

References Msg::kWarning, and MSG.

00179 {
00180   MSG("NuMatrix2D",Msg::kWarning)
00181     << "2D histograms cannot be corrected with graphs without further information"
00182     << endl;
00183 }

void NuMatrix2D::Divide ( const TH1 &  correction,
const Option_t *  option = "" 
) [virtual]

Implements NuMatrix.

Definition at line 170 of file NuMatrix2D.cxx.

References fSpectrum.

00171 {
00172   // fSpectrum->Divide(&correction);
00173   fSpectrum->Divide(fSpectrum, &correction, 1, 1, option);
00174 }

void NuMatrix2D::Divide ( const NuMatrix2D correction  )  [virtual]

Make a correction by Dividing.

Implements NuMatrix.

Definition at line 163 of file NuMatrix2D.cxx.

References fSpectrum, and Spectrum().

00164 {
00165   fSpectrum->Divide(correction.Spectrum());
00166 }

void NuMatrix2D::Divide ( const NuMatrix correction  )  [virtual]

Make a correction by Dividing.

Definition at line 150 of file NuMatrix2D.cxx.

References Msg::kWarning, and MSG.

00151 {
00152   // Convert the NuMatrix to a NuMatrix1D
00153   const NuMatrix2D *other = dynamic_cast<const NuMatrix2D*>(&correction);
00154   if (other == 0) {
00155     MSG("NuMatrix2D",Msg::kWarning) << "Attempting to divide a NuMatrix2D to something other than a NuMatrix2D" << endl;
00156   }
00157 
00158   this->Divide(*other);
00159 }

void NuMatrix2D::Draw ( Option_t *  option = ""  )  [virtual]

Implements NuMatrix.

Definition at line 361 of file NuMatrix2D.cxx.

References fSpectrum, Msg::kWarning, and MSG.

00362 {
00363   if(fSpectrum) {
00364     fSpectrum->Draw(option);
00365   } else {
00366     MSG("NuMatrix2D",Msg::kWarning) << "No spectrum exists: Cannot draw" << endl;
00367   }
00368 }

void NuMatrix2D::ExtrapolateNDToFD ( const TH2D &  beammatrix  )  [virtual]

Implements NuMatrix.

Definition at line 288 of file NuMatrix2D.cxx.

References Msg::kWarning, and MSG.

00289 {
00290   MSG("NuMatrix2D",Msg::kWarning) << "Base NuMatrix2D cannot be extrapolated" << endl;
00291 }

void NuMatrix2D::Multiply ( const TGraph &  correction  )  [virtual]

Implements NuMatrix.

Definition at line 217 of file NuMatrix2D.cxx.

References Msg::kWarning, and MSG.

00218 {
00219   MSG("NuMatrix2D",Msg::kWarning)
00220     << "2D histograms cannot be corrected with graphs without further information"
00221     << endl;
00222 }

void NuMatrix2D::Multiply ( const TH1 &  correction,
const Option_t *  option = "" 
) [virtual]

Implements NuMatrix.

Definition at line 209 of file NuMatrix2D.cxx.

References fSpectrum.

00210 {
00211   // fSpectrum->Multiply(&correction);
00212   fSpectrum->Multiply(fSpectrum, &correction, 1, 1, option);
00213 }

void NuMatrix2D::Multiply ( const NuMatrix2D correction  )  [virtual]

Make a correction by Multiplying.

Implements NuMatrix.

Definition at line 202 of file NuMatrix2D.cxx.

References fSpectrum, and Spectrum().

00203 {
00204   fSpectrum->Multiply(correction.Spectrum());
00205 }

void NuMatrix2D::Multiply ( const NuMatrix correction  )  [virtual]

Make a correction by Multiplying.

Definition at line 189 of file NuMatrix2D.cxx.

References Msg::kWarning, and MSG.

00190 {
00191   // Convert the NuMatrix to a NuMatrix1D
00192   const NuMatrix2D *other = dynamic_cast<const NuMatrix2D*>(&correction);
00193   if (other == 0) {
00194     MSG("NuMatrix2D",Msg::kWarning) << "Attempting to divide a NuMatrix2D to something other than a NuMatrix2D" << endl;
00195   }
00196 
00197   this->Multiply(*other);
00198 }

NuMatrix2D & NuMatrix2D::operator= ( const NuMatrix2D orig  ) 

Definition at line 55 of file NuMatrix2D.cxx.

References fSpectrum.

00056 {
00057   if (this == &orig) return *this;
00058 
00059   // Copy the base class stuff
00060   this->NuMatrix::operator=(orig);
00061 
00062   // Copy the histogram
00063   if (fSpectrum) delete fSpectrum;
00064   fSpectrum = new TH2D(*orig.fSpectrum);
00065 
00066   return *this;
00067 }

void NuMatrix2D::Oscillate ( const Double_t  dm2,
const Double_t  sn2 
) [virtual]

Implements NuMatrix.

Definition at line 354 of file NuMatrix2D.cxx.

References Msg::kWarning, and MSG.

00355 {
00356   MSG("NuMatrix2D",Msg::kWarning) << "Base NuMatrix2D cannot be oscillated" << endl;
00357 }

void NuMatrix2D::Read ( TFile *  f,
const TString &  name 
) [virtual]

Definition at line 330 of file NuMatrix2D.cxx.

References fSpectrum, Msg::kError, and MSG.

Referenced by RockMatrixRAF0720Eonly::Read(), RockMatrixRAF0720Ext::Read(), and RockMatrixRAF0720Std::Read().

00331 {
00332   if(!f || f->IsZombie()){
00333     MSG("NuMatrix2D",Msg::kError) << "Invalid file passed to Read()\n"
00334       "Passing back empty histogram\n";
00335     fSpectrum = new TH2D;
00336     return;
00337   }
00338 
00339   fSpectrum = dynamic_cast<TH2D *>(f->Get(name));
00340 
00341   if(!fSpectrum){
00342     MSG("NuMatrix2D",Msg::kError) << "Failed to Read() histogram named "
00343       << name << " from file!\nPassing back empty histogram\n";
00344     fSpectrum = new TH2D;
00345     return;
00346   }
00347 
00348   // Shouldn't be associated with the file it came from...
00349   fSpectrum->SetDirectory(0);
00350 }

void NuMatrix2D::RecoToTrue ( const TH2D &  correction  )  [virtual]

Implements NuMatrix.

Definition at line 274 of file NuMatrix2D.cxx.

References Msg::kWarning, and MSG.

00275 {
00276   MSG("NuMatrix2D",Msg::kWarning) << "Base NuMatrix2D cannot Reco->True" << endl;
00277 }

void NuMatrix2D::Scale ( Double_t  value  )  [virtual]

Scales the Matrix, without changing the POT.

Implements NuMatrix.

Definition at line 135 of file NuMatrix2D.cxx.

References fSpectrum.

Referenced by RockMatrixRAF0720Eonly::Scale(), RockMatrixRAF0720Std::Scale(), and RockMatrixRAF0720Ext::Scale().

00136 {
00137   // RockMuons uses Scale(0) to reset the histogram. It's much faster this
00138   // way because we don't eg try to propagate errors
00139   if(value == 0){
00140     fSpectrum->Reset();
00141     return;
00142   }
00143 
00144   fSpectrum->Scale(value);
00145 }

void NuMatrix2D::ScaleToPOT ( Double_t  new_POT  )  [virtual]

Changes the POT, by scaling the data. Beware when using this function that all the data you are storing scales with POT. Enumerations and plane numbers and such fall into this category. Re-implement the function in derived classes if it is needed.

Implements NuMatrix.

Definition at line 120 of file NuMatrix2D.cxx.

References fSpectrum, NuMatrix::GetPOT(), and NuMatrix::ResetPOT().

00121 {
00122   // If the old POT is zero, or the spectrum does not exist
00123   if (GetPOT() == 0.0 || fSpectrum == 0) {
00124     // Simply set the new POT (avoids infinite scaling)
00125     ResetPOT(new_POT);
00126   } else {
00127     // The spectrum must exist - calculate the scale factor
00128     Double_t scale_factor = new_POT / GetPOT();
00129     fSpectrum->Scale(scale_factor);
00130   }
00131 }

virtual void NuMatrix2D::SetSpectrum ( const TH2D &  spectrum  )  [inline, virtual]

Definition at line 91 of file NuMatrix2D.h.

References fSpectrum.

Referenced by RockMatrixRAF0720Eonly::RockMatrixRAF0720Eonly(), RockMatrixRAF0720Ext::RockMatrixRAF0720Ext(), and RockMatrixRAF0720Std::RockMatrixRAF0720Std().

00091                                                  {
00092     if (fSpectrum) delete fSpectrum;
00093     fSpectrum = static_cast<TH2D*>(spectrum.Clone());
00094   }

void NuMatrix2D::SetValue ( Double_t  val  )  [virtual]

Implements NuMatrix.

Definition at line 295 of file NuMatrix2D.cxx.

References fSpectrum, Msg::kWarning, and MSG.

00296 {
00297   // No spectrum - don't set
00298   if (!fSpectrum) {
00299     MSG("NuMatrix1D",Msg::kWarning) << "Cannot set constant value: No histogram" << endl;
00300     return;
00301   }
00302 
00303   for (Int_t i = 1; i <= fSpectrum->GetNbinsX(); ++i)
00304   {
00305     for (Int_t j = 1; j <= fSpectrum->GetNbinsY(); ++j)
00306     {
00307       fSpectrum->SetBinContent(i, j, val);
00308     }
00309   }
00310 }

virtual TH2* NuMatrix2D::Spectrum ( void   )  [inline, virtual]

Returns a TH1 object representing the data the spectrum holds. Or zero.

Definition at line 89 of file NuMatrix2D.h.

References fSpectrum.

00089 { return fSpectrum; };

virtual TH1* NuMatrix2D::Spectrum ( void   )  const [inline, virtual]

Returns a pointer to the built in data storage.

Implements NuMatrix.

Definition at line 37 of file NuMatrix2D.h.

References fSpectrum.

Referenced by Add(), Divide(), RockMatrixRAF0720Std::FillJess(), RockMatrixRAF0720Eonly::FillJess(), RockMatrixRAF0720Ext::FillJess(), Multiply(), StatsLikelihood(), and Subtract().

00037 { return fSpectrum; };

Double_t NuMatrix2D::StatsLikelihood ( const NuMatrix2D with  )  const [virtual]

Compares two 2D histograms and returns the log-likelihood difference.

Implements NuMatrix.

Definition at line 97 of file NuMatrix2D.cxx.

References fSpectrum, NuUtilities::LogLikelihood(), and Spectrum().

00098 {
00099   // Do the same as the 1D, but over all bins
00100   Double_t like = 0.0;
00101 
00102   //Aim to minimise -2lnL. That's what I'm returning.
00103   for (Int_t i=1; i<= fSpectrum->GetNbinsX(); ++i)
00104   {
00105     for (Int_t j=1; j <= fSpectrum->GetNbinsY(); ++j)
00106     {
00107       //Bizarre limits because root histograms are silly
00108       Double_t mnu = fSpectrum->GetBinContent(i, j);
00109       Double_t dnu = with->Spectrum()->GetBinContent(i, j);
00110 
00111       like += NuUtilities::LogLikelihood(dnu,mnu);
00112     }
00113   }
00114 
00115   return like;
00116 }

Double_t NuMatrix2D::StatsLikelihood ( const NuMatrix with  )  const

Checks the passed object is a NuMatrix2D then returns the log-likelihood difference.

Definition at line 80 of file NuMatrix2D.cxx.

References Msg::kWarning, and MSG.

00081 {
00082   // Convert the NuMatrix to a NuMatrix2D
00083   const NuMatrix2D *other = dynamic_cast<const NuMatrix2D*>(with);
00084   if (other == 0) {
00085     MSG("NuMatrix2D",Msg::kWarning) << "Attempting to compare a NuMatrix2D to something other than a NuMatrix2D" << endl;
00086     return -1;
00087   }
00088 
00089   // // Do the statistical comparison
00090   // MSG("NuMatrix2D",Msg::kError) << "Comparing statistical likelihood - but function not implemented" << endl;
00091   // return 0;
00092   return this->StatsLikelihood(other);
00093 }

void NuMatrix2D::Subtract ( const NuMatrix2D correction  )  [virtual]

Implements NuMatrix.

Definition at line 266 of file NuMatrix2D.cxx.

References fSpectrum, and Spectrum().

00267 {
00268   fSpectrum->Add(with.Spectrum(), -1.0);
00269 }

void NuMatrix2D::Subtract ( const NuMatrix correction  )  [virtual]

Definition at line 253 of file NuMatrix2D.cxx.

References Msg::kWarning, and MSG.

00254 {
00255   // Convert the NuMatrix to a NuMatrix1D
00256   const NuMatrix2D *other = dynamic_cast<const NuMatrix2D*>(&with);
00257   if (other == 0) {
00258     MSG("NuMatrix2D",Msg::kWarning) << "Attempting to subtract a NuMatrix2D to something other than a NuMatrix2D" << endl;
00259   }
00260 
00261   this->Subtract(*other);
00262 }

void NuMatrix2D::TrueToReco ( const TH2D &  correction  )  [virtual]

Implements NuMatrix.

Definition at line 281 of file NuMatrix2D.cxx.

References Msg::kWarning, and MSG.

00282 {
00283   MSG("NuMatrix2D",Msg::kWarning) << "Base NuMatrix2D cannot True->Reco" << endl;
00284 }

Int_t NuMatrix2D::Write ( const TString &  name  )  const [virtual]

Writes to the current file.

Implements NuMatrix.

Definition at line 314 of file NuMatrix2D.cxx.

References fSpectrum.

Referenced by RockMatrixRAF0720Std::Write(), RockMatrixRAF0720Eonly::Write(), and RockMatrixRAF0720Ext::Write().

00315 {
00316   if (fSpectrum) {
00317     if (name == "")
00318     {
00319       return fSpectrum->Write();
00320     } else {
00321       return fSpectrum->Write(name);
00322     }
00323   } else {
00324     return 0;
00325   }
00326 }


Member Data Documentation

TH2D* NuMatrix2D::fSpectrum [protected]

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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1