Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef SiStripDeDx2DReader_H
0002 #define SiStripDeDx2DReader_H
0003 
0004 // system include files
0005 //#include <memory>
0006 
0007 // user include files
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/EventSetup.h"
0012 #include "FWCore/Framework/interface/ESHandle.h"
0013 #include "FWCore/ServiceRegistry/interface/Service.h"
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 #include "CondFormats/PhysicsToolsObjects/interface/Histogram2D.h"
0017 #include "CondFormats/DataRecord/interface/SiStripDeDxProton_2D_Rcd.h"
0018 
0019 #include <iostream>
0020 #include <stdio.h>
0021 #include <sys/time.h>
0022 
0023 class SiStripDeDx2DReader : public edm::one::EDAnalyzer<> {
0024 public:
0025   explicit SiStripDeDx2DReader(const edm::ParameterSet&);
0026   ~SiStripDeDx2DReader();
0027 
0028   void analyze(const edm::Event&, const edm::EventSetup&);
0029 
0030 private:
0031   const edm::ESGetToken<PhysicsTools::Calibration::VHistogramD2D, SiStripDeDxProton_2D_Rcd> SiStripDeDx2DToken_;
0032 };
0033 
0034 SiStripDeDx2DReader::SiStripDeDx2DReader(const edm::ParameterSet& iConfig) : SiStripDeDx2DToken_(esConsumes()) {}
0035 
0036 SiStripDeDx2DReader::~SiStripDeDx2DReader() = default;
0037 
0038 void SiStripDeDx2DReader::analyze(const edm::Event& e, const edm::EventSetup& iSetup) {
0039   edm::ESHandle<PhysicsTools::Calibration::VHistogramD2D> SiStripDeDx2D_ = iSetup.getHandle(SiStripDeDx2DToken_);
0040   edm::LogInfo("SiStripDeDx2DReader") << "[SiStripDeDx2DReader::analyze] End Reading SiStripDeDxProton_2D" << std::endl;
0041 
0042   for (int ihisto = 0; ihisto < 3; ihisto++) {
0043     std::cout << (SiStripDeDx2D_->vHist)[ihisto].numberOfBinsX() << "   "
0044               << (SiStripDeDx2D_->vHist)[ihisto].numberOfBinsY() << std::endl;
0045 
0046     for (int ix = 0; ix < 300; ix++) {
0047       for (int iy = 0; iy < 1000; iy++) {
0048         std::cout << (SiStripDeDx2D_->vHist)[ihisto].binContent(ix, iy) << " "
0049                   << (SiStripDeDx2D_->vHist)[ihisto].value(ix / 100., iy) << std::endl;
0050       }
0051     }
0052 
0053     std::cout << "Value = " << (SiStripDeDx2D_->vValues)[ihisto] << std::endl;
0054   }
0055 }
0056 
0057 #include "FWCore/PluginManager/interface/ModuleDef.h"
0058 #include "FWCore/Framework/interface/MakerMacros.h"
0059 
0060 DEFINE_FWK_MODULE(SiStripDeDx2DReader);
0061 
0062 #endif