From 5d786977d89714b557984dfba6f01a19cd2bbfdb Mon Sep 17 00:00:00 2001 From: "Stephen A. Wood" <saw@jlab.org> Date: Mon, 19 Mar 2012 14:34:55 -0400 Subject: [PATCH] Start writing a Load method to read the detector map --- src/THcDetectorMap.cxx | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/THcDetectorMap.cxx b/src/THcDetectorMap.cxx index 2baba7d..1de0391 100644 --- a/src/THcDetectorMap.cxx +++ b/src/THcDetectorMap.cxx @@ -17,7 +17,62 @@ using namespace std; ClassImp(THcDetectorMap) +inline static bool IsComment( const string& s, string::size_type pos ) +{ + return ( pos != string::npos && pos < s.length() && + (s[pos] == '!') ); +} + + void THcDetectorMap::Load(const char *fname) { + static const char* const here = "THcDetectorMap::Load"; + static const char* const whtspc = " \t"; + + ifstream ifile; + + ifile.open(fname); + if(!ifile.is_open) { + Error(here, "error opening detector map file %s",fname); + return; // Need a success/failure argument? + } + string line; + + Int_t roc=0; + Int_t nsubadd=0; + Int_t mask=0; + Int_t bsub=0; + Int_t detector=0; + Int_t slot=0; + + while(getline(ifile,line)) { + // BLank line or comment + if(line.empty() + || (start = line.find_first_not_of( whtspc )) == string::npos + || IsComment(line, start) ) + continue; + } + // Get rid of trailing comments and leading and trailing whitespace + cout << "MAPA: " << line << endl; + while ((pos = line.find_first_of("!", pos+1)) != string::npos) { + if(IsComment(line, pos)) { + line.erase(pos); + break; + } + } + cout << "MAPB: " << line << endl; + + // Decide if line is ROC/NSUBADD/MASK/BSUB/DETECTOR/SLOT = something + // or chan, plane, counter[, signal] + + + if((pos=line.find_first_of("=")) != string::npos) { // Setting parameter + char varname[100]; + + + } else { // Assume channel definition + + } + } -- GitLab