NueGenConfig Class Reference

#include <NueGenConfig.h>

List of all members.

Public Types

enum  GenMethod { kFileList = 1, kSetList = 2 }
typedef enum
NueGenConfig::GenMethod 
GCTypes_t

Public Member Functions

 NueGenConfig ()
 NueGenConfig (std::string input)
void ReadInput (std::string input)
bool CheckConfig ()
void Reset ()
bool LoadNextNumberSet (double *num)
double * GetErrors ()
double * GetOscPar ()
int GetDataMethod ()
void SetDataRange (int nuClass, std::string line, GCCompleteSet &set)
void AddInputFile (std::string file)
void SetOffset (int in)
void SetReadNumber (int in)

Private Member Functions

void SetErrorVal (int pos, std::string line)

Private Attributes

int fOffSet
int fReadUntil
int fDataMethod
bool found [6]
std::vector< std::string > files
double fErrors [6]
std::vector< GCCompleteSetEventGroups
double fOscPar [6]

Detailed Description

Definition at line 35 of file NueGenConfig.h.


Member Typedef Documentation


Member Enumeration Documentation

Enumerator:
kFileList 
kSetList 

Definition at line 38 of file NueGenConfig.h.

00038                          {
00039       kFileList = 1,
00040       kSetList  = 2
00041    } GCTypes_t;


Constructor & Destructor Documentation

NueGenConfig::NueGenConfig (  ) 

Definition at line 13 of file NueGenConfig.cxx.

References Reset().

00013                           {
00014   Reset();
00015 }

NueGenConfig::NueGenConfig ( std::string  input  ) 

Definition at line 17 of file NueGenConfig.cxx.

References ReadInput(), and Reset().

00018 {
00019   Reset();
00020   ReadInput(input);
00021 }


Member Function Documentation

void NueGenConfig::AddInputFile ( std::string  file  )  [inline]

Definition at line 58 of file NueGenConfig.h.

References files.

Referenced by NueExpGenerator::Run().

00058 {files.push_back(file);}

bool NueGenConfig::CheckConfig (  ) 

Definition at line 172 of file NueGenConfig.cxx.

References fDataMethod, and found.

Referenced by ReadInput(), and NueExpGenerator::Run().

00172                               {
00173 
00174   if(fDataMethod < 0 || fDataMethod > 2) return false;
00175   if(fDataMethod == 1 || fDataMethod == 0){
00176     for(int i = 0; i < 6; i++) { if(!found[i]) return false; }
00177   }
00178     
00179   return true;
00180 }

int NueGenConfig::GetDataMethod (  )  [inline]

Definition at line 55 of file NueGenConfig.h.

References fDataMethod.

00055 {return fDataMethod;}

double* NueGenConfig::GetErrors ( void   )  [inline]

Definition at line 51 of file NueGenConfig.h.

References fErrors.

Referenced by NueExpGenerator::Run().

00051 { return fErrors;};

double* NueGenConfig::GetOscPar (  )  [inline]

Definition at line 52 of file NueGenConfig.h.

References fOscPar.

Referenced by NueExpGenerator::Run().

00052 { return fOscPar;};

bool NueGenConfig::LoadNextNumberSet ( double *  num  ) 

Definition at line 182 of file NueGenConfig.cxx.

References count, fDataMethod, files, fOffSet, fOscPar, fReadUntil, kFileList, and kSetList.

Referenced by NueExpGenerator::Run().

00183 {
00184   static std::ifstream ins;
00185   static int count = 0;
00186   //  static place pos;
00187 //  std::cout<<"Entering number loader"<<std::endl;
00188 
00189   if(fDataMethod == NueGenConfig::kFileList)
00190   {
00191     std::string dum;
00192     if(count >= fReadUntil && fReadUntil > 0) return false;
00193 
00194     if(!ins.is_open()){
00195         ins.open(files[0].c_str());
00196         int skipped = 0;
00197 
00198         if(fOffSet > 0){
00199            do{
00200              ins>>fOscPar[0]>>fOscPar[1]>>fOscPar[2]>>fOscPar[3];
00201              ins>>num[0]>>num[1]>>num[4]>>num[3]>>num[2]>>dum;
00202              skipped++;
00203            }while(skipped < fOffSet && !ins.eof());
00204 
00205         }
00206       std::cout<<"Reading: "<<fReadUntil<<" skipped: "<<fOffSet<<std::endl;
00207     }
00208     ins>>fOscPar[0]>>fOscPar[1]>>fOscPar[2]>>fOscPar[3];
00209     ins>>num[0]>>num[1]>>num[4]>>num[3]>>num[2]>>dum;
00210     count++;
00211     if(ins.eof()){  ins.close();  return false; }
00212   }
00213   if(fDataMethod == NueGenConfig::kSetList)
00214   {
00215      
00216   }
00217 
00218 
00219 
00220 
00221         
00222 
00223   return true;
00224 }  

