Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "CondTools/Ecal/interface/EcalTPGFineGrainStripfromFile.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::EcalTPGFineGrainStripfromFile::EcalTPGFineGrainStripfromFile(const edm::ParameterSet& ps)
0015     : m_name(ps.getUntrackedParameter<std::string>("name", "EcalTPGFineGrainStripfromFile")) {
0016   fname = ps.getParameter<std::string>("FileName");
0017 
0018   std::cout << "EcalTPGFineGrainStripfromFile constructor\n" << std::endl;
0019 }
0020 
0021 popcon::EcalTPGFineGrainStripfromFile::~EcalTPGFineGrainStripfromFile() {
0022   // do nothing
0023 }
0024 
0025 void popcon::EcalTPGFineGrainStripfromFile::getNewObjects() {
0026   std::cout << "------- Ecal -> getNewObjects\n";
0027   edm::LogInfo("EcalTPGFineGrainStripfromFile") << "Started GetNewObjects!!!";
0028 
0029   int fileIOV;
0030   std::cout << "LinPed which input IOV do you want " << std::endl;
0031   std::cin >> fileIOV;
0032   std::ifstream fLin;
0033   std::ostringstream oss;
0034   oss << fileIOV;
0035   //  std::string fname = "/afs/cern.ch/cms/ECAL/triggerTransp/TPG_beamv6_trans_" + oss.str() + "_spikekill.txt";
0036   fLin.open(fname.c_str());
0037   if (!fLin.is_open()) {
0038     std::cout << "ERROR : can't open file '" << fname << std::endl;
0039     return;
0040   }
0041   std::cout << " file " << fname << " opened" << std::endl;
0042   std::string line;
0043   for (int i = 0; i < 304517; i++)
0044     getline(fLin, line);
0045   char strip[8];
0046   unsigned int stripId, Threshold, LUTFgr;
0047 
0048   EcalTPGFineGrainStripEE* fgrStripEE = new EcalTPGFineGrainStripEE;
0049 
0050   for (int istrip = 0; istrip < 15176; istrip++) {
0051     getline(fLin, line);
0052     sscanf(line.c_str(), "%s %u", strip, &stripId);
0053     if (istrip < 10 || (istrip > 12239 && istrip < 12250))
0054       std::cout << " string " << strip << " Id " << stripId;
0055     getline(fLin, line);  // sliding_window
0056     getline(fLin, line);  // weightGroupId
0057     getline(fLin, line);  // threshold_sfg lut_sfg
0058     if (istrip < 10 || (istrip > 12239 && istrip < 12250))
0059       std::cout << " line " << line;
0060     sscanf(line.c_str(), "%x %x", &Threshold, &LUTFgr);
0061     if (istrip < 10 || (istrip > 12239 && istrip < 12250))
0062       std::cout << " Threshold " << Threshold << std::endl;
0063     EcalTPGFineGrainStripEE::Item item;
0064     item.threshold = Threshold;
0065     item.lut = LUTFgr;
0066 
0067     fgrStripEE->setValue(stripId, item);
0068     if (istrip == 12239)
0069       getline(fLin, line);  // 1 empty line between EB and EE
0070   }                         // end loop over EB + EE strips
0071   fLin.close();
0072 
0073   m_to_transfer.push_back(std::make_pair(fgrStripEE, fileIOV));
0074 
0075   std::cout << "Ecal -> end of getNewObjects -----------\n";
0076 }