CMS 3D CMS Logo

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 <cstdint>
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  isInvalid_ = false;
29  if (index_ <= maxIndex_) {
30  i = (int)(*this).sVector_[index_];
31  index_++;
32  } else
33  (*this).setInvalid();
34  return *this;
35  }
36  //- Fills float from dbobject
38  isInvalid_ = false;
39  if (index_ <= maxIndex_) {
40  f = (*this).sVector_[index_];
41  index_++;
42  } else
43  (*this).setInvalid();
44  return *this;
45  }
46 
47  //- Functions to monitor integrity of dbobject
48  void setVersion(float version) { version_ = version; }
49  void setInvalid() { isInvalid_ = true; }
50  bool fail() { return isInvalid_; }
51 
52  //- Setter functions
53  void push_back(float entry) { sVector_.push_back(entry); }
54  void setIndex(int index) { index_ = index; }
57 
58  //- Accessor functions
59  int index() const { return index_; }
60  int maxIndex() const { return maxIndex_; }
61  int numOfTempl() const { return numOfTempl_; }
62  float version() const { return version_; }
63  std::vector<float> sVector() const { return sVector_; }
64 
65  //- Able to set the index for GenError header
66  void incrementIndex(int i) { index_ += i; }
67 
68  //- Allows storage of header (type = char[80]) in dbobject
69  union char2float {
70  char c[4];
71  float f;
72  };
73 
74  //- To be used to select GenError calibration based on detid
75  void putGenErrorIDs(std::map<unsigned int, short>& t_ID) { templ_ID = t_ID; }
76  const std::map<unsigned int, short>& getGenErrorIDs() const { return templ_ID; }
77 
78  bool putGenErrorID(const uint32_t& detid, short& value) {
79  std::map<unsigned int, short>::const_iterator id = templ_ID.find(detid);
80  if (id != templ_ID.end()) {
81  edm::LogError("SiPixelGenErrorDBObject")
82  << "GenError ID for DetID " << detid << " is already stored. Skipping this put" << std::endl;
83  return false;
84  } else
85  templ_ID[detid] = value;
86  return true;
87  }
88 
89  short getGenErrorID(const uint32_t& detid) const {
90  std::map<unsigned int, short>::const_iterator id = templ_ID.find(detid);
91  if (id != templ_ID.end())
92  return id->second;
93  else
94  edm::LogError("SiPixelGenErrorDBObject") << "GenError ID for DetID " << detid << " is not stored" << std::endl;
95  return 0;
96  }
97 
98 private:
99  int index_;
102  float version_;
104  std::vector<float> sVector_;
105  std::map<unsigned int, short> templ_ID;
106 
108 
109 }; //end SiPixelGenErrorDBObject
110 #endif
void putGenErrorIDs(std::map< unsigned int, short > &t_ID)
friend std::ostream & operator<<(std::ostream &s, const SiPixelGenErrorDBObject &dbobject)
SiPixelGenErrorDBObject & operator>>(int &i)
void setNumOfTempl(int numOfTempl)
Log< level::Error, false > LogError
bool putGenErrorID(const uint32_t &detid, short &value)
std::map< unsigned int, short > templ_ID
SiPixelGenErrorDBObject & operator>>(float &f)
short getGenErrorID(const uint32_t &detid) const
double f[11][100]
Definition: value.py:1
std::vector< float > sVector() const
#define COND_SERIALIZABLE
Definition: Serializable.h:39
void setVersion(float version)
const std::map< unsigned int, short > & getGenErrorIDs() const