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