|
1 | 1 | import FWCore.ParameterSet.Config as cms |
2 | 2 | import FWCore.ParameterSet.VarParsing as opts |
3 | 3 | import csv |
| 4 | +from io import open |
4 | 5 |
|
5 | 6 | options = opts.VarParsing ('standard') |
6 | 7 |
|
|
83 | 84 | MagFieldString+=magfieldstrsplit[1] |
84 | 85 |
|
85 | 86 | #open the map file |
86 | | -mapfile = open(options.Map,'rUb') |
| 87 | +mapfile = open(options.Map,'rU', newline='') |
87 | 88 | #read the csv file into a reader |
88 | 89 | mapfilereader = csv.reader(mapfile,delimiter=options.Delimiter,quotechar=options.Quotechar) |
89 | 90 | #separate into the different sections |
90 | 91 | barrel_rule_lines = []; endcap_rule_lines = [] |
91 | 92 | barrel_exception_lines = []; endcap_exception_lines = [] |
92 | 93 | sections = [barrel_rule_lines, endcap_rule_lines, barrel_exception_lines, endcap_exception_lines] |
93 | | -i=0; line = mapfilereader.next() |
| 94 | +i=0; line = next(mapfilereader) |
94 | 95 | for i in range(len(sections)) : |
95 | | - #print 'line = %s (length=%d)'%(line,len(line)) #DEBUG |
96 | | - while len(line)==0 or line[0].find('NUMERATOR TEMPLATE ID')==-1 : #skip to just before the section of info |
97 | | - line=mapfilereader.next() |
98 | | - # print 'line = %s (length=%d)'%(line,len(line)) #DEBUG |
| 96 | + while line[0].find('TEMPLATE ID')==-1 : #skip to just before the section of info |
| 97 | + line=next(mapfilereader) |
99 | 98 | try : |
100 | | - line=mapfilereader.next() |
| 99 | + line=next(mapfilereader) |
101 | 100 | except StopIteration : |
102 | | - print 'Done reading input file' #DEBUG |
| 101 | + print('Done reading input file') |
103 | 102 | break |
104 | | - #print 'line2 = %s'%(line) #DEBUG |
105 | | - while len(line)>0 and line[1]!='' : #add the relevant lines to the section |
| 103 | + while line[1]!='' : #add the lines that are the barrel rules |
106 | 104 | sections[i].append(line) |
107 | 105 | try : |
108 | | - line=mapfilereader.next() |
| 106 | + line=next(mapfilereader) |
109 | 107 | except StopIteration : |
110 | | - print 'Done reading input file' |
| 108 | + print('Done reading input file') |
111 | 109 | break |
112 | 110 | #print 'barrel rules = %s\nendcap rules = %s\nbarrel exceptions = %s\nendcap exceptions = %s'%(barrel_rule_lines,endcap_rule_lines,barrel_exception_lines,endcap_exception_lines) #DEBUG |
113 | 111 | #Make the lists of location strings and template IDs |
|
121 | 119 | for s in range(len(sections)) : |
122 | 120 | for line in sections[s] : |
123 | 121 | # print 'reading line: %s'%(line) #DEBUG |
124 | | - template_ID_s = line[0] if options.numerator==True else line[1] |
| 122 | + template_ID_s = line[0] |
125 | 123 | while len(template_ID_s)<4 : |
126 | 124 | template_ID_s='0'+template_ID_s |
127 | 125 | newtemplatefilename = prefix+template_ID_s+suffix |
128 | 126 | template_ID = int(template_ID_s) |
129 | 127 | if not newtemplatefilename in template_filenames : |
130 | 128 | template_filenames.append(newtemplatefilename) |
131 | 129 | if s%2==0 : |
132 | | - lay, lad, mod = line[2], line[3], line[4] |
| 130 | + lay, lad, mod = line[1], line[2], line[3] |
133 | 131 | # print ' lay = %s, lad = %s, mod = %s'%(lay, lad, mod) #DEBUG |
134 | 132 | #barrel ID strings are "layer_ladder_module" |
135 | 133 | laysplit = lay.split('-'); firstlay=int(laysplit[0]); lastlay= int(laysplit[1])+1 if len(laysplit)>1 else firstlay+1 |
|
149 | 147 | location_index = barrel_locations.index(location_string) |
150 | 148 | barrel_template_IDs[location_index]=template_ID |
151 | 149 | else : |
152 | | - disk, blade, side, panel = line[2], line[3], line[4], line[5] |
| 150 | + disk, blade, side, panel = line[1], line[2], line[3], line[4] |
153 | 151 | #endcap ID strings are "disk_blade_side_panel" |
154 | 152 | disksplit = disk.split('-'); firstdisk=int(disksplit[0]); lastdisk = int(disksplit[1])+1 if len(disksplit)>1 else firstdisk+1 |
155 | 153 | for i in range(firstdisk,lastdisk) : |
|
172 | 170 | #Debug print out assignments |
173 | 171 | #print 'BARREL ASSIGNMENTS:' #DEBUG |
174 | 172 | #for i in range(len(barrel_locations)) : #DEBUG |
175 | | -# tempid = barrel_template_IDs[i] #DEBUG |
176 | | -# lay, lad, mod = barrel_locations[i].split('_')[0], barrel_locations[i].split('_')[1], barrel_locations[i].split('_')[2] #DEBUG |
177 | | -# print ' layer %s, ladder %s, module %s will have template ID %d assigned to it'%(lay,lad,mod,tempid) #DEBUG |
| 173 | + #tempid = barrel_template_IDs[i] #DEBUG |
| 174 | + #lay, lad, mod = barrel_locations[i].split('_')[0], barrel_locations[i].split('_')[1], barrel_locations[i].split('_')[2] #DEBUG |
| 175 | + #print ' layer %s, ladder %s, module %s will have template ID %d assigned to it'%(lay,lad,mod,tempid) #DEBUG |
178 | 176 | #print 'ENDCAP ASSIGNMENTS:' #DEBUG |
179 | 177 | #for i in range(len(endcap_locations)) : #DEBUG |
180 | 178 | # tempid = endcap_template_IDs[i] #DEBUG |
|
186 | 184 | process = cms.Process("SiPixel2DTemplateDBUpload",eras.Phase2)#C2) |
187 | 185 | process.load("CondCore.CondDB.CondDB_cfi") |
188 | 186 | process.load("FWCore.MessageService.MessageLogger_cfi") |
189 | | -process.load('Configuration.Geometry.GeometryExtended2023D17Reco_cff') |
190 | | -process.load('Configuration.Geometry.GeometryExtended2023D17_cff') |
| 187 | +process.load('Configuration.Geometry.GeometryExtended2026D49_cff') |
| 188 | +process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') |
191 | 189 | process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") |
192 | 190 | from Configuration.AlCa.GlobalTag import GlobalTag |
193 | 191 | process.GlobalTag = GlobalTag(process.GlobalTag, options.GlobalTag, '') |
194 | 192 |
|
195 | | -template_base = 'SiPixel2DTemplateDBObject_phase2_'+MagFieldString+'T_'+options.Year+'_v'+version |
| 193 | +template_base = 'SiPixel2DTemplateDBObject_phase2_'+MagFieldString+'T'+'_v'+version |
196 | 194 | if options.numerator==True : |
197 | 195 | template_base+='_num' |
198 | 196 | elif options.denominator==True : |
|
205 | 203 | print '\nUploading %s with record SiPixel2DTemplateDBObjectRcd in file %s\n' % (template_base,sqlitefilename) |
206 | 204 |
|
207 | 205 | process.source = cms.Source("EmptyIOVSource", |
208 | | - timetype = cms.string('runnumber'), |
209 | | - firstValue = cms.uint64(1), |
210 | | - lastValue = cms.uint64(1), |
211 | | - interval = cms.uint64(1) |
212 | | - ) |
| 206 | + timetype = cms.string('runnumber'), |
| 207 | + firstValue = cms.uint64(1), |
| 208 | + lastValue = cms.uint64(1), |
| 209 | + interval = cms.uint64(1) |
| 210 | + ) |
213 | 211 | process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1)) |
214 | 212 | if options.numerator==True : |
215 | 213 | process.PoolDBOutputService = cms.Service("PoolDBOutputService", |
216 | | - DBParameters = cms.PSet(messageLevel = cms.untracked.int32(0), |
217 | | - authenticationPath = cms.untracked.string('.') |
218 | | - ), |
219 | | - timetype = cms.untracked.string('runnumber'), |
220 | | - connect = cms.string(sqlitefilename), |
221 | | - toPut = cms.VPSet(cms.PSet(record = cms.string('SiPixel2DTemplateDBObjectRcd'), |
222 | | - tag = cms.string(template_base) |
223 | | - ) |
224 | | - ) |
225 | | - ) |
| 214 | + DBParameters = cms.PSet(messageLevel = cms.untracked.int32(0), |
| 215 | + authenticationPath = cms.untracked.string('.') |
| 216 | + ), |
| 217 | + timetype = cms.untracked.string('runnumber'), |
| 218 | + connect = cms.string(sqlitefilename), |
| 219 | + toPut = cms.VPSet(cms.PSet(record = cms.string('SiPixel2DTemplateDBObjectRcd'), |
| 220 | + tag = cms.string(template_base) |
| 221 | + ) |
| 222 | + ) |
| 223 | + ) |
226 | 224 | elif options.denominator==True : |
227 | 225 | process.PoolDBOutputService = cms.Service("PoolDBOutputService", |
228 | | - DBParameters = cms.PSet(messageLevel = cms.untracked.int32(0), |
229 | | - authenticationPath = cms.untracked.string('.') |
230 | | - ), |
231 | | - timetype = cms.untracked.string('runnumber'), |
232 | | - connect = cms.string(sqlitefilename), |
233 | | - toPut = cms.VPSet(cms.PSet(record = cms.string('SiPixel2DTemplateDBObjectRcd'), |
234 | | - label=cms.string('unirradiated'), |
235 | | - tag = cms.string(template_base) |
236 | | - ) |
237 | | - ) |
238 | | - ) |
| 226 | + DBParameters = cms.PSet(messageLevel = cms.untracked.int32(0), |
| 227 | + authenticationPath = cms.untracked.string('.') |
| 228 | + ), |
| 229 | + timetype = cms.untracked.string('runnumber'), |
| 230 | + connect = cms.string(sqlitefilename), |
| 231 | + toPut = cms.VPSet(cms.PSet(record = cms.string('SiPixel2DTemplateDBObjectRcd'), |
| 232 | + label=cms.string('unirradiated'), |
| 233 | + tag = cms.string(template_base) |
| 234 | + ) |
| 235 | + ) |
| 236 | + ) |
239 | 237 | process.uploader = cms.EDAnalyzer("SiPixel2DTemplateDBObjectUploader", |
240 | | - siPixelTemplateCalibrations = cms.vstring(template_filenames), |
241 | | - theTemplateBaseString = cms.string(template_base), |
242 | | - Version = cms.double(3.0), |
243 | | - MagField = cms.double(MagFieldValue), |
244 | | - detIds = cms.vuint32(1,2), #0 is for all, 1 is Barrel, 2 is EndCap |
245 | | - barrelLocations = cms.vstring(barrel_locations), |
246 | | - endcapLocations = cms.vstring(endcap_locations), |
247 | | - barrelTemplateIds = cms.vuint32(barrel_template_IDs), |
248 | | - endcapTemplateIds = cms.vuint32(endcap_template_IDs), |
249 | | - useVectorIndices = cms.untracked.bool(options.useVectorIndices), |
250 | | - ) |
| 238 | + siPixelTemplateCalibrations = cms.vstring(template_filenames), |
| 239 | + theTemplateBaseString = cms.string(template_base), |
| 240 | + Version = cms.double(3.0), |
| 241 | + MagField = cms.double(MagFieldValue), |
| 242 | + detIds = cms.vuint32(1,2), #0 is for all, 1 is Barrel, 2 is EndCap |
| 243 | + barrelLocations = cms.vstring(barrel_locations), |
| 244 | + endcapLocations = cms.vstring(endcap_locations), |
| 245 | + barrelTemplateIds = cms.vuint32(barrel_template_IDs), |
| 246 | + endcapTemplateIds = cms.vuint32(endcap_template_IDs), |
| 247 | + useVectorIndices = cms.untracked.bool(options.useVectorIndices), |
| 248 | + ) |
251 | 249 | process.myprint = cms.OutputModule("AsciiOutputModule") |
252 | 250 | process.p = cms.Path(process.uploader) |
253 | 251 | process.CondDB.connect = sqlitefilename |
|
0 commit comments