Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:43

0001 #include "EffSourceHandler.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 <memory>
0008 #include <sstream>
0009 #include <vector>
0010 #include <string>
0011 #include <sstream>
0012 #include <typeinfo>
0013 
0014 #include "CondCore/CondDB/interface/Serialization.h"
0015 
0016 namespace cond {
0017   template <>
0018   std::unique_ptr<condex::Efficiency> deserialize<condex::Efficiency>(const std::string& payloadType,
0019                                                                       const Binary& payloadData,
0020                                                                       const Binary& streamerInfoData) {
0021     // DESERIALIZE_BASE_CASE( condex::Efficiency );  abstract
0022     DESERIALIZE_POLIMORPHIC_CASE(condex::Efficiency, condex::ParametricEfficiencyInPt);
0023     DESERIALIZE_POLIMORPHIC_CASE(condex::Efficiency, condex::ParametricEfficiencyInEta);
0024 
0025     // here we come if none of the deserializations above match the payload type:
0026     throwException(std::string("Type mismatch, target object is type \"") + payloadType + "\"", "deserialize<>");
0027   }
0028 }  // namespace cond
0029 
0030 popcon::ExEffSource::ExEffSource(const edm::ParameterSet& pset)
0031     : m_name(pset.getUntrackedParameter<std::string>("name", "ExEffSource")),
0032       m_since(pset.getUntrackedParameter<long long>("since", 5)),
0033       m_type(pset.getUntrackedParameter<std::string>("type", "NULL")),
0034       m_params(pset.getUntrackedParameter<std::vector<double> >("params", std::vector<double>())) {}
0035 
0036 popcon::ExEffSource::~ExEffSource() {}
0037 
0038 void popcon::ExEffSource::getNewObjects() {
0039   edm::LogInfo("ExEffSource") << "------- " << m_name
0040                               << " - > getNewObjects\n"
0041                               //check whats already inside of database
0042                               << "got offlineInfo" << tagInfo().name << ", size " << tagInfo().size
0043                               << ", last object valid since " << tagInfo().lastInterval.since << " token "
0044                               << tagInfo().lastInterval.payloadId << std::endl;
0045   //
0046   //edm::LogInfo ("ExEffsSource")<< " ------ last entry info regarding the payload (if existing): " <<logDBEntry().usertext<<
0047   //  "; last record with the correct tag (if existing) has been written in the db: " <<logDBEntry().destinationDB<< std::endl;
0048 
0049   if (tagInfo().size > 0) {
0050     Ref payload = lastPayload();
0051     edm::LogInfo("ExEffsSource") << " type of last payload  " << typeid(value_type).name() << std::endl;
0052   }
0053 
0054   std::cout << "since = " << m_since << std::endl;
0055 
0056   // the most stupid factory It shall be not be anymore in fase with "record name"
0057   condex::Efficiency* p0 = 0;
0058   if (m_type.find("Eta") != std::string::npos)
0059     p0 = new condex::ParametricEfficiencyInEta(m_params[0], m_params[1], m_params[2], m_params[3]);
0060   else
0061     p0 = new condex::ParametricEfficiencyInPt(m_params[0], m_params[1], m_params[2], m_params[3]);
0062 
0063   if (p0 == 0) {
0064     edm::LogInfo("ExEffsSource") << " unable to build " << m_type << std::endl;
0065     return;
0066   }
0067 
0068   if ((unsigned long long)m_since > tagInfo().lastInterval.since) {
0069     m_to_transfer.push_back(std::make_pair(p0, (unsigned long long)m_since));
0070 
0071     std::ostringstream ss;
0072     ss << "type=" << m_type << ",since=" << m_since;
0073 
0074     m_userTextLog = ss.str() + ";";
0075   }
0076 
0077   edm::LogInfo("ExEffsSource") << "------- " << m_name << " - > getNewObjects" << std::endl;
0078 }
0079 
0080 #include "CondCore/PopCon/interface/PopConAnalyzer.h"
0081 #include "FWCore/Framework/interface/MakerMacros.h"
0082 
0083 typedef popcon::PopConAnalyzer<popcon::ExEffSource> ExPopConEfficiency;
0084 //define this as a plug-in
0085 DEFINE_FWK_MODULE(ExPopConEfficiency);