コード例 #1
0
ファイル: createCoolFolderAnFill.py プロジェクト: lenjoyn/DB
def defineFolderSpec( isMultiVersion ):
    recordSpec = cool.RecordSpecification()
    recordSpec.extend( "Offset", ST.Float )

    folderSpec = cool.FolderSpecification( FV.MULTI_VERSION if isMultiVersion else FV.SINGLE_VERSION,
                                           recordSpec )

    recordSpec2 = cool.RecordSpecification()
    recordSpec2.extend( "Noise", ST.Blob64k )

    folderSpec2 = cool.FolderSpecification( FV.MULTI_VERSION if isMultiVersion else FV.SINGLE_VERSION,
                                            recordSpec2 )
    
    return ( folderSpec, folderSpec2 )
コード例 #2
0
    def execute(self):

        folder = '/DMTest/TestAttrList'

        # do update - setup folder specification and create if needed
        spec = cool.RecordSpecification()
        spec.extend("xint", cool.StorageType.Int32)
        print(">== Store object in folder", folder)
        cfolder = AtlCoolLib.ensureFolder(
            self.db, folder, spec,
            AtlCoolLib.athenaDesc(self.runLumi, 'AthenaAttributeList'),
            cool.FolderVersioning.MULTI_VERSION)
        if (cfolder is None): sys.exit(1)
        # now write data
        payload = cool.Record(spec)
        payload['xint'] = self.xint
        print('>== Store object with IOV [', self.since, ',', self.until,
              '] and tag', self.tag, 'xint', self.xint)
        try:
            if (self.tag == "HEAD"):
                cfolder.storeObject(self.since, self.until, payload, 0)
            else:
                cfolder.storeObject(self.since, self.until, payload, 0,
                                    self.tag)
            print(">== Storing COOL object succeeded. Current content:")
        except Exception:
            import traceback
            traceback.print_exc()
            print('>== Storing COOL object FAILED')
            sys.exit(1)

        # print full content
        act = AtlCoolTool.AtlCoolTool(self.db)
        print(act.more(folder))
コード例 #3
0
    def execute(self):
        chanlist = self.getchans()
        if len(chanlist) == 0: sys.exit(1)
        # now do update - setup folder specification and create if needed
        spec = cool.RecordSpecification()
        spec.extend("NBuilt", cool.StorageType.Int32)
        print ">== Store object in folder", self.foldername
        cfolder = AtlCoolLib.ensureFolder(
            self.db, self.foldername, spec,
            AtlCoolLib.athenaDesc(True, 'CondAttrListCollection') + '<named/>',
            cool.FolderVersioning.SINGLE_VERSION)
        if (cfolder is None): sys.exit(1)
        # if we do not have data to add - finish here
        if (not self.isdata): return

        # now write data
        payload = cool.Record(spec)
        payload['NBuilt'] = self.nbuilt
        for channel in chanlist:
            print '>== Store object with IOV [', self.since, ',', self.until, '] channel', channel, 'NBuilt=', self.nbuilt
            try:
                cfolder.storeObject(self.since, self.until, payload, channel)
            except Exception, e:
                print e
                print 'Exception thrown when storing for channel', channel
                print '>== Storing COOL object FAILED'
                sys.exit(1)
コード例 #4
0
    def build_folder(cls, db, folder_name, multiversion, record):
        """
        Create `folder_name` on database instance `db`, with recordspecification
        `record`.
        
        Also creates folderset to which folder_name belongs if necessary.
        """
        from PyCool import cool

        folderset_path = dirname(folder_name)
        try:
            db.getFolderSet(folderset_path)
        except Exception as error:
            caught_error = "Folder set %s not found" % folderset_path
            if caught_error not in error.args[0]:
                raise

            log.debug("Folderset doesn't exist - creating it.")
            db.createFolderSet(folderset_path, "", True)

        if not isinstance(record, cool.RecordSpecification):
            record_spec = cool.RecordSpecification()
            for field in record:
                record_spec.extend(*field)
        else:
            record_spec = record

        FV = cool.FolderVersioning
        versioning = FV.MULTI_VERSION if multiversion else FV.SINGLE_VERSION
        folder_spec = cool.FolderSpecification(versioning, record_spec)
        folder = db.createFolder(folder_name, folder_spec)
        payload = cool.Record(record_spec)

        return folder, payload
コード例 #5
0
def createDB():
    """Create sqlite file with DCS currents"""
    from PyCool import cool
    from CoolConvUtilities import AtlCoolLib, AtlCoolTool

    # Cleanup previous file
    import os
    if os.path.isfile("magfield.db"):
        os.remove("magfield.db")

    db = cool.DatabaseSvcFactory.databaseService().createDatabase(
        'sqlite://;schema=magfield.db;dbname=CONDBR2')
    spec = cool.RecordSpecification()
    spec.extend("value", cool.StorageType.Float)
    spec.extend("quality_invalid", cool.StorageType.Bool)
    f = AtlCoolLib.ensureFolder(
        db, folder, spec, AtlCoolLib.athenaDesc(True,
                                                'CondAttrListCollection'))

    for v in currents:
        sol = cool.Record(spec)
        sol['value'] = v[1]
        sol['quality_invalid'] = False
        tor = cool.Record(spec)
        tor['value'] = v[2]
        tor['quality_invalid'] = False
        f.storeObject(v[0], cool.ValidityKeyMax, sol, 1)  # channel 1
        f.storeObject(v[0], cool.ValidityKeyMax, tor, 3)  # channel 3

    # print database content
    act = AtlCoolTool.AtlCoolTool(db)
    print(act.more(folder))
コード例 #6
0
def createSqlite(sqliteName,folderName="/TDAQ/OLC/LHC/FILLPARAMS"):

    dbSvc = cool.DatabaseSvcFactory.databaseService()

    if os.access(sqliteName,os.R_OK):
        print ("UPDATING existing sqlite file %s" % sqliteName)
        db=dbSvc.openDatabase("sqlite://;schema="+sqliteName+";dbname=CONDBR2",False)
    else:
        print("Creating new sqlite file %s" % sqliteName)
        db=dbSvc.createDatabase("sqlite://;schema="+sqliteName+";dbname=CONDBR2")
        pass
       
    spec = cool.RecordSpecification()
    spec.extend("Beam1Bunches",cool.StorageType.UInt32)
    spec.extend("Beam2Bunches",cool.StorageType.UInt32)
    spec.extend("LuminousBunches",cool.StorageType.UInt32)
    spec.extend("BCIDmasks",cool.StorageType.Blob64k)
    descr='<timeStamp>time</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>'

    if db.existsFolder(folderName):
        folder=db.getFolder(folderName)
    else:
        print("Creating COOL folder/tag  %s" % (folderName))
        #folder = db.createFolder(folderName, spec, desc, cool.FolderVersioning.MULTI_VERSION, True)
        folderSpec = cool.FolderSpecification(cool.FolderVersioning.SINGLE_VERSION, spec)
        folder = db.createFolder(folderName, folderSpec, descr, True)
        pass
      
    return db,folder
コード例 #7
0
def store_PID_to_folder(db, values_list):
    """
        Function to create folder FOLDER_NAME in db with channels and input data from values_list with tag TAG_NAME
        :param db: Open cool db
        :param values_list: list of tuples ('channel name', valus array)

        """
    spec = cool.RecordSpecification()
    spec.extend('array_value', cool.StorageType.Float)
    _logger.info('Create folder %s' % FOLDER_NAME)
    folder_spec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION,
                                           spec,
                                           cool.PayloadMode.VECTORPAYLOAD)
    folder = db.createFolder(
        FOLDER_NAME, folder_spec,
        ' <timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type="71" clid="55403898"/></addrHeader><typeName>CondAttrListVec</typeName>',
        True)

    for index, channel_name in enumerate(values_list):
        folder.createChannel(index, channel_name[0])
        print '%i - %s' % (index, channel_name[0])
    folder.setupStorageBuffer()
    for index, channel_values in enumerate(values_list):
        _logger.info('Store data from %s' % channel_values[0])
        values = channel_values[1]
        #     print channel_values[0]
        #     print channel_values[1]
        vector = cool.IRecordVector()
        for value in values:
            #         print value
            data = cool.PyCool.Helpers.IRecordPtr(spec)
            data.get()['array_value'] = value
            vector.push_back(data)
        folder.storeObject(0, cool.ValidityKeyMax, vector, index, TAG_NAME)
    folder.flushStorageBuffer()
コード例 #8
0
def createRPCConditionDB():
    import os
    from PyCool import cool

    # get database service and open database
    dbSvc = cool.DatabaseSvcFactory.databaseService()
    # database accessed via physical name
    dbstring = 'sqlite://;schema=RPCConditionDB.db;dbname=RPC_DQA'
    if os.access('RPCConditionDB.db', os.R_OK):
        try:
            os.unlink('RPCConditionDB.db')
        except Exception as e:
            print('Unable to remove existing db file, reason', e)
    try:
        db = dbSvc.createDatabase(dbstring)
    except Exception as e:
        print('Problem creating database', e)
        return
    print("Created database", dbstring)

    spec2 = cool.RecordSpecification()
    spec2.extend("PanelRes", cool.StorageType.String255)
    spec2.extend("StripStatus", cool.StorageType.String4k)

    desc = "<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type=\"71\" clid=\"1238547719\" /></addrHeader><typeName>CondAttrListCollection</typeName>"

    # create the folder - single version
    # last argument is createParents - if true, automatically creates parent
    # folders if needed
    # note this will not work if the database already exists - delete mycool.db first
    # Deprecated/dropped:  myfolder=db.createFolder('/OFFLINE/FINAL',spec2,desc,cool.FolderVersioning.MULTI_VERSION,True)
    folderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION,
                                          spec2)
    db.createFolder('/OFFLINE/FINAL', folderSpec, desc, True)
    db.closeDatabase()
コード例 #9
0
ファイル: CoolDB.py プロジェクト: lenjoyn/DB
def defineFolderSpecTypeName(Name, Type, isMultiVersion):
    recordSpec = cool.RecordSpecification()
    #    recordSpec.extend( "Maps", ST.Float )
    recordSpec.extend(Name, Type)
    folderSpec = cool.FolderSpecification(
        FV.MULTI_VERSION if isMultiVersion else FV.SINGLE_VERSION, recordSpec)

    return (folderSpec)
コード例 #10
0
def createFolder(db, name):
    desc = '<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type="71" clid="1238547719" /></addrHeader><typeName>CondAttrListCollection</typeName>'
    spec = cool.RecordSpecification()
    spec.extend('LBAvInstLumi', cool.StorageType.Float)
    spec.extend('Valid', cool.StorageType.UInt32)
    folderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION,
                                          spec)
    #return db.createFolder(name,spec,desc,cool.FolderVersioning.MULTI_VERSION, True)
    return db.createFolder(name, folderSpec, desc, True)
コード例 #11
0
    def __init__(self,
                 db,
                 folderPath,
                 caloBlobType=None,
                 isMultiVersionFolder=True,
                 isRunLumiTimeStamp=True):
        """
        Input:
        - db        : db should be an open database connection 
        - folderPath: full folder path to create or update
        """

        #=== initialize base class
        CaloCondLogger.__init__(self, "CaloBlobWriter")

        #=== store db
        self.__db = db

        #=== determine folder mode
        folderMode = cool.FolderVersioning.MULTI_VERSION
        if not isMultiVersionFolder:
            folderMode = cool.FolderVersioning.SINGLE_VERSION

        #=== determine folder description
        folderDescr = getAthenaFolderDescr()

        #=== access folder in db
        try:
            #=== create folder if it does not exist
            if self.__db.existsFolder(folderPath):
                self.__folder = self.__db.getFolder(folderPath)
                #=== check folder mode
                modeInCool = self.__folder.versioningMode()
                if modeInCool != folderMode:
                    str = "Incompatible folder mode detected, COOL folder has type "
                    if modeInCool == cool.FolderVersioning.MULTI_VERSION:
                        str += "MULTI"
                    else:
                        str += "SINGLE"
                    raise Exception(str)
            else:
                #=== create folder if it does not exist
                payloadSpec = cool.RecordSpecification()
                payloadSpec.extend('CaloCondBlob16M', cool.StorageType.Blob16M)
                folderSpec = cool.FolderSpecification(folderMode, payloadSpec)
                self.__folder = db.createFolder(folderPath, folderSpec,
                                                folderDescr, True)
        except Exception as e:
            self.log().critical(e)
            raise

        #=== initialize channel dictionaries
        self.__chanDictRecord = {}  # <int, cool.Record    >
        self.__chanDictCells = {}  # <int, CaloCondBlobFlt>
コード例 #12
0
    def _create_defect_logic_folder(self, db):
        """
        Creates the COOL database/folder for virtual defect logic, if they don't exist.
        Internal - use create=True in the constructor to create the COOL folder.
        """
        log.info("Creating defect logic folder")

        record_spec = cool.RecordSpecification()
        record_spec.extend("clauses", ST.String4k)

        folder_spec = cool.FolderSpecification(FV.MULTI_VERSION, record_spec)
        return db.createFolder(DEFECT_LOGIC_FOLDER, folder_spec,
                               DEFECT_LOGIC_FOLDER_DESC, True)
コード例 #13
0
    def write_geometry(self, new_file_name):
        print(" Writing geometry to file ", new_file_name)

        dbSvc = cool.DatabaseSvcFactory.databaseService()
        connectString = 'sqlite://;schema=' + new_file_name + ';dbname=L1CALO'

        print('Writing into database file', new_file_name)
        db = dbSvc.openDatabase(connectString, False)

        spec = cool.RecordSpecification()
        spec.extend('NLayers', cool.StorageType.UChar)

        spec.extend('Name1', cool.StorageType.UChar)
        spec.extend('Name2', cool.StorageType.UChar)
        spec.extend('Name3', cool.StorageType.UChar)
        spec.extend('Name4', cool.StorageType.UChar)

        spec.extend('NCells1', cool.StorageType.UChar)
        spec.extend('NCells2', cool.StorageType.UChar)
        spec.extend('NCells3', cool.StorageType.UChar)
        spec.extend('NCells4', cool.StorageType.UChar)

        now = int(time.time())

        since = now * self.UNIX2COOL
        until = cool.ValidityKeyMax

        folder_description = "<timeStamp>time</timeStamp><addrHeader><address_header service_type=\"71\" clid=\"1238547719\"/></addrHeader><typeName>CondAttrListCollection</typeName>"
        f = db.createFolder("/TRIGGER/L1Calo/V1/Results/RxLayers", spec,
                            folder_description)

        for i in self.NLayers.keys():

            data = cool.Record(spec)

            data['NLayers'] = struct.pack('B', self.NLayers[i])
            data['Name1'] = struct.pack('B', self.LayerName[i][0])
            data['Name2'] = struct.pack('B', self.LayerName[i][1])
            data['Name3'] = struct.pack('B', self.LayerName[i][2])
            data['Name4'] = struct.pack('B', self.LayerName[i][3])

            data['NCells1'] = struct.pack('B', self.NCells[i][0])
            data['NCells2'] = struct.pack('B', self.NCells[i][1])
            data['NCells3'] = struct.pack('B', self.NCells[i][2])
            data['NCells4'] = struct.pack('B', self.NCells[i][3])

            f.storeObject(since, until, data, int(i, 16))

        db.closeDatabase()

        return
コード例 #14
0
def tests():
    print 'AtlCoolLib tests'
    db = forceOpen("TESTCOOL")
    if (db is None):
        print 'Could not create test database'
        sys.exit(1)
    spec = cool.RecordSpecification()
    spec.extend('testString', cool.StorageType.String255)
    folder = ensureFolder(db, '/TEST/TEST1', spec,
                          athenaDesc(True, 'CondAttrListCollection'),
                          cool.FolderVersioning.MULTI_VERSION)
    if (folder is None):
        print 'Could not create test folder'
        sys.exit(1)
    print 'All done'
    return
コード例 #15
0
    def _create_defects_folder(self, db):
        """
        Creates the COOL database/folder for defects, if they don't exist.
        Internal - use create=True in the constructor to create the COOL folder.
        """
        log.info("Creating defects folder")

        record_spec = cool.RecordSpecification()
        record_spec.extend("present", ST.Bool)
        record_spec.extend("recoverable", ST.Bool)
        record_spec.extend("user", ST.String255)
        record_spec.extend("comment", ST.String255)

        folder_spec = cool.FolderSpecification(FV.MULTI_VERSION, record_spec)
        return db.createFolder(DEFECTS_FOLDER, folder_spec, DEFECT_FOLDER_DESC,
                               True)
コード例 #16
0
 def execute(self):
     # do update - setup folder specification and create if needed
     spec = cool.RecordSpecification()
     spec.extend("status", cool.StorageType.Int32)
     spec.extend("posX", cool.StorageType.Float)
     spec.extend("posY", cool.StorageType.Float)
     spec.extend("posZ", cool.StorageType.Float)
     spec.extend("sigmaX", cool.StorageType.Float)
     spec.extend("sigmaY", cool.StorageType.Float)
     spec.extend("sigmaZ", cool.StorageType.Float)
     spec.extend("tiltX", cool.StorageType.Float)
     spec.extend("tiltY", cool.StorageType.Float)
     spec.extend("sigmaXY", cool.StorageType.Float)
     folder = '/Indet/Beampos'
     print ">== Store object in folder", folder
     cfolder = AtlCoolLib.ensureFolder(
         self.db, folder, spec,
         AtlCoolLib.athenaDesc(self.runLumi, 'AthenaAttributeList'),
         cool.FolderVersioning.MULTI_VERSION)
     if (cfolder is None): sys.exit(1)
     # now write data
     payload = cool.Record(spec)
     payload['status'] = self.status
     payload['posX'] = self.posx
     payload['posY'] = self.posy
     payload['posZ'] = self.posz
     payload['sigmaX'] = self.sigmax
     payload['sigmaY'] = self.sigmay
     payload['sigmaZ'] = self.sigmaz
     payload['tiltX'] = self.tiltx
     payload['tiltY'] = self.tilty
     payload['sigmaXY'] = self.sigmaxy
     print '>== Store object with IOV [', self.since, ',', self.until, '] and tag', self.tag, 'status', self.status
     print '>== Beamspot position (mm):', self.posx, self.posy, self.posz
     print '>== Beamspot sigma    (mm):', self.sigmax, self.sigmay, self.sigmaz
     print '>== Beamspot tilt    (rad):', self.tiltx, self.tilty
     try:
         if (self.tag == "HEAD"):
             cfolder.storeObject(self.since, self.until, payload, 0)
         else:
             cfolder.storeObject(self.since, self.until, payload, 0,
                                 self.tag)
         print ">== Storing COOL object succeeded"
     except Exception, e:
         print e
         print '>== Storing COOL object FAILED'
         sys.exit(1)
コード例 #17
0
    def __init__(self):
        self.records = []
        self.iovStartRun = 0
        self.iovStartLumiBlock = 0
        self.iovEndRun = 0
        self.iovEndLumiBlock = 0

        self.tag = "AFPTest-00-00-00"
        self.folderName = "/FWD/AFP/TEST"
        self.spec = cool.RecordSpecification()
        #        self.spec.extend("data", cool.StorageType.Blob64k)
        self.spec.extend("data", cool.StorageType.String16M)
        #        self.desc = '<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type="71" clid="1238547719" /></addrHeader><typeName>CondAttrListCollection</typeName>'
        self.desc = '<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>'
        self.data = cool.Record(self.spec)
        self.folderSpec = cool.FolderSpecification(
            cool.FolderVersioning.MULTI_VERSION, self.spec)
コード例 #18
0
def openBeamSpotDbFile(fileName,
                       forceNew=False,
                       folderName='/Indet/Beampos',
                       dbName='BEAMSPOT'):
    """Open a beam spot SQLite COOL file and get a `folderHandle` to the beam spot folder. If the folder
       doesn't exist yet, it is created. If the SQLite file doesn't exist, it is created. If forceNew=True,
       any previously existing output file with the specified name is overwritten."""
    connString = 'sqlite://;schema=%s;dbname=%s' % (fileName, dbName)
    dbSvc = cool.DatabaseSvcFactory.databaseService()
    if forceNew and os.path.exists(fileName):
        os.remove(fileName)
    if os.path.exists(fileName):
        db = dbSvc.openDatabase(connString, False)
    else:
        db = dbSvc.createDatabase(connString)

    # Make sure we have /Indet/Beampos with the correct schema
    spec = cool.RecordSpecification()
    spec.extend("status", cool.StorageType.Int32)
    spec.extend("posX", cool.StorageType.Float)
    spec.extend("posY", cool.StorageType.Float)
    spec.extend("posZ", cool.StorageType.Float)
    spec.extend("sigmaX", cool.StorageType.Float)
    spec.extend("sigmaY", cool.StorageType.Float)
    spec.extend("sigmaZ", cool.StorageType.Float)
    spec.extend("tiltX", cool.StorageType.Float)
    spec.extend("tiltY", cool.StorageType.Float)
    spec.extend("sigmaXY", cool.StorageType.Float)
    spec.extend("posXErr", cool.StorageType.Float)
    spec.extend("posYErr", cool.StorageType.Float)
    spec.extend("posZErr", cool.StorageType.Float)
    spec.extend("sigmaXErr", cool.StorageType.Float)
    spec.extend("sigmaYErr", cool.StorageType.Float)
    spec.extend("sigmaZErr", cool.StorageType.Float)
    spec.extend("tiltXErr", cool.StorageType.Float)
    spec.extend("tiltYErr", cool.StorageType.Float)
    spec.extend("sigmaXYErr", cool.StorageType.Float)

    folder = AtlCoolLib.ensureFolder(
        db, folderName, spec, AtlCoolLib.athenaDesc(True,
                                                    'AthenaAttributeList'),
        cool.FolderVersioning.MULTI_VERSION)

    folderHandle = (db, folder, spec)
    return folderHandle
コード例 #19
0
def createSqlite(sqliteName,
                 folderName,
                 foldertag,
                 iovMin=cool.ValidityKeyMin,
                 iovMax=cool.ValidityKeyMax,
                 inputFileName=None,
                 defaultvalue=1.0):

    dbSvc = cool.DatabaseSvcFactory.databaseService()

    if os.access(sqliteName, os.R_OK):
        print("UPDATING existing sqlite file", sqliteName)
        db = dbSvc.openDatabase(
            "sqlite://;schema=" + sqliteName + ";dbname=CONDBR2", False)
    else:
        print("Creating new sqlite file", sqliteName)
        db = dbSvc.createDatabase("sqlite://;schema=" + sqliteName +
                                  ";dbname=CONDBR2")

    spec = cool.RecordSpecification()
    spec.extend('CaloCondBlob16M', cool.StorageType.Blob16M)

    desc = '<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>'

    if db.existsFolder(folderName):
        folder = db.getFolder(folderName)
    else:
        print("Creating COOL folder/tag  %s/%s" % (folderName, foldertag))
        #folder = db.createFolder(folderName, spec, desc, cool.FolderVersioning.MULTI_VERSION, True)
        folderSpec = cool.FolderSpecification(
            cool.FolderVersioning.MULTI_VERSION, spec)
        folder = db.createFolder(folderName, folderSpec, desc, True)
        pass

    if inputFileName is None or len(inputFileName) == 0:
        print("No input given. Create empty blob")
        data = cool.Record(spec)
    else:
        data = CaloCondBlobWriterFromFile(spec, inputFileName, defaultvalue)

    print("Storing CaloCondBlob object")
    folder.storeObject(iovMin, iovMax, data, cool.ChannelId(0), foldertag,
                       True)

    db.closeDatabase()
コード例 #20
0
def WriteSqlite(name, input_dict):

    UNIX2COOL = 1000000000

    dbSvc = cool.DatabaseSvcFactory.databaseService()
    connectString = 'sqlite://;schema=' + name + ';dbname=L1CALO'
    # folder_name="/TRIGGER/Receivers/Factors/CalibGains"

    print('\nrecreating database file:', name)
    dbSvc.dropDatabase(connectString)
    db = dbSvc.createDatabase(connectString)

    spec = cool.RecordSpecification()
    spec.extend("factor", cool.StorageType.Float)
    spec.extend("status", cool.StorageType.UInt32)
    folderSpec = cool.FolderSpecification(cool.FolderVersioning.SINGLE_VERSION,
                                          spec)

    now = int(time.time())

    since = now * UNIX2COOL
    # since = 0
    #  until = sys.maxint
    until = cool.ValidityKeyMax
    db.createFolderSet('/TRIGGER')
    db.createFolderSet('/TRIGGER/Receivers')
    db.createFolderSet('/TRIGGER/Receivers/Factors')

    folder_description = '<timeStamp>time</timeStamp><addrHeader><address_header service_type="71" clid="1238547719"/></addrHeader><typeName>CondAttrListCollection</typeName>'
    f = db.createFolder("/TRIGGER/Receivers/Factors/CalibGains", folderSpec,
                        folder_description)

    print(" Now creating sqlite file for ", len(input_dict.keys()),
          " channels")
    for i in input_dict.keys():
        data = cool.Record(spec)
        data['factor'] = input_dict[i][0]
        data['status'] = input_dict[i][1]
        f.storeObject(since, until, data, int(i, 16))

    db.closeDatabase()
コード例 #21
0
 def execute(self):
     print '>== Inserting reference to file:', self.file, ' - find GUID'
     os.system('coolHist_extractFileIdentifier.sh %s' % self.file)
     guid = open('coolhist_guid.tmp', 'r').readline()[:-1]
     if (guid == 'none'):
         print '>== File has no GUID - aborting'
         sys.exit(1)
     # setup folder specification and create if needed
     spec = cool.RecordSpecification()
     spec.extend("fileGUID", cool.StorageType.String4k)
     cfolder = AtlCoolLib.ensureFolder(
         self.db, self.folder, spec,
         AtlCoolLib.athenaDesc(self.runLumi, 'CondAttrListCollection') +
         '<named/>', cool.FolderVersioning.MULTI_VERSION)
     print
     if (cfolder is None): sys.exit(1)
     # check if channel number needs to be looked up
     if (self.channelstr != ""):
         try:
             self.channel = cfolder.channelId(self.channelstr)
             print '>== Channel name', self.channelstr, 'is channelId', self.channel
         except Exception:
             print 'Non-existant or invalid channel name:', self.channelstr
             sys.exit(1)
     print '>== Write data on COOL connection:', self.conn
     print '>== To folder:', self.folder, 'channel:', self.channel
     print '>== COOL tag:', self.tag
     # now write data
     payload = cool.Record(spec)
     payload['fileGUID'] = guid
     print '>== Store object with IOV [', self.since, ',', self.until, '] channel', self.channel, 'and tag', self.tag
     try:
         cfolder.storeObject(self.since, self.until, payload, self.channel,
                             self.tag)
         return
     except Exception, e:
         print e
         print '>== Storing COOL object FAILED'
         sys.exit(1)
コード例 #22
0
    def BadChan_SaveBadChannelCorrectionsToDatabase(self, dbstring, dbSvc,
                                                    dbFolderName, selectedTag):

        listKeys = self.dict_vectBadChanEntry.keys()
        listKeys.sort()

        # Create LArBadChannel object for defined BadChanEntry vector and coolChan
        self.class_LArBadChannelState = PyCintex.makeClass(
            'LArBadChannelState')
        inst_larBadChannelState = self.class_LArBadChannelState()

        # Loop over cool channels
        bStoreNewCoolChannels = False
        bNewDBCreated = False
        for coolChan in listKeys:

            vect_BadChanEntry = PyCintex.gbl.std.vector(
                'std::pair<HWIdentifier,LArBadChannel>')()

            listHWidKeys = [
                x for x in self.dict_vectBadChanEntry[coolChan].keys()
            ]
            listHWidKeys.sort()
            iNbCorrection = 0
            for key in listHWidKeys:

                sHWid = key
                if self.dict_vectBadChanEntry_Status[coolChan][
                        sHWid] == STATUS_INIT:
                    badChan_word = self.dict_vectBadChanEntry_Init[coolChan][
                        sHWid][1]
                elif self.dict_vectBadChanEntry_Status[coolChan][
                        sHWid] == STATUS_MODIFIED or self.dict_vectBadChanEntry_Status[
                            coolChan][sHWid] == STATUS_NEW:
                    iNbCorrection += 1
                    badChan_word = self.dict_vectBadChanEntry[coolChan][sHWid][
                        1]
                elif self.dict_vectBadChanEntry_Status[coolChan][
                        sHWid] == STATUS_REMOVED:
                    iNbCorrection += 1
                    continue

                obj_HWid = self.class_HWIdentifier()
                obj_HWid.set(sHWid)
                larBadChannel = self.class_LArBadChannel(badChan_word)

                pair_BadChanEntry = PyCintex.gbl.pair(
                    'HWIdentifier,LArBadChannel')(obj_HWid, larBadChannel)
                vect_BadChanEntry.push_back(pair_BadChanEntry)

            # if correction were made => store BadChanEntry vector
            if iNbCorrection > 0:
                for sEntry in vect_BadChanEntry:
                    inst_larBadChannelState.add(sEntry, coolChan)
                bStoreNewCoolChannels = True
            else:
                continue

            # Create object based on new LArBadChannelState (via LArBadChannelDBTools python interface)
            attrListSpec = PyCintex.gbl.coral.AttributeListSpecification()
            athenaAttrList = PyCintex.gbl.AthenaAttributeList()

            attrListSpec = self.nspace_LArBadChannelDBTools.createCoolSpec()
            athenaAttrList = self.nspace_LArBadChannelDBTools.createPayload(
                inst_larBadChannelState.coolChannel(coolChan), attrListSpec)

            # if save DB has not been created => do it
            if bNewDBCreated == False:
                import os
                try:
                    dbSave = dbSvc.createDatabase(dbstring)
                except Exception, e:
                    print 'Problem opening database', e
                    sys.exit(-1)
                print "Opened database", dbstring

                desc = '<timeStamp>run-event</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>'

                # Create cool spec from AttributeListSpec
                coolSpec = cool.RecordSpecification()
                for iElemt in range(0, attrListSpec.size()):
                    attrSpec = attrListSpec[iElemt]
                    typeName = attrSpec.typeName()
                    if typeName == "unsigned int":
                        coolSpec.extend(attrSpec.name(),
                                        cool.StorageType.UInt32)
                    elif typeName == "blob":
                        coolSpec.extend(attrSpec.name(),
                                        cool.StorageType.Blob64k)
                    else:
                        print "Undefined cool.StorageType " + typeName

#                myfolder=dbSave.createFolder(dbFolderName, coolSpec, desc, cool.FolderVersioning.SINGLE_VERSION,True)
                myfolder = dbSave.createFolder(
                    dbFolderName, coolSpec, desc,
                    cool.FolderVersioning.MULTI_VERSION, True)

                import string
                IOVBeginEnd = ["90", "9999999"]
                beginRun = string.atoi(IOVBeginEnd[0]) << 32
                endRun = string.atoi(IOVBeginEnd[1]) << 32

                bNewDBCreated = True

            # Create cool payload from AthenaAttributeList payload
            coolPayload = cool.Record(coolSpec)
            for iElemt in range(0, attrListSpec.size()):
                attrSpec = attrListSpec[iElemt]
                coolPayload[attrSpec.name()] = athenaAttrList[attrSpec.name()]

            # Store cool object to folder
            myfolder.storeObject(beginRun, endRun, coolPayload, coolChan,
                                 selectedTag)
コード例 #23
0
    def genDb(self, dbFileName, dbName, params, folderPath, params64={}):

        # Do checks
        if self.beginRun is None:
            raise ParameterDbFillerError(
                'Must set begin run number before generating db')
        if self.endRun is None:
            raise ParameterDbFillerError(
                'Must set end run number before generating db')
        if len(params) == 0:
            raise ParameterDbFillerError('No parameters for db ' + dbName)

        # remove existing db, if any
        try:
            os.remove(dbFileName)
            print("ParameterDbFiller.genDb:  Removed db", dbFileName)
        except Exception:
            pass

        # get database service and open database
        dbSvc = cool.DatabaseSvcFactory.databaseService()

        # build dbstring - database accessed via physical name
        dbstring = "sqlite://;schema=" + dbFileName + ";dbname=" + dbName
        try:
            db = dbSvc.createDatabase(dbstring)
        except Exception as e:
            print('ParameterDbFiller.genDb:  Problem creating database', e)
            sys.exit(-1)
            print("ParameterDbFiller.genDb:  Created database", dbstring)

        # setup a folder payload specification
        spec = cool.RecordSpecification()
        for key in params:
            spec.extend(key, cool.StorageType.String4k)
            pass
        # add in spec for long strings
        for key in params64:
            spec.extend(key, cool.StorageType.String64k)

        # folder meta-data - note for Athena this has a special meaning
        desc = '<timeStamp>run-event</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>'
        # create the folder - single version
        # last argument is createParents - if true, automatically creates parent
        # folders if needed
        # note this will not work if the database already exists - delete mycool.db first
        # myfolder=db.createFolder(folderPath, spec, desc, cool.FolderVersioning.SINGLE_VERSION,True)
        folderSpec = cool.FolderSpecification(
            cool.FolderVersioning.SINGLE_VERSION, spec)
        myfolder = db.createFolder(folderPath, folderSpec, desc, True)

        # now fill in parameters
        data = cool.Record(spec)
        for k, v in six.iteritems(params):
            data[k] = v
        for k, v in six.iteritems(params64):
            data[k] = v

        print("ParameterDbFiller.genDb:  Recording parameters", data)

        # store object with IOV valid from 0-10, channel 3
        myfolder.storeObject(self.beginRun, self.endRun, data, 0)
        print("ParameterDbFiller.genDb:  Stored object")

        # finalize
        db.closeDatabase()

        # Try to dump out db as test
        self.dumpDb(dbstring)
コード例 #24
0
class ParameterDbFiller(object):
    """
    A simple class used to fill SQLite db file with parameters for simulation
    and/or digitization.
    """
    
    def __init__(self):
        object.__init__(self)

        self.beginRun      = None
        self.endRun        = None
        self.simParams     = {}
        self.digitParams   = {}
        self.digitParams64 = {}
        return

    # 
    def setBeginRun(self, beginRun):
        self.beginRun    = beginRun << 32
        return

    def setEndRun(self, endRun):
        self.endRun      = endRun << 32
        return

    def addSimParam(self, name, value):
        self.simParams[name] = value
        return

    def addDigitParam(self, name, value):
        self.digitParams[name] = value
        return

    def addDigitParam64(self, name, value):
        self.digitParams64[name] = value
        return

    def genSimDb(self, dbFileName = None):
        # Allow to define specific file name, otherwise use 
        customDb = False
        if dbFileName == None:
            # Set to default value
            dbFileName = "SimParams.db"
            customDb = True

        # Generate db: args -  file name, dbname, params, folder path
        self.genDb(dbFileName, 'SIMPARAM', self.simParams, '/Simulation/Parameters')


    def genDigitDb(self, dbFileName = None):
        # Allow to define specific file name, otherwise use 
        customDb = False
        if dbFileName == None:
            # Set to default value
            dbFileName = "DigitParams.db"
            customDb = True

        # Generate db: args -  file name, dbname, params, folder path
        self.genDb(dbFileName, 'DIGPARAM', self.digitParams, '/Digitization/Parameters', self.digitParams64)


    def genDb(self, dbFileName, dbName, params, folderPath, params64 = {}):

        # Do checks
        if self.beginRun == None:
            raise ParameterDbFillerError, 'Must set begin run number before generating db'
        if self.endRun == None:
            raise ParameterDbFillerError, 'Must set end run number before generating db'
        if len(params) == 0:
            raise ParameterDbFillerError, 'No parameters for db ' + dbName

        # remove existing db, if any
        try:
            os.remove(dbFileName)
            print "ParameterDbFiller.genDb:  Removed db", dbFileName
        except:
            pass

        # get database service and open database
        dbSvc=cool.DatabaseSvcFactory.databaseService()

        # build dbstring - database accessed via physical name
        dbstring="sqlite://;schema=" + dbFileName + ";dbname=" + dbName
        try:
            db=dbSvc.createDatabase(dbstring)
        except Exception,e:
            print 'ParameterDbFiller.genDb:  Problem creating database',e
            sys.exit(-1)
            print "ParameterDbFiller.genDb:  Created database",dbstring
        
        # setup a folder payload specification
        spec=cool.RecordSpecification()
        for key in params:
            spec.extend(key, cool.StorageType.String4k)
            pass
        # add in spec for long strings
        for key in params64:
            spec.extend(key, cool.StorageType.String64k)

        # folder meta-data - note for Athena this has a special meaning
        desc = '<timeStamp>run-event</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>'
        # create the folder - single version
        # last argument is createParents - if true, automatically creates parent
        # folders if needed
        # note this will not work if the database already exists - delete mycool.db first
        # myfolder=db.createFolder(folderPath, spec, desc, cool.FolderVersioning.SINGLE_VERSION,True)
        folderSpec = cool.FolderSpecification(cool.FolderVersioning.SINGLE_VERSION, spec)
        myfolder   = db.createFolder(folderPath, folderSpec, desc, True)

        # now fill in parameters
        data = cool.Record(spec)
        for k, v in params.iteritems():
            data[k] = v
        for k, v in params64.iteritems():
            data[k] = v

        print "ParameterDbFiller.genDb:  Recording parameters", data

        # store object with IOV valid from 0-10, channel 3
        myfolder.storeObject(self.beginRun, self.endRun, data, 0)
        print "ParameterDbFiller.genDb:  Stored object"

        # finalize
        db.closeDatabase()

        # Try to dump out db as test
        self.dumpDb(dbstring)
コード例 #25
0
class mergeStatus(AtlCoolLib.coolTool):
    def setup(self, args):
        # set values of non-optional parameters
        self.destdbstr = str(args[0])
        # access to name encoding
        self.namelookup = DetStatusLib.DetStatusNames()
        self.folderinfo = []
        self.destfolder = '/GLOBAL/DETSTATUS/LBSUMM'
        self.tag = ''
        self.truncate = False
        self.numbers = False

    def usage(self):
        "Define additional syntax for options"
        self._usage1()
        print 'destdbname'
        print '--and=<folder> : set folder name to be Anded'
        print '--override=<folder>:<tag> : set folder and tag name for override'
        print '--destfolder=<folder> : set destinaton folder (default /GLOBAL/DETSTATUS/LBSUMM'
        print '--desttag=<tag> : set destination tag'
        print '--numbers : Transfer NConfig and NWorking from source folders if given'
        print '--truncate : truncate IOVs which exceed given interval'
        self._usage2()

    def procopts(self, opts):
        "Process additional options"
        for o, a in opts:
            if (o == '--and' or o == '--override'):
                fields = str(a).split(':')
                folder = fields[0]
                if len(fields) > 1:
                    tag = fields[1]
                else:
                    tag = 'HEAD'
                self.folderinfo += [(folder, tag, (o == '--override'))]
            if (o == '--destfolder'):
                self.destfolder = str(a)
            if (o == '--numbers'):
                self.numbers = True
            if (o == '--desttag'):
                self.tag = str(a)
            if (o == '--truncate'):
                self.truncate = True

    def execute(self):
        # print "Name is %s" AtlCoolLib.getHostname()
        # prepare an empty StatusList for each channel
        statuslists = {}
        for chan in self.namelookup.allNums():
            statuslists[chan] = DetStatusLib.StatusList()

        # deduce the source database instance name, looking for xyzP200
        idx = self.conn.find('P200')
        if (idx >= 3):
            dbinst = self.conn[idx - 3:idx + 4]
            print "Working with database instance %s" % dbinst
        else:
            print "Cannot deduce database instance name, assume COMP200"
            dbinst = 'COMP200'

        # Extract timestamp information for mapping to run/LB
        tsconvdb = AtlCoolLib.indirectOpen('COOLONL_TRIGGER/' + dbinst,
                                           oracle=self.oracle)
        # initialize the converter
        tsToRLB = AtlCoolLib.TimeStampToRLB(tsconvdb, self.since, self.until)
        tsconvdb.closeDatabase()

        StartTime = tsToRLB.StartTime
        EndTime = tsToRLB.EndTime

        # open auxillary databases for online and DCS info
        onlinedb = AtlCoolLib.indirectOpen('COOLONL_GLOBAL/' + dbinst,
                                           oracle=self.oracle)
        dcsdb = AtlCoolLib.indirectOpen('COOLOFL_GLOBAL/' + dbinst,
                                        oracle=self.oracle)

        # loop over all 'AND' folders and merge information
        ngood = 0
        nbad = 0
        for (afolder, atag, override) in self.folderinfo:
            print "Process folder %s tag %s override %d" % (afolder, atag,
                                                            override)
            try:
                atsindexed = 0
                isonline = 0
                if (afolder.find("ONL") != -1):
                    isonline = 1

                isdcs = 0
                if (afolder.find("DCS") != -1):
                    isdcs = 1

                tostart = self.since
                toend = self.until
                ifolder = None

                if (isonline):
                    ifolder = onlinedb.getFolder(afolder)
                elif (isdcs):
                    ifolder = dcsdb.getFolder(afolder)
                else:
                    ifolder = self.db.getFolder(afolder)

                descr = ifolder.description()

                if (descr.find("<timeStamp>time") != -1):
                    atsindexed = 1
                    tostart = StartTime
                    toend = EndTime

                objs = None
                if (isonline | isdcs):
                    objs = ifolder.browseObjects(tostart, toend,
                                                 cool.ChannelSelection.all())
                else:
                    objs = ifolder.browseObjects(tostart, toend,
                                                 cool.ChannelSelection.all(),
                                                 atag)

                while objs.goToNext():
                    obj = objs.currentRef()
                    chan = obj.channelId()
                    if (chan in statuslists.keys()):
                        start = obj.since()
                        stop = obj.until()
                        payload = obj.payload()
                        code = payload['Code']
                        deadfrac = payload['deadFrac']
                        thrust = payload['Thrust']
                        if ('NConfig' in payload.keys()):
                            nconfig = payload['NConfig']
                            nworking = payload['NWorking']
                        else:
                            nconfig = -1
                            nworking = -1

                        if ('Comment' in payload.keys()):
                            comment = payload['Comment']
                        else:
                            comment = ''
                        #override=False

                        if (atsindexed):
                            start = tsToRLB.getRLB(start, True)
                            stop = tsToRLB.getRLB(stop, False) + 1

                        statuslists[chan].merge(
                            DetStatusLib.StatusObj(start, stop, code, deadfrac,
                                                   thrust, nconfig, nworking,
                                                   comment), override)
                        ngood += 1
                    else:
                        print "Data found for unexpected channel %i" % chan
                        nbad += 1
            except Exception, e:
                print e
                print "Problem accessing folder %s" % afolder
                nbad += 1

        print "All folders processed with %i good and %i items of bad data" % (
            ngood, nbad)

        # now compose COOL update
        # establish write connection
        writedb = AtlCoolLib.forceOpen(self.destdbstr)
        if (writedb is None): return
        try:
            cfolder = writedb.getFolder(self.destfolder)
            print "Write data to existing folder %s" % self.destfolder
            spec = cfolder.payloadSpecification()
        except Exception, e:
            print "Creating destination folder %s" % self.destfolder
            spec = cool.RecordSpecification()
            spec.extend("Code", cool.StorageType.Int32)
            spec.extend("deadFrac", cool.StorageType.Float)
            spec.extend("Thrust", cool.StorageType.Float)
            if self.numbers:
                spec.extend("NConfig", cool.StorageType.Int32)
                spec.extend("NWorking", cool.StorageType.Int32)
            spec.extend("Comment", cool.StorageType.String255)

            cfolder = AtlCoolLib.ensureFolder(
                writedb, self.destfolder, spec,
                AtlCoolLib.athenaDesc(self.runLumi, 'CondAttrListCollection'),
                cool.FolderVersioning.MULTI_VERSION)
コード例 #26
0
class LArHVMapDbFiller(object):
    """
    A simple class used to fill SQLite db file with parameters for simulation
    and/or digitization.
    """
    def __init__(self):
        object.__init__(self)

        self.beginTime = None
        self.endTime = None
        self.FileName = None
        self.FolderTag = None
        self.Params = {}
        return

    #
    def setBegin(self, run, lumi):
        print " setBegin  run,lumi ", run
        self.beginTime = (long(run) << 32) + long(lumi)
        print "    time ", self.beginTime
        return

    def setEnd(self, run, lumi):
        print "setEnd runmlumi ", run
        self.endTime = (long(run) << 32) + long(lumi)
        print "   time ", self.endTime
        return

    def setFileName(self, fileName):
        self.FileName = fileName
        return

    def setFolderTag(self, folderTag):
        self.FolderTag = folderTag
        return

    def readFile(self):
        value = ''
        f = file(self.FileName, 'r')
        for lines in f:
            value += lines
        self.Params['LArHVMap'] = value
        return

    def genDb(self):

        dbFileName = 'HVmap.db'
        dbName = 'COMP200'
        folderPath = '/LAR/IdentifierOfl/HVLineToElectrodeMap'
        # Do checks
        if self.beginTime == None:
            raise LArHVMapDbFillerError, 'Must set begin run number before generating db'
        if self.endTime == None:
            self.endTime = cool.ValidityKeyMax
        if self.FileName == None:
            raise LArHVMapDbFillerError, 'Must give an input file for LArHVToElectrode.data'
        if self.FolderTag == None:
            raise LArHVMapDbFillerError, 'Must give a folder tag'

        self.readFile()

        if len(self.Params) == 0:
            raise LArHVMapDbFillerError, 'No parameters for db ' + dbName

        # remove existing db, if any
        try:
            os.remove(dbFileName)
            print "LArHVMapDbFiller.genDb:  Removed db", dbFileName
        except:
            pass

        # get database service and open database
        dbSvc = cool.DatabaseSvcFactory.databaseService()

        # build dbstring - database accessed via physical name
        dbstring = "sqlite://;schema=" + dbFileName + ";dbname=" + dbName
        try:
            db = dbSvc.createDatabase(dbstring)
        except Exception, e:
            print 'LArHVMapDbFiller.genDb:  Problem creating database', e
            sys.exit(-1)
            print "LArHVMapDbFiller.genDb:  Created database", dbstring

        # setup a folder payload specification
        spec = cool.RecordSpecification()
        for key in self.Params:
            spec.extend(key, cool.StorageType.String16M)

        # folder meta-data - note for Athena this has a special meaning
        desc = '<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>'
        # create the folder - single version
        # last argument is createParents - if true, automatically creates parent
        # folders if needed
        # note this will not work if the database already exists - delete mycool.db first
        myfolder = db.createFolder(folderPath, spec, desc,
                                   cool.FolderVersioning.MULTI_VERSION, True)
        # now fill in simlation parameters
        data = cool.Record(spec)
        for k, v in self.Params.iteritems():
            data[k] = v

        print "LArHVMapDbFiller.genDb:  Recording parameters", data

        # store object with IOV valid from 0-10, channel 3
        myfolder.storeObject(self.beginTime, self.endTime, data, 0,
                             self.FolderTag)
        print "LArHVMapDbFiller.genDb:  Stored object"

        # finalize
        db.closeDatabase()

        # Try to dump out db as test
        self.dumpDb(dbstring)
コード例 #27
0
class Databases(object):
    """
    Databases helper class. Used as a singleton. (don't instantiate)
    Specifies abbreviations for database connection strings and folders
    """

    FOLDERS = {
        "DQMFONL": "COOLONL_GLOBAL::/GLOBAL/DETSTATUS/DQMFONL",
        "DQMFONLLB": "COOLONL_GLOBAL::/GLOBAL/DETSTATUS/DQMFONLLB",
        "SHIFTONL": "COOLONL_GLOBAL::/GLOBAL/DETSTATUS/SHIFTONL",
        "DQMFOFL": "COOLOFL_GLOBAL::/GLOBAL/DETSTATUS/DQMFOFL",
        "DCSOFL": "COOLOFL_GLOBAL::/GLOBAL/DETSTATUS/DCSOFL",
        "DQCALCOFL": "COOLOFL_GLOBAL::/GLOBAL/DETSTATUS/DQCALCOFL",
        "SHIFTOFL": "COOLOFL_GLOBAL::/GLOBAL/DETSTATUS/SHIFTOFL",
        "LBSUMM": "COOLOFL_GLOBAL::/GLOBAL/DETSTATUS/LBSUMM",
        "VIRTUALFLAGS": "COOLOFL_GLOBAL::/GLOBAL/DETSTATUS/VIRTUALFLAGS",
        "DEFECTS": "COOLOFL_GLOBAL::/GLOBAL/DETSTATUS/DEFECTS",
        "SOR_Params": "COOLONL_TDAQ::/TDAQ/RunCtrl/SOR_Params",
        "EOR_Params": "COOLONL_TDAQ::/TDAQ/RunCtrl/EOR_Params",
        "SOR": "COOLONL_TDAQ::/TDAQ/RunCtrl/SOR",
        "EOR": "COOLONL_TDAQ::/TDAQ/RunCtrl/EOR",
        "LBLB": "COOLONL_TRIGGER::/TRIGGER/LUMI/LBLB",
        "LBTIME": "COOLONL_TRIGGER::/TRIGGER/LUMI/LBTIME",
        "LBLESTONL": "COOLONL_TRIGGER::/TRIGGER/LUMI/LBLESTONL",
        "LVL1COUNTERS": "COOLONL_TRIGGER::/TRIGGER/LUMI/LVL1COUNTERS",
        "HLTCOUNTERS": "COOLOFL_TRIGGER::/TRIGGER/LUMI/HLTCOUNTERS",
        "HLT/Menu": "COOLONL_TRIGGER::/TRIGGER/HLT/Menu",
        "LVL1/Menu": "COOLONL_TRIGGER::/TRIGGER/LVL1/Menu",
        "Prescales": "COOLONL_TRIGGER::/TRIGGER/LVL1/Prescales",
    }

    @classmethod
    def resolve_folder_string(cls, folder_name, db_override=None):
        """
        Resolves a simplified folder URI.
        
        Examples:   
            folder_name == "SHIFTOFL" 
                will give a connection to COOLOFL_GLOBAL/COMP200
                folder /GLOBAL/DETSTATUS/SHIFTOFL
            folder_name == "test.db::SHIFTOFL"
                will give a connection to an sqlite database test.db
        
        Priority:
            * Database specified in db_override
            * Database specified in `folder_name`
            * Database specified in cls.FOLDERS[folder_name]
        """
        res_database = db_override

        # First check - is a database specified in the folder name?
        if "::" in folder_name:
            assert folder_name.count("::") == 1, "Bad folder format"
            database, folder_name = folder_name.split("::")

            # If res_database hasn't already been set, do so
            res_database = database if not res_database else res_database

        if folder_name in cls.FOLDERS:
            database, res_folder = cls.FOLDERS[folder_name].split("::")
            res_database = database if not res_database else res_database
        else:
            res_folder = folder_name

        return res_database, res_folder

    @classmethod
    def get_folder(cls,
                   folder_name,
                   db_override=None,
                   read_only=True,
                   create_function=None,
                   also_db=False):
        """
        Retrieve a folder. The `db_override` parameter allows over-riding the
        database which comes from the folder string.
        
        Parameters:
            `folder_name` : Folder name or alias to load
            `db_override` : If specified, causes an alternate database string
                            to be used.
            `read_only`   : Specifies if a read-only database connection should
                            be used.
            `create_function` : If specified, function to be called in case the
                                folder doesn't exist. It is passed the database
                                connection.
            `also_db`     : Make the return value (db, folder)
        """

        if read_only:
            assert not create_function, "`read_only` specified with `create`"

        database, folder = cls.resolve_folder_string(folder_name, db_override)
        assert database, ("Unable to resolve database for (%s, %s)" %
                          (folder_name, db_override))

        create = bool(create_function)
        db = cls.get_instance(database, read_only, create)

        try:
            cool_folder = db.getFolder(folder)
        except Exception as error:
            log.debug('HELP! %s' % error.args)
            args = str(error.args[0] if not isinstance(error.args, basestring)
                       else error.args)
            log.debug('THIS IS %s' % type(args))
            log.debug('Value of boolean: %s' % ("not found" in args))
            if not ("cannot be established" in args or "not found" in args):
                log.exception("Unknown error encountered whilst opening "
                              "database connection to '%s'" % database)
                raise

            if not create_function:
                log.exception("Database does not exist, `create_function` not "
                              "specified")
                raise

            cool_folder = create_function(db)
        if also_db:
            return db, cool_folder
        return cool_folder

    @classmethod
    def resolve_db_string(cls, db_string, read_only=True):
        """
        Take a database string - if it looks like a filename ending in ".db"
        then assume it is a sqlite database with that name.
        
        If the `db_string` is prepended with "WRITE|" then a writable connection
        is requested.
        
        If the db_string doesn't contain a "/", then "/" + DEFAULT_DBNAME is
        appended.
        """
        if "://" in db_string:
            # Assume that the string is already resolved
            return db_string, read_only

        if db_string.startswith("WRITE|"):
            assert db_string.count("|") == 1, "Bad db_string format"
            db_string = db_string.split("|")[1]
            read_only = False

        sqlite_regex = re.compile(
            r"(?P<filename>.*?\.db)(?:/?(?P<dbname>[^/]+))?$")
        matched = sqlite_regex.match(db_string)
        if matched:
            filename, dbname = matched.groups()
            dbname = DEFAULT_DBNAME if not dbname else dbname
            db_string = "sqlite://schema=%s;dbname=%s" % (filename, dbname)
        else:
            if "/" not in db_string:
                return db_string + "/" + DEFAULT_DBNAME, read_only

        return db_string, read_only

    @classmethod
    def get_instance(cls, db_string, read_only=True, create=False):
        """
        Open a database connection
        """
        res_db_string, read_only = cls.resolve_db_string(db_string, read_only)

        try:
            prev_stdout = sys.stdout
            sys.stdout = StringIO()
            try:
                connection = indirectOpen(res_db_string,
                                          readOnly=read_only,
                                          oracle=True)
            finally:
                sys.stdout = prev_stdout
        except Exception as e:
            if "The database does not exist" in e.args[0] and not create:
                log.info("Failed trying to connect to '%s'", res_db_string)
                raise
            from PyCool import cool
            dbService = cool.DatabaseSvcFactory.databaseService()
            connection = dbService.createDatabase(res_db_string)
        except:
            print sys.exc_info()[0]
            raise
        return connection

    @classmethod
    def build_folder(cls, db, folder_name, multiversion, record):
        """
        Create `folder_name` on database instance `db`, with recordspecification
        `record`.
        
        Also creates folderset to which folder_name belongs if necessary.
        """
        from PyCool import cool

        folderset_path = dirname(folder_name)
        try:
            folder_set = db.getFolderSet(folderset_path)
        except Exception, error:
            caught_error = "Folder set %s not found" % folderset_path
            if caught_error not in error.args[0]:
                raise

            log.debug("Folderset doesn't exist - creating it.")
            db.createFolderSet(folderset_path, "", True)

        if not isinstance(record, cool.RecordSpecification):
            record_spec = cool.RecordSpecification()
            for field in record:
                record_spec.extend(*field)
        else:
            record_spec = record

        FV = cool.FolderVersioning
        versioning = FV.MULTI_VERSION if multiversion else FV.SINGLE_VERSION
        folder_spec = cool.FolderSpecification(versioning, record_spec)
        folder = db.createFolder(folder_name, folder_spec)
        payload = cool.Record(record_spec)

        return folder, payload
コード例 #28
0
      dbSvc=cool.DatabaseSvcFactory.databaseService()
      # database accessed via physical name
      dbstring='sqlite://;schema=RPCDQMFOFFLINE.db;dbname=RPC_DQA'
      if os.access('RPCDQMFOFFLINE.db', os.R_OK):
            try:
                  os.unlink('RPCDQMFOFFLINE.db')
            except Exception, e:
                  print 'Unable to remove existing db file, reason', e
      try:
            db=dbSvc.createDatabase(dbstring)
      except Exception,e:
            print 'Problem creating database',e
            return
      print "Created database",dbstring

      spec2=cool.RecordSpecification()
      spec2.extend("recEta",cool.StorageType.String4k)
      spec2.extend("detEta",cool.StorageType.String4k)
      spec2.extend("recPhi1",cool.StorageType.String4k)
      spec2.extend("recPhi2",cool.StorageType.String4k)
      spec2.extend("detPhi1",cool.StorageType.String4k)
      spec2.extend("detPhi2",cool.StorageType.String4k)

      # folder meta-data - note for Athena this has a special meaning
      desc="<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type=\"71\" clid=\"1238547719\" /></addrHeader><typeName>CondAttrListCollection</typeName>"
      # create the folder - single version
      # last argument is createParents - if true, automatically creates parent
      # folders if needed
      # note this will not work if the database already exists - delete mycool.db first
      # Deprecated/dropped:  myfolder=db.createFolder('/OFFLINE/OFFLINE_DQMF',spec2,desc,cool.FolderVersioning.MULTI_VERSION,True)
      folderSpec=cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, spec2)
コード例 #29
0
dbSvc = cool.DatabaseSvcFactory.databaseService()
# database accessed via physical name
dbstring = "sqlite://;schema=%s;dbname=%s" % (dbfile, dbname)
try:
    db = dbSvc.createDatabase(dbstring)
except Exception, e:
    print 'Problem creating database', e
    sys.exit(-1)

print "Created database", dbstring

# ----------------------------------------------------------------------- #
# setup a folder
# ----------------------------------------------------------------------- #
#spec=cool.RecordSpecification()
recspec = cool.RecordSpecification()
recspec.extend("version", cool.StorageType.String4k)
recspec.extend("syserrors", cool.StorageType.String4k)
spec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, recspec,
                                True)

#spec.extend(fdspec,cool.StorageType.String16M)
# folder meta-data - note for Athena this has a special meaning

desc = '<timeStamp>time</timeStamp><addrHeader><address_header service_type="71" clid="1238547719" /></addrHeader><typeName>CondAttrListCollection</typeName>'

####<timeStamp>time</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>

