Skip to content

Commit 53fc108

Browse files
authored
Merge pull request cms-sw#31796 from tvami/PixelTempMaking2D
Changes in Pixel 2D template making code cfg for Phase-2 + adding a unit test
2 parents 325b07c + c9b5e8e commit 53fc108

File tree

6 files changed

+82
-76
lines changed

6 files changed

+82
-76
lines changed

CondTools/SiPixel/data/phase2_T15_mapping.csv

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ RULES,,,,
33
BARREL,,,,
44
,,,,
55
TEMPLATE ID ,LAYER,LADDER,MODULE,
6-
1293,1,1-12,1-9,
7-
1293,2,1-28,1-9,
8-
1293,3,1-24,1-9,
9-
1293,4,1-32,1-9,
6+
2293,1,1-12,1-9,
7+
2293,2,1-28,1-9,
8+
2293,3,1-24,1-9,
9+
2293,4,1-32,1-9,
1010
,,,,
1111
ENDCAP,,,,
1212
,,,,
1313
TEMPLATE ID ,DISK,BLADE,SIDE,PANEL
14-
1295,1-12,1-05,1-2,1
14+
2295,1-12,1-05,1-2,1
1515
,,,,
1616
EXCEPTIONS,,,,
1717
,,,,

CondTools/SiPixel/test/BuildFile.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
</library>
1515
<environment>
1616
<bin file="testPixelDBs.cpp">
17-
<flags TEST_RUNNER_ARGS=" /bin/bash CondTools/SiPixel/test run_0T_BoR3.sh"/>
17+
<flags TEST_RUNNER_ARGS=" /bin/bash CondTools/SiPixel/test createTestDBObjects.sh"/>
1818
<use name="FWCore/Utilities"/>
1919
</bin>
2020
</environment>
21-

CondTools/SiPixel/test/SiPixel2DTemplateDBObjectUploader_Phase2_cfg.py

Lines changed: 56 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import FWCore.ParameterSet.Config as cms
22
import FWCore.ParameterSet.VarParsing as opts
33
import csv
4+
from io import open
45

56
options = opts.VarParsing ('standard')
67

@@ -83,31 +84,28 @@
8384
MagFieldString+=magfieldstrsplit[1]
8485

8586
#open the map file
86-
mapfile = open(options.Map,'rUb')
87+
mapfile = open(options.Map,'rU', newline='')
8788
#read the csv file into a reader
8889
mapfilereader = csv.reader(mapfile,delimiter=options.Delimiter,quotechar=options.Quotechar)
8990
#separate into the different sections
9091
barrel_rule_lines = []; endcap_rule_lines = []
9192
barrel_exception_lines = []; endcap_exception_lines = []
9293
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)
9495
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)
9998
try :
100-
line=mapfilereader.next()
99+
line=next(mapfilereader)
101100
except StopIteration :
102-
print 'Done reading input file' #DEBUG
101+
print('Done reading input file')
103102
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
106104
sections[i].append(line)
107105
try :
108-
line=mapfilereader.next()
106+
line=next(mapfilereader)
109107
except StopIteration :
110-
print 'Done reading input file'
108+
print('Done reading input file')
111109
break
112110
#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
113111
#Make the lists of location strings and template IDs
@@ -121,15 +119,15 @@
121119
for s in range(len(sections)) :
122120
for line in sections[s] :
123121
# 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]
125123
while len(template_ID_s)<4 :
126124
template_ID_s='0'+template_ID_s
127125
newtemplatefilename = prefix+template_ID_s+suffix
128126
template_ID = int(template_ID_s)
129127
if not newtemplatefilename in template_filenames :
130128
template_filenames.append(newtemplatefilename)
131129
if s%2==0 :
132-
lay, lad, mod = line[2], line[3], line[4]
130+
lay, lad, mod = line[1], line[2], line[3]
133131
# print ' lay = %s, lad = %s, mod = %s'%(lay, lad, mod) #DEBUG
134132
#barrel ID strings are "layer_ladder_module"
135133
laysplit = lay.split('-'); firstlay=int(laysplit[0]); lastlay= int(laysplit[1])+1 if len(laysplit)>1 else firstlay+1
@@ -149,7 +147,7 @@
149147
location_index = barrel_locations.index(location_string)
150148
barrel_template_IDs[location_index]=template_ID
151149
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]
153151
#endcap ID strings are "disk_blade_side_panel"
154152
disksplit = disk.split('-'); firstdisk=int(disksplit[0]); lastdisk = int(disksplit[1])+1 if len(disksplit)>1 else firstdisk+1
155153
for i in range(firstdisk,lastdisk) :
@@ -172,9 +170,9 @@
172170
#Debug print out assignments
173171
#print 'BARREL ASSIGNMENTS:' #DEBUG
174172
#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
178176
#print 'ENDCAP ASSIGNMENTS:' #DEBUG
179177
#for i in range(len(endcap_locations)) : #DEBUG
180178
# tempid = endcap_template_IDs[i] #DEBUG
@@ -186,13 +184,13 @@
186184
process = cms.Process("SiPixel2DTemplateDBUpload",eras.Phase2)#C2)
187185
process.load("CondCore.CondDB.CondDB_cfi")
188186
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')
191189
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
192190
from Configuration.AlCa.GlobalTag import GlobalTag
193191
process.GlobalTag = GlobalTag(process.GlobalTag, options.GlobalTag, '')
194192

