Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:46:15

0001 #include "ExSourceHandler.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 
0006 //#include<iostream>
0007 #include <sstream>
0008 #include <vector>
0009 #include <string>
0010 #include <sstream>
0011 
0012 #include "CondCore/CondDB/interface/Serialization.h"
0013 
0014 namespace {
0015 
0016   void fill(Pedestals& p, int nc) {
0017     p.m_pedestals.reserve(nc);
0018     for (int ichannel = 1; ichannel <= nc; ++ichannel) {
0019       Pedestals::Item item;
0020       item.m_mean = 1.11 * ichannel;
0021       item.m_variance = 1.12 * ichannel;
0022       p.m_pedestals.push_back(item);
0023     }
0024   }
0025 }  // namespace
0026 
0027 popcon::ExPedestalSource::ExPedestalSource(const edm::ParameterSet& pset)
0028     : m_name(pset.getUntrackedParameter<std::string>("name", "ExPedestalSource")),
0029       m_since(pset.getUntrackedParameter<long long>("firstSince", 5)),
0030       m_increment(pset.getUntrackedParameter<long long>("increment", 10)),
0031       m_number(pset.getUntrackedParameter<long long>("number", 3)) {}
0032 
0033 popcon::ExPedestalSource::~ExPedestalSource() {}
0034 
0035 void popcon::ExPedestalSource::getNewObjects() {
0036   edm::LogInfo("ExPedestalsSource") << "------- " << m_name
0037                                     << " - > getNewObjects\n"
0038                                     //check whats already inside of database
0039                                     << "got offlineInfo" << tagInfo().name << ", size " << tagInfo().size
0040                                     << ", last object valid since " << tagInfo().lastInterval.since << " token "
0041                                     << tagInfo().lastInterval.payloadId << std::endl;
0042 
0043   //edm::LogInfo ("ExPedestalsSource")
0044   //  << " ------ last entry info regarding the payload (if existing): " <<logDBEntry().usertext
0045   //  << "; last record with the correct tag (if existing) has been written in the db: "
0046   //  <<logDBEntry().destinationDB<< std::endl;
0047 
0048   if (tagInfo().size > 0) {
0049     Ref payload = lastPayload();
0050     edm::LogInfo("ExPedestalsSource") << "size of last payload  " << payload->m_pedestals.size() << std::endl;
0051   }
0052 
0053   std::cout << "first since = " << m_since << std::endl;
0054 
0055   Pedestals* p0 = new Pedestals;
0056   fill(*p0, 3);
0057   m_to_transfer.push_back(std::make_pair((Pedestals*)p0, m_since));
0058 
0059   unsigned long long since = (unsigned long long)(m_since + m_increment * (m_number - 1));
0060 
0061   std::cout << "last since = " << since << std::endl;
0062 
0063   unsigned long long size = 5;
0064   for (unsigned long long j = 1; j < (unsigned long long)m_number; ++j) {
0065     Pedestals* p1 = new Pedestals;
0066     fill(*p1, size);
0067     m_to_transfer.push_back(std::make_pair((Pedestals*)p1, since));
0068     since -= m_increment;
0069     size += 2;
0070   }
0071 
0072   std::ostringstream ss;
0073   ss << "num=" << m_number << ","
0074      << "firstSize=3,"
0075      << "lastSize=" << size - 2 << std::endl;
0076 
0077   std::ostringstream fsince;
0078   fsince << "iov fisrtsince == " << m_since;
0079 
0080   m_userTextLog = ss.str() + ";" + fsince.str();
0081 
0082   edm::LogInfo("ExPedestalsSource") << "------- " << m_name << " - > getNewObjects" << std::endl;
0083 }