CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelGenErrorDBObject.h
Go to the documentation of this file.
1 #ifndef CondFormats_SiPixelObjects_SiPixelGenErrorDBObject_h
2 #define CondFormats_SiPixelObjects_SiPixelGenErrorDBObject_h 1
3 
4 #include <vector>
5 #include <map>
6 #include <stdint.h>
8 
10 
11 // ******************************************************************************************
14 // ******************************************************************************************
15 
17 public:
19  sVector_.reserve(1000000);
20  }
22 
23  //- Allows the dbobject to be read out like cout
24  friend std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobject);
25 
26  //- Fills integer from dbobject
28  {
29  isInvalid_ = false;
30  if(index_<=maxIndex_) {
31  i = (int) (*this).sVector_[index_];
32  index_++;
33  }
34  else
35  (*this).setInvalid();
36  return *this;
37  }
38  //- Fills float from dbobject
40  {
41  isInvalid_ = false;
42  if(index_<=maxIndex_) {
43  f = (*this).sVector_[index_];
44  index_++;
45  }
46  else
47  (*this).setInvalid();
48  return *this;
49  }
50 
51  //- Functions to monitor integrity of dbobject
53  void setInvalid() {isInvalid_ = true;}
54  bool fail() {return isInvalid_;}
55 
56  //- Setter functions
57  void push_back(float entry) {sVector_.push_back(entry);}
58  void setIndex(int index) {index_ = index;}
61 
62  //- Accessor functions
63  int index() const {return index_;}
64  int maxIndex() const {return maxIndex_;}
65  int numOfTempl() const {return numOfTempl_;}
66  float version() const {return version_;}
67  std::vector<float> sVector() const {return sVector_;}
68 
69  //- Able to set the index for GenError header
70  void incrementIndex(int i) {index_+=i;}
71 
72  //- Allows storage of header (type = char[80]) in dbobject
73  union char2float
74  {
75  char c[4];
76  float f;
77  };
78 
79  //- To be used to select GenError calibration based on detid
80  void putGenErrorIDs(std::map<unsigned int,short>& t_ID) {templ_ID = t_ID;}
81  const std::map<unsigned int,short>& getGenErrorIDs () const {return templ_ID;}
82 
83  bool putGenErrorID(const uint32_t& detid, short& value)
84  {
85  std::map<unsigned int,short>::const_iterator id=templ_ID.find(detid);
86  if(id!=templ_ID.end()){
87  edm::LogError("SiPixelGenErrorDBObject") << "GenError ID for DetID " << detid
88  << " is already stored. Skipping this put" << std::endl;
89  return false;
90  }
91  else templ_ID[detid] = value;
92  return true;
93  }
94 
95  short getGenErrorID(const uint32_t& detid) const
96  {
97  std::map<unsigned int,short>::const_iterator id=templ_ID.find(detid);
98  if(id!=templ_ID.end()) return id->second;
99  else edm::LogError("SiPixelGenErrorDBObject") << "GenError ID for DetID " << detid
100  << " is not stored" << std::endl;
101  return 0;
102  }
103 
104 private:
105  int index_;
108  float version_;
110  std::vector<float> sVector_;
111  std::map<unsigned int,short> templ_ID;
112 
114 
115 };//end SiPixelGenErrorDBObject
116 #endif
void putGenErrorIDs(std::map< unsigned int, short > &t_ID)
int i
Definition: DBlmapReader.cc:9
friend std::ostream & operator<<(std::ostream &s, const SiPixelGenErrorDBObject &dbobject)
SiPixelGenErrorDBObject & operator>>(int &i)
void setNumOfTempl(int numOfTempl)
short getGenErrorID(const uint32_t &detid) const
bool putGenErrorID(const uint32_t &detid, short &value)
SiPixelGenErrorDBObject & operator>>(float &f)
const std::map< unsigned int, short > & getGenErrorIDs() const
std::vector< float > sVector() const
double f[11][100]
#define COND_SERIALIZABLE
Definition: Serializable.h:38
std::map< unsigned int, short > templ_ID
void setVersion(float version)
list entry
Definition: mps_splice.py:62
volatile std::atomic< bool > shutdown_flag false