Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:03

0001 import socket
0002 import FWCore.ParameterSet.Config as cms
0003 import FWCore.ParameterSet.VarParsing as VarParsing
0004 from CondCore.CondDB.CondDB_cfi import *
0005 
0006 options = VarParsing.VarParsing()
0007 options.register( 'runNumber'
0008                 , 1 #default value
0009                 , VarParsing.VarParsing.multiplicity.singleton
0010                 , VarParsing.VarParsing.varType.int
0011                 , "Run number to be uploaded."
0012                   )
0013 options.register( 'destinationConnection'
0014                 , 'sqlite_file:EcalADCToGeVConstant_PopCon_test.db' #default value
0015                 , VarParsing.VarParsing.multiplicity.singleton
0016                 , VarParsing.VarParsing.varType.string
0017                 , "Connection string to the DB where payloads will be possibly written."
0018                   )
0019 options.register( 'targetConnection'
0020                 , '' #default value
0021                 , VarParsing.VarParsing.multiplicity.singleton
0022                 , VarParsing.VarParsing.varType.string
0023                 , """Connection string to the target DB:
0024                      if not empty (default), this provides the latest IOV and payloads to compare;
0025                      it is the DB where payloads should be finally uploaded."""
0026                   )
0027 options.register( 'sourceConnection'
0028                 , '' #default value
0029                 , VarParsing.VarParsing.multiplicity.singleton
0030                 , VarParsing.VarParsing.varType.string
0031                 , """Connection string to the DB hosting tags for RunInfo and EcalADCToGeVConstant.
0032                      It defaults to the same as the target connection, i.e. empty.
0033                      If target connection is also empty, it is set to be the same as destination connection."""
0034                   )
0035 options.register( 'tag'
0036                 , 'EcalADCToGeVConstant_PopCon_test'
0037                 , VarParsing.VarParsing.multiplicity.singleton
0038                 , VarParsing.VarParsing.varType.string
0039                 , "Tag written in destinationConnection and finally appended in targetConnection."
0040                   )
0041 options.register( 'tagForRunInfo'
0042                 , 'runInfo_31X_hlt'
0043                 , VarParsing.VarParsing.multiplicity.singleton
0044                 , VarParsing.VarParsing.varType.string
0045                 , "Tag used to retrieve the RunInfo payload and the magnet current therein."
0046                   )
0047 options.register( 'tagForBOff'
0048                 , 'EcalADCToGeVConstant_0T_test0'
0049                 , VarParsing.VarParsing.multiplicity.singleton
0050                 , VarParsing.VarParsing.varType.string
0051                 , "Tag used to retrieve the EcalADCToGeVConstant payload for magnet off."
0052                   )
0053 options.register( 'tagForBOn'
0054                 , 'EcalADCToGeVConstant_3.8T_test0'
0055                 , VarParsing.VarParsing.multiplicity.singleton
0056                 , VarParsing.VarParsing.varType.string
0057                 , "Tag used to retrieve the EcalADCToGeVConstant payload for magnet on."
0058                   )
0059 options.register( 'currentThreshold'
0060                 , 18000.
0061                 , VarParsing.VarParsing.multiplicity.singleton
0062                 , VarParsing.VarParsing.varType.float
0063                 , "The threshold on the magnet current for considering a switch of the magnetic field."
0064                   )
0065 options.register( 'messageLevel'
0066                 , 0 #default value
0067                 , VarParsing.VarParsing.multiplicity.singleton
0068                 , VarParsing.VarParsing.varType.int
0069                 , "Message level; default to 0"
0070                   )
0071 options.parseArguments()
0072 
0073 if not options.sourceConnection:
0074     if options.targetConnection:
0075         options.sourceConnection = options.targetConnection
0076     else:
0077         options.sourceConnection = options.destinationConnection
0078 
0079 CondDBConnection = CondDB.clone( connect = cms.string( options.destinationConnection ) )
0080 CondDBConnection.DBParameters.messageLevel = cms.untracked.int32( options.messageLevel )
0081 
0082 PopConConnection = CondDB.clone( connect = cms.string( options.sourceConnection ) )
0083 PopConConnection.DBParameters.messageLevel = cms.untracked.int32( options.messageLevel )
0084 
0085 process = cms.Process( "EcalADCToGeVConstantPopulator" )
0086 
0087 process.MessageLogger = cms.Service( "MessageLogger"
0088                                    , destinations = cms.untracked.vstring( 'cout' )
0089                                    , cout = cms.untracked.PSet( threshold = cms.untracked.string( 'INFO' ) )
0090                                      )
0091 
0092 if options.messageLevel == 3:
0093     #enable LogDebug output: remember the USER_CXXFLAGS="-DEDM_ML_DEBUG" compilation flag!
0094     process.MessageLogger.cout = cms.untracked.PSet( threshold = cms.untracked.string( 'DEBUG' ) )
0095     process.MessageLogger.debugModules = cms.untracked.vstring( '*' )
0096 
0097 process.source = cms.Source( "EmptyIOVSource"
0098                            , lastValue = cms.uint64( options.runNumber )
0099                            , timetype = cms.string( 'runnumber' )
0100                            , firstValue = cms.uint64( options.runNumber )
0101                            , interval = cms.uint64( 1 )
0102                              )
0103 
0104 process.PoolDBOutputService = cms.Service( "PoolDBOutputService"
0105                                          , CondDBConnection
0106                                          , timetype = cms.untracked.string( 'runnumber' )
0107                                          , toPut = cms.VPSet( cms.PSet( record = cms.string( 'EcalADCToGeVConstantRcd' )
0108                                                                       , tag = cms.string( options.tag )
0109                                                                         )
0110                                                               )
0111                                           )
0112 
0113 process.popConEcalADCToGeVConstant = cms.EDAnalyzer( "EcalADCToGeVConstantPopConBTransitionAnalyzer"
0114                                                    , SinceAppendMode = cms.bool( True )
0115                                                    , record = cms.string( 'EcalADCToGeVConstantRcd' )
0116                                                    , Source = cms.PSet( BTransition = cms.PSet( PopConConnection
0117                                                                                               , runNumber = cms.uint64( options.runNumber )
0118                                                                                               , tagForRunInfo = cms.string( options.tagForRunInfo )
0119                                                                                               , tagForBOff = cms.string( options.tagForBOff )
0120                                                                                               , tagForBOn = cms.string( options.tagForBOn )
0121                                                                                               , currentThreshold = cms.untracked.double( options.currentThreshold )
0122                                                                                                 )
0123                                                                         )
0124                                                    , loggingOn = cms.untracked.bool( True )
0125                                                    , targetDBConnectionString = cms.untracked.string( options.targetConnection )
0126                                                      )
0127 
0128 process.p = cms.Path( process.popConEcalADCToGeVConstant )