Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding missing scripts for ECAL TPG double weights + unit tests #38856

Merged
merged 2 commits into from Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15,026 changes: 15,026 additions & 0 deletions CondTools/Ecal/data/EcalTPGOddWeightGroup_perstrip_test.txt

Large diffs are not rendered by default.

15,176 changes: 15,176 additions & 0 deletions CondTools/Ecal/data/EcalTPGOddWeightIdMap_perstrip_test.txt

Large diffs are not rendered by default.

15,026 changes: 15,026 additions & 0 deletions CondTools/Ecal/data/EcalTPGWeightGroup_perstrip_test.txt

Large diffs are not rendered by default.

15,176 changes: 15,176 additions & 0 deletions CondTools/Ecal/data/EcalTPGWeightIdMap_perstrip_test.txt

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions CondTools/Ecal/python/updateTPGOddWeightGroup.py
@@ -0,0 +1,84 @@
import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.VarParsing as VarParsing

options = VarParsing.VarParsing('analysis')

options.register ('input', # input text file with encoded weight groups
'EcalTPGOddWeightGroup.txt',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"input")
options.register ('output', # output file with SQLite format
'EcalTPGOddWeightGroup.db',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"output")
options.register ('filetype', # input file format txt/xml
'txt',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"filetype")
options.register('outputtag',
'EcalTPGOddWeightGroup',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"outputtag")
options.parseArguments()


process = cms.Process("ProcessOne")

process.MessageLogger = cms.Service("MessageLogger",
cerr = cms.untracked.PSet(
enable = cms.untracked.bool(False)
),
cout = cms.untracked.PSet(
enable = cms.untracked.bool(True),
threshold = cms.untracked.string('DEBUG')
),
debugModules = cms.untracked.vstring('*')
)

process.source = cms.Source("EmptyIOVSource",
lastValue = cms.uint64(100000000000),
timetype = cms.string('runnumber'),
firstValue = cms.uint64(100000000000),
interval = cms.uint64(1)
)

process.load("CondCore.CondDB.CondDB_cfi")

process.CondDB.connect = 'sqlite_file:%s'%(options.output)

process.PoolDBOutputService = cms.Service("PoolDBOutputService",
process.CondDB,
logconnect = cms.untracked.string('sqlite_file:log.db'),
toPut = cms.VPSet(
cms.PSet(
record = cms.string('EcalTPGOddWeightGroupRcd'),
tag = cms.string(options.outputtag)
)
)
)

process.Test1 = cms.EDAnalyzer("ExTestEcalTPGOddWeightGroupAnalyzer",
record = cms.string('EcalTPGOddWeightGroupRcd'),
loggingOn= cms.untracked.bool(True),
IsDestDbCheckedInQueryLog=cms.untracked.bool(True),
SinceAppendMode=cms.bool(True),
Source=cms.PSet(
firstRun = cms.string('1'),
lastRun = cms.string('10'),
OnlineDBSID = cms.string(''),
OnlineDBUser = cms.string(''),
OnlineDBPassword = cms.string(''),
LocationSource = cms.string(''),
Location = cms.string(''),
GenTag = cms.string(''),
RunType = cms.string(''),
fileType = cms.string(options.filetype),
fileName = cms.string(options.input),
)
)

process.p = cms.Path(process.Test1)
84 changes: 84 additions & 0 deletions CondTools/Ecal/python/updateTPGOddWeightIdMap.py
@@ -0,0 +1,84 @@
import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.VarParsing as VarParsing

options = VarParsing.VarParsing('analysis')

options.register ('input', # input text file with encoded weights mapping
'EcalTPGOddWeightIdMap.txt',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"input")
options.register ('output', # output file with SQLite format
'EcalTPGOddWeightIdMap.db',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"output")
options.register ('filetype', # input file format txt/xml
'txt',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"filetype")
options.register('outputtag',
'EcalTPGOddWeightIdMap',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"outputtag")
options.parseArguments()


process = cms.Process("ProcessOne")

process.MessageLogger = cms.Service("MessageLogger",
cerr = cms.untracked.PSet(
enable = cms.untracked.bool(False)
),
cout = cms.untracked.PSet(
enable = cms.untracked.bool(True),
threshold = cms.untracked.string('DEBUG')
),
debugModules = cms.untracked.vstring('*')
)

process.source = cms.Source("EmptyIOVSource",
lastValue = cms.uint64(100000000000),
timetype = cms.string('runnumber'),
firstValue = cms.uint64(100000000000),
interval = cms.uint64(1)
)

process.load("CondCore.CondDB.CondDB_cfi")

process.CondDB.connect = 'sqlite_file:%s'%(options.output)

process.PoolDBOutputService = cms.Service("PoolDBOutputService",
process.CondDB,
logconnect = cms.untracked.string('sqlite_file:log.db'),
toPut = cms.VPSet(
cms.PSet(
record = cms.string('EcalTPGOddWeightIdMapRcd'),
tag = cms.string(options.outputtag)
)
)
)

