Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:01

0001 #include "CondTools/Ecal/interface/EcalTPGPedfromFile.h"
0002 #include "CondTools/Ecal/interface/EcalTPGPedestalsHandler.h"
0003 #include "OnlineDB/EcalCondDB/interface/EcalLogicID.h"
0004 #include "OnlineDB/EcalCondDB/interface/LMFSextuple.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0006 #include "CondCore/CondDB/interface/Time.h"
0007 #include "DataFormats/Provenance/interface/Timestamp.h"
0008 #include "OnlineDB/EcalCondDB/interface/Tm.h"
0009 
0010 #include <iostream>
0011 #include <iomanip>
0012 #include <sstream>
0013 
0014 popcon::EcalTPGPedfromFile::EcalTPGPedfromFile(const edm::ParameterSet& ps)
0015     : m_name(ps.getUntrackedParameter<std::string>("name", "EcalTPGPedfromFileHandler")) {
0016   std::cout << "EcalTPGPedfromFile  constructor\n" << std::endl;
0017 }
0018 
0019 popcon::EcalTPGPedfromFile::~EcalTPGPedfromFile() {
0020   // do nothing
0021 }
0022 
0023 void popcon::EcalTPGPedfromFile::getNewObjects() {
0024   std::cout << "------- Ecal -> getNewObjects\n";
0025 
0026   unsigned long long max_since = 1;
0027   Ref payload = lastPayload();
0028 
0029   // here popcon tells us which is the last since of the last object in the offline DB
0030   max_since = tagInfo().lastInterval.since;
0031   Tm max_since_tm(max_since);
0032 
0033   int fileIOV;
0034   std::cout << "PedfromFile which input IOV do you want " << std::endl;
0035   std::cin >> fileIOV;
0036   std::ifstream fLin;
0037   std::ostringstream oss;
0038   oss << fileIOV;
0039   std::string fname = "/afs/cern.ch/cms/ECAL/triggerTransp/TPG_beamv6_trans_" + oss.str() + "_spikekill.txt";
0040   fLin.open(fname.c_str());
0041   if (!fLin.is_open()) {
0042     std::cout << "ERROR : can't open file '" << fname << std::endl;
0043     return;
0044   }
0045   std::cout << " file " << fname << " opened" << std::endl;
0046   std::string line;
0047   for (int i = 0; i < 85; i++)
0048     getline(fLin, line);
0049   char cryst[10];
0050   uint32_t ped[kGains], mult[kGains], shift[kGains];
0051   uint32_t id;
0052   EcalTPGLinearizationConst* linC = new EcalTPGLinearizationConst;
0053   EcalTPGPedestals* peds = new EcalTPGPedestals;
0054   for (int iChannel = 0; iChannel < kEBChannels; iChannel++) {
0055     getline(fLin, line);
0056     sscanf(line.c_str(), "%s %u", cryst, &id);
0057     for (int gain = 0; gain < kGains; gain++) {
0058       getline(fLin, line);
0059       sscanf(line.c_str(), "%X %X %X", &ped[gain], &mult[gain], &shift[gain]);
0060     }
0061     EcalTPGLinearizationConst::Item item;
0062     item.mult_x1 = mult[2];
0063     item.mult_x6 = mult[1];
0064     item.mult_x12 = mult[0];
0065     item.shift_x1 = shift[2];
0066     item.shift_x6 = shift[1];
0067     item.shift_x12 = shift[0];
0068 
0069     EcalTPGPedestals::Item itemPed;
0070     itemPed.mean_x1 = ped[2];
0071     itemPed.mean_x6 = ped[1];
0072     itemPed.mean_x12 = ped[0];
0073 
0074     linC->insert(std::make_pair(id, item));
0075     peds->insert(std::make_pair(id, itemPed));
0076   }                     // end loop over EB channels
0077   getline(fLin, line);  // comment before EE crystals
0078   std::cout << " comment line " << line << std::endl;
0079   for (int iChannel = 0; iChannel < kEEChannels; iChannel++) {
0080     getline(fLin, line);
0081     //      std::cout << " line " << line << std::endl;
0082     sscanf(line.c_str(), "%s %u", cryst, &id);
0083     //      std::cout << cryst << " id " << id << std::endl;
0084     for (int gain = 0; gain < kGains; gain++) {
0085       getline(fLin, line);
0086       //    std::cout << " line g " << line << std::endl;
0087       sscanf(line.c_str(), "%X %X %X", &ped[gain], &mult[gain], &shift[gain]);
0088       //    std::cout << " gain " << gain << " ped " << ped[gain] << " mult " << mult[gain] << " shift " << shift[gain]<< std::endl;
0089     }
0090     EcalTPGLinearizationConst::Item item;
0091     item.mult_x1 = mult[2];
0092     item.mult_x6 = mult[1];
0093     item.mult_x12 = mult[0];
0094     item.shift_x1 = shift[2];
0095     item.shift_x6 = shift[1];
0096     item.shift_x12 = shift[0];
0097 
0098     EcalTPGPedestals::Item itemPed;
0099     itemPed.mean_x1 = ped[2];
0100     itemPed.mean_x6 = ped[1];
0101     itemPed.mean_x12 = ped[0];
0102 
0103     linC->insert(std::make_pair(id, item));
0104     peds->insert(std::make_pair(id, itemPed));
0105   }  // end loop over EE channels
0106   fLin.close();
0107   // for the time beeing just transfer pedestal
0108   //  m_to_transfer.push_back(std::make_pair(linC, fileIOV));
0109   m_to_transfer.push_back(std::make_pair(peds, fileIOV));
0110 
0111   std::cout << "Ecal -> end of getNewObjects -----------\n";
0112 }