NuFCGridPoint Class Reference

Controls the Feldman-cousins process for a single gridpoint Currently only works with the antineutrino oscillation fitting, though this should be relatively easy to change. More...

#include <NuFCGridPoint.h>

List of all members.

Public Member Functions

 NuFCGridPoint (Double_t sin, Double_t dm2, const NuMatrixSpectrum &ndNQData, const NuMatrixSpectrum &ndPQData, const NuMMHelperCPT &helper)
virtual ~NuFCGridPoint ()
void PredictSpectrum (Double_t POT)
 Generates far detector data, by extrapolating the near detector.
void UsePrediction (const NuMatrixSpectrum &fdNQData, const NuMatrixSpectrum &fdPQData)
 Uses an already existing far detector spectrum for far data.
void Run (UInt_t num)
 Runs a specified number of experiments.
const vector< Double_t > & GetChi2 ()
 Returns the list of Delta Chi2 values.
const NuMMParametersGetPars ()
void SetPars (const NuMMParameters &pars)
 Sets the fitting parameters for this fitter to use.
void SetRandom (TRandom3 *ranGen)
 Sets the random number generator for the fitting to use.
void SetSeed (UInt_t seed)
 Sets the seed that the internal random number generator uses.
const NuMatrixSpectrumGetBarSpectrum ()
 Retrieves the far antineutrino prediction.
const NuMatrixSpectrumGetNuSpectrum ()
 Retrieves the far neutrino prediction.
void SetOutFiles (TString _chifile, TString _minfile)
 Set filenames for direct output of experiments rather than through python interface.
void AlwaysArchive (std::string filename)
 Call if you want to write out every experiment.
void ArchiveTo (std::string filename)

Private Member Functions

 NuFCGridPoint (const NuFCGridPoint &)
NuFCGridPointoperator= (const NuFCGridPoint &)
 ClassDef (NuFCGridPoint, 0)

Private Attributes

Double_t fsin2
 The grid point this class is evaluating.
Double_t fdm2
Double_t fepsilon
NuMMHelperCPT fHelper
 Storage to the helper file class.
std::vector< Double_t > fdeltaChi2
NuMatrixSpectrumffdPredictionNQ
 Pointer to FD neutrino data.
NuMatrixSpectrumffdPredictionPQ
 Pointer to FD antineutrino data.
NuMatrixSpectrum fndNQ
 ND neutrino spectrum.
NuMatrixSpectrum fndPQ
 ND antineutrino spectrum.
NuMMParameters fmmPars
 Standard fitting parameters to use.
TRandom3 * fRandy
 Random generator.
Bool_t fArchive
 Do we want to archive every experiment?
std::string fArchiveFilename
NuFCExperimentFactoryfExperimentFactory
TString chifile
TString minfile

Detailed Description

Controls the Feldman-cousins process for a single gridpoint Currently only works with the antineutrino oscillation fitting, though this should be relatively easy to change.

Author:
Nick Devenish, Last checkin
Author
zisvan
Version:
Revision
1.10
Date:
Date
2011/03/29 02:38:44

Created on: Sat Aug 16, 2008

Definition at line 34 of file NuFCGridPoint.h.


Constructor & Destructor Documentation

NuFCGridPoint::NuFCGridPoint ( Double_t  sin,
Double_t  dm2,
const NuMatrixSpectrum ndNQData,
const NuMatrixSpectrum ndPQData,
const NuMMHelperCPT helper 
)

Initisalises the class.

Parameters:
sin The value of sin22theta (or bar) for the grid point that wishes to be evaluated.
dm2 The corresponding value for dm2.
ndNQData The Near detector neutrino spectrum
ndPQData The Near detector antineutrino spectrum
helper The helper file object to use.

Definition at line 28 of file NuFCGridPoint.cxx.

References NuMMParameters::Dm2(), NuMMParameters::Dm2Bar(), MuELoss::e, fdm2, fExperimentFactory, NuMMParameters::FixDm2(), NuFCConfig::FixedSin(), NuMMParameters::FixNCBackground(), NuMMParameters::FixNorm(), NuMMParameters::FixShwScale(), NuMMParameters::FixSn2(), NuMMParameters::FixSn2Bar(), fmmPars, fRandy, fsin2, NuFCConfig::GetConfig(), NuFCConfig::GetEventsFD(), NuFCConfig::GetEventsND(), NuFCConfig::GetEventsTau(), NuFCExperimentFactory::NoSystematics(), NuMMParameters::Sn2(), NuMMParameters::Sn2Bar(), and NuFCConfig::Systematics().

