CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
SiStripDelay Class Reference

#include <SiStripDelay.h>

Public Member Functions

void clear ()
 Empty all the containers. More...
 
void fillNewDelay (const SiStripBaseDelay &baseDelay, const int sumSign, const std::pair< std::string, std::string > &recordLabelPair)
 
const SiStripBaseDelaygetBaseDelay (const uint32_t index) const
 
float getDelay (const uint32_t detId) const
 Return the delay combining all the baseDelays. More...
 
std::string getLabelName (const uint32_t index) const
 
size_t getNumberOfTags () const
 
std::string getRcdName (const uint32_t index) const
 
int getTagSign (const uint32_t index) const
 
bool makeDelay ()
 Builds the boost::unordered_map. More...
 
const SiStripDelayoperator= (const SiStripDelay &)=delete
 
void printDebug (std::stringstream &ss, const TrackerTopology *tTopo) const
 Prints the delays for all the detIds. More...
 
void printSummary (std::stringstream &ss, const TrackerTopology *trackerTopo) const
 
 SiStripDelay ()
 
 SiStripDelay (const SiStripBaseDelay &baseDelay, const int sumSign, const std::pair< std::string, std::string > &recordLabelPair)
 
 SiStripDelay (const SiStripDelay &)=delete
 
virtual ~SiStripDelay ()
 

Private Attributes

std::vector< const SiStripBaseDelay * > baseDelayVector_
 
std::unordered_map< uint32_t, double > delays_
 
std::vector< std::pair< std::string, std::string > > recordLabelPair_
 
std::vector< int > sumSignVector_
 

Detailed Description

Author: M. De Mattia (demat.nosp@m.tia@.nosp@m.pd.in.nosp@m.fn.i.nosp@m.t) 25/10/2010:

Dependent record used to combine the SiStripBaseDelays and provide the reconstruction with a single delay value.
When the object is built the list of values is stored in boost::unordered_map which, for the number of modules in the Tracker (~15000) resulted much faster (more than a factor 2) than a std::map or a lower_bound search in a sorted vector.
The base delays must be filled in together with the sign they will get in the summation: baseDelay1*sign1 + baseDelay2*sign2 + ...
Pointers to the baseDelays are stored and after the fill is complete the method "makeDelay" must be called to build the internal map.
This additional step is required such that we don't build the map anytime a new baseDelay is inserted and we don't make checks anytime the getDelay method is called.
NOTE: Even if the code does not rely on the presence of the same detIds in all the baseDelays, this condition should be fullfilled for consistency. The code checks only that the number of detIds is the same in all baseDelays.

Definition at line 33 of file SiStripDelay.h.

Constructor & Destructor Documentation

◆ SiStripDelay() [1/3]

SiStripDelay::SiStripDelay ( )
inline

Definition at line 35 of file SiStripDelay.h.

35 {};

◆ ~SiStripDelay()

virtual SiStripDelay::~SiStripDelay ( )
inlinevirtual

Definition at line 36 of file SiStripDelay.h.

36 {};

◆ SiStripDelay() [2/3]

SiStripDelay::SiStripDelay ( const SiStripDelay )
delete

◆ SiStripDelay() [3/3]

SiStripDelay::SiStripDelay ( const SiStripBaseDelay baseDelay,
const int  sumSign,
const std::pair< std::string, std::string > &  recordLabelPair 
)
inline

Definition at line 41 of file SiStripDelay.h.

43  {
44  fillNewDelay(baseDelay, sumSign, recordLabelPair);
45  }

References fillNewDelay().

Member Function Documentation

◆ clear()

void SiStripDelay::clear ( void  )

Empty all the containers.

Definition at line 111 of file SiStripDelay.cc.

111  {
112  baseDelayVector_.clear();
113  sumSignVector_.clear();
114  recordLabelPair_.clear();
115  delays_.clear();
116 }

References baseDelayVector_, delays_, recordLabelPair_, and sumSignVector_.

Referenced by BeautifulSoup.Tag::setString().

◆ fillNewDelay()

void SiStripDelay::fillNewDelay ( const SiStripBaseDelay baseDelay,
const int  sumSign,
const std::pair< std::string, std::string > &  recordLabelPair 
)

Definition at line 18 of file SiStripDelay.cc.

20  {
21  baseDelayVector_.push_back(&baseDelay);
22  sumSignVector_.push_back(sumSign);
23  recordLabelPair_.push_back(recordLabelPair);
24 }

References baseDelayVector_, recordLabelPair_, and sumSignVector_.

Referenced by SiStripDelay().

