Create a calib DataObject by calib type name, flavor and time. This method does not register DataObject in the transient data store. The string storage type is discovered at runtime in the Metadata dbs.
Create a calib DataObject by calib type, flavor, time and instrument. This method does not register DataObject in the transient data store, [but may register TDS addresses for its children if needed (e.g. Catalog).
471{
472 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc" );
473
474
476
477
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
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
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
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
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
527 if (st1 .isFailure() )
528 {
529 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
530 return st1;
531 }
532
533 ret = m_meta->getReadTOFInfo(ser,&runfrm,&runto,m_calPar[3],res,
runNo,m_bossver[3]);
534
535
536 }
537 }
538 else if ((cType=="TofCal")&&(m_bossver[3]!= "default" ))
539 {
540 m_flag[3]="set";
542
543 ret = m_meta->getReadTOFInfo(ser,&runfrm,&runto,m_calPar[3],res,
runNo,m_bossver[3]);
544
545 }
546
547
548
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
561
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
569 }
570 }
571 else if((cType=="EmcCal")&&(m_bossver[2]!= "default" ))
572 {
573 m_flag[2]="set";
575
576 ret = m_meta->getReadEMCInfo(ser,&runfrm,&runto, m_calPar[2], res,
runNo,m_bossver[2]);
577
578 }
579
580
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
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
600 }
601 }
602 else if((cType=="DedxCal")&&(m_bossver[1]!= "default" ))
603 {
604 m_flag[1]="set";
606
607 ret = m_meta->getReadDedxInfo(ser,&runfrm,&runto, m_calPar[1], res,
runNo,m_bossver[1]);
608
609 }
610
611
612 if((cType=="MdcCal")&&(m_bossver[0]== "default" ))
613 {
614 std::string cType="Mdc";
615
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
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
632
633 }
634 }
635 else if((cType=="MdcCal")&&(m_bossver[0]!= "default"))
636 {
637 m_flag[0]="set";
639
640 ret = m_meta->getReadMDCInfo(ser,&runfrm,&runto, m_calPar[0], res,
runNo,m_bossver[0]);
641
642
643 }
644
645
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
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
665 }
666 }
667 else if((cType=="MucCal")&&(m_bossver[4]!= "default" ))
668 {
669 m_flag[4]="set";
671
672 ret = m_meta->getReadMUCInfo(ser,&runfrm,&runto, m_calPar[4], res,
runNo,m_bossver[4]);
673
674 }
675
676
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
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
696 }
697 }
698 else if((cType=="EsTimeCal")&&(m_bossver[5]!= "default" ))
699 {
700 m_flag[5]="set";
702
703 ret = m_meta->getReadEsTimeInfo(ser,&runfrm,&runto, m_calPar[5], res,
runNo,m_bossver[5]);
704
705 }
706
707
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
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
724 }
725 }
726 else if((cType=="MdcAlign")&&(m_bossver[7]!= "default" ))
727 {
728 m_flag[7]="set";
730
731 ret = m_meta->getReadMdcAlignInfo(ser,&runfrm,&runto, m_calPar[7], res,
runNo,m_bossver[7]);
732
733 }
734
735
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
745 st1=
getSftParVer(m_bossver[8],m_calPar[8],runfrm1,runto1,
runNo,m_bossRelease,cType);
746
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
753 }
754 }
755 else if((cType=="TofQElec")&&(m_bossver[8]!= "default" ))
756 {
757 m_flag[8]="set";
759
760 ret = m_meta->getReadTofQElecInfo(ser,&runfrm,&runto, m_calPar[8], res,
runNo,m_bossver[8]);
761
762 }
763
764
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
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
781 }
782 }
783 else if((cType=="TofSim")&&(m_bossver[9]!= "default" ))
784 {
785 m_flag[9]="set";
787
788 ret = m_meta->getReadTofSimInfo(ser,&runfrm,&runto, m_calPar[9], res,
runNo,m_bossver[9]);
789
790 }
791
792
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
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
809 }
810 }
811 else if((cType=="DedxSim")&&(m_bossver[10]!= "default" ))
812 {
813 m_flag[10]="set";
815
816 ret = m_meta->getReadDedxSimInfo(ser,&runfrm,&runto, m_calPar[10], res,
runNo,m_bossver[10]);
817
818 }
819
820
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
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
837 }
838 }
839 else if((cType=="MdcDataConst")&&(m_bossver[11]!= "default" ))
840 {
841 m_flag[11]="set";
843
844 ret = m_meta->getReadMdcDataConstInfo(ser,&runfrm,&runto, m_calPar[11], res,
runNo,m_bossver[11]);
845
846 }
847
848
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
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
865 }
866 }
867 else if((cType=="EstTofCal")&&(m_bossver[6]!= "default" ))
868 {
869 m_flag[6]="set";
871
872 ret = m_meta->getReadEstTofInfo(ser,&runfrm,&runto, m_calPar[6], res,
runNo,m_bossver[6]);
873
874 }
875
876
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
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
896 }
897 }
898 else if((cType=="InjSigInterval")&&(m_bossver[12]!= "default"))
899 {
900 m_flag[12]="set";
902 ret = m_meta->getReadInjSigIntervalInfo(ser,&runfrm,&runto, m_calPar[12], res,
runNo,m_bossver[12]);
903
904
905 }
906
907
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
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
927 }
928 }
929 else if((cType=="InjSigTime")&&(m_bossver[13]!= "default"))
930 {
931 m_flag[13]="set";
933 ret = m_meta->getReadInjSigTimeInfo(ser,&runfrm,&runto, m_calPar[13], res,
runNo,m_bossver[13]);
934
935
936 }
937
938
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
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
958 }
959 }
960 else if((cType=="OffEvtFilter")&&(m_bossver[14]!= "default"))
961 {
962 m_flag[14]="set";
964 ret = m_meta->getReadOffEvtFilterInfo(ser,&runfrm,&runto, m_calPar[14], res,
runNo,m_bossver[14]);
965
966
967 }
968
969
970 if(cType=="CorrectedETS")
971 {
972 std::string cType="CorrectedETS";
973
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;
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";
1008
1009
1010
1011
1012
1013
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
1020
1021 const unsigned long ipar[2] = {0,0};
1022
1023
1024
1025
1026 tmpAddress = new TreeAddress(storageType, classID,*records1,ipar);
1027
1028
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
1034 {
1035 if(runfrm1>runfrm)
1036 {
1037 runfrm=runfrm1;
1038 }
1039 if(runto1<runto)
1040 {
1041 runto=runto1;
1042 }
1043 }
1045 {
1047 }
1048 log << MSG::DEBUG <<__LINE__<< " runfrm of max is:"<<runfrm<<" runto min is:"<<runto<<endreq;
1049 TreeAddress* treeAddress = dynamic_cast <TreeAddress*> (tmpAddress);
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064 tmpAddress->addRef();
1065
1066
1067 tmpAddress->setRegistry(entry);
1068
1069
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
1083 log << MSG::DEBUG << "New object successfully created" << endreq;
1084 return StatusCode::SUCCESS;
1087}
static std::string getCalibType(const std::string &fullpath)
Return calibration type name, extracted from full path name in TCDS.
virtual StatusCode decodeDescription(const std::string &description, unsigned char &type)
Decode the string storage type to enumerated storage type.
StatusCode getSftParVer(std::string &SftVer, std::string &CalParVer, int &runfrm, int &runto, int RunNo, std::string BossRelease, std::string DataType)
void setRunFrom(int runFrom)
set run from
void setRunTo(int runTo)
set run to