CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Static Public Attributes | Private Attributes
SiStripDetVOff Class Reference

#include <SiStripDetVOff.h>

Public Types

typedef std::vector< int >
::const_iterator 
constVboolIterator
 
typedef std::vector< uint32_t >
::const_iterator 
constVoffIterator
 
typedef std::vector< uint32_t >
::iterator 
vOffIterator
 

Public Member Functions

void getDetIds (std::vector< uint32_t > &DetIds_) const
 
int getHVoffCounts () const
 Returns the total number of modules with HV off. More...
 
int getLVoffCounts () const
 Returns the total number of modules with LV off. More...
 
void getVoff (std::vector< uint32_t > &vOff_) const
 Needed by the copy constructor. More...
 
bool IsModuleHVOff (const uint32_t DetID) const
 
bool IsModuleLVOff (const uint32_t DetID) const
 
bool IsModuleVOff (const uint32_t DetID) const
 Returns true if either HV or LV are off. More...
 
bool operator== (const SiStripDetVOff &d) const
 
void printDebug (std::stringstream &ss) const
 
void printSummary (std::stringstream &ss) const
 
bool put (const uint32_t DetId, const int HVoff, const int LVoff)
 Insert information for a single detId. More...
 
bool put (std::vector< uint32_t > &DetId, std::vector< int > &HVoff, std::vector< int > &LVoff)
 Insert information for a vector of detIds. More...
 
void setBits (uint32_t &enDetId, const int HVoff, const int LVoff)
 Changes the bits in the stored value according to on/off voltages. More...
 
 SiStripDetVOff ()
 
 SiStripDetVOff (const SiStripDetVOff &toCopy)
 
 ~SiStripDetVOff ()
 

Static Public Attributes

static const unsigned int allOnMask = 0x03
 
static const short bitShift = 2
 
static const unsigned int eightBitMask = 0xFFFFFFFF
 
static const short HVmask = 0x2
 
static const unsigned int HVonMask = 0xFFFFFFFD
 
static const short LVmask = 0x1
 
static const unsigned int LVonMask = 0xFFFFFFFE
 

Private Attributes

std::vector< uint32_t > v_Voff
 

Detailed Description

This class stores the information if the HV or LV of a detId were off.
Internally it uses two bits to store the information about HV and LV. It saves a uint32_t containing the detId number and these additional bits, which are stored in the first position. This is realized by the put method using a bit shift so that the actual number written in the database is: detId|HV|LV.
The getDetIds method builds and returns a vector with detIds, removing the additional bits. It has three methods to extract the information:

The printSummary method uses SiStripDetSummary to print both LV off and HV off summaries. See description of the SiStripDetSummary class therein.
The printDebug method prints the status of HV and LV for all DetIds that have at least one of the two off.

Definition at line 27 of file SiStripDetVOff.h.

Member Typedef Documentation

typedef std::vector<int>::const_iterator SiStripDetVOff::constVboolIterator

Definition at line 33 of file SiStripDetVOff.h.

typedef std::vector<uint32_t>::const_iterator SiStripDetVOff::constVoffIterator

Definition at line 32 of file SiStripDetVOff.h.

typedef std::vector<uint32_t>::iterator SiStripDetVOff::vOffIterator

Definition at line 31 of file SiStripDetVOff.h.

Constructor & Destructor Documentation

SiStripDetVOff::SiStripDetVOff ( )
inline

Definition at line 44 of file SiStripDetVOff.h.

44 {}
SiStripDetVOff::~SiStripDetVOff ( )
inline

Definition at line 45 of file SiStripDetVOff.h.

45 {}
SiStripDetVOff::SiStripDetVOff ( const SiStripDetVOff toCopy)
inline

Definition at line 46 of file SiStripDetVOff.h.

References getVoff(), and v_Voff.

46 { toCopy.getVoff(v_Voff); }
std::vector< uint32_t > v_Voff
void getVoff(std::vector< uint32_t > &vOff_) const
Needed by the copy constructor.

Member Function Documentation

void SiStripDetVOff::getDetIds ( std::vector< uint32_t > &  DetIds_) const

Definition at line 62 of file SiStripDetVOff.cc.

References bitShift, and v_Voff.

Referenced by SiPixelQuality::add(), SiStripDetVOffBuilder::BuildDetVOffObj(), getHVoffCounts(), getLVoffCounts(), printDebug(), and printSummary().

