BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
CalibTreeCnvSvc.cxx
Go to the documentation of this file.
1
2#include "GaudiKernel/IDetDataSvc.h"
3#include "GaudiKernel/IConversionSvc.h"
4#include "GaudiKernel/IConverter.h"
5
6#include "GaudiKernel/MsgStream.h"
7#include "GaudiKernel/SvcFactory.h"
8#include "GaudiKernel/CnvFactory.h"
9#include "GaudiKernel/ISvcLocator.h"
10#include "GaudiKernel/IDataProviderSvc.h"
11#include "GaudiKernel/GenericAddress.h"
13#include "CalibData/CalibBase.h"
14#include "cnv/TreeCalBaseCnv.h"
17// Make instances only via static factory class
18//static SvcFactory<CalibTreeCnvSvc> calibRootCnvSvc_factory;
19//const ISvcFactory& CalibTreeCnvSvcFactory = calibRootCnvSvc_factory;
20DECLARE_COMPONENT(CalibTreeCnvSvc)
21CalibTreeCnvSvc::CalibTreeCnvSvc(const std::string& name, ISvcLocator* svc) :
22 ConversionSvc(name, svc, CALIBTREE_StorageType),
23 m_detPersSvc(0), m_detDataSvc(0) {
24
25 //huangb add
26}
27
28/*StatusCode CalibTreeCnvSvc::queryInterface(const InterfaceID& riid,
29 void** ppvInterface) {
30 // Uncomment if choose to derive from abstract root conv. interface
31 if (IID_ICalibTreeSvc.versionMatch(riid)) {
32 *ppvInterface = (ICalibTreeSvc*)this;
33 }
34 else {
35 // Interface is not directly availible: try out a base class
36 return ConversionSvc::queryInterface(riid, ppvInterface);
37 // }
38 addRef();
39 }
40 return StatusCode::SUCCESS;
41}
42*/
43
45 StatusCode sc = ConversionSvc::initialize();
46
47 MsgStream log(msgSvc(), "CalibTreeCnvSvc");
48
49 if (!sc.isSuccess()) return sc;
50
51 // Locate the Calib Data Service. Since it inherits from DataSvc
52 // it has to implement IDataProviderSvc
53 m_detDataSvc = 0;
54 /*sc = serviceLocator()->getService
55 ("CalibDataSvc", IID_IDataProviderSvc,(IInterface*&) m_detDataSvc);*/
56 sc = serviceLocator()->getService
57 ("CalibDataSvc", IDataProviderSvc::interfaceID(),(IInterface*&) m_detDataSvc);
58 if ( !sc.isSuccess() ) {
59 log << MSG::ERROR << "Could not locate CalibDataSvc" << endreq;
60 return sc;
61 }
62
63 /* IInstrumentName* iInstrumentName;
64 sc = m_detDataSvc->queryInterface(IID_IInstrumentName,
65 (void**) &iInstrumentName);
66*/
67 // Set the CalibDataSvc as data provider service
68 sc = setDataProvider(m_detDataSvc);
69 if ( !sc.isSuccess() ) {
70 log << MSG::ERROR << "Could not set data provider" << endreq;
71 return sc;
72 }
73 //huangb add
74 sc = setProperties();
75
76 // Locate IConversionSvc interface of the DetectorPersistencySvc
77 sc = serviceLocator()->service
78 ("DetectorPersistencySvc", m_detPersSvc, true);
79 if ( !sc.isSuccess() ) {
80 log << MSG::ERROR
81 << "Cannot locate IConversionSvc interface of DetectorPersistencySvc"
82 << endreq;
83 return sc;
84 } else {
85 log << MSG::DEBUG
86 << "Retrieved IConversionSvc interface of DetectorPersistencySvc"
87 << endreq;
88 }
89
90 // Query the IAddressCreator interface of the detector persistency service
91 IAddressCreator* iAddrCreator;
92 /*sc = m_detPersSvc->queryInterface(IID_IAddressCreator,
93 (void**) &iAddrCreator);*/
94 sc = m_detPersSvc->queryInterface(IAddressCreator::interfaceID(),
95 (void**) &iAddrCreator);
96 if ( !sc.isSuccess() ) {
97 log << MSG::ERROR
98 << "Cannot query IAddressCreator interface of DetectorPersistencySvc"
99 << endreq;
100 return sc;
101 } else {
102 log << MSG::DEBUG
103 << "Retrieved IAddressCreator interface of DetectorPersistencySvc"
104 << endreq;
105 }
106 log << MSG::DEBUG
107 << "Set it as the address creator of the CalibTreeCnvSvc" << endreq;
108 sc = setAddressCreator(iAddrCreator);
109 if ( !sc.isSuccess() ) {
110 log << MSG::ERROR << "Cannot set the address creator" << endreq;
111 return sc;
112 }
113
114 // set properties if there are any??
115
116 return sc;
117}
118
120 // If anything was allocated, get rid of it. So far, nothing was.
121
122 return ConversionSvc::finalize();
123}
124
125 StatusCode CalibTreeCnvSvc::createAddress(long svc_type,
126 const CLID& clid,
127 const std::string* par,
128 const unsigned long* ip,
129 IOpaqueAddress*& refpAddress) {
130 //createAddress of CalibTreeCnvSvc
131 MsgStream log( msgSvc(), name() );
132 if (svc_type != CALIBTREE_StorageType) {
133 log << MSG::ERROR << "bad storage type" << (int)svc_type << endreq;
134 return StatusCode::FAILURE;
135 }
136 std::string dataIdent;
137 std::string fullpath;
138 int index ;
139 if(clid==CLID_Calib_MdcCal)
140 { index=0;}
141 else if(clid==CLID_Calib_TofCal)
142 {index =1;}
143 else if(clid==CLID_Calib_DedxCal)
144 {index =2;}
145 else if(clid==CLID_Calib_EmcCal)
146 {index =3;}
147 else{
148 log << MSG::WARNING<<"Wrong CLID"<<endreq;
149 }
150
151 //see if svctype set in the CalibDataSvc is MYSQL_StorageType or CALIBROOT_StorageType
152/* IInstrumentName* iInstrumentName;
153 StatusCode sc = m_detDataSvc->queryInterface(IID_IInstrumentName,
154 (void**) &iInstrumentName);
155
156 if ( !sc.isSuccess() ) {
157 log << MSG::ERROR
158 << "Cannot query IInstrumentName interface of CalibDataSvc"
159 << endreq;
160 return sc;
161 } else {
162 log << MSG::DEBUG
163 << "Retrieved IInstrumentName interface of CalibDataSvc"
164 << endreq;
165 }
166
167 int svctype = iInstrumentName->getsvctype();
168 if(svctype== CALIBROOT_StorageType)
169 {
170 dataIdent = m_rootfile[index];
171 fullpath = par[0];
172 }
173
174 if(svctype== MYSQL_StorageType)
175 { log << MSG::INFO<<"rootfile is not set in the jobOption,get it from MySQL"<<endreq;
176 dataIdent = par[0];
177 fullpath = par[1];
178 }
179
180 if ((svctype != CALIBROOT_StorageType)&&(svctype!= MYSQL_StorageType)) {
181 log << MSG::ERROR << "bad storage type" << (int)svctype << endreq;
182 return StatusCode::FAILURE;
183 }
184*/
185 // std::string dataIdent(par[0]); // file identifier for PDS version of data
186 // log << MSG::INFO<<"dataIdent is:"<<dataIdent<<endreq;
187 //std::string fullpath(par[1]); // path within TCDS for the object
188 // log << MSG::INFO<<"fullpath is :"<<fullpath<<endreq;
189
190
191 int runfrm = ip[0];
192 int runto = ip[1];
193 dataIdent = par[0];
194 fullpath = par[1];
195
196 // for now have to ignore fmtVersion because of defective implementation
197 // of GenericAddress. If we want it, should probably write new
198 // opaque address implementation for this package to use. All
199 // dealings with (calibration) opaque addresses are confined to
200 // the CalibSvc package.
201 refpAddress = new GenericAddress(CALIBTREE_StorageType,
202 clid,
203 dataIdent,
204 fullpath,
205 runfrm,
206 runto);
207
208
209 return StatusCode::SUCCESS;
210
211}
212
213
214StatusCode CalibTreeCnvSvc::updateObj(IOpaqueAddress* pAddress,
215 DataObject* pObject ) {
216
217 // using facilities::Timestamp;
218
219 MsgStream log(msgSvc(), "CalibTreeCnvSvc" );
220
221 // Don't update when we're using enter time
222 log << MSG::DEBUG << "CalibTreeCnvSvc::updateObj starting ...."<<endreq;
223}
const CLID CLID_Calib_EmcCal
Definition CalibModel.h:47
const CLID CLID_Calib_DedxCal
Definition CalibModel.h:45
const CLID CLID_Calib_MdcCal
Definition CalibModel.h:41
const CLID CLID_Calib_TofCal
Definition CalibModel.h:43
unsigned const char CALIBTREE_StorageType
IMessageSvc * msgSvc()
virtual StatusCode finalize()
virtual StatusCode initialize()
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *pObject)
virtual StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)