OscFit::DataInterface Class Reference

#include <DataInterface.h>

List of all members.

Public Member Functions

void LoadData (Experiment_t experiment, RunType_t runtype, Sample_t sample, OscType_t osctype, const char *filename)
DataMakeData (Experiment_t experiment, RunType_t runtype, Sample_t sample, OscType_t osctype)
DataGetData (RunType_t runtype, Sample_t sample, OscType_t osctype)
Bool_t TouchData (RunType_t runtype, Sample_t sample)

Static Public Member Functions

static DataInterfaceInstance ()
static int GetIndex (RunType_t runtype, Sample_t sample, OscType_t osctype)

Private Member Functions

 DataInterface ()
 ~DataInterface ()
void CleanUp ()

Private Attributes

std::map< int, Data * > fDataMap
Experiment_t fExperiment

Detailed Description

Definition at line 12 of file DataInterface.h.


Constructor & Destructor Documentation

DataInterface::DataInterface (  )  [private]

Definition at line 24 of file DataInterface.cxx.

References fExperiment, and OscFit::kUnknownExperiment.

Referenced by Instance().

00025 {
00026   fExperiment = kUnknownExperiment;
00027 }

DataInterface::~DataInterface (  )  [private]

Definition at line 29 of file DataInterface.cxx.

References CleanUp().

00030 {
00031   this->CleanUp();
00032 }


Member Function Documentation

void DataInterface::CleanUp (  )  [private]

Definition at line 179 of file DataInterface.cxx.

References fDataMap.

Referenced by ~DataInterface().

00180 {
00181   std::cout << " *** DataInterface::CleanUp() *** " << std::endl;
00182   
00183   std::map<Int_t,Data*>::iterator Iter = fDataMap.begin();
00184 
00185   for( ; Iter!=fDataMap.end(); Iter++ ){
00186     Data* myData = Iter->second;
00187     if( myData ) delete myData;
00188   }
00189 
00190   fDataMap.clear();
00191 }

Data * DataInterface::GetData ( RunType_t  runtype,
Sample_t  sample,
OscType_t  osctype 
)

Definition at line 150 of file DataInterface.cxx.

References fDataMap, and GetIndex().

Referenced by TouchData().

00151 {
00152   Int_t index = DataInterface::GetIndex( runtype, sample, osctype );
00153 
00154   if( index<0 ) return 0;
00155 
00156   Data* myData = 0;
00157 
00158   std::map<Int_t,Data*>::iterator myEntry = fDataMap.find(index);
00159 
00160   if( myEntry != fDataMap.end() ){
00161     myData = myEntry->second;
00162   }
00163   else{
00164     // couldn't find data set
00165   }
00166 
00167   return myData;
00168 }

Int_t DataInterface::GetIndex ( RunType_t  runtype,
Sample_t  sample,
OscType_t  osctype 
) [static]

Definition at line 34 of file DataInterface.cxx.

References OscFit::kAtNu, OscFit::kCosmic, OscFit::kCV, OscFit::kData, OscFit::kFHC, OscFit::kNonOsc, OscFit::kNoOsc, OscFit::kNue2Nutau, OscFit::kNumu2Nue, OscFit::kNumu2Nutau, OscFit::kRHC, and OscFit::kRock.

Referenced by GetData(), and LoadData().