◆ getBaseDelay()

const SiStripBaseDelay* SiStripDelay::getBaseDelay ( const uint32_t  index) const
inline

The second parameter allows to specify which delay to retrieve, considering that they are in input order. NOTE that no protection is inside the method (because we want to keep it very light) therefore it is the caller duty to check that the index is in the correct range.

Definition at line 66 of file SiStripDelay.h.

66 { return baseDelayVector_[index]; }

References baseDelayVector_.

◆ getDelay()

float SiStripDelay::getDelay ( const uint32_t  detId) const

Return the delay combining all the baseDelays.

Definition at line 26 of file SiStripDelay.cc.

26  {
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 }

References delays_.

◆ getLabelName()

std::string SiStripDelay::getLabelName ( const uint32_t  index) const
inline

Definition at line 70 of file SiStripDelay.h.

70 { return recordLabelPair_[index].second; }

References recordLabelPair_.

◆ getNumberOfTags()

size_t SiStripDelay::getNumberOfTags ( ) const
inline

Definition at line 68 of file SiStripDelay.h.

68 { return baseDelayVector_.size(); }

References baseDelayVector_.

◆ getRcdName()

std::string SiStripDelay::getRcdName ( const uint32_t  index) const
inline

Definition at line 69 of file SiStripDelay.h.

69 { return recordLabelPair_[index].first; }

References recordLabelPair_.

◆ getTagSign()

int SiStripDelay::getTagSign ( const uint32_t  index) const
inline

Definition at line 71 of file SiStripDelay.h.

71 { return sumSignVector_[index]; }

References sumSignVector_.

◆ makeDelay()

bool SiStripDelay::makeDelay ( )

Builds the boost::unordered_map.

Definition at line 34 of file SiStripDelay.cc.

34  {
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 }

References baseDelayVector_, gather_cfg::cout, delays_, and sumSignVector_.

◆ operator=()

const SiStripDelay& SiStripDelay::operator= ( const SiStripDelay )
delete

◆ printDebug()

void SiStripDelay::printDebug ( std::stringstream &  ss,
const TrackerTopology tTopo 
) const

Prints the delays for all the detIds.

Definition at line 118 of file SiStripDelay.cc.

118  {
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 }

References delays_, and contentValuesCheck::ss.

◆ printSummary()

void SiStripDelay::printSummary ( std::stringstream &  ss,
const TrackerTopology trackerTopo 
) const

Prints the average value of the delays for all layers and wheels in the SiStripTracker

Definition at line 125 of file SiStripDelay.cc.

125  {
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 }

References delays_, and contentValuesCheck::ss.

Member Data Documentation

◆ baseDelayVector_

std::vector<const SiStripBaseDelay *> SiStripDelay::baseDelayVector_
private

Definition at line 82 of file SiStripDelay.h.

Referenced by clear(), fillNewDelay(), getBaseDelay(), getNumberOfTags(), and makeDelay().

◆ delays_

std::unordered_map<uint32_t, double> SiStripDelay::delays_
private

Definition at line 85 of file SiStripDelay.h.

Referenced by clear(), getDelay(), makeDelay(), printDebug(), and printSummary().

◆ recordLabelPair_

std::vector<std::pair<std::string, std::string> > SiStripDelay::recordLabelPair_
private

Definition at line 84 of file SiStripDelay.h.

Referenced by clear(), fillNewDelay(), getLabelName(), and getRcdName().

◆ sumSignVector_

std::vector<int> SiStripDelay::sumSignVector_
private

Definition at line 83 of file SiStripDelay.h.

Referenced by clear(), fillNewDelay(), getTagSign(), and makeDelay().

SiStripDelay::sumSignVector_
std::vector< int > sumSignVector_
Definition: SiStripDelay.h:83
gather_cfg.cout
cout
Definition: gather_cfg.py:144
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
SiStripDelay::baseDelayVector_
std::vector< const SiStripBaseDelay * > baseDelayVector_
Definition: SiStripDelay.h:82
SiStripDelay::delays_
std::unordered_map< uint32_t, double > delays_
Definition: SiStripDelay.h:85
SiStripDelay::fillNewDelay
void fillNewDelay(const SiStripBaseDelay &baseDelay, const int sumSign, const std::pair< std::string, std::string > &recordLabelPair)
Definition: SiStripDelay.cc:18
SiStripDelay::recordLabelPair_
std::vector< std::pair< std::string, std::string > > recordLabelPair_
Definition: SiStripDelay.h:84
SiStripDetSummary
Definition: SiStripDetSummary.h:28
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46