NuFCGridPointNSINubar 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 <NuFCGridPointNSINubar.h>

List of all members.

Public Member Functions

 NuFCGridPointNSINubar (Double_t epsilon, Double_t dm2, const NuMatrixSpectrum &ndNQData, const NuMatrixSpectrum &ndPQData, const NuMMHelperCPT &helper)
virtual ~NuFCGridPointNSINubar ()
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

 NuFCGridPointNSINubar (const NuFCGridPointNSINubar &)
NuFCGridPointNSINubaroperator= (const NuFCGridPointNSINubar &)
 ClassDef (NuFCGridPointNSINubar, 0)

Private Attributes

Double_t fepsilon
 The grid point this class is evaluating.
Double_t fdm2
Double_t fsin2
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.1
Date:
Date
2011/03/29 04:11:53

Created on: Sat Aug 16, 2008

Definition at line 34 of file NuFCGridPointNSINubar.h.


Constructor & Destructor Documentation

NuFCGridPointNSINubar::NuFCGridPointNSINubar ( Double_t  epsilon,
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 NuFCGridPointNSINubar.cxx.

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

00030   : fepsilon(epsilon),
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   fmmPars.Sn2Bar(1.0);
00049 
00050   // Set the neutrino parameters
00051   fmmPars.Dm2Bar(fdm2);
00052   fmmPars.Epsilon(fepsilon);
00053   // Fix everything except dm2, eps fitting
00054   fmmPars.FixNorm();
00055   fmmPars.FixShwScale();
00056   fmmPars.FixNCBackground();
00057   fmmPars.FixDm2();
00058   fmmPars.FixSn2();
00059   fmmPars.FixSn2Bar();
00060 
00061   // Set up the random number generator
00062   fRandy = new TRandom3(0);
00063   
00064   // Load the configuration
00065   NuFCConfig &cfg = NuFCConfig::GetConfig();
00066   // Set up the experiment factory... if we want to
00067 
00068   // We always use the experiment factory now
00069   string near_events = cfg.GetEventsND();
00070   string far_events = cfg.GetEventsFD();
00071   string tau_events = cfg.GetEventsTau();
00072   fExperimentFactory = new NuFCExperimentFactory(fRandy, near_events, far_events, tau_events);
00073   
00074   // Turn off systematics if we've said we don't want them
00075   if (cfg.Systematics() == false) fExperimentFactory->NoSystematics();
00076   
00077   // Are we doing a one-parameter fit?
00078   if (cfg.FixedDm2()) {
00079     fmmPars.FixDm2Bar();
00080   }
00081 }

NuFCGridPointNSINubar::~NuFCGridPointNSINubar (  )  [virtual]

Definition at line 85 of file NuFCGridPointNSINubar.cxx.

References ffdPredictionNQ, and ffdPredictionPQ.

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

NuFCGridPointNSINubar::NuFCGridPointNSINubar ( const NuFCGridPointNSINubar  )  [private]

Member Function Documentation

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

Call if you want to write out every experiment.

Definition at line 83 of file NuFCGridPointNSINubar.h.

References fArchive, and fArchiveFilename.

00083                                          {
00084     fArchiveFilename = filename;
00085     fArchive = true;
00086   }

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

Definition at line 88 of file NuFCGridPointNSINubar.h.

References fArchiveFilename.

00088                                      {
00089     fArchiveFilename = filename;
00090   }

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

Retrieves the far antineutrino prediction.

Definition at line 170 of file NuFCGridPointNSINubar.cxx.

References err(), and ffdPredictionPQ.

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

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

Returns the list of Delta Chi2 values.

Definition at line 60 of file NuFCGridPointNSINubar.h.

References fdeltaChi2.

00060 { return fdeltaChi2; }

const NuMatrixSpectrum & NuFCGridPointNSINubar::GetNuSpectrum (  ) 

Retrieves the far neutrino prediction.

Definition at line 184 of file NuFCGridPointNSINubar.cxx.

References err(), and ffdPredictionPQ.

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

