CMS 3D CMS Logo

SiStripDelay.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripObjects
4 // Class : SiStripDelay
5 // Implementation:
6 // <Notes on implementation>
7 // Original Author: M. De Mattia
8 // Created: 26/10/2010
9 
15 #include <cassert>
16 #include <sstream>
17 
19  const int sumSign,
20  const std::pair<std::string, std::string> &recordLabelPair) {
21  baseDelayVector_.push_back(&baseDelay);
22  sumSignVector_.push_back(sumSign);
23  recordLabelPair_.push_back(recordLabelPair);
24 }
25 
26 float SiStripDelay::getDelay(const uint32_t detId) const {
27  std::unordered_map<uint32_t, double>::const_iterator it = delays_.find(detId);
28  if (it != delays_.end()) {
29  return it->second;
30  }
31  return 0.;
32 }
33 
35  if (baseDelayVector_.empty()) {
36  return false;
37  }
38  std::vector<const SiStripBaseDelay *>::const_iterator it = baseDelayVector_.begin();
39  // Check for consistent size in all baseDelays
40  if (baseDelayVector_.size() > 1) {
41  for (; it != baseDelayVector_.end() - 1; ++it) {
42  if ((*it)->delaysSize() != (*(it + 1))->delaysSize()) {
43  std::cout << "makeDelay: Error, size of base delays is different!!" << std::endl;
44  return false;
45  }
46  }
47  }
48 
49  // // All checks done, fill the boost::unoredered_map with the first one
50  // (initialization) int sumSignIndex = 0; int sumSign = 0;
51  // std::vector<uint32_t>::const_iterator detIdIt;
52  // for( it = baseDelayVector_.begin(); it != baseDelayVector_.end(); ++it,
53  // ++sumSignIndex ) {
54  // std::vector<uint32_t> detIds;
55  // (*it)->detIds(detIds);
56  // sumSign = sumSignVector_[sumSignIndex];
57  // for( detIdIt = detIds.begin(); detIdIt != detIds.end(); ++detIdIt ) {
58  // // Check if is alread there so that we never rely on the default
59  // initialization boost::unordered_map<uint32_t, double>::iterator
60  // delayIt = delays_.find(*detIdIt); if( delayIt != delays_.end() ) {
61  // std::cout << "second delay = " << (*it)->delay(*detIdIt)*sumSign <<
62  // std::endl; delays_[*detIdIt] += (*it)->delay(*detIdIt)*sumSign;
63  // std::cout
64  // << "Full delay = " << delays_[*detIdIt] << std::endl;
65  // }
66  // else {
67  // std::cout << "first delay = " << (*it)->delay(*detIdIt)*sumSign <<
68  // std::endl; delays_[*detIdIt] = (*it)->delay(*detIdIt)*sumSign;
69  // }
70  // }
71  // }
72 
73  // All checks done, fill the boost::unoredered_map with the first one
74  // (initialization)
75  int sumSignIndex = 0;
76  int sumSign = sumSignVector_[sumSignIndex];
77  it = baseDelayVector_.begin();
78  std::vector<uint32_t> detIds;
79  (*it)->detIds(detIds);
80  std::vector<uint32_t>::const_iterator detIdIt = detIds.begin();
81  for (; detIdIt != detIds.end(); ++detIdIt) {
82  delays_[*detIdIt] = (*it)->delay(*detIdIt) * sumSign;
83  }
84  ++it;
85  ++sumSignIndex;
86  // Fill all the others
87  for (; it != baseDelayVector_.end(); ++it, ++sumSignIndex) {
88  std::vector<uint32_t> detIds;
89  (*it)->detIds(detIds);
90  detIdIt = detIds.begin();
91  sumSign = sumSignVector_[sumSignIndex];
92  for (; detIdIt != detIds.end(); ++detIdIt) {
93  // The same detIds should be in both maps, if not don't rely on the
94  // default initialization
95  std::unordered_map<uint32_t, double>::iterator delayIt = delays_.find(*detIdIt);
96  if (delayIt != delays_.end()) {
97  delays_[*detIdIt] += (*it)->delay(*detIdIt) * sumSign;
98  } else {
99  std::cout << "makeDelay: Warning, detId = " << *detIdIt << " not present, summing to 0..." << std::endl;
100  std::cout << "This means that the two baseDelay tags have different "
101  "detIds. PLEASE, CHECK THAT THIS IS EXPECTED."
102  << std::endl;
103  delays_[*detIdIt] = (*it)->delay(*detIdIt) * sumSign;
104  }
105  }
106  }
107 
108  return true;
109 }
110 
112  baseDelayVector_.clear();
113  sumSignVector_.clear();
114  recordLabelPair_.clear();
115  delays_.clear();
116 }
117 
118 void SiStripDelay::printDebug(std::stringstream &ss, const TrackerTopology * /*trackerTopo*/) const {
119  std::unordered_map<uint32_t, double>::const_iterator it = delays_.begin();
120  for (; it != delays_.end(); ++it) {
121  ss << "detId = " << it->first << " delay = " << it->second << std::endl;
122  }
123 }
124 
125 void SiStripDelay::printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const {
126  SiStripDetSummary summaryDelays{trackerTopo};
127  std::unordered_map<uint32_t, double>::const_iterator it = delays_.begin();
128  for (; it != delays_.end(); ++it) {
129  summaryDelays.add(it->first, it->second);
130  }
131  summaryDelays.print(ss);
132 }
SiStripDelay::makeDelay
bool makeDelay()
Builds the boost::unordered_map.
Definition: SiStripDelay.cc:34
SiStripDelay.h
SiStripDetSummary.h
MessageLogger.h
SiStripDelay::sumSignVector_
std::vector< int > sumSignVector_
Definition: SiStripDelay.h:83
TrackerTopology
Definition: TrackerTopology.h:16
gather_cfg.cout
cout
Definition: gather_cfg.py:144
typelookup.h
SiStripDelay::printSummary
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Definition: SiStripDelay.cc:125
SiStripBaseDelay
Definition: SiStripBaseDelay.h:23
SiStripDelay::clear
void clear()
Empty all the containers.
Definition: SiStripDelay.cc:111
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
SiStripDelay::baseDelayVector_
std::vector< const SiStripBaseDelay * > baseDelayVector_
Definition: SiStripDelay.h:82
SiStripDetInfoFileReader.h
SiStripDelay::delays_
std::unordered_map< uint32_t, double > delays_
Definition: SiStripDelay.h:85
SiStripDelay::getDelay
float getDelay(const uint32_t detId) const
Return the delay combining all the baseDelays.
Definition: SiStripDelay.cc:26
SiStripDelay::fillNewDelay
void fillNewDelay(const SiStripBaseDelay &baseDelay, const int sumSign, const std::pair< std::string, std::string > &recordLabelPair)
Definition: SiStripDelay.cc:18
SiStripDelay::printDebug
void printDebug(std::stringstream &ss, const TrackerTopology *tTopo) const
Prints the delays for all the detIds.
Definition: SiStripDelay.cc:118
SiStripDelay::recordLabelPair_
std::vector< std::pair< std::string, std::string > > recordLabelPair_
Definition: SiStripDelay.h:84
SiStripDetSummary
Definition: SiStripDetSummary.h:28