Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /*----------------------------------------------------------------------
0002 
0003 Toy EDProducers and EDProducts for testing purposes only.
0004 
0005 ----------------------------------------------------------------------*/
0006 
0007 #include <stdexcept>
0008 #include <string>
0009 #include <fstream>
0010 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0011 #include "FWCore/Framework/interface/Event.h"
0012 #include "FWCore/Framework/interface/MakerMacros.h"
0013 
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 #include "FWCore/Utilities/interface/ESGetToken.h"
0017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0018 
0019 #include "CondFormats/CSCObjects/interface/CSCDBChipSpeedCorrection.h"
0020 #include "CondFormats/DataRecord/interface/CSCDBChipSpeedCorrectionRcd.h"
0021 
0022 namespace edmtest {
0023   class CSCChipSpeedCorrectionDBReadAnalyzer : public edm::one::EDAnalyzer<> {
0024   public:
0025     explicit CSCChipSpeedCorrectionDBReadAnalyzer(edm::ParameterSet const& p) : token_{esConsumes()} {}
0026     ~CSCChipSpeedCorrectionDBReadAnalyzer() override {}
0027     void analyze(const edm::Event& e, const edm::EventSetup& c) override;
0028 
0029   private:
0030     edm::ESGetToken<CSCDBChipSpeedCorrection, CSCDBChipSpeedCorrectionRcd> token_;
0031   };
0032 
0033   void CSCChipSpeedCorrectionDBReadAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) {
0034     //const float epsilon = 1.E-09; // some 'small' value to test for non-positive values.
0035     //*    const float epsilon = 20; // some 'small' value to test
0036 
0037     using namespace edm::eventsetup;
0038     std::ofstream DBChipSpeedCorrectionFile("dbChipSpeedCorrection.dat", std::ios::out);
0039     int counter = 0;
0040 
0041     edm::LogSystem log("CSCDBChipSpeedCorrection");
0042 
0043     log << " I AM IN RUN NUMBER " << e.id().run() << std::endl;
0044     log << " ---EVENT NUMBER " << e.id().event() << std::endl;
0045 
0046     const CSCDBChipSpeedCorrection* myChipCorr = &context.getData(token_);
0047     CSCDBChipSpeedCorrection::ChipSpeedContainer::const_iterator it;
0048 
0049     for (it = myChipCorr->chipSpeedCorr.begin(); it != myChipCorr->chipSpeedCorr.end(); ++it) {
0050       counter++;
0051       DBChipSpeedCorrectionFile << counter << "  " << it->speedCorr / 100. << std::endl;
0052       //* if ( it->speedCorr <= epsilon ) DBChipSpeedCorrectionFile << " ERROR? Chip Correction <= " << epsilon << std::endl;
0053     }
0054   }
0055   DEFINE_FWK_MODULE(CSCChipSpeedCorrectionDBReadAnalyzer);
0056 }  // namespace edmtest