CMS 3D CMS Logo

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