Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:10

0001 // -*- C++ -*-
0002 //
0003 // Package:     CalibCalorimetry/HcalTPGAlgos
0004 // Class  :     HcalEmap
0005 //
0006 // Implementation:
0007 //     structure and functionality for HCAL electronic map
0008 //     NOTE!
0009 //     Keep xdaq and Oracle dependencies out of here!
0010 //
0011 // Original Author:  Gena Kukartsev, kukarzev@fnal.gov
0012 //         Created:  Tue Oct 14 14:30:20 CDT 2009
0013 //
0014 
0015 #include <cstdio>
0016 #include <iostream>
0017 #include <fstream>
0018 #include <sstream>
0019 #include <vector>
0020 #include "CalibCalorimetry/HcalTPGAlgos/interface/HcalEmap.h"
0021 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0022 
0023 using namespace std;
0024 
0025 int HcalEmap::read_map(std::string filename) {
0026   int lines = 0;
0027 
0028   std::string _row;
0029   ifstream inFile(filename.c_str(), std::ios::in);
0030   if (!inFile) {
0031     std::cout << "Unable to open file with the electronic map: " << filename << std::endl;
0032   } else {
0033     std::cout << "File with the electronic map opened successfully: " << filename << std::endl;
0034   }
0035   while (getline(inFile, _row)) {
0036     HcalEmapRow aRow;
0037     char fpga[32];
0038     char subdet[32];
0039 
0040     int _read;
0041     const char* _format = "%d %d %d %s %d %d %d %d %s %d %d %d";
0042     _read = sscanf(_row.c_str(),
0043                    _format,
0044                    &(aRow.rawId),
0045                    &(aRow.crate),
0046                    &(aRow.slot),
0047                    fpga,
0048                    &(aRow.dcc),
0049                    &(aRow.spigot),
0050                    &(aRow.fiber),
0051                    &(aRow.fiberchan),
0052                    subdet,
0053                    &(aRow.ieta),
0054                    &(aRow.iphi),
0055                    &(aRow.idepth));
0056     if (_read >= 12) {
0057       lines++;
0058 
0059       aRow.subdet.append(subdet);
0060       aRow.topbottom.append(fpga);
0061 
0062       map.push_back(aRow);
0063     }
0064   }
0065   inFile.close();
0066   std::cout << "HcalEmap: " << lines << " lines read" << std::endl;
0067 
0068   return 0;
0069 }
0070 
0071 std::vector<HcalEmap::HcalEmapRow>& HcalEmap::get_map(void) { return map; }
0072 
0073 bool HcalEmap::HcalEmapRow::operator<(const HcalEmap::HcalEmapRow& other) const { return rawId < other.rawId; }
0074 
0075 //
0076 // _____ test procedures for the HcalEmap class _____________________________
0077 //
0078 int HcalEmap_test::test_read_map(std::string filename) {
0079   HcalEmap map(filename);
0080   return 0;
0081 }