Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-14 11:44:45

0001 /*----------------------------------------------------------------------
0002 
0003 Toy EDProducers and EDProducts for testing purposes only.
0004 
0005 ----------------------------------------------------------------------*/
0006 
0007 #include <stdexcept>
0008 #include <string>
0009 #include <iostream>
0010 #include <map>
0011 
0012 #include "CondFormats/Calibration/interface/Pedestals.h"
0013 #include "CondFormats/DataRecord/interface/PedestalsRcd.h"
0014 
0015 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0016 #include "FWCore/Framework/interface/Event.h"
0017 #include "FWCore/Framework/interface/EventSetup.h"
0018 #include "FWCore/Framework/interface/MakerMacros.h"
0019 
0020 using namespace std;
0021 
0022 namespace edmtest {
0023   class PedestalsByLabelAnalyzer : public edm::one::EDAnalyzer<> {
0024   public:
0025     explicit PedestalsByLabelAnalyzer(edm::ParameterSet const& p)
0026         : thePedestalToken_(esConsumes(edm::ESInputTag("", "lab3d"))) {
0027       edm::LogPrint("PedestalsByLabelAnalyzer") << "PedestalsByLabelAnalyzer";
0028     }
0029     explicit PedestalsByLabelAnalyzer(int i) {
0030       edm::LogPrint("PedestalsByLabelAnalyzer") << "PedestalsByLabelAnalyzer " << i;
0031     }
0032     virtual ~PedestalsByLabelAnalyzer() { edm::LogPrint("PedestalsByLabelAnalyzer") << "~PedestalsByLabelAnalyzer "; }
0033     virtual void analyze(const edm::Event& e, const edm::EventSetup& c);
0034 
0035   private:
0036     const edm::ESGetToken<Pedestals, PedestalsRcd> thePedestalToken_;
0037   };
0038 
0039   void PedestalsByLabelAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) {
0040     using namespace edm::eventsetup;
0041     // Context is not used.
0042     edm::LogPrint("PedestalsByLabelAnalyzer") << " I AM IN RUN NUMBER " << e.id().run();
0043     edm::LogPrint("PedestalsByLabelAnalyzer") << " ---EVENT NUMBER " << e.id().event();
0044     edm::eventsetup::EventSetupRecordKey recordKey(
0045         edm::eventsetup::EventSetupRecordKey::TypeTag::findType("PedestalsRcd"));
0046     if (recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
0047       //record not found
0048       edm::LogPrint("PedestalsByLabelAnalyzer") << "Record \"PedestalsRcd\" does not exist";
0049     }
0050     edm::LogPrint("PedestalsByLabelAnalyzer") << "got context";
0051     auto const& myped = &context.getData(thePedestalToken_);
0052     edm::LogPrint("PedestalsByLabelAnalyzer") << "Pedestals* " << myped;
0053     for (std::vector<Pedestals::Item>::const_iterator it = myped->m_pedestals.begin(); it != myped->m_pedestals.end();
0054          ++it)
0055       edm::LogPrint("PedestalsByLabelAnalyzer") << " mean: " << it->m_mean << " variance: " << it->m_variance;
0056     edm::LogPrint("PedestalsByLabelAnalyzer") << std::endl;
0057   }
0058   DEFINE_FWK_MODULE(PedestalsByLabelAnalyzer);
0059 }  // namespace edmtest