CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/CondFormats/CSCObjects/src/CSCReadoutMappingFromFile.cc

Go to the documentation of this file.
00001 #include <CondFormats/CSCObjects/interface/CSCReadoutMappingFromFile.h>
00002 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00003 #include <FWCore/ParameterSet/interface/FileInPath.h>
00004 #include <iostream>
00005 #include <fstream>
00006 #include <sstream>
00007 
00008 CSCReadoutMappingFromFile::CSCReadoutMappingFromFile( const edm::ParameterSet& ps ) {
00009   fill( ps ); 
00010 }
00011 
00012 CSCReadoutMappingFromFile::~CSCReadoutMappingFromFile(){}
00013 
00014 void CSCReadoutMappingFromFile::fill( const edm::ParameterSet& ps ) {
00015   edm::FileInPath fp = ps.getParameter<edm::FileInPath>("theMappingFile");
00016   theMappingFile = fp.fullPath();
00017   std::ifstream in( theMappingFile.c_str() );
00018   std::string line;
00019   const std::string commentFlag = "#";
00020   if ( !in ) {
00021     edm::LogError("CSC") << " Failed to open file " << theMappingFile << " containing mapping.";
00022   }
00023   else
00024   {
00025     edm::LogInfo("CSC") << " Opened file " << theMappingFile << " containing mapping.";
00026 
00027     while ( getline(in, line) ) { // getline() from <string>
00028       // LogDebug("CSC") << line;
00029       if ( line[0] != commentFlag[0] ) {
00030         int i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11;
00031         std::istringstream is( line );
00032         is >> i1 >> i2 >> i3 >> i4 >> i5 >> i6 >> i7 >> i8 >> i9 >> i10 >> i11;
00033         // LogDebug("CSC") << i1 << " " << i2 << " " << i3 << " " << i4 << " " <<
00034         //        i5 << " " << i6 << " " << i7 << " " << i8 << " " << i9;
00035         addRecord( i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11 );
00036       }
00037     }
00038 
00039   }
00040 
00041   return;
00042 }
00043