Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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 <fstream>
0011 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "FWCore/Framework/interface/MakerMacros.h"
0014 
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 #include "FWCore/Utilities/interface/ESGetToken.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 
0019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0020 
0021 #include "CondFormats/CSCObjects/interface/CSCDBPedestals.h"
0022 #include "CondFormats/DataRecord/interface/CSCDBPedestalsRcd.h"
0023 
0024 namespace edmtest {
0025   class CSCPedestalDBReadAnalyzer : public edm::one::EDAnalyzer<> {
0026   public:
0027     explicit CSCPedestalDBReadAnalyzer(edm::ParameterSet const& p) : token_{esConsumes()} {}
0028     ~CSCPedestalDBReadAnalyzer() override {}
0029     void analyze(const edm::Event& e, const edm::EventSetup& c) override;
0030 
0031   private:
0032     edm::ESGetToken<CSCDBPedestals, CSCDBPedestalsRcd> token_;
0033   };
0034 
0035   void CSCPedestalDBReadAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) {
0036     const float epsilon = 1.E-09;  // some 'small' value to test for non-positive values.
0037 
0038     using namespace edm::eventsetup;
0039     std::ofstream DBPedestalFile("dbpeds.dat", std::ios::out);
0040     int counter = 0;
0041 
0042     edm::LogSystem log("CSCDBPedestals");
0043 
0044     log << " I AM IN RUN NUMBER " << e.id().run() << std::endl;
0045     log << " ---EVENT NUMBER " << e.id().event() << std::endl;
0046 
0047     const CSCDBPedestals* myped = &context.getData(token_);
0048     CSCDBPedestals::PedestalContainer::const_iterator it;
0049 
0050     for (it = myped->pedestals.begin(); it != myped->pedestals.end(); ++it) {
0051       counter++;
0052       DBPedestalFile << counter << "  " << it->ped << "  " << it->rms << std::endl;
0053       if (it->rms <= epsilon)
0054         DBPedestalFile << " ERROR? pedestal width <= " << epsilon << std::endl;
0055     }
0056   }
0057   DEFINE_FWK_MODULE(CSCPedestalDBReadAnalyzer);
0058 }  // namespace edmtest