CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/OnlineDB/EcalCondDB/src/LMFPnPrimDat.cc

Go to the documentation of this file.
00001 #include "OnlineDB/EcalCondDB/interface/LMFPnPrimDat.h"
00002 
00003 LMFPnPrimDat::LMFPnPrimDat() : LMFColoredTable() {
00004   init();
00005 }
00006 
00007 LMFPnPrimDat::LMFPnPrimDat(oracle::occi::Environment* env,
00008                          oracle::occi::Connection* conn) : 
00009   LMFColoredTable(env, conn) {
00010   init();
00011 }
00012 
00013 LMFPnPrimDat::LMFPnPrimDat(EcalDBConnection *c) : LMFColoredTable(c) {
00014   init();
00015 }
00016 
00017 LMFPnPrimDat::LMFPnPrimDat(std::string color, std::string system) : 
00018   LMFColoredTable() {
00019   init();
00020   setColor(color);
00021   setSystem(system);
00022 }
00023 
00024 LMFPnPrimDat::LMFPnPrimDat(oracle::occi::Environment* env,
00025                          oracle::occi::Connection* conn,
00026                          std::string color, std::string system) : 
00027   LMFColoredTable(env, conn) {
00028   init();
00029   setColor(color);
00030   setSystem(system);
00031 }
00032 
00033 LMFPnPrimDat::LMFPnPrimDat(EcalDBConnection *c, std::string color, 
00034                            std::string system, bool d) : LMFColoredTable(c) {
00035   if (d) {
00036     debug();
00037   }
00038   init();
00039   setColor(color);
00040   setSystem(system);
00041 }
00042 
00043 LMFPnPrimDat::LMFPnPrimDat(EcalDBConnection *c, std::string color, 
00044                            std::string system) : LMFColoredTable(c) {
00045   init();
00046   setColor(color);
00047   setSystem(system);
00048 }
00049 
00050 LMFPnPrimDat::LMFPnPrimDat(int color, std::string system) : 
00051   LMFColoredTable() {
00052   init();
00053   setColor(color);
00054   setSystem(system);
00055 }
00056 
00057 LMFPnPrimDat::LMFPnPrimDat(oracle::occi::Environment* env,
00058                          oracle::occi::Connection* conn,
00059                          int color, std::string system) : 
00060   LMFColoredTable(env, conn) {
00061   init();
00062   setColor(color);
00063   setSystem(system);
00064 }
00065 
00066 LMFPnPrimDat::LMFPnPrimDat(EcalDBConnection *c, int color, 
00067                          std::string system) : LMFColoredTable(c) {
00068   init();
00069   setColor(color);
00070   setSystem(system);
00071 }
00072 
00073 LMFPnPrimDat& LMFPnPrimDat::setSystem(std::string s) {
00074   // LED tables do not hold the shapecorr column. Drop it.
00075   std::transform(s.begin(), s.end(), s.begin(), toupper);
00076   if (s == "LED") {
00077     if (m_debug) {
00078       std::cout << "Erasing unwanted data" << std::endl;
00079     }
00080     m_type.erase(m_type.begin());
00081     m_keys.erase("SHAPECORRPN");
00082     if (m_debug) {
00083       std::cout << "Data: " << m_data.size() << " Keys: " <<  m_keys.size()
00084                 << " Type: " << m_type.size() << std::endl;
00085     }
00086     std::map<std::string, unsigned int>::iterator i = m_keys.begin();
00087     std::map<std::string, unsigned int>::iterator e = m_keys.end();
00088     while (i != e) {
00089       // modify indexes
00090       (i->second)--;
00091       if (m_debug) {
00092         std::cout << "Key " << i->first << " = " << i->second << std::endl;
00093       }
00094       i++;
00095     }
00096   }
00097   LMFColoredTable::setSystem(s);
00098   return *this;
00099 }
00100 
00101 void LMFPnPrimDat::init() {
00102   m_className = "LMFPnPrimDat";
00103 
00104   m_keys["SHAPECORRPN"] = 0;
00105   m_keys["MEAN"] = 1;
00106   m_keys["RMS"] = 2;
00107   m_keys["M3"] = 3;
00108   m_keys["PNABMEAN"] = 4;
00109   m_keys["PNABRMS"] = 5;
00110   m_keys["PNABM3"] = 6;
00111   m_keys["FLAG"] = 7;
00112   m_keys["VMIN"] = 8;
00113   m_keys["VMAX"] = 9;
00114 
00115   m_type.resize(10);
00116   for (int i = 0; i < 10; i++) {
00117     m_type[i] = "NUMBER";
00118   }
00119 
00120   m_system = 0;
00121   m_color = 0;
00122 }
00123 
00124 bool LMFPnPrimDat::isValid() {
00125   bool ret = true;
00126   if ((getSystem() != "LASER") && (getSystem() != "LED")) {
00127     m_Error += " System name not properly set [" + getSystem() + "]";
00128     ret = false;
00129   }
00130   if ((getSystem() == "LASER") && 
00131       (getColor() != "BLUE") && (getColor() != "IR")) {
00132     m_Error += " Color not properly set [" + getColor() + "]";
00133     ret = false;
00134   }
00135   if ((getSystem() == "LED") && 
00136       (getColor() != "BLUE") && (getColor() != "ORANGE")) {
00137     m_Error += " Color not properly set [" + getColor() + "]";
00138     ret = false;
00139   }
00140   return ret;
00141 }
00142 
00143 LMFPnPrimDat& LMFPnPrimDat::setMean(EcalLogicID &id, float v) {
00144   LMFDat::setData(id, "MEAN", v);
00145   return *this;
00146 }
00147 
00148 LMFPnPrimDat& LMFPnPrimDat::setRMS(EcalLogicID &id, float v) {
00149   LMFDat::setData(id, "RMS", v);
00150   return *this;
00151 }
00152 
00153 LMFPnPrimDat& LMFPnPrimDat::setM3(EcalLogicID &id, float v) {
00154   LMFDat::setData(id, "M3", v);
00155   return *this;
00156 }
00157 
00158 LMFPnPrimDat& LMFPnPrimDat::setPN(EcalLogicID &id, float mean, float rms, 
00159                                   float m3) {
00160   setMean(id, mean);
00161   setRMS(id, rms);
00162   setM3(id, m3);
00163   return *this;
00164 }
00165 LMFPnPrimDat& LMFPnPrimDat::setShapeCorr(EcalLogicID &id, float v ) {
00166   if (getSystem() != "LED") {
00167     LMFDat::setData(id, "SHAPECORRPN", v);
00168   }
00169   return *this;
00170 }
00171 
00172 LMFPnPrimDat& LMFPnPrimDat::setPNAoverBM3(EcalLogicID &id, float v) {
00173   LMFDat::setData(id, "PNABM3", v);
00174   return *this;
00175 }
00176 
00177 LMFPnPrimDat& LMFPnPrimDat::setPNAoverBMean(EcalLogicID &id, float v) {
00178   LMFDat::setData(id, "PNABMEAN", v);
00179   return *this;
00180 }
00181 
00182 LMFPnPrimDat& LMFPnPrimDat::setPNAoverBRMS(EcalLogicID &id, float v) {
00183   LMFDat::setData(id, "PNABRMS", v);
00184   return *this;
00185 }
00186 
00187 LMFPnPrimDat& LMFPnPrimDat::setPNAoverB(EcalLogicID &id, 
00188                                         float mean, float rms, float m3) {
00189   setPNAoverBMean(id, mean);
00190   setPNAoverBRMS(id, rms);
00191   setPNAoverBM3(id, m3);
00192   return *this;
00193 }
00194 LMFPnPrimDat& LMFPnPrimDat::setFlag(EcalLogicID &id, int v) {
00195   LMFDat::setData(id, "FLAG", v);
00196   return *this;
00197 }
00198 
00199 float LMFPnPrimDat::getMean(int id) {
00200   return getData(id, "MEAN");
00201 }
00202 
00203 float LMFPnPrimDat::getShapeCor(int id) {
00204   float x = 0;
00205   if (getSystem() != "LED") {
00206     x = getData(id, "SHAPECORRPN");
00207   }
00208   return x;
00209 }
00210 
00211 float LMFPnPrimDat::getRMS(int id) {
00212   return getData(id, "RMS");
00213 }
00214 
00215 float LMFPnPrimDat::getM3(int id) {
00216   return getData(id, "M3");
00217 }
00218 
00219 float LMFPnPrimDat::getPNAoverBM3(int id) {
00220   return getData(id, "PNABM3");
00221 }
00222 
00223 float LMFPnPrimDat::getPNAoverBMean(int id) {
00224   return getData(id, "PNABMEAN");
00225 }
00226 
00227 float LMFPnPrimDat::getPNAoverBRMS(int id) {
00228   return getData(id, "PNABRMS");
00229 }
00230 
00231 int LMFPnPrimDat::getFlag(int id) {
00232   return getData(id, "FLAG");
00233 }
00234 
00235 float LMFPnPrimDat::getMean(EcalLogicID &id) {
00236   return getData(id, "MEAN");
00237 }
00238 
00239 float LMFPnPrimDat::getShapeCor(EcalLogicID &id) {
00240   float x = 0.;
00241   if (getSystem() != "LED") {
00242     x = getData(id, "SHAPECORRPN");
00243   }
00244   return x;
00245 }
00246 
00247 float LMFPnPrimDat::getRMS(EcalLogicID &id) {
00248   return getData(id, "RMS");
00249 }
00250 
00251 float LMFPnPrimDat::getM3(EcalLogicID &id) {
00252   return getData(id, "M3");
00253 }
00254 
00255 float LMFPnPrimDat::getPNAoverBM3(EcalLogicID &id) {
00256   return getData(id, "PNABM3");
00257 }
00258 
00259 float LMFPnPrimDat::getPNAoverBMean(EcalLogicID &id) {
00260   return getData(id, "PNABMEAN");
00261 }
00262 
00263 float LMFPnPrimDat::getPNAoverBRMS(EcalLogicID &id) {
00264   return getData(id, "PNABRMS");
00265 }
00266 
00267 int LMFPnPrimDat::getFlag(EcalLogicID &id) {
00268   return getData(id, "FLAG");
00269 }
00270 
00271