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

In This Package:

CalibFeeWriter.cc

Go to the documentation of this file.
00001 #include "DBWriter/CalibFeeWriter.h"
00002 
00003 #ifdef I_LIKE_DUPLICITY 
00004 #include "DbiDataSvc/CalibFeeSpec.h"
00005 #else
00006 #include "genDbi/GCalibFeeSpec.h"
00007 #endif
00008 
00009 #include "Context/Context.h"
00010 #include "Context/ContextRange.h"
00011 
00012 #include "DatabaseInterface/DbiLog.h"
00013 #include "DatabaseInterface/DbiOutRowStream.h"
00014 #include "DatabaseInterface/DbiResultSet.h"
00015 #include "DatabaseInterface/DbiValidityRec.h"
00016 
00017 #include "GaudiKernel/Service.h"
00018 #include <iostream>
00019 #include <sstream>
00020 #include <fstream>
00021 using namespace std;
00022 CalibFeeWriter:: CalibFeeWriter(const string& type,
00023                                 const string& name, 
00024                                 const IInterface* parent)
00025               :GaudiTool(type, name, parent)
00026 {
00027     declareInterface< ICalibWriter >(this);
00028     //aggNo = -1;
00029     //subsite = 0;
00030     //task = 0;
00031    // m_daqRunInfoSvcName = "DaqRunInfoSvc";
00032 }
00033 
00034 CalibFeeWriter::~CalibFeeWriter(){
00035 //    delete myWriter;
00036 }
00037 
00038 StatusCode CalibFeeWriter::initialize(){
00039   cout<<"CalibFeeWriter initialzing--------------"<<endl;
00040   info()<< "initialize()"<< endreq;
00041   StatusCode sc = this->GaudiTool::initialize();
00042   if(sc != StatusCode::SUCCESS) return sc;
00043 
00044   //Get the DaqRunInfo Service
00045  // m_daqRunInfoSvc = svc<IDaqRunInfoSvc>("DaqRunInfoSvc", true);
00046  // if(!m_daqRunInfoSvc)
00047  // {
00048  //   error()<< "No DaqRunInfoSvc available."<< endreq;
00049  //   return StatusCode::FAILURE;
00050  // } 
00051   return StatusCode::SUCCESS;
00052 }
00053 
00054 StatusCode CalibFeeWriter::finalize(){
00055     cout<<"CalibFeeWriter finalizing--------------"<<endl;
00056     StatusCode sc = this->GaudiTool::finalize();
00057     if(sc != StatusCode::SUCCESS) return sc;
00058     return StatusCode::SUCCESS;
00059 }
00060 
00061 int CalibFeeWriter::setRunNo(int runNo){ 
00062     runNumber = runNo;
00063     return 1;
00064 } 
00065 
00066 int CalibFeeWriter::setFileName(string fileName){
00067     inputFileName = fileName; 
00068     return 1;
00069 } 
00070 
00071 int CalibFeeWriter::setTimeWindow(int time){
00072     timeWindow = time; 
00073     return 1;
00074 }
00075 
00076 void CalibFeeWriter::setSubsite(int subSite)
00077 {
00078     this->subsite = subSite;
00079 }
00080 
00081 void CalibFeeWriter::setIsSim(bool isSim)
00082 {
00083     this->isSim = isSim;
00084 }
00085 /*
00086 void CalibFeeWriter::setSiteMask(int siteMask)
00087 {
00088     this->siteMask = siteMask;
00089 }
00090 */
00091 int CalibFeeWriter::init()
00092 {
00093 
00094 #ifdef I_LIKE_DUPLICITY
00095    myWriter = new DbiWriter<CalibFeeSpec>(range,aggNo,subsite,task);
00096 #else
00097    TimeStamp versionDate(0,0) ;
00098    UInt_t dbNo(0) ;
00099    const std::string logComment = "" ;
00100    const std::string tableName = "CalibFeeSpec" ;
00101    myWriter = new DbiWriter<GCalibFeeSpec>(range,aggNo,subsite,task, versionDate, dbNo, logComment, tableName );
00102 #endif
00103    return 1;
00104 }
00105 
00106 int CalibFeeWriter::final()
00107 {     
00108     cout<<"close DB"<<endl;
00109     myWriter->Close();
00110     return 1;
00111 }
00112 
00113 int CalibFeeWriter::run()
00114 {
00115     mainProcess();
00116 }
00117 
00118 int CalibFeeWriter::fillRow(){ 
00119 #ifdef I_LIKE_DUPLICITY
00120     CalibFeeSpec row;
00121 #else
00122 #endif
00123     ifstream input;
00124     input.open(inputFileName.c_str());
00125     if(!input){
00126       cout<<"can not open file : "<<inputFileName<<endl;
00127     }else{
00128       int channalId = 0;
00129       string channalIdDescribe;
00130       int status = 0;
00131       double pedestalHigh = 0;
00132       double sigmaPedestalHigh = 0;
00133       double pedestalLow = 0;
00134       double sigmapedestalLow = 0;
00135       double threshordHigh = 0;
00136       double threshordLow = 0;
00137       double fitChi2 = 0;
00138       double uselessData = 0;
00139       double ndf = 0;
00140       char buffer[500];
00141       input.getline(buffer, sizeof(buffer));
00142       input.getline(buffer, sizeof(buffer));
00143       while(input.peek()!=EOF)
00144       {
00145         input.getline(buffer, sizeof(buffer));
00146         istringstream(buffer)>>channalId
00147             >>channalIdDescribe
00148             //>>status
00149             //>>pedestalHigh
00150             //>>sigmaPedestalHigh
00151             >>pedestalLow
00152             >>uselessData
00153             >>sigmapedestalLow
00154             >>uselessData 
00155             //>>threshordHigh
00156             //>>threshordLow
00157             >>fitChi2
00158             >>ndf;
00159         cout<<channalId<<"   "
00160            <<channalIdDescribe<<"   "
00161            <<status<<"   "
00162            <<pedestalHigh<<"   "
00163            <<sigmaPedestalHigh<<"   "
00164            <<pedestalLow<<"   "
00165            <<sigmapedestalLow<<"   "
00166            <<threshordHigh<<"   "
00167            <<threshordLow<<endl;
00168 
00169 
00170 #ifdef I_LIKE_DUPLICITY
00171          row.SetCalibFeeSpec(
00172 #else
00173          GCalibFeeSpec row(
00174 #endif
00175                                channalId,
00176                                status,
00177                                pedestalHigh,
00178                                sigmaPedestalHigh,                               
00179                                pedestalLow,
00180                                sigmapedestalLow,
00181                                threshordHigh,
00182                                threshordLow);
00183 
00184 
00185          *myWriter << row;
00186         // writeToDB();
00187       }
00188     }
00189     return 1;
00190 } 
00191 
00192 
00193 
| 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