63 {
64  // returns vector of DetIds in map
65  DetIds_.clear();
66  // Extract the detId from the bitSet and fill the vector
67  constVoffIterator bitSetIt = v_Voff.begin();
68  constVoffIterator bitSetItEnd = v_Voff.end();
69  for( ; bitSetIt != bitSetItEnd; ++bitSetIt ) {
70  DetIds_.push_back( (*bitSetIt) >> bitShift );
71  }
72 }
static const short bitShift
std::vector< uint32_t > v_Voff
std::vector< uint32_t >::const_iterator constVoffIterator
int SiStripDetVOff::getHVoffCounts ( ) const

Returns the total number of modules with HV off.

Definition at line 131 of file SiStripDetVOff.cc.

References SiStripDetSummary::add(), SiStripDetSummary::getCounts(), getDetIds(), IsModuleHVOff(), and simpleEdmComparison::totalCount.

132 {
133  SiStripDetSummary summaryHV;
134  std::vector<uint32_t> detIds;
135  getDetIds(detIds);
136  constVoffIterator it = detIds.begin();
137  for( ; it!=detIds.end(); ++it ) {
138  if( IsModuleHVOff(*it)) summaryHV.add(*it);
139  }
140  int totalCount = 0;
141  std::map<unsigned int, SiStripDetSummary::Values> counts = summaryHV.getCounts();
142  std::map<unsigned int, SiStripDetSummary::Values>::const_iterator mapIt = counts.begin();
143  for( ; mapIt != counts.end(); ++mapIt ) {
144  totalCount += mapIt->second.count;
145  }
146  return totalCount;
147 }
std::map< unsigned int, Values > getCounts()
bool IsModuleHVOff(const uint32_t DetID) const
void getDetIds(std::vector< uint32_t > &DetIds_) const
std::vector< uint32_t >::const_iterator constVoffIterator
void add(const DetId &detid, const float &value)
Used to compute the mean value of the value variable divided by subdetector, layer and mono/stereo...
int SiStripDetVOff::getLVoffCounts ( ) const

Returns the total number of modules with LV off.

Definition at line 113 of file SiStripDetVOff.cc.

References SiStripDetSummary::add(), SiStripDetSummary::getCounts(), getDetIds(), IsModuleLVOff(), and simpleEdmComparison::totalCount.

114 {
115  SiStripDetSummary summaryLV;
116  std::vector<uint32_t> detIds;
117  getDetIds(detIds);
118  constVoffIterator it = detIds.begin();
119  for( ; it!=detIds.end(); ++it ) {
120  if( IsModuleLVOff(*it)) summaryLV.add(*it);
121  }
122  int totalCount = 0;
123  std::map<unsigned int, SiStripDetSummary::Values> counts = summaryLV.getCounts();
124  std::map<unsigned int, SiStripDetSummary::Values>::const_iterator mapIt = counts.begin();
125  for( ; mapIt != counts.end(); ++mapIt ) {
126  totalCount += mapIt->second.count;
127  }
128  return totalCount;
129 }
std::map< unsigned int, Values > getCounts()
bool IsModuleLVOff(const uint32_t DetID) const
void getDetIds(std::vector< uint32_t > &DetIds_) const
std::vector< uint32_t >::const_iterator constVoffIterator
void add(const DetId &detid, const float &value)
Used to compute the mean value of the value variable divided by subdetector, layer and mono/stereo...
void SiStripDetVOff::getVoff ( std::vector< uint32_t > &  vOff_) const
inline

Needed by the copy constructor.

Definition at line 49 of file SiStripDetVOff.h.

References v_Voff.

Referenced by SiStripDetVOff().

49 { vOff_ = v_Voff; }
std::vector< uint32_t > v_Voff
bool SiStripDetVOff::IsModuleHVOff ( const uint32_t  DetID) const

Definition at line 90 of file SiStripDetVOff.cc.

References bitShift, eightBitMask, HVmask, AlCaHLTBitMon_ParallelJobs::p, and v_Voff.

Referenced by getHVoffCounts(), printDebug(), and printSummary().

91 {
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) ) return true;
95  return false;
96 }
static const short bitShift
std::vector< uint32_t > v_Voff
static const unsigned int eightBitMask
static const short HVmask
Definition: DetId.h:18
std::vector< uint32_t >::const_iterator constVoffIterator
bool SiStripDetVOff::IsModuleLVOff ( const uint32_t  DetID) const

Definition at line 82 of file SiStripDetVOff.cc.

References bitShift, eightBitMask, LVmask, AlCaHLTBitMon_ParallelJobs::p, and v_Voff.

Referenced by getLVoffCounts(), printDebug(), and printSummary().

83 {
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) ) return true;
87  return false;
88 }
static const short bitShift
std::vector< uint32_t > v_Voff
static const unsigned int eightBitMask
Definition: DetId.h:18
static const short LVmask
std::vector< uint32_t >::const_iterator constVoffIterator
bool SiStripDetVOff::IsModuleVOff ( const uint32_t  DetID) const

Returns true if either HV or LV are off.

Definition at line 74 of file SiStripDetVOff.cc.

References bitShift, eightBitMask, AlCaHLTBitMon_ParallelJobs::p, and v_Voff.

75 {
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) return true;
79  return false;
80 }
static const short bitShift
std::vector< uint32_t > v_Voff
static const unsigned int eightBitMask
Definition: DetId.h:18
std::vector< uint32_t >::const_iterator constVoffIterator
bool SiStripDetVOff::operator== ( const SiStripDetVOff d) const
inline

Definition at line 57 of file SiStripDetVOff.h.

References v_Voff.

57 { return d.v_Voff==v_Voff; }
std::vector< uint32_t > v_Voff
void SiStripDetVOff::printDebug ( std::stringstream &  ss) const

Definition at line 98 of file SiStripDetVOff.cc.

References getDetIds(), IsModuleHVOff(), and IsModuleLVOff().

99 {
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)) ss << "OFF\t";
107  else ss << "ON \t";
108  if( IsModuleLVOff(*it)) ss << "OFF" << std::endl;
109  else ss << "ON" << std::endl;
110  }
111 }
bool IsModuleHVOff(const uint32_t DetID) const
bool IsModuleLVOff(const uint32_t DetID) const
void getDetIds(std::vector< uint32_t > &DetIds_) const
std::vector< uint32_t >::const_iterator constVoffIterator
void SiStripDetVOff::printSummary ( std::stringstream &  ss) const

Definition at line 149 of file SiStripDetVOff.cc.

References SiStripDetSummary::add(), getDetIds(), IsModuleHVOff(), IsModuleLVOff(), and SiStripDetSummary::print().

150 {
151  SiStripDetSummary summaryHV;
152  SiStripDetSummary summaryLV;
153  std::vector<uint32_t> detIds;
154  getDetIds(detIds);
155  constVoffIterator it = detIds.begin();
156  for( ; it!=detIds.end(); ++it ) {
157  if( IsModuleHVOff(*it)) summaryHV.add(*it);
158  if( IsModuleLVOff(*it)) summaryLV.add(*it);
159  }
160  ss << "Summary of detectors with HV off:" << std::endl;
161  summaryHV.print(ss, false);
162  ss << "Summary of detectors with LV off:" << std::endl;
163  summaryLV.print(ss, false);
164 }
bool IsModuleHVOff(const uint32_t DetID) const
bool IsModuleLVOff(const uint32_t DetID) const
void getDetIds(std::vector< uint32_t > &DetIds_) const
void print(std::stringstream &ss, const bool mean=true) const
std::vector< uint32_t >::const_iterator constVoffIterator
void add(const DetId &detid, const float &value)
Used to compute the mean value of the value variable divided by subdetector, layer and mono/stereo...
bool SiStripDetVOff::put ( const uint32_t  DetId,
const int  HVoff,
const int  LVoff 
)

Insert information for a single detId.

Definition at line 21 of file SiStripDetVOff.cc.

References allOnMask, bitShift, eightBitMask, AlCaHLTBitMon_ParallelJobs::p, setBits(), and v_Voff.

Referenced by SiStripDetVOffFakeBuilder::analyze(), SiStripDetVOffBuilder::BuildDetVOffObj(), and put().

22 {
23  // Shift the DetId number of 2 bits to the left to have it in the final format with
24  // the two additional bits used for HV and LV.
25  uint32_t enDetId = (DetId << bitShift) & eightBitMask;
26 
27  // Binary search to determine if the element is already in the vector
28  vOffIterator p = std::lower_bound(v_Voff.begin(), v_Voff.end(), enDetId);
29  if( p != v_Voff.end() && (*p >> bitShift) == DetId) {
30  // Found a matching entry, insert the HV and LV information.
31  setBits(*p, HVoff, LVoff);
32  // Check if the detector has all on, in that case remove it from the list.
33  if( (~(*p) & allOnMask) == allOnMask ) v_Voff.erase(p);
34  }
35  else {
36  // Not found, insert a new entry only if it is not all on
37  setBits(enDetId, HVoff, LVoff);
38  if( (~enDetId & allOnMask) != allOnMask ) v_Voff.insert(p, enDetId);
39  }
40  return true;
41 }
static const short bitShift
static const unsigned int allOnMask
std::vector< uint32_t > v_Voff
void setBits(uint32_t &enDetId, const int HVoff, const int LVoff)
Changes the bits in the stored value according to on/off voltages.
static const unsigned int eightBitMask
Definition: DetId.h:18
std::vector< uint32_t >::iterator vOffIterator
bool SiStripDetVOff::put ( std::vector< uint32_t > &  DetId,
std::vector< int > &  HVoff,
std::vector< int > &  LVoff 
)

Insert information for a vector of detIds.

Definition at line 43 of file SiStripDetVOff.cc.

References gather_cfg::cout, and put().

44 {
45  if( DetId.size() == HVoff.size() && DetId.size() == LVoff.size() ) {
46  constVoffIterator detIdIt = DetId.begin();
47  constVoffIterator detIdItEnd = DetId.end();
48  constVboolIterator HVoffIt = HVoff.begin();
49  constVboolIterator LVoffIt = LVoff.begin();
50  for( ; detIdIt != detIdItEnd; ++detIdIt, ++HVoffIt, ++LVoffIt ) {
51  put( *detIdIt, *HVoffIt, *LVoffIt );
52  }
53  }
54  else {
55  std::cout << "Error: inconsistent sizes of vectors:" << std::endl;
56  std::cout << "DetId size = " << DetId.size() << ", HVoff size = " << HVoff.size() << ", LVoff size = " << LVoff.size() << std::endl;
57  return false;
58  }
59  return true;
60 }
bool put(const uint32_t DetId, const int HVoff, const int LVoff)
Insert information for a single detId.
std::vector< int >::const_iterator constVboolIterator
Definition: DetId.h:18
tuple cout
Definition: gather_cfg.py:121
std::vector< uint32_t >::const_iterator constVoffIterator
void SiStripDetVOff::setBits ( uint32_t &  enDetId,
const int  HVoff,
const int  LVoff 
)

Changes the bits in the stored value according to on/off voltages.

Definition at line 7 of file SiStripDetVOff.cc.

References HVmask, HVonMask, LVmask, and LVonMask.

Referenced by put().

8 {
9  if( LVoff != -1 ) {
10  // LVonMask has all bits equal to 1 apart from the last one.
11  if( LVoff == 0 ) enDetId &= LVonMask;
12  if( LVoff == 1 ) enDetId |= LVmask;
13  }
14  if( HVoff != -1 ) {
15  // HVonMask has all bits equal to 1 apart from the next to last one.
16  if( HVoff == 0 ) enDetId &= HVonMask;
17  if( HVoff == 1 ) enDetId |= HVmask;
18  }
19 }
static const unsigned int LVonMask
static const short HVmask
static const short LVmask
static const unsigned int HVonMask

Member Data Documentation

const unsigned int SiStripDetVOff::allOnMask = 0x03
static

Definition at line 40 of file SiStripDetVOff.h.

Referenced by put().

const short SiStripDetVOff::bitShift = 2
static

Definition at line 42 of file SiStripDetVOff.h.

Referenced by getDetIds(), IsModuleHVOff(), IsModuleLVOff(), IsModuleVOff(), and put().

const unsigned int SiStripDetVOff::eightBitMask = 0xFFFFFFFF
static

Definition at line 41 of file SiStripDetVOff.h.

Referenced by IsModuleHVOff(), IsModuleLVOff(), IsModuleVOff(), and put().

const short SiStripDetVOff::HVmask = 0x2
static

Definition at line 38 of file SiStripDetVOff.h.

Referenced by IsModuleHVOff(), and setBits().

const unsigned int SiStripDetVOff::HVonMask = 0xFFFFFFFD
static

Definition at line 39 of file SiStripDetVOff.h.

Referenced by setBits().

const short SiStripDetVOff::LVmask = 0x1
static

Definition at line 36 of file SiStripDetVOff.h.

Referenced by IsModuleLVOff(), and setBits().

const unsigned int SiStripDetVOff::LVonMask = 0xFFFFFFFE
static

Definition at line 37 of file SiStripDetVOff.h.

Referenced by setBits().

std::vector<uint32_t> SiStripDetVOff::v_Voff
private