#include <LArBadChannelParser.h>
|  | 
|  | LArBadChannelParser (const std::string &filename, MsgStream *const log, unsigned int numInts, int numStrings, unsigned int firstWildcard=0) | 
|  | A parser object must be initialized with the filename that it is to parse.  More... 
 | 
|  | 
| virtual | ~LArBadChannelParser () | 
|  | 
| bool | fileStatusGood () const | 
|  | You can use this function to check whether file-reading will succeed.  More... 
 | 
|  | 
| template<typename T > | 
| std::vector< std::pair< std::vector< int >, std::vector< T > > > | parseFile () | 
|  | Parse the file using the following format for each line: First, exactly numInts integers are required.  More... 
 | 
|  | 
| template<> | 
| bool | convertStrings (std::vector< std::string > &result, const std::vector< std::string >::const_iterator begin, const std::vector< std::string >::const_iterator end) const | 
|  | 
Definition at line 11 of file LArBadChannelParser.h.
 
◆ LArBadChannelParser() [1/2]
      
        
          | LArBadChannelParser::LArBadChannelParser | ( | const std::string & | filename, | 
        
          |  |  | MsgStream *const | log, | 
        
          |  |  | unsigned int | numInts, | 
        
          |  |  | int | numStrings, | 
        
          |  |  | unsigned int | firstWildcard = 0 | 
        
          |  | ) |  |  | 
      
 
A parser object must be initialized with the filename that it is to parse. 
It must also be given a MsgStream pointer for logging messages. 
Definition at line 10 of file LArBadChannelParser.cxx.
   20     std::cerr << 
"ERROR \t LArBadChannelParser was given a NULL MsgStream pointer!" << std::endl;
 
 
 
 
◆ ~LArBadChannelParser()
  
  | 
        
          | LArBadChannelParser::~LArBadChannelParser | ( |  | ) |  |  | virtual | 
 
 
◆ LArBadChannelParser() [2/2]
  
  | 
        
          | LArBadChannelParser::LArBadChannelParser | ( |  | ) |  |  | private | 
 
 
◆ convertStrings() [1/2]
template<> 
  
  | 
        
          | bool LArBadChannelParser::convertStrings | ( | std::vector< std::string > & | result, |  
          |  |  | const std::vector< std::string >::const_iterator | begin, |  
          |  |  | const std::vector< std::string >::const_iterator | end |  
          |  | ) |  | const |  | inline | 
 
 
◆ convertStrings() [2/2]
template<typename T > 
  
  | 
        
          | bool LArBadChannelParser::convertStrings | ( | std::vector< T > & | result, |  
          |  |  | const std::vector< std::string >::const_iterator | begin, |  
          |  |  | const std::vector< std::string >::const_iterator | end |  
          |  | ) |  | const |  | inlineprivate | 
 
Definition at line 142 of file LArBadChannelParser.h.
  150     if(stringToNumber<T>(element, *
iter))
 
  151       result.push_back(element);
 
  154       (*m_log) << MSG::WARNING << 
"LArBadChannelParser REJECTED line " << 
m_linenumber \
 
  155         << 
" -\t failed to extract status." << 
endmsg;
 
 
 
 
◆ fileStatusGood()
  
  | 
        
          | bool LArBadChannelParser::fileStatusGood | ( |  | ) | const |  | inline | 
 
You can use this function to check whether file-reading will succeed. 
If false, parseFile() will return an empty vector. 
Definition at line 74 of file LArBadChannelParser.h.
 
 
◆ getIdFields()
  
  | 
        
          | std::vector< int > LArBadChannelParser::getIdFields | ( | const std::vector< std::string > & | words | ) |  |  | private | 
 
Definition at line 54 of file LArBadChannelParser.cxx.
   66       if (
w.compare(0,3,
"EMB")==0 || 
w[0]==
'B')
 
   74       else if (
w==
"C" || 
w==
"c")
 
   80     if(canBeWildcard && 
w == 
"*")
 
   82     else if(stringToNumber<int>(idComponent, 
w) && idComponent >= 0)
 
   83       result.push_back(idComponent);
 
   86       (*m_log) << MSG::WARNING << 
