Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-15 05:17:25

0001 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0002 #include "FWCore/Framework/interface/EventSetup.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 
0006 #include "FWCore/Framework/interface/ESHandle.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0009 #include "CondFormats/DataRecord/interface/SiStripPedestalsRcd.h"
0010 #include "CondFormats/SiStripObjects/interface/SiStripPedestals.h"
0011 #include <iostream>
0012 #include <sstream>
0013 
0014 /**
0015    @class test_PedestalsBuilder 
0016    @brief Simple class that analyzes Digis produced by RawToDigi unpacker
0017 */
0018 class test_PedestalsBuilder : public edm::global::EDAnalyzer<> {
0019 public:
0020   test_PedestalsBuilder(const edm::ParameterSet&) : pedToken_(esConsumes()) {}
0021   virtual ~test_PedestalsBuilder() override = default;
0022   void analyze(edm::StreamID, const edm::Event&, const edm::EventSetup&) const override;
0023 
0024 private:
0025   const edm::ESGetToken<SiStripPedestals, SiStripPedestalsRcd> pedToken_;
0026 };
0027 
0028 using namespace std;
0029 using namespace sistrip;
0030 
0031 // -----------------------------------------------------------------------------
0032 void test_PedestalsBuilder::analyze(edm::StreamID, const edm::Event& event, const edm::EventSetup& setup) const {
0033   LogTrace(mlCabling_) << "[test_PedestalsBuilder::" << __func__ << "]"
0034                        << " Dumping all FED connections...";
0035 
0036   const SiStripPedestals* peds = &setup.getData(pedToken_);
0037 
0038   // Retrieve DetIds in Pedestals object
0039   vector<uint32_t> det_ids;
0040   peds->getDetIds(det_ids);
0041 
0042   // Iterate through DetIds
0043   vector<uint32_t>::const_iterator det_id = det_ids.begin();
0044   for (; det_id != det_ids.end(); det_id++) {
0045     // Retrieve pedestals for given DetId
0046     SiStripPedestals::Range range = peds->getRange(*det_id);
0047 
0048     // Check if module has 512 or 768 strips (horrible!)
0049     uint16_t nstrips = 2 * sistrip::STRIPS_PER_FEDCH;
0050     //     try {
0051     //       peds->getPed( 2*sistrip::STRIPS_PER_FEDCH, range );
0052     //     } catch ( cms::Exception& e ) {
0053     //       nstrips = 2*sistrip::STRIPS_PER_FEDCH;
0054     //     }
0055 
0056     stringstream ss;
0057     ss << "[test_PedestalsBuilder::" << __func__ << "]"
0058        << " Found " << nstrips << " pedestals for DetId " << *det_id << " (ped/low/high): ";
0059 
0060     // Extract peds and low/high thresholds
0061     for (uint16_t istrip = 0; istrip < nstrips; istrip++) {
0062       ss << peds->getPed(istrip, range) << ", ";
0063     }
0064 
0065     LogTrace(mlCabling_) << ss.str();
0066   }
0067 }
0068 
0069 #include "FWCore/Framework/interface/MakerMacros.h"
0070 DEFINE_FWK_MODULE(test_PedestalsBuilder);