00035 {
00036   Int_t index = -1;
00037 
00038   if( runtype==kAtNu && sample==kCV     && osctype==kNoOsc      ) index = 11;
00039   if( runtype==kAtNu && sample==kCV     && osctype==kNumu2Nutau ) index = 12;
00040   if( runtype==kAtNu && sample==kCV     && osctype==kNumu2Nue   ) index = 13;
00041   if( runtype==kAtNu && sample==kCV     && osctype==kNue2Nutau  ) index = 14;
00042   if( runtype==kAtNu && sample==kRock   && osctype==kNoOsc      ) index = 21;
00043   if( runtype==kAtNu && sample==kRock   && osctype==kNumu2Nutau ) index = 22;
00044   if( runtype==kAtNu && sample==kRock   && osctype==kNumu2Nue   ) index = 23;
00045   if( runtype==kAtNu && sample==kRock   && osctype==kNue2Nutau  ) index = 24;
00046   if( runtype==kAtNu && sample==kData   && osctype==kNonOsc     ) index = 1;
00047   if( runtype==kAtNu && sample==kCosmic && osctype==kNonOsc     ) index = 2;
00048 
00049   if( runtype==kFHC  && sample==kCV     && osctype==kNoOsc      ) index = 1011;
00050   if( runtype==kFHC  && sample==kCV     && osctype==kNumu2Nutau ) index = 1012;
00051   if( runtype==kFHC  && sample==kCV     && osctype==kNumu2Nue   ) index = 1013;
00052   if( runtype==kFHC  && sample==kCV     && osctype==kNue2Nutau  ) index = 1014;
00053   if( runtype==kFHC  && sample==kRock   && osctype==kNoOsc      ) index = 1021;
00054   if( runtype==kFHC  && sample==kRock   && osctype==kNumu2Nutau ) index = 1022;
00055   if( runtype==kFHC  && sample==kRock   && osctype==kNumu2Nue   ) index = 1023;
00056   if( runtype==kFHC  && sample==kRock   && osctype==kNue2Nutau  ) index = 1024;
00057   if( runtype==kFHC  && sample==kData   && osctype==kNonOsc     ) index = 1001;
00058   if( runtype==kFHC  && sample==kCosmic && osctype==kNonOsc     ) index = 1002;  
00059 
00060   if( runtype==kRHC  && sample==kCV     && osctype==kNoOsc      ) index = 2011;
00061   if( runtype==kRHC  && sample==kCV     && osctype==kNumu2Nutau ) index = 2012;
00062   if( runtype==kRHC  && sample==kCV     && osctype==kNumu2Nue   ) index = 2013;
00063   if( runtype==kRHC  && sample==kCV     && osctype==kNue2Nutau  ) index = 2014;
00064   if( runtype==kRHC  && sample==kRock   && osctype==kNoOsc      ) index = 2021;
00065   if( runtype==kRHC  && sample==kRock   && osctype==kNumu2Nutau ) index = 2022;
00066   if( runtype==kRHC  && sample==kRock   && osctype==kNumu2Nue   ) index = 2023;
00067   if( runtype==kRHC  && sample==kRock   && osctype==kNue2Nutau  ) index = 2024;
00068   if( runtype==kRHC  && sample==kData   && osctype==kNonOsc     ) index = 2001;
00069   if( runtype==kRHC  && sample==kCosmic && osctype==kNonOsc     ) index = 2002;
00070 
00071   return index;
00072 }

DataInterface * DataInterface::Instance (  )  [static]

Definition at line 15 of file DataInterface.cxx.

References DataInterface().

Referenced by OscFit::TemplateMaker::BuildTemplates(), and OscFit::TemplateMaker::MakeTemplate().

00016 {
00017   if( !fgDataInterface ){
00018     fgDataInterface = new DataInterface();
00019   }
00020 
00021   return fgDataInterface;
00022 }

void DataInterface::LoadData ( Experiment_t  experiment,
RunType_t  runtype,
Sample_t  sample,
OscType_t  osctype,
const char *  filename 
)

Definition at line 104 of file DataInterface.cxx.

References OscFit::Data::AddFile(), OscFit::AsString(), fDataMap, fExperiment, GetIndex(), OscFit::kUnknownExperiment, and MakeData().

