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 <cstdint>
10 
11 // ******************************************************************************************
14 // ******************************************************************************************
15 
17 public:
19  : index_(0), maxIndex_(0), numOfTempl_(1), version_(-99.9), isInvalid_(false), sVector_(0) {
20  sVector_.reserve(1000000);
21  }
23 
24  //- Allows the dbobject to be read out like cout
25  friend std::ostream& operator<<(std::ostream& s, const SiPixel2DTemplateDBObject& dbobject);
26 
27  //- Fills integer from dbobject
29  isInvalid_ = false;
30  if (index_ <= maxIndex_) {
31  i = (int)(*this).sVector_[index_];
32  index_++;
33  } else
34  (*this).setInvalid();
35  return *this;
36  }
37  //- Fills float from dbobject
39  isInvalid_ = false;
40  if (index_ <= maxIndex_) {
41  f = (*this).sVector_[index_];
42  index_++;
43  } else
44  (*this).setInvalid();
45  return *this;
46  }
47 
48  //- Functions to monitor integrity of dbobject
49  void setVersion(float version) { version_ = version; }
50  void setInvalid() { isInvalid_ = true; }
51  bool fail() { return isInvalid_; }
52 
53  //- Setter functions
54  void push_back(float entry) { sVector_.push_back(entry); }
55  void setIndex(int index) { index_ = index; }
58 
59  //- Accessor functions
60  int index() const { return index_; }
61  int maxIndex() const { return maxIndex_; }
62  int numOfTempl() const { return numOfTempl_; }
63  float version() const { return version_; }
64  std::vector<float> sVector() const { return sVector_; }
65 
66  //- Able to set the index for template header
67  void incrementIndex(int i) { index_ += i; }
68 
69  //- Allows storage of header (type = char[80]) in dbobject
70  union char2float {
71  char c[4];
72  float f;
73  };
74 
75  //- To be used to select template calibration based on detid
76  void putTemplateIDs(std::map<unsigned int, short>& t_ID) { templ_ID = t_ID; }
77  const std::map<unsigned int, short>& getTemplateIDs() const { return templ_ID; }
78 
79  bool putTemplateID(const uint32_t& detid, short& value) {
80  std::map<unsigned int, short>::const_iterator id = templ_ID.find(detid);
81  if (id != templ_ID.end()) {
82  edm::LogError("SiPixel2DTemplateDBObject")
83  << "2Dtemplate ID for DetID " << detid << " is already stored. Skipping this put" << std::endl;
84  return false;
85  } else
86  templ_ID[detid] = value;
87  return true;
88  }
89 
90  short getTemplateID(const uint32_t& detid) const {
91  std::map<unsigned int, short>::const_iterator id = templ_ID.find(detid);
92  if (id != templ_ID.end())
93  return id->second;
94  else
95  edm::LogError("SiPixel2DTemplateDBObject")
96  << "2Dtemplate ID for DetID " << detid << " is not stored" << std::endl;
97  return 0;
98  }
99 
100 private:
101  int index_;
104  float version_;
106  std::vector<float> sVector_;
107  std::map<unsigned int, short> templ_ID;
108 
110 }; //end SiPixel2DTemplateDBObject
111 #endif
mps_fire.i
i
Definition: mps_fire.py:428
SiPixel2DTemplateDBObject::operator>>
SiPixel2DTemplateDBObject & operator>>(float &f)
Definition: SiPixel2DTemplateDBObject.h:38
SiPixel2DTemplateDBObject
Definition: SiPixel2DTemplateDBObject.h:16
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
SiPixel2DTemplateDBObject::operator<<
friend std::ostream & operator<<(std::ostream &s, const SiPixel2DTemplateDBObject &dbobject)
SiPixel2DTemplateDBObject::getTemplateIDs
const std::map< unsigned int, short > & getTemplateIDs() const
Definition: SiPixel2DTemplateDBObject.h:77
mps_splice.entry
entry
Definition: mps_splice.py:68
SiPixel2DTemplateDBObject::push_back
void push_back(float entry)
Definition: SiPixel2DTemplateDBObject.h:54
SiPixel2DTemplateDBObject::char2float
Definition: SiPixel2DTemplateDBObject.h:70
COND_SERIALIZABLE
#define COND_SERIALIZABLE
Definition: Serializable.h:39
SiPixel2DTemplateDBObject::setMaxIndex
void setMaxIndex(int maxIndex)
Definition: SiPixel2DTemplateDBObject.h:56
SiPixel2DTemplateDBObject::index_
int index_
Definition: SiPixel2DTemplateDBObject.h:101
alignCSCRings.s
s
Definition: alignCSCRings.py:92
SiPixel2DTemplateDBObject::fail
bool fail()
Definition: SiPixel2DTemplateDBObject.h:51
SiPixel2DTemplateDBObject::version
float version() const
Definition: SiPixel2DTemplateDBObject.h:63
SiPixel2DTemplateDBObject::incrementIndex
void incrementIndex(int i)
Definition: SiPixel2DTemplateDBObject.h:67
SiPixel2DTemplateDBObject::setIndex
void setIndex(int index)
Definition: SiPixel2DTemplateDBObject.h:55
SiPixel2DTemplateDBObject::putTemplateIDs
void putTemplateIDs(std::map< unsigned int, short > &t_ID)
Definition: SiPixel2DTemplateDBObject.h:76
SiPixel2DTemplateDBObject::maxIndex_
int maxIndex_
Definition: SiPixel2DTemplateDBObject.h:102
SiPixel2DTemplateDBObject::maxIndex
int maxIndex() const
Definition: SiPixel2DTemplateDBObject.h:61
SiPixel2DTemplateDBObject::version_
float version_
Definition: SiPixel2DTemplateDBObject.h:104
SiPixel2DTemplateDBObject::setVersion
void setVersion(float version)
Definition: SiPixel2DTemplateDBObject.h:49
SiPixel2DTemplateDBObject::index
int index() const
Definition: SiPixel2DTemplateDBObject.h:60
SiPixel2DTemplateDBObject::putTemplateID
bool putTemplateID(const uint32_t &detid, short &value)
Definition: SiPixel2DTemplateDBObject.h:79
SiPixel2DTemplateDBObject::getTemplateID
short getTemplateID(const uint32_t &detid) const
Definition: SiPixel2DTemplateDBObject.h:90
SiPixel2DTemplateDBObject::sVector
std::vector< float > sVector() const
Definition: SiPixel2DTemplateDBObject.h:64
SiPixel2DTemplateDBObject::char2float::c
char c[4]
Definition: SiPixel2DTemplateDBObject.h:71
createfilelist.int
int
Definition: createfilelist.py:10
Serializable.h
value
Definition: value.py:1
SiPixel2DTemplateDBObject::operator>>
SiPixel2DTemplateDBObject & operator>>(int &i)
Definition: SiPixel2DTemplateDBObject.h:28
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiPixel2DTemplateDBObject::isInvalid_
bool isInvalid_
Definition: SiPixel2DTemplateDBObject.h:105
SiPixel2DTemplateDBObject::~SiPixel2DTemplateDBObject
virtual ~SiPixel2DTemplateDBObject()
Definition: SiPixel2DTemplateDBObject.h:22
SiPixel2DTemplateDBObject::numOfTempl_
int numOfTempl_
Definition: SiPixel2DTemplateDBObject.h:103
SiPixel2DTemplateDBObject::setNumOfTempl
void setNumOfTempl(int numOfTempl)
Definition: SiPixel2DTemplateDBObject.h:57
SiPixel2DTemplateDBObject::char2float::f
float f
Definition: SiPixel2DTemplateDBObject.h:72
SiPixel2DTemplateDBObject::sVector_
std::vector< float > sVector_
Definition: SiPixel2DTemplateDBObject.h:106
SiPixel2DTemplateDBObject::SiPixel2DTemplateDBObject
SiPixel2DTemplateDBObject()
Definition: SiPixel2DTemplateDBObject.h:18
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
relativeConstraints.value
value
Definition: relativeConstraints.py:53
SiPixel2DTemplateDBObject::numOfTempl
int numOfTempl() const
Definition: SiPixel2DTemplateDBObject.h:62
SiPixel2DTemplateDBObject::setInvalid
void setInvalid()
Definition: SiPixel2DTemplateDBObject.h:50
edm::Log
Definition: MessageLogger.h:70
SiPixel2DTemplateDBObject::templ_ID
std::map< unsigned int, short > templ_ID
Definition: SiPixel2DTemplateDBObject.h:107