Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-04 02:55:13

0001 // -*- C++ -*-
0002 //
0003 // Package:    SiPixelCalibConfigurationReadDb
0004 // Class:      SiPixelCalibConfigurationReadDb
0005 //
0006 /**\class SiPixelCalibConfigurationReadDb SiPixelCalibConfigurationReadDb.cc CalibTracker/SiPixelTools/plugins/SiPixelCalibConfigurationReadDb.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Freya Blekman
0015 //         Created:  Thu Sep 20 12:13:20 CEST 2007
0016 // $Id: SiPixelCalibConfigurationReadDb.cc,v 1.2 2009/02/10 09:27:50 fblekman Exp $
0017 //
0018 //
0019 
0020 // system include files
0021 #include <memory>
0022 
0023 // user include files
0024 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0025 #include "FWCore/Framework/interface/EventSetup.h"
0026 
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 
0029 #include "CondFormats/SiPixelObjects/interface/SiPixelCalibConfiguration.h"
0030 #include "FWCore/Framework/interface/ESHandle.h"
0031 #include "CondFormats/DataRecord/interface/SiPixelCalibConfigurationRcd.h"
0032 #include <iostream>
0033 //
0034 // class decleration
0035 //
0036 
0037 class SiPixelCalibConfigurationReadDb : public edm::one::EDAnalyzer<> {
0038 public:
0039   explicit SiPixelCalibConfigurationReadDb(const edm::ParameterSet&);
0040   ~SiPixelCalibConfigurationReadDb() override;
0041 
0042 private:
0043   const edm::ESGetToken<SiPixelCalibConfiguration, SiPixelCalibConfigurationRcd> calibConfigToken;
0044   void analyze(const edm::Event&, const edm::EventSetup&) override;
0045 
0046   // ----------member data ---------------------------
0047   bool verbose_;
0048 };
0049 
0050 //
0051 // constants, enums and typedefs
0052 //
0053 
0054 //
0055 // static data member definitions
0056 //
0057 
0058 //
0059 // constructors and destructor
0060 //
0061 SiPixelCalibConfigurationReadDb::SiPixelCalibConfigurationReadDb(const edm::ParameterSet& iConfig)
0062     : calibConfigToken(esConsumes()), verbose_(iConfig.getParameter<bool>("verbosity")) {
0063   //now do what ever initialization is needed
0064 }
0065 
0066 SiPixelCalibConfigurationReadDb::~SiPixelCalibConfigurationReadDb() = default;
0067 
0068 //
0069 // member functions
0070 //
0071 
0072 // ------------ method called to for each event  ------------
0073 void SiPixelCalibConfigurationReadDb::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0074   using namespace edm;
0075 
0076   LogInfo("") << " examining SiPixelCalibConfiguration database object..." << std::endl;
0077 
0078   const SiPixelCalibConfiguration* calib = &iSetup.getData(calibConfigToken);
0079   edm::LogPrint("SiPixelCalibConfigurationReadDb") << "calibration type: " << calib->getCalibrationMode() << std::endl;
0080   edm::LogPrint("SiPixelCalibConfigurationReadDb") << "number of triggers: " << calib->getNTriggers() << std::endl;
0081   std::vector<short> vcalvalues = calib->getVCalValues();
0082   edm::LogPrint("SiPixelCalibConfigurationReadDb") << "number of VCAL: " << vcalvalues.size() << std::endl;
0083   int ngoodcols = 0;
0084   int ngoodrows = 0;
0085   for (uint32_t i = 0; i < vcalvalues.size(); ++i) {
0086     if (verbose_) {
0087       edm::LogPrint("SiPixelCalibConfigurationReadDb")
0088           << "Vcal values " << i << "," << i + 1 << " : " << vcalvalues[i] << ",";
0089     }
0090     ++i;
0091     if (verbose_) {
0092       if (i < vcalvalues.size())
0093         edm::LogPrint("SiPixelCalibConfigurationReadDb") << vcalvalues[i];
0094       edm::LogPrint("SiPixelCalibConfigurationReadDb") << std::endl;
0095     }
0096   }
0097   if (verbose_)
0098     edm::LogPrint("SiPixelCalibConfigurationReadDb") << "column patterns:" << std::endl;
0099   for (uint32_t i = 0; i < calib->getColumnPattern().size(); ++i) {
0100     if (calib->getColumnPattern()[i] != -1) {
0101       if (verbose_)
0102         edm::LogPrint("SiPixelCalibConfigurationReadDb") << calib->getColumnPattern()[i];
0103       ngoodcols++;
0104     }
0105     if (verbose_) {
0106       if (i != 0)
0107         edm::LogPrint("SiPixelCalibConfigurationReadDb") << " ";
0108       if (calib->getColumnPattern()[i] == -1)
0109         edm::LogPrint("SiPixelCalibConfigurationReadDb") << "- ";
0110     }
0111   }
0112   if (verbose_) {
0113     edm::LogPrint("SiPixelCalibConfigurationReadDb") << std::endl;
0114     edm::LogPrint("SiPixelCalibConfigurationReadDb") << "row patterns:" << std::endl;
0115   }
0116   for (uint32_t i = 0; i < calib->getRowPattern().size(); ++i) {
0117     if (calib->getRowPattern()[i] != -1) {
0118       if (verbose_)
0119         edm::LogPrint("SiPixelCalibConfigurationReadDb") << calib->getRowPattern()[i];
0120       ngoodrows++;
0121     }
0122     if (verbose_) {
0123       if (i != 0)
0124         edm::LogPrint("SiPixelCalibConfigurationReadDb") << " ";
0125       if (calib->getRowPattern()[i] == -1)
0126         edm::LogPrint("SiPixelCalibConfigurationReadDb") << "- ";
0127     }
0128   }
0129   if (verbose_) {
0130     edm::LogPrint("SiPixelCalibConfigurationReadDb") << std::endl;
0131     edm::LogPrint("SiPixelCalibConfigurationReadDb") << "number of row patterns: " << ngoodrows << std::endl;
0132     edm::LogPrint("SiPixelCalibConfigurationReadDb") << "number of column patterns: " << ngoodcols << std::endl;
0133   }
0134   edm::LogPrint("SiPixelCalibConfigurationReadDb")
0135       << "this payload is designed to run on " << vcalvalues.size() * ngoodcols * ngoodrows * calib->getNTriggers()
0136       << " events." << std::endl;
0137 }
0138 
0139 //define this as a plug-in
0140 DEFINE_FWK_MODULE(SiPixelCalibConfigurationReadDb);