CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #include "OnlineDB/EcalCondDB/interface/LMFColoredTable.h"
00002 
00003 LMFColoredTable::LMFColoredTable() : LMFDat() {
00004   m_className = "LMFColoredTable";
00005   m_system = 0;
00006   m_color = 0;
00007   COLOR[0]  = "BLUE";
00008   COLOR[1]  = "GREEN";
00009   COLOR[2]  = "ORANGE";
00010   COLOR[3]  = "IR";
00011   SYSTEM[0] = "LASER";
00012   SYSTEM[1] = "LED";
00013 }
00014 
00015 LMFColoredTable::LMFColoredTable(EcalDBConnection *c) : LMFDat(c) {
00016   m_className = "LMFColoredTable";
00017   m_system = 0;
00018   m_color = 0;
00019   COLOR[0]  = "BLUE";
00020   COLOR[1]  = "GREEN";
00021   COLOR[2]  = "ORANGE";
00022   COLOR[3]  = "IR";
00023   SYSTEM[0] = "LASER";
00024   SYSTEM[1] = "LED";
00025 }
00026 
00027 LMFColoredTable::LMFColoredTable(oracle::occi::Environment* env,
00028                                  oracle::occi::Connection* conn) : 
00029   LMFDat(env, conn) {
00030   m_className = "LMFColoredTable";
00031   m_system = 0;
00032   m_color = 0;
00033   COLOR[0]  = "BLUE";
00034   COLOR[1]  = "GREEN";
00035   COLOR[2]  = "ORANGE";
00036   COLOR[3]  = "IR";
00037   SYSTEM[0] = "LASER";
00038   SYSTEM[1] = "LED";
00039 }
00040 
00041 std::string LMFColoredTable::getColor() const {
00042   std::string ret = "";
00043   std::map<int, std::string>::const_iterator i = COLOR.find(m_color);
00044   if (i != COLOR.end()) {
00045     ret = i->second;
00046   }
00047   return ret;
00048 }
00049 
00050 std::string LMFColoredTable::getSystem() const {
00051   std::string ret = "";
00052   std::map<int, std::string>::const_iterator i = SYSTEM.find(m_system);
00053   if (i != SYSTEM.end()) {
00054     ret = i->second;
00055   }
00056   return ret;
00057 }
00058 
00059 LMFColoredTable& LMFColoredTable::setColor(std::string color) {
00060   std::map<int, std::string>::const_iterator i = COLOR.begin();
00061   std::map<int, std::string>::const_iterator e = COLOR.end();
00062   bool loop = true;
00063   while ((loop) && (i != e)) {
00064     if (i->second == color) {
00065       loop = false;
00066       setColor(i->first);
00067     }
00068     i++;
00069   }
00070   return *this;
00071 }
00072 
00073 LMFColoredTable& LMFColoredTable::setSystem(std::string system) {
00074   std::map<int, std::string>::const_iterator i = SYSTEM.begin();
00075   std::map<int, std::string>::const_iterator e = SYSTEM.end();
00076   bool loop = true;
00077   while ((loop) && (i != e)) {
00078     if (i->second == system) {
00079       loop = false;
00080       setSystem(i->first);
00081     }
00082     i++;
00083   }
00084   return *this;
00085 }
00086 
00087 int LMFColoredTable::writeDB() 
00088   throw(std::runtime_error) {
00089   // check if the VMIN version has been properly set, otherwise 
00090   // change it to the default value
00091   std::map<int, std::vector<float> >::iterator i = m_data.begin();
00092   std::map<int, std::vector<float> >::iterator e = m_data.end();
00093   std::list<int> versions; // the list of different versions
00094   while (i != e) {
00095     int s = i->second.size();
00096     if (i->second[s - 2] == 0) { // VMIN cannot be NULL
00097       i->second[s - 2] = 1;
00098     }
00099     versions.push_back(i->second[s - 1]);
00100     versions.push_back(i->second[s - 2]);
00101     versions.unique();
00102     i++;
00103   }
00104   //  checkVesrions(versions); // not yet used, in fact...
00105   int ret = 0;
00106   try {
00107     ret = LMFDat::writeDB();
00108   }
00109   catch (std::runtime_error &e) {
00110     m_conn->rollback();
00111     throw(e);
00112   }
00113   return ret;
00114 }