process.Test1 = cms.EDAnalyzer("ExTestEcalTPGOddWeightIdMapAnalyzer",
record = cms.string('EcalTPGOddWeightIdMapRcd'),
loggingOn= cms.untracked.bool(True),
IsDestDbCheckedInQueryLog=cms.untracked.bool(True),
SinceAppendMode=cms.bool(True),
Source=cms.PSet(
firstRun = cms.string('1'),
lastRun = cms.string('10'),
OnlineDBSID = cms.string(''),
OnlineDBUser = cms.string(''),
OnlineDBPassword = cms.string(''),
LocationSource = cms.string(''),
Location = cms.string(''),
GenTag = cms.string(''),
RunType = cms.string(''),
fileType = cms.string(options.filetype),
fileName = cms.string(options.input),
)
)

process.p = cms.Path(process.Test1)
35 changes: 29 additions & 6 deletions CondTools/Ecal/python/updateTPGWeightGroup.py
@@ -1,4 +1,29 @@
import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.VarParsing as VarParsing

options = VarParsing.VarParsing('analysis')

options.register ('input', # input text file with encoded weight groups
'EcalTPGWeightGroup.txt',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"input")
options.register ('output', # output file with SQLite format
'EcalTPGWeightGroup.db',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"output")
options.register ('filetype', # input file format txt/xml
'txt',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"filetype")
options.register('outputtag',
'EcalTPGWeightGroup',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"outputtag")
options.parseArguments()

process = cms.Process("ProcessOne")

Expand All @@ -22,15 +47,15 @@

process.load("CondCore.CondDB.CondDB_cfi")

process.CondDB.connect = 'sqlite_file:EcalTPGWeightGroup.db'
process.CondDB.connect = 'sqlite_file:%s'%(options.output)

process.PoolDBOutputService = cms.Service("PoolDBOutputService",
process.CondDB,
logconnect = cms.untracked.string('sqlite_file:log.db'),
toPut = cms.VPSet(
cms.PSet(
record = cms.string('EcalTPGWeightGroupRcd'),
tag = cms.string('EcalTPGWeightGroup')
tag = cms.string(options.outputtag)
)
)
)
Expand All @@ -50,10 +75,8 @@
Location = cms.string(''),
GenTag = cms.string(''),
RunType = cms.string(''),
fileType = cms.string('xml'),
# fileType = cms.string('txt'),
fileName = cms.string('EcalTPGWeightGroup.xml'),
# fileName = cms.string('EcalTPGWeightGroup.txt'),
fileType = cms.string(options.filetype),
fileName = cms.string(options.input),
)
)

Expand Down
35 changes: 29 additions & 6 deletions CondTools/Ecal/python/updateTPGWeightIdMap.py
@@ -1,5 +1,30 @@
import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.VarParsing as VarParsing

options = VarParsing.VarParsing('analysis')

options.register ('input', # input text file with encoded weight groups
'EcalTPGWeightIdMap.txt',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"input")
options.register ('output', # output file with SQLite format
'EcalTPGWeightIdMap.db',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"output")
options.register ('filetype', # input file format txt/xml
'txt',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"filetype")
options.register('outputtag',
'EcalTPGWeightIdMap',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"outputtag")
options.parseArguments()

process = cms.Process("ProcessOne")

process.MessageLogger = cms.Service("MessageLogger",
Expand All @@ -22,15 +47,15 @@

process.load("CondCore.CondDB.CondDB_cfi")

process.CondDB.connect = 'sqlite_file:EcalTPGWeightIdMap.db'
process.CondDB.connect = 'sqlite_file:%s'%(options.output)

process.PoolDBOutputService = cms.Service("PoolDBOutputService",
process.CondDB,
logconnect = cms.untracked.string('sqlite_file:log.db'),
toPut = cms.VPSet(
cms.PSet(
record = cms.string('EcalTPGWeightIdMapRcd'),
tag = cms.string('EcalTPGWeightIdMap')
tag = cms.string(options.outputtag)
)
)
)
Expand All @@ -50,10 +75,8 @@
Location = cms.string(''),
GenTag = cms.string(''),
RunType = cms.string(''),
# fileType = cms.string('xml'),
fileType = cms.string('txt'),
# fileName = cms.string('EcalTPGWeightIdMap.xml'),
fileName = cms.string('EcalTPGWeightIdMap.txt'),
fileType = cms.string(options.filetype),
fileName = cms.string(options.input),
)
)

Expand Down
65 changes: 65 additions & 0 deletions CondTools/Ecal/scripts/create_idmaps.py
@@ -0,0 +1,65 @@
import pandas as pd
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("-l","--logicid", help="Logicid mapping", default="params_EBEE_logicid.csv")
parser.add_argument("-i","--inputfile", type=str, help="Input file", required=True)
parser.add_argument("-o","--outputfile", type=str, help="Output file", required=True)
args = parser.parse_args()


gmap = pd.read_csv(args.logicid, sep=",")

