Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:59

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