CMS 3D CMS Logo

SiStripDCS_popcon.py
Go to the documentation of this file.
1 import datetime
2 import os
3 import FWCore.ParameterSet.Config as cms
4 import FWCore.ParameterSet.VarParsing as VarParsing
5 
6 options = VarParsing.VarParsing()
7 options.register('delay'
8  , 1 # default value
9  , VarParsing.VarParsing.multiplicity.singleton
10  , VarParsing.VarParsing.varType.int
11  , "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."
12  )
13 options.register('sourceConnection'
14  , 'oracle://cms_omds_adg/CMS_TRK_R' # default value
15  , VarParsing.VarParsing.multiplicity.singleton
16  , VarParsing.VarParsing.varType.string
17  , "Connection string to the PVSS DB."
18  )
19 options.register('destinationConnection'
20  , 'sqlite_file:SiStripDetVOff.db' # default value
21  , VarParsing.VarParsing.multiplicity.singleton
22  , VarParsing.VarParsing.varType.string
23  , "Connection string to the DB where payloads will be possibly written."
24  )
25 options.register('conddbConnection'
26  , 'oracle://cms_orcon_adg/CMS_CONDITIONS' # default value
27  , VarParsing.VarParsing.multiplicity.singleton
28  , VarParsing.VarParsing.varType.string
29  , "Connection string to the DB from which the last IOV is read."
30  )
31 options.register('tag'
32  , 'SiStripDetVOff_test'
33  , VarParsing.VarParsing.multiplicity.singleton
34  , VarParsing.VarParsing.varType.string
35  , "Tag written in destinationConnection and finally appended in targetConnection."
36  )
37 options.parseArguments()
38 
39 # convert delay to tmax
40 dt = datetime.datetime.utcnow() - datetime.timedelta(hours=options.delay)
41 tmax = [dt.year, dt.month, dt.day, dt.hour, 0, 0, 0]
42 
43 # authentication path to the key file
44 authPath = os.environ['COND_AUTH_PATH'] if 'COND_AUTH_PATH' in os.environ else os.environ["HOME"]
45 
46 process = cms.Process("SiStripDCSO2O")
47 
48 process.MessageLogger = cms.Service( "MessageLogger",
49  debugModules = cms.untracked.vstring( "*" ),
50  cout = cms.untracked.PSet( threshold = cms.untracked.string( "DEBUG" ) ),
51  destinations = cms.untracked.vstring( "cout" )
52  )
53 
54 process.maxEvents = cms.untracked.PSet(
55  input = cms.untracked.int32(1)
56 )
57 process.source = cms.Source("EmptySource",
58  numberEventsInRun = cms.untracked.uint32(1),
59  firstRun = cms.untracked.uint32(1)
60 )
61 
62 # -----------------------------------------------------------------------------
63 process.SiStripDetVOffBuilder = cms.Service(
64  "SiStripDetVOffBuilder",
65  onlineDB=cms.string(options.sourceConnection),
66  authPath=cms.string(authPath),
67 
68  # Format for date/time vector: year, month, day, hour, minute, second, nanosecond
69  Tmin = cms.vint32(2016, 1, 1, 0, 0, 0, 0),
70  Tmax = cms.vint32(tmax),
71 
72  # Do NOT change this unless you know what you are doing!
73  TSetMin = cms.vint32(2007, 11, 26, 0, 0, 0, 0),
74 
75  # queryType can be either STATUSCHANGE or LASTVALUE
76  queryType = cms.string('STATUSCHANGE'),
77 
78  #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
79  DeltaTmin = cms.uint32(2),
80 
81  #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)
82  MaxIOVlength = cms.uint32(90),
83 
84  # if reading lastValue from file put insert file name here
85  lastValueFile = cms.string(''),
86 
87  # flag to show if you are reading from file for lastValue or not
88  lastValueFromFile = cms.bool(False),
89 
90  # flag to toggle debug output
91  debugModeOn = cms.bool(False),
92 
93  # DetIdFile
94  DetIdListFile = cms.string('CalibTracker/SiStripCommon/data/SiStripDetInfo.dat'),
95 
96  # Threshold to consider an HV channel on
97  HighVoltageOnThreshold = cms.double(0.97),
98 
99  # Leave empty if you want to use the db
100  PsuDetIdMapFile = cms.string("CalibTracker/SiStripDCS/data/StripPSUDetIDMap_FromFeb2016.dat"),
101 
102  #This excluded detids file is not currently used (it was needed when there were unmapped detids.
103  ExcludedDetIdListFile = cms.string('')
104 )
105 
106 # -----------------------------------------------------------------------------
107 process.load("CondCore.CondDB.CondDB_cfi")
108 process.siStripPopConDetVOff = cms.EDAnalyzer( "SiStripO2ODetVOff",
109  process.CondDB,
110  # Get the last IOV from conditionDatabase.
111  # Leave empty for manual restart (will then get the last IOV from sqlite condDbFile).
112  conditionDatabase = cms.string(options.conddbConnection),
113  condDbFile = cms.string(options.destinationConnection),
114  targetTag = cms.string(options.tag),
115  # max length (in hours) before a new IOV is started for the same payload (use -1 to disable this)
116  maxTimeBeforeNewIOV=cms.untracked.int32(168)
117  )
118 
119 process.p = cms.Path(process.siStripPopConDetVOff)