test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SurveyInputTextReader.cc
Go to the documentation of this file.
1 // System
2 
3 #include <fstream>
4 
6 
9 
10 //__________________________________________________________________________________________________
11 void SurveyInputTextReader::readFile( const std::string& textFileName )
12 {
13 
14  std::ifstream myfile( textFileName.c_str() );
15  if ( !myfile.is_open() )
16  throw cms::Exception("FileAccess") << "Unable to open input text file";
17 
18  while ( !myfile.eof() && myfile.good() )
19  {
20  align::Scalars m_inputs;
21 
22  UniqueId m_uId;
23  char firstchar;
24  firstchar = myfile.peek();
25 
26  if(firstchar == '#'){
28  getline(myfile,line);
29  }
30  else if (firstchar == '!'){
31  std::string firststring;
32  std::string structure;
33  myfile >> firststring >> structure;
34  std::string endofline;
35  getline(myfile,endofline);
36  m_uId.second = AlignableObjectId::stringToId(structure.c_str());
37  }
38  else{
39  myfile >> m_uId.first;
40 
41  for ( int i=0; i<NINPUTS; i++ )
42  {
43  float tmpInput;
44  myfile >> tmpInput;
45  m_inputs.push_back( tmpInput );
46  }
47  std::string endofline;
48  getline(myfile,endofline);
49  theMap.insert( PairType( m_uId, m_inputs));
50 
51  // Check if read succeeded (otherwise, we are at eof)
52  if ( myfile.fail() ) break;
53 
54 
55  }
56  }
57 }
int i
Definition: DBlmapReader.cc:9
void readFile(const std::string &textFileName)
Read given text file.
static align::StructureType stringToId(const char *)
std::vector< Scalar > Scalars
Definition: Utilities.h:24
std::pair< UniqueId, align::Scalars > PairType
std::pair< align::ID, align::StructureType > UniqueId