Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "CondTools/Ecal/interface/EcalTPGSpikeThresholdfromFile.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::EcalTPGSpikeThresholdfromFile::EcalTPGSpikeThresholdfromFile(const edm::ParameterSet &ps)
0015     : m_name(ps.getUntrackedParameter<std::string>("name", "EcalTPGSpikeThresholdfromFile")) {
0016   std::cout << "EcalTPGSpikeThresholdfromFile constructor\n" << std::endl;
0017 }
0018 
0019 popcon::EcalTPGSpikeThresholdfromFile::~EcalTPGSpikeThresholdfromFile() {
0020   // do nothing
0021 }
0022 
0023 void popcon::EcalTPGSpikeThresholdfromFile::getNewObjects() {
0024   std::cout << "------- Ecal -> getNewObjects\n";
0025   edm::LogInfo("EcalTPGSpikeThresholdfromFile") << "Started GetNewObjects!!!";
0026 
0027   Ref payload = lastPayload();
0028 
0029   // here popcon tells us which is the last since of the last object in the offline DB
0030 
0031   int fileIOV;
0032   std::cout << "LinPed which input IOV do you want " << std::endl;
0033   std::cin >> fileIOV;
0034   std::ifstream fLin;
0035   std::ostringstream oss;
0036   oss << fileIOV;
0037   std::string fname = "/afs/cern.ch/cms/ECAL/triggerTransp/TPG_beamv6_trans_" + oss.str() + "_spikekill.txt";
0038   fLin.open(fname.c_str());
0039   if (!fLin.is_open()) {
0040     std::cout << "ERROR : can't open file '" << fname << std::endl;
0041     return;
0042   }
0043   std::cout << " file " << fname << " opened" << std::endl;
0044   std::string line;
0045   for (int i = 0; i < 365223; i++)
0046     getline(fLin, line);
0047   char tow[8];
0048   unsigned int towerId, Threshold;
0049   EcalTPGSpike *lut = new EcalTPGSpike();
0050   for (int istrip = 0; istrip < 2448; istrip++) {
0051     getline(fLin, line);
0052     sscanf(line.c_str(), "%s %u", tow, &towerId);
0053     if (istrip < 10)
0054       std::cout << " string " << tow << " Id " << towerId;
0055     getline(fLin, line);  // LUTGroupId
0056     getline(fLin, line);  // FgGroupId
0057     getline(fLin, line);  // spike_killing_threshold
0058     if (istrip < 10)
0059       std::cout << " line " << line;
0060     sscanf(line.c_str(), "%u", &Threshold);
0061     if (istrip < 10)
0062       std::cout << " Threshold " << Threshold << std::endl;
0063 
0064     lut->setValue(towerId, Threshold);
0065   }  // end loop over EB towers
0066   fLin.close();
0067 
0068   m_to_transfer.push_back(std::make_pair(lut, fileIOV));
0069 
0070   std::cout << "Ecal -> end of getNewObjects -----------\n";
0071 }