void NueGenConfig::ReadInput ( std::string  input  ) 

Definition at line 36 of file NueGenConfig.cxx.

References NueConvention::bnue, CheckConfig(), EventGroups, fDataMethod, files, kFileList, NueConvention::NC, NueConvention::nue, NueConvention::numu, NueConvention::nutau, SetDataRange(), and SetErrorVal().

Referenced by NueGenConfig().

00037 {
00038   std::ifstream stream;
00039   stream.open(input.c_str());
00040   assert(stream.is_open() && "Can't open input file");
00041   std::cout <<"Reading Nue Data from "<<input<<std::endl;
00042 
00043   std::string line, temp;
00044   char cline[200];
00045                                                                                 
00046   while (stream.getline(cline,200)){
00047     line=cline;
00048     if (line.find("/",0)==0||line.size()==0) continue;  //ignore comments
00049     if(line.find("BEGINDATA") != std::string::npos){
00050        while (line.substr(0,7) != "ENDDATA"){
00051          stream.getline(cline,200);
00052          line=cline;
00053          if (line.find("/",0)==0||line.size()==0) continue;
00054 
00055          if (line.find("METHOD") != std::string::npos) {
00056            fDataMethod = atoi((line.substr(7,line.size()-7)).c_str());
00057 //           std::cout<<"Setting method "<<fDataMethod<<std::endl;
00058          }
00059          if(line.find("FILE")!=std::string::npos){
00060            if(fDataMethod != NueGenConfig::kFileList){
00061               std::cout<<"Error in config file, invalid data input"<<std::endl;
00062               continue;
00063            }
00064            temp = line.substr(line.find("{")+1,
00065                      line.find_first_of("}")-line.find("{")-1);
00066            files.push_back(temp);
00067            continue;
00068          }
00069 //        std::cout<<"On line: "<<line<<std::endl;         
00070        }
00071     }
00072     if(line.find("BEGINERROR") != std::string::npos){
00073        while (line.substr(0,8) != "ENDERROR"){
00074          stream.getline(cline,200);
00075          line=cline;
00076          if (line.find("NuMu")!=std::string::npos){
00077            SetErrorVal(ClassType::numu, line); continue;
00078          }
00079          if (line.find("NC")!=std::string::npos){
00080            SetErrorVal(ClassType::NC, line); continue;
00081          }
00082          if (line.find("BNue")!=std::string::npos){
00083            SetErrorVal(ClassType::bnue, line); continue;
00084          }
00085          if (line.find("NuTau")!=std::string::npos) {
00086            SetErrorVal(ClassType::nutau, line); continue;
00087          }
00088          if (line.find("SigNue")!=std::string::npos){
00089            SetErrorVal(ClassType::nue, line);  continue;
00090          }
00091          if (line.find("Total")!=std::string::npos){
00092            SetErrorVal(5, line);  continue;
00093          }
00094 //         std::cout<<" err stuff "<<line<<std::endl;
00095 
00096        }
00097        std::cout<<"Err section"<<std::endl;
00098     }  //End of Parsing the input data
00099   
00100     if(line.find("BEGINSET") != std::string::npos){
00101        GCCompleteSet set;
00102        std::cout<<"beg set"<<std::endl;
00103        while (line.substr(0,6) != "ENDSET"){
00104          stream.getline(cline,200);
00105          line=cline;
00106          if (line.find("/",0)==0||line.size()==0) continue;
00107          if (line.find("NuMu")!=std::string::npos){
00108            SetDataRange(ClassType::numu, line, set); continue;
00109          }
00110          if (line.find("NC")!=std::string::npos){
00111            SetDataRange(ClassType::NC, line, set); continue;
00112          }
00113          if (line.find("BNue")!=std::string::npos){
00114            SetDataRange(ClassType::bnue, line, set); continue;
00115          }
00116          if (line.find("NuTau")!=std::string::npos) {
00117            SetDataRange(ClassType::nutau, line, set); continue;
00118          }
00119          if (line.find("SigNue")!=std::string::npos){
00120            SetDataRange(ClassType::nue, line,set);  continue;
00121          }
00122 //         std::cout<<" set stuff "<<line<<std::endl;
00123 
00124        } //End of while loop
00125        EventGroups.push_back(set);
00126        std::cout<<" set stuff "<<line<<std::endl;
00127     } //End of Par data
00128        
00129   }  
00130   std::cout <<"Finished Reading Nue Data "<<std::endl;
00131  
00132   CheckConfig();                                                                     
00133 } 

