Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:41

0001 #include "CondFormats/SiStripObjects/interface/SiStripBaseDelay.h"
0002 
0003 #include <algorithm>
0004 #include <iterator>
0005 #include <iostream>
0006 #include <sstream>
0007 
0008 bool SiStripBaseDelay::put(const uint32_t detId, const uint16_t coarseDelay, const uint16_t fineDelay) {
0009   delays_.push_back(Delay(detId, coarseDelay, fineDelay));
0010   return true;
0011 }
0012 
0013 uint16_t SiStripBaseDelay::coarseDelay(const uint32_t detId) {
0014   delayConstIt it = std::find_if(delays_.begin(), delays_.end(), [&](auto& x) { return x.detId == detId; });
0015   if (it != delays_.end()) {
0016     return it->coarseDelay;
0017   }
0018   return 0;
0019 }
0020 
0021 uint16_t SiStripBaseDelay::fineDelay(const uint32_t detId) const {
0022   delayConstIt it = std::find_if(delays_.begin(), delays_.end(), [&](auto& x) { return x.detId == detId; });
0023   if (it != delays_.end()) {
0024     return it->fineDelay;
0025   }
0026   return 0;
0027 }
0028 
0029 double SiStripBaseDelay::delay(const uint32_t detId) const {
0030   delayConstIt it = std::find_if(delays_.begin(), delays_.end(), [&](auto& x) { return x.detId == detId; });
0031   if (it != delays_.end()) {
0032     return makeDelay(it->coarseDelay, it->fineDelay);
0033   }
0034   return 0;
0035 }
0036 
0037 void SiStripBaseDelay::detIds(std::vector<uint32_t>& detIdVector) const {
0038   std::vector<Delay>::const_iterator it = delays_.begin();
0039   for (; it != delays_.end(); ++it) {
0040     detIdVector.push_back(it->detId);
0041   }
0042 }
0043 
0044 void SiStripBaseDelay::printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const {
0045   ss << "Total number of delays = " << delays_.size() << std::endl;
0046   SiStripDetSummary summaryDelays{trackerTopo};
0047   delayConstIt it = delays_.begin();
0048   for (; it != delays_.end(); ++it) {
0049     summaryDelays.add(it->detId, makeDelay(it->coarseDelay, it->fineDelay));
0050   }
0051   ss << std::endl << "Summary:" << std::endl;
0052   summaryDelays.print(ss);
0053 }
0054 
0055 void SiStripBaseDelay::printDebug(std::stringstream& ss, const TrackerTopology* trackerTopo) const {
0056   printSummary(ss, trackerTopo);
0057   delayConstIt it = delays_.begin();
0058   ss << std::endl << "All pedestal values:" << std::endl;
0059   for (; it != delays_.end(); ++it) {
0060     ss << "detId = " << it->detId << " delay = " << makeDelay(it->coarseDelay, it->fineDelay) << std::endl;
0061   }
0062 }