Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-27 04:04:15

0001 #ifndef CalibTracker_SiStripESProducer_DummyCondObjPrinter_h
0002 #define CalibTracker_SiStripESProducer_DummyCondObjPrinter_h
0003 
0004 // user include files
0005 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0006 #include "FWCore/Framework/interface/ESWatcher.h"
0007 #include "FWCore/Framework/interface/EventSetup.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 #include "FWCore/ServiceRegistry/interface/Service.h"
0011 #include "FWCore/Utilities/interface/Exception.h"
0012 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0013 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0014 #include <string>
0015 
0016 template <typename TObject, typename TRecord>
0017 class DummyCondObjPrinter : public edm::one::EDAnalyzer<> {
0018 public:
0019   explicit DummyCondObjPrinter(const edm::ParameterSet& iConfig);
0020   ~DummyCondObjPrinter() override;
0021   void analyze(const edm::Event& e, const edm::EventSetup& es) override;
0022 
0023 private:
0024   edm::ParameterSet iConfig_;
0025   edm::ESWatcher<TRecord> watcher_;
0026   edm::ESGetToken<TObject, TRecord> token_;
0027   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
0028 };
0029 
0030 template <typename TObject, typename TRecord>
0031 DummyCondObjPrinter<TObject, TRecord>::DummyCondObjPrinter(const edm::ParameterSet& iConfig)
0032     : iConfig_(iConfig), token_(esConsumes()), tTopoToken_(esConsumes()) {
0033   edm::LogInfo("DummyCondObjPrinter") << "DummyCondObjPrinter constructor for typename " << typeid(TObject).name()
0034                                       << " and record " << typeid(TRecord).name() << std::endl;
0035 }
0036 
0037 template <typename TObject, typename TRecord>
0038 DummyCondObjPrinter<TObject, TRecord>::~DummyCondObjPrinter() {
0039   edm::LogInfo("DummyCondObjPrinter") << "DummyCondObjPrinter::~DummyCondObjPrinter()" << std::endl;
0040 }
0041 
0042 template <typename TObject, typename TRecord>
0043 void DummyCondObjPrinter<TObject, TRecord>::analyze(const edm::Event& e, const edm::EventSetup& es) {
0044   if (!watcher_.check(es))
0045     return;
0046 
0047   const auto& esobj = es.getData(token_);
0048   const auto tTopo = &es.getData(tTopoToken_);
0049   std::stringstream sSummary, sDebug;
0050   esobj.printSummary(sSummary, tTopo);
0051   esobj.printDebug(sDebug, tTopo);
0052 
0053   //  edm::LogInfo("DummyCondObjPrinter") << "\nPrintSummary \n" << sSummary.str()  << std::endl;
0054   //  edm::LogWarning("DummyCondObjPrinter") << "\nPrintDebug \n" << sDebug.str()  << std::endl;
0055   edm::LogPrint("DummyCondObjContentPrinter") << "\nPrintSummary \n" << sSummary.str() << std::endl;
0056   edm::LogVerbatim("DummyCondObjContentPrinter") << "\nPrintDebug \n" << sDebug.str() << std::endl;
0057 }
0058 
0059 #endif