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

In This Package:

CalibPmtWriter.cc

Go to the documentation of this file.
00001 #include "DBWriter/CalibPmtWriter.h"
00002 #include "DBWriter/ICalibWriter.h"
00003 
00004 #ifdef I_LIKE_DUPLICITY 
00005 #include "DbiDataSvc/CalibPmtSpec.h"
00006 #else
00007 #include "genDbi/GCalibPmtSpec.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 CalibPmtWriter:: CalibPmtWriter(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 CalibPmtWriter::~CalibPmtWriter(){
00040 //    delete myWriter;
00041 }
00042 
00043 StatusCode CalibPmtWriter::initialize(){
00044   cout<<"CalibPmtWriter 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 CalibPmtWriter::finalize(){
00060     cout<<"CalibPmtWriter finalizing--------------"<<endl;
00061     StatusCode sc = this->GaudiTool::finalize();
00062     if(sc != StatusCode::SUCCESS) return sc;
00063     return StatusCode::SUCCESS;
00064 }
00065 
00066 int CalibPmtWriter::setRunNo(int runNo){ 
00067     runNumber = runNo;
00068     return 1;
00069 } 
00070 
00071 int CalibPmtWriter::setFileName(string fileName){
00072     inputFileName = fileName; 
00073     return 1;
00074 } 
00075 
00076 int CalibPmtWriter::setTimeWindow(int time){
00077     timeWindow = time; 
00078     return 1;
00079 } 
00080 
00081 void CalibPmtWriter::setSubsite(int subSite)
00082 {
00083     this->subsite = subSite;
00084 }
00085 
00086 void CalibPmtWriter::setIsSim(bool isSim)
00087 {
00088     this->isSim = isSim;
00089 }
00090 
00091 void CalibPmtWriter::setSiteMask(int siteMask)
00092 {
00093     this->siteMask = siteMask;
00094 }
00095 
00096 /*
00097 int CalibPmtWriter::getRunInfo(){
00098 
00099     const DaqRunInfo* row;
00100     row = m_daqRunInfoSvc->GetRunInfo(runNo);
00101     if(!row){
00102       cout<< "runNo: "<<runNo<<" is not found in table DaqRunInfo."<<endl;
00103       return 0;
00104     }
00105     DbiResult* res = row->GetOwner();
00106     const DbiValidityRec vr = res->GetValidityRec();
00107     range = vr.GetContextRange();
00108     return 1;
00109 
00110 }
00111 */
00112 
00113 int CalibPmtWriter::init()
00114 {
00115 #ifdef I_LIKE_DUPLICITY 
00116    myWriter = new DbiWriter<CalibPmtSpec>(range,aggNo,subsite,task);
00117 #else
00118    TimeStamp versionDate(0,0) ;
00119    UInt_t dbNo(0) ;
00120    const std::string logComment = "" ;
00121    const std::string tableName = "CalibPmtSpec" ;
00122    myWriter = new DbiWriter<GCalibPmtSpec>(range,aggNo,subsite,task, versionDate, dbNo, logComment, tableName );
00123 #endif
00124    return 1;
00125 }
00126 
00127 int CalibPmtWriter::final()
00128 {     
00129     cout<<"close DB"<<endl;
00130     myWriter->Close();
00131     return 1;
00132 }
00133 
00134 int CalibPmtWriter::run()
00135 {
00136     mainProcess();
00137 }
00138 
00139 int CalibPmtWriter::fillRow(){ 
00140 #ifdef I_LIKE_DUPLICITY 
00141     CalibPmtSpec row;
00142 #else
00143 #endif
00144     ifstream input;
00145     input.open(inputFileName.c_str());
00146     if(!input){
00147       cout<<"can not open file : "<<inputFileName<<endl;
00148       return 0;
00149     }else{
00150       int pmtID = 0;
00151       string description;
00152       int status = 0;
00153       double speHigh = 0;
00154       double sigmaSpe = 0;
00155       double speLow = 0;
00156       double timeOffset = 0;
00157       double timeSpread = 0;
00158       double efficiency = 0;
00159       double prePulse = 0;
00160       double afterPulse = 0;
00161       double darkRate = 0;
00162       char buffer[500];
00163       input.getline(buffer, sizeof(buffer));
00164       input.getline(buffer, sizeof(buffer));
00165       while(input.peek()!=EOF)
00166       {
00167         input.getline(buffer, sizeof(buffer));
00168         istringstream(buffer)>>pmtID
00169                              >>description
00170                              >>status
00171                              >>speHigh
00172                              >>sigmaSpe
00173                              >>speLow
00174                              >>timeOffset
00175                              >>timeSpread
00176                              >>efficiency 
00177                              >>prePulse 
00178                              >>afterPulse
00179                              >>darkRate ;
00180 
00181         cout<<pmtID<<"   "
00182             <<description<<"   "
00183             <<status<<"   "
00184             <<speHigh<<"   "
00185             <<sigmaSpe<<"   "
00186             <<speLow<<"   "
00187             <<timeOffset<<"   "
00188             <<timeSpread<<"   "
00189             <<efficiency<<"   "
00190             <<prePulse<<"   "
00191             <<afterPulse<<"   "
00192             <<darkRate<<endl;
00193 
00194 #ifdef I_LIKE_DUPLICITY 
00195          row.SetCalibPmtSpecValues(
00196 #else
00197          GCalibPmtSpec row(
00198 #endif
00199                                    pmtID,
00200                                    description,
00201                                    status,
00202                                    speHigh,                             
00203                                    sigmaSpe,
00204                                    speLow,
00205                                    timeOffset,
00206                                    timeSpread,
00207                                    efficiency,
00208                                    prePulse,
00209                                    afterPulse,
00210                                    darkRate);
00211          //writeToDB();
00212          *myWriter << row;
00213       }
00214     }
00215     return 1;
00216 } 
00217 
00218 
00219 
00220 
| 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