# create the folder - single version
# last argument is createParents - if true, automatically creates parent folders if needed
# note this will not work if the database already exists - delete mycool.db first
コード例 #30
0
class LArDBFolderBrowser_MissingFEBs():
    def __init__(self, nspace_LArBadChannelDBTools, class_LArBadChanBitPacking,
                 class_LArBadChannel, class_HWIdentifier, onLineID,
                 larCablingSvc):

        self.nspace_LArBadChannelDBTools = nspace_LArBadChannelDBTools
        self.class_LArBadChanBitPacking = class_LArBadChanBitPacking
        self.class_LArBadChannel = class_LArBadChannel
        self.class_HWIdentifier = class_HWIdentifier
        self.onlineID = onLineID
        self.larCablingSvc = larCablingSvc

        self.dict_vectMissingFebHWid = {}
        self.dict_vectMissingFebHWid_Status = {}
        self.dict_vectMissingFebHWid_Init = {}

        return

    def MissingFeb_SetBadChannelDataFromPayload(self, coolChan, payload):

        # Get components of payload object
        channelSize = payload['ChannelSize']
        endianness = payload['Endianness']
        version = payload['Version']
        blob = payload['Blob']

        # Decode blob content
        vect_MissingFebHWid = self.nspace_LArBadChannelDBTools.decodeFebBlob(
            blob, channelSize, endianness, version,
            self.nspace_LArBadChannelDBTools.getDefaultMsgStream())

        print vect_MissingFebHWid.size()
        for s in vect_MissingFebHWid:
            print s,
        print ""

        # Add entry in dictionnary
        sChannelKey = coolChan
        if not self.dict_vectMissingFebHWid.has_key(sChannelKey):
            self.dict_vectMissingFebHWid[sChannelKey] = {}

        # Transform vect_BadChanNetry into python dictionnary
        sChannelDict, sChannelDict_Status = self.MissingFeb_TransformEntryIntoDictionnary(
            vect_MissingFebHWid)

        self.dict_vectMissingFebHWid[sChannelKey] = {}
        self.dict_vectMissingFebHWid_Init[sChannelKey] = {}
        for key in sChannelDict.keys():
            self.dict_vectMissingFebHWid[sChannelKey][key] = sChannelDict[key]
            self.dict_vectMissingFebHWid_Init[sChannelKey][key] = sChannelDict[
                key]
        self.dict_vectMissingFebHWid_Status[sChannelKey] = sChannelDict_Status

        return ("None")

    def MissingFeb_DisplayMissingFeb(self, coolChan):
        """   """

        iChanCmpt = 0
        listHWidKeys = [
            x for x in self.dict_vectMissingFebHWid[coolChan].keys()
        ]
        listHWidKeys.sort()

        print ""
        for sHWid in listHWidKeys:

            if self.dict_vectMissingFebHWid_Init[coolChan].has_key(sHWid):
                sChanName, sStatus, sValueInit = self.dict_vectMissingFebHWid_Init[
                    coolChan][sHWid]
                sPrefix = ""
                if self.dict_vectMissingFebHWid_Status[coolChan][
                        sHWid] != STATUS_INIT:
                    sPrefix = "->"
                self.MissingFeb_DisplayMissingFebLine(sPrefix, iChanCmpt,
                                                      sHWid, sChanName,
                                                      sStatus, "")

            if self.dict_vectMissingFebHWid_Status[coolChan][
                    sHWid] != STATUS_INIT:
                sChanName, sStatus, sValueInit = self.dict_vectMissingFebHWid[
                    coolChan][sHWid]
                channelStatus = self.dict_vectMissingFebHWid_Status[coolChan][
                    sHWid]
                self.MissingFeb_DisplayMissingFebLine(channelStatus, iChanCmpt,
                                                      sHWid, sChanName,
                                                      sStatus, "")

            iChanCmpt += 1

    def MissingFeb_DisplayMissingFebLine(self, sMessage, iChanCmpt, sHWid,
                                         sChanName, sStatusValue, sValueInit):

        obj_HWid = self.class_HWIdentifier()
        obj_HWid.set(sHWid)

        cblSvc_id = self.larCablingSvc.cnvToIdentifier(obj_HWid)
        cblSvc_string = self.onlineID.print_to_string(cblSvc_id)

        barrel_ec = self.onlineID.barrel_ec(obj_HWid)
        pos_neg = self.onlineID.pos_neg(obj_HWid)
        feedthrough = self.onlineID.feedthrough(obj_HWid)
        slot = self.onlineID.slot(obj_HWid)
        channel = self.onlineID.channel(obj_HWid)

        if sMessage == "":
            print "    %5d :  %-10s  %1d %1d %2d %2d %3d %40s   %s " % (
                iChanCmpt + 1, obj_HWid.getString(), barrel_ec, pos_neg,
                feedthrough, slot, channel, sChanName, sStatusValue)
        else:
            print "%3s %5d :  %-10s  %1d %1d %2d %2d %3d %40s   %s %s" % (
                sMessage, iChanCmpt + 1, obj_HWid.getString(), barrel_ec,
                pos_neg, feedthrough, slot, channel, sChanName, sStatusValue,
                sValueInit)

    def MissingFeb_ShowMissingFebCorrectionsSummary(self, coolChan):

        listHWidKeys = [
            x for x in self.dict_vectMissingFebHWid[coolChan].keys()
        ]
        listHWidKeys.sort()

        print ""
        print "Correction summary : "
        iNbCorrection = 0
        for index, sHWid in enumerate(listHWidKeys):
            if self.dict_vectMissingFebHWid_Status[coolChan][
                    sHWid] != STATUS_INIT:
                sChanName, badChan_word, sValueInit = self.dict_vectMissingFebHWid[
                    coolChan][sHWid]
                channelStatus = self.dict_vectMissingFebHWid_Status[coolChan][
                    sHWid]
                self.MissingFeb_DisplayMissingFebLine(channelStatus, index,
                                                      sHWid, sChanName,
                                                      badChan_word, "")
                iNbCorrection += 1

        if iNbCorrection == 0: print "-"

    def MissingFeb_TransformEntryIntoDictionnary(self, vMissingFEBHWid):
        """ Transform the missing FEB decoded from blob object into a python dictionnary """

        print "--------------------------- Blob SIZE : ", vMissingFEBHWid.size(
        )
        iNbMissingFEB = vMissingFEBHWid.size()

        sChannelDict = {}
        sChannelDict_Status = {}
        for i in range(0, iNbMissingFEB):

            obj_HWid = vMissingFEBHWid.at(i)
            sHexaString = obj_HWid.getString()

            sChannelName = self.onlineID.channel_name(vMissingFEBHWid.at(i))
            sInitialValues = sHexaString + " " + STATUS_MISSING_FEB
            sChannelDict[sHexaString] = (sChannelName, STATUS_MISSING_FEB,
                                         sInitialValues)
            sChannelDict_Status[sHexaString] = STATUS_INIT

        return (sChannelDict, sChannelDict_Status)

    def MissingFeb_ModifyMissingFeb(self, coolChan):

        listHWidKeys = [
            x for x in self.dict_vectMissingFebHWid[coolChan].keys()
        ]
        listHWidKeys.sort()
        iNbBadChannel = len(self.dict_vectMissingFebHWid[coolChan].keys())

        bEndOfCorrection = False
        while not bEndOfCorrection:

            print ""
            print ".. To add a missing feb    : enter barrel_ec pos_neg feedthrough slot "
            print ".. To remove a missing feb : enter -(channel index) "
            print ".. Other :   s (summary)  /  r (refresh list)  /  a (abort)  / q (save and quit)      .. > ",
            tty = open("/dev/tty", "r+")
            rep = tty.readline()
            rep = rep.strip()

            bReadableAnswer = True
            barrel_ec = -1
            pos_neg = -1
            feedthrough = -1
            slot = -1
            channel = -1
            iSelectedIndex = 0
            sTxtAnswer = ""
            iCombinationAnswer = 0
            try:
                barrel_ec, pos_neg, feedthrough, slot = rep.split(' ')
                channel = 0
                bReadableAnswer = True
                iCombinationAnswer = 1
            except:
                if rep == "a": sTxtAnswer = "abort"
                elif rep == "r": sTxtAnswer = "refresh"
                elif rep == "s": sTxtAnswer = "summary"
                elif rep == "q": sTxtAnswer = "save-quit"
                else:
                    try:
                        iSelection = int(rep)
                        if iSelection in range(1, iNbBadChannel + 1):
                            iSelectedIndex = iSelection
                        if iSelection in range(-iNbBadChannel - 1, 0):
                            iSelectedIndex = iSelection
                        if iSelectedIndex == -99999: bReadableAnswer = False
                    except:
                        iSelectedIndex = 0
                        bReadableAnswer = False
                        continue

            if bReadableAnswer == False:
                print "could not decode answer... "
                bEndOfCorrection = False
                continue

            # Abort answer
            if sTxtAnswer == "abort":
                iAbortConfirmation = LArBadChannelBrowserTools.YesNoQuestion(
                    "Are you sure you want to quit ? ")
                if iAbortConfirmation == 1: return 'a'
                bEndOfCorrection = False

            # Refresh answer
            if sTxtAnswer == "refresh":
                self.MissingFeb_DisplayMissingFeb(coolChan)
                bEndOfCorrection = False

            # Summary answer
            if sTxtAnswer == "summary":
                self.MissingFeb_ShowMissingFebCorrectionsSummary(coolChan)
                bEndOfCorrection = False

            # Refresh answer
            if sTxtAnswer == "save-quit":
                return 'q'

            # Channel selected by negative index => to remove
            if iSelectedIndex < 0:
                sHWid = listHWidKeys[-iSelectedIndex - 1]
                sChanName, sFebstatus, sValueInit = self.dict_vectMissingFebHWid[
                    coolChan][sHWid]
                iDeleteConfirmation = LArBadChannelBrowserTools.YesNoQuestion(
                    "Are you sure you want to delete " + sChanName + " ? ")
                if iDeleteConfirmation == 1:
                    self.dict_vectMissingFebHWid_Status[coolChan][
                        sHWid] = STATUS_REMOVED
                    self.dict_vectMissingFebHWid[coolChan][sHWid] = (
                        sChanName, STATUS_NOT_MISSING_FEB, sValueInit)
                bEndOfCorrection = False

            # Channel selected by index or parameters
            if iSelectedIndex > 0 or iCombinationAnswer == 1:

                if iSelectedIndex > 0:
                    sHWid = listHWidKeys[iSelectedIndex - 1]
                    sChanName, sFebStatus, sValueInit = self.dict_vectMissingFebHWid[
                        coolChan][sHWid]
                else:
                    iRes, sHWid, sChanName, sFebStatus = self.MissingFeb_GetChannelHWIdentifierAndStatus(
                        barrel_ec, pos_neg, feedthrough, slot, channel)
                    if iRes == 0:
                        print "FEB already defined as missing"
                        sValueInit = self.dict_vectMissingFebHWid[coolChan][
                            sHWid][2]
                    else:
                        sValueInit = "None"
                        self.dict_vectMissingFebHWid_Status[coolChan][
                            sHWid] = STATUS_NEW
                        self.dict_vectMissingFebHWid[coolChan][sHWid] = (
                            sChanName, STATUS_MISSING_FEB, sValueInit)
                bEndOfCorrection = False

            # Display correction summary
            self.MissingFeb_ShowMissingFebCorrectionsSummary(coolChan)

        return StatusCode.Success

    def MissingFeb_GetChannelHWIdentifierAndStatus(self, barrel_ec, pos_neg,
                                                   feedthrough, slot, channel):
        """ Get channel HW identifier and its status """

        sid = self.onlineID.channel_Id(int(barrel_ec), int(pos_neg),
                                       int(feedthrough), int(slot),
                                       int(channel))
        print str(barrel_ec) + " " + str(pos_neg) + " " + str(
            feedthrough) + " " + str(slot) + " " + str(
                channel) + "  =>  ", sid.getString()

        # Check if HW identifier is valid
        bValidWHidentifier = False
        if self.onlineID.isEMBchannel(sid): bValidWHidentifier = True
        if self.onlineID.isEMECchannel(sid): bValidWHidentifier = True
        if self.onlineID.isHECchannel(sid): bValidWHidentifier = True
        if self.onlineID.isFCALchannel(sid): bValidWHidentifier = True
        if bValidWHidentifier == False: return (-1, sid.getString(), "", 0)

        for key in self.dict_vectMissingFebHWid.keys():
            for sHWid in self.dict_vectMissingFebHWid[key].keys():
                sChannelName, sFebStatus, x = self.dict_vectMissingFebHWid[
                    key][sHWid]
                if sid.getString() == sHWid:
                    return (0, sid.getString(), sChannelName, sFebStatus)

        return (1, sid.getString(), sChannelName, STATUS_MISSING_FEB)

    def MissingFeb_SaveMissingFebCorrectionsToDatabase(self, dbstring, dbSvc,
                                                       dbFolderName,
                                                       selectedTag):

        listKeys = self.dict_vectMissingFebHWid.keys()
        listKeys.sort()

        # Loop over cool channels
        bStoreNewCoolChannels = False
        bNewDBCreated = False

        vect_MissingFebHWid = PyCintex.gbl.std.vector('HWIdentifier')()

        coolChan = 0
        listHWidKeys = [
            x for x in self.dict_vectMissingFebHWid[coolChan].keys()
        ]
        listHWidKeys.sort()
        iNbCorrection = 0
        for key in listHWidKeys:

            sHWid = key
            if self.dict_vectMissingFebHWid_Status[coolChan][
                    sHWid] == STATUS_INIT:
                sStatusFeb = self.dict_vectMissingFebHWid_Init[coolChan][
                    sHWid][1]
            elif self.dict_vectMissingFebHWid_Status[coolChan][
                    sHWid] == STATUS_MODIFIED or self.dict_vectMissingFebHWid_Status[
                        coolChan][sHWid] == STATUS_NEW:
                iNbCorrection += 1
                sStatusFeb = self.dict_vectMissingFebHWid[coolChan][sHWid][1]
            elif self.dict_vectMissingFebHWid_Status[coolChan][
                    sHWid] == STATUS_REMOVED:
                iNbCorrection += 1
                continue

            obj_HWid = self.class_HWIdentifier()
            obj_HWid.set(sHWid)

            vect_MissingFebHWid.push_back(obj_HWid)

        # if correction were made => store MissingFebHWid vector
        if iNbCorrection > 0:
            bStoreNewCoolChannels = True
        else:
            print "No correcton to save"
            return

        # Create object based on new LArBadChannelState (via LArBadChannelDBTools python interface)
        attrListSpec = PyCintex.gbl.coral.AttributeListSpecification()
        athenaAttrList = PyCintex.gbl.AthenaAttributeList()

        attrListSpec = self.nspace_LArBadChannelDBTools.createCoolSpec()
        athenaAttrList = self.nspace_LArBadChannelDBTools.createFebPayload(
            vect_MissingFebHWid)

        # new DB creation
        import os
        try:
            dbSave = dbSvc.createDatabase(dbstring)
        except Exception, e:
            print 'Problem opening database', e
            sys.exit(-1)
        print "Opened database", dbstring

        desc = '<timeStamp>run-event</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>'

        # Create cool spec from AttributeListSpec
        coolSpec = cool.RecordSpecification()
        for iElemt in range(0, attrListSpec.size()):
            attrSpec = attrListSpec[iElemt]
            typeName = attrSpec.typeName()
            if typeName == "unsigned int":
                coolSpec.extend(attrSpec.name(), cool.StorageType.UInt32)
            elif typeName == "blob":
                coolSpec.extend(attrSpec.name(), cool.StorageType.Blob64k)
            else:
                print "Undefined cool.StorageType " + typeName

        myfolder = dbSave.createFolder(dbFolderName, coolSpec, desc,
                                       cool.FolderVersioning.MULTI_VERSION,
                                       True)

        import string
        IOVBeginEnd = ["90", "9999999"]
        beginRun = string.atoi(IOVBeginEnd[0]) << 32
        endRun = string.atoi(IOVBeginEnd[1]) << 32

        # Create cool payload from AthenaAttributeList payload
        coolPayload = cool.Record(coolSpec)
        for iElemt in range(0, attrListSpec.size()):
            attrSpec = attrListSpec[iElemt]
            coolPayload[attrSpec.name()] = athenaAttrList[attrSpec.name()]

            # Store cool object to folder
            myfolder.storeObject(beginRun, endRun, coolPayload, coolChan,
                                 selectedTag)

        # Close new databse
        dbSave.closeDatabase()