const NuMMParameters& NuFCGridPointNSINubar::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 65 of file NuFCGridPointNSINubar.h.

References fmmPars.

00065 { return fmmPars; }

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

Generates far detector data, by extrapolating the near detector.

Definition at line 120 of file NuFCGridPointNSINubar.cxx.

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

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

void NuFCGridPointNSINubar::Run ( UInt_t  num  ) 

Runs a specified number of experiments.

Definition at line 220 of file NuFCGridPointNSINubar.cxx.

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

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

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

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

Definition at line 200 of file NuFCGridPointNSINubar.cxx.

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

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

void NuFCGridPointNSINubar::SetPars ( const NuMMParameters pars  ) 

Sets the fitting parameters for this fitter to use.

Definition at line 285 of file NuFCGridPointNSINubar.cxx.

References fmmPars.

00286 {
00287     fmmPars = pars;    
00288 }

void NuFCGridPointNSINubar::SetRandom ( TRandom3 *  ranGen  ) 

Sets the random number generator for the fitting to use.

Definition at line 154 of file NuFCGridPointNSINubar.cxx.

References fRandy.

00155 {
00156   // Reassign our random number generator, deleting if needed
00157   if (fRandy) delete fRandy;
00158   fRandy = ranGen;
00159 }

void NuFCGridPointNSINubar::SetSeed ( UInt_t  seed  ) 

Sets the seed that the internal random number generator uses.

Definition at line 163 of file NuFCGridPointNSINubar.cxx.

References fRandy.

00164 {
00165   fRandy->SetSeed(seed);
00166 }

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

Uses an already existing far detector spectrum for far data.

Definition at line 102 of file NuFCGridPointNSINubar.cxx.

References ffdPredictionNQ, and ffdPredictionPQ.

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


Member Data Documentation

TString NuFCGridPointNSINubar::chifile [private]

Definition at line 126 of file NuFCGridPointNSINubar.h.

Referenced by Run(), and SetOutFiles().

Do we want to archive every experiment?

Definition at line 121 of file NuFCGridPointNSINubar.h.

Referenced by AlwaysArchive(), and Run().

Definition at line 122 of file NuFCGridPointNSINubar.h.

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

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

Definition at line 104 of file NuFCGridPointNSINubar.h.

Referenced by GetChi2(), and Run().

Double_t NuFCGridPointNSINubar::fdm2 [private]

Definition at line 99 of file NuFCGridPointNSINubar.h.

Referenced by NuFCGridPointNSINubar().

Double_t NuFCGridPointNSINubar::fepsilon [private]

The grid point this class is evaluating.

Definition at line 99 of file NuFCGridPointNSINubar.h.

Referenced by NuFCGridPointNSINubar().

Definition at line 124 of file NuFCGridPointNSINubar.h.

Referenced by NuFCGridPointNSINubar(), and Run().

Pointer to FD neutrino data.

Definition at line 106 of file NuFCGridPointNSINubar.h.

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

Pointer to FD antineutrino data.

Definition at line 108 of file NuFCGridPointNSINubar.h.

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

Storage to the helper file class.

Definition at line 102 of file NuFCGridPointNSINubar.h.

Referenced by PredictSpectrum(), and Run().

Standard fitting parameters to use.

Definition at line 115 of file NuFCGridPointNSINubar.h.

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

ND neutrino spectrum.

Definition at line 110 of file NuFCGridPointNSINubar.h.

Referenced by PredictSpectrum(), and Run().

ND antineutrino spectrum.

Definition at line 112 of file NuFCGridPointNSINubar.h.

Referenced by PredictSpectrum(), and Run().

TRandom3* NuFCGridPointNSINubar::fRandy [private]

Random generator.

Definition at line 118 of file NuFCGridPointNSINubar.h.

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

Double_t NuFCGridPointNSINubar::fsin2 [private]

Definition at line 99 of file NuFCGridPointNSINubar.h.

TString NuFCGridPointNSINubar::minfile [private]

Definition at line 127 of file NuFCGridPointNSINubar.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