Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.VarParsing as VarParsing
from . import popcon2dropbox

options = VarParsing.VarParsing()
options.register('targetFile',
                'popcon.db',
                VarParsing.VarParsing.multiplicity.singleton,
                VarParsing.VarParsing.varType.string,
                "the target sqlite file name")
options.register('destinationDatabase',
                '',
                VarParsing.VarParsing.multiplicity.singleton,
                VarParsing.VarParsing.varType.string,
                "the destination database connection string")
options.register('destinationTag',
                '',
                VarParsing.VarParsing.multiplicity.singleton,
                VarParsing.VarParsing.varType.string,
                "the destination tag name")
options.parseArguments()

def setup_popcon( recordName, tagTimeType ):
    psetForOutRec = []
    psetForOutRec.append( cms.PSet( record = cms.string(str( recordName )),
                                    tag = cms.string(str( options.destinationTag )),
                                    timetype = cms.untracked.string(str(tagTimeType))
                                    )
                          )

    sqliteConnect = 'sqlite:%s' %options.targetFile
    process = cms.Process("PopCon")
    process.load("CondCore.CondDB.CondDB_cfi")
    process.CondDB.DBParameters.messageLevel = cms.untracked.int32( 3 )

    process.PoolDBOutputService = cms.Service("PoolDBOutputService",
                                              DBParameters = cms.PSet( messageLevel = cms.untracked.int32( 3 ),
                                                                       ),
                                              connect = cms.string( sqliteConnect ),
                                              toPut = cms.VPSet( psetForOutRec )
    )
    
    process.source = cms.Source("EmptyIOVSource",
                                timetype   = cms.string('runnumber'),
                                firstValue = cms.uint64(1),
                                lastValue  = cms.uint64(1),
                                interval   = cms.uint64(1)
    )
    return process

def psetForRecord( recordName ):
    psetForRec = []
    psetForRec.append( cms.PSet( record = cms.string(str(recordName)),
                                 tag = cms.string(str( options.destinationTag ))
                                 ) 
                       )
    return psetForRec