CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/OnlineDB/EcalCondDB/src/LMFCorrCoefDatComponent.cc

Go to the documentation of this file.
00001 #include "OnlineDB/EcalCondDB/interface/LMFCorrCoefDatComponent.h"
00002 #include <math.h>
00003 
00004 LMFCorrCoefDatComponent::LMFCorrCoefDatComponent() : LMFDat() {
00005   init();
00006 }
00007 
00008 LMFCorrCoefDatComponent::LMFCorrCoefDatComponent(EcalDBConnection *c) : LMFDat(c) {
00009   init();
00010 }
00011 
00012 LMFCorrCoefDatComponent::LMFCorrCoefDatComponent(oracle::occi::Environment* env,
00013                                oracle::occi::Connection* conn): 
00014   LMFDat(env, conn) {
00015   init();
00016 }
00017 
00018 void LMFCorrCoefDatComponent::init() {
00019   m_className = "LMFCorrCoefDatComponent";
00020   m_keys["P1"] = 0;
00021   m_keys["P2"] = 1;
00022   m_keys["P3"] = 2;
00023   m_keys["P1E"] = 3;
00024   m_keys["P2E"] = 4;
00025   m_keys["P3E"] = 5;
00026   m_keys["FLAG"] = 6;
00027   m_keys["SEQ_ID"] = 7;
00028   for (unsigned int i = 0; i < m_keys.size(); i++) {
00029     m_type.push_back("NUMBER");
00030   }
00031 }
00032 
00033 std::string LMFCorrCoefDatComponent::foreignKeyName() const {
00034   return "lmfLmrSubIOV";
00035 }
00036 
00037 std::string LMFCorrCoefDatComponent::getTableName() const {
00038   return "LMF_CORR_COEF_DAT";
00039 }
00040 
00041 std::string LMFCorrCoefDatComponent::getIovIdFieldName() const {
00042   return "LMR_SUB_IOV_ID";
00043 }
00044 
00045 LMFCorrCoefDatComponent& LMFCorrCoefDatComponent::setLMFLmrSubIOV(const LMFLmrSubIOV &iov) {
00046   setInt(foreignKeyName(), iov.getID());
00047   attach(foreignKeyName(), (LMFUnique*)&iov);
00048   return *this;
00049 }
00050 
00051 LMFCorrCoefDatComponent& LMFCorrCoefDatComponent::setP123(const EcalLogicID &id, 
00052                                         float p1, float p2, float p3) {
00053   LMFDat::setData(id, "P1", p1);
00054   LMFDat::setData(id, "P2", p2);
00055   LMFDat::setData(id, "P3", p3);
00056   return *this;
00057 }
00058 
00059 LMFCorrCoefDatComponent& LMFCorrCoefDatComponent::setP123(const EcalLogicID &id, 
00060                                         float p1, float p2, float p3,
00061                                         float p1e, float p2e, float p3e) {
00062   setP123(id, p1, p2, p3);
00063   setP123Errors(id, p1e, p2e, p3e);
00064   return *this;
00065 }
00066 
00067 LMFCorrCoefDatComponent& LMFCorrCoefDatComponent::setP123Errors(const EcalLogicID &id, 
00068                                               float p1e, float p2e, float p3e) {
00069   LMFDat::setData(id, "P1E", p1e);
00070   LMFDat::setData(id, "P2E", p2e);
00071   LMFDat::setData(id, "P3E", p3e);
00072   return *this;
00073 }
00074 
00075 LMFCorrCoefDatComponent& LMFCorrCoefDatComponent::setFlag(const EcalLogicID &id, int flag) {
00076   LMFDat::setData(id, "FLAG", flag);
00077   return *this;
00078 }
00079 
00080 LMFCorrCoefDatComponent& LMFCorrCoefDatComponent::setSequence(const EcalLogicID &id, 
00081                                                               int seq_id) {
00082   LMFDat::setData(id, "SEQ_ID", seq_id);
00083   return *this;
00084 }
00085 
00086 LMFCorrCoefDatComponent& LMFCorrCoefDatComponent::setSequence(const EcalLogicID &id, 
00087                                                               const LMFSeqDat &seq) {
00088   LMFDat::setData(id, "SEQ_ID", seq.getID());
00089   return *this;
00090 }
00091 
00092 LMFLmrSubIOV LMFCorrCoefDatComponent::getLMFLmrSubIOV() const {
00093   LMFLmrSubIOV iov(m_env, m_conn);
00094   iov.setByID(getInt(foreignKeyName()));
00095   return iov;
00096 }
00097 
00098 int LMFCorrCoefDatComponent::getLMFLmrSubIOVID() const {
00099   return getInt(foreignKeyName());
00100 }
00101 
00102 std::vector<float>  LMFCorrCoefDatComponent::getParameters(const EcalLogicID &id) {
00103   std::vector<float> v;
00104   v.push_back(getData(id, "P1"));
00105   v.push_back(getData(id, "P2"));
00106   v.push_back(getData(id, "P3"));
00107   return v;
00108 }
00109 
00110 std::vector<float>  LMFCorrCoefDatComponent::getParameters(int id) {
00111   std::vector<float> v;
00112   v.push_back(getData(id, "P1"));
00113   v.push_back(getData(id, "P2"));
00114   v.push_back(getData(id, "P3"));
00115   return v;
00116 }
00117 
00118 std::vector<float>  LMFCorrCoefDatComponent::getParameterErrors(const EcalLogicID &id) {
00119   std::vector<float> v;
00120   v.push_back(getData(id, "P1E"));
00121   v.push_back(getData(id, "P2E"));
00122   v.push_back(getData(id, "P3E"));
00123   return v;
00124 }
00125 
00126 std::vector<float>  LMFCorrCoefDatComponent::getParameterErrors(int id) {
00127   std::vector<float> v;
00128   v.push_back(getData(id, "P1E"));
00129   v.push_back(getData(id, "P2E"));
00130   v.push_back(getData(id, "P3E"));
00131   return v;
00132 }
00133 
00134 int LMFCorrCoefDatComponent::getFlag(const EcalLogicID &id) {
00135   return getData(id, "FLAG");
00136 }
00137 
00138 int LMFCorrCoefDatComponent::getSeqID(const EcalLogicID &id) {
00139   return getData(id, "SEQ_ID");
00140 }
00141 
00142 int LMFCorrCoefDatComponent::getSeqID(int id) {
00143   return getData(id, "SEQ_ID");
00144 }
00145 
00146 LMFSeqDat LMFCorrCoefDatComponent::getSequence(const EcalLogicID &id) {
00147   int seq_id = getData(id, "SEQ_ID");
00148   LMFSeqDat seq(m_env, m_conn);
00149   seq.setByID(seq_id);
00150   return seq;
00151 }
00152 
00153 int LMFCorrCoefDatComponent::writeDB() 
00154   throw(std::runtime_error) {
00155   int ret = 0;
00156   try {
00157     ret = LMFDat::writeDB();
00158   }
00159   catch (std::runtime_error &e) {
00160     m_conn->rollback();
00161     throw(e);
00162   }
00163   return ret;
00164 }