NuFCDelegateWriterLegacy Class Reference

#include <NuFCDelegate.h>

Inheritance diagram for NuFCDelegateWriterLegacy:
NuFCDelegate

List of all members.

Public Member Functions

 NuFCDelegateWriterLegacy (const NuFCRunner &runner, Int_t cachesize=100)
void SetChi2File (TString filename)
 Called to set the output file for Delta Chi2.
void SetFitPointFile (TString filename)
 Called to set the output file for Delta Chi2.
void GotDeltaChi2 (const NuMMParameters &bestFit, Double_t deltaChi2)
 Called when we have the final answer.
void StartRunning (Int_t experiments)
 Called to start running.
void EndRunning (void)
 Called when we have all answers.
UInt_t WriteCache (void)
 Forces writing of the cache.

Private Attributes

UInt_t fCacheSize
 How many results to cache between writes.
std::vector< ResultfResults
 A vector of stored results.
TString fFilenameChi2
 The filename of the chi2 results.
TString fFilenameMinimum

Detailed Description

Definition at line 131 of file NuFCDelegate.h.


Constructor & Destructor Documentation

NuFCDelegateWriterLegacy::NuFCDelegateWriterLegacy ( const NuFCRunner runner,
Int_t  cachesize = 100 
)

Definition at line 324 of file NuFCDelegate.cxx.

00325   : NuFCDelegate(runner), fCacheSize(cachesize)
00326 {
00327   
00328 }


Member Function Documentation

void NuFCDelegateWriterLegacy::EndRunning ( void   )  [virtual]

Called when we have all answers.

Reimplemented from NuFCDelegate.

Definition at line 366 of file NuFCDelegate.cxx.

References fResults, and WriteCache().

00367 {
00368   if (fResults.size() > 0) WriteCache();
00369 }

void NuFCDelegateWriterLegacy::GotDeltaChi2 ( const NuMMParameters bestFit,
Double_t  deltaChi2 
) [virtual]

Called when we have the final answer.

Reimplemented from NuFCDelegate.

Definition at line 332 of file NuFCDelegate.cxx.

References NuMMParameters::Dm2Bar(), fCacheSize, fResults, NuMMParameters::Sn2Bar(), and WriteCache().

00333 {
00334   // Store this result in the result list
00335   fResults.push_back(Result(deltaChi2, bestFit.Dm2Bar(), bestFit.Sn2Bar()));  
00336   
00337   // If we have more than fCacheSize entries, write these
00338   if (fResults.size() > fCacheSize) WriteCache();
00339 }

void NuFCDelegateWriterLegacy::SetChi2File ( TString  filename  )  [inline]

Called to set the output file for Delta Chi2.

Definition at line 146 of file NuFCDelegate.h.

References fFilenameChi2.

00146 { fFilenameChi2 = filename; }

void NuFCDelegateWriterLegacy::SetFitPointFile ( TString  filename  )  [inline]

Called to set the output file for Delta Chi2.

Definition at line 149 of file NuFCDelegate.h.

References fFilenameMinimum.

00149 { fFilenameMinimum = filename; }

void NuFCDelegateWriterLegacy::StartRunning ( Int_t  experiments  )  [virtual]

Called to start running.

Reimplemented from NuFCDelegate.

Definition at line 343 of file NuFCDelegate.cxx.

References fFilenameChi2, fFilenameMinimum, Plot::Format(), and header.

00344 {
00345   // Form a 'header' line that gives a timestamp
00346   TString header = "# Running " + TString::Format("%d", experiments) + " experiments. ";
00347   TDatime dt;
00348   header += dt.AsString();
00349   
00350   if (!fFilenameChi2.IsNull()) {
00351     ofstream out(fFilenameChi2, ios_base::app);
00352     out << header << endl;
00353     out.close();
00354   }
00355   
00356   if (!fFilenameMinimum.IsNull()) {
00357     ofstream out(fFilenameMinimum, ios_base::app);    
00358     out << header << endl;    
00359     out.close();
00360   }
00361 }

UInt_t NuFCDelegateWriterLegacy::WriteCache ( void   ) 

Forces writing of the cache.

Definition at line 373 of file NuFCDelegate.cxx.

References fFilenameChi2, fFilenameMinimum, Plot::Format(), fResults, it, Msg::kInfo, MSG, and size.

Referenced by EndRunning(), and GotDeltaChi2().

00374 {
00375   UInt_t size = fResults.size();
00376   if (size == 0) return 0;
00377   
00378   MSG("NuFCDelegateWriterLegacy",Msg::kInfo) << "Writing " << size << " cached results to files." << endl;
00379   // TString fFilenameChi2;
00380   // TString fFilenameMinimum;
00381   
00382   // cout  << "Running Write routine " << endl
00383   //   << fFilenameChi2 << endl
00384   //   << fFilenameMinimum << endl;
00385   // Do the Chi2 file
00386   if (!fFilenameChi2.IsNull()) {
00387     ofstream out(fFilenameChi2, ios_base::app);
00388     
00389     // For each results,
00390     for (vector<Result>::const_iterator it = fResults.begin(); it != fResults.end(); ++it)
00391     {
00392       TString chi2 = TString::Format("%.5f", it->chi2);
00393       // cout << "Writing \"" << chi2 << "\"" << endl;
00394       out << chi2 << "\n";
00395     }
00396     out.close();
00397   }
00398   
00399   // Do the grid minimum file
00400   if (!fFilenameMinimum.IsNull()) {
00401     ofstream out(fFilenameMinimum, ios_base::app);    
00402     
00403     // For each results,
00404     for (vector<Result>::const_iterator it = fResults.begin(); it != fResults.end(); ++it)
00405     {
00406       TString dm2bar = TString::Format("%.5f\t%.5f", it->dm2bar, it->sn2bar);
00407       // cout << "Writing \"" << dm2bar << "\"" << endl;
00408       out << dm2bar << "\n";
00409     }
00410     out.close();
00411   }
00412   
00413   // Clear the results list
00414   fResults.clear();
00415   return size;
00416 }


Member Data Documentation

How many results to cache between writes.

Definition at line 134 of file NuFCDelegate.h.

Referenced by GotDeltaChi2().

The filename of the chi2 results.

Definition at line 139 of file NuFCDelegate.h.

Referenced by SetChi2File(), StartRunning(), and WriteCache().

Definition at line 140 of file NuFCDelegate.h.

Referenced by SetFitPointFile(), StartRunning(), and WriteCache().

A vector of stored results.

Reimplemented from NuFCDelegate.

Definition at line 136 of file NuFCDelegate.h.

Referenced by EndRunning(), GotDeltaChi2(), and WriteCache().


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

Generated on 22 Jul 2018 for loon by  doxygen 1.6.1