File indexing completed on 2024-04-06 12:23:05
0001 #include "OnlineDB/EcalCondDB/interface/LMFCorrCoefDatComponent.h"
0002 #include <cmath>
0003
0004 LMFCorrCoefDatComponent::LMFCorrCoefDatComponent() : LMFDat() { init(); }
0005
0006 LMFCorrCoefDatComponent::LMFCorrCoefDatComponent(EcalDBConnection *c) : LMFDat(c) { init(); }
0007
0008 LMFCorrCoefDatComponent::LMFCorrCoefDatComponent(oracle::occi::Environment *env, oracle::occi::Connection *conn)
0009 : LMFDat(env, conn) {
0010 init();
0011 }
0012
0013 void LMFCorrCoefDatComponent::init() {
0014 m_className = "LMFCorrCoefDatComponent";
0015 m_keys["P1"] = 0;
0016 m_keys["P2"] = 1;
0017 m_keys["P3"] = 2;
0018 m_keys["P1E"] = 3;
0019 m_keys["P2E"] = 4;
0020 m_keys["P3E"] = 5;
0021 m_keys["FLAG"] = 6;
0022 m_keys["SEQ_ID"] = 7;
0023 for (unsigned int i = 0; i < m_keys.size(); i++) {
0024 m_type.push_back("NUMBER");
0025 }
0026 }
0027
0028 std::string LMFCorrCoefDatComponent::foreignKeyName() const { return "lmfLmrSubIOV"; }
0029
0030 std::string LMFCorrCoefDatComponent::getTableName() const { return "LMF_CORR_COEF_DAT"; }
0031
0032 std::string LMFCorrCoefDatComponent::getIovIdFieldName() const { return "LMR_SUB_IOV_ID"; }
0033
0034 LMFCorrCoefDatComponent &LMFCorrCoefDatComponent::setLMFLmrSubIOV(const LMFLmrSubIOV &iov) {
0035 setInt(foreignKeyName(), iov.getID());
0036 attach(foreignKeyName(), (LMFUnique *)&iov);
0037 return *this;
0038 }
0039
0040 LMFCorrCoefDatComponent &LMFCorrCoefDatComponent::setP123(const EcalLogicID &id, float p1, float p2, float p3) {
0041 LMFDat::setData(id, "P1", p1);
0042 LMFDat::setData(id, "P2", p2);
0043 LMFDat::setData(id, "P3", p3);
0044 return *this;
0045 }
0046
0047 LMFCorrCoefDatComponent &LMFCorrCoefDatComponent::setP123(
0048 const EcalLogicID &id, float p1, float p2, float p3, float p1e, float p2e, float p3e) {
0049 setP123(id, p1, p2, p3);
0050 setP123Errors(id, p1e, p2e, p3e);
0051 return *this;
0052 }
0053
0054 LMFCorrCoefDatComponent &LMFCorrCoefDatComponent::setP123Errors(const EcalLogicID &id, float p1e, float p2e, float p3e) {
0055 LMFDat::setData(id, "P1E", p1e);
0056 LMFDat::setData(id, "P2E", p2e);
0057 LMFDat::setData(id, "P3E", p3e);
0058 return *this;
0059 }
0060
0061 LMFCorrCoefDatComponent &LMFCorrCoefDatComponent::setFlag(const EcalLogicID &id, int flag) {
0062 LMFDat::setData(id, "FLAG", flag);
0063 return *this;
0064 }
0065
0066 LMFCorrCoefDatComponent &LMFCorrCoefDatComponent::setSequence(const EcalLogicID &id, int seq_id) {
0067 LMFDat::setData(id, "SEQ_ID", seq_id);
0068 return *this;
0069 }
0070
0071 LMFCorrCoefDatComponent &LMFCorrCoefDatComponent::setSequence(const EcalLogicID &id, const LMFSeqDat &seq) {
0072 LMFDat::setData(id, "SEQ_ID", seq.getID());
0073 return *this;
0074 }
0075
0076 LMFLmrSubIOV LMFCorrCoefDatComponent::getLMFLmrSubIOV() const {
0077 LMFLmrSubIOV iov(m_env, m_conn);
0078 iov.setByID(getInt(foreignKeyName()));
0079 return iov;
0080 }
0081
0082 int LMFCorrCoefDatComponent::getLMFLmrSubIOVID() const { return getInt(foreignKeyName()); }
0083
0084 std::vector<float> LMFCorrCoefDatComponent::getParameters(const EcalLogicID &id) {
0085 std::vector<float> v;
0086 v.push_back(getData(id, "P1"));
0087 v.push_back(getData(id, "P2"));
0088 v.push_back(getData(id, "P3"));
0089 return v;
0090 }
0091
0092 std::vector<float> LMFCorrCoefDatComponent::getParameters(int id) {
0093 std::vector<float> v;
0094 v.push_back(getData(id, "P1"));
0095 v.push_back(getData(id, "P2"));
0096 v.push_back(getData(id, "P3"));
0097 return v;
0098 }
0099
0100 std::vector<float> LMFCorrCoefDatComponent::getParameterErrors(const EcalLogicID &id) {
0101 std::vector<float> v;
0102 v.push_back(getData(id, "P1E"));
0103 v.push_back(getData(id, "P2E"));
0104 v.push_back(getData(id, "P3E"));
0105 return v;
0106 }
0107
0108 std::vector<float> LMFCorrCoefDatComponent::getParameterErrors(int id) {
0109 std::vector<float> v;
0110 v.push_back(getData(id, "P1E"));
0111 v.push_back(getData(id, "P2E"));
0112 v.push_back(getData(id, "P3E"));
0113 return v;
0114 }
0115
0116 int LMFCorrCoefDatComponent::getFlag(const EcalLogicID &id) { return getData(id, "FLAG"); }
0117
0118 int LMFCorrCoefDatComponent::getSeqID(const EcalLogicID &id) { return getData(id, "SEQ_ID"); }
0119
0120 int LMFCorrCoefDatComponent::getSeqID(int id) { return getData(id, "SEQ_ID"); }
0121
0122 LMFSeqDat LMFCorrCoefDatComponent::getSequence(const EcalLogicID &id) {
0123 int seq_id = getData(id, "SEQ_ID");
0124 LMFSeqDat seq(m_env, m_conn);
0125 seq.setByID(seq_id);
0126 return seq;
0127 }
0128
0129 int LMFCorrCoefDatComponent::writeDB() noexcept(false) {
0130 int ret = 0;
0131 try {
0132 ret = LMFDat::writeDB();
0133 } catch (std::runtime_error &e) {
0134 m_conn->rollback();
0135 throw(e);
0136 }
0137 return ret;
0138 }