00030   : fsin2(sin),
00031     fdm2(dm2),
00032     fHelper(helper),
00033     ffdPredictionNQ(0),
00034     ffdPredictionPQ(0),
00035     fndNQ(ndNQData),
00036     fndPQ(ndPQData),
00037     fRandy(0),
00038     fArchive(false),
00039     fArchiveFilename("archive.root"),
00040     fExperimentFactory(0),
00041     chifile(""),
00042     minfile("")
00043 { 
00044   // Initialise the NuMMParameters object
00045   // Use default parameters for neutrinos, even though this is bad
00046   fmmPars.Dm2(2.43e-3);
00047   fmmPars.Sn2(1.0);
00048 
00049   // Set the neutrino parameters
00050   fmmPars.Dm2Bar(fdm2);
00051   fmmPars.Sn2Bar(fsin2);
00052   // Fix everything except antineutrino fitting
00053   fmmPars.FixNorm();
00054   fmmPars.FixShwScale();
00055   fmmPars.FixNCBackground();
00056   fmmPars.FixDm2();
00057   fmmPars.FixSn2();
00058 
00059   // Set up the random number generator
00060   fRandy = new TRandom3(0);
00061   
00062   // Load the configuration
00063   NuFCConfig &cfg = NuFCConfig::GetConfig();
00064   // Set up the experiment factory... if we want to
00065 
00066   // We always use the experiment factory now
00067   string near_events = cfg.GetEventsND();
00068   string far_events = cfg.GetEventsFD();
00069   string tau_events = cfg.GetEventsTau();
00070   fExperimentFactory = new NuFCExperimentFactory(fRandy, near_events, far_events, tau_events);
00071   
00072   // Turn off systematics if we've said we don't want them
00073   if (cfg.Systematics() == false) fExperimentFactory->NoSystematics();
00074   
00075   // Are we doing a one-parameter fit?
00076   if (cfg.FixedSin()) {
00077     fmmPars.FixSn2Bar();
00078   }
00079 }

NuFCGridPoint::~NuFCGridPoint (  )  [virtual]

Definition at line 83 of file NuFCGridPoint.cxx.

References ffdPredictionNQ, and ffdPredictionPQ.

00084 {
00085   // Delete the far detector predictions
00086   if (ffdPredictionNQ) delete ffdPredictionNQ;
00087   if (ffdPredictionPQ) delete ffdPredictionPQ;
00088   ffdPredictionNQ = ffdPredictionPQ = 0;
00089   
00090   // // Delete the near detector spectra
00091   // if (fndNQ) delete fndNQ;
00092   // if (fndPQ) delete fndPQ;
00093   // fndNQ = fndPQ = 0;
00094 
00095 }

NuFCGridPoint::NuFCGridPoint ( const NuFCGridPoint  )  [private]

Member Function Documentation

void NuFCGridPoint::AlwaysArchive ( std::string  filename  )  [inline]

Call if you want to write out every experiment.

Definition at line 81 of file NuFCGridPoint.h.

References fArchive, and fArchiveFilename.

00081                                          {
00082     fArchiveFilename = filename;
00083     fArchive = true;
00084   }

void NuFCGridPoint::ArchiveTo ( std::string  filename  )  [inline]

Definition at line 86 of file NuFCGridPoint.h.

References fArchiveFilename.

00086                                      {
00087     fArchiveFilename = filename;
00088   }

NuFCGridPoint::ClassDef ( NuFCGridPoint  ,
 
) [private]
const NuMatrixSpectrum & NuFCGridPoint::GetBarSpectrum (  ) 

Retrieves the far antineutrino prediction.

Definition at line 167 of file NuFCGridPoint.cxx.

References err(), and ffdPredictionPQ.

00168 {
00169   if (!ffdPredictionPQ) {
00170     // We are backed into a corner... throw an exception as this is
00171     // a better alternative than a segfault!
00172     ostringstream err;
00173     err << "NuFCGridPoint::GetBarSpectrum(): Asking for reference to prediction\n"
00174         << "    before it is calculated. Try calling NuFCGridPoint::PredictSpectrum\n"
00175         << "    or NuFCGridPoint::UsePrediction first.";
00176     throw runtime_error(err.str().c_str());
00177   }
00178    return *ffdPredictionPQ;
00179 }

const vector<Double_t>& NuFCGridPoint::GetChi2 (  )  [inline]