void NueGenConfig::Reset (  ) 

Definition at line 23 of file NueGenConfig.cxx.

References fDataMethod, fErrors, fOffSet, found, fReadUntil, and kSetList.

Referenced by NueGenConfig().

00024 { 
00025    fDataMethod = NueGenConfig::kSetList;
00026 
00027    for(int i = 0; i < 6; i++){
00028      fErrors[i] = 0.0;
00029      found[i] = true;
00030    }
00031 
00032    fReadUntil = -1;
00033    fOffSet = 0;
00034 }

void NueGenConfig::SetDataRange ( int  nuClass,
std::string  line,
GCCompleteSet set 
)

Definition at line 135 of file NueGenConfig.cxx.

References fDataMethod, and kSetList.

Referenced by ReadInput().

00136 {
00137   if(fDataMethod != NueGenConfig::kSetList){
00138 //    std::cout<<"Error in config file, invalid data input"<<std::endl;
00139     return;
00140   }
00141 
00142   std::string temp;
00143   while (line.find(" ",0)<line.size())
00144               line.replace(line.find(" ",0),1,"");
00145                                                                                      
00146   temp = line.substr(line.find("{")+1,
00147               line.find_first_of(",")-line.find("{")-1);
00148   set.EventClass[nuClass].start = atof(temp.c_str());
00149 
00150   temp = line.substr(line.find_first_of(",")+1,
00151                      line.find_last_of(",")-line.find_first_of(",")-1);
00152   set.EventClass[nuClass].end = atof(temp.c_str());
00153 
00154   temp = line.substr(line.find_last_of(",")+1,
00155                      line.find("}")-line.find_last_of(",")-1);
00156   set.EventClass[nuClass].step = atof(temp.c_str());
00157                                                                                      
00158   set.EventClass[nuClass].isfixed = false;
00159   if(line.find("fix")!=std::string::npos) set.EventClass[nuClass].isfixed = true;
00160                                                                                
00161 }

void NueGenConfig::SetErrorVal ( int  pos,
std::string  line 
) [private]

Definition at line 163 of file NueGenConfig.cxx.

References fErrors, and found.

Referenced by ReadInput().

00164 {
00165    std::string temp = line.substr(line.find("{")+1,
00166                       line.find("}")-line.find("{")-1);
00167    fErrors[pos] = atof(temp.c_str());
00168    found[pos] = true;
00169 
00170 }

void NueGenConfig::SetOffset ( int  in  )  [inline]

Definition at line 60 of file NueGenConfig.h.

References fOffSet.

Referenced by NueExpGenerator::Run().

00060 { fOffSet = in; };

void NueGenConfig::SetReadNumber ( int  in  )  [inline]

Definition at line 61 of file NueGenConfig.h.

References fReadUntil.

Referenced by NueExpGenerator::Run().

00061 {fReadUntil = in; };


Member Data Documentation

std::vector<GCCompleteSet> NueGenConfig::EventGroups [private]

Definition at line 74 of file NueGenConfig.h.

Referenced by ReadInput().

double NueGenConfig::fErrors[6] [private]

Definition at line 73 of file NueGenConfig.h.

Referenced by GetErrors(), Reset(), and SetErrorVal().

std::vector<std::string> NueGenConfig::files [private]

Definition at line 71 of file NueGenConfig.h.

Referenced by AddInputFile(), LoadNextNumberSet(), and ReadInput().

int NueGenConfig::fOffSet [private]

Definition at line 67 of file NueGenConfig.h.

Referenced by LoadNextNumberSet(), Reset(), and SetOffset().

double NueGenConfig::fOscPar[6] [private]

Definition at line 76 of file NueGenConfig.h.

Referenced by GetOscPar(), and LoadNextNumberSet().

bool NueGenConfig::found[6] [private]

Definition at line 70 of file NueGenConfig.h.

Referenced by CheckConfig(), Reset(), and SetErrorVal().

int NueGenConfig::fReadUntil [private]

Definition at line 68 of file NueGenConfig.h.

Referenced by LoadNextNumberSet(), Reset(), and SetReadNumber().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1