CMS 3D CMS Logo

SiStripDetVOff.cc
Go to the documentation of this file.
4 
5 #include <algorithm>
6 
7 void SiStripDetVOff::setBits(uint32_t& enDetId, const int HVoff, const int LVoff) {
8  if (LVoff != -1) {
9  // LVonMask has all bits equal to 1 apart from the last one.
10  if (LVoff == 0)
11  enDetId &= LVonMask;
12  if (LVoff == 1)
13  enDetId |= LVmask;
14  }
15  if (HVoff != -1) {
16  // HVonMask has all bits equal to 1 apart from the next to last one.
17  if (HVoff == 0)
18  enDetId &= HVonMask;
19  if (HVoff == 1)
20  enDetId |= HVmask;
21  }
22 }
23 
24 bool SiStripDetVOff::put(const uint32_t DetId, const int HVoff, const int LVoff) {
25  // Shift the DetId number of 2 bits to the left to have it in the final format with
26  // the two additional bits used for HV and LV.
27  uint32_t enDetId = (DetId << bitShift) & eightBitMask;
28 
29  // Binary search to determine if the element is already in the vector
30  vOffIterator p = std::lower_bound(v_Voff.begin(), v_Voff.end(), enDetId);
31  if (p != v_Voff.end() && (*p >> bitShift) == DetId) {
32  // Found a matching entry, insert the HV and LV information.
33  setBits(*p, HVoff, LVoff);
34  // Check if the detector has all on, in that case remove it from the list.
35  if ((~(*p) & allOnMask) == allOnMask)
36  v_Voff.erase(p);
37  } else {
38  // Not found, insert a new entry only if it is not all on
39  setBits(enDetId, HVoff, LVoff);
40  if ((~enDetId & allOnMask) != allOnMask)
41  v_Voff.insert(p, enDetId);
42  }
43  return true;
44 }
45 
46 bool SiStripDetVOff::put(std::vector<uint32_t>& DetId, std::vector<int>& HVoff, std::vector<int>& LVoff) {
47  if (DetId.size() == HVoff.size() && DetId.size() == LVoff.size()) {
48  constVoffIterator detIdIt = DetId.begin();
49  constVoffIterator detIdItEnd = DetId.end();
50  constVboolIterator HVoffIt = HVoff.begin();
51  constVboolIterator LVoffIt = LVoff.begin();
52  for (; detIdIt != detIdItEnd; ++detIdIt, ++HVoffIt, ++LVoffIt) {
53  put(*detIdIt, *HVoffIt, *LVoffIt);
54  }
55  } else {
56  std::cout << "Error: inconsistent sizes of vectors:" << std::endl;
57  std::cout << "DetId size = " << DetId.size() << ", HVoff size = " << HVoff.size()
58  << ", LVoff size = " << LVoff.size() << std::endl;
59  return false;
60  }
61  return true;
62 }
63 
64 void SiStripDetVOff::getDetIds(std::vector<uint32_t>& DetIds_) const {
65  // returns vector of DetIds in map
66  DetIds_.clear();
67  // Extract the detId from the bitSet and fill the vector
68  constVoffIterator bitSetIt = v_Voff.begin();
69  constVoffIterator bitSetItEnd = v_Voff.end();
70  for (; bitSetIt != bitSetItEnd; ++bitSetIt) {
71  DetIds_.push_back((*bitSetIt) >> bitShift);
72  }
73 }
74 
75 bool SiStripDetVOff::IsModuleVOff(const uint32_t DetId) const {
76  uint32_t enDetId = (DetId << bitShift) & eightBitMask;
77  constVoffIterator p = std::lower_bound(v_Voff.begin(), v_Voff.end(), enDetId);
78  if (p != v_Voff.end() && (*p >> bitShift) == DetId)
79  return true;
80  return false;
81 }
82 
83 bool SiStripDetVOff::IsModuleLVOff(const uint32_t DetId) const {
84  uint32_t enDetId = (DetId << bitShift) & eightBitMask;
85  constVoffIterator p = std::lower_bound(v_Voff.begin(), v_Voff.end(), enDetId);
86  if (p != v_Voff.end() && (*p >> bitShift) == DetId && (*p & LVmask))
87  return true;
88  return false;
89 }
90 
91 bool SiStripDetVOff::IsModuleHVOff(const uint32_t DetId) const {
92  uint32_t enDetId = (DetId << bitShift) & eightBitMask;
93  constVoffIterator p = std::lower_bound(v_Voff.begin(), v_Voff.end(), enDetId);
94  if (p != v_Voff.end() && (*p >> bitShift) == DetId && (*p & HVmask))
95  return true;
96  return false;
97 }
98 
99 void SiStripDetVOff::printDebug(std::stringstream& ss, const TrackerTopology* /*trackerTopo*/) const {
100  std::vector<uint32_t> detIds;
101  getDetIds(detIds);
102  constVoffIterator it = detIds.begin();
103  ss << "DetId \t HV \t LV" << std::endl;
104  for (; it != detIds.end(); ++it) {
105  ss << *it << "\t";
106  if (IsModuleHVOff(*it))
107  ss << "OFF\t";
108  else
109  ss << "ON \t";
110  if (IsModuleLVOff(*it))
111  ss << "OFF" << std::endl;
112  else
113  ss << "ON" << std::endl;
114  }
115 }
116 
118  std::vector<uint32_t> detIds;
119  getDetIds(detIds);
120  return std::count_if(std::begin(detIds), std::end(detIds), [this](uint32_t id) -> bool { return IsModuleLVOff(id); });
121 }
122 
124  std::vector<uint32_t> detIds;
125  getDetIds(detIds);
126  return std::count_if(std::begin(detIds), std::end(detIds), [this](uint32_t id) -> bool { return IsModuleHVOff(id); });
127 }
128 
129 void SiStripDetVOff::printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const {
130  SiStripDetSummary summaryHV{trackerTopo};
131  SiStripDetSummary summaryLV{trackerTopo};
132  std::vector<uint32_t> detIds;
133  getDetIds(detIds);
134  constVoffIterator it = detIds.begin();
135  for (; it != detIds.end(); ++it) {
136  if (IsModuleHVOff(*it))
137  summaryHV.add(*it);
138  if (IsModuleLVOff(*it))
139  summaryLV.add(*it);
140  }
141  ss << "Summary of detectors with HV off:" << std::endl;
142  summaryHV.print(ss, false);
143  ss << "Summary of detectors with LV off:" << std::endl;
144  summaryLV.print(ss, false);
145 }
SiStripDetVOff::getLVoffCounts
int getLVoffCounts() const
Returns the total number of modules with LV off.
Definition: SiStripDetVOff.cc:117
SiStripDetSummary.h
MessageLogger.h
TrackerTopology
Definition: TrackerTopology.h:16
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SiStripDetVOff::setBits
void setBits(uint32_t &enDetId, const int HVoff, const int LVoff)
Changes the bits in the stored value according to on/off voltages.
Definition: SiStripDetVOff.cc:7
SiStripDetVOff::HVmask
static const short HVmask
Definition: SiStripDetVOff.h:40
SiStripDetVOff::IsModuleHVOff
bool IsModuleHVOff(const uint32_t DetID) const
Definition: SiStripDetVOff.cc:91
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
DetId
Definition: DetId.h:17
SiStripDetVOff::IsModuleVOff
bool IsModuleVOff(const uint32_t DetID) const
Returns true if either HV or LV are off.
Definition: SiStripDetVOff.cc:75
SiStripDetVOff::v_Voff
std::vector< uint32_t > v_Voff
Definition: SiStripDetVOff.h:82
mps_fire.end
end
Definition: mps_fire.py:242
SiStripDetVOff::vOffIterator
std::vector< uint32_t >::iterator vOffIterator
Definition: SiStripDetVOff.h:33
SiStripDetVOff::getDetIds
void getDetIds(std::vector< uint32_t > &DetIds_) const
Definition: SiStripDetVOff.cc:64
SiStripDetVOff::printDebug
void printDebug(std::stringstream &ss, const TrackerTopology *) const
Definition: SiStripDetVOff.cc:99
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
SiStripDetVOff::getHVoffCounts
int getHVoffCounts() const
Returns the total number of modules with HV off.
Definition: SiStripDetVOff.cc:123
SiStripDetVOff::LVmask
static const short LVmask
Definition: SiStripDetVOff.h:38
SiStripDetVOff::constVoffIterator
std::vector< uint32_t >::const_iterator constVoffIterator
Definition: SiStripDetVOff.h:34
SiStripDetVOff::put
bool put(const uint32_t DetId, const int HVoff, const int LVoff)
Insert information for a single detId.
Definition: SiStripDetVOff.cc:24
SiStripDetVOff::constVboolIterator
std::vector< int >::const_iterator constVboolIterator
Definition: SiStripDetVOff.h:35
SiStripDetVOff::LVonMask
static const unsigned int LVonMask
Definition: SiStripDetVOff.h:39
SiStripDetVOff::printSummary
void printSummary(std::stringstream &ss, const TrackerTopology *) const
Definition: SiStripDetVOff.cc:129
SiStripDetSummary
Definition: SiStripDetSummary.h:28
SiStripDetVOff::allOnMask
static const unsigned int allOnMask
Definition: SiStripDetVOff.h:42
SiStripDetVOff::eightBitMask
static const unsigned int eightBitMask
Definition: SiStripDetVOff.h:43
SiStripDetVOff.h
SiStripDetVOff::bitShift
static const short bitShift
Definition: SiStripDetVOff.h:44
SiStripDetVOff::HVonMask
static const unsigned int HVonMask
Definition: SiStripDetVOff.h:41
SiStripDetVOff::IsModuleLVOff
bool IsModuleLVOff(const uint32_t DetID) const
Definition: SiStripDetVOff.cc:83