"LArBadChannelParser REJECTED line " << 
m_linenumber \
 
   87         << 
" -\t word " << 
i + 1 << 
" must be a non-negative integer " \
 
   88         << (canBeWildcard ? 
"or " : 
"and not " ) \
 
 
 
 
◆ parseFile()
template<typename T > 
  
  | 
        
          | std::vector< std::pair< std::vector< int >, std::vector< T > > > LArBadChannelParser::parseFile |  | inline | 
 
Parse the file using the following format for each line: First, exactly numInts integers are required. 
Then, if numString is negative, at least std::abs(numString) strings are required, otherwise exactly numString strings are required. These strings are converted to a vector<T>. A vector of all successfully parsed lines is returned. The integer part of a line may contain wildcards, starting from position firstWildcard (where counting begins from 1); firstWildcard = 0 means wildcards are not allowed. The wildcard character in the input file is "*", it is replaced by -1 in the parsed output. Comments in the ASCII file are demarcated with the '#' character. Lines that fail to parse are skipped, with diagnostic messages sent to the message stream. 
Definition at line 80 of file LArBadChannelParser.h.
   82   typedef std::pair< std::vector<int>, std::vector<T> > LineData;
 
   83   std::vector<LineData> 
result;
 
   87     (*m_log) << MSG::ERROR << 
"LArBadChannelParser - Could not open file: " << 
m_filename << 
endmsg;
 
  102       if(
input.size() != 0) 
 
  103         {(*m_log) << MSG::WARNING << 
"LArBadChannelParser REJECTED line " << 
m_linenumber \
 
  104           << 
" -\t not enough parameters given: " << 
input.size() << 
endmsg;}
 
  111     if(parsedData.first.size() == 0)
 
  115     const std::vector<std::string>::const_iterator 
stop = \
 
  116       (m_numStrings < 0) ? static_cast<const std::vector<std::string>::const_iterator>(
input.end()) : (
start + 
m_numStrings);
 
  120       if(!convertStrings<T>(parsedData.second, 
start, 
stop))
 
  125       (*m_log) << MSG::WARNING << 
"LArBadChannelParser IGNORED unexpected input on line " << 
m_linenumber << 
"." << 
endmsg;
 
  127     result.push_back(std::move(parsedData));
 
 
 
 
◆ parseLine()
  
  | 
        
          | std::vector< std::string > LArBadChannelParser::parseLine | ( | std::string & | line | ) | const |  | private | 
 
Definition at line 28 of file LArBadChannelParser.cxx.
   30   std::string::size_type commentPosition = 
line.find(
'#');
 
   31   if(commentPosition != std::string::npos)  
 
   32     line.erase(commentPosition);        
 
   35   std::vector<std::string> 
result;
 
   37   std::istringstream stringIn(
line);    
 
   42     result.push_back(readWord);
 
 
 
 
◆ stringToNumber()
template<typename T > 
  
  | 
        
          | bool LArBadChannelParser::stringToNumber | ( | T & | theNumber, |  
          |  |  | const std::string & | theStr |  
          |  | ) |  | const |  | inlineprivate | 
 
Definition at line 173 of file LArBadChannelParser.h.
  175         std::istringstream iss(theString);
 
  177         return !(iss >> std::dec >> theNumber).
fail();
 
 
 
 
◆ m_filename
  
  | 
        
          | const std::string LArBadChannelParser::m_filename |  | private | 
 
 
◆ m_fin
  
  | 
        
          | std::ifstream LArBadChannelParser::m_fin |  | private | 
 
 
◆ m_firstWildcard
  
  | 
        
          | const unsigned int LArBadChannelParser::m_firstWildcard |  | private | 
 
 
◆ m_linenumber
  
  | 
        
          | unsigned int LArBadChannelParser::m_linenumber |  | private | 
 
 
◆ m_log
  
  | 
        
          | MsgStream* const LArBadChannelParser::m_log |  | private | 
 
 
◆ m_numInts
  
  | 
        
          | const unsigned int LArBadChannelParser::m_numInts |  | private | 
 
 
◆ m_numStrings
  
  | 
        
          | const int LArBadChannelParser::m_numStrings |  | private | 
 
 
The documentation for this class was generated from the following files: