CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/CondTools/Ecal/src/EcalLaser_weekly_Linearization.cc

Go to the documentation of this file.
00001 #include "CondTools/Ecal/interface/EcalLaser_weekly_Linearization.h"
00002 #include "OnlineDB/EcalCondDB/interface/EcalLogicID.h"
00003 #include "OnlineDB/EcalCondDB/interface/LMFSextuple.h"
00004 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
00005 #include "CondCore/DBCommon/interface/Time.h"
00006 #include "DataFormats/Provenance/interface/Timestamp.h"
00007 #include "OnlineDB/EcalCondDB/interface/Tm.h"
00008 
00009 #include<iostream>
00010 #include<iomanip>
00011 #include <sstream>
00012 
00013 popcon::EcalLaser_weekly_Linearization::EcalLaser_weekly_Linearization(const edm::ParameterSet & ps) 
00014   : m_name(ps.getUntrackedParameter<std::string>("name","EcalLaser_weekly_Handler")) {
00015   std::cout << "EcalLaser Source handler constructor\n" << std::endl;
00016 }
00017 
00018 popcon::EcalLaser_weekly_Linearization::~EcalLaser_weekly_Linearization() {
00019   // do nothing
00020 }
00021 
00022 void popcon::EcalLaser_weekly_Linearization::getNewObjects() {
00023   //  int file[1] = {190708};
00024 
00025   int iIov = 0;  
00026 
00027   std::cout << "------- Ecal -> getNewObjects\n";
00028   
00029   
00030   unsigned long long max_since= 1;
00031   Ref payload= lastPayload();
00032   
00033   // here popcon tells us which is the last since of the last object in the offline DB
00034   max_since=tagInfo().lastInterval.first;
00035   Tm max_since_tm(max_since);
00036 
00037   //  const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap& laserRatiosMap = 
00038   //    payload->getLaserMap(); 
00039   //  std::cout << "payload->getLaserMap():  OK " << std::endl;
00040   //  std::cout << "Its size is " << laserRatiosMap.size() << std::endl;
00041   //  const EcalLaserAPDPNRatios::EcalLaserTimeStampMap& laserTimeMap = 
00042   //    payload->getTimeMap();
00043   //  std::cout << "payload->getTimeMap():  OK " << std::endl;
00044   //  std::cout << "Last Object in Offline DB has SINCE = "  << max_since
00045   //        << " -> " << max_since_tm.cmsNanoSeconds() 
00046   //        << " (" << max_since_tm << ")"
00047   //        << " and  SIZE = " << tagInfo().size
00048   //        << std::endl;
00049 
00050   for(int week = 0; week < 1; week++) {
00051     EcalTPGLinearizationConst *linC = new EcalTPGLinearizationConst;
00052     int fileIOV;
00053     std::cout << " which input IOV do you want " << std::endl;
00054     std::cin >> fileIOV; 
00055     std::ifstream fWeek;
00056     std::ostringstream oss;
00057     oss << fileIOV;
00058     std::string fname = "/afs/cern.ch/cms/ECAL/triggerTransp/TPG_beamv6_trans_" + oss.str() + "_spikekill.txt";
00059     /*
00060     oss << file[week];
00061     //    std::string fname = "/afs/cern.ch/cms/ECAL/triggerTransp/TPG_beamv5_trans_" + oss.str() + "_";
00062     std::string fname = "/afs/cern.ch/cms/ECAL/triggerTransp/TPG_beamv6_trans_" + oss.str() + "_";
00063     oss.str("");
00064     //   if(week == 32) oss << 200000;
00065     //   else oss << file[week + 1] - 1;
00066     oss << 200000;
00067     fname += oss.str() + ".txt";
00068     */
00069     fWeek.open(fname.c_str());
00070     if(!fWeek.is_open()) {
00071       std::cout << "ERROR : can't open file '" << fname << std::endl;
00072       break;
00073     }
00074     std::cout << " file " << fname << " opened" << std::endl;
00075     //    int rawId;
00076     //    float corrp;
00077     std::string line;
00078     for(int i = 0; i < 85; i++) getline (fWeek, line);
00079     char cryst[10];
00080     uint32_t  ped[kGains], mult[kGains], shift[kGains];
00081     uint32_t id;
00082     for (int iChannel = 0; iChannel < kEBChannels; iChannel++) {
00083       getline (fWeek, line);
00084       //     std::cout << " line " << line << std::endl;
00085       //      fWeek >> cryst >> id;
00086       sscanf(line.c_str(), "%s %u", cryst, &id);
00087       //      std::cout << cryst << " id " << id << std::endl; 
00088       // EBDetId ebId = DetId(id);
00089       for (int gain = 0; gain < kGains; gain++) {
00090         //      fWeek >> std::hex >> ped[gain] >> mult[gain] >> shift[gain];
00091         getline (fWeek, line);
00092         //      std::cout << " line g " << line << std::endl;
00093         sscanf(line.c_str(), "%X %X %X", &ped[gain], &mult[gain], &shift[gain]);
00094         //      std::cout << " gain " << gain << " ped " << ped[gain] << " mult " << mult[gain] << " shift " << shift[gain]<< std::endl;
00095       }
00096       EcalTPGLinearizationConst::Item item;
00097       item.mult_x1   = mult[2];
00098       item.mult_x6   = mult[1];
00099       item.mult_x12  = mult[0];
00100       item.shift_x1  = shift[2];
00101       item.shift_x6  = shift[1];
00102       item.shift_x12 = shift[0];
00103           
00104       linC->insert(std::make_pair(id, item));
00105       //      corr.p1=corr.p2=corr.p3 = corrp;
00106       //      corrSet->setValue((int)ebId, corr );
00107       //      cryst ="";
00108     }   // end loop over EB channels
00109     getline (fWeek, line);  // cmment before EE crystals
00110     std::cout << " comment line " << line << std::endl;
00111     for (int iChannel = 0; iChannel < kEEChannels; iChannel++) {
00112       getline (fWeek, line);
00113       //      std::cout << " line " << line << std::endl;
00114       sscanf(line.c_str(), "%s %u", cryst, &id);
00115       //      std::cout << cryst << " id " << id << std::endl; 
00116       // EEDetId eeId = DetId(id);
00117       for (int gain =0; gain < kGains; gain++) {
00118         getline (fWeek, line);
00119         //      std::cout << " line g " << line << std::endl;
00120         sscanf(line.c_str(), "%X %X %X", &ped[gain], &mult[gain], &shift[gain]);
00121         //      std::cout << " gain " << gain << " ped " << ped[gain] << " mult " << mult[gain] << " shift " << shift[gain]<< std::endl;
00122 
00123       }      //      corr.p1=corr.p2=corr.p3 = corrp;
00124       //      corrSet->setValue((int)eeId, corr );
00125       EcalTPGLinearizationConst::Item item;
00126       item.mult_x1   = mult[2];
00127       item.mult_x6   = mult[1];
00128       item.mult_x12  = mult[0];
00129       item.shift_x1  = shift[2];
00130       item.shift_x6  = shift[1];
00131       item.shift_x12 = shift[0];
00132           
00133       linC->insert(std::make_pair(id, item));
00134     }   // end loop over EE channels
00135     fWeek.close();
00136     // special tag for Stephanie
00137     //    m_to_transfer.push_back(std::make_pair((EcalTPGLinearizationConst*)linC, file[week]));
00138     m_to_transfer.push_back(std::make_pair((EcalTPGLinearizationConst*)linC, fileIOV));
00139     // end special
00140     iIov++;
00141   }   // end loop over week
00142   std::cout << "Ecal -> end of getNewObjects -----------\n";    
00143 }