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  static AlignableObjectId alignObjId;
19 
20  while ( !myfile.eof() && myfile.good() )
21  {
22  align::Scalars m_inputs;
23 
24  UniqueId m_uId;
25  char firstchar;
26  firstchar = myfile.peek();
27 
28  if(firstchar == '#'){
29  std::string line;
30  getline(myfile,line);
31  }
32  else if (firstchar == '!'){
33  std::string firststring;
34  std::string structure;
35  myfile >> firststring >> structure;
36  std::string endofline;
37  getline(myfile,endofline);
38  m_uId.second = alignObjId.nameToType(structure);
39  }
40  else{
41  myfile >> m_uId.first;
42 
43  for ( int i=0; i<NINPUTS; i++ )
44  {
45  float tmpInput;
46  myfile >> tmpInput;
47  m_inputs.push_back( tmpInput );
48  }
49  std::string endofline;
50  getline(myfile,endofline);
51  theMap.insert( PairType( m_uId, m_inputs));
52 
53  // Check if read succeeded (otherwise, we are at eof)
54  if ( myfile.fail() ) break;
55 
56 
57  }
58  }
59 }
int i
Definition: DBlmapReader.cc:9
void readFile(const std::string &textFileName)
Read given text file.
std::vector< Scalar > Scalars
Definition: Utilities.h:22
Allows conversion between type and name, and vice-versa.
std::pair< UniqueId, align::Scalars > PairType
align::StructureType nameToType(const std::string &name) const
Convert name to type.
std::pair< align::ID, align::StructureType > UniqueId