BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
UseEmc.cxx
Go to the documentation of this file.
1//$Header: /bes/bes/BossCvs/Calibration/CalibSvc/CalibROOTCnv/src/test/UseEmc.cxx,v 1.5
2//2008/04/08 08:34:13 huangb Exp $
3/*#include <stdio.h>
4#include "CalibData/CalibBase1.h"
5#include "CalibData/CalibModel.h"
6#include "CalibData/Emc/EmcCalibData.h"
7#include "CalibDataSvc/ICalibRootSvc.h"
8#include "GaudiKernel/AlgFactory.h"
9#include "GaudiKernel/Algorithm.h"
10#include "GaudiKernel/DataSvc.h"
11#include "GaudiKernel/IDataProviderSvc.h"
12#include "GaudiKernel/MsgStream.h"
13#include "GaudiKernel/Service.h"
14#include "GaudiKernel/SmartDataPtr.h"
15//using namespace std;
16/// Simple algorithm to test functioning of "the other" TDS
17class UseEmc : public Algorithm {
18
19public:
20 UseEmc(const std::string& name, ISvcLocator* pSvcLocator);
21
22 StatusCode initialize();
23
24 StatusCode execute();
25
26 StatusCode finalize();
27
28private:
29 IDataProviderSvc* m_pCalibDataSvc;
30 ICalibRootSvc* m_pRootSvc;
31 // Maybe something to say which kind of data to look up?
32
33};
34
35/// Instantiation of a static factory to create instances of this algorithm
36//static const AlgFactory<UseEmc> Factory;
37//const IAlgFactory& UseCalibFactory = Factory;
38//const IAlgFactory& UseEmcFactory = Factory;
39*/
40#include "UseEmc.h"
41UseEmc::UseEmc( const std::string& name, ISvcLocator* pSvcLocator )
42 : Algorithm( name, pSvcLocator ), m_pCalibDataSvc( 0 ) {
43 // Declare properties here.
44}
45
46StatusCode UseEmc::initialize() {
47 StatusCode sc;
48 MsgStream log( msgSvc(), name() );
49 log << MSG::INFO << "Initialize()" << endmsg;
50
51 // So far don't have any properties, but in case we do some day..
52 // setProperties();
53
54 log << MSG::INFO << "setProperties()" << endmsg;
55
56 sc = service( "CalibDataSvc", m_pCalibDataSvc, true );
57
58 if ( !sc.isSuccess() )
59 {
60 log << MSG::ERROR << "Could not get IDataProviderSvc interface of CalibXmlCnvSvc"
61 << endmsg;
62 return sc;
63 }
64 else
65 { log << MSG::DEBUG << "Retrieved IDataProviderSvc interface of CalibXmlCnvSvc" << endmsg; }
66
67 sc = service( "CalibRootCnvSvc", m_pRootSvc, true );
68 if ( !sc.isSuccess() )
69 {
70 log << MSG::ERROR << "Could not get ICalibRootSvc interface of CalibRootCnvSvc" << endmsg;
71 return sc;
72 }
73 // Get properties from the JobOptionsSvc
74
75 sc = setProperties();
76
77 return StatusCode::SUCCESS;
78}
79
80StatusCode UseEmc::execute() {
81
82 MsgStream log( msgSvc(), name() );
83 int i;
84 std::vector<double> emccalib;
86 // set emcCalibdata--------------------------------
87 for ( i = 0; i < 6000; i++ ) { emccalib.push_back( i ); }
88
89 emc->setDigiCalibConst( &emccalib );
90 emc->setrunfrm( 0 );
91 emc->setrunto( 0 );
92
93 // register the emcCalibData into the TCDS ; nelectable
94 std::string fullPath = "/Calib/EmcCal";
95 log << MSG::INFO << "execute() fullPath = " << fullPath << endmsg;
96 m_pCalibDataSvc->registerObject( fullPath, emc );
97
98 // write the EmcCalibData to the rootfile;
99 m_pRootSvc->writeToRoot( "./Emc_dat.root", fullPath );
100 // another way,write the EmcCalibData without TCDS
101 m_pRootSvc->writeToRoot( "./Emc_dat1.root", emc );
102 // retrieve DataObject from the TCDS-----------------
103 SmartDataPtr<CalibData::EmcCalibData> test( m_pCalibDataSvc, fullPath );
104 if ( !test )
105 ;
106 return StatusCode::SUCCESS;
107}
108StatusCode UseEmc::finalize() {
109
110 MsgStream log( msgSvc(), name() );
111 log << MSG::INFO << " UseEmc FINALIZE!! " << endmsg;
112
113 return StatusCode::SUCCESS;
114}
std::string test
IMessageSvc * msgSvc()
void setDigiCalibConst(const vector< double > *DigiCalibConst)
StatusCode initialize()
Definition UseEmc.cxx:46
StatusCode finalize()
Definition UseEmc.cxx:108
StatusCode execute()
Definition UseEmc.cxx:80
UseEmc(const std::string &name, ISvcLocator *pSvcLocator)
Definition UseEmc.cxx:41