Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:11:39

0001 #include "DQM/SiStripCommissioningSources/interface/VpspScanTask.h"
0002 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0003 #include "DataFormats/SiStripCommon/interface/SiStripFecKey.h"
0004 #include "DataFormats/SiStripCommon/interface/SiStripHistoTitle.h"
0005 #include "DQMServices/Core/interface/DQMStore.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include <algorithm>
0008 
0009 using namespace sistrip;
0010 
0011 // -----------------------------------------------------------------------------
0012 //
0013 VpspScanTask::VpspScanTask(DQMStore* dqm, const FedChannelConnection& conn)
0014     : CommissioningTask(dqm, conn, "VpspScanTask"), vpsp_() {}
0015 
0016 // -----------------------------------------------------------------------------
0017 //
0018 VpspScanTask::~VpspScanTask() {}
0019 
0020 // -----------------------------------------------------------------------------
0021 //
0022 void VpspScanTask::book() {
0023   uint16_t nbins = 60;
0024 
0025   std::string title;
0026 
0027   vpsp_.resize(2);
0028   for (uint16_t iapv = 0; iapv < 2; iapv++) {
0029     if (connection().i2cAddr(iapv)) {
0030       std::stringstream extra_info;
0031       extra_info << sistrip::apv_ << iapv;
0032 
0033       title = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0034                                 sistrip::VPSP_SCAN,
0035                                 sistrip::FED_KEY,
0036                                 fedKey(),
0037                                 sistrip::LLD_CHAN,
0038                                 connection().lldChannel(),
0039                                 extra_info.str())
0040                   .title();
0041 
0042       vpsp_[iapv].histo(dqm()->bookProfile(title, title, nbins, -0.5, nbins * 1. - 0.5, 1025, 0., 1025.));
0043 
0044       vpsp_[iapv].vNumOfEntries_.resize(nbins, 0);
0045       vpsp_[iapv].vSumOfContents_.resize(nbins, 0);
0046       vpsp_[iapv].vSumOfSquares_.resize(nbins, 0);
0047     }
0048   }
0049 }
0050 
0051 // -----------------------------------------------------------------------------
0052 //
0053 void VpspScanTask::fill(const SiStripEventSummary& summary, const edm::DetSet<SiStripRawDigi>& digis) {
0054   // Retrieve VPSP setting and CCU channel
0055   uint32_t vpsp = summary.vpsp();
0056   uint32_t ccu_chan = summary.vpspCcuChan();
0057 
0058   // Check CCU channel from EventSummary is consistent with this module
0059   if (SiStripFecKey(fecKey()).ccuChan() != ccu_chan) {
0060     return;
0061   }
0062 
0063   if (digis.data.size() != 256) {
0064     edm::LogWarning(mlDqmSource_) << "[VpspScanTask::" << __func__ << "]"
0065                                   << " Unexpected number of digis! " << digis.data.size();
0066     return;
0067   }
0068 
0069   // Fill histo with baseline(calc'ed from median value of data)
0070   for (uint16_t iapv = 0; iapv < 2; iapv++) {
0071     if (vpsp >= vpsp_[iapv].vNumOfEntries_.size()) {
0072       edm::LogWarning(mlDqmSource_) << "[VpspScanTask::" << __func__ << "]"
0073                                     << " Unexpected VPSP value! " << vpsp;
0074       return;
0075     }
0076 
0077     std::vector<uint16_t> baseline;
0078     baseline.reserve(128);
0079     for (uint16_t idigi = 128 * iapv; idigi < 128 * (iapv + 1); idigi++) {
0080       baseline.push_back(digis.data[idigi].adc());
0081     }
0082     sort(baseline.begin(), baseline.end());
0083     uint16_t index = baseline.size() % 2 ? baseline.size() / 2 : baseline.size() / 2 - 1;
0084 
0085     if (!baseline.empty()) {
0086       updateHistoSet(vpsp_[iapv], vpsp, baseline[index]);
0087     }
0088   }
0089 }
0090 
0091 // -----------------------------------------------------------------------------
0092 //
0093 void VpspScanTask::update() {
0094   for (uint32_t iapv = 0; iapv < vpsp_.size(); iapv++) {
0095     updateHistoSet(vpsp_[iapv]);
0096   }
0097 }