CMS 3D CMS Logo

SiStripApvGain.cc
Go to the documentation of this file.
5 
6 #include <algorithm>
7 
8 bool SiStripApvGain::put(const uint32_t& DetId, Range input) {
9  // put in SiStripApvGain of DetId
11  if (p != v_detids.end() && *p == DetId) {
12  edm::LogError("SiStripApvGain") << "[" << __PRETTY_FUNCTION__ << "] SiStripApvGain for DetID " << DetId
13  << " is already stored. Skipping this put" << std::endl;
14  return false;
15  }
16 
17  unsigned int sd = input.second - input.first;
18  unsigned int pd = p - v_detids.begin();
19 
20  unsigned int ibegin = v_gains.size();
21  unsigned int iend = v_gains.size() + sd;
22  v_detids.insert(p, DetId);
23  v_ibegin.insert(v_ibegin.begin() + pd, ibegin);
24  v_iend.insert(v_iend.begin() + pd, iend);
25 
26  v_gains.insert(v_gains.end(), input.first, input.second);
27  return true;
28 }
29 
31  // get SiStripApvGain Range of DetId
33  if (p == v_detids.end() || *p != DetId)
34  return SiStripApvGain::Range(v_gains.end(), v_gains.end());
35  else {
36  unsigned int pd = p - v_detids.begin();
37  unsigned int ibegin = *(v_ibegin.begin() + pd);
38  unsigned int iend = *(v_iend.begin() + pd);
39  __builtin_prefetch((&v_gains.front()) + ibegin);
40  return SiStripApvGain::Range(v_gains.begin() + ibegin, v_gains.begin() + iend);
41  }
42 }
43 
45  if (pos > v_detids.size())
46  return Range(v_gains.end(), v_gains.end());
47  unsigned int ibegin = *(v_ibegin.begin() + pos);
48  unsigned int iend = *(v_iend.begin() + pos);
49  __builtin_prefetch((&v_gains.front()) + ibegin);
50  return SiStripApvGain::Range(v_gains.begin() + ibegin, v_gains.begin() + iend);
51 }
52 
53 void SiStripApvGain::getDetIds(std::vector<uint32_t>& DetIds_) const {
54  // returns vector of DetIds in map
55  // DetIds_=v_detids;
56  DetIds_.insert(DetIds_.begin(), v_detids.begin(), v_detids.end());
57 }
58 
59 #ifdef EDM_ML_DEBUG
60 float SiStripApvGain::getStripGain(const uint16_t& strip, const Range& range) {
61  uint16_t apv = (uint16_t)(strip / 128);
62  if (apv >= range.second - range.first) {
63  throw cms::Exception("CorruptedData")
64  << "[SiStripApvGain::getApvGain] looking for SiStripApvGain for a strip out of range: strip " << strip
65  << " apv " << apv << std::endl;
66  }
67 
68  // return static_cast<float> (*(range.first+apv));
69 
70  return *(range.first + apv);
71 }
72 
73 float SiStripApvGain::getApvGain(const uint16_t& apv, const Range& range) {
74  if (apv >= range.second - range.first) {
75  throw cms::Exception("CorruptedData")
76  << "[SiStripApvGain::getApvGain] looking for SiStripApvGain for an apv out of range: apv " << apv << std::endl;
77  }
78 
79  // return static_cast<float> (*(range.first+apv));
80 
81  return *(range.first + apv);
82 }
83 #endif
84 
85 void SiStripApvGain::printDebug(std::stringstream& ss, const TrackerTopology* /*trackerTopo*/) const {
86  std::vector<unsigned int>::const_iterator detid = v_detids.begin();
87  ss << "Number of detids " << v_detids.size() << std::endl;
88 
89  for (; detid != v_detids.end(); ++detid) {
91  int apv = 0;
92  for (int it = 0; it < range.second - range.first; ++it) {
93  ss << "detid " << *detid << " \t"
94  << " apv " << apv++ << " \t" << getApvGain(it, range) << " \t" << std::endl;
95  }
96  }
97 }
98 
99 void SiStripApvGain::printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const {
100  SiStripDetSummary summaryGain{trackerTopo};
101 
102  std::vector<uint32_t>::const_iterator detid = v_detids.begin();
103  for (; detid != v_detids.end(); ++detid) {
104  Range range = getRange(*detid);
105  for (int it = 0; it < range.second - range.first; ++it) {
106  summaryGain.add(*detid, getApvGain(it, range));
107  }
108  }
109  ss << "Summary of gain values:" << std::endl;
110  summaryGain.print(ss, true);
111 }
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Registry::const_iterator RegistryConstIterator
static float getApvGain(uint16_t apv, const Range &range)
PixelRecoRange< float > Range
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Registry::iterator RegistryIterator
Range getRangeByPos(unsigned short pos) const
Log< level::Error, false > LogError
static std::string const input
Definition: EdmProvDump.cc:50
bool put(const uint32_t &detID, Range input)
void getDetIds(std::vector< uint32_t > &DetIds_) const
std::vector< float > v_gains
std::pair< ContainerIterator, ContainerIterator > Range
std::vector< unsigned int > v_iend
Definition: DetId.h:17
std::vector< unsigned int > v_detids
const Range getRange(const uint32_t detID) const
static float getStripGain(uint16_t strip, const Range &range)
std::vector< unsigned int > v_ibegin