final_map = {}
for lid in gmap.stripid:
final_map[lid] = 0


with open(args.inputfile) as lm:
for l in lm.readlines():
if l.startswith("#") or len(l)==0 : continue
n = l.strip().split(" ")
# Now apply the rules
if n[0] == "ALL":
# set all the strips to the value
for k in final_map.keys():
final_map[k] = n[1]

if n[0] == "SUBDET":
if n[1] == "EB":
for strip in gmap[(gmap.FED >= 610)&(gmap.FED <=645)].stripid:
final_map[strip] = n[2]
if n[1] == "EE":
for strip in gmap[(gmap.FED < 610)&(gmap.FED >645)].stripid:
final_map[strip] = n[2]
if n[1] == "EE-":
for strip in gmap[gmap.FED < 610].stripid:
final_map[strip] = n[2]
if n[1] == "EE+":
for strip in gmap[gmap.FED > 645].stripid:
final_map[strip] = n[2]

if n[0] == "FED":
# set all the strips with the FED to value
for strip in gmap[gmap.FED == int(n[1])].stripid:
final_map[strip] = n[2]

if n[0] == "TT":
# all strips of the same TT(EB) or CCU(EE) for all the FEDs
for strip in gmap[gmap.TT == int(n[1])].stripid:
final_map[strip] = n[2]

if n[0] == "FEDTT":
# all strips of the same TT(EB) or CCU(EE) for a specific FEDs
for strip in gmap[(gmap.FED == int(n[1])) & (gmap.TT == int(n[2]))].stripid:
final_map[strip] = n[3]

if n[0] == "STRIP":
final_map[int(n[1])] = n[2]

# Write the final IDMap file
with open(args.outputfile, "w") as of:
for k,v in final_map.items():
of.write("{} {}\n".format(k,v))


5 changes: 5 additions & 0 deletions CondTools/Ecal/test/BuildFile.xml
Expand Up @@ -24,4 +24,9 @@
<test name="EcalTPGTowerStatus_O2O_test" command="EcalTPGTowerStatus_O2O_test.sh"/>
<test name="EcalADCToGeV_update_test" command="EcalADCToGeV_update_test.sh"/>
<test name="EcalIntercalibConstants_O2O_test" command="EcalIntercalibConstants_O2O_test.sh"/>
<test name="EcalTPG_updateWeightGroup_test" command="EcalTPG_updateWeightGroup_test.sh"/>
<test name="EcalTPG_updateWeightIdMap_test" command="EcalTPG_updateWeightIdMap_test.sh"/>
<test name="EcalTPG_updateOddWeightGroup_test" command="EcalTPG_updateOddWeightGroup_test.sh"/>
<test name="EcalTPG_updateOddWeightIdMap_test" command="EcalTPG_updateOddWeightIdMap_test.sh"/>

</ifarch>
6 changes: 6 additions & 0 deletions CondTools/Ecal/test/EcalTPG_updateOddWeightGroup_test.sh
@@ -0,0 +1,6 @@
#!/bin/sh

cmsRun ./src/CondTools/Ecal/python/updateTPGOddWeightGroup.py output=EcalTPGOddWeightGroup_TEST.db input=./src/CondTools/Ecal/data/EcalTPGWeightGroup_perstrip_test.txt filetype=txt outputtag=unittest
ret=$?
echo "return code is $ret"
exit $ret
6 changes: 6 additions & 0 deletions CondTools/Ecal/test/EcalTPG_updateOddWeightIdMap_test.sh
@@ -0,0 +1,6 @@
#!/bin/sh

cmsRun ./src/CondTools/Ecal/python/updateTPGOddWeightIdMap.py output=EcalTPGOddWeightIdMap_TEST.db input=./src/CondTools/Ecal/data/EcalTPGOddWeightIdMap_perstrip_test.txt filetype=txt outputtag=unittest
ret=$?
echo "return code is $ret"
exit $ret
6 changes: 6 additions & 0 deletions CondTools/Ecal/test/EcalTPG_updateWeightGroup_test.sh
@@ -0,0 +1,6 @@
#!/bin/sh

cmsRun ./src/CondTools/Ecal/python/updateTPGWeightGroup.py output=EcalTPGWeightGroup_TEST.db input=./src/CondTools/Ecal/data/EcalTPGWeightGroup_perstrip_test.txt filetype=txt outputtag=unittest
ret=$?
echo "return code is $ret"
exit $ret
6 changes: 6 additions & 0 deletions CondTools/Ecal/test/EcalTPG_updateWeightIdMap_test.sh
@@ -0,0 +1,6 @@
#!/bin/sh

cmsRun ./src/CondTools/Ecal/python/updateTPGWeightIdMap.py output=EcalTPGWeightGroup_TEST.db input=./src/CondTools/Ecal/data/EcalTPGWeightIdMap_perstrip_test.txt filetype=txt outputtag=unittest
ret=$?
echo "return code is $ret"
exit $ret