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
SiPixelGenErrorDBObject::operator<<
friend std::ostream & operator<<(std::ostream &s, const SiPixelGenErrorDBObject &dbobject)
SiPixelGenErrorDBObject::operator>>
SiPixelGenErrorDBObject & operator>>(int &i)
Definition: SiPixelGenErrorDBObject.h:27
SiPixelGenErrorDBObject::setMaxIndex
void setMaxIndex(int maxIndex)
Definition: SiPixelGenErrorDBObject.h:55
mps_fire.i
i
Definition: mps_fire.py:428
SiPixelGenErrorDBObject::putGenErrorIDs
void putGenErrorIDs(std::map< unsigned int, short > &t_ID)
Definition: SiPixelGenErrorDBObject.h:75
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
SiPixelGenErrorDBObject::maxIndex
int maxIndex() const
Definition: SiPixelGenErrorDBObject.h:60
SiPixelGenErrorDBObject::setNumOfTempl
void setNumOfTempl(int numOfTempl)
Definition: SiPixelGenErrorDBObject.h:56
SiPixelGenErrorDBObject::version_
float version_
Definition: SiPixelGenErrorDBObject.h:102
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
mps_splice.entry
entry
Definition: mps_splice.py:68
SiPixelGenErrorDBObject::fail
bool fail()
Definition: SiPixelGenErrorDBObject.h:50
COND_SERIALIZABLE
#define COND_SERIALIZABLE
Definition: Serializable.h:39
SiPixelGenErrorDBObject::~SiPixelGenErrorDBObject
virtual ~SiPixelGenErrorDBObject()
Definition: SiPixelGenErrorDBObject.h:21
SiPixelGenErrorDBObject::numOfTempl_
int numOfTempl_
Definition: SiPixelGenErrorDBObject.h:101
SiPixelGenErrorDBObject::templ_ID
std::map< unsigned int, short > templ_ID
Definition: SiPixelGenErrorDBObject.h:105
SiPixelGenErrorDBObject::version
float version() const
Definition: SiPixelGenErrorDBObject.h:62
SiPixelGenErrorDBObject::operator>>
SiPixelGenErrorDBObject & operator>>(float &f)
Definition: SiPixelGenErrorDBObject.h:37
alignCSCRings.s
s
Definition: alignCSCRings.py:92
SiPixelGenErrorDBObject::putGenErrorID
bool putGenErrorID(const uint32_t &detid, short &value)
Definition: SiPixelGenErrorDBObject.h:78
SiPixelGenErrorDBObject::char2float
Definition: SiPixelGenErrorDBObject.h:69
SiPixelGenErrorDBObject::getGenErrorID
short getGenErrorID(const uint32_t &detid) const
Definition: SiPixelGenErrorDBObject.h:89
SiPixelGenErrorDBObject::incrementIndex
void incrementIndex(int i)
Definition: SiPixelGenErrorDBObject.h:66
createfilelist.int
int
Definition: createfilelist.py:10
Serializable.h
SiPixelGenErrorDBObject::char2float::f
float f
Definition: SiPixelGenErrorDBObject.h:71
value
Definition: value.py:1
SiPixelGenErrorDBObject::sVector
std::vector< float > sVector() const
Definition: SiPixelGenErrorDBObject.h:63
SiPixelGenErrorDBObject::push_back
void push_back(float entry)
Definition: SiPixelGenErrorDBObject.h:53
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiPixelGenErrorDBObject::numOfTempl
int numOfTempl() const
Definition: SiPixelGenErrorDBObject.h:61
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
relativeConstraints.value
value
Definition: relativeConstraints.py:53
SiPixelGenErrorDBObject::setVersion
void setVersion(float version)
Definition: SiPixelGenErrorDBObject.h:48
SiPixelGenErrorDBObject::maxIndex_
int maxIndex_
Definition: SiPixelGenErrorDBObject.h:100
SiPixelGenErrorDBObject::index_
int index_
Definition: SiPixelGenErrorDBObject.h:99
SiPixelGenErrorDBObject::sVector_
std::vector< float > sVector_
Definition: SiPixelGenErrorDBObject.h:104
SiPixelGenErrorDBObject::index
int index() const
Definition: SiPixelGenErrorDBObject.h:59
SiPixelGenErrorDBObject::setIndex
void setIndex(int index)
Definition: SiPixelGenErrorDBObject.h:54
SiPixelGenErrorDBObject
Definition: SiPixelGenErrorDBObject.h:16
SiPixelGenErrorDBObject::isInvalid_
bool isInvalid_
Definition: SiPixelGenErrorDBObject.h:103
SiPixelGenErrorDBObject::getGenErrorIDs
const std::map< unsigned int, short > & getGenErrorIDs() const
Definition: SiPixelGenErrorDBObject.h:76
SiPixelGenErrorDBObject::setInvalid
void setInvalid()
Definition: SiPixelGenErrorDBObject.h:49
SiPixelGenErrorDBObject::char2float::c
char c[4]
Definition: SiPixelGenErrorDBObject.h:70
SiPixelGenErrorDBObject::SiPixelGenErrorDBObject
SiPixelGenErrorDBObject()
Definition: SiPixelGenErrorDBObject.h:18
edm::Log
Definition: MessageLogger.h:70