00105 {
00106   std::cout << " *** DataInterface::LoadData(...) *** " << std::endl;
00107 
00108   std::cout << "   Loading: [" << AsString(experiment) << "][" << AsString(runtype) << "][" << AsString(sample) << "][" << AsString(osctype) << "]" << std::endl;
00109 
00111   // if( gSystem->AccessPathName(filename) ) { // returns kTrue if non-existent
00112   //   std::cout << "   Warning: failed to find input file " << std::endl;
00113   //   return;
00114   // }
00115 
00116   if( fExperiment != kUnknownExperiment 
00117    && fExperiment != experiment ){
00118     std::cout << "   Warning: already loaded data for " << AsString(fExperiment) << std::endl;
00119     return;
00120   }
00121 
00122   std::cout << "   Loading: " << filename << std::endl;
00123 
00124   Int_t index = DataInterface::GetIndex( runtype, sample, osctype );
00125 
00126   if( index<0 ) return;
00127 
00128   Data* myData = 0;
00129 
00130   std::map<Int_t,Data*>::iterator myEntry = fDataMap.find(index);
00131 
00132   if( myEntry == fDataMap.end() ){
00133     myData = MakeData( experiment, runtype, sample, osctype );
00134     if( myData ){
00135       fDataMap.insert( std::pair<int,Data*>(index,myData) );
00136       fExperiment = experiment;
00137     }
00138   }
00139   else{
00140     myData = myEntry->second;
00141   }
00142 
00143   if( myData ){
00144     myData->AddFile( filename );
00145   }
00146 
00147   return;
00148 }

Data * DataInterface::MakeData ( Experiment_t  experiment,
RunType_t  runtype,
Sample_t  sample,
OscType_t  osctype 
)

Definition at line 74 of file DataInterface.cxx.

References OscFit::AsString(), OscFit::kAtNu, OscFit::kFHC, OscFit::kLBNE, OscFit::kMINOS, and OscFit::kRHC.

Referenced by LoadData().

00075 {
00076   Data* myData = 0;
00077 
00078   if( experiment==kMINOS && runtype==kAtNu ) 
00079     myData = new AtmosData( sample, osctype );
00080 
00081   if( experiment==kLBNE  && runtype==kAtNu  ) 
00082     myData = new ArgonData( runtype, sample, osctype );
00083 
00084   if( experiment==kLBNE  && runtype==kFHC ) 
00085     myData = new ArgonData( runtype, sample, osctype );
00086 
00087   if( experiment==kLBNE  && runtype==kRHC ) 
00088     myData = new ArgonData( runtype, sample, osctype );
00089 
00090   //
00091   // Other data go here
00092   //
00093 
00094   if( myData==0 ){
00095     std::cout << "  DataInterface::MakeData(" << AsString(experiment) << "," << AsString(runtype) << "," << AsString(sample) << "," << AsString(osctype) << ")" << std::endl;
00096     std::cout << "   Warning: invalid data type " << std::endl;
00097   }
00098 
00099   assert( myData ); // bail out if data type is invalid
00100 
00101   return myData;
00102 }

Bool_t DataInterface::TouchData ( RunType_t  runtype,
Sample_t  sample 
)

Definition at line 170 of file DataInterface.cxx.

References GetData(), OscFit::kNonOsc, OscFit::kNoOsc, OscFit::kNue2Nutau, OscFit::kNumu2Nue, and OscFit::kNumu2Nutau.

00171 {
00172   return ( GetData( runtype, sample, OscFit::kNoOsc      )
00173         || GetData( runtype, sample, OscFit::kNumu2Nue   )
00174         || GetData( runtype, sample, OscFit::kNumu2Nutau )
00175         || GetData( runtype, sample, OscFit::kNue2Nutau  )
00176         || GetData( runtype, sample, OscFit::kNonOsc     ) ); 
00177 }


Member Data Documentation

std::map<int,Data*> OscFit::DataInterface::fDataMap [private]

Definition at line 37 of file DataInterface.h.

Referenced by CleanUp(), GetData(), and LoadData().

Definition at line 39 of file DataInterface.h.

Referenced by DataInterface(), and LoadData().


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

Generated on 24 Jul 2018 for loon by  doxygen 1.6.1