CMS 3D CMS Logo

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