195-
template_base = 'SiPixel2DTemplateDBObject_phase2_'+MagFieldString+'T_'+options.Year+'_v'+version
193+
template_base = 'SiPixel2DTemplateDBObject_phase2_'+MagFieldString+'T'+'_v'+version
196194
if options.numerator==True :
197195
template_base+='_num'
198196
elif options.denominator==True :
@@ -205,49 +203,49 @@
205203
print '\nUploading %s with record SiPixel2DTemplateDBObjectRcd in file %s\n' % (template_base,sqlitefilename)
206204

207205
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+
)
213211
process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1))
214212
if options.numerator==True :
215213
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+
)
226224
elif options.denominator==True :
227225
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+
)
239237
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+
)
251249
process.myprint = cms.OutputModule("AsciiOutputModule")
252250
process.p = cms.Path(process.uploader)
253251
process.CondDB.connect = sqlitefilename
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
function die { echo $1: status $2 ; exit $2; }
4+
5+
echo "TESTING Pixel CPE DB codes ..."
6+
7+
echo "TESTING Pixel 1D Template DB code ..."
8+
cmsRun ${LOCAL_TEST_DIR}/SiPixelTemplateDBObjectUploader_cfg.py MagField=0.0 Fullname=SiPixelTemplateDBObject_phase1_0T_mc_BoR3_v1_bugfix Map=${LOCAL_TEST_DIR}/../data/phaseI_mapping.csv TemplateFilePath=CalibTracker/SiPixelESProducers/data/SiPixelTemplateDBObject_0T_phase1_BoR3_v1 || die "Failure running SiPixelTemplateDBObjectUploader_cfg.py" $?
9+
10+
echo "TESTING Pixel 1D GenErr DB code ..."
11+
cmsRun ${LOCAL_TEST_DIR}/SiPixelGenErrorDBObjectUploader_cfg.py MagField=0.0 Fullname=SiPixelGenErrorDBObject_phase1_0T_mc_BoR3_v1_bugfix Map=${LOCAL_TEST_DIR}/../data/phaseI_mapping.csv GenErrFilePath=CalibTracker/SiPixelESProducers/data/SiPixelTemplateDBObject_0T_phase1_BoR3_v1 || die "Failure running SiPixelGenErrorDBObjectUploader_cfg.py" $?
12+
13+
echo "TESTING Pixel 1D Template DB code for Phase-2 ..."
14+
cmsRun ${LOCAL_TEST_DIR}/SiPixelTemplateDBObjectUploader_Phase2_cfg.py MagField=3.8 Version=7 Append=mc_25x100 Map=${LOCAL_TEST_DIR}/../data/phase2_T15_mapping.csv geometry=T15 TemplateFilePath=CalibTracker/SiPixelESProducers/data/Phase2_25by100_templates_2020October || die "Failure running SiPixelTemplateDBObjectUploader_Phase2_cfg.py" $?
15+
16+
echo "TESTING Pixel 1D GenErr DB code for Phase-2 ..."
17+
cmsRun ${LOCAL_TEST_DIR}/SiPixelGenErrorDBObjectUploader_Phase2_cfg.py MagField=3.8 Version=7 Append=mc_25x100 Map=${LOCAL_TEST_DIR}/../data/phase2_T15_mapping.csv geometry=T15 GenErrFilePath=CalibTracker/SiPixelESProducers/data/Phase2_25by100_templates_2020October || die "Failure running SiPixelGenErrorDBObjectUploader_Phase2_cfg.py" $?
18+
19+
echo "TESTING Pixel 2D Template DB code for Phase-2 ..."
20+
cmsRun ${LOCAL_TEST_DIR}/SiPixel2DTemplateDBObjectUploader_Phase2_cfg.py MagField=3.8 Version=7 Append=mc_25x100 Map=${LOCAL_TEST_DIR}/../data/phase2_T15_mapping.csv TemplateFilePath=CalibTracker/SiPixelESProducers/data/Phase2_25by100_templates_2020October denominator=True || die "Failure running SiPixel2DTemplateDBObjectUploader_Phase2_cfg.py" $?

CondTools/SiPixel/test/run_0T_BoR3.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

CondTools/SiPixel/test/run_Phase2cpeDBTest_v6.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)