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