| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

FeeCableMapWriter.cc

Go to the documentation of this file.
00001 #include "DBWriter/FeeCableMapWriter.h"
00002 #include "DBWriter/ICalibWriter.h"
00003 
00004 #ifdef I_LIKE_DUPLICITY
00005 #include "DbiDataSvc/FeeCableMap.h"
00006 #else
00007 #include "genDbi/GFeeCableMap.h"
00008 #endif
00009 
00010 #include "Context/Context.h"
00011 #include "Context/ContextRange.h"
00012 
00013 #include "DatabaseInterface/DbiLog.h"
00014 #include "DatabaseInterface/DbiOutRowStream.h"
00015 #include "DatabaseInterface/DbiResultSet.h"
00016 #include "DatabaseInterface/DbiValidityRec.h"
00017 
00018 #include "DaqRunInfoSvc/IDaqRunInfoSvc.h"
00019 #include "DaqRunInfoSvc/DaqRunInfo.h"
00020 #include "DaqRunInfoSvc/DaqCalibRunInfo.h"
00021 
00022 #include "GaudiKernel/Service.h"
00023 #include <iostream>
00024 #include <sstream>
00025 #include <fstream>
00026 using namespace std;
00027 FeeCableMapWriter:: FeeCableMapWriter(const string& type,
00028                                 const string& name, 
00029                                 const IInterface* parent)
00030               :GaudiTool(type, name, parent)
00031 {
00032     declareInterface< ICalibWriter >(this);
00033     //aggNo = -1;
00034     //subsite = 0;
00035     //task = 0;
00036     //m_daqRunInfoSvcName = "DaqRunInfoSvc";
00037 }
00038 
00039 FeeCableMapWriter::~FeeCableMapWriter(){
00040 //    delete myWriter;
00041 }
00042 
00043 StatusCode FeeCableMapWriter::initialize(){
00044   cout<<"FeeCableMapWriter initialzing--------------"<<endl;
00045   info()<< "initialize()"<< endreq;
00046   StatusCode sc = this->GaudiTool::initialize();
00047   if(sc != StatusCode::SUCCESS) return sc;
00048 
00049   //Get the DaqRunInfo Service
00050   //m_daqRunInfoSvc = svc<IDaqRunInfoSvc>("DaqRunInfoSvc", true);
00051   //if(!m_daqRunInfoSvc)
00052   //{
00053   //  error()<< "No DaqRunInfoSvc available."<< endreq;
00054   //  return StatusCode::FAILURE;
00055   //} 
00056   return StatusCode::SUCCESS;
00057 }
00058 
00059 StatusCode FeeCableMapWriter::finalize(){
00060     cout<<"FeeCableMapWriter finalizing--------------"<<endl;
00061     StatusCode sc = this->GaudiTool::finalize();
00062     if(sc != StatusCode::SUCCESS) return sc;
00063     return StatusCode::SUCCESS;
00064 }
00065 
00066 int FeeCableMapWriter::setRunNo(int runNo){ 
00067     runNumber = runNo;
00068     return 1;
00069 } 
00070 
00071 int FeeCableMapWriter::setFileName(string fileName){
00072     inputFileName = fileName; 
00073     return 1;
00074 } 
00075 
00076 int FeeCableMapWriter::setTimeWindow(int time){
00077     timeWindow = time; 
00078     return 1;
00079 } 
00080 
00081 /*
00082 int FeeCableMapWriter::getRunInfo(){
00083 
00084     const DaqRunInfo* row;
00085     row = m_daqRunInfoSvc->GetRunInfo(runNo);
00086     if(!row){
00087       cout<< "runNo: "<<runNo<<" is not found in table DaqRunInfo."<<endl;
00088       return 0;
00089     }
00090     DbiResult* res = row->GetOwner();
00091     const DbiValidityRec vr = res->GetValidityRec();
00092     range = vr.GetContextRange();
00093     return 1;
00094 
00095 }
00096 */
00097 
00098 int FeeCableMapWriter::init()
00099 {
00100 #ifdef I_LIKE_DUPLICITY
00101    myWriter = new DbiWriter<FeeCableMap>(range,aggNo,subsite,task);
00102 #else
00103    TimeStamp versionDate(0,0) ;
00104    UInt_t dbNo(0) ;
00105    const std::string logComment = "" ;
00106    const std::string tableName = "FeeCableMap" ;
00107    myWriter = new DbiWriter<GFeeCableMap>(range,aggNo,subsite,task, versionDate, dbNo, logComment, tableName );
00108 #endif
00109    return 1;
00110 }
00111 
00112 int FeeCableMapWriter::final()
00113 {     
00114     cout<<"close DB"<<endl;
00115     myWriter->Close();
00116     return 1;
00117 }
00118 
00119 int FeeCableMapWriter::run()
00120 {
00121     mainProcess();
00122 }
00123 
00124 int FeeCableMapWriter::fillRow(){ 
00125 #ifdef I_LIKE_DUPLICITY
00126     FeeCableMap row;
00127 #else
00128 #endif
00129     ifstream input;
00130     input.open(inputFileName.c_str());
00131     if(!input){
00132       cout<<"can not open file : "<<inputFileName<<endl;
00133       return 0;
00134     }else{
00135           int feeChannelId = 0;
00136           string channelDesc;
00137           int feeHardwareId = 0;
00138           string chanHrdwDesc;
00139           int sensorId = 0;
00140           string sensorDesc;
00141           int pmtHardwareId = 0;
00142           string pmtHrdwDesc;
00143 
00144         char buffer[500];
00145 //      input.getline(buffer, sizeof(buffer));
00146 //      input.getline(buffer, sizeof(buffer));
00147       while(input.peek()!=EOF)
00148       {
00149         input.getline(buffer, sizeof(buffer));
00150         istringstream(buffer)>>feeChannelId
00151                              >>channelDesc
00152                              >>feeHardwareId
00153                              >>chanHrdwDesc
00154                              >>sensorId
00155                              >>sensorDesc
00156                              >>pmtHardwareId
00157                              >>pmtHrdwDesc;
00158 
00159 cout<< feeChannelId<<"   "
00160     << channelDesc<<"   "
00161     << feeHardwareId<<"   "
00162     << chanHrdwDesc<<"   "
00163     << sensorId<<"   "
00164     << sensorDesc<<"   "
00165     << pmtHardwareId<<"   "
00166     << pmtHrdwDesc;
00167 
00168 
00169 #ifdef I_LIKE_DUPLICITY
00170 row.SetFeeCableMapValues(
00171 #else
00172   GFeeCableMap row( 
00173 #endif
00174 feeChannelId,
00175 channelDesc,
00176 feeHardwareId,
00177 chanHrdwDesc,
00178 sensorId,
00179 sensorDesc,
00180 pmtHardwareId,
00181 pmtHrdwDesc
00182               );
00183          //writeToDB();
00184          *myWriter << row;
00185       }
00186     }
00187     return 1;
00188 } 
00189 
00190 int FeeCableMapWriter::setContextRange(){
00191     ifstream input;
00192     input.open("/publicfs/dyb/user/anfp/DBIW/DBWriter/share/feeCableMap.conf");
00193      if(!input){
00194       cout<<"can not open file : "<<"/publicfs/dyb/user/anfp/DBIW/DBWriter/share/feeCableMap.conf"<<endl;
00195       return 0;
00196     }else{
00197       int Syear;
00198       int Smonth;
00199       int Sday;
00200       int Shour;
00201       int Smin;
00202       int Ssec;
00203 
00204       int Eyear;
00205       int Emonth;
00206       int Eday;
00207       int Ehour;
00208       int Emin;
00209       int Esec;
00210 
00211       int sitemask;
00212       int simmask;
00213 
00214       input>> Syear
00215            >> Smonth
00216            >> Sday
00217            >> Shour
00218            >> Smin
00219            >> Ssec;
00220 
00221       input>> Eyear
00222            >> Emonth
00223            >> Eday
00224            >> Ehour
00225            >> Emin
00226            >> Esec;
00227 
00228       input>> sitemask
00229            >> simmask;
00230 
00231 
00232 
00233 //    startTime.Set(Syear, Smonth, Sday, Shour, Smin, Ssec,0,0,0);///
00234 TimeStamp Tstart(Syear, Smonth, Sday, Shour, Smin, Ssec,0,1,0);
00235 //TimeStamp Tstart(2010, 4, 1, 0, 0, 0,0,0,0);
00236     startTime = Tstart;
00237 
00238 TimeStamp Tend(Eyear, Emonth, Eday, Ehour, Emin, Esec,0,1,0);
00239 //    TimeStamp Tend(2020, 12, 22, 0, 0, 0,0,0,0);
00240     endTime = Tend;
00241 
00242 //    endTime.Set(Eyear, Emonth, Eday, Ehour, Emin, Esec,0,0,0);///
00243     ContextRange Cr(sitemask, simmask, startTime, endTime);
00244 // ContextRange Cr(32, 1, startTime, endTime);///
00245     range = Cr;
00246 }
00247 
00248 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:28:15 2011 for DBWriter by doxygen 1.4.7