Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:52:03

0001 #include "CondTools/Ecal/interface/EcalTPGFineGrainTowerfromFile.h"
0002 
0003 #include "FWCore/Framework/interface/ESHandle.h"
0004 
0005 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0006 
0007 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
0008 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
0009 
0010 #include <iostream>
0011 #include <fstream>
0012 #include <sstream>
0013 
0014 popcon::EcalTPGFineGrainTowerfromFile::EcalTPGFineGrainTowerfromFile(const edm::ParameterSet& ps)
0015     : m_name(ps.getUntrackedParameter<std::string>("name", "EcalTPGFineGrainTowerfromFile")) {
0016   fname = ps.getParameter<std::string>("FileName");
0017 
0018   std::cout << "EcalTPGFineGrainTowerfromFile constructor\n" << std::endl;
0019 }
0020 
0021 popcon::EcalTPGFineGrainTowerfromFile::~EcalTPGFineGrainTowerfromFile() {}
0022 
0023 void popcon::EcalTPGFineGrainTowerfromFile::getNewObjects() {
0024   std::cout << "------- Ecal -> getNewObjects\n";
0025   edm::LogInfo("EcalTPGFineGrainTowerfromFile") << "Started GetNewObjects!!!";
0026 
0027   int fileIOV;
0028   std::cout << "LinPed which input IOV do you want " << std::endl;
0029   std::cin >> fileIOV;
0030   std::ifstream fLin;
0031   std::ostringstream oss;
0032   oss << fileIOV;
0033   //  std::string fname = "/afs/cern.ch/cms/ECAL/triggerTransp/TPG_beamv6_trans_" + oss.str() + "_spikekill.txt";
0034   fLin.open(fname.c_str());
0035   if (!fLin.is_open()) {
0036     std::cout << "ERROR : can't open file '" << fname << std::endl;
0037     return;
0038   }
0039   std::cout << " file " << fname << " opened" << std::endl;
0040   /*      structure of the file:
0041 TOWER_EB                     365224/375015 : 9792 lines  2448 towers 3 lines : 0, 0, 96 (LUTGroupId, FgGroupId, spike_killing_threshold)
0042 empty line                   375016
0043 TOWER_EE                     375017/379768 : 4752 lines  1584 towers 2 lines : 0, 0x0 (LUTGroupId, tower_lut_fg)
0044   */
0045   std::string line;
0046   for (int i = 0; i < 375016; i++)
0047     getline(fLin, line);
0048   char tower[8];
0049   unsigned int towerId, LUTFg;
0050   EcalTPGFineGrainTowerEE* fgrMap = new EcalTPGFineGrainTowerEE;
0051   for (int itower = 0; itower < 1584; itower++) {
0052     getline(fLin, line);
0053     sscanf(line.c_str(), "%s %u", tower, &towerId);
0054     if (itower < 10 || (itower > 1574 && itower < 1584))
0055       std::cout << " string " << tower << " Id " << towerId;
0056     getline(fLin, line);  // LUTGroupId
0057     getline(fLin, line);  // tower_lut_fg
0058     if (itower < 10 || (itower > 1574 && itower < 1584))
0059       std::cout << " line " << line << std::endl;
0060     sscanf(line.c_str(), "%x", &LUTFg);
0061     //    EcalTPGFineGrainTowerEE::Item item;
0062     //    item.lut = LUTFg;
0063     //    fgrMap->setValue(towerId, item);
0064 
0065     fgrMap->setValue(towerId, LUTFg);
0066   }  // end loop over EE towers
0067   fLin.close();
0068 
0069   m_to_transfer.push_back(std::make_pair(fgrMap, fileIOV));
0070 
0071   std::cout << "Ecal -> end of getNewObjects -----------\n";
0072 }