CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private 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...
 
void printDebug (std::stringstream &ss) const
 Prints the delays for all the detIds. More...
 
void printSummary (std::stringstream &ss) const
 Prints the average value of the delays for all layers and wheels in the SiStripTracker. More...
 
 SiStripDelay ()
 
 SiStripDelay (const SiStripBaseDelay &baseDelay, const int sumSign, const std::pair< std::string, std::string > &recordLabelPair)
 
virtual ~SiStripDelay ()
 

Private Member Functions

const SiStripDelayoperator= (const SiStripDelay &)
 
 SiStripDelay (const SiStripDelay &)
 

Private Attributes

std::vector< const
SiStripBaseDelay * > 
baseDelayVector_
 
boost::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 32 of file SiStripDelay.h.

Constructor & Destructor Documentation

SiStripDelay::SiStripDelay ( )
inline

Definition at line 35 of file SiStripDelay.h.

35 {};
virtual SiStripDelay::~SiStripDelay ( )
inlinevirtual

Definition at line 36 of file SiStripDelay.h.

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

Definition at line 38 of file SiStripDelay.h.

References fillNewDelay().

40  {
41  fillNewDelay(baseDelay, sumSign, recordLabelPair);
42  }
void fillNewDelay(const SiStripBaseDelay &baseDelay, const int sumSign, const std::pair< std::string, std::string > &recordLabelPair)
Definition: SiStripDelay.cc:19
SiStripDelay::SiStripDelay ( const SiStripDelay )
private

Member Function Documentation

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

Definition at line 19 of file SiStripDelay.cc.

References baseDelayVector_, recordLabelPair_, and sumSignVector_.

Referenced by SiStripDelay().

21 {
22  baseDelayVector_.push_back(&baseDelay);
23  sumSignVector_.push_back(sumSign);
24  recordLabelPair_.push_back(recordLabelPair);
25 }
std::vector< std::pair< std::string, std::string > > recordLabelPair_
Definition: SiStripDelay.h:98
std::vector< const SiStripBaseDelay * > baseDelayVector_
Definition: SiStripDelay.h:96
std::vector< int > sumSignVector_
Definition: SiStripDelay.h:97
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 62 of file SiStripDelay.h.

References baseDelayVector_, and getHLTprescales::index.

63  {
64  return baseDelayVector_[index];
65  }
std::vector< const SiStripBaseDelay * > baseDelayVector_
Definition: SiStripDelay.h:96
float SiStripDelay::getDelay ( const uint32_t  detId) const

Return the delay combining all the baseDelays.

Definition at line 27 of file SiStripDelay.cc.

References delays_.

28 {
29  boost::unordered_map<uint32_t, double>::const_iterator it = delays_.find(detId);
30  if( it != delays_.end() ) {
31  return it->second;
32  }
33  return 0.;
34 }
boost::unordered_map< uint32_t, double > delays_
Definition: SiStripDelay.h:99
std::string SiStripDelay::getLabelName ( const uint32_t  index) const
inline

Definition at line 75 of file SiStripDelay.h.

References getHLTprescales::index, and recordLabelPair_.

76  {
77  return recordLabelPair_[index].second;
78  }
std::vector< std::pair< std::string, std::string > > recordLabelPair_
Definition: SiStripDelay.h:98
size_t SiStripDelay::getNumberOfTags ( ) const
inline

Definition at line 67 of file SiStripDelay.h.

References baseDelayVector_.

68  {
69  return baseDelayVector_.size();
70  }
std::vector< const SiStripBaseDelay * > baseDelayVector_
Definition: SiStripDelay.h:96
std::string SiStripDelay::getRcdName ( const uint32_t  index) const
inline

Definition at line 71 of file SiStripDelay.h.

References getHLTprescales::index, and recordLabelPair_.

72  {
73  return recordLabelPair_[index].first;
74  }
std::vector< std::pair< std::string, std::string > > recordLabelPair_
Definition: SiStripDelay.h:98
int SiStripDelay::getTagSign ( const uint32_t  index) const
inline

Definition at line 79 of file SiStripDelay.h.

References getHLTprescales::index, and sumSignVector_.

80  {
81  return sumSignVector_[index];
82  }
std::vector< int > sumSignVector_
Definition: SiStripDelay.h:97
bool SiStripDelay::makeDelay ( )

Builds the boost::unordered_map.

Definition at line 36 of file SiStripDelay.cc.

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

37 {
38  if( baseDelayVector_.empty() ) {
39  return false;
40  }
41  std::vector<const SiStripBaseDelay*>::const_iterator it = baseDelayVector_.begin();
42  // Check for consistent size in all baseDelays
43  if( baseDelayVector_.size() > 1 ) {
44  for( ; it != baseDelayVector_.end()-1; ++it ) {
45  if( (*it)->delaysSize() != (*(it+1))->delaysSize() ) {
46  std::cout << "makeDelay: Error, size of base delays is different!!" << std::endl;
47  return false;
48  }
49  }
50  }
51 
52 // // All checks done, fill the boost::unoredered_map with the first one (initialization)
53 // int sumSignIndex = 0;
54 // int sumSign = 0;
55 // std::vector<uint32_t>::const_iterator detIdIt;
56 // for( it = baseDelayVector_.begin(); it != baseDelayVector_.end(); ++it, ++sumSignIndex ) {
57 // std::vector<uint32_t> detIds;
58 // (*it)->detIds(detIds);
59 // sumSign = sumSignVector_[sumSignIndex];
60 // for( detIdIt = detIds.begin(); detIdIt != detIds.end(); ++detIdIt ) {
61 // // Check if is alread there so that we never rely on the default initialization
62 // boost::unordered_map<uint32_t, double>::iterator delayIt = delays_.find(*detIdIt);
63 // if( delayIt != delays_.end() ) {
64 // std::cout << "second delay = " << (*it)->delay(*detIdIt)*sumSign << std::endl;
65 // delays_[*detIdIt] += (*it)->delay(*detIdIt)*sumSign;
66 // std::cout << "Full delay = " << delays_[*detIdIt] << std::endl;
67 // }
68 // else {
69 // std::cout << "first delay = " << (*it)->delay(*detIdIt)*sumSign << std::endl;
70 // delays_[*detIdIt] = (*it)->delay(*detIdIt)*sumSign;
71 // }
72 // }
73 // }
74 
75  // All checks done, fill the boost::unoredered_map with the first one (initialization)
76  int sumSignIndex = 0;
77  int sumSign = sumSignVector_[sumSignIndex];
78  it = baseDelayVector_.begin();
79  std::vector<uint32_t> detIds;
80  (*it)->detIds(detIds);
81  std::vector<uint32_t>::const_iterator detIdIt = detIds.begin();
82  for( ; detIdIt != detIds.end(); ++detIdIt ) {
83  delays_[*detIdIt] = (*it)->delay(*detIdIt)*sumSign;
84  }
85  ++it;
86  ++sumSignIndex;
87  // Fill all the others
88  for( ; it != baseDelayVector_.end(); ++it, ++sumSignIndex ) {
89  std::vector<uint32_t> detIds;
90  (*it)->detIds(detIds);
91  detIdIt = detIds.begin();
92  sumSign = sumSignVector_[sumSignIndex];
93  for( ; detIdIt != detIds.end(); ++detIdIt ) {
94  // The same detIds should be in both maps, if not don't rely on the default initialization
95  boost::unordered_map<uint32_t, double>::iterator delayIt = delays_.find(*detIdIt);
96  if( delayIt != delays_.end() ) {
97  delays_[*detIdIt] += (*it)->delay(*detIdIt)*sumSign;
98  }
99  else {
100  std::cout << "makeDelay: Warning, detId = " << *detIdIt << " not present, summing to 0..." << std::cout;
101  std::cout << "This means that the two baseDelay tags have different detIds. PLEASE, CHECK THAT THIS IS EXPECTED." << std::cout;
102  delays_[*detIdIt] = (*it)->delay(*detIdIt)*sumSign;
103  }
104  }
105  }
106 
107  return true;
108 }
std::vector< const SiStripBaseDelay * > baseDelayVector_
Definition: SiStripDelay.h:96
boost::unordered_map< uint32_t, double > delays_
Definition: SiStripDelay.h:99
tuple cout
Definition: gather_cfg.py:121
std::vector< int > sumSignVector_
Definition: SiStripDelay.h:97
const SiStripDelay& SiStripDelay::operator= ( const SiStripDelay )
private
void SiStripDelay::printDebug ( std::stringstream &  ss) const

Prints the delays for all the detIds.

Definition at line 118 of file SiStripDelay.cc.

References delays_.

119 {
120  boost::unordered_map<uint32_t, double>::const_iterator it = delays_.begin();
121  for( ; it != delays_.end(); ++it ) {
122  ss << "detId = " << it->first << " delay = " << it->second << std::endl;
123  }
124 }
boost::unordered_map< uint32_t, double > delays_
Definition: SiStripDelay.h:99
void SiStripDelay::printSummary ( std::stringstream &  ss) const

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

Definition at line 126 of file SiStripDelay.cc.

References SiStripDetSummary::add(), delays_, and SiStripDetSummary::print().

127 {
128  SiStripDetSummary summaryDelays;
129  boost::unordered_map<uint32_t, double>::const_iterator it = delays_.begin();
130  for( ; it != delays_.end(); ++it ) {
131  summaryDelays.add(it->first, it->second);
132  }
133  summaryDelays.print(ss);
134 }
void print(std::stringstream &ss, const bool mean=true) const
boost::unordered_map< uint32_t, double > delays_
Definition: SiStripDelay.h:99
void add(const DetId &detid, const float &value)
Used to compute the mean value of the value variable divided by subdetector, layer and mono/stereo...

Member Data Documentation

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

Definition at line 96 of file SiStripDelay.h.

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

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

Definition at line 99 of file SiStripDelay.h.

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

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

Definition at line 98 of file SiStripDelay.h.

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

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

Definition at line 97 of file SiStripDelay.h.

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