Returns the list of Delta Chi2 values.

Definition at line 58 of file NuFCGridPoint.h.

References fdeltaChi2.

00058 { return fdeltaChi2; }

const NuMatrixSpectrum & NuFCGridPoint::GetNuSpectrum (  ) 

Retrieves the far neutrino prediction.

Definition at line 181 of file NuFCGridPoint.cxx.

References err(), and ffdPredictionPQ.

00182 {
00183   if (!ffdPredictionPQ) {
00184     // Also backed into a corner here. Nothing left but an exception!
00185     ostringstream err;
00186     err << "NuFCGridPoint::GetNuSpectrum(): Asking for reference to prediction\n"
00187         << "    before it is calculated. Try calling NuFCGridPoint::PredictSpectrum\n"
00188         << "    or NuFCGridPoint::UsePrediction first.";
00189     throw runtime_error(err.str().c_str());
00190   }
00191   
00192   return *ffdPredictionPQ;
00193 }

const NuMMParameters& NuFCGridPoint::GetPars (  )  [inline]

Returns the parameters structure that the class is using for fitting. All access should go through this, so that the object cannot be randomly modified.

Definition at line 63 of file NuFCGridPoint.h.

References fmmPars.

00063 { return fmmPars; }

NuFCGridPoint& NuFCGridPoint::operator= ( const NuFCGridPoint  )  [private]
void NuFCGridPoint::PredictSpectrum ( Double_t  POT  ) 

Generates far detector data, by extrapolating the near detector.

Definition at line 118 of file NuFCGridPoint.cxx.

References NuMMParameters::Dm2Bar(), NuMMParameters::Epsilon(), ffdPredictionNQ, ffdPredictionPQ, fHelper, fmmPars, fndNQ, fndPQ, Msg::kInfo, NuMMRunFC::MakeFDPred(), MSG, NuMMRun::QuietModeOn(), and NuMMParameters::Sn2Bar().

00119 {
00120   // We want to make an extrapolation of the near detector data
00121   MSG("NuFCGridPoint", Msg::kInfo) << "Generating Extrapolated Near Detector\n"
00122                                    << "Using Oscillation Parameters sn2bar: " 
00123                                    << fmmPars.Sn2Bar()
00124                                    << ", dm2bar: " << fmmPars.Dm2Bar() 
00125                                    << ", epsilon: " << fmmPars.Epsilon()
00126                                    << endl;
00127   
00128   // Give blank prediction spectra, as we won't be checking the far data
00129   NuMatrixSpectrum blankpot(POT);
00130   // Make the extrapolator
00131   NuMMRunFC mmFakeFar(&fHelper, &fndNQ, &fndPQ, &blankpot, &blankpot);
00132   mmFakeFar.QuietModeOn();
00133   
00134   // Now, grab the extrapolations, and pretend they are far detector data
00135   pair<NuMatrixSpectrum,NuMatrixSpectrum> fakefar = mmFakeFar.MakeFDPred(fmmPars);
00136 
00137   // Tell the user what POT we got out
00138   MSG("NuFCGridPoint", Msg::kInfo) << "Far extrapolation is at POT "
00139     << fakefar.second.GetPOT() << " (" << fakefar.second.Spectrum()->Integral()
00140     << " events)" << endl;
00141 
00142   // Grab a copy of these Spectra
00143   // ffdPredictionNQ = static_cast<TH1*>( fakefar.first.Spectrum()->Clone() );
00144   // ffdPredictionPQ = static_cast<TH1*>( fakefar.second.Spectrum()->Clone() );
00145   ffdPredictionNQ = new NuMatrixSpectrum(fakefar.first);
00146   ffdPredictionPQ = new NuMatrixSpectrum(fakefar.second);
00147 }

void NuFCGridPoint::Run ( UInt_t  num  ) 

Runs a specified number of experiments.

Definition at line 217 of file NuFCGridPoint.cxx.

References NuFCFitter::AlwaysArchive(), NuFCFitter::ArchiveTo(), NuFCFitter::BestFit(), chifile, NuMMParameters::Dm2Bar(), fArchive, fArchiveFilename, fdeltaChi2, fExperimentFactory, ffdPredictionPQ, fHelper, NuFCFitter::Fit(), fmmPars, fndNQ, fndPQ, NuFCExperimentFactory::GenerateNewExperiment(), NuFCExperimentFactory::GetNQSpectrum(), NuFCExperimentFactory::GetNQSpectrumND(), NuMatrix::GetPOT(), NuFCExperimentFactory::GetPQSpectrum(), NuFCExperimentFactory::GetPQSpectrumND(), Msg::kInfo, minfile, MSG, NuFCFitter::SetSilent(), and NuMMParameters::Sn2Bar().

