Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:48:51

0001 import datetime
0002 import os
0003 import FWCore.ParameterSet.Config as cms
0004 import FWCore.ParameterSet.VarParsing as VarParsing
0005 
0006 options = VarParsing.VarParsing()
0007 options.register('delay'
0008                 , 1  # default value
0009                 , VarParsing.VarParsing.multiplicity.singleton
0010                 , VarParsing.VarParsing.varType.int
0011                 , "Time delay (in hours) for the O2O. The O2O then queries the PVSS DB from last IOV until (current hour - delay), ignoring minutes and seconds."
0012                   )
0013 options.register('sourceConnection'
0014                 , 'oracle://cms_omds_adg/CMS_TRK_R'  # default value
0015                 , VarParsing.VarParsing.multiplicity.singleton
0016                 , VarParsing.VarParsing.varType.string
0017                 , "Connection string to the PVSS DB."
0018                   )
0019 options.register('destinationConnection'
0020                 , 'sqlite_file:SiStripDetVOff.db'  # default value
0021                 , VarParsing.VarParsing.multiplicity.singleton
0022                 , VarParsing.VarParsing.varType.string
0023                 , "Connection string to the DB where payloads will be possibly written."
0024                   )
0025 options.register('conddbConnection'
0026                 , 'oracle://cms_orcon_adg/CMS_CONDITIONS'  # default value
0027                 , VarParsing.VarParsing.multiplicity.singleton
0028                 , VarParsing.VarParsing.varType.string
0029                 , "Connection string to the DB from which the last IOV is read."
0030                   )
0031 options.register('tag'
0032                 , 'SiStripDetVOff_test'
0033                 , VarParsing.VarParsing.multiplicity.singleton
0034                 , VarParsing.VarParsing.varType.string
0035                 , "Tag written in destinationConnection and finally appended in targetConnection."
0036                   )
0037 options.parseArguments()
0038 
0039 # convert delay to tmax
0040 dt = datetime.datetime.utcnow() - datetime.timedelta(hours=options.delay)
0041 tmax = [dt.year, dt.month, dt.day, dt.hour, 0, 0, 0]
0042 
0043 # authentication path to the key file
0044 authPath = os.environ['COND_AUTH_PATH'] if 'COND_AUTH_PATH' in os.environ else os.environ["HOME"]
0045 
0046 process = cms.Process("SiStripDCSO2O")
0047 
0048 process.MessageLogger = cms.Service( "MessageLogger",
0049                                      debugModules = cms.untracked.vstring( "*" ),
0050                                      cout = cms.untracked.PSet( threshold = cms.untracked.string( "DEBUG" ) ),
0051                                      destinations = cms.untracked.vstring( "cout" )
0052                                      )
0053 
0054 process.maxEvents = cms.untracked.PSet(
0055     input = cms.untracked.int32(1)
0056 )
0057 process.source = cms.Source("EmptySource",
0058     numberEventsInRun = cms.untracked.uint32(1),
0059     firstRun = cms.untracked.uint32(1)
0060 )
0061 
0062 # -----------------------------------------------------------------------------
0063 process.SiStripDetVOffBuilder = cms.Service(
0064     "SiStripDetVOffBuilder",
0065     onlineDB=cms.string(options.sourceConnection),
0066     authPath=cms.string(authPath),
0067 
0068     # Format for date/time vector:  year, month, day, hour, minute, second, nanosecond      
0069     Tmin = cms.vint32(2016, 1, 1, 0, 0, 0, 0),
0070     Tmax = cms.vint32(tmax),
0071 
0072     # Do NOT change this unless you know what you are doing!
0073     TSetMin = cms.vint32(2007, 11, 26, 0, 0, 0, 0),
0074     
0075     # queryType can be either STATUSCHANGE or LASTVALUE                                
0076     queryType = cms.string('STATUSCHANGE'),
0077     
0078     #Length in seconds of minimum deltaT for 2 consecutive IOVs in the original data to be considered separately and not be merged by the IOV reduction
0079     DeltaTmin = cms.uint32(2),
0080 
0081     #Length in seconds of the maximum time an IOV sequence can be (i.e. one can be compressing sequences up to 120 seconds long, after that a new IOV would be made)
0082     MaxIOVlength = cms.uint32(90),
0083 
0084     # if reading lastValue from file put insert file name here                              
0085     lastValueFile = cms.string(''),
0086     
0087     # flag to show if you are reading from file for lastValue or not                              
0088     lastValueFromFile = cms.bool(False),
0089     
0090     # flag to toggle debug output
0091     debugModeOn = cms.bool(False),
0092 
0093     # DetIdFile
0094     DetIdListFile = cms.string('CalibTracker/SiStripCommon/data/SiStripDetInfo.dat'),
0095 
0096     # Threshold to consider an HV channel on
0097     HighVoltageOnThreshold = cms.double(0.97),
0098 
0099     # Leave empty if you want to use the db
0100     PsuDetIdMapFile = cms.string("CalibTracker/SiStripDCS/data/StripPSUDetIDMap_FromFeb2016.dat"),
0101 
0102     #This excluded detids file is not currently used (it was needed when there were unmapped detids.
0103     ExcludedDetIdListFile = cms.string('')
0104 )
0105 
0106 # -----------------------------------------------------------------------------
0107 process.load("CondCore.CondDB.CondDB_cfi")
0108 process.siStripPopConDetVOff = cms.EDAnalyzer( "SiStripO2ODetVOff",
0109                                      process.CondDB,
0110                                      # Get the last IOV from conditionDatabase.
0111                                      # Leave empty for manual restart (will then get the last IOV from sqlite condDbFile). 
0112                                      conditionDatabase = cms.string(options.conddbConnection),
0113                                      condDbFile = cms.string(options.destinationConnection),
0114                                      targetTag = cms.string(options.tag),
0115                                      # max length (in hours) before a new IOV is started for the same payload (use -1 to disable this)
0116                                      maxTimeBeforeNewIOV=cms.untracked.int32(168)
0117                                      )
0118 
0119 process.p = cms.Path(process.siStripPopConDetVOff)