Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:19

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