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. Skippig 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 }
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
SiStripDetSummary.h
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
SiStripApvGain::getStripGain
static float getStripGain(uint16_t strip, const Range &range)
Definition: SiStripApvGain.h:78
Range
PixelRecoRange< float > Range
Definition: PixelTripletHLTGenerator.cc:31
SiStripApvGain::v_iend
std::vector< unsigned int > v_iend
Definition: SiStripApvGain.h:92
TrackerTopology
Definition: TrackerTopology.h:16
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
SiStripApvGain::printSummary
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Definition: SiStripApvGain.cc:99
pos
Definition: PixelAliasList.h:18
SiStripApvGain::v_ibegin
std::vector< unsigned int > v_ibegin
Definition: SiStripApvGain.h:91
SiStripApvGain::v_gains
std::vector< float > v_gains
Definition: SiStripApvGain.h:89
SiStripApvGain::getRange
const Range getRange(const uint32_t detID) const
Definition: SiStripApvGain.cc:30
SiStripApvGain::RegistryConstIterator
Registry::const_iterator RegistryConstIterator
Definition: SiStripApvGain.h:31
SiStripApvGain::printDebug
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Definition: SiStripApvGain.cc:85
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
DetId
Definition: DetId.h:17
SiStripApvGain::put
bool put(const uint32_t &detID, Range input)
Definition: SiStripApvGain.cc:8
SiStripApvGain.h
cuda_std::lower_bound
__host__ constexpr __device__ RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:27
SiStripApvGain::RegistryIterator
Registry::iterator RegistryIterator
Definition: SiStripApvGain.h:30
edm::LogError
Definition: MessageLogger.h:183
SiStripApvGain::v_detids
std::vector< unsigned int > v_detids
Definition: SiStripApvGain.h:90
SiStripApvGain::getRangeByPos
Range getRangeByPos(unsigned short pos) const
Definition: SiStripApvGain.cc:44
SiStripApvGain::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripApvGain.h:28
Exception
Definition: hltDiff.cc:246
Exception.h
SiStripDetSummary
Definition: SiStripDetSummary.h:28
sd
double sd
Definition: CascadeWrapper.h:113
SiStripApvGain::getDetIds
void getDetIds(std::vector< uint32_t > &DetIds_) const
Definition: SiStripApvGain.cc:53
SiStripApvGain::getApvGain
static float getApvGain(uint16_t apv, const Range &range)
Definition: SiStripApvGain.h:82