CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/Alignment/SurveyAnalysis/src/SurveyInputTextReader.cc

Go to the documentation of this file.
00001 // System
00002 
00003 #include <fstream>
00004 
00005 #include "FWCore/Utilities/interface/Exception.h"
00006 
00007 #include "Alignment/CommonAlignment/interface/AlignableObjectId.h"
00008 #include "Alignment/SurveyAnalysis/interface/SurveyInputTextReader.h"
00009 
00010 //__________________________________________________________________________________________________
00011 void SurveyInputTextReader::readFile( const std::string& textFileName )
00012 {
00013 
00014   std::ifstream myfile( textFileName.c_str() );
00015   if ( !myfile.is_open() )
00016         throw cms::Exception("FileAccess") << "Unable to open input text file";
00017 
00018   static AlignableObjectId alignObjId;
00019         
00020   while ( !myfile.eof() && myfile.good() )
00021     {
00022       align::Scalars m_inputs;
00023                 
00024       UniqueId  m_uId;
00025       char firstchar;
00026       firstchar = myfile.peek();
00027 
00028       if(firstchar == '#'){
00029         std::string line;
00030         getline(myfile,line);
00031       }
00032       else if (firstchar == '!'){
00033         std::string firststring;
00034         std::string structure; 
00035         myfile >> firststring >> structure;
00036         std::string endofline;
00037         getline(myfile,endofline);
00038         m_uId.second = alignObjId.nameToType(structure);
00039       }
00040       else{
00041         myfile >> m_uId.first;
00042 
00043         for ( int i=0; i<NINPUTS; i++ )
00044           {
00045             float tmpInput;
00046             myfile >> tmpInput;
00047             m_inputs.push_back( tmpInput );
00048           }
00049         std::string endofline;
00050         getline(myfile,endofline);
00051         theMap.insert( PairType( m_uId, m_inputs));                     
00052                         
00053         // Check if read succeeded (otherwise, we are at eof)
00054         if ( myfile.fail() ) break;
00055                         
00056 
00057       }
00058     }
00059 }