BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
CalibMySQLCnvSvc.cxx
Go to the documentation of this file.
1// $Header: /bes/bes/BossCvs/Calibration/CalibSvc/CalibMySQLCnv/src/CalibMySQLCnvSvc.cxx,v 1.58
2// 2022/02/21 06:01:56 maqm Exp $
3#include "GaudiKernel/DataObject.h"
4#include "GaudiKernel/GenericAddress.h"
5#include "GaudiKernel/IConverter.h"
6#include "GaudiKernel/IDataManagerSvc.h"
7#include "GaudiKernel/IDataProviderSvc.h"
8#include "GaudiKernel/IDetDataSvc.h"
9#include "GaudiKernel/IOpaqueAddress.h"
10#include "GaudiKernel/ISvcLocator.h"
11#include "GaudiKernel/IValidity.h"
12#include "GaudiKernel/MsgStream.h"
13#include "GaudiKernel/SmartDataPtr.h"
14#include "TBuffer.h"
15#include "TBufferFile.h"
16#include "TFile.h"
17#include "TROOT.h"
18#include "TTree.h"
19#include <cstdio>
20#include <iostream>
21#include <stdexcept>
22#include <string>
23
24#include "CalibDataSvc/ICalibRootSvc.h" // for def. of CALIBROOT_StorageType
25#include "CalibDataSvc/ICalibTreeSvc.h"
26
27#include "calibUtil/Metadata.h"
28
29#include "CalibData/CalibBase.h"
30#include "CalibData/CalibBase1.h"
31#include "CalibData/CalibModelSvc.h"
32// #include "CalibData/CalibTime.h"
33
34#include "DatabaseSvc/IDatabaseSvc.h"
35#include "EventModel/EventHeader.h"
36#include "EventModel/EventModel.h"
37
38// #include "GaudiKernel/SvcFactory.h"
39
40#include "CalibMySQLCnvSvc.h"
41#include "CalibMySQLCnvSvc/TreeAddress.h"
42
44using namespace CalibData;
45/// Instantiation of a static factory to create instances of this service
46// static SvcFactory<CalibMySQLCnvSvc> CalibMySQLCnvSvc_factory;
47// const ISvcFactory& CalibMySQLCnvSvcFactory = CalibMySQLCnvSvc_factory;
48
49// Local utility to translate calibration quality list to bit map
50namespace {
51 unsigned int toQualityMask( std::vector<std::string>& qualities ) {
53
54 unsigned int mask = 0;
55 unsigned n = qualities.size();
56
57 for ( unsigned i = 0; i < n; i++ )
58 {
59 std::string iString = qualities[i];
60 if ( iString.size() < 3 ) continue;
61 iString.resize( 3 );
62 if ( iString == "PRO" ) mask |= Metadata::LEVELProd;
63 else if ( iString == "DEV" ) mask |= Metadata::LEVELDev;
64 else if ( iString == "TES" ) mask |= Metadata::LEVELTest;
65 else if ( iString == "SUP" ) mask |= Metadata::LEVELSuperseded;
66 }
67 return mask;
68 }
69} // namespace
70
71CalibMySQLCnvSvc::CalibMySQLCnvSvc( const std::string& name, ISvcLocator* svc )
72 : ConversionSvc( name, svc, MYSQL_StorageType )
73 , m_meta( 0 )
74 , m_useEventTime( true )
75 , m_enterTimeStart( 0 )
76 , m_enterTimeEnd( 0 )
77 , m_qualityMask( 0 ) {
78 // declareProperty("Host", m_host = "202.122.37.69");
79 declareProperty( "Host", m_host = "bes3db2.ihep.ac.cn" );
80 declareProperty( "UseEventTime", m_useEventTime = true );
81 declareProperty( "EnterTimeEnd", m_enterTimeEndString = std::string( "" ) );
82 declareProperty( "EnterTimeStart", m_enterTimeStartString = std::string( "" ) );
83 // declareProperty("DbName", m_dbName = std::string("calib") );
84 declareProperty( "DbName", m_dbName = std::string( "offlinedb" ) );
85 declareProperty( "QualityList", m_qualityList );
86 declareProperty( "CrashOnError", m_crash = true );
87 declareProperty( "Sft_Ver", sft_ver );
88 declareProperty( "Cal_Ver", cal_ver );
89 declareProperty( "MdcFlag", m_flag[0] = "default" );
90 declareProperty( "DeDxFlag", m_flag[1] = "default" );
91 declareProperty( "EmcFlag", m_flag[2] = "default" );
92 declareProperty( "TofFlag", m_flag[3] = "default" );
93 declareProperty( "MucFlag", m_flag[4] = "default" );
94 declareProperty( "EsTimeFlag", m_flag[5] = "default" );
95 declareProperty( "EstTofFlag", m_flag[6] = "default" );
96 declareProperty( "MdcAlignFlag", m_flag[7] = "default" );
97 declareProperty( "TofQElecFlag", m_flag[8] = "default" );
98 declareProperty( "TofSimPFlag", m_flag[9] = "default" );
99 declareProperty( "DedxSimFlag", m_flag[10] = "default" );
100 declareProperty( "MdcDataFlag", m_flag[11] = "default" );
101 // Top_up Qiumei Ma
102 declareProperty( "InjSigIntervalFlag", m_flag[12] = "default" );
103 declareProperty( "InjSigTimeFlag", m_flag[13] = "default" );
104 declareProperty( "OffEvtFilterFlag", m_flag[14] = "default" );
105 declareProperty( "CorrectedETSFlag", m_flag[15] = "default" );
106
107 declareProperty( "MdcCalPar", m_calPar[0] = "default" );
108 declareProperty( "DeDxCalPar", m_calPar[1] = "default" );
109 declareProperty( "EmcCalPar", m_calPar[2] = "default" );
110 declareProperty( "TofCalPar", m_calPar[3] = "default" );
111 declareProperty( "MucCalPar", m_calPar[4] = "default" );
112 declareProperty( "EsTimeCalPar", m_calPar[5] = "default" );
113 declareProperty( "EstTofCalPar", m_calPar[6] = "default" );
114 declareProperty( "MdcAlignPar", m_calPar[7] = "default" );
115 declareProperty( "TofQElecPar", m_calPar[8] = "default" );
116 declareProperty( "TofSimPar", m_calPar[9] = "default" );
117 declareProperty( "DedxSimPar", m_calPar[10] = "default" );
118 declareProperty( "MdcDataConstVer", m_calPar[11] = "default" );
119 // Top_up Qiumei Ma
120 declareProperty( "InjSigIntervalPar", m_calPar[12] = "default" );
121 declareProperty( "InjSigTimePar", m_calPar[13] = "default" );
122 declareProperty( "OffEvtFilterPar", m_calPar[14] = "default" );
123 declareProperty( "CorrectedETSPar", m_calPar[15] = "default" );
124
125 declareProperty( "MdcBossVer", m_bossver[0] = "default" );
126 declareProperty( "DeDxBossVer", m_bossver[1] = "default" );
127 declareProperty( "EmcBossVer", m_bossver[2] = "default" );
128 declareProperty( "TofBossVer", m_bossver[3] = "default" );
129 declareProperty( "MucBossVer", m_bossver[4] = "default" );
130 declareProperty( "EsTimeBossVer", m_bossver[5] = "default" );
131 declareProperty( "EstTofBossVer", m_bossver[6] = "default" );
132 declareProperty( "MdcAlignBossVer", m_bossver[7] = "default" );
133 declareProperty( "TofQElecBossVer", m_bossver[8] = "default" );
134 declareProperty( "TofSimBossVer", m_bossver[9] = "default" );
135 declareProperty( "DedxSimBossVer", m_bossver[10] = "default" );
136 declareProperty( "MdcDataConstBossVer", m_bossver[11] = "default" );
137 declareProperty( "InjSigIntervalBossVer", m_bossver[12] = "default" );
138 declareProperty( "InjSigTimeBossVer", m_bossver[13] = "default" );
139 declareProperty( "OffEvtFilterBossVer", m_bossver[14] = "default" );
140 declareProperty( "Align_RunNo", m_MdcAlign_No = 8093 );
141 declareProperty( "Db_Status", m_dbStatus = "OK" );
142 declareProperty( "BossRelease", m_bossRelease = "default" );
143}
144
146
148 // Initialize base class
149 StatusCode sc = ConversionSvc::initialize();
150 if ( !sc.isSuccess() ) return sc;
151
152 MsgStream log( msgSvc(), "CalibMySQLCnvSvc" );
153 log << MSG::INFO << "Specific initialization starting" << endmsg;
154
155 IDataProviderSvc* pCDS = 0;
156
157 sc = serviceLocator()->getService( "CalibDataSvc", IDataProviderSvc::interfaceID(),
158 (IInterface*&)pCDS );
159
160 if ( !sc.isSuccess() )
161 {
162 log << MSG::ERROR << "Could not locate CalibDataSvc" << endmsg;
163 return sc;
164 }
165
166 sc = serviceLocator()->service( "EventDataSvc", m_eventSvc, true );
167 if ( sc.isFailure() )
168 {
169 log << MSG::ERROR << "Unable to find EventDataSvc " << endmsg;
170 return sc;
171 }
172
173 // Set the CalibDataSvc as data provider service
174 sc = setDataProvider( pCDS );
175 if ( !sc.isSuccess() )
176 {
177 log << MSG::ERROR << "Could not set data provider" << endmsg;
178 return sc;
179 }
180
181 // Query the IAddressCreator interface of the detector persistency service
182
183 sc = serviceLocator()->service( "DetectorPersistencySvc", m_detPersSvc, true );
184 if ( !sc.isSuccess() )
185 {
186 log << MSG::ERROR << "Cannot locate IConversionSvc interface of DetectorPersistencySvc"
187 << endmsg;
188 return sc;
189 }
190 else
191 {
192 log << MSG::DEBUG << "Retrieved IConversionSvc interface of DetectorPersistencySvc"
193 << endmsg;
194 }
195
196 IAddressCreator* iAddrCreator;
197 sc = m_detPersSvc->queryInterface( IAddressCreator::interfaceID(), (void**)&iAddrCreator );
198 // sc = m_detPersSvc->queryInterface(IID_IAddressCreator,(void**) &iAddrCreator);
199 if ( !sc.isSuccess() )
200 {
201 log << MSG::ERROR << "Could not locate CalibDataSvc" << endmsg;
202 return sc;
203 }
204
205 sc = setAddressCreator( iAddrCreator );
206 if ( !sc.isSuccess() )
207 {
208 log << MSG::ERROR << "Cannot set the address creator" << endmsg;
209 return sc;
210 }
211
212 // Get properties from the JobOptionsSvc
213 // sc = setProperties();
214 if ( !sc.isSuccess() )
215 {
216 log << MSG::ERROR << "Could not set jobOptions properties" << endmsg;
217 return sc;
218 }
219 log << MSG::DEBUG << "Properties were read from jobOptions" << endmsg;
220
221 // Translate list of calibration quality names to bit mask form used
222 // by calibUtil::Metadata::findBest Defaults to PROD + DEV for now
223 // (that was old fixed value)
224 m_qualityMask = toQualityMask( m_qualityList );
225 if ( !m_qualityMask )
227
228 // Make a calibUtil::Metadata instance
229 // Conceivably, could start up a different conversion service, depending
230 // on job options parameters, which would look very much like this one
231 // except for having a different way to access metadata.
232 m_meta = new calibUtil::Metadata( m_host, "*", m_dbName );
233
234 if ( !m_meta )
235 {
236 log << MSG::ERROR << "Could not open connection to metadata dbs" << endmsg;
237 return StatusCode::FAILURE;
238 }
239
240 // Probably should get this value from job options.
241 // Now we do. See m_qualityMask, m_qualityList
242 // m_calibLevelMask = calibUtil::Metadata::LEVELProd +
243 // calibUtil::Metadata::LEVELDev;
244
245 log << MSG::INFO << "Specific initialization completed" << endmsg;
246 return sc;
247}
248
250 MsgStream log( msgSvc(), "CalibMySQLCnvSvc" );
251 log << MSG::DEBUG << "Finalizing" << endmsg;
252 delete m_meta;
253 m_meta = 0;
254 return ConversionSvc::finalize();
255}
256
257/*StatusCode CalibMySQLCnvSvc::queryInterface(const InterfaceID& riid,
258 void** ppvInterface)
259{
260 if ( IID_ICalibMetaCnvSvc == riid ) {
261 // With the highest priority return the specific interface of this service
262 *ppvInterface = (ICalibMetaCnvSvc*)this;
263 } else {
264 // Interface is not directly available: try out a base class
265 return ConversionSvc::queryInterface(riid, ppvInterface);
266 }
267 addRef();
268 return StatusCode::SUCCESS;
269}*/
270
271/// Create a transient representation from another representation of an object.
272/// Overloaded from ConversionSvc because CalibMySQLCnvSvc has no converters.
273/// (The typical conversion service delegates this to an appropriate converter)
274StatusCode CalibMySQLCnvSvc::createObj( IOpaqueAddress* pAddress, DataObject*& refpObject ) {
275
276 MsgStream log( msgSvc(), "CalibMySQLCnvSvc" );
277
278 // Create the object according to calib type, flavor, time, instrument, clid.
279 // Notice that the CalibMySQLCnvSvc has no converters of its own:
280 // object creation is delegated to another CnvSvc via a temporary address
281 // The IOpaqueAddress specifies calibration type and specific flavor.
282 // The secondary storage type is always discovered dynamically
283 StatusCode sc;
284 sc = createCalib( refpObject, pAddress->par()[0], pAddress->clID(), pAddress->registry() );
285
286 if ( !sc.isSuccess() )
287 { log << MSG::ERROR << "Could not create calib DataObject" << endmsg; }
288 log << MSG::DEBUG << "Method createObj exiting" << endmsg;
289 return sc;
290}
291
292/// Resolve the references of the created transient object.
293/// (Actually, don't, because this operation isn't supported, nor is
294/// it needed for the conversion service.)
295/// Overloaded from ConversionSvc because CalibMySQLCnvSvc has no converters.
296StatusCode CalibMySQLCnvSvc::fillObjRefs( IOpaqueAddress* /*pAddress*/,
297 DataObject* /*pObject */ ) {
298 MsgStream log( msgSvc(), "CalibMySQLCnvSvc" );
299 return StatusCode::SUCCESS;
300}
301
302/// Update a transient representation from another representation of an object.
303/// Overloaded from ConversionSvc because CalibMySQLCnvSvc has no converters.
304StatusCode CalibMySQLCnvSvc::updateObj( IOpaqueAddress* pAddress, DataObject* pObject ) {
305
306 // using facilities::Timestamp;
307
308 MsgStream log( msgSvc(), "CalibMySQLCnvSvc" );
309
310 // Don't update when we're using enter time
311 log << MSG::DEBUG << "CalibMySQLCnvSvc::updateObj starting ...." << endmsg;
312
313 if ( 0 == pObject )
314 {
315 log << MSG::ERROR << "There is no object to update" << endmsg;
316 return StatusCode::FAILURE;
317 }
318
319 StatusCode sc =
320 updateCalib( pObject, pAddress->par()[0], pAddress->clID(), pAddress->registry() );
321 if ( !sc.isSuccess() )
322 {
323 log << MSG::ERROR << "Could not update calib DataObject" << endmsg;
324 return sc;
325 }
326
327 return StatusCode::SUCCESS;
328}
329
330/// Update the references of an updated transient object. [actually, don't.
331/// Calib data doesn't have any inter-object references.]
332/// Overloaded from ConversionSvc because CalibMySQLCnvSvc has no converters.
333StatusCode CalibMySQLCnvSvc::updateObjRefs( IOpaqueAddress* /*pAddress*/,
334 DataObject* /*pObject */ ) {
335 MsgStream log( msgSvc(), "CalibMySQLCnvSvc" );
336 return StatusCode::SUCCESS;
337}
338
339/// Convert a transient object to a requested representation. Not implemented.
340/// Overloaded from ConversionSvc because CalibMySQLCnvSvc has no converters.
341StatusCode CalibMySQLCnvSvc::createRep( DataObject* /*pObject*/,
342 IOpaqueAddress*& /*refpAddress*/ ) {
343
344 MsgStream log( msgSvc(), "CalibMySQLCnvSvc" );
345 // log << MSG::WARNING << "Method createRep is not implemented" << endmsg;
346 return StatusCode::SUCCESS;
347}
348
349/// Resolve the references of a converted object. [actually, don't.
350/// Calib data doesn't have any inter-object references.]
351/// Overloaded from ConversionSvc because CalibMySQLCnvSvc has no converters.
352StatusCode CalibMySQLCnvSvc::fillRepRefs( IOpaqueAddress* /*pAddress*/,
353 DataObject* /*pObject */ ) {
354 MsgStream log( msgSvc(), "CalibMySQLCnvSvc" );
355 // log << MSG::WARNING << "Method fillRepRefs is not implemented" << endmsg;
356 return StatusCode::SUCCESS;
357}
358
359/// Update a converted representation of a transient object.
360/// Overloaded from ConversionSvc because CalibMySQLCnvSvc has no converters.
361StatusCode CalibMySQLCnvSvc::updateRep( IOpaqueAddress* /*pAddress*/,
362 DataObject* /*pObject */ ) {
363 MsgStream log( msgSvc(), "CalibMySQLCnvSvc" );
364 // log << MSG::WARNING << "Method updateRep is not implemented" << endmsg;
365 return StatusCode::SUCCESS;
366}
367
368/// Update the references of an already converted object.
369/// Overloaded from ConversionSvc because CalibMySQLCnvSvc has no converters.
370/// Don't do anything because calib objects have no inter-object references.
371StatusCode CalibMySQLCnvSvc::updateRepRefs( IOpaqueAddress* /*pAddress*/,
372 DataObject* /*pObject */ ) {
373 MsgStream log( msgSvc(), "CalibMySQLCnvSvc" );
374 // log << MSG::WARNING << "Method updateRepRefs is not implemented" << endmsg;
375 return StatusCode::SUCCESS;
376}
377
378/// Overload ConversionSvc implementation of createAddress.
379/// Create an address using explicit arguments to identify a single object.
380/// Par[0] is full path in calibration TDS
381StatusCode CalibMySQLCnvSvc::createAddress( long svc_type, const CLID& clid,
382 const std::string* par,
383 const unsigned long* /*ipar*/,
384 IOpaqueAddress*& refpAddress ) {
385 // First check that requested address is of type MYSQL_StorageType
386 MsgStream log( msgSvc(), "CalibMySQLCnvSvc" );
387 if ( svc_type != MYSQL_StorageType )
388 {
389 log << MSG::ERROR << "Cannot create addresses of type " << (int)svc_type
390 << " which is different from " << (int)MYSQL_StorageType << endmsg;
391 return StatusCode::FAILURE;
392 }
393 log << MSG::INFO << " create address in CalibMySQLCnvSvc " << endmsg;
394
395 refpAddress = new GenericAddress( MYSQL_StorageType, clid, par[0] );
396
397 return StatusCode::SUCCESS;
398}
399
400// select sftver and parver frm table CalVtxLum
401StatusCode CalibMySQLCnvSvc::getSftParVer( std::string& SftVer, std::string& CalParVer,
402 int& runfrm, int& runto, int RunNo,
403 std::string BossRelease, std::string DataType ) {
404 using namespace rdbModel;
405 MsgStream log( msgSvc(), "CalibMySQLCnvSvc" );
406 char stmt[300];
407 int run_No = RunNo;
408 MYSQL_RES* res_set;
409 IDatabaseSvc* m_dbsvc;
410 DatabaseRecordVector res, res1;
411 StatusCode sc = serviceLocator()->service( "DatabaseSvc", m_dbsvc, true );
412 if ( sc.isFailure() )
413 {
414 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
415 return sc;
416 }
417 const char* bossRelease = BossRelease.c_str();
418 const char* dataType = DataType.c_str();
419
420 sprintf( stmt,
421 "select RunFrom,RunTo,SftVer,ParVer from CalVtxLumVer where BossRelease = '%s' and "
422 "RunFrom <= %d and RunTo "
423 ">= %d and DataType='%s' ",
424 bossRelease, run_No, run_No, dataType );
425
426 int row_no = m_dbsvc->query( "offlinedb", stmt, res );
427 if ( row_no < 1 )
428 {
429 std::cout << "ERROR:error searching with:" << stmt << std::endl;
430 exit( 1 );
431 }
432 if ( row_no = 1 )
433 {
434 DatabaseRecord* records1 = res[0];
435 runfrm = records1->GetInt( "RunFrom" );
436 runto = records1->GetInt( "RunTo" );
437 cout << dataType << " runfrm,runto in getSftParVer is:" << runfrm << "::::" << runto
438 << endl;
439 SftVer = records1->GetString( "SftVer" );
440 CalParVer = records1->GetString( "ParVer" );
441 }
442 if ( row_no > 1 )
443 {
444 cout << "ERROR: " << dataType << " set overlapped run number in the table CalVtxLumVer"
445 << endl;
446 exit( 1 );
447 }
448 // cout<<"getSftParVer end()::::getSftParVer"<<endl;
449 return StatusCode::SUCCESS;
450}
451
452/// Create a calib DataObject by calib type, flavor, time and instrument.
453/// This method does not register DataObject in the transient data store,
454/// [but may register TDS addresses for its children if needed (e.g. Catalog).
455/// - what's all this about? ]
456/// The string storage type is discovered at runtime in the metadata dbs
457/// The entry name identifies a condition amongst the many in the string.
458/// Implementation:
459/// - create a temporary address containing storage type and classID;
460/// - dispatch to appropriate conversion service according to storage type;
461/// - this will dispatch to appropriate converter according to CLID
462/// (CalibMySQLCnvSvc has no converters of its own).
463
464StatusCode CalibMySQLCnvSvc::createCalib( DataObject*& refpObject, const std::string& fullpath,
465 const CLID& classID, IRegistry* entry ) {
466 MsgStream log( msgSvc(), "CalibMySQLCnvSvc" );
467
468 debug() << "In createCalib, fullpath = " << fullpath << endmsg;
469
470 // Look up calib object in the Metadata database
471 std::string cType = CalibData::CalibModelSvc::getCalibType( fullpath );
472
473 debug() << "org-ctype = " << cType << endmsg;
474
475 // ..and extra special munging for test
476 if ( std::string( "Test" ) == cType.substr( 0, 4 ) ) { cType = std::string( "Test_Gen" ); }
477
478 debug() << "ctype = " << cType << endmsg;
479
480 std::string testfile = std::string( getenv( "CALIBMYSQLCNVROOT" ) ) + "/share/test.root";
481 TFile* f1 = new TFile( testfile.c_str(), "read" );
482 unsigned int ser = 0;
483 // runfrm,runto are the value from the table ***CalConst;runfrm1,runto1 are the value from
484 // the table CalVtxLumVer
485 int runfrm, runfrm1;
486 int runto, runto1;
487 std::string flag = "default";
489
490 MSG::Level msgLevel = MSG::DEBUG;
491
492 std::string physFmt = "UNK";
493 std::string fmtVersion;
494 std::string dataIdent;
495
496 // Get the runNo of current event:
497 SmartDataPtr<Event::EventHeader> evt( m_eventSvc, "/Event/EventHeader" );
498 int runNo = 0, FirstEvent = 0;
499 if ( !evt )
500 {
501 log << MSG::WARNING << "Unable to read the Event for TDS" << endmsg;
502 // return StatusCode::FAILURE;
503 }
504 if ( evt )
505 {
506 if ( cType != "TofCal" && cType != "EstTofCal" && cType != "TofSim" && cType != "DedxSim" )
507 runNo = fabs( evt->runNumber() );
508 if ( cType == "TofCal" || cType == "EstTofCal" || cType == "TofSim" || cType == "DedxSim" )
509 runNo = evt->runNumber();
510 FirstEvent = evt->eventNumber();
511 }
512 DatabaseRecordVector res, res1;
513
514 StatusCode st1;
515
516 // TofCalConst
517 if ( ( cType == "TofCal" ) && ( m_bossver[3] == "default" ) )
518 {
519 std::string cType = "Tof";
520 if ( m_bossRelease == "default" )
521 {
522 log << MSG::FATAL << " Boss Release for TofCal not set!" << endmsg;
523 exit( 1 );
524 }
525 else
526 {
527 st1 = getSftParVer( m_bossver[3], m_calPar[3], runfrm1, runto1, runNo, m_bossRelease,
528 cType );
529 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
530 if ( st1.isFailure() )
531 {
532 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
533 return st1;
534 }
535 // cout<<"SftVer and CalParVer are:"<<sft_ver<<";"<<cal_ver<<endl;
536 ret = m_meta->getReadTOFInfo( ser, &runfrm, &runto, m_calPar[3], res, runNo,
537 m_bossver[3] );
538 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
539 }
540 }
541 else if ( ( cType == "TofCal" ) && ( m_bossver[3] != "default" ) )
542 {
543 m_flag[3] = "set";
544 flag = m_flag[3];
545 // cout<<"flag @create Tof is:"<<m_flag[3]<<endl;
546 ret =
547 m_meta->getReadTOFInfo( ser, &runfrm, &runto, m_calPar[3], res, runNo, m_bossver[3] );
548 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
549 }
550
551 // EmcCalConst
552 if ( ( cType == "EmcCal" ) && ( m_bossver[2] == "default" ) )
553 {
554 std::string cType = "Emc";
555 if ( m_bossRelease == "default" )
556 {
557 log << MSG::FATAL << " Boss Release for EmcCal not set!" << endmsg;
558 exit( 1 );
559 }
560 else
561 {
562
563 st1 = getSftParVer( m_bossver[2], m_calPar[2], runfrm1, runto1, runNo, m_bossRelease,
564 cType );
565 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
566 // cout<<"flag @create Emc is:"<<flag<<endl;
567 if ( st1.isFailure() )
568 {
569 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
570 return st1;
571 }
572 ret = m_meta->getReadEMCInfo( ser, &runfrm, &runto, m_calPar[2], res, runNo,
573 m_bossver[2] );
574 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
575 }
576 }
577 else if ( ( cType == "EmcCal" ) && ( m_bossver[2] != "default" ) )
578 {
579 m_flag[2] = "set";
580 flag = m_flag[2];
581 // cout<<"flag @create Emc is:"<<m_flag[2]<<endl;
582 ret =
583 m_meta->getReadEMCInfo( ser, &runfrm, &runto, m_calPar[2], res, runNo, m_bossver[2] );
584 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
585 }
586
587 // DedxCalConst
588 if ( ( cType == "DedxCal" ) && ( m_bossver[1] == "default" ) )
589 {
590 std::string cType = "Dedx";
591 if ( m_bossRelease == "default" )
592 {
593 log << MSG::FATAL << " Boss Release for DedxCal not set!" << endmsg;
594 exit( 1 );
595 }
596 else
597 {
598 st1 = getSftParVer( m_bossver[1], m_calPar[1], runfrm1, runto1, runNo, m_bossRelease,
599 cType );
600 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
601 if ( st1.isFailure() )
602 {
603 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
604 return st1;
605 }
606 ret = m_meta->getReadDedxInfo( ser, &runfrm, &runto, m_calPar[1], res, runNo,
607 m_bossver[1] );
608 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
609 }
610 }
611 else if ( ( cType == "DedxCal" ) && ( m_bossver[1] != "default" ) )
612 {
613 m_flag[1] = "set";
614 flag = m_flag[1];
615 // cout<<"flag @create Dedx is:"<<m_flag[1]<<endl;
616 ret =
617 m_meta->getReadDedxInfo( ser, &runfrm, &runto, m_calPar[1], res, runNo, m_bossver[1] );
618 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
619 }
620
621 // MdcCalConst
622 if ( ( cType == "MdcCal" ) && ( m_bossver[0] == "default" ) )
623 {
624 std::string cType = "Mdc";
625 // cout<<"cType is"<<cType<<"m_bossver[0] is:"<<m_bossver[0]<<endl;
626 if ( m_bossRelease == "default" )
627 {
628 log << MSG::FATAL << " Boss Release for MdcCal not set!" << endmsg;
629 exit( 1 );
630 }
631 else
632 {
633 st1 = getSftParVer( m_bossver[0], m_calPar[0], runfrm1, runto1, runNo, m_bossRelease,
634 cType );
635 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
636 if ( st1.isFailure() )
637 {
638 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
639 return st1;
640 }
641 ret = m_meta->getReadMDCInfo( ser, &runfrm, &runto, m_calPar[0], res, runNo,
642 m_bossver[0] );
643 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
644 }
645 }
646 else if ( ( cType == "MdcCal" ) && ( m_bossver[0] != "default" ) )
647 {
648 m_flag[0] = "set";
649 flag = m_flag[0];
650 // cout<<"flag @create Mdc is:"<<m_flag[0]<<endl;
651 ret =
652 m_meta->getReadMDCInfo( ser, &runfrm, &runto, m_calPar[0], res, runNo, m_bossver[0] );
653 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
654 }
655
656 // MucCalConst
657 if ( ( cType == "MucCal" ) && ( m_bossver[4] == "default" ) )
658 {
659 std::string cType = "Muc";
660 if ( m_bossRelease == "default" )
661 {
662 log << MSG::FATAL << " Boss Release for MucCal not set!" << endmsg;
663 exit( 1 );
664 }
665 else
666 {
667 st1 = getSftParVer( m_bossver[4], m_calPar[4], runfrm1, runto1, runNo, m_bossRelease,
668 cType );
669 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
670 if ( st1.isFailure() )
671 {
672 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
673 return st1;
674 }
675 ret = m_meta->getReadMUCInfo( ser, &runfrm, &runto, m_calPar[4], res, runNo,
676 m_bossver[4] );
677 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
678 }
679 }
680 else if ( ( cType == "MucCal" ) && ( m_bossver[4] != "default" ) )
681 {
682 m_flag[4] = "set";
683 flag = m_flag[4];
684 // cout<<"flag @create Muc is:"<<m_flag[4]<<endl;
685 ret =
686 m_meta->getReadMUCInfo( ser, &runfrm, &runto, m_calPar[4], res, runNo, m_bossver[4] );
687 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
688 }
689
690 // EsTimeCal
691 if ( ( cType == "EsTimeCal" ) && ( m_bossver[5] == "default" ) )
692 {
693 std::string cType = "EsTime";
694 if ( m_bossRelease == "default" )
695 {
696 log << MSG::FATAL << " Boss Release for EsTimeCal not set!" << endmsg;
697 exit( 1 );
698 }
699 else
700 {
701 st1 = getSftParVer( m_bossver[5], m_calPar[5], runfrm1, runto1, runNo, m_bossRelease,
702 cType );
703 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
704 if ( st1.isFailure() )
705 {
706 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
707 return st1;
708 }
709 ret = m_meta->getReadEsTimeInfo( ser, &runfrm, &runto, m_calPar[5], res, runNo,
710 m_bossver[5] );
711 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
712 }
713 }
714 else if ( ( cType == "EsTimeCal" ) && ( m_bossver[5] != "default" ) )
715 {
716 m_flag[5] = "set";
717 flag = m_flag[5];
718 // cout<<"flag @create EsTime is:"<<m_flag[5]<<endl;
719 ret = m_meta->getReadEsTimeInfo( ser, &runfrm, &runto, m_calPar[5], res, runNo,
720 m_bossver[5] );
721 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
722 }
723
724 // MdcAlign
725 if ( ( cType == "MdcAlign" ) && ( m_bossver[7] == "default" ) )
726 {
727 std::string cType = "MdcAlign";
728 if ( m_bossRelease == "default" )
729 {
730 log << MSG::FATAL << " Boss Release for MdcAlignCal not set!" << endmsg;
731 exit( 1 );
732 }
733 else
734 {
735 st1 = getSftParVer( m_bossver[7], m_calPar[7], runfrm1, runto1, runNo, m_bossRelease,
736 cType );
737 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
738 if ( st1.isFailure() )
739 {
740 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
741 return st1;
742 }
743 ret = m_meta->getReadMdcAlignInfo( ser, &runfrm, &runto, m_calPar[7], res, runNo,
744 m_bossver[7] );
745 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
746 }
747 }
748 else if ( ( cType == "MdcAlign" ) && ( m_bossver[7] != "default" ) )
749 {
750 m_flag[7] = "set";
751 flag = m_flag[7];
752 // cout<<"flag @create MdcAlign is:"<<m_flag[7]<<endl;
753 ret = m_meta->getReadMdcAlignInfo( ser, &runfrm, &runto, m_calPar[7], res, runNo,
754 m_bossver[7] );
755 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
756 }
757
758 // TofQElec
759 if ( ( cType == "TofQElec" ) && ( m_bossver[8] == "default" ) )
760 {
761 std::string cType = "TofQElec";
762 if ( m_bossRelease == "default" )
763 {
764 log << MSG::FATAL << " Boss Release for TofQElecCal not set!" << endmsg;
765 exit( 1 );
766 }
767 else
768 {
769 // cout<<"TofQElec @create"<<endl;
770 st1 = getSftParVer( m_bossver[8], m_calPar[8], runfrm1, runto1, runNo, m_bossRelease,
771 cType );
772 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
773 if ( st1.isFailure() )
774 {
775 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
776 return st1;
777 }
778 ret = m_meta->getReadTofQElecInfo( ser, &runfrm, &runto, m_calPar[8], res, runNo,
779 m_bossver[8] );
780 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
781 }
782 }
783 else if ( ( cType == "TofQElec" ) && ( m_bossver[8] != "default" ) )
784 {
785 m_flag[8] = "set";
786 flag = m_flag[8];
787 // cout<<"flag @create TofQElec is:"<<flag<<endl;
788 ret = m_meta->getReadTofQElecInfo( ser, &runfrm, &runto, m_calPar[8], res, runNo,
789 m_bossver[8] );
790 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
791 }
792
793 // TofSim
794 if ( ( cType == "TofSim" ) && ( m_bossver[9] == "default" ) )
795 {
796 std::string cType = "TofSim";
797 if ( m_bossRelease == "default" )
798 {
799 log << MSG::FATAL << " Boss Release for TofSimCal not set!" << endmsg;
800 exit( 1 );
801 }
802 else
803 {
804 st1 = getSftParVer( m_bossver[9], m_calPar[9], runfrm1, runto1, runNo, m_bossRelease,
805 cType );
806 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
807 if ( st1.isFailure() )
808 {
809 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
810 return st1;
811 }
812 ret = m_meta->getReadTofSimInfo( ser, &runfrm, &runto, m_calPar[9], res, runNo,
813 m_bossver[9] );
814 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
815 }
816 }
817 else if ( ( cType == "TofSim" ) && ( m_bossver[9] != "default" ) )
818 {
819 m_flag[9] = "set";
820 flag = m_flag[9];
821 // cout<<"flag @create TofSim is:"<<m_flag[9]<<endl;
822 ret = m_meta->getReadTofSimInfo( ser, &runfrm, &runto, m_calPar[9], res, runNo,
823 m_bossver[9] );
824 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
825 }
826
827 // DedxSim
828 if ( ( cType == "DedxSim" ) && ( m_bossver[10] == "default" ) )
829 {
830 std::string cType = "DedxSim";
831 if ( m_bossRelease == "default" )
832 {
833 log << MSG::FATAL << " Boss Release for DedxSimCal not set!" << endmsg;
834 exit( 1 );
835 }
836 else
837 {
838 st1 = getSftParVer( m_bossver[10], m_calPar[10], runfrm1, runto1, runNo, m_bossRelease,
839 cType );
840 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
841 if ( st1.isFailure() )
842 {
843 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
844 return st1;
845 }
846 ret = m_meta->getReadDedxSimInfo( ser, &runfrm, &runto, m_calPar[10], res, runNo,
847 m_bossver[10] );
848 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
849 }
850 }
851 else if ( ( cType == "DedxSim" ) && ( m_bossver[10] != "default" ) )
852 {
853 m_flag[10] = "set";
854 flag = m_flag[10];
855 // cout<<"flag @create DedxSim is:"<<m_flag[10]<<endl;
856 ret = m_meta->getReadDedxSimInfo( ser, &runfrm, &runto, m_calPar[10], res, runNo,
857 m_bossver[10] );
858 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
859 }
860
861 // MdcDataConst
862 if ( ( cType == "MdcDataConst" ) && ( m_bossver[11] == "default" ) )
863 {
864 std::string cType = "MdcData";
865 if ( m_bossRelease == "default" )
866 {
867 log << MSG::FATAL << " Boss Release for MdcDataConst not set!" << endmsg;
868 exit( 1 );
869 }
870 else
871 {
872 st1 = getSftParVer( m_bossver[11], m_calPar[11], runfrm1, runto1, runNo, m_bossRelease,
873 cType );
874 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
875 if ( st1.isFailure() )
876 {
877 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
878 return st1;
879 }
880 ret = m_meta->getReadMdcDataConstInfo( ser, &runfrm, &runto, m_calPar[11], res, runNo,
881 m_bossver[11] );
882 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
883 }
884 }
885 else if ( ( cType == "MdcDataConst" ) && ( m_bossver[11] != "default" ) )
886 {
887 m_flag[11] = "set";
888 flag = m_flag[11];
889 // cout<<"flag @create MdcData is:"<<m_flag[11]<<endl;
890 ret = m_meta->getReadMdcDataConstInfo( ser, &runfrm, &runto, m_calPar[11], res, runNo,
891 m_bossver[11] );
892 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
893 }
894
895 // EstTofCalConst
896 if ( ( cType == "EstTofCal" ) && ( m_bossver[6] == "default" ) )
897 {
898 std::string cType = "EsTof";
899 if ( m_bossRelease == "default" )
900 {
901 log << MSG::FATAL << " Boss Release for EstTofCal not set!" << endmsg;
902 exit( 1 );
903 }
904 else
905 {
906 st1 = getSftParVer( m_bossver[6], m_calPar[6], runfrm1, runto1, runNo, m_bossRelease,
907 cType );
908 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
909 if ( st1.isFailure() )
910 {
911 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
912 return st1;
913 }
914 ret = m_meta->getReadEstTofInfo( ser, &runfrm, &runto, m_calPar[6], res, runNo,
915 m_bossver[6] );
916 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
917 }
918 }
919 else if ( ( cType == "EstTofCal" ) && ( m_bossver[6] != "default" ) )
920 {
921 m_flag[6] = "set";
922 flag = m_flag[6];
923 // cout<<"flag @create EstTof is:"<<m_flag[6]<<endl;
924 ret = m_meta->getReadEstTofInfo( ser, &runfrm, &runto, m_calPar[6], res, runNo,
925 m_bossver[6] );
926 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
927 }
928 // Top_up Qiumei Ma
929 // InjSigIntercal
930 if ( ( cType == "InjSigInterval" ) && ( m_bossver[12] == "default" ) )
931 {
932 std::string cType = "InjSigInterval";
933 if ( m_bossRelease == "default" )
934 {
935 log << MSG::FATAL << " Boss Release for InjSigInterval not set!" << endmsg;
936 exit( 1 );
937 }
938 else
939 {
940 st1 = getSftParVer( m_bossver[12], m_calPar[12], runfrm1, runto1, runNo, m_bossRelease,
941 cType );
942 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
943 if ( st1.isFailure() )
944 {
945 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
946 return st1;
947 }
948 ret = m_meta->getReadInjSigIntervalInfo( ser, &runfrm, &runto, m_calPar[12], res, runNo,
949 m_bossver[12] );
950 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
951 }
952 }
953 else if ( ( cType == "InjSigInterval" ) && ( m_bossver[12] != "default" ) )
954 {
955 m_flag[12] = "set";
956 flag = m_flag[12];
957 ret = m_meta->getReadInjSigIntervalInfo( ser, &runfrm, &runto, m_calPar[12], res, runNo,
958 m_bossver[12] );
959 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
960 }
961
962 // InjSigTime
963 if ( ( cType == "InjSigTime" ) && ( m_bossver[13] == "default" ) )
964 {
965 std::string cType = "InjSigTime";
966 if ( m_bossRelease == "default" )
967 {
968 log << MSG::FATAL << " Boss Release for InjSigTime not set!" << endmsg;
969 exit( 1 );
970 }
971 else
972 {
973 st1 = getSftParVer( m_bossver[13], m_calPar[13], runfrm1, runto1, runNo, m_bossRelease,
974 cType );
975 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
976 if ( st1.isFailure() )
977 {
978 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
979 return st1;
980 }
981 ret = m_meta->getReadInjSigTimeInfo( ser, &runfrm, &runto, m_calPar[13], res, runNo,
982 m_bossver[13] );
983 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
984 }
985 }
986 else if ( ( cType == "InjSigTime" ) && ( m_bossver[13] != "default" ) )
987 {
988 m_flag[13] = "set";
989 flag = m_flag[13];
990 ret = m_meta->getReadInjSigTimeInfo( ser, &runfrm, &runto, m_calPar[13], res, runNo,
991 m_bossver[13] );
992 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
993 }
994
995 // OffEvtFilter
996 if ( ( cType == "OffEvtFilter" ) && ( m_bossver[14] == "default" ) )
997 {
998 std::string cType = "OffEvtFilter";
999 if ( m_bossRelease == "default" )
1000 {
1001 log << MSG::FATAL << " Boss Release for OffEvtFilter not set!" << endmsg;
1002 exit( 1 );
1003 }
1004 else
1005 {
1006 st1 = getSftParVer( m_bossver[14], m_calPar[14], runfrm1, runto1, runNo, m_bossRelease,
1007 cType );
1008 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
1009 if ( st1.isFailure() )
1010 {
1011 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
1012 return st1;
1013 }
1014 ret = m_meta->getReadOffEvtFilterInfo( ser, &runfrm, &runto, m_calPar[14], res, runNo,
1015 m_bossver[14] );
1016 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
1017 }
1018 }
1019 else if ( ( cType == "OffEvtFilter" ) && ( m_bossver[14] != "default" ) )
1020 {
1021 m_flag[14] = "set";
1022 flag = m_flag[14];
1023 ret = m_meta->getReadOffEvtFilterInfo( ser, &runfrm, &runto, m_calPar[14], res, runNo,
1024 m_bossver[14] );
1025 // cout<<cType<<"::runfrom, runto @create "<<" are:"<<runfrm<<"::"<<runto<<endl;
1026 }
1027
1028 // CorrectedETS
1029 if ( cType == "CorrectedETS" )
1030 {
1031 std::string cType = "CorrectedETS";
1032 // cout<<"First Event is:::"<<FirstEvent<<endl;
1033 ret = m_meta->getReadCorrectedETSInfo( ser, runNo, FirstEvent, m_calPar[15], res );
1034
1035 int _strlenRun = strlen( ( *res[0] )["Run"] ) + 1;
1036 char* _pStatus = new char[3];
1037 char* _pRunFrom = new char[_strlenRun];
1038 char* _pRunTo = new char[_strlenRun];
1039 memcpy( _pStatus, "OK", 3 );
1040 memcpy( _pRunFrom, ( *res[0] )["Run"], _strlenRun );
1041 memcpy( _pRunTo, ( *res[0] )["Run"], _strlenRun );
1042
1043 ( *res[0] )["Status"] = _pStatus;
1044 ( *res[0] )["RunFrom"] = _pRunFrom;
1045 ( *res[0] )["RunTo"] = _pRunTo;
1046 runfrm1 = runNo;
1047 runto1 = runNo;
1048 }
1049
1050 if ( ret != calibUtil::Metadata::RETOk )
1051 {
1052 log << MSG::ERROR << "no record in the database" << endmsg;
1053 exit( 1 );
1054 }
1055
1056 int sz = res.size();
1057
1058 DatabaseRecord* records1 = res[0];
1059 if ( m_dbStatus == "OK" )
1060 {
1061 if ( std::string( ( *records1 )["Status"] ) != "OK" )
1062 {
1063 log << MSG::FATAL << "Status of type " << cType << " is " << ( *records1 )["Status"]
1064 << " your setting is OK" << endmsg;
1065 exit( 1 );
1066 }
1067 }
1068
1069 log << MSG::DEBUG << "dataIdent is:" << dataIdent << endmsg;
1070 unsigned char storageType;
1071 physFmt = "TREE";
1072 StatusCode sc = decodeDescription( physFmt, storageType );
1073
1074 // Depending on value of eDataFmt, figure out which private
1075 // conversion service to invoke. Pass dataIdent and fmtVersion
1076 // as part of the opaque address.
1077 // Create temporary address for the relevant type and classID
1078 log << MSG::DEBUG << "Creating an address of type " << (int)storageType << " for class "
1079 << classID << endmsg;
1080
1081 IOpaqueAddress* tmpAddress;
1082 const std::string par[3] = { dataIdent, fullpath, fmtVersion };
1083 // const unsigned long ipar[2] = {int(runfrm),int(runto)};
1084 // log << MSG::DEBUG << "ipar is:"<<ipar[0]<<":"<<ipar[1]<<"ipar[1]"<<endmsg;
1085 const unsigned long ipar[2] = { 0, 0 }; // yzhang fix unsigned bug for runfrom runto
1086
1087 // sc = addressCreator()->createAddress(storageType, classID,
1088 // par, ipar, tmpAddress);
1089
1090 tmpAddress = new TreeAddress( storageType, classID, *records1, ipar );
1091 // sscanf((*records2)["RunFrom"], "%d", &runfrm1);
1092 // sscanf((*records2)["RunTo"], "%d", &runto1);
1093 sscanf( ( *records1 )["RunFrom"], "%d", &runfrm );
1094 sscanf( ( *records1 )["RunTo"], "%d", &runto );
1095 log << MSG::DEBUG << __LINE__ << " records @ runfrm is:" << ( *records1 )["RunFrom"]
1096 << " runto is:" << ( *records1 )["RunTo"] << " ser_no is:" << ser << endmsg;
1097 // log << MSG::DEBUG <<__LINE__<< " runfrm is:"<<runfrm<<" runto is:"<<runto<<" ser_no
1098 // is:"<<ser<<endmsg;
1099 if ( flag == "default" )
1100 {
1101 if ( runfrm1 > runfrm ) { runfrm = runfrm1; }
1102 if ( runto1 < runto ) { runto = runto1; }
1103 }
1104 if ( flag == "set" ) { flag = "default"; }
1105 log << MSG::DEBUG << __LINE__ << " runfrm of max is:" << runfrm << " runto min is:" << runto
1106 << endmsg;
1107 TreeAddress* treeAddress = dynamic_cast<TreeAddress*>( tmpAddress );
1108 treeAddress->setRunFrom( runfrm );
1109 treeAddress->setRunTo( runto );
1110 // log << MSG::DEBUG << __LINE__<<" records @ runfrm is:"<<(*records1)["RunFrom"]<<" runto
1111 // is:"<<(*records1)["RunTo"]<<" ser_no is:"<<ser<<endmsg; log << MSG::DEBUG <<__LINE__<<
1112 // " runfrm is:"<<runfrm<<" runto is:"<<runto<<" ser_no is:"<<ser<<endmsg;
1113 /*
1114 if ( !sc.isSuccess() ) {
1115 log << msgLevel << "Persistency service could not create a new address" << endmsg;
1116 if (m_crash) {
1117 log << msgLevel << std::endl << "Exiting... " << std::endl << endmsg;
1118 exit(1);
1119 }
1120 return sc;
1121 }
1122 */
1123 tmpAddress->addRef();
1124
1125 // Set the transient store registry for the object associated to this address
1126 tmpAddress->setRegistry( entry );
1127
1128 // Now create the object
1129 sc = m_detPersSvc->createObj( tmpAddress, refpObject );
1130 tmpAddress->release();
1131 if ( !sc.isSuccess() )
1132 {
1133 log << msgLevel << "Persistency service could not create a new object" << endmsg;
1134 if ( m_crash )
1135 {
1136 log << msgLevel << std::endl
1137 << "++++CalibMySQLCnvSvc Exiting... " << std::endl
1138 << endmsg;
1139 exit( 1 );
1140 }
1141 return sc;
1142 }
1143 // std::cout<<" CalibMySQLCnvSvc res.size()=="<<res.size()<<std::endl;
1144 res.clear();
1145 log << MSG::DEBUG << "New object successfully created" << endmsg;
1146 return StatusCode::SUCCESS;
1147 f1->Close();
1148 delete f1;
1149
1150 return StatusCode::SUCCESS;
1151}
1152
1153/// Update a calib DataObject by calib type, flavor,and instrument
1154/// if necessary.
1155/// This method does not register DataObject in the transient data store,
1156/// The string storage type is discovered at runtime in the MySQL dbs.
1157/// Implementation:
1158/// - create a temporary address containing storage type and classID;
1159/// - dispatch to appropriate conversion service according to storage type;
1160/// - this will dispatch to appropriate converter according to CLID
1161/// (the CalibMySQLCnvSvc has no converters of its own).
1162
1163StatusCode CalibMySQLCnvSvc::updateCalib( DataObject* pObject, const std::string& fullpath,
1164 const CLID& classID, IRegistry* entry ) {
1166
1167 MsgStream log( msgSvc(), "CalibMySQLCnvSvc" );
1168 StatusCode status;
1169
1170 std::string testfile = std::string( getenv( "CALIBMYSQLCNVROOT" ) ) + "/share/test.root";
1171 TFile* f1 = new TFile( testfile.c_str(), "read" );
1172
1173 // Look up calib object in the Metadata database
1174 // std::string flavor = CalibData::CalibModelSvc::getFlavor(fullpath);
1175 std::string cType = CalibData::CalibModelSvc::getCalibType( fullpath );
1176
1177 // ..and extra special munging for test
1178 if ( std::string( "Test" ) == cType.substr( 0, 4 ) ) { cType = std::string( "Test_Gen" ); }
1179
1180 if ( 0 == pObject )
1181 {
1182 log << MSG::ERROR << "There is no DataObject to update" << endmsg;
1183 return StatusCode::FAILURE;
1184 }
1185 // Is object an instance of the specified class?
1186 if ( pObject->clID() != 6411 && classID != 6411 )
1187 {
1188 if ( classID != pObject->clID() )
1189 {
1190 log << MSG::ERROR << "Update requested for clID " << classID
1191 << " while DataObject is of clID " << pObject->clID() << endmsg;
1192 exit( 1 );
1193 return StatusCode::FAILURE;
1194 }
1195 }
1196
1197 // check if already valid. If so, we're done.
1198 // Need access to IValidity interface
1199 CalibBase1* pBase = dynamic_cast<CalibBase1*>( pObject );
1200 if ( pBase == 0 )
1201 {
1202 log << MSG::WARNING << "Object to be updated is not a calib object! " << endmsg;
1203 return StatusCode::FAILURE;
1204 }
1205
1206 // Following comes from createCalib. Perhaps create and update
1207 // should be calling common utility since much of what they do is identical.
1208 unsigned int ser = 0;
1209 int runfrm, runfrm1;
1210 int runto, runto1, FirstEvent = 0;
1212
1213 // calibUtil::Metadata::eDataFmt physFmt = calibUtil::Metadata::FMTUnknown;
1214 std::string physFmt;
1215 std::string fmtVersion;
1216 std::string dataIdent;
1217 std::string flag = "default";
1218 // Get the information needed to find and interpret the bulk data:
1219 // * physical storage type
1220 // * version of the physical format
1221 // * pathname or similar identifying information so the data can be found
1222 // maqm comment remove fmtversion :
1223 // ret = m_meta->getReadInfo(ser, physFmt, fmtVersion, dataIdent);
1224
1225 SmartDataPtr<Event::EventHeader> evt( m_eventSvc, "/Event/EventHeader" );
1226 int runNo = 0;
1227 if ( !evt )
1228 {
1229 log << MSG::WARNING << "Unable to read the Event for TDS" << endmsg;
1230 // return StatusCode::FAILURE;
1231 }
1232
1233 // eRet ret;
1234
1236 StatusCode st1;
1237 if ( evt )
1238 {
1239 if ( cType != "TofCal" && cType != "EstTofCal" && cType != "TofSim" && cType != "DedxSim" )
1240 runNo = fabs( evt->runNumber() );
1241 if ( cType == "TofCal" || cType == "EstTofCal" || cType == "TofSim" || cType == "DedxSim" )
1242 runNo = evt->runNumber();
1243 FirstEvent = evt->eventNumber();
1244 }
1245
1246 // TofCalConst
1247 if ( ( cType == "TofCal" ) )
1248 {
1249 std::string cType = "Tof";
1250 if ( m_flag[3] == "default" )
1251 {
1252 st1 = getSftParVer( m_bossver[3], m_calPar[3], runfrm1, runto1, runNo, m_bossRelease,
1253 cType );
1254 cout << cType << " runfrm1,runto1 @update is:" << runfrm1 << ":::" << runto1 << endl;
1255 if ( st1.isFailure() )
1256 {
1257 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
1258 return st1;
1259 }
1260 }
1261
1262 flag = m_flag[3];
1263
1264 // cout<<"flag @update Tof is:"<<flag<<endl;
1265 // cout<<"SftVer and CalParVer are:"<<sft_ver<<";"<<cal_ver<<endl;
1266 ret =
1267 m_meta->getReadTOFInfo( ser, &runfrm, &runto, m_calPar[3], res, runNo, m_bossver[3] );
1268 // cout<<"runfrom, runto @update "<<cType<<" are:"<<runfrm<<"::"<<runto<<endl;
1269 }
1270
1271 // EmcCalConst
1272 if ( ( cType == "EmcCal" ) )
1273 {
1274 std::string cType = "Emc";
1275 if ( m_flag[2] == "default" )
1276 {
1277 st1 = getSftParVer( m_bossver[2], m_calPar[2], runfrm1, runto1, runNo, m_bossRelease,
1278 cType );
1279 // cout<<cType<<" runfrm1,runto1 @update is:"<<runfrm1<<":::"<<runto1<<endl;
1280 if ( st1.isFailure() )
1281 {
1282 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
1283 return st1;
1284 }
1285 }
1286 flag = m_flag[2];
1287 // cout<<"flag @update Emc is:"<<m_flag[2]<<endl;
1288 ret =
1289 m_meta->getReadEMCInfo( ser, &runfrm, &runto, m_calPar[2], res, runNo, m_bossver[2] );
1290 // cout<<"runfrom, runto @update "<<cType<<" are:"<<runfrm<<"::"<<runto<<endl;
1291 }
1292
1293 // DedxCalConst
1294 if ( ( cType == "DedxCal" ) )
1295 {
1296 std::string cType = "Dedx";
1297 if ( m_flag[1] == "default" )
1298 {
1299 st1 = getSftParVer( m_bossver[1], m_calPar[1], runfrm1, runto1, runNo, m_bossRelease,
1300 cType );
1301 // cout<<cType<<" runfrm1,runto1 @update is:"<<runfrm1<<":::"<<runto1<<endl;
1302 if ( st1.isFailure() )
1303 {
1304 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
1305 return st1;
1306 }
1307 }
1308 flag = m_flag[1];
1309 // cout<<"flag @update Dedx is:"<<m_flag[1]<<endl;
1310 ret =
1311 m_meta->getReadDedxInfo( ser, &runfrm, &runto, m_calPar[1], res, runNo, m_bossver[1] );
1312 }
1313
1314 // MdcCalConst
1315 if ( ( cType == "MdcCal" ) )
1316 {
1317 std::string cType = "Mdc";
1318 if ( m_flag[0] == "default" )
1319 {
1320 // cout<<"cType is"<<cType<<"m_bossver[0] is:"<<m_bossver[0]<<endl;
1321 st1 = getSftParVer( m_bossver[0], m_calPar[0], runfrm1, runto1, runNo, m_bossRelease,
1322 cType );
1323 // cout<<cType<<" runfrm1,runto1 @update is:"<<runfrm1<<":::"<<runto1<<endl;
1324 if ( st1.isFailure() )
1325 {
1326 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
1327 return st1;
1328 }
1329 }
1330 flag = m_flag[0];
1331 // cout<<"flag @update Mdc is:"<<m_flag[0]<<endl;
1332 ret =
1333 m_meta->getReadMDCInfo( ser, &runfrm, &runto, m_calPar[0], res, runNo, m_bossver[0] );
1334 // cout<<"runfrom, runto @update "<<cType<<" are:"<<runfrm<<"::"<<runto<<endl;
1335 }
1336
1337 // MucCalConst
1338 if ( ( cType == "MucCal" ) )
1339 {
1340 std::string cType = "Muc";
1341 if ( m_flag[4] == "default" )
1342 {
1343 st1 = getSftParVer( m_bossver[4], m_calPar[4], runfrm1, runto1, runNo, m_bossRelease,
1344 cType );
1345 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
1346 if ( st1.isFailure() )
1347 {
1348 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
1349 return st1;
1350 }
1351 }
1352 flag = m_flag[4];
1353 // cout<<"flag @update Muc is:"<<m_flag[4]<<endl;
1354 ret =
1355 m_meta->getReadMUCInfo( ser, &runfrm, &runto, m_calPar[4], res, runNo, m_bossver[4] );
1356 }
1357
1358 // EsTimeCal
1359 if ( ( cType == "EsTimeCal" ) )
1360 {
1361 std::string cType = "EsTime";
1362 if ( m_flag[5] == "default" )
1363 {
1364 st1 = getSftParVer( m_bossver[5], m_calPar[5], runfrm1, runto1, runNo, m_bossRelease,
1365 cType );
1366 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
1367 if ( st1.isFailure() )
1368 {
1369 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
1370 return st1;
1371 }
1372 }
1373 flag = m_flag[5];
1374 // cout<<"flag @update EsTime is:"<<m_flag[5]<<endl;
1375 ret = m_meta->getReadEsTimeInfo( ser, &runfrm, &runto, m_calPar[5], res, runNo,
1376 m_bossver[5] );
1377 }
1378
1379 // MdcAlign
1380 if ( ( cType == "MdcAlign" ) )
1381 {
1382 std::string cType = "MdcAlign";
1383 if ( m_flag[7] == "default" )
1384 {
1385 st1 = getSftParVer( m_bossver[7], m_calPar[7], runfrm1, runto1, runNo, m_bossRelease,
1386 cType );
1387 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
1388 if ( st1.isFailure() )
1389 {
1390 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
1391 return st1;
1392 }
1393 }
1394 flag = m_flag[7];
1395 // cout<<"flag @update MdcAlign is:"<<m_flag[7]<<endl;
1396 ret = m_meta->getReadMdcAlignInfo( ser, &runfrm, &runto, m_calPar[7], res, runNo,
1397 m_bossver[7] );
1398 }
1399
1400 // TofQElec
1401 if ( ( cType == "TofQElec" ) )
1402 {
1403 std::string cType = "TofQElec";
1404 if ( m_flag[8] == "default" )
1405 {
1406 // cout<<"TofQElec @update"<<endl;
1407 st1 = getSftParVer( m_bossver[8], m_calPar[8], runfrm1, runto1, runNo, m_bossRelease,
1408 cType );
1409 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
1410 }
1411 flag = m_flag[8];
1412 // cout<<"flag @update TofQElec is:"<<m_flag[8]<<endl;
1413 ret = m_meta->getReadTofQElecInfo( ser, &runfrm, &runto, m_calPar[8], res, runNo,
1414 m_bossver[8] );
1415 // cout<<"runfrom, runto @TofQElec are:"<<runfrm<<"::"<<runto<<endl;
1416 }
1417
1418 // TofSim
1419 if ( ( cType == "TofSim" ) )
1420 {
1421 std::string cType = "TofSim";
1422 if ( m_flag[9] == "default" )
1423 {
1424 st1 = getSftParVer( m_bossver[9], m_calPar[9], runfrm1, runto1, runNo, m_bossRelease,
1425 cType );
1426 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
1427 if ( st1.isFailure() )
1428 {
1429 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
1430 return st1;
1431 }
1432 }
1433 flag = m_flag[9];
1434 // cout<<"flag @update TofSim is:"<<m_flag[9]<<endl;
1435 ret = m_meta->getReadTofSimInfo( ser, &runfrm, &runto, m_calPar[9], res, runNo,
1436 m_bossver[9] );
1437 // cout<<"runfrom, runto @TofSim are:"<<runfrm<<"::"<<runto<<endl;
1438 }
1439
1440 // DedxSim
1441 if ( ( cType == "DedxSim" ) )
1442 {
1443 std::string cType = "DedxSim";
1444 if ( m_flag[10] == "default" )
1445 {
1446 st1 = getSftParVer( m_bossver[10], m_calPar[10], runfrm1, runto1, runNo, m_bossRelease,
1447 cType );
1448 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
1449 if ( st1.isFailure() )
1450 {
1451 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
1452 return st1;
1453 }
1454 }
1455 flag = m_flag[10];
1456 // cout<<"flag @update DedxSim is:"<<m_flag[10]<<endl;
1457 ret = m_meta->getReadDedxSimInfo( ser, &runfrm, &runto, m_calPar[10], res, runNo,
1458 m_bossver[10] );
1459 // cout<<"runfrom, runto @DedxSim are:"<<runfrm<<"::"<<runto<<endl;
1460 }
1461
1462 // MdcDataConst
1463 if ( ( cType == "MdcDataConst" ) )
1464 {
1465 std::string cType = "MdcData";
1466 if ( m_flag[11] == "default" )
1467 {
1468 st1 = getSftParVer( m_bossver[11], m_calPar[11], runfrm1, runto1, runNo, m_bossRelease,
1469 cType );
1470 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
1471 if ( st1.isFailure() )
1472 {
1473 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
1474 return st1;
1475 }
1476 }
1477 flag = m_flag[11];
1478 // cout<<"flag @update MdcData is:"<<m_flag[11]<<endl;
1479 ret = m_meta->getReadMdcDataConstInfo( ser, &runfrm, &runto, m_calPar[11], res, runNo,
1480 m_bossver[11] );
1481 // cout<<"runfrom, runto @MdcDataConst are:"<<runfrm<<"::"<<runto<<endl;
1482 }
1483
1484 // InjSigInterval
1485 if ( cType == "InjSigInterval" )
1486 {
1487 std::string cType = "InjSigInterval";
1488 if ( m_flag[12] == "default" )
1489 {
1490 st1 = getSftParVer( m_bossver[12], m_calPar[12], runfrm1, runto1, runNo, m_bossRelease,
1491 cType );
1492 if ( st1.isFailure() )
1493 {
1494 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
1495 return st1;
1496 }
1497 }
1498 flag = m_flag[12];
1499 ret = m_meta->getReadInjSigIntervalInfo( ser, &runfrm, &runto, m_calPar[12], res, runNo,
1500 m_bossver[12] );
1501 }
1502 // InjSigTime
1503 if ( cType == "InjSigTime" )
1504 {
1505 std::string cType = "InjSigTime";
1506 if ( m_flag[13] == "default" )
1507 {
1508 st1 = getSftParVer( m_bossver[13], m_calPar[13], runfrm1, runto1, runNo, m_bossRelease,
1509 cType );
1510 if ( st1.isFailure() )
1511 {
1512 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
1513 return st1;
1514 }
1515 }
1516 flag = m_flag[13];
1517 ret = m_meta->getReadInjSigTimeInfo( ser, &runfrm, &runto, m_calPar[13], res, runNo,
1518 m_bossver[13] );
1519 }
1520 // OffEvtFilter
1521 if ( cType == "OffEvtFilter" )
1522 {
1523 std::string cType = "OffEvtFilter";
1524 if ( m_flag[14] == "default" )
1525 {
1526 st1 = getSftParVer( m_bossver[14], m_calPar[14], runfrm1, runto1, runNo, m_bossRelease,
1527 cType );
1528 if ( st1.isFailure() )
1529 {
1530 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
1531 return st1;
1532 }
1533 }
1534 flag = m_flag[14];
1535 ret = m_meta->getReadOffEvtFilterInfo( ser, &runfrm, &runto, m_calPar[14], res, runNo,
1536 m_bossver[14] );
1537 }
1538 // CorrectedETS
1539 if ( cType == "CorrectedETS" )
1540 {
1541 std::string cType = "CorrectedETS";
1542 ret = m_meta->getReadCorrectedETSInfo( ser, runNo, FirstEvent, m_calPar[15], res );
1543
1544 int _strlenRun = strlen( ( *res[0] )["Run"] ) + 1;
1545 char* _pStatus = new char[3];
1546 char* _pRunFrom = new char[_strlenRun];
1547 char* _pRunTo = new char[_strlenRun];
1548 memcpy( _pStatus, "OK", 3 );
1549 memcpy( _pRunFrom, ( *res[0] )["Run"], _strlenRun );
1550 memcpy( _pRunTo, ( *res[0] )["Run"], _strlenRun );
1551
1552 ( *res[0] )["Status"] = _pStatus;
1553 ( *res[0] )["RunFrom"] = _pRunFrom;
1554 ( *res[0] )["RunTo"] = _pRunTo;
1555 runfrm1 = runNo;
1556 runto1 = runNo;
1557 }
1558
1559 // EstTofCalConst
1560 if ( ( cType == "EstTofCal" ) )
1561 {
1562 std::string cType = "EsTof";
1563 if ( m_flag[6] == "default" )
1564 {
1565 st1 = getSftParVer( m_bossver[6], m_calPar[6], runfrm1, runto1, runNo, m_bossRelease,
1566 cType );
1567 // cout<<cType<<" runfrm1,runto1 @CalVtxLumVer are:"<<runfrm1<<":::"<<runto1<<endl;
1568 if ( st1.isFailure() )
1569 {
1570 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
1571 return st1;
1572 }
1573 }
1574 flag = m_flag[6];
1575 // cout<<"flag @update EstTof is:"<<m_flag[6]<<endl;
1576 ret = m_meta->getReadEstTofInfo( ser, &runfrm, &runto, m_calPar[6], res, runNo,
1577 m_bossver[6] );
1578 // cout<<"runfrom, runto @EstTofCalConst are:"<<runfrm<<"::"<<runto<<endl;
1579 }
1580
1581 if ( ret != calibUtil::Metadata::RETOk )
1582 {
1583 log << MSG::ERROR << "Error searching in the database" << endmsg;
1584 exit( 1 );
1585 }
1586
1587 physFmt = "TREE";
1588 unsigned char storageType;
1589 status = decodeDescription( physFmt, storageType );
1590
1591 // Depending on value of eDataFmt, figure out which private
1592 // conversion service to invoke. Pass dataIdent and fmtVersion
1593 // as part of the opaque address.
1594 // Create temporary address for the relevant type and classID
1595 log << MSG::DEBUG << "Creating an address of type " << (int)storageType << " for class "
1596 << classID << endmsg;
1597
1598 // int sz=res.size();
1599 DatabaseRecord* records1 = res[0];
1600
1601 if ( m_dbStatus == "OK" )
1602 {
1603 if ( std::string( ( *records1 )["Status"] ) != "OK" )
1604 {
1605 log << MSG::FATAL << "the status of type " << cType << " is " << ( *records1 )["Status"]
1606 << " your setting is OK" << endmsg;
1607 exit( 1 );
1608 }
1609 }
1610
1611 IOpaqueAddress* tmpAddress;
1612 // const unsigned long ipar[2] = {runfrm,runto};
1613 const unsigned long ipar[2] = { 0, 0 }; // yzhang fix unsigned bug for runfrom runto
1614
1615 tmpAddress = new TreeAddress( storageType, classID, *records1, ipar );
1616 // log << MSG::DEBUG <<__LINE__<<cType<<" runfrm,runto @CalVtxLumVer/update
1617 // is:"<<runfrm1<<":::"<<runto1<<endmsg;
1618 sscanf( ( *records1 )["RunFrom"], "%d", &runfrm );
1619 sscanf( ( *records1 )["RunTo"], "%d", &runto );
1620 log << MSG::DEBUG << __LINE__ << " records @update runfrm is:" << ( *records1 )["RunFrom"]
1621 << " runto is:" << ( *records1 )["RunTo"] << " ser_no is:" << ser << endmsg;
1622 if ( flag == "default" )
1623 {
1624 if ( runfrm1 > runfrm ) { runfrm = runfrm1; }
1625 if ( runto1 < runto ) { runto = runto1; }
1626 }
1627 if ( flag == "set" ) { flag == "default"; }
1628
1629 log << MSG::DEBUG << __LINE__ << " runfrm of max is:" << runfrm << " runto min is:" << runto
1630 << endmsg;
1631 TreeAddress* treeAddress = dynamic_cast<TreeAddress*>( tmpAddress );
1632 treeAddress->setRunFrom( runfrm );
1633 treeAddress->setRunTo( runto );
1634 // log << MSG::DEBUG << __LINE__<<" records runfrm is:"<<(*records1)["RunFrom"]<<" runto
1635 // is:"<<(*records1)["RunTo"]<<" ser_no is:"<<ser<<endmsg; log << MSG::DEBUG <<__LINE__<< "
1636 // runfrm is:"<<runfrm<<" runto is:"<<runto<<" ser_no is:"<<ser<<endmsg;
1637
1638 log << MSG::DEBUG << "Temporary address successfully created" << endmsg;
1639 tmpAddress->addRef();
1640
1641 // Set the transient store registry for the object associated to this address
1642 tmpAddress->setRegistry( entry );
1643
1644 // Now update the object
1645 DataObject* pNewObject;
1646 status = m_detPersSvc->createObj( tmpAddress, pNewObject );
1647 tmpAddress->release();
1648 if ( !status.isSuccess() )
1649 {
1650 log << MSG::ERROR << "Persistency service could not create object" << endmsg;
1651 return status;
1652 }
1653
1654 // Since DataObject::operator= operator is not virtual, dynamic cast first!
1655 // Overloaded virtual method Condition::update() must be properly defined!
1656 // The memory pointed to by the old pointer must contain the new object
1657 // Note this dynamic cast only gets us part-way. The object is
1658 // actually of some type derived from CalibBase.
1659 CalibBase1* pNewBase = dynamic_cast<CalibBase1*>( pNewObject );
1660 if ( 0 == pNewBase )
1661 {
1662 log << MSG::ERROR << "Cannot update objects other than Calib objects: "
1663 << "update() must be defined!" << endmsg;
1664 return StatusCode::FAILURE;
1665 }
1666
1667 // Deep copy the new calib into the old DataObject. To copy the *whole*
1668 // object, not just the CalibBase part, classes derived from CalibBase
1669 // must override update method.
1670 // NOTE: classes directly derived from CalibBase must call
1671 // CalibBase::update in their own update method.
1672 pBase->update( *pNewBase, &log );
1673 res.clear();
1674 f1->Close();
1675 delete f1;
1676 delete pNewBase;
1677 return StatusCode::SUCCESS;
1678}
1679
1680StatusCode CalibMySQLCnvSvc::decodeDescription( const std::string& description,
1681 unsigned char& type ) {
1682 MsgStream log( msgSvc(), "CalibMySQLCnvSvc" );
1683
1684 // description ="ROOT";
1685 if ( description == std::string( "XML" ) ) { type = XML_StorageType; }
1686 else if ( description == std::string( "ROOT" ) ) { type = CALIBROOT_StorageType; }
1687 else if ( description == std::string( "TREE" ) ) { type = CALIBTREE_StorageType; }
1688 else
1689 { // unsupported
1690 log << MSG::ERROR << "unsupported storage type " << description << endmsg;
1691 return StatusCode::FAILURE;
1692 }
1693 return StatusCode::SUCCESS;
1694}
1695
1696/// Handle to the MySQL metadata database
DECLARE_COMPONENT(BesBdkRc)
sprintf(cut, "kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_" "pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
char * SftVer
Definition DQA_TO_DB.cxx:19
int runNo
Definition DQA_TO_DB.cxx:13
const Int_t n
TFile * f1
IMessageSvc * msgSvc()
virtual StatusCode update(CalibBase1 &obj, MsgStream *)
static std::string getCalibType(const std::string &fullpath)
Return calibration type name, extracted from full path name in TCDS.
virtual StatusCode finalize()
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject)
Update a converted representation of a transient object.
virtual StatusCode decodeDescription(const std::string &description, unsigned char &type)
Decode the string storage type to enumerated storage type.
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Resolve the references of the created transient object.
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)
Create a transient representation from another rep of this object.
virtual StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
Create an address using explicit arguments to identify a single object.
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert a transient object to a requested representation.
virtual StatusCode createCalib(DataObject *&refpObject, const std::string &fullpath, const CLID &classID, IRegistry *entry=0)
virtual StatusCode updateCalib(DataObject *pObject, const std::string &fullpath, const CLID &classID, IRegistry *entry=0)
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Resolve the references of a converted object.
StatusCode getSftParVer(std::string &SftVer, std::string &CalParVer, int &runfrm, int &runto, int RunNo, std::string BossRelease, std::string DataType)
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Update the references of an updated transient object.
CalibMySQLCnvSvc(const std::string &name, ISvcLocator *svc)
virtual calibUtil::Metadata * getMeta()
Handle to the MySQL metadata database.
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *pObject)
Update a transient representation from another rep of this object.
virtual StatusCode initialize()
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Update the references of an already converted object.
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0