/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Calibration/CalibSvc/CalibROOTCnv/CalibROOTCnv-00-01-13/src/test/UseEmc.cxx

Go to the documentation of this file.
00001 //$Header: /bes/bes/BossCvs/Calibration/CalibSvc/CalibROOTCnv/src/test/UseEmc.cxx,v 1.5 2008/04/08 08:34:13 huangb Exp $
00002 /*#include <stdio.h>
00003 #include "GaudiKernel/Algorithm.h"
00004 #include "GaudiKernel/AlgFactory.h"
00005 #include "GaudiKernel/IDataProviderSvc.h"
00006 #include "GaudiKernel/Service.h"
00007 #include "GaudiKernel/MsgStream.h"
00008 #include "GaudiKernel/SmartDataPtr.h"
00009 #include "CalibData/Emc/EmcCalibData.h"
00010 #include "CalibData/CalibModel.h"
00011 #include "GaudiKernel/DataSvc.h"
00012 #include "CalibDataSvc/ICalibRootSvc.h"
00013 #include "GaudiKernel/MsgStream.h"
00014 #include "CalibData/CalibModel.h"
00015 #include "CalibData/CalibBase1.h"
00016 //using namespace std;
00018 class UseEmc : public Algorithm {
00019 
00020 public:
00021   UseEmc(const std::string& name, ISvcLocator* pSvcLocator); 
00022 
00023   StatusCode initialize();
00024 
00025   StatusCode execute();
00026 
00027   StatusCode finalize();
00028 
00029 private:
00030   IDataProviderSvc* m_pCalibDataSvc;
00031   ICalibRootSvc*    m_pRootSvc;
00032   // Maybe something to say which kind of data to look up?
00033 
00034 };
00035 
00037 //static const AlgFactory<UseEmc> Factory;
00038 //const IAlgFactory& UseCalibFactory = Factory;
00039 //const IAlgFactory& UseEmcFactory = Factory;
00040 */
00041 #include "UseEmc.h"
00042 UseEmc::UseEmc( const std::string&  name, 
00043                     ISvcLocator*        pSvcLocator )
00044   : Algorithm     ( name, pSvcLocator ), m_pCalibDataSvc(0)
00045 {
00046   // Declare properties here.
00047 
00048 }
00049 
00050 
00051 StatusCode UseEmc::initialize() {
00052   StatusCode sc;
00053   MsgStream log(msgSvc(), name());
00054   log << MSG::INFO << "Initialize()" << endreq;
00055 
00056   // So far don't have any properties, but in case we do some day..
00057 //  setProperties();
00058 
00059    log<<MSG::INFO << "setProperties()" << endreq;
00060   
00061    sc = service("CalibDataSvc", m_pCalibDataSvc, true);
00062 
00063   if ( !sc.isSuccess() ) {
00064     log << MSG::ERROR 
00065         << "Could not get IDataProviderSvc interface of CalibXmlCnvSvc" 
00066         << endreq;
00067     return sc;
00068   } else {
00069     log << MSG::DEBUG 
00070         << "Retrieved IDataProviderSvc interface of CalibXmlCnvSvc" 
00071         << endreq;
00072   }
00073   
00074   sc = service("CalibRootCnvSvc", m_pRootSvc, true);
00075   if ( !sc.isSuccess() ) {
00076     log << MSG::ERROR 
00077         << "Could not get ICalibRootSvc interface of CalibRootCnvSvc" 
00078         << endreq;
00079     return sc;
00080   }
00081   // Get properties from the JobOptionsSvc
00082   
00083  sc = setProperties();
00084 
00085  return StatusCode::SUCCESS;
00086 
00087 }
00088 
00089 
00090 StatusCode UseEmc::execute( ) {
00091    
00092   MsgStream log(msgSvc(), name());
00093   int i;
00094   std::vector<double> emccalib;
00095   CalibData::EmcCalibData* emc = new CalibData::EmcCalibData;
00096   //set emcCalibdata--------------------------------
00097    for(i=0;i<6000;i++)
00098     {  emccalib.push_back(i);
00099     }
00100   
00101    emc->setDigiCalibConst(&emccalib);
00102   emc->setrunfrm(0);
00103   emc->setrunto(0);
00104  
00105    //register the emcCalibData into the TCDS ; nelectable
00106    std::string fullPath = "/Calib/EmcCal";
00107     log << MSG::INFO<<"execute() fullPath = "<<fullPath<< endreq;
00108     m_pCalibDataSvc->registerObject(fullPath,emc);
00109 
00110     //write the EmcCalibData to the rootfile; 
00111    m_pRootSvc->writeToRoot("./Emc_dat.root", fullPath);
00112    //another way,write the EmcCalibData without TCDS
00113    m_pRootSvc->writeToRoot("./Emc_dat1.root", emc);
00114   //retrieve DataObject from the TCDS-----------------
00115   SmartDataPtr<CalibData::EmcCalibData> test(m_pCalibDataSvc, fullPath);
00116   if(!test);
00117    return StatusCode::SUCCESS;
00118 }
00119 StatusCode UseEmc::finalize( ) {
00120 
00121   MsgStream log(msgSvc(), name());
00122   log << MSG::INFO 
00123       << "        UseEmc FINALIZE!! "
00124       << endreq;
00125   
00126   return StatusCode::SUCCESS;
00127 }
00128 
00129 

Generated on Tue Nov 29 22:57:51 2016 for BOSS_7.0.2 by  doxygen 1.4.7