Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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