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