00218 {
00219   ofstream chiout, minout;
00220   bool useFiles = false;
00221   if (!chifile.IsNull()) {
00222     MSG("NuFCGridPoint", Msg::kInfo) << "Opening " << chifile << " and " << minfile << endl;
00223     useFiles = true;
00224     chiout.open(chifile.Data(), ios::app);
00225     minout.open(minfile.Data(), ios::app);
00226   }
00227   
00228   for (UInt_t i = 0; i < number; i++)
00229   {
00230     // Say we are starting!
00231     if (!useFiles) {
00232       MSG("NuFCGridPoint", Msg::kInfo) << "Running experiment " << i << endl;
00233     }
00234     
00235     // Create a new experiment
00236     // NuFCExperiment fcexp(i, *ffdPredictionPQ, fRandy);
00237 
00238     // Make a blank extrapolator for predictions
00239     NuMatrixSpectrum blankpot(ffdPredictionPQ->GetPOT());
00240     NuMMRunFC extrapolator(&fHelper, &fndNQ, &fndPQ, &blankpot, &blankpot);
00241     extrapolator.PredictNus(false);
00242     extrapolator.PredictNuBars(true);
00243     extrapolator.QuietModeOn();
00244 
00245     // Generte the fake experiment
00246     fExperimentFactory->GenerateNewExperiment(&extrapolator, fmmPars);
00247     NuFCExperiment fcexp(i, fExperimentFactory->GetNQSpectrum(), fExperimentFactory->GetPQSpectrum());
00248     
00249     // Grab the (possibly shifted) near detector histograms
00250     NuMatrixSpectrum ndNQ = fExperimentFactory->GetNQSpectrumND();
00251     NuMatrixSpectrum ndPQ = fExperimentFactory->GetPQSpectrumND();
00252     
00253     // Create the fitter
00254     NuFCFitter fitter(&fcexp, &fHelper, &ndNQ, &ndPQ, fmmPars);
00255     fitter.SetSilent(useFiles);
00256     
00257     // Do we want to archive every fit?
00258     if (fArchive) fitter.AlwaysArchive(fArchiveFilename);
00259     else fitter.ArchiveTo(fArchiveFilename);
00260     
00261     // Run the fit
00262     Double_t fitDeltachi = fitter.Fit(fmmPars);
00263     
00264     if (useFiles) {
00265       chiout << fitDeltachi << endl;
00266       minout << fitter.BestFit()->Dm2Bar() << "\t" << fitter.BestFit()->Sn2Bar() << endl;
00267     }
00268     
00269     // Store the delta chi2
00270     fdeltaChi2.push_back(fitDeltachi);
00271   }
00272   
00273   if (useFiles) {
00274     MSG("NuFCGridPoint", Msg::kInfo) << "Closing " << chifile << " and " << minfile << endl;
00275     chiout.close();
00276     minout.close();
00277   }  
00278 }

void NuFCGridPoint::SetOutFiles ( TString  _chifile,
TString  _minfile 
)

Set filenames for direct output of experiments rather than through python interface.

Definition at line 197 of file NuFCGridPoint.cxx.

References chifile, Msg::kInfo, minfile, and MSG.

00198 {
00199   if (_chifile.IsNull() && _minfile.IsNull()) {
00200     MSG("NuFCGridPoint",Msg::kInfo) << "Outputing through python interface." << endl;
00201     return;
00202   }
00203   if (_chifile.IsNull() || _minfile.IsNull()) {
00204     MSG("NuFCGridPoint",Msg::kInfo) << "One of the output files is null, so the other is being ignored "
00205     << "(" << _chifile << ", " << _minfile << "). "
00206     << "Outputing through python interface." << endl;
00207     return;
00208   }
00209   
00210   chifile = _chifile;
00211   minfile = _minfile;
00212 }

void NuFCGridPoint::SetPars ( const NuMMParameters pars  ) 

Sets the fitting parameters for this fitter to use.

Definition at line 281 of file NuFCGridPoint.cxx.

References fmmPars.

00282 {
00283     fmmPars = pars;    
00284 }

void NuFCGridPoint::SetRandom ( TRandom3 *  ranGen  ) 

Sets the random number generator for the fitting to use.

Definition at line 151 of file NuFCGridPoint.cxx.

References fRandy.

00152 {
00153   // Reassign our random number generator, deleting if needed
00154   if (fRandy) delete fRandy;
00155   fRandy = ranGen;
00156 }

void NuFCGridPoint::SetSeed ( UInt_t  seed  ) 

Sets the seed that the internal random number generator uses.

Definition at line 160 of file NuFCGridPoint.cxx.

References fRandy.

00161 {
00162   fRandy->SetSeed(seed);
00163 }

void NuFCGridPoint::UsePrediction ( const NuMatrixSpectrum fdNQData,
const NuMatrixSpectrum fdPQData 
)

Uses an already existing far detector spectrum for far data.

Definition at line 100 of file NuFCGridPoint.cxx.

References ffdPredictionNQ, and ffdPredictionPQ.

00102 {
00103   // Delete the far spectra if they exist
00104   if (ffdPredictionNQ) delete ffdPredictionNQ;
00105   if (ffdPredictionPQ) delete ffdPredictionPQ;
00106 
00107   // Make a copy of the passed in data spectra
00108   // this->ffdPredictionNQ = static_cast<TH1*>( fdNQData.Spectrum()->Clone() );
00109   // this->ffdPredictionPQ = static_cast<TH1*>( fdPQData.Spectrum()->Clone() );
00110   // ffdPredictionNQ->SetDirectory(0);
00111   // ffdPredictionPQ->SetDirectory(0);
00112   ffdPredictionNQ = new NuMatrixSpectrum(fdNQData);
00113   ffdPredictionPQ = new NuMatrixSpectrum(fdPQData);
00114 }


Member Data Documentation

TString NuFCGridPoint::chifile [private]

Definition at line 124 of file NuFCGridPoint.h.

Referenced by Run(), and SetOutFiles().

Bool_t NuFCGridPoint::fArchive [private]

Do we want to archive every experiment?

Definition at line 119 of file NuFCGridPoint.h.

Referenced by AlwaysArchive(), and Run().

std::string NuFCGridPoint::fArchiveFilename [private]

Definition at line 120 of file NuFCGridPoint.h.

Referenced by AlwaysArchive(), ArchiveTo(), and Run().

std::vector<Double_t> NuFCGridPoint::fdeltaChi2 [private]

Definition at line 102 of file NuFCGridPoint.h.

Referenced by GetChi2(), and Run().

Double_t NuFCGridPoint::fdm2 [private]

Definition at line 97 of file NuFCGridPoint.h.

Referenced by NuFCGridPoint().

Double_t NuFCGridPoint::fepsilon [private]

Definition at line 97 of file NuFCGridPoint.h.

Definition at line 122 of file NuFCGridPoint.h.

Referenced by NuFCGridPoint(), and Run().

Pointer to FD neutrino data.

Definition at line 104 of file NuFCGridPoint.h.

Referenced by PredictSpectrum(), UsePrediction(), and ~NuFCGridPoint().

Pointer to FD antineutrino data.

Definition at line 106 of file NuFCGridPoint.h.

Referenced by GetBarSpectrum(), GetNuSpectrum(), PredictSpectrum(), Run(), UsePrediction(), and ~NuFCGridPoint().

Storage to the helper file class.

Definition at line 100 of file NuFCGridPoint.h.

Referenced by PredictSpectrum(), and Run().

Standard fitting parameters to use.

Definition at line 113 of file NuFCGridPoint.h.

Referenced by GetPars(), NuFCGridPoint(), PredictSpectrum(), Run(), and SetPars().

ND neutrino spectrum.

Definition at line 108 of file NuFCGridPoint.h.

Referenced by PredictSpectrum(), and Run().

ND antineutrino spectrum.

Definition at line 110 of file NuFCGridPoint.h.

Referenced by PredictSpectrum(), and Run().

TRandom3* NuFCGridPoint::fRandy [private]

Random generator.

Definition at line 116 of file NuFCGridPoint.h.

Referenced by NuFCGridPoint(), SetRandom(), and SetSeed().

Double_t NuFCGridPoint::fsin2 [private]

The grid point this class is evaluating.

Definition at line 97 of file NuFCGridPoint.h.

Referenced by NuFCGridPoint().

TString NuFCGridPoint::minfile [private]

Definition at line 125 of file NuFCGridPoint.h.

Referenced by Run(), and SetOutFiles().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1