File indexing completed on 2024-04-06 11:58:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "CalibFormats/SiStripObjects/interface/SiStripDelay.h"
0011 #include "CondFormats/SiStripObjects/interface/SiStripDetSummary.h"
0012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0013 #include "FWCore/Utilities/interface/typelookup.h"
0014 #include <cassert>
0015 #include <sstream>
0016
0017 void SiStripDelay::fillNewDelay(const SiStripBaseDelay &baseDelay,
0018 const int sumSign,
0019 const std::pair<std::string, std::string> &recordLabelPair) {
0020 baseDelayVector_.push_back(&baseDelay);
0021 sumSignVector_.push_back(sumSign);
0022 recordLabelPair_.push_back(recordLabelPair);
0023 }
0024
0025 float SiStripDelay::getDelay(const uint32_t detId) const {
0026 std::unordered_map<uint32_t, double>::const_iterator it = delays_.find(detId);
0027 if (it != delays_.end()) {
0028 return it->second;
0029 }
0030 return 0.;
0031 }
0032
0033 bool SiStripDelay::makeDelay() {
0034 if (baseDelayVector_.empty()) {
0035 return false;
0036 }
0037 std::vector<const SiStripBaseDelay *>::const_iterator it = baseDelayVector_.begin();
0038
0039 if (baseDelayVector_.size() > 1) {
0040 for (; it != baseDelayVector_.end() - 1; ++it) {
0041 if ((*it)->delaysSize() != (*(it + 1))->delaysSize()) {
0042 std::cout << "makeDelay: Error, size of base delays is different!!" << std::endl;
0043 return false;
0044 }
0045 }
0046 }
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074 int sumSignIndex = 0;
0075 int sumSign = sumSignVector_[sumSignIndex];
0076 it = baseDelayVector_.begin();
0077 std::vector<uint32_t> detIds;
0078 (*it)->detIds(detIds);
0079 std::vector<uint32_t>::const_iterator detIdIt = detIds.begin();
0080 for (; detIdIt != detIds.end(); ++detIdIt) {
0081 delays_[*detIdIt] = (*it)->delay(*detIdIt) * sumSign;
0082 }
0083 ++it;
0084 ++sumSignIndex;
0085
0086 for (; it != baseDelayVector_.end(); ++it, ++sumSignIndex) {
0087 std::vector<uint32_t> detIds;
0088 (*it)->detIds(detIds);
0089 detIdIt = detIds.begin();
0090 sumSign = sumSignVector_[sumSignIndex];
0091 for (; detIdIt != detIds.end(); ++detIdIt) {
0092
0093
0094 std::unordered_map<uint32_t, double>::iterator delayIt = delays_.find(*detIdIt);
0095 if (delayIt != delays_.end()) {
0096 delays_[*detIdIt] += (*it)->delay(*detIdIt) * sumSign;
0097 } else {
0098 std::cout << "makeDelay: Warning, detId = " << *detIdIt << " not present, summing to 0..." << std::endl;
0099 std::cout << "This means that the two baseDelay tags have different "
0100 "detIds. PLEASE, CHECK THAT THIS IS EXPECTED."
0101 << std::endl;
0102 delays_[*detIdIt] = (*it)->delay(*detIdIt) * sumSign;
0103 }
0104 }
0105 }
0106
0107 return true;
0108 }
0109
0110 void SiStripDelay::clear() {
0111 baseDelayVector_.clear();
0112 sumSignVector_.clear();
0113 recordLabelPair_.clear();
0114 delays_.clear();
0115 }
0116
0117 void SiStripDelay::printDebug(std::stringstream &ss, const TrackerTopology * ) const {
0118 std::unordered_map<uint32_t, double>::const_iterator it = delays_.begin();
0119 for (; it != delays_.end(); ++it) {
0120 ss << "detId = " << it->first << " delay = " << it->second << std::endl;
0121 }
0122 }
0123
0124 void SiStripDelay::printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const {
0125 SiStripDetSummary summaryDelays{trackerTopo};
0126 std::unordered_map<uint32_t, double>::const_iterator it = delays_.begin();
0127 for (; it != delays_.end(); ++it) {
0128 summaryDelays.add(it->first, it->second);
0129 }
0130 summaryDelays.print(ss);
0131 }