CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiPixelPerformanceSummary.cc
Go to the documentation of this file.
2 
4 
5 #include <algorithm>
6 
7 using namespace edm;
8 using namespace std;
9 
11  : timeStamp_(0), runNumber_(0), luminosityBlock_(0), numberOfEvents_(0) {}
12 
14  timeStamp_ = performanceSummary.getTimeStamp();
15  runNumber_ = performanceSummary.getRunNumber();
16  luminosityBlock_ = performanceSummary.getLuminosityBlock();
17  numberOfEvents_ = performanceSummary.getNumberOfEvents();
18  allDetSummaries_ = performanceSummary.getAllDetSummaries();
19 }
20 
22 
24  timeStamp_ = 0;
25  runNumber_ = 0;
26  luminosityBlock_ = 0;
27  numberOfEvents_ = 0;
28  allDetSummaries_.clear();
29 }
30 
31 pair<bool, vector<SiPixelPerformanceSummary::DetSummary>::iterator> SiPixelPerformanceSummary::initDet(
32  const uint32_t detId) {
33  vector<float> performanceValues;
34  performanceValues.reserve(kDetSummarySize);
35  for (int i = 0; i < kDetSummarySize; ++i)
36  performanceValues.push_back(kDefaultValue);
37  return setDet(detId, performanceValues);
38 }
39 
40 pair<bool, vector<SiPixelPerformanceSummary::DetSummary>::iterator> SiPixelPerformanceSummary::setDet(
41  const uint32_t detId, const vector<float>& performanceValues) {
42  vector<DetSummary>::iterator iDetSumm = allDetSummaries_.end();
43 
44  if (performanceValues.size() != kDetSummarySize) { // for inappropriate input
45  cout << "not adding these " << performanceValues.size() << " values; "
46  << "SiPixelPerformanceSummary can only add " << kDetSummarySize << " values per DetSummary";
47  return make_pair(false, iDetSumm);
48  }
49  iDetSumm = lower_bound(
51 
52  if (iDetSumm != allDetSummaries_.end() && // for an existong entry
53  iDetSumm->detId_ == detId)
54  return make_pair(false, iDetSumm);
55 
56  DetSummary newDetSumm; // for a new entry, put at (position-1) returned by StrictWeakOrdering
57  newDetSumm.detId_ = detId;
58  newDetSumm.performanceValues_ = performanceValues;
59  return make_pair(true, allDetSummaries_.insert(iDetSumm, newDetSumm));
60 }
61 
62 bool SiPixelPerformanceSummary::setValue(uint32_t detId, int index, float performanceValue) {
63  if (index > kDetSummarySize) {
64  cout << "cannot set the performance value for index = " << index << " > " << kDetSummarySize;
65  return false;
66  }
67  pair<bool, vector<DetSummary>::iterator> initResult = initDet(detId);
68  if (initResult.first || initResult.second != allDetSummaries_.end()) {
69  initResult.second->performanceValues_[index] = performanceValue;
70  return true;
71  } else {
72  cout << "cannot set the performance value; cannot create new entry for detId = " << detId;
73  return false;
74  }
75  return true;
76 }
77 
78 float SiPixelPerformanceSummary::getValue(uint32_t detId, int index) {
79  if (index > kDetSummarySize) {
80  cout << "cannot get value for detId = " << detId << " index = " << index << " > " << kDetSummarySize;
81  return kDefaultValue;
82  }
83  vector<float> performanceValues = getDetSummary(detId);
84  if (performanceValues.size() == kDetSummarySize)
85  return performanceValues[index];
86  else
87  return kDefaultValue;
88 }
89 
90 bool SiPixelPerformanceSummary::setRawDataErrorType(uint32_t detId, int bin, float nErrors) {
91  return setValue(detId, bin, nErrors);
92 }
93 
94 bool SiPixelPerformanceSummary::setNumberOfDigis(uint32_t detId, float mean, float rms, float emPtn) {
95  return (setValue(detId, 15, mean) && setValue(detId, 16, rms) && setValue(detId, 17, emPtn));
96 }
97 
98 bool SiPixelPerformanceSummary::setADC(uint32_t detId, float mean, float rms, float emPtn) {
99  return (setValue(detId, 18, mean) && setValue(detId, 19, rms) && setValue(detId, 20, emPtn));
100 }
101 
102 bool SiPixelPerformanceSummary::setNumberOfClusters(uint32_t detId, float mean, float rms, float emPtn) {
103  return (setValue(detId, 21, mean) && setValue(detId, 22, rms) && setValue(detId, 23, emPtn));
104 }
105 
106 bool SiPixelPerformanceSummary::setClusterCharge(uint32_t detId, float mean, float rms, float emPtn) {
107  return (setValue(detId, 24, mean) && setValue(detId, 25, rms) && setValue(detId, 26, emPtn));
108 }
109 
110 bool SiPixelPerformanceSummary::setClusterSize(uint32_t detId, float mean, float rms, float emPtn) {
111  return (setValue(detId, 27, mean) && setValue(detId, 28, rms) && setValue(detId, 29, emPtn));
112 }
113 
114 bool SiPixelPerformanceSummary::setClusterSizeX(uint32_t detId, float mean, float rms, float emPtn) {
115  return (setValue(detId, 30, mean) && setValue(detId, 31, rms) && setValue(detId, 32, emPtn));
116 }
117 
118 bool SiPixelPerformanceSummary::setClusterSizeY(uint32_t detId, float mean, float rms, float emPtn) {
119  return (setValue(detId, 33, mean) && setValue(detId, 34, rms) && setValue(detId, 35, emPtn));
120 }
121 
122 bool SiPixelPerformanceSummary::setNumberOfRecHits(uint32_t detId, float mean, float rms, float emPtn) {
123  return (setValue(detId, 36, mean) && setValue(detId, 37, rms) && setValue(detId, 38, emPtn));
124 }
125 
126 bool SiPixelPerformanceSummary::setResidualX(uint32_t detId, float mean, float rms, float emPtn) {
127  return (setValue(detId, 39, mean) && setValue(detId, 40, rms) && setValue(detId, 41, emPtn));
128 }
129 
130 bool SiPixelPerformanceSummary::setResidualY(uint32_t detId, float mean, float rms, float emPtn) {
131  return (setValue(detId, 42, mean) && setValue(detId, 43, rms) && setValue(detId, 44, emPtn));
132 }
133 
134 bool SiPixelPerformanceSummary::setNumberOfNoisCells(uint32_t detId, float nNpixCells) {
135  return setValue(detId, 45, nNpixCells);
136 }
137 
138 bool SiPixelPerformanceSummary::setNumberOfDeadCells(uint32_t detId, float nNpixCells) {
139  return setValue(detId, 46, nNpixCells);
140 }
141 
142 bool SiPixelPerformanceSummary::setNumberOfPixelHitsInTrackFit(uint32_t detId, float nPixelHits) {
143  return setValue(detId, 47, nPixelHits);
144 }
145 
146 bool SiPixelPerformanceSummary::setFractionOfTracks(uint32_t detId, float mean, float rms) {
147  return (setValue(detId, 48, mean) && setValue(detId, 49, rms));
148 }
149 
150 bool SiPixelPerformanceSummary::setNumberOfOnTrackClusters(uint32_t detId, float nClusters) {
151  return setValue(detId, 50, nClusters);
152 }
153 
154 bool SiPixelPerformanceSummary::setNumberOfOffTrackClusters(uint32_t detId, float nClusters) {
155  return setValue(detId, 51, nClusters);
156 }
157 
158 bool SiPixelPerformanceSummary::setClusterChargeOnTrack(uint32_t detId, float mean, float rms) {
159  return (setValue(detId, 52, mean) && setValue(detId, 53, rms));
160 }
161 
163  return (setValue(detId, 54, mean) && setValue(detId, 55, rms));
164 }
165 
166 bool SiPixelPerformanceSummary::setClusterSizeOnTrack(uint32_t detId, float mean, float rms) {
167  return (setValue(detId, 56, mean) && setValue(detId, 57, rms));
168 }
169 
170 bool SiPixelPerformanceSummary::setClusterSizeOffTrack(uint32_t detId, float mean, float rms) {
171  return (setValue(detId, 58, mean) && setValue(detId, 59, rms));
172 }
173 
174 vector<uint32_t> SiPixelPerformanceSummary::getAllDetIds() const {
175  vector<uint32_t> allDetIds;
176  for (vector<DetSummary>::const_iterator iDetSumm = allDetSummaries_.begin(); iDetSumm != allDetSummaries_.end();
177  ++iDetSumm)
178  allDetIds.push_back(iDetSumm->detId_);
179  return allDetIds;
180 }
181 
182 vector<float> SiPixelPerformanceSummary::getDetSummary(const uint32_t detId) const {
183  vector<DetSummary>::const_iterator iDetSumm =
184  find_if(allDetSummaries_.begin(), allDetSummaries_.end(), [&detId](const DetSummary& detSumm) -> bool {
185  return detSumm.detId_ == detId;
186  });
187  if (iDetSumm == allDetSummaries_.end()) {
188  vector<float> performanceValues;
189  cout << "cannot get DetSummary for detId = " << detId;
190  return performanceValues;
191  } else
192  return iDetSumm->performanceValues_;
193 }
194 
195 void SiPixelPerformanceSummary::print(const uint32_t detId) const {
196  vector<float> performanceValues = getDetSummary(detId);
197  cout << "DetSummary for detId " << detId << " : ";
198  for (vector<float>::const_iterator v = performanceValues.begin(); v != performanceValues.end(); ++v)
199  cout << " " << *v;
200  cout << endl;
201 }
202 
204  cout << "SiPixelPerformanceSummary size (allDets) = " << allDetSummaries_.size() << ", "
205  << "time stamp = " << timeStamp_ << ", "
206  << "run number = " << runNumber_ << ", "
207  << "luminosity section = " << luminosityBlock_ << ", "
208  << "number of events = " << numberOfEvents_ << endl;
209 }
210 
212  print();
213  for (vector<DetSummary>::const_iterator iDetSumm = allDetSummaries_.begin(); iDetSumm != allDetSummaries_.end();
214  ++iDetSumm)
215  print(iDetSumm->detId_);
216 }
static const char runNumber_[]
bool setRawDataErrorType(uint32_t detId, int bin, float nErrors)
bool setValue(uint32_t detId, int index, float performanceValue)
std::vector< float > getDetSummary(uint32_t detId) const
std::vector< DetSummary > getAllDetSummaries() const
std::pair< bool, std::vector< DetSummary >::iterator > setDet(const uint32_t detId, const std::vector< float > &performanceValues)
bool setADC(uint32_t detId, float mean, float rms, float emPtn)
unsigned int getRunNumber() const
std::pair< bool, std::vector< DetSummary >::iterator > initDet(const uint32_t detId)
bool setNumberOfOnTrackClusters(uint32_t detId, float nClusters)
bool setClusterSizeY(uint32_t detId, float mean, float rms, float emPtn)
std::vector< DetSummary > allDetSummaries_
bool setNumberOfDigis(uint32_t detId, float mean, float rms, float emPtn)
#define kDefaultValue
float getValue(uint32_t detId, int index)
bool setNumberOfDeadCells(uint32_t detId, float nNpixCells)
bool setResidualY(uint32_t detId, float mean, float rms, float emPtn)
bool setClusterSize(uint32_t detId, float mean, float rms, float emPtn)
bool setNumberOfOffTrackClusters(uint32_t detId, float nClusters)
bool setResidualX(uint32_t detId, float mean, float rms, float emPtn)
bool setClusterSizeX(uint32_t detId, float mean, float rms, float emPtn)
bool setNumberOfRecHits(uint32_t detId, float mean, float rms, float emPtn)
bool setClusterCharge(uint32_t detId, float mean, float rms, float emPtn)
bool setClusterSizeOffTrack(uint32_t detId, float mean, float rms)
bool setClusterChargeOffTrack(uint32_t detId, float mean, float rms)
std::vector< uint32_t > getAllDetIds() const
#define kDetSummarySize
bool setNumberOfPixelHitsInTrackFit(uint32_t detId, float nPixelHits)
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
bool setNumberOfNoisCells(uint32_t detId, float nNpixCells)
unsigned int getNumberOfEvents() const
bool setClusterChargeOnTrack(uint32_t detId, float mean, float rms)
tuple cout
Definition: gather_cfg.py:144
unsigned int getLuminosityBlock() const
bool setClusterSizeOnTrack(uint32_t detId, float mean, float rms)
bool setNumberOfClusters(uint32_t detId, float mean, float rms, float emPtn)
bool setFractionOfTracks(uint32_t detId, float mean, float rms)
unsigned long long getTimeStamp() const