Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:35:43

0001 #include "CondTools/Ecal/interface/EcalLaser_weekly_Linearization.h"
0002 #include "OnlineDB/EcalCondDB/interface/EcalLogicID.h"
0003 #include "OnlineDB/EcalCondDB/interface/LMFSextuple.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0005 #include "CondCore/CondDB/interface/Time.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::EcalLaser_weekly_Linearization::EcalLaser_weekly_Linearization(const edm::ParameterSet &ps)
0014     : m_name(ps.getUntrackedParameter<std::string>("name", "EcalLaser_weekly_Handler")) {
0015   std::cout << "EcalLaser Source handler constructor\n" << std::endl;
0016 }
0017 
0018 popcon::EcalLaser_weekly_Linearization::~EcalLaser_weekly_Linearization() {
0019   // do nothing
0020 }
0021 
0022 void popcon::EcalLaser_weekly_Linearization::getNewObjects() {
0023   //  int file[1] = {190708};
0024 
0025   std::cout << "------- Ecal -> getNewObjects\n";
0026 
0027   unsigned long long max_since = 1;
0028   Ref payload = lastPayload();
0029 
0030   // here popcon tells us which is the last since of the last object in the offline DB
0031   max_since = tagInfo().lastInterval.since;
0032   Tm max_since_tm(max_since);
0033 
0034   //  const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap& laserRatiosMap =
0035   //    payload->getLaserMap();
0036   //  std::cout << "payload->getLaserMap():  OK " << std::endl;
0037   //  std::cout << "Its size is " << laserRatiosMap.size() << std::endl;
0038   //  const EcalLaserAPDPNRatios::EcalLaserTimeStampMap& laserTimeMap =
0039   //    payload->getTimeMap();
0040   //  std::cout << "payload->getTimeMap():  OK " << std::endl;
0041   //  std::cout << "Last Object in Offline DB has SINCE = "  << max_since
0042   //        << " -> " << max_since_tm.cmsNanoSeconds()
0043   //        << " (" << max_since_tm << ")"
0044   //        << " and  SIZE = " << tagInfo().size
0045   //        << std::endl;
0046 
0047   for (int week = 0; week < 1; week++) {
0048     int fileIOV;
0049     std::cout << " which input IOV do you want " << std::endl;
0050     std::cin >> fileIOV;
0051     std::ifstream fWeek;
0052     std::ostringstream oss;
0053     oss << fileIOV;
0054     std::string fname = "/afs/cern.ch/cms/ECAL/triggerTransp/TPG_beamv6_trans_" + oss.str() + "_spikekill.txt";
0055     /*
0056     oss << file[week];
0057     //    std::string fname = "/afs/cern.ch/cms/ECAL/triggerTransp/TPG_beamv5_trans_" + oss.str() + "_";
0058     std::string fname = "/afs/cern.ch/cms/ECAL/triggerTransp/TPG_beamv6_trans_" + oss.str() + "_";
0059     oss.str("");
0060     //   if(week == 32) oss << 200000;
0061     //   else oss << file[week + 1] - 1;
0062     oss << 200000;
0063     fname += oss.str() + ".txt";
0064     */
0065     fWeek.open(fname.c_str());
0066     if (!fWeek.is_open()) {
0067       std::cout << "ERROR : can't open file '" << fname << std::endl;
0068       break;
0069     }
0070     std::cout << " file " << fname << " opened" << std::endl;
0071     //    int rawId;
0072     //    float corrp;
0073     std::string line;
0074     for (int i = 0; i < 85; i++)
0075       getline(fWeek, line);
0076     char cryst[10];
0077     uint32_t ped[kGains], mult[kGains], shift[kGains];
0078     uint32_t id;
0079 
0080     EcalTPGLinearizationConst *linC = new EcalTPGLinearizationConst;
0081 
0082     for (int iChannel = 0; iChannel < kEBChannels; iChannel++) {
0083       getline(fWeek, line);
0084       //     std::cout << " line " << line << std::endl;
0085       //      fWeek >> cryst >> id;
0086       sscanf(line.c_str(), "%s %u", cryst, &id);
0087       //      std::cout << cryst << " id " << id << std::endl;
0088       // EBDetId ebId = DetId(id);
0089       for (int gain = 0; gain < kGains; gain++) {
0090         //  fWeek >> std::hex >> ped[gain] >> mult[gain] >> shift[gain];
0091         getline(fWeek, line);
0092         //  std::cout << " line g " << line << std::endl;
0093         sscanf(line.c_str(), "%X %X %X", &ped[gain], &mult[gain], &shift[gain]);
0094         //  std::cout << " gain " << gain << " ped " << ped[gain] << " mult " << mult[gain] << " shift " << shift[gain]<< std::endl;
0095       }
0096       EcalTPGLinearizationConst::Item item;
0097       item.mult_x1 = mult[2];
0098       item.mult_x6 = mult[1];
0099       item.mult_x12 = mult[0];
0100       item.shift_x1 = shift[2];
0101       item.shift_x6 = shift[1];
0102       item.shift_x12 = shift[0];
0103 
0104       linC->insert(std::make_pair(id, item));
0105       //      corr.p1=corr.p2=corr.p3 = corrp;
0106       //      corrSet->setValue((int)ebId, corr );
0107       //      cryst ="";
0108     }  // end loop over EB channels
0109     getline(fWeek, line);  // cmment before EE crystals
0110     std::cout << " comment line " << line << std::endl;
0111     for (int iChannel = 0; iChannel < kEEChannels; iChannel++) {
0112       getline(fWeek, line);
0113       //      std::cout << " line " << line << std::endl;
0114       sscanf(line.c_str(), "%s %u", cryst, &id);
0115       //      std::cout << cryst << " id " << id << std::endl;
0116       // EEDetId eeId = DetId(id);
0117       for (int gain = 0; gain < kGains; gain++) {
0118         getline(fWeek, line);
0119         //  std::cout << " line g " << line << std::endl;
0120         sscanf(line.c_str(), "%X %X %X", &ped[gain], &mult[gain], &shift[gain]);
0121         //  std::cout << " gain " << gain << " ped " << ped[gain] << " mult " << mult[gain] << " shift " << shift[gain]<< std::endl;
0122 
0123       }  //      corr.p1=corr.p2=corr.p3 = corrp;
0124       //      corrSet->setValue((int)eeId, corr );
0125       EcalTPGLinearizationConst::Item item;
0126       item.mult_x1 = mult[2];
0127       item.mult_x6 = mult[1];
0128       item.mult_x12 = mult[0];
0129       item.shift_x1 = shift[2];
0130       item.shift_x6 = shift[1];
0131       item.shift_x12 = shift[0];
0132 
0133       linC->insert(std::make_pair(id, item));
0134     }  // end loop over EE channels
0135     fWeek.close();
0136     // special tag for Stephanie
0137     //    m_to_transfer.push_back(std::make_pair((EcalTPGLinearizationConst*)linC, file[week]));
0138     m_to_transfer.push_back(std::make_pair(linC, fileIOV));
0139     // end special
0140   }  // end loop over week
0141   std::cout << "Ecal -> end of getNewObjects -----------\n";
0142 }