CMS 3D CMS Logo

SiPixel2DTemplateDBObject.h
Go to the documentation of this file.
1 #ifndef CondFormats_SiPixelObjects_SiPixel2DTemplateDBObject_h
2 #define CondFormats_SiPixelObjects_SiPixel2DTemplateDBObject_h 1
3 
5 
6 #include <vector>
7 #include <map>
8 #include <stdint.h>
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 SiPixel2DTemplateDBObject& 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 template 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 template calibration based on detid
80  void putTemplateIDs(std::map<unsigned int,short>& t_ID) {templ_ID = t_ID;}
81  const std::map<unsigned int,short>& getTemplateIDs () const {return templ_ID;}
82 
83  bool putTemplateID(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("SiPixel2DTemplateDBObject") << "2Dtemplate 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 getTemplateID(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("SiPixel2DTemplateDBObject") << "2Dtemplate 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 };//end SiPixel2DTemplateDBObject
115 #endif
int i
Definition: DBlmapReader.cc:9
std::vector< float > sVector() const
SiPixel2DTemplateDBObject & operator>>(int &i)
double f[11][100]
Definition: value.py:1
void putTemplateIDs(std::map< unsigned int, short > &t_ID)
short getTemplateID(const uint32_t &detid) const
friend std::ostream & operator<<(std::ostream &s, const SiPixel2DTemplateDBObject &dbobject)
#define COND_SERIALIZABLE
Definition: Serializable.h:38
std::map< unsigned int, short > templ_ID
bool putTemplateID(const uint32_t &detid, short &value)
SiPixel2DTemplateDBObject & operator>>(float &f)
const std::map< unsigned int, short > & getTemplateIDs() const