Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:46:13

0001 // System
0002 
0003 #include <fstream>
0004 
0005 #include "FWCore/Utilities/interface/Exception.h"
0006 
0007 #include "Alignment/CommonAlignment/interface/AlignableObjectId.h"
0008 #include "Alignment/SurveyAnalysis/interface/SurveyInputTextReader.h"
0009 
0010 //__________________________________________________________________________________________________
0011 void SurveyInputTextReader::readFile(const std::string& textFileName) {
0012   std::ifstream myfile(textFileName.c_str());
0013   if (!myfile.is_open())
0014     throw cms::Exception("FileAccess") << "Unable to open input text file";
0015 
0016   // FIXME: - currently defaulting to RunI as this was the previous behaviour
0017   //        - check this, when resurrecting this code in the future
0018   AlignableObjectId alignableObjectId{AlignableObjectId::Geometry::General};
0019 
0020   while (!myfile.eof() && myfile.good()) {
0021     align::Scalars m_inputs;
0022 
0023     UniqueId m_uId;
0024     char firstchar;
0025     firstchar = myfile.peek();
0026 
0027     if (firstchar == '#') {
0028       std::string line;
0029       getline(myfile, line);
0030     } else if (firstchar == '!') {
0031       std::string firststring;
0032       std::string structure;
0033       myfile >> firststring >> structure;
0034       std::string endofline;
0035       getline(myfile, endofline);
0036       m_uId.second = alignableObjectId.stringToId(structure.c_str());
0037     } else {
0038       myfile >> m_uId.first;
0039 
0040       for (int i = 0; i < NINPUTS; i++) {
0041         float tmpInput;
0042         myfile >> tmpInput;
0043         m_inputs.push_back(tmpInput);
0044       }
0045       std::string endofline;
0046       getline(myfile, endofline);
0047       theMap.insert(PairType(m_uId, m_inputs));
0048 
0049       // Check if read succeeded (otherwise, we are at eof)
0050       if (myfile.fail())
0051         break;
0052     }
0053   }
0054 }