CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/CalibCalorimetry/HcalTPGAlgos/src/HcalEmap.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     CalibCalorimetry/HcalTPGAlgos
00004 // Class  :     HcalEmap
00005 // 
00006 // Implementation:
00007 //     structure and functionality for HCAL electronic map
00008 //     NOTE!
00009 //     Keep xdaq and Oracle dependencies out of here!
00010 //
00011 // Original Author:  Gena Kukartsev, kukarzev@fnal.gov
00012 //         Created:  Tue Oct 14 14:30:20 CDT 2009
00013 // $Id: HcalEmap.cc,v 1.2 2010/08/06 20:24:03 wmtan Exp $
00014 //
00015 
00016 #include <stdio.h>
00017 #include <iostream>
00018 #include <fstream>
00019 #include <sstream>
00020 #include <vector>
00021 #include "CalibCalorimetry/HcalTPGAlgos/interface/HcalEmap.h"
00022 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00023 
00024 using namespace std;
00025 
00026 
00027 
00028 
00029 int HcalEmap::read_map( std::string filename )
00030 {
00031   int lines=0;
00032 
00033   std::string _row;
00034   ifstream inFile( filename . c_str(), std::ios::in );
00035   if (!inFile){
00036     std::cout << "Unable to open file with the electronic map: " << filename << std::endl;
00037   }
00038   else{
00039     std::cout << "File with the electronic map opened successfully: " << filename << std::endl;
00040   }
00041   while ( getline( inFile, _row ) > 0 ){
00042     HcalEmapRow aRow;
00043     char fpga[32];
00044     char subdet[32];
00045     
00046     int _read;
00047     const char * _format = "%d %d %d %s %d %d %d %d %s %d %d %d";
00048     _read = sscanf( _row . c_str(), _format,
00049                     &(aRow.rawId),
00050                     &(aRow.crate), &(aRow.slot),
00051                       fpga,
00052                     &(aRow.dcc),
00053                     &(aRow.spigot),&(aRow.fiber),&(aRow.fiberchan),
00054                     subdet,
00055                     &(aRow.ieta), &(aRow.iphi), &(aRow.idepth) );
00056     if ( _read >= 12 ){
00057       lines++;
00058       
00059       aRow . subdet .append( subdet );
00060       aRow . topbottom .append( fpga );
00061       
00062       map . push_back( aRow );
00063     }  
00064   }
00065   inFile.close();
00066   std::cout << "HcalEmap: " << lines << " lines read" << std::endl;
00067 
00068   return 0;
00069 }
00070   
00071 
00072 
00073 std::vector<HcalEmap::HcalEmapRow> & HcalEmap::get_map( void )
00074 {
00075   return map;
00076 }
00077 
00078 
00079 bool HcalEmap::HcalEmapRow::operator<( const HcalEmap::HcalEmapRow & other) const{
00080   return rawId < other.rawId;
00081 }
00082 
00083 
00084 
00085 //
00086 // _____ test procedures for the HcalEmap class _____________________________
00087 //
00088 int HcalEmap_test::test_read_map( std::string filename )
00089 {
00090   HcalEmap map( filename );
00091   return 0;
00092 }
00093