Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:52:22

0001 
0002 /* 
0003  *  See header file for a description of this class.
0004  *
0005  *  \author D. Pagano - Dip. Fis. Nucl. e Teo. & INFN Pavia
0006  */
0007 
0008 #include "CondTools/RPC/interface/RPCFw.h"
0009 #include "RelationalAccess/ISession.h"
0010 #include "RelationalAccess/ITransaction.h"
0011 #include "RelationalAccess/ISchema.h"
0012 #include "RelationalAccess/ITable.h"
0013 #include "RelationalAccess/ITableDataEditor.h"
0014 #include "RelationalAccess/TableDescription.h"
0015 #include "RelationalAccess/IQuery.h"
0016 #include "RelationalAccess/ICursor.h"
0017 
0018 #include "CoralBase/AttributeList.h"
0019 #include "CoralBase/Attribute.h"
0020 #include "CoralBase/AttributeSpecification.h"
0021 #include <iostream>
0022 #include <stdexcept>
0023 #include <vector>
0024 #include <cmath>
0025 #include <iostream>
0026 #include <sstream>
0027 #include <ctime>
0028 #include "CondFormats/RPCObjects/interface/RPCObFebmap.h"
0029 
0030 RPCFw::RPCFw(const std::string& connectionString, const std::string& userName, const std::string& password)
0031     : RPCDBCom(), m_connectionString(connectionString), m_userName(userName), m_password(password) {}
0032 
0033 RPCFw::~RPCFw() {}
0034 
0035 void RPCFw::run() {}
0036 
0037 //----------------------------- I M O N ------------------------------------------------------------------------
0038 std::vector<RPCObImon::I_Item> RPCFw::createIMON(long long since, long long till) {
0039   tMIN = UTtoT(since);
0040   std::cout << ">> Processing since: " << tMIN.day() << "/" << tMIN.month() << "/" << tMIN.year() << " " << tMIN.hour()
0041             << ":" << tMIN.minute() << "." << tMIN.second() << std::endl;
0042 
0043   coral::ISession* session = this->connect(m_connectionString, m_userName, m_password);
0044   session->transaction().start(true);
0045   coral::ISchema& schema = session->nominalSchema();
0046   int nRows = 0;
0047   coral::IQuery* queryI = schema.newQuery();
0048   queryI->addToTableList("FWCAENCHANNEL");
0049   queryI->addToOutputList("FWCAENCHANNEL.DPID", "DPID");
0050   queryI->addToOutputList("FWCAENCHANNEL.CHANGE_DATE", "TSTAMP");
0051   queryI->addToOutputList("FWCAENCHANNEL.ACTUAL_IMON", "IMON");
0052 
0053   RPCObImon::I_Item Itemp;
0054   std::vector<RPCObImon::I_Item> imonarray;
0055   coral::TimeStamp tlast = tMIN;
0056   if (till > since) {
0057     tMAX = UTtoT(till);
0058     std::cout << ">> Processing till: " << tMAX.day() << "/" << tMAX.month() << "/" << tMAX.year() << " " << tMAX.hour()
0059               << ":" << tMAX.minute() << "." << tMAX.second() << std::endl;
0060     std::cout << ">> creating IMON object..." << std::endl;
0061     coral::AttributeList conditionData;
0062     conditionData.extend<coral::TimeStamp>("tmin");
0063     conditionData.extend<coral::TimeStamp>("tmax");
0064     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0065     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
0066     std::string condition = "FWCAENCHANNEL.ACTUAL_IMON IS NOT NULL AND CHANGE_DATE >:tmin AND CHANGE_DATE <:tmax";
0067     queryI->setCondition(condition, conditionData);
0068     coral::ICursor& cursorI = queryI->execute();
0069     while (cursorI.next()) {
0070       const coral::AttributeList& row = cursorI.currentRow();
0071       float idoub = row["DPID"].data<float>();
0072       int id = static_cast<int>(idoub);
0073       float val = row["IMON"].data<float>();
0074       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0075       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0076       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0077       Itemp.dpid = id;
0078       Itemp.value = val;
0079       Itemp.day = ndate;
0080       Itemp.time = ntime;
0081       imonarray.push_back(Itemp);
0082       ++nRows;
0083     }
0084   } else {
0085     std::cout << ">> creating IMON object..." << std::endl;
0086     coral::AttributeList conditionData;
0087     conditionData.extend<coral::TimeStamp>("tmin");
0088     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0089     std::string condition = "FWCAENCHANNEL.ACTUAL_IMON IS NOT NULL AND FWCAENCHANNEL.CHANGE_DATE >:tmin";
0090     queryI->setCondition(condition, conditionData);
0091     coral::ICursor& cursorI = queryI->execute();
0092     while (cursorI.next()) {
0093       const coral::AttributeList& row = cursorI.currentRow();
0094       float idoub = row["DPID"].data<float>();
0095       int id = static_cast<int>(idoub);
0096       float val = row["IMON"].data<float>();
0097       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0098       if (isMajor(ts, tlast))
0099         tlast = ts;
0100       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0101       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0102       Itemp.dpid = id;
0103       Itemp.value = val;
0104       Itemp.day = ndate;
0105       Itemp.time = ntime;
0106       imonarray.push_back(Itemp);
0107       ++nRows;
0108     }
0109   }
0110   N_IOV = TtoUT(tlast);
0111   if (till > since)
0112     N_IOV = till;
0113   std::cout << ">> Imon array --> size: " << imonarray.size() << " >> done." << std::endl;
0114   delete queryI;
0115   session->transaction().commit();
0116   delete session;
0117   return imonarray;
0118 }
0119 
0120 //------------------------------------------------------- V M O N ---------------------------------------------------
0121 std::vector<RPCObVmon::V_Item> RPCFw::createVMON(long long since, long long till) {
0122   tMIN = UTtoT(since);
0123   std::cout << ">> Processing since: " << tMIN.day() << "/" << tMIN.month() << "/" << tMIN.year() << " " << tMIN.hour()
0124             << ":" << tMIN.minute() << "." << tMIN.second() << std::endl;
0125 
0126   coral::ISession* session = this->connect(m_connectionString, m_userName, m_password);
0127   session->transaction().start(true);
0128   coral::ISchema& schema = session->nominalSchema();
0129   int nRows = 0;
0130   coral::IQuery* queryV = schema.newQuery();
0131   queryV->addToTableList("FWCAENCHANNEL");
0132   queryV->addToOutputList("FWCAENCHANNEL.DPID", "DPID");
0133   queryV->addToOutputList("FWCAENCHANNEL.CHANGE_DATE", "TSTAMP");
0134   queryV->addToOutputList("FWCAENCHANNEL.ACTUAL_VMON", "VMON");
0135   RPCObVmon::V_Item Vtemp;
0136   std::vector<RPCObVmon::V_Item> vmonarray;
0137   coral::TimeStamp tlast = tMIN;
0138   if (till > since) {
0139     tMAX = UTtoT(till);
0140     std::cout << ">> Processing till: " << tMAX.day() << "/" << tMAX.month() << "/" << tMAX.year() << " " << tMAX.hour()
0141               << ":" << tMAX.minute() << "." << tMAX.second() << std::endl;
0142     std::cout << ">> creating VMON object..." << std::endl;
0143     coral::AttributeList conditionData;
0144     conditionData.extend<coral::TimeStamp>("tmin");
0145     conditionData.extend<coral::TimeStamp>("tmax");
0146     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0147     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
0148     std::string condition =
0149         " NOT FWCAENCHANNEL.ACTUAL_VMON IS NULL AND FWCAENCHANNEL.CHANGE_DATE >:tmin AND FWCAENCHANNEL.CHANGE_DATE "
0150         "<:tmax";
0151     queryV->setCondition(condition, conditionData);
0152     coral::ICursor& cursorV = queryV->execute();
0153     while (cursorV.next()) {
0154       const coral::AttributeList& row = cursorV.currentRow();
0155       float idoub = row["DPID"].data<float>();
0156       int id = static_cast<int>(idoub);
0157       float val = row["VMON"].data<float>();
0158       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0159       if (isMajor(ts, tlast))
0160         tlast = ts;
0161       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0162       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0163       Vtemp.dpid = id;
0164       Vtemp.value = val;
0165       Vtemp.day = ndate;
0166       Vtemp.time = ntime;
0167       vmonarray.push_back(Vtemp);
0168       ++nRows;
0169     }
0170   } else {
0171     std::cout << ">> creating VMON object..." << std::endl;
0172     coral::AttributeList conditionData;
0173     conditionData.extend<coral::TimeStamp>("tmin");
0174     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0175     std::string condition = " NOT FWCAENCHANNEL.ACTUAL_VMON IS NULL AND FWCAENCHANNEL.CHANGE_DATE >:tmin";
0176     queryV->setCondition(condition, conditionData);
0177     coral::ICursor& cursorV = queryV->execute();
0178     while (cursorV.next()) {
0179       const coral::AttributeList& row = cursorV.currentRow();
0180       float idoub = row["DPID"].data<float>();
0181       int id = static_cast<int>(idoub);
0182       float val = row["VMON"].data<float>();
0183       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0184       if (isMajor(ts, tlast))
0185         tlast = ts;
0186       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0187       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0188       Vtemp.dpid = id;
0189       Vtemp.value = val;
0190       Vtemp.day = ndate;
0191       Vtemp.time = ntime;
0192       vmonarray.push_back(Vtemp);
0193       ++nRows;
0194     }
0195   }
0196 
0197   std::cout << ">> Vmon array --> size: " << vmonarray.size() << " >> done." << std::endl;
0198   delete queryV;
0199   session->transaction().commit();
0200   delete session;
0201   return vmonarray;
0202 }
0203 
0204 //------------------------------ S T A T U S ---------------------------------------------------------------------
0205 std::vector<RPCObStatus::S_Item> RPCFw::createSTATUS(long long since, long long till) {
0206   tMIN = UTtoT(since);
0207   std::cout << ">> Processing since: " << tMIN.day() << "/" << tMIN.month() << "/" << tMIN.year() << " " << tMIN.hour()
0208             << ":" << tMIN.minute() << "." << tMIN.second() << std::endl;
0209 
0210   coral::ISession* session = this->connect(m_connectionString, m_userName, m_password);
0211   session->transaction().start(true);
0212   coral::ISchema& schema = session->nominalSchema();
0213   int nRows = 0;
0214   std::cout << ">> creating STATUS object..." << std::endl;
0215   coral::IQuery* queryS = schema.newQuery();
0216   queryS->addToTableList("FWCAENCHANNEL");
0217   queryS->addToOutputList("FWCAENCHANNEL.DPID", "DPID");
0218   queryS->addToOutputList("FWCAENCHANNEL.CHANGE_DATE", "TSTAMP");
0219   queryS->addToOutputList("FWCAENCHANNEL.ACTUAL_STATUS", "STATUS");
0220   RPCObStatus::S_Item Stemp;
0221   std::vector<RPCObStatus::S_Item> statusarray;
0222   coral::TimeStamp tlast = tMIN;
0223   if (till > since) {
0224     tMAX = UTtoT(till);
0225     std::cout << ">> Processing till: " << tMAX.day() << "/" << tMAX.month() << "/" << tMAX.year() << " " << tMAX.hour()
0226               << ":" << tMAX.minute() << "." << tMAX.second() << std::endl;
0227     std::cout << ">> creating STATUS object..." << std::endl;
0228     coral::AttributeList conditionData;
0229     conditionData.extend<coral::TimeStamp>("tmin");
0230     conditionData.extend<coral::TimeStamp>("tmax");
0231     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0232     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
0233     std::string condition =
0234         " NOT FWCAENCHANNEL.ACTUAL_STATUS IS NULL AND FWCAENCHANNEL.CHANGE_DATE >:tmin AND FWCAENCHANNEL.CHANGE_DATE "
0235         "<:tmax";
0236     queryS->setCondition(condition, conditionData);
0237     coral::ICursor& cursorS = queryS->execute();
0238     while (cursorS.next()) {
0239       const coral::AttributeList& row = cursorS.currentRow();
0240       float idoub = row["DPID"].data<float>();
0241       int id = static_cast<int>(idoub);
0242       float val = row["STATUS"].data<float>();
0243       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0244       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0245       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0246       Stemp.dpid = id;
0247       Stemp.value = val;
0248       Stemp.day = ndate;
0249       Stemp.time = ntime;
0250       statusarray.push_back(Stemp);
0251       ++nRows;
0252     }
0253   } else {
0254     std::cout << ">> creating STATUS object..." << std::endl;
0255     coral::AttributeList conditionData;
0256     conditionData.extend<coral::TimeStamp>("tmin");
0257     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0258     std::string condition = " NOT FWCAENCHANNEL.ACTUAL_STATUS IS NULL AND FWCAENCHANNEL.CHANGE_DATE >:tmin";
0259     queryS->setCondition(condition, conditionData);
0260     coral::ICursor& cursorS = queryS->execute();
0261     while (cursorS.next()) {
0262       const coral::AttributeList& row = cursorS.currentRow();
0263       float idoub = row["DPID"].data<float>();
0264       int id = static_cast<int>(idoub);
0265       float val = row["STATUS"].data<float>();
0266       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0267       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0268       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0269       Stemp.dpid = id;
0270       Stemp.value = val;
0271       Stemp.day = ndate;
0272       Stemp.time = ntime;
0273       statusarray.push_back(Stemp);
0274       ++nRows;
0275     }
0276   }
0277   std::cout << ">> Staus array --> size: " << statusarray.size() << " >> done." << std::endl << std::endl << std::endl;
0278 
0279   delete queryS;
0280   session->transaction().commit();
0281   delete session;
0282 
0283   return statusarray;
0284 }
0285 
0286 //------------------------------ G A S ---------------------------------------------------------------------
0287 std::vector<RPCObGas::Item> RPCFw::createGAS(long long since, long long till) {
0288   tMIN = UTtoT(since);
0289   std::cout << ">> Processing since: " << tMIN.day() << "/" << tMIN.month() << "/" << tMIN.year() << " " << tMIN.hour()
0290             << ":" << tMIN.minute() << "." << tMIN.second() << std::endl;
0291 
0292   coral::ISession* session = this->connect(m_connectionString, m_userName, m_password);
0293   session->transaction().start(true);
0294   coral::ISchema& schema = session->nominalSchema();
0295 
0296   coral::TimeStamp tlast = tMIN;
0297 
0298   // FLOWIN
0299   coral::IQuery* querySIN = schema.newQuery();
0300   querySIN->addToTableList("RPCGASCHANNEL");
0301   querySIN->addToOutputList("RPCGASCHANNEL.DPID", "DPID");
0302   querySIN->addToOutputList("RPCGASCHANNEL.CHANGE_DATE", "TSTAMP");
0303   querySIN->addToOutputList("RPCGASCHANNEL.FLOWIN", "FLOWIN");
0304 
0305   // FLOWOUT
0306   coral::IQuery* querySOUT = schema.newQuery();
0307   querySOUT->addToTableList("RPCGASCHANNEL");
0308   querySOUT->addToOutputList("RPCGASCHANNEL.DPID", "DPID");
0309   querySOUT->addToOutputList("RPCGASCHANNEL.CHANGE_DATE", "TSTAMP");
0310   querySOUT->addToOutputList("RPCGASCHANNEL.FLOWOUT", "FLOWOUT");
0311 
0312   RPCObGas::Item gastemp;
0313   std::vector<RPCObGas::Item> gasarray;
0314 
0315   if (till > since) {
0316     tMAX = UTtoT(till);
0317     std::cout << ">> Processing till: " << tMAX.day() << "/" << tMAX.month() << "/" << tMAX.year() << " " << tMAX.hour()
0318               << ":" << tMAX.minute() << "." << tMAX.second() << std::endl;
0319     std::cout << ">> creating GAS object..." << std::endl;
0320     std::cout << ">> processing FLOWIN..." << std::endl;
0321     coral::AttributeList conditionData;
0322     conditionData.extend<coral::TimeStamp>("tmin");
0323     conditionData.extend<coral::TimeStamp>("tmax");
0324     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0325     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
0326     std::string conditionIN = "RPCGASCHANNEL.FLOWIN IS NOT NULL AND CHANGE_DATE >:tmin AND CHANGE_DATE <:tmax";
0327 
0328     querySIN->setCondition(conditionIN, conditionData);
0329     coral::ICursor& cursorSIN = querySIN->execute();
0330     while (cursorSIN.next()) {
0331       gastemp.dpid = 0;
0332       gastemp.flowin = 0;
0333       gastemp.flowout = 0;
0334       gastemp.day = 0;
0335       gastemp.time = 0;
0336       const coral::AttributeList& row = cursorSIN.currentRow();
0337       float idoub = row["DPID"].data<float>();
0338       int id = static_cast<int>(idoub);
0339       float val = row["FLOWIN"].data<float>();
0340       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0341       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0342       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0343       gastemp.dpid = id;
0344       gastemp.flowin = val;
0345       gastemp.day = ndate;
0346       gastemp.time = ntime;
0347       gasarray.push_back(gastemp);
0348     }
0349   } else {
0350     std::cout << ">> creating GAS object..." << std::endl;
0351     std::cout << ">> processing FLOWIN..." << std::endl;
0352     coral::AttributeList conditionData;
0353     conditionData.extend<coral::TimeStamp>("tmin");
0354     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0355     std::string conditionIN = "RPCGASCHANNEL.FLOWIN IS NOT NULL AND CHANGE_DATE >:tmin";
0356     std::cout << "processing FLOWIN..." << std::endl;
0357     querySIN->setCondition(conditionIN, conditionData);
0358     coral::ICursor& cursorSIN = querySIN->execute();
0359     while (cursorSIN.next()) {
0360       gastemp.dpid = 0;
0361       gastemp.flowin = 0;
0362       gastemp.flowout = 0;
0363       gastemp.day = 0;
0364       gastemp.time = 0;
0365       const coral::AttributeList& row = cursorSIN.currentRow();
0366       float idoub = row["DPID"].data<float>();
0367       int id = static_cast<int>(idoub);
0368       float val = row["FLOWIN"].data<float>();
0369       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0370       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0371       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0372       gastemp.dpid = id;
0373       gastemp.flowin = val;
0374       gastemp.day = ndate;
0375       gastemp.time = ntime;
0376       gasarray.push_back(gastemp);
0377     }
0378   }
0379 
0380   if (till > since) {
0381     tMAX = UTtoT(till);
0382     //    std::cout <<">> Processing till: "<<tMAX.day()<<"/"<<tMAX.month()<<"/"<<tMAX.year()<<" "<<tMAX.hour()<<":"<<tMAX.minute()<<"."<<tMAX.second()<< std::endl;
0383     std::cout << ">> processing FLOWOUT..." << std::endl;
0384     coral::AttributeList conditionData;
0385     conditionData.extend<coral::TimeStamp>("tmin");
0386     conditionData.extend<coral::TimeStamp>("tmax");
0387     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0388     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
0389     std::string conditionOUT = "RPCGASCHANNEL.FLOWOUT IS NOT NULL AND CHANGE_DATE >:tmin AND CHANGE_DATE <:tmax";
0390 
0391     querySOUT->setCondition(conditionOUT, conditionData);
0392     coral::ICursor& cursorSOUT = querySOUT->execute();
0393     while (cursorSOUT.next()) {
0394       gastemp.dpid = 0;
0395       gastemp.flowin = 0;
0396       gastemp.flowout = 0;
0397       gastemp.day = 0;
0398       gastemp.time = 0;
0399       const coral::AttributeList& row = cursorSOUT.currentRow();
0400       float idoub = row["DPID"].data<float>();
0401       int id = static_cast<int>(idoub);
0402       float val = row["FLOWOUT"].data<float>();
0403       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0404       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0405       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0406       gastemp.dpid = id;
0407       gastemp.flowout = val;
0408       gastemp.day = ndate;
0409       gastemp.time = ntime;
0410       gasarray.push_back(gastemp);
0411     }
0412   } else {
0413     std::cout << ">> processing FLOWOUT..." << std::endl;
0414     coral::AttributeList conditionData;
0415     conditionData.extend<coral::TimeStamp>("tmin");
0416     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0417     std::string conditionOUT = "RPCGASCHANNEL.FLOWOUT IS NOT NULL AND CHANGE_DATE >:tmin";
0418     querySOUT->setCondition(conditionOUT, conditionData);
0419     coral::ICursor& cursorSOUT = querySOUT->execute();
0420     while (cursorSOUT.next()) {
0421       gastemp.dpid = 0;
0422       gastemp.flowin = 0;
0423       gastemp.flowout = 0;
0424       gastemp.day = 0;
0425       gastemp.time = 0;
0426       const coral::AttributeList& row = cursorSOUT.currentRow();
0427       float idoub = row["DPID"].data<float>();
0428       int id = static_cast<int>(idoub);
0429       float val = row["FLOWOUT"].data<float>();
0430       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0431       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0432       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0433       gastemp.dpid = id;
0434       gastemp.flowout = val;
0435       gastemp.day = ndate;
0436       gastemp.time = ntime;
0437       gasarray.push_back(gastemp);
0438     }
0439   }
0440 
0441   N_IOV = TtoUT(tlast);
0442   if (till > since)
0443     N_IOV = till;
0444   std::cout << ">> Gas array --> size: " << gasarray.size() << " >> done." << std::endl << std::endl << std::endl;
0445 
0446   delete querySIN;
0447   delete querySOUT;
0448   session->transaction().commit();
0449   delete session;
0450 
0451   return gasarray;
0452 }
0453 
0454 //------------------------------ T E M P E R A T U R E ---------------------------------------------------------------------
0455 std::vector<RPCObTemp::T_Item> RPCFw::createT(long long since, long long till) {
0456   tMIN = UTtoT(since);
0457   std::cout << ">> Processing since: " << tMIN.day() << "/" << tMIN.month() << "/" << tMIN.year() << " " << tMIN.hour()
0458             << ":" << tMIN.minute() << "." << tMIN.second() << std::endl;
0459 
0460   coral::ISession* session = this->connect(m_connectionString, m_userName, m_password);
0461   session->transaction().start(true);
0462   coral::ISchema& schema = session->nominalSchema();
0463   int nRows = 0;
0464   coral::IQuery* queryS = schema.newQuery();
0465   queryS->addToTableList("FWCAENCHANNELADC");
0466   queryS->addToOutputList("FWCAENCHANNELADC.DPID", "DPID");
0467   queryS->addToOutputList("FWCAENCHANNELADC.CHANGE_DATE", "TSTAMP");
0468   queryS->addToOutputList("FWCAENCHANNELADC.ACTUAL_TEMPERATURE", "TEMPERATURE");
0469   RPCObTemp::T_Item Ttemp;
0470   std::vector<RPCObTemp::T_Item> temparray;
0471   coral::TimeStamp tlast = tMIN;
0472   if (till > since) {
0473     tMAX = UTtoT(till);
0474     std::cout << ">> Processing till: " << tMAX.day() << "/" << tMAX.month() << "/" << tMAX.year() << " " << tMAX.hour()
0475               << ":" << tMAX.minute() << "." << tMAX.second() << std::endl;
0476     std::cout << ">> creating TEMPERATURE object..." << std::endl;
0477     coral::AttributeList conditionData;
0478     conditionData.extend<coral::TimeStamp>("tmin");
0479     conditionData.extend<coral::TimeStamp>("tmax");
0480     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0481     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
0482     std::string condition =
0483         "FWCAENCHANNELADC.ACTUAL_TEMPERATURE IS NOT NULL AND CHANGE_DATE >:tmin AND CHANGE_DATE <:tmax";
0484     queryS->setCondition(condition, conditionData);
0485     coral::ICursor& cursorS = queryS->execute();
0486     while (cursorS.next()) {
0487       const coral::AttributeList& row = cursorS.currentRow();
0488       float idoub = row["DPID"].data<float>();
0489       int id = static_cast<int>(idoub);
0490       float val = row["TEMPERATURE"].data<float>();
0491       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0492       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0493       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0494 
0495       Ttemp.dpid = id;
0496       Ttemp.value = val;
0497       Ttemp.day = ndate;
0498       Ttemp.time = ntime;
0499       temparray.push_back(Ttemp);
0500 
0501       ++nRows;
0502     }
0503   } else {
0504     std::cout << ">> creating TEMPERATURE object..." << std::endl;
0505     coral::AttributeList conditionData;
0506     conditionData.extend<coral::TimeStamp>("tmin");
0507     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0508     std::string condition = "FWCAENCHANNELADC.ACTUAL_TEMPERATURE IS NOT NULL AND CHANGE_DATE >:tmin";
0509     queryS->setCondition(condition, conditionData);
0510     coral::ICursor& cursorS = queryS->execute();
0511     while (cursorS.next()) {
0512       const coral::AttributeList& row = cursorS.currentRow();
0513       float idoub = row["DPID"].data<float>();
0514       int id = static_cast<int>(idoub);
0515       float val = row["TEMPERATURE"].data<float>();
0516       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0517       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0518       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0519 
0520       Ttemp.dpid = id;
0521       Ttemp.value = val;
0522       Ttemp.day = ndate;
0523       Ttemp.time = ntime;
0524       temparray.push_back(Ttemp);
0525 
0526       ++nRows;
0527     }
0528   }
0529   N_IOV = TtoUT(tlast);
0530   if (till > since)
0531     N_IOV = till;
0532   std::cout << ">> Temperature array --> size: " << temparray.size() << " >> done." << std::endl
0533             << std::endl
0534             << std::endl;
0535 
0536   delete queryS;
0537   session->transaction().commit();
0538   delete session;
0539 
0540   return temparray;
0541 }
0542 
0543 //----------------------------- I D   M A P ------------------------------------------------------------------------
0544 std::vector<RPCObPVSSmap::Item> RPCFw::createIDMAP() {
0545   //  float tMINi = 0;
0546   std::cout << ">> Processing data..." << std::endl;
0547 
0548   coral::ISession* session = this->connect(m_connectionString, m_userName, m_password);
0549   session->transaction().start(true);
0550   coral::ISchema& schema = session->nominalSchema();
0551   int nRows = 0;
0552   std::cout << ">> creating IDMAP object..." << std::endl;
0553   coral::IQuery* queryM = schema.newQuery();
0554   queryM->addToTableList("RPCPVSSDETID");
0555   queryM->addToOutputList("RPCPVSSDETID.SINCE", "SINCE");
0556   queryM->addToOutputList("RPCPVSSDETID.PVSS_ID", "PVSS_ID");
0557   queryM->addToOutputList("RPCPVSSDETID.REGION", "REGION");
0558   queryM->addToOutputList("RPCPVSSDETID.RING", "RING");
0559   queryM->addToOutputList("RPCPVSSDETID.STATION", "STATION");
0560   queryM->addToOutputList("RPCPVSSDETID.SECTOR", "SECTOR");
0561   queryM->addToOutputList("RPCPVSSDETID.LAYER", "LAYER");
0562   queryM->addToOutputList("RPCPVSSDETID.SUBSECTOR", "SUBSECTOR");
0563   queryM->addToOutputList("RPCPVSSDETID.SUPPLYTYPE", "SUPPLYTYPE");
0564 
0565   std::string condM = "RPCPVSSDETID.PVSS_ID is not NULL";
0566 
0567   //  queryM->setCondition(condM);
0568   coral::ICursor& cursorM = queryM->execute();
0569 
0570   RPCObPVSSmap::Item Itemp;
0571   std::vector<RPCObPVSSmap::Item> idmaparray;
0572   while (cursorM.next()) {
0573     const coral::AttributeList& row = cursorM.currentRow();
0574     int id = row["PVSS_ID"].data<int>();
0575     std::string reg_s = row["REGION"].data<std::string>();
0576     std::string rin_s = row["RING"].data<std::string>();
0577     std::string sta_s = row["STATION"].data<std::string>();
0578     std::string sec_s = row["SECTOR"].data<std::string>();
0579     std::string lay_s = row["LAYER"].data<std::string>();
0580     std::string sub_s = row["SUBSECTOR"].data<std::string>();
0581     std::string sup_s = row["SUPPLYTYPE"].data<std::string>();
0582 
0583     int reg = atoi(reg_s.c_str());
0584     int rin = atoi(rin_s.c_str());
0585     int sta = atoi(sta_s.c_str());
0586     int sec = atoi(sec_s.c_str());
0587     int lay = atoi(lay_s.c_str());
0588     int sub = atoi(sub_s.c_str());
0589     int sup = 5;
0590 
0591     if (sup_s == "HV")
0592       sup = 0;
0593     if (sup_s == "LVA")
0594       sup = 1;
0595     if (sup_s == "LVD")
0596       sup = 2;
0597     if (sup_s == "LB")
0598       sup = 3;
0599     if (sup_s == "T")
0600       sup = 4;
0601 
0602     coral::TimeStamp ts = row["SINCE"].data<coral::TimeStamp>();
0603 
0604     std::ostringstream dday;
0605     std::ostringstream dmon;
0606     std::ostringstream dyea;
0607     dday << ts.day();
0608     dmon << ts.month();
0609     dyea << ts.year();
0610     std::string date = dday.str() + "-" + dmon.str() + "-" + dyea.str();
0611 
0612     Itemp.since = atoi(date.c_str());
0613     Itemp.dpid = id;
0614     Itemp.region = reg;
0615     Itemp.ring = rin;
0616     Itemp.station = sta;
0617     Itemp.sector = sec;
0618     Itemp.layer = lay;
0619     Itemp.subsector = sub;
0620     Itemp.suptype = sup;
0621 
0622     idmaparray.push_back(Itemp);
0623 
0624     ++nRows;
0625   }
0626 
0627   std::cout << ">> IDMAP array --> size: " << idmaparray.size() << " >> done." << std::endl;
0628   delete queryM;
0629   session->transaction().commit();
0630   delete session;
0631   return idmaparray;
0632 }
0633 
0634 //----------------------------- F E B ------------------------------------------------------------------------
0635 std::vector<RPCObFebmap::Feb_Item> RPCFw::createFEB(long long since, long long till) {
0636   tMIN = UTtoT(since);
0637   std::cout << ">> Processing since: " << tMIN.day() << "/" << tMIN.month() << "/" << tMIN.year() << " " << tMIN.hour()
0638             << ":" << tMIN.minute() << "." << tMIN.second() << std::endl;
0639 
0640   coral::ISession* session = this->connect(m_connectionString, m_userName, m_password);
0641   session->transaction().start(true);
0642   coral::ISchema& schema = session->nominalSchema();
0643   std::cout << ">> creating FEB object..." << std::endl;
0644 
0645   // VTH1
0646   coral::IQuery* queryFVTH1 = schema.newQuery();
0647   queryFVTH1->addToTableList("RPCFEB");
0648   queryFVTH1->addToOutputList("RPCFEB.DPID", "DPID");
0649   queryFVTH1->addToOutputList("RPCFEB.CHANGE_DATE", "TSTAMP");
0650   queryFVTH1->addToOutputList("RPCFEB.VTH1", "VTH1");
0651 
0652   // VTH2
0653   coral::IQuery* queryFVTH2 = schema.newQuery();
0654   queryFVTH2->addToTableList("RPCFEB");
0655   queryFVTH2->addToOutputList("RPCFEB.DPID", "DPID");
0656   queryFVTH2->addToOutputList("RPCFEB.CHANGE_DATE", "TSTAMP");
0657   queryFVTH2->addToOutputList("RPCFEB.VTH2", "VTH2");
0658 
0659   // VTH3
0660   coral::IQuery* queryFVTH3 = schema.newQuery();
0661   queryFVTH3->addToTableList("RPCFEB");
0662   queryFVTH3->addToOutputList("RPCFEB.DPID", "DPID");
0663   queryFVTH3->addToOutputList("RPCFEB.CHANGE_DATE", "TSTAMP");
0664   queryFVTH3->addToOutputList("RPCFEB.VTH3", "VTH3");
0665 
0666   // VTH4
0667   coral::IQuery* queryFVTH4 = schema.newQuery();
0668   queryFVTH4->addToTableList("RPCFEB");
0669   queryFVTH4->addToOutputList("RPCFEB.DPID", "DPID");
0670   queryFVTH4->addToOutputList("RPCFEB.CHANGE_DATE", "TSTAMP");
0671   queryFVTH4->addToOutputList("RPCFEB.VTH4", "VTH4");
0672 
0673   // VMON1
0674   coral::IQuery* queryFVMON1 = schema.newQuery();
0675   queryFVMON1->addToTableList("RPCFEB");
0676   queryFVMON1->addToOutputList("RPCFEB.DPID", "DPID");
0677   queryFVMON1->addToOutputList("RPCFEB.CHANGE_DATE", "TSTAMP");
0678   queryFVMON1->addToOutputList("RPCFEB.VMON1", "VMON1");
0679 
0680   // VMON2
0681   coral::IQuery* queryFVMON2 = schema.newQuery();
0682   queryFVMON2->addToTableList("RPCFEB");
0683   queryFVMON2->addToOutputList("RPCFEB.DPID", "DPID");
0684   queryFVMON2->addToOutputList("RPCFEB.CHANGE_DATE", "TSTAMP");
0685   queryFVMON2->addToOutputList("RPCFEB.VMON2", "VMON2");
0686 
0687   // VMON3
0688   coral::IQuery* queryFVMON3 = schema.newQuery();
0689   queryFVMON3->addToTableList("RPCFEB");
0690   queryFVMON3->addToOutputList("RPCFEB.DPID", "DPID");
0691   queryFVMON3->addToOutputList("RPCFEB.CHANGE_DATE", "TSTAMP");
0692   queryFVMON3->addToOutputList("RPCFEB.VMON3", "VMON3");
0693 
0694   // VMON4
0695   coral::IQuery* queryFVMON4 = schema.newQuery();
0696   queryFVMON4->addToTableList("RPCFEB");
0697   queryFVMON4->addToOutputList("RPCFEB.DPID", "DPID");
0698   queryFVMON4->addToOutputList("RPCFEB.CHANGE_DATE", "TSTAMP");
0699   queryFVMON4->addToOutputList("RPCFEB.VMON4", "VMON4");
0700 
0701   // TEMP1
0702   coral::IQuery* queryFTEMP1 = schema.newQuery();
0703   queryFTEMP1->addToTableList("RPCFEB");
0704   queryFTEMP1->addToOutputList("RPCFEB.DPID", "DPID");
0705   queryFTEMP1->addToOutputList("RPCFEB.CHANGE_DATE", "TSTAMP");
0706   queryFTEMP1->addToOutputList("RPCFEB.TEMPERATURE1", "TEMP1");
0707 
0708   // TEMP2
0709   coral::IQuery* queryFTEMP2 = schema.newQuery();
0710   queryFTEMP2->addToTableList("RPCFEB");
0711   queryFTEMP2->addToOutputList("RPCFEB.DPID", "DPID");
0712   queryFTEMP2->addToOutputList("RPCFEB.CHANGE_DATE", "TSTAMP");
0713   queryFTEMP2->addToOutputList("RPCFEB.TEMPERATURE2", "TEMP2");
0714 
0715   RPCObFebmap::Feb_Item Itemp;
0716   std::vector<RPCObFebmap::Feb_Item> febarray;
0717   coral::TimeStamp tlast = tMIN;
0718   if (till > since) {
0719     tMAX = UTtoT(till);
0720     std::cout << ">> Processing till: " << tMAX.day() << "/" << tMAX.month() << "/" << tMAX.year() << " " << tMAX.hour()
0721               << ":" << tMAX.minute() << "." << tMAX.second() << std::endl;
0722     std::cout << "Processing VTH1..." << std::endl;
0723     coral::AttributeList conditionData;
0724     conditionData.extend<coral::TimeStamp>("tmin");
0725     conditionData.extend<coral::TimeStamp>("tmax");
0726     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0727     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
0728     std::string conditionVTH1 = "RPCFEB.VTH1 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
0729     queryFVTH1->setCondition(conditionVTH1, conditionData);
0730     coral::ICursor& cursorFVTH1 = queryFVTH1->execute();
0731     while (cursorFVTH1.next()) {
0732       Itemp.thr1 = 0;
0733       Itemp.thr2 = 0;
0734       Itemp.thr3 = 0;
0735       Itemp.thr4 = 0;
0736       Itemp.vmon1 = 0;
0737       Itemp.vmon2 = 0;
0738       Itemp.vmon3 = 0;
0739       Itemp.vmon4 = 0;
0740       Itemp.temp1 = 0;
0741       Itemp.temp2 = 0;
0742       Itemp.noise1 = 0;
0743       Itemp.noise2 = 0;
0744       Itemp.noise3 = 0;
0745       Itemp.noise4 = 0;
0746       const coral::AttributeList& row = cursorFVTH1.currentRow();
0747       float idoub = row["DPID"].data<float>();
0748       int id = static_cast<int>(idoub);
0749       float vth1 = row["VTH1"].data<float>();
0750       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0751       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0752       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0753       Itemp.dpid = id;
0754       Itemp.thr1 = vth1;
0755       Itemp.day = ndate;
0756       Itemp.time = ntime;
0757       febarray.push_back(Itemp);
0758     }
0759   } else {
0760     std::cout << ">> Processing VTH1..." << std::endl;
0761     coral::AttributeList conditionData;
0762     conditionData.extend<coral::TimeStamp>("tmin");
0763     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0764     std::string conditionVTH1 = "RPCFEB.VTH1 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
0765     queryFVTH1->setCondition(conditionVTH1, conditionData);
0766     coral::ICursor& cursorFVTH1 = queryFVTH1->execute();
0767     while (cursorFVTH1.next()) {
0768       Itemp.thr1 = 0;
0769       Itemp.thr2 = 0;
0770       Itemp.thr3 = 0;
0771       Itemp.thr4 = 0;
0772       Itemp.vmon1 = 0;
0773       Itemp.vmon2 = 0;
0774       Itemp.vmon3 = 0;
0775       Itemp.vmon4 = 0;
0776       Itemp.temp1 = 0;
0777       Itemp.temp2 = 0;
0778       Itemp.noise1 = 0;
0779       Itemp.noise2 = 0;
0780       Itemp.noise3 = 0;
0781       Itemp.noise4 = 0;
0782       const coral::AttributeList& row = cursorFVTH1.currentRow();
0783       float idoub = row["DPID"].data<float>();
0784       int id = static_cast<int>(idoub);
0785       float vth1 = row["VTH1"].data<float>();
0786       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0787       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0788       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0789       Itemp.dpid = id;
0790       Itemp.thr1 = vth1;
0791       Itemp.day = ndate;
0792       Itemp.time = ntime;
0793       febarray.push_back(Itemp);
0794     }
0795   }
0796 
0797   if (till > since) {
0798     tMAX = UTtoT(till);
0799     std::cout << "Processing VTH2..." << std::endl;
0800     coral::AttributeList conditionData;
0801     conditionData.extend<coral::TimeStamp>("tmin");
0802     conditionData.extend<coral::TimeStamp>("tmax");
0803     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0804     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
0805     std::string conditionVTH2 = "RPCFEB.VTH2 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
0806     queryFVTH2->setCondition(conditionVTH2, conditionData);
0807     coral::ICursor& cursorFVTH2 = queryFVTH2->execute();
0808     while (cursorFVTH2.next()) {
0809       Itemp.thr1 = 0;
0810       Itemp.thr2 = 0;
0811       Itemp.thr3 = 0;
0812       Itemp.thr4 = 0;
0813       Itemp.vmon1 = 0;
0814       Itemp.vmon2 = 0;
0815       Itemp.vmon3 = 0;
0816       Itemp.vmon4 = 0;
0817       Itemp.temp1 = 0;
0818       Itemp.temp2 = 0;
0819       Itemp.noise1 = 0;
0820       Itemp.noise2 = 0;
0821       Itemp.noise3 = 0;
0822       Itemp.noise4 = 0;
0823       const coral::AttributeList& row = cursorFVTH2.currentRow();
0824       float idoub = row["DPID"].data<float>();
0825       int id = static_cast<int>(idoub);
0826       float vth2 = row["VTH2"].data<float>();
0827       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0828       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0829       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0830       Itemp.dpid = id;
0831       Itemp.thr2 = vth2;
0832       Itemp.day = ndate;
0833       Itemp.time = ntime;
0834       febarray.push_back(Itemp);
0835     }
0836   } else {
0837     std::cout << ">> Processing VTH2..." << std::endl;
0838     coral::AttributeList conditionData;
0839     conditionData.extend<coral::TimeStamp>("tmin");
0840     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0841     std::string conditionVTH2 = "RPCFEB.VTH2 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
0842     queryFVTH2->setCondition(conditionVTH2, conditionData);
0843     coral::ICursor& cursorFVTH2 = queryFVTH2->execute();
0844     while (cursorFVTH2.next()) {
0845       Itemp.thr1 = 0;
0846       Itemp.thr2 = 0;
0847       Itemp.thr3 = 0;
0848       Itemp.thr4 = 0;
0849       Itemp.vmon1 = 0;
0850       Itemp.vmon2 = 0;
0851       Itemp.vmon3 = 0;
0852       Itemp.vmon4 = 0;
0853       Itemp.temp1 = 0;
0854       Itemp.temp2 = 0;
0855       Itemp.noise1 = 0;
0856       Itemp.noise2 = 0;
0857       Itemp.noise3 = 0;
0858       Itemp.noise4 = 0;
0859       const coral::AttributeList& row = cursorFVTH2.currentRow();
0860       float idoub = row["DPID"].data<float>();
0861       int id = static_cast<int>(idoub);
0862       float vth2 = row["VTH2"].data<float>();
0863       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0864       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0865       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0866       Itemp.dpid = id;
0867       Itemp.thr2 = vth2;
0868       Itemp.day = ndate;
0869       Itemp.time = ntime;
0870       febarray.push_back(Itemp);
0871     }
0872   }
0873 
0874   if (till > since) {
0875     tMAX = UTtoT(till);
0876     std::cout << "Processing VTH3..." << std::endl;
0877     coral::AttributeList conditionData;
0878     conditionData.extend<coral::TimeStamp>("tmin");
0879     conditionData.extend<coral::TimeStamp>("tmax");
0880     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0881     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
0882     std::string conditionVTH3 = "RPCFEB.VTH3 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
0883     queryFVTH3->setCondition(conditionVTH3, conditionData);
0884     coral::ICursor& cursorFVTH3 = queryFVTH3->execute();
0885     while (cursorFVTH3.next()) {
0886       Itemp.thr1 = 0;
0887       Itemp.thr2 = 0;
0888       Itemp.thr3 = 0;
0889       Itemp.thr4 = 0;
0890       Itemp.vmon1 = 0;
0891       Itemp.vmon2 = 0;
0892       Itemp.vmon3 = 0;
0893       Itemp.vmon4 = 0;
0894       Itemp.temp1 = 0;
0895       Itemp.temp2 = 0;
0896       Itemp.noise1 = 0;
0897       Itemp.noise2 = 0;
0898       Itemp.noise3 = 0;
0899       Itemp.noise4 = 0;
0900       const coral::AttributeList& row = cursorFVTH3.currentRow();
0901       float idoub = row["DPID"].data<float>();
0902       int id = static_cast<int>(idoub);
0903       float vth3 = row["VTH3"].data<float>();
0904       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0905       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0906       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0907       Itemp.dpid = id;
0908       Itemp.thr3 = vth3;
0909       Itemp.day = ndate;
0910       Itemp.time = ntime;
0911       febarray.push_back(Itemp);
0912     }
0913   } else {
0914     std::cout << ">> Processing VTH3..." << std::endl;
0915     coral::AttributeList conditionData;
0916     conditionData.extend<coral::TimeStamp>("tmin");
0917     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0918     std::string conditionVTH3 = "RPCFEB.VTH3 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
0919     queryFVTH3->setCondition(conditionVTH3, conditionData);
0920     coral::ICursor& cursorFVTH3 = queryFVTH3->execute();
0921     while (cursorFVTH3.next()) {
0922       Itemp.thr1 = 0;
0923       Itemp.thr2 = 0;
0924       Itemp.thr3 = 0;
0925       Itemp.thr4 = 0;
0926       Itemp.vmon1 = 0;
0927       Itemp.vmon2 = 0;
0928       Itemp.vmon3 = 0;
0929       Itemp.vmon4 = 0;
0930       Itemp.temp1 = 0;
0931       Itemp.temp2 = 0;
0932       Itemp.noise1 = 0;
0933       Itemp.noise2 = 0;
0934       Itemp.noise3 = 0;
0935       Itemp.noise4 = 0;
0936       const coral::AttributeList& row = cursorFVTH3.currentRow();
0937       float idoub = row["DPID"].data<float>();
0938       int id = static_cast<int>(idoub);
0939       float vth3 = row["VTH3"].data<float>();
0940       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0941       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0942       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0943       Itemp.dpid = id;
0944       Itemp.thr3 = vth3;
0945       Itemp.day = ndate;
0946       Itemp.time = ntime;
0947       febarray.push_back(Itemp);
0948     }
0949   }
0950 
0951   if (till > since) {
0952     tMAX = UTtoT(till);
0953     std::cout << "Processing VTH4..." << std::endl;
0954     coral::AttributeList conditionData;
0955     conditionData.extend<coral::TimeStamp>("tmin");
0956     conditionData.extend<coral::TimeStamp>("tmax");
0957     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0958     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
0959     std::string conditionVTH4 = "RPCFEB.VTH4 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
0960     queryFVTH4->setCondition(conditionVTH4, conditionData);
0961     coral::ICursor& cursorFVTH4 = queryFVTH4->execute();
0962     while (cursorFVTH4.next()) {
0963       Itemp.thr1 = 0;
0964       Itemp.thr2 = 0;
0965       Itemp.thr3 = 0;
0966       Itemp.thr4 = 0;
0967       Itemp.vmon1 = 0;
0968       Itemp.vmon2 = 0;
0969       Itemp.vmon3 = 0;
0970       Itemp.vmon4 = 0;
0971       Itemp.temp1 = 0;
0972       Itemp.temp2 = 0;
0973       Itemp.noise1 = 0;
0974       Itemp.noise2 = 0;
0975       Itemp.noise3 = 0;
0976       Itemp.noise4 = 0;
0977       const coral::AttributeList& row = cursorFVTH4.currentRow();
0978       float idoub = row["DPID"].data<float>();
0979       int id = static_cast<int>(idoub);
0980       float vth4 = row["VTH4"].data<float>();
0981       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
0982       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
0983       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
0984       Itemp.dpid = id;
0985       Itemp.thr4 = vth4;
0986       Itemp.day = ndate;
0987       Itemp.time = ntime;
0988       febarray.push_back(Itemp);
0989     }
0990   } else {
0991     std::cout << ">> Processing VTH4..." << std::endl;
0992     coral::AttributeList conditionData;
0993     conditionData.extend<coral::TimeStamp>("tmin");
0994     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
0995     std::string conditionVTH4 = "RPCFEB.VTH4 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
0996     queryFVTH4->setCondition(conditionVTH4, conditionData);
0997     coral::ICursor& cursorFVTH4 = queryFVTH4->execute();
0998     while (cursorFVTH4.next()) {
0999       Itemp.thr1 = 0;
1000       Itemp.thr2 = 0;
1001       Itemp.thr3 = 0;
1002       Itemp.thr4 = 0;
1003       Itemp.vmon1 = 0;
1004       Itemp.vmon2 = 0;
1005       Itemp.vmon3 = 0;
1006       Itemp.vmon4 = 0;
1007       Itemp.temp1 = 0;
1008       Itemp.temp2 = 0;
1009       Itemp.noise1 = 0;
1010       Itemp.noise2 = 0;
1011       Itemp.noise3 = 0;
1012       Itemp.noise4 = 0;
1013       const coral::AttributeList& row = cursorFVTH4.currentRow();
1014       float idoub = row["DPID"].data<float>();
1015       int id = static_cast<int>(idoub);
1016       float vth4 = row["VTH4"].data<float>();
1017       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1018       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
1019       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
1020       Itemp.dpid = id;
1021       Itemp.thr4 = vth4;
1022       Itemp.day = ndate;
1023       Itemp.time = ntime;
1024       febarray.push_back(Itemp);
1025     }
1026   }
1027 
1028   if (till > since) {
1029     tMAX = UTtoT(till);
1030     std::cout << "Processing VMON1..." << std::endl;
1031     coral::AttributeList conditionData;
1032     conditionData.extend<coral::TimeStamp>("tmin");
1033     conditionData.extend<coral::TimeStamp>("tmax");
1034     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
1035     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
1036     std::string conditionVMON1 = "RPCFEB.VMON1 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
1037     queryFVMON1->setCondition(conditionVMON1, conditionData);
1038     coral::ICursor& cursorFVMON1 = queryFVMON1->execute();
1039     while (cursorFVMON1.next()) {
1040       Itemp.thr1 = 0;
1041       Itemp.thr2 = 0;
1042       Itemp.thr3 = 0;
1043       Itemp.thr4 = 0;
1044       Itemp.vmon1 = 0;
1045       Itemp.vmon2 = 0;
1046       Itemp.vmon3 = 0;
1047       Itemp.vmon4 = 0;
1048       Itemp.temp1 = 0;
1049       Itemp.temp2 = 0;
1050       Itemp.noise1 = 0;
1051       Itemp.noise2 = 0;
1052       Itemp.noise3 = 0;
1053       Itemp.noise4 = 0;
1054       const coral::AttributeList& row = cursorFVMON1.currentRow();
1055       float idoub = row["DPID"].data<float>();
1056       int id = static_cast<int>(idoub);
1057       float vmon1 = row["VMON1"].data<float>();
1058       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1059       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
1060       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
1061       Itemp.dpid = id;
1062       Itemp.vmon1 = vmon1;
1063       Itemp.day = ndate;
1064       Itemp.time = ntime;
1065       febarray.push_back(Itemp);
1066     }
1067   } else {
1068     std::cout << ">> Processing VMON1..." << std::endl;
1069     coral::AttributeList conditionData;
1070     conditionData.extend<coral::TimeStamp>("tmin");
1071     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
1072     std::string conditionVMON1 = "RPCFEB.VMON1 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
1073     queryFVMON1->setCondition(conditionVMON1, conditionData);
1074     coral::ICursor& cursorFVMON1 = queryFVMON1->execute();
1075     while (cursorFVMON1.next()) {
1076       Itemp.thr1 = 0;
1077       Itemp.thr2 = 0;
1078       Itemp.thr3 = 0;
1079       Itemp.thr4 = 0;
1080       Itemp.vmon1 = 0;
1081       Itemp.vmon2 = 0;
1082       Itemp.vmon3 = 0;
1083       Itemp.vmon4 = 0;
1084       Itemp.temp1 = 0;
1085       Itemp.temp2 = 0;
1086       Itemp.noise1 = 0;
1087       Itemp.noise2 = 0;
1088       Itemp.noise3 = 0;
1089       Itemp.noise4 = 0;
1090       const coral::AttributeList& row = cursorFVMON1.currentRow();
1091       float idoub = row["DPID"].data<float>();
1092       int id = static_cast<int>(idoub);
1093       float vmon1 = row["VMON1"].data<float>();
1094       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1095       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
1096       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
1097       Itemp.dpid = id;
1098       Itemp.vmon1 = vmon1;
1099       Itemp.day = ndate;
1100       Itemp.time = ntime;
1101       febarray.push_back(Itemp);
1102     }
1103   }
1104 
1105   if (till > since) {
1106     tMAX = UTtoT(till);
1107     std::cout << "Processing VMON2..." << std::endl;
1108     coral::AttributeList conditionData;
1109     conditionData.extend<coral::TimeStamp>("tmin");
1110     conditionData.extend<coral::TimeStamp>("tmax");
1111     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
1112     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
1113     std::string conditionVMON2 = "RPCFEB.VMON2 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
1114     queryFVMON2->setCondition(conditionVMON2, conditionData);
1115     coral::ICursor& cursorFVMON2 = queryFVMON2->execute();
1116     while (cursorFVMON2.next()) {
1117       Itemp.thr1 = 0;
1118       Itemp.thr2 = 0;
1119       Itemp.thr3 = 0;
1120       Itemp.thr4 = 0;
1121       Itemp.vmon1 = 0;
1122       Itemp.vmon2 = 0;
1123       Itemp.vmon3 = 0;
1124       Itemp.vmon4 = 0;
1125       Itemp.temp1 = 0;
1126       Itemp.temp2 = 0;
1127       Itemp.noise1 = 0;
1128       Itemp.noise2 = 0;
1129       Itemp.noise3 = 0;
1130       Itemp.noise4 = 0;
1131       const coral::AttributeList& row = cursorFVMON2.currentRow();
1132       float idoub = row["DPID"].data<float>();
1133       int id = static_cast<int>(idoub);
1134       float vmon2 = row["VMON2"].data<float>();
1135       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1136       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
1137       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
1138       Itemp.dpid = id;
1139       Itemp.vmon2 = vmon2;
1140       Itemp.day = ndate;
1141       Itemp.time = ntime;
1142       febarray.push_back(Itemp);
1143     }
1144   } else {
1145     std::cout << ">> Processing VMON2..." << std::endl;
1146     coral::AttributeList conditionData;
1147     conditionData.extend<coral::TimeStamp>("tmin");
1148     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
1149     std::string conditionVMON2 = "RPCFEB.VMON2 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
1150     queryFVMON2->setCondition(conditionVMON2, conditionData);
1151     coral::ICursor& cursorFVMON2 = queryFVMON2->execute();
1152     while (cursorFVMON2.next()) {
1153       Itemp.thr1 = 0;
1154       Itemp.thr2 = 0;
1155       Itemp.thr3 = 0;
1156       Itemp.thr4 = 0;
1157       Itemp.vmon1 = 0;
1158       Itemp.vmon2 = 0;
1159       Itemp.vmon3 = 0;
1160       Itemp.vmon4 = 0;
1161       Itemp.temp1 = 0;
1162       Itemp.temp2 = 0;
1163       Itemp.noise1 = 0;
1164       Itemp.noise2 = 0;
1165       Itemp.noise3 = 0;
1166       Itemp.noise4 = 0;
1167       const coral::AttributeList& row = cursorFVMON2.currentRow();
1168       float idoub = row["DPID"].data<float>();
1169       int id = static_cast<int>(idoub);
1170       float vmon2 = row["VMON2"].data<float>();
1171       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1172       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
1173       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
1174       Itemp.dpid = id;
1175       Itemp.vmon2 = vmon2;
1176       Itemp.day = ndate;
1177       Itemp.time = ntime;
1178       febarray.push_back(Itemp);
1179     }
1180   }
1181 
1182   if (till > since) {
1183     tMAX = UTtoT(till);
1184     std::cout << "Processing VMON3..." << std::endl;
1185     coral::AttributeList conditionData;
1186     conditionData.extend<coral::TimeStamp>("tmin");
1187     conditionData.extend<coral::TimeStamp>("tmax");
1188     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
1189     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
1190     std::string conditionVMON3 = "RPCFEB.VMON3 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
1191     queryFVMON3->setCondition(conditionVMON3, conditionData);
1192     coral::ICursor& cursorFVMON3 = queryFVMON3->execute();
1193     while (cursorFVMON3.next()) {
1194       Itemp.thr1 = 0;
1195       Itemp.thr2 = 0;
1196       Itemp.thr3 = 0;
1197       Itemp.thr4 = 0;
1198       Itemp.vmon1 = 0;
1199       Itemp.vmon2 = 0;
1200       Itemp.vmon3 = 0;
1201       Itemp.vmon4 = 0;
1202       Itemp.temp1 = 0;
1203       Itemp.temp2 = 0;
1204       Itemp.noise1 = 0;
1205       Itemp.noise2 = 0;
1206       Itemp.noise3 = 0;
1207       Itemp.noise4 = 0;
1208       const coral::AttributeList& row = cursorFVMON3.currentRow();
1209       float idoub = row["DPID"].data<float>();
1210       int id = static_cast<int>(idoub);
1211       float vmon3 = row["VMON3"].data<float>();
1212       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1213       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
1214       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
1215       Itemp.dpid = id;
1216       Itemp.vmon3 = vmon3;
1217       Itemp.day = ndate;
1218       Itemp.time = ntime;
1219       febarray.push_back(Itemp);
1220     }
1221   } else {
1222     std::cout << ">> Processing VMON3..." << std::endl;
1223     coral::AttributeList conditionData;
1224     conditionData.extend<coral::TimeStamp>("tmin");
1225     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
1226     std::string conditionVMON3 = "RPCFEB.VMON3 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
1227     queryFVMON3->setCondition(conditionVMON3, conditionData);
1228     coral::ICursor& cursorFVMON3 = queryFVMON3->execute();
1229     while (cursorFVMON3.next()) {
1230       Itemp.thr1 = 0;
1231       Itemp.thr2 = 0;
1232       Itemp.thr3 = 0;
1233       Itemp.thr4 = 0;
1234       Itemp.vmon1 = 0;
1235       Itemp.vmon2 = 0;
1236       Itemp.vmon3 = 0;
1237       Itemp.vmon4 = 0;
1238       Itemp.temp1 = 0;
1239       Itemp.temp2 = 0;
1240       Itemp.noise1 = 0;
1241       Itemp.noise2 = 0;
1242       Itemp.noise3 = 0;
1243       Itemp.noise4 = 0;
1244       const coral::AttributeList& row = cursorFVMON3.currentRow();
1245       float idoub = row["DPID"].data<float>();
1246       int id = static_cast<int>(idoub);
1247       float vmon3 = row["VMON3"].data<float>();
1248       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1249       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
1250       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
1251       Itemp.dpid = id;
1252       Itemp.vmon3 = vmon3;
1253       Itemp.day = ndate;
1254       Itemp.time = ntime;
1255       febarray.push_back(Itemp);
1256     }
1257   }
1258 
1259   if (till > since) {
1260     tMAX = UTtoT(till);
1261     std::cout << "Processing VMON4..." << std::endl;
1262     coral::AttributeList conditionData;
1263     conditionData.extend<coral::TimeStamp>("tmin");
1264     conditionData.extend<coral::TimeStamp>("tmax");
1265     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
1266     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
1267     std::string conditionVMON4 = "RPCFEB.VMON4 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
1268     queryFVMON4->setCondition(conditionVMON4, conditionData);
1269     coral::ICursor& cursorFVMON4 = queryFVMON4->execute();
1270     while (cursorFVMON4.next()) {
1271       Itemp.thr1 = 0;
1272       Itemp.thr2 = 0;
1273       Itemp.thr3 = 0;
1274       Itemp.thr4 = 0;
1275       Itemp.vmon1 = 0;
1276       Itemp.vmon2 = 0;
1277       Itemp.vmon3 = 0;
1278       Itemp.vmon4 = 0;
1279       Itemp.temp1 = 0;
1280       Itemp.temp2 = 0;
1281       Itemp.noise1 = 0;
1282       Itemp.noise2 = 0;
1283       Itemp.noise3 = 0;
1284       Itemp.noise4 = 0;
1285       const coral::AttributeList& row = cursorFVMON4.currentRow();
1286       float idoub = row["DPID"].data<float>();
1287       int id = static_cast<int>(idoub);
1288       float vmon4 = row["VMON4"].data<float>();
1289       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1290       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
1291       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
1292       Itemp.dpid = id;
1293       Itemp.vmon4 = vmon4;
1294       Itemp.day = ndate;
1295       Itemp.time = ntime;
1296       febarray.push_back(Itemp);
1297     }
1298   } else {
1299     std::cout << ">> Processing VMON4..." << std::endl;
1300     coral::AttributeList conditionData;
1301     conditionData.extend<coral::TimeStamp>("tmin");
1302     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
1303     std::string conditionVMON4 = "RPCFEB.VMON4 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
1304     queryFVMON4->setCondition(conditionVMON4, conditionData);
1305     coral::ICursor& cursorFVMON4 = queryFVMON4->execute();
1306     while (cursorFVMON4.next()) {
1307       Itemp.thr1 = 0;
1308       Itemp.thr2 = 0;
1309       Itemp.thr3 = 0;
1310       Itemp.thr4 = 0;
1311       Itemp.vmon1 = 0;
1312       Itemp.vmon2 = 0;
1313       Itemp.vmon3 = 0;
1314       Itemp.vmon4 = 0;
1315       Itemp.temp1 = 0;
1316       Itemp.temp2 = 0;
1317       Itemp.noise1 = 0;
1318       Itemp.noise2 = 0;
1319       Itemp.noise3 = 0;
1320       Itemp.noise4 = 0;
1321       const coral::AttributeList& row = cursorFVMON4.currentRow();
1322       float idoub = row["DPID"].data<float>();
1323       int id = static_cast<int>(idoub);
1324       float vmon4 = row["VMON4"].data<float>();
1325       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1326       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
1327       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
1328       Itemp.dpid = id;
1329       Itemp.vmon4 = vmon4;
1330       Itemp.day = ndate;
1331       Itemp.time = ntime;
1332       febarray.push_back(Itemp);
1333     }
1334   }
1335 
1336   if (till > since) {
1337     tMAX = UTtoT(till);
1338     std::cout << "Processing TEMP1..." << std::endl;
1339     coral::AttributeList conditionData;
1340     conditionData.extend<coral::TimeStamp>("tmin");
1341     conditionData.extend<coral::TimeStamp>("tmax");
1342     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
1343     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
1344     std::string conditionTEMP1 =
1345         "RPCFEB.TEMPERATURE1 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
1346     queryFTEMP1->setCondition(conditionTEMP1, conditionData);
1347     coral::ICursor& cursorFTEMP1 = queryFTEMP1->execute();
1348     while (cursorFTEMP1.next()) {
1349       Itemp.thr1 = 0;
1350       Itemp.thr2 = 0;
1351       Itemp.thr3 = 0;
1352       Itemp.thr4 = 0;
1353       Itemp.vmon1 = 0;
1354       Itemp.vmon2 = 0;
1355       Itemp.vmon3 = 0;
1356       Itemp.vmon4 = 0;
1357       Itemp.temp1 = 0;
1358       Itemp.temp2 = 0;
1359       Itemp.noise1 = 0;
1360       Itemp.noise2 = 0;
1361       Itemp.noise3 = 0;
1362       Itemp.noise4 = 0;
1363       const coral::AttributeList& row = cursorFTEMP1.currentRow();
1364       float idoub = row["DPID"].data<float>();
1365       int id = static_cast<int>(idoub);
1366       float temp1 = row["TEMP1"].data<float>();
1367       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1368       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
1369       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
1370       Itemp.dpid = id;
1371       Itemp.temp1 = temp1;
1372       Itemp.day = ndate;
1373       Itemp.time = ntime;
1374       febarray.push_back(Itemp);
1375     }
1376   } else {
1377     std::cout << ">> Processing TEMP1..." << std::endl;
1378     coral::AttributeList conditionData;
1379     conditionData.extend<coral::TimeStamp>("tmin");
1380     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
1381     std::string conditionTEMP1 = "RPCFEB.TEMPERATURE1 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
1382     queryFTEMP1->setCondition(conditionTEMP1, conditionData);
1383     coral::ICursor& cursorFTEMP1 = queryFTEMP1->execute();
1384     while (cursorFTEMP1.next()) {
1385       Itemp.thr1 = 0;
1386       Itemp.thr2 = 0;
1387       Itemp.thr3 = 0;
1388       Itemp.thr4 = 0;
1389       Itemp.vmon1 = 0;
1390       Itemp.vmon2 = 0;
1391       Itemp.vmon3 = 0;
1392       Itemp.vmon4 = 0;
1393       Itemp.temp1 = 0;
1394       Itemp.temp2 = 0;
1395       Itemp.noise1 = 0;
1396       Itemp.noise2 = 0;
1397       Itemp.noise3 = 0;
1398       Itemp.noise4 = 0;
1399       const coral::AttributeList& row = cursorFTEMP1.currentRow();
1400       float idoub = row["DPID"].data<float>();
1401       int id = static_cast<int>(idoub);
1402       float temp1 = row["TEMP1"].data<float>();
1403       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1404       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
1405       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
1406       Itemp.dpid = id;
1407       Itemp.temp1 = temp1;
1408       Itemp.day = ndate;
1409       Itemp.time = ntime;
1410       febarray.push_back(Itemp);
1411     }
1412   }
1413 
1414   if (till > since) {
1415     tMAX = UTtoT(till);
1416     std::cout << "Processing TEMP2..." << std::endl;
1417     coral::AttributeList conditionData;
1418     conditionData.extend<coral::TimeStamp>("tmin");
1419     conditionData.extend<coral::TimeStamp>("tmax");
1420     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
1421     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
1422     std::string conditionTEMP2 =
1423         "RPCFEB.TEMPERATURE2 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
1424     queryFTEMP2->setCondition(conditionTEMP2, conditionData);
1425     coral::ICursor& cursorFTEMP2 = queryFTEMP2->execute();
1426     while (cursorFTEMP2.next()) {
1427       Itemp.thr1 = 0;
1428       Itemp.thr2 = 0;
1429       Itemp.thr3 = 0;
1430       Itemp.thr4 = 0;
1431       Itemp.vmon1 = 0;
1432       Itemp.vmon2 = 0;
1433       Itemp.vmon3 = 0;
1434       Itemp.vmon4 = 0;
1435       Itemp.temp1 = 0;
1436       Itemp.temp2 = 0;
1437       Itemp.noise1 = 0;
1438       Itemp.noise2 = 0;
1439       Itemp.noise3 = 0;
1440       Itemp.noise4 = 0;
1441       const coral::AttributeList& row = cursorFTEMP2.currentRow();
1442       float idoub = row["DPID"].data<float>();
1443       int id = static_cast<int>(idoub);
1444       float temp2 = row["TEMP2"].data<float>();
1445       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1446       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
1447       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
1448       Itemp.dpid = id;
1449       Itemp.temp2 = temp2;
1450       Itemp.day = ndate;
1451       Itemp.time = ntime;
1452       febarray.push_back(Itemp);
1453     }
1454   } else {
1455     std::cout << ">> Processing TEMP2..." << std::endl;
1456     coral::AttributeList conditionData;
1457     conditionData.extend<coral::TimeStamp>("tmin");
1458     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
1459     std::string conditionTEMP2 = "RPCFEB.TEMPERATURE2 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
1460     queryFTEMP2->setCondition(conditionTEMP2, conditionData);
1461     coral::ICursor& cursorFTEMP2 = queryFTEMP2->execute();
1462     while (cursorFTEMP2.next()) {
1463       Itemp.thr1 = 0;
1464       Itemp.thr2 = 0;
1465       Itemp.thr3 = 0;
1466       Itemp.thr4 = 0;
1467       Itemp.vmon1 = 0;
1468       Itemp.vmon2 = 0;
1469       Itemp.vmon3 = 0;
1470       Itemp.vmon4 = 0;
1471       Itemp.temp1 = 0;
1472       Itemp.temp2 = 0;
1473       Itemp.noise1 = 0;
1474       Itemp.noise2 = 0;
1475       Itemp.noise3 = 0;
1476       Itemp.noise4 = 0;
1477       const coral::AttributeList& row = cursorFTEMP2.currentRow();
1478       float idoub = row["DPID"].data<float>();
1479       int id = static_cast<int>(idoub);
1480       float temp2 = row["TEMP2"].data<float>();
1481       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1482       int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year() - 2000);
1483       int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
1484       Itemp.dpid = id;
1485       Itemp.temp2 = temp2;
1486       Itemp.day = ndate;
1487       Itemp.time = ntime;
1488       febarray.push_back(Itemp);
1489     }
1490   }
1491 
1492   std::cout << ">> FEB array --> size: " << febarray.size() << " >> done." << std::endl;
1493   delete queryFVTH1;
1494   delete queryFVTH2;
1495   delete queryFVTH3;
1496   delete queryFVTH4;
1497   delete queryFTEMP1;
1498   session->transaction().commit();
1499   delete session;
1500   return febarray;
1501 }
1502 
1503 //----------------------------- U X C ------------------------------------------------------------------------
1504 std::vector<RPCObUXC::Item> RPCFw::createUXC(long long since, long long till) {
1505   tMIN = UTtoT(since);
1506   std::cout << ">> Processing since: " << tMIN.day() << "/" << tMIN.month() << "/" << tMIN.year() << " " << tMIN.hour()
1507             << ":" << tMIN.minute() << "." << tMIN.second() << std::endl;
1508 
1509   coral::ISession* session = this->connect(m_connectionString, m_userName, m_password);
1510   session->transaction().start(true);
1511   coral::ISchema& schema = session->nominalSchema();
1512   std::cout << ">> creating UXC object..." << std::endl;
1513 
1514   // UXCT
1515   coral::IQuery* queryUXCP = schema.newQuery();
1516   queryUXCP->addToTableList("RPCGASPARAMETERS");
1517   queryUXCP->addToTableList("DP_NAME2ID");
1518   queryUXCP->addToOutputList("DP_NAME2ID.DPNAME", "DPNAME");
1519   queryUXCP->addToOutputList("DP_NAME2ID.ID", "ID");
1520   queryUXCP->addToOutputList("RPCGASPARAMETERS.DPID", "DPID");
1521   queryUXCP->addToOutputList("RPCGASPARAMETERS.CHANGE_DATE", "TSTAMP");
1522   queryUXCP->addToOutputList("RPCGASPARAMETERS.VALUE", "VALUE");
1523   coral::IQuery* queryUXCT = schema.newQuery();
1524   queryUXCT->addToTableList("RPCCOOLING");
1525   queryUXCT->addToTableList("DP_NAME2ID");
1526   queryUXCT->addToOutputList("DP_NAME2ID.DPNAME", "DPNAME");
1527   queryUXCT->addToOutputList("DP_NAME2ID.ID", "ID");
1528   queryUXCT->addToOutputList("RPCCOOLING.DPID", "DPID");
1529   queryUXCT->addToOutputList("RPCCOOLING.CHANGE_DATE", "TSTAMP");
1530   queryUXCT->addToOutputList("RPCCOOLING.VALUE", "VALUE");
1531   coral::IQuery* queryUXCH = schema.newQuery();
1532   queryUXCH->addToTableList("RPCCOOLING");
1533   queryUXCH->addToTableList("DP_NAME2ID");
1534   queryUXCH->addToOutputList("DP_NAME2ID.DPNAME", "DPNAME");
1535   queryUXCH->addToOutputList("DP_NAME2ID.ID", "ID");
1536   queryUXCH->addToOutputList("RPCCOOLING.DPID", "DPID");
1537   queryUXCH->addToOutputList("RPCCOOLING.CHANGE_DATE", "TSTAMP");
1538   queryUXCH->addToOutputList("RPCCOOLING.VALUE", "VALUE");
1539 
1540   RPCObUXC::Item Itemp;
1541   std::vector<RPCObUXC::Item> uxcarray;
1542   coral::TimeStamp tlast = tMIN;
1543   if (till > since) {
1544     tMAX = UTtoT(till);
1545     std::cout << ">> Processing till: " << tMAX.day() << "/" << tMAX.month() << "/" << tMAX.year() << " " << tMAX.hour()
1546               << ":" << tMAX.minute() << "." << tMAX.second() << std::endl;
1547     std::cout << "Processing UXC..." << std::endl;
1548     coral::AttributeList conditionData;
1549     conditionData.extend<coral::TimeStamp>("tmin");
1550     conditionData.extend<coral::TimeStamp>("tmax");
1551     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
1552     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
1553     std::string conditionUXCP =
1554         "RPCGASPARAMETERS.DPID = DP_NAME2ID.ID AND RPCGASPARAMETERS.CHANGE_DATE >:tmin AND "
1555         "RPCGASPARAMETERS.CHANGE_DATE <:tmax AND (DP_NAME2ID.DPNAME like '%UXCPressure%')";
1556     queryUXCP->setCondition(conditionUXCP, conditionData);
1557     coral::ICursor& cursorUXCP = queryUXCP->execute();
1558     while (cursorUXCP.next()) {
1559       Itemp.temperature = 0;
1560       Itemp.pressure = 0;
1561       Itemp.dewpoint = 0;
1562       const coral::AttributeList& row = cursorUXCP.currentRow();
1563       float value = row["VALUE"].data<float>();
1564       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1565       unsigned long long ut_time = TtoUT(ts);
1566       Itemp.pressure = value;
1567       Itemp.unixtime = ut_time;
1568       uxcarray.push_back(Itemp);
1569     }
1570     std::string conditionUXCT =
1571         "RPCCOOLING.DPID = DP_NAME2ID.ID AND RPCCOOLING.CHANGE_DATE >:tmin AND RPCCOOLING.CHANGE_DATE <:tmax AND "
1572         "(DP_NAME2ID.DPNAME like '%TempUXC%')";
1573     queryUXCT->setCondition(conditionUXCT, conditionData);
1574     coral::ICursor& cursorUXCT = queryUXCT->execute();
1575     while (cursorUXCT.next()) {
1576       Itemp.temperature = 0;
1577       Itemp.pressure = 0;
1578       Itemp.dewpoint = 0;
1579       const coral::AttributeList& row = cursorUXCT.currentRow();
1580       float value = row["VALUE"].data<float>();
1581       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1582       unsigned long long ut_time = TtoUT(ts);
1583       Itemp.temperature = value;
1584       Itemp.unixtime = ut_time;
1585       uxcarray.push_back(Itemp);
1586     }
1587     std::string conditionUXCH =
1588         "RPCCOOLING.DPID = DP_NAME2ID.ID AND RPCCOOLING.CHANGE_DATE >:tmin AND RPCCOOLING.CHANGE_DATE <:tmax AND "
1589         "(DP_NAME2ID.DPNAME like '%DewpointUXC%')";
1590     queryUXCH->setCondition(conditionUXCH, conditionData);
1591     coral::ICursor& cursorUXCH = queryUXCH->execute();
1592     while (cursorUXCH.next()) {
1593       Itemp.temperature = 0;
1594       Itemp.pressure = 0;
1595       Itemp.dewpoint = 0;
1596       const coral::AttributeList& row = cursorUXCH.currentRow();
1597       float value = row["VALUE"].data<float>();
1598       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1599       unsigned long long ut_time = TtoUT(ts);
1600       Itemp.dewpoint = value;
1601       Itemp.unixtime = ut_time;
1602       uxcarray.push_back(Itemp);
1603     }
1604   } else {
1605     std::cout << "This objects cannot be copied in this mode. Use RANGE mode!" << std::endl;
1606   }
1607 
1608   std::cout << ">> UXC array --> size: " << uxcarray.size() << " >> done." << std::endl;
1609   delete queryUXCT;
1610   delete queryUXCP;
1611   delete queryUXCH;
1612   session->transaction().commit();
1613   delete session;
1614   return uxcarray;
1615 }
1616 
1617 //----------------------------- M I X ------------------------------------------------------------------------
1618 std::vector<RPCObGasMix::Item> RPCFw::createMix(long long since, long long till) {
1619   tMIN = UTtoT(since);
1620   std::cout << ">> Processing since: " << tMIN.day() << "/" << tMIN.month() << "/" << tMIN.year() << " " << tMIN.hour()
1621             << ":" << tMIN.minute() << "." << tMIN.second() << std::endl;
1622 
1623   coral::ISession* session = this->connect(m_connectionString, m_userName, m_password);
1624   session->transaction().start(true);
1625   coral::ISchema& schema = session->nominalSchema();
1626   std::cout << ">> creating UXC object..." << std::endl;
1627 
1628   coral::IQuery* queryMix = schema.newQuery();
1629   queryMix->addToTableList("RPCGASPARAMETERS");
1630   queryMix->addToTableList("DP_NAME2ID");
1631   queryMix->addToOutputList("DP_NAME2ID.DPNAME", "DPNAME");
1632   queryMix->addToOutputList("DP_NAME2ID.ID", "ID");
1633   queryMix->addToOutputList("RPCGASPARAMETERS.DPID", "DPID");
1634   queryMix->addToOutputList("RPCGASPARAMETERS.CHANGE_DATE", "TSTAMP");
1635   queryMix->addToOutputList("RPCGASPARAMETERS.VALUE", "VALUE");
1636 
1637   coral::IQuery* queryMix2 = schema.newQuery();
1638   queryMix2->addToTableList("RPCGASPARAMETERS");
1639   queryMix2->addToTableList("DP_NAME2ID");
1640   queryMix2->addToOutputList("DP_NAME2ID.DPNAME", "DPNAME");
1641   queryMix2->addToOutputList("DP_NAME2ID.ID", "ID");
1642   queryMix2->addToOutputList("RPCGASPARAMETERS.DPID", "DPID");
1643   queryMix2->addToOutputList("RPCGASPARAMETERS.CHANGE_DATE", "TSTAMP");
1644   queryMix2->addToOutputList("RPCGASPARAMETERS.VALUE", "VALUE");
1645 
1646   coral::IQuery* queryMix3 = schema.newQuery();
1647   queryMix3->addToTableList("RPCGASPARAMETERS");
1648   queryMix3->addToTableList("DP_NAME2ID");
1649   queryMix3->addToOutputList("DP_NAME2ID.DPNAME", "DPNAME");
1650   queryMix3->addToOutputList("DP_NAME2ID.ID", "ID");
1651   queryMix3->addToOutputList("RPCGASPARAMETERS.DPID", "DPID");
1652   queryMix3->addToOutputList("RPCGASPARAMETERS.CHANGE_DATE", "TSTAMP");
1653   queryMix3->addToOutputList("RPCGASPARAMETERS.VALUE", "VALUE");
1654 
1655   RPCObGasMix::Item Mtemp;
1656   std::vector<RPCObGasMix::Item> marray;
1657   coral::TimeStamp tlast = tMIN;
1658   if (till > since) {
1659     tMAX = UTtoT(till);
1660     std::cout << ">> Processing till: " << tMAX.day() << "/" << tMAX.month() << "/" << tMAX.year() << " " << tMAX.hour()
1661               << ":" << tMAX.minute() << "." << tMAX.second() << std::endl;
1662     std::cout << "Processing UXC..." << std::endl;
1663     coral::AttributeList conditionData;
1664     conditionData.extend<coral::TimeStamp>("tmin");
1665     conditionData.extend<coral::TimeStamp>("tmax");
1666     conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
1667     conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
1668     std::string conditionM1 =
1669         "RPCGASPARAMETERS.DPID = DP_NAME2ID.ID AND RPCGASPARAMETERS.CHANGE_DATE >:tmin AND "
1670         "RPCGASPARAMETERS.CHANGE_DATE <:tmax AND (DP_NAME2ID.DPNAME like '%IC4H10Ratio%')";
1671     queryMix->setCondition(conditionM1, conditionData);
1672     coral::ICursor& cursorMix = queryMix->execute();
1673     while (cursorMix.next()) {
1674       Mtemp.gas1 = 0;
1675       Mtemp.gas2 = 0;
1676       Mtemp.gas3 = 0;
1677       const coral::AttributeList& row = cursorMix.currentRow();
1678       float value = row["VALUE"].data<float>();
1679       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1680       unsigned long long ut_time = TtoUT(ts);
1681       Mtemp.gas1 = value;
1682       Mtemp.unixtime = ut_time;
1683       marray.push_back(Mtemp);
1684     }
1685     std::string conditionM2 =
1686         "RPCGASPARAMETERS.DPID = DP_NAME2ID.ID AND RPCGASPARAMETERS.CHANGE_DATE >:tmin AND "
1687         "RPCGASPARAMETERS.CHANGE_DATE <:tmax AND (DP_NAME2ID.DPNAME like '%C2H2F4Ratio%')";
1688     queryMix2->setCondition(conditionM2, conditionData);
1689     coral::ICursor& cursorMix2 = queryMix2->execute();
1690     while (cursorMix2.next()) {
1691       Mtemp.gas1 = 0;
1692       Mtemp.gas2 = 0;
1693       Mtemp.gas3 = 0;
1694       const coral::AttributeList& row = cursorMix2.currentRow();
1695       float value = row["VALUE"].data<float>();
1696       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1697       unsigned long long ut_time = TtoUT(ts);
1698       Mtemp.gas2 = value;
1699       Mtemp.unixtime = ut_time;
1700       marray.push_back(Mtemp);
1701     }
1702     std::string conditionM3 =
1703         "RPCGASPARAMETERS.DPID = DP_NAME2ID.ID AND RPCGASPARAMETERS.CHANGE_DATE >:tmin AND "
1704         "RPCGASPARAMETERS.CHANGE_DATE <:tmax AND (DP_NAME2ID.DPNAME like '%SF6Ratio%')";
1705     queryMix3->setCondition(conditionM3, conditionData);
1706     coral::ICursor& cursorMix3 = queryMix3->execute();
1707     while (cursorMix3.next()) {
1708       Mtemp.gas1 = 0;
1709       Mtemp.gas2 = 0;
1710       Mtemp.gas3 = 0;
1711       const coral::AttributeList& row = cursorMix3.currentRow();
1712       float value = row["VALUE"].data<float>();
1713       coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
1714       unsigned long long ut_time = TtoUT(ts);
1715       Mtemp.gas3 = value;
1716       Mtemp.unixtime = ut_time;
1717       marray.push_back(Mtemp);
1718     }
1719   } else {
1720     std::cout << "This objects cannot be copied in this mode. Use RANGE mode!" << std::endl;
1721   }
1722 
1723   std::cout << ">> GasMix array --> size: " << marray.size() << " >> done." << std::endl;
1724   delete queryMix;
1725   session->transaction().commit();
1726   delete session;
1727   return marray;
1728 }
1729 
1730 //----------------------------------------------------------------------------------------------
1731 coral::TimeStamp RPCFw::UTtoT(long long utime) {
1732   int yea = static_cast<int>(trunc(utime / 31536000) + 1970);
1733   int yes = (yea - 1970) * 31536000;
1734   int cony = ((yea - 1972) % 4) + 1;
1735   if (cony == 0)
1736     yes = yes + (yea - 1972) / 4 * 86400;
1737   else
1738     yes = yes + static_cast<int>(trunc((yea - 1972) / 4)) * 86400;
1739   int day = static_cast<int>(trunc((utime - yes) / 86400));
1740   int rest = static_cast<int>(utime - yes - day * 86400);
1741   int mon = 0;
1742   // BISESTILE YEAR
1743   if (cony == 0) {
1744     day = day + 1;
1745     if (day < 32) {
1746       mon = 1;
1747       day = day - 0;
1748     }
1749     if (day >= 32 && day < 61) {
1750       mon = 2;
1751       day = day - 31;
1752     }
1753     if (day >= 61 && day < 92) {
1754       mon = 3;
1755       day = day - 60;
1756     }
1757     if (day >= 92 && day < 122) {
1758       mon = 4;
1759       day = day - 91;
1760     }
1761     if (day >= 122 && day < 153) {
1762       mon = 5;
1763       day = day - 121;
1764     }
1765     if (day >= 153 && day < 183) {
1766       mon = 6;
1767       day = day - 152;
1768     }
1769     if (day >= 183 && day < 214) {
1770       mon = 7;
1771       day = day - 182;
1772     }
1773     if (day >= 214 && day < 245) {
1774       mon = 8;
1775       day = day - 213;
1776     }
1777     if (day >= 245 && day < 275) {
1778       mon = 9;
1779       day = day - 244;
1780     }
1781     if (day >= 275 && day < 306) {
1782       mon = 10;
1783       day = day - 274;
1784     }
1785     if (day >= 306 && day < 336) {
1786       mon = 11;
1787       day = day - 305;
1788     }
1789     if (day >= 336) {
1790       mon = 12;
1791       day = day - 335;
1792     }
1793   }
1794   // NOT BISESTILE YEAR
1795   else {
1796     if (day < 32) {
1797       mon = 1;
1798       day = day - 0;
1799     }
1800     if (day >= 32 && day < 60) {
1801       mon = 2;
1802       day = day - 31;
1803     }
1804     if (day >= 60 && day < 91) {
1805       mon = 3;
1806       day = day - 59;
1807     }
1808     if (day >= 91 && day < 121) {
1809       mon = 4;
1810       day = day - 90;
1811     }
1812     if (day >= 121 && day < 152) {
1813       mon = 5;
1814       day = day - 120;
1815     }
1816     if (day >= 152 && day < 182) {
1817       mon = 6;
1818       day = day - 151;
1819     }
1820     if (day >= 182 && day < 213) {
1821       mon = 7;
1822       day = day - 181;
1823     }
1824     if (day >= 213 && day < 244) {
1825       mon = 8;
1826       day = day - 212;
1827     }
1828     if (day >= 244 && day < 274) {
1829       mon = 9;
1830       day = day - 243;
1831     }
1832     if (day >= 274 && day < 305) {
1833       mon = 10;
1834       day = day - 273;
1835     }
1836     if (day >= 305 && day < 335) {
1837       mon = 11;
1838       day = day - 304;
1839     }
1840     if (day >= 335) {
1841       mon = 12;
1842       day = day - 334;
1843     }
1844   }
1845 
1846   int hou = static_cast<int>(trunc(rest / 3600));
1847   rest = rest - hou * 3600;
1848   int min = static_cast<int>(trunc(rest / 60));
1849   rest = rest - min * 60;
1850   int sec = rest;
1851   int nan = 0;
1852 
1853   //  std::cout <<">> Processing since: "<<day<<"/"<<mon<<"/"<<yea<<" "<<hou<<":"<<min<<"."<<sec<< std::endl;
1854 
1855   coral::TimeStamp Tthr;
1856 
1857   Tthr = coral::TimeStamp(yea, mon, day, hou, min, sec, nan);
1858   return Tthr;
1859 }
1860 
1861 //----------------------------------------------------------------------------------------------
1862 unsigned long long RPCFw::TtoUT(const coral::TimeStamp& time) {
1863   long long utime = (time.year() - 1970) * 31536000 + static_cast<int>(trunc((time.year() - 1972) / 4)) * 86400 +
1864                     (((time.month() - 1) * 31) * 86400) + ((time.day() - 1) * 86400) + time.hour() * 3600 +
1865                     time.minute() * 60 + time.second();
1866 
1867   if (time.month() == 3)
1868     utime = utime - 3 * 86400;
1869   if (time.month() == 4)
1870     utime = utime - 3 * 86400;
1871   if (time.month() == 5)
1872     utime = utime - 4 * 86400;
1873   if (time.month() == 6)
1874     utime = utime - 4 * 86400;
1875   if (time.month() == 7)
1876     utime = utime - 5 * 86400;
1877   if (time.month() == 8)
1878     utime = utime - 5 * 86400;
1879   if (time.month() == 9)
1880     utime = utime - 5 * 86400;
1881   if (time.month() == 10)
1882     utime = utime - 6 * 86400;
1883   if (time.month() == 11)
1884     utime = utime - 6 * 86400;
1885   if (time.month() == 12)
1886     utime = utime - 7 * 86400;
1887 
1888   return utime;
1889 }
1890 
1891 bool RPCFw::isMajor(const coral::TimeStamp& fir, const coral::TimeStamp& sec) {
1892   double first =
1893       fir.year() * 1e10 + fir.month() + 1e8 + fir.day() * 1e6 + fir.hour() * 1e4 + fir.minute() * 1e2 + fir.second();
1894   double second =
1895       sec.year() * 1e10 + sec.month() + 1e8 + sec.day() * 1e6 + sec.hour() * 1e4 + sec.minute() * 1e2 + sec.second();
1896 
1897   if (first > second)
1898     return true;
1899 
1900   return false;
1901 }