Skip to content

Commit

Permalink
Update offline to online conversion script from T.Williams
Browse files Browse the repository at this point in the history
  • Loading branch information
bundocka authored and rekovic committed Aug 8, 2018
1 parent ade1913 commit 99e7807
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
51 changes: 34 additions & 17 deletions L1Trigger/L1TCalorimeter/python/convertParamsToOnlineFormat.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def pairwiseGen(aList):
for i in xrange(len(aList)-1):
yield (aList[i], aList[i+1])

def parseOfflineLUTfile(aRelPath):
def parseOfflineLUTfile(aRelPath, aExpectedSize, aPaddingValue = None, aTruncate = False):
# Find file by looking under directories listed in 'CMSSW_SEARCH_PATH' as outlined in https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideEdmFileInPath
searchPaths = os.getenv('CMSSW_SEARCH_PATH').split(':')
resolvedPath = None
Expand Down Expand Up @@ -65,7 +65,19 @@ def parseOfflineLUTfile(aRelPath):
print("ERROR parsing file", resolvedPath, ": ", x2[0] - x1[0] - 1,"LUT entries between indices", x1[0], "and", x2[0], "are not defined")
sys.exit(1)

return [x[1] for x in entries]
result = [x[1] for x in entries]

if (len(result) < aExpectedSize) and not (aPaddingValue is None):
print "WARNING : Padding", str(len(result))+"-entry LUT with value", aPaddingValue, "to have", aExpectedSize, "entries"
result += ([aPaddingValue] * (aExpectedSize - len(result)))
elif (len(result) > aExpectedSize) and aTruncate:
print "WARNING : Truncating", str(len(result))+"-entry LUT to have", aExpectedSize, "entries"
result = result[0:aExpectedSize]
elif len(result) != aExpectedSize:
print "ERROR parsing file", resolvedPath, ": Expected LUT of size", aExpectedSize, ", but", len(result), "entries were specified (and no padding/truncation requested)"
sys.exit(1)

return result


def getFullListOfParameters(aModule):
Expand All @@ -90,39 +102,40 @@ def divideByJetLsb(aParam):

result += [
(('mp_egamma', 'egammaRelaxationThreshold'), '10_EgRelaxThr.mif', divideByEgLsb(aModule.egMaxPtHOverE)),
(('mp_egamma', 'egammaMaxEta'), '5_EgammaTauEtaMax.mif', aModule.egEtaCut.value()),
(('mp_egamma', 'egammaMaxEta'), 'egammaMaxEta.mif', aModule.egEtaCut.value()),
(('mp_egamma', 'egammaBypassCuts'), 'BypassEgVeto.mif', bool(aModule.egBypassEGVetos.value())),
(('mp_egamma', 'egammaHOverECut_iEtaLT15'), '_RatioCutLt15.mif', aModule.egHOverEcutBarrel.value()),
(('mp_egamma', 'egammaHOverECut_iEtaGTEq15'), '_RatioCutGe15.mif', aModule.egHOverEcutEndcap.value()),
(('mp_egamma', 'egammaBypassExtendedHOverE'), '_BypassExtHE.mif', bool(aModule.egBypassExtHOverE)),
(('mp_egamma', 'egammaEnergyCalibLUT'), 'C_EgammaCalibration_12to18.mif', parseOfflineLUTfile(aModule.egCalibrationLUTFile.value())),
(('mp_egamma', 'egammaIsoLUT1'), 'D_EgammaIsolation1_13to9.mif', parseOfflineLUTfile(aModule.egIsoLUTFile.value())),
(('mp_egamma', 'egammaIsoLUT2'), 'D_EgammaIsolation2_13to9.mif', parseOfflineLUTfile(aModule.egIsoLUTFile2.value()))
(('mp_egamma', 'egammaEnergyCalibLUT'), 'C_EgammaCalibration_12to18.mif', parseOfflineLUTfile(aModule.egCalibrationLUTFile.value(), 4096)),
(('mp_egamma', 'egammaIsoLUT1'), 'D_EgammaIsolation1_13to9.mif', parseOfflineLUTfile(aModule.egIsoLUTFile.value(), 8192)),
(('mp_egamma', 'egammaIsoLUT2'), 'D_EgammaIsolation2_13to9.mif', parseOfflineLUTfile(aModule.egIsoLUTFile2.value(), 8192))
]

result += [
(('mp_tau', 'tauMaxEta'), '5_EgammaTauEtaMax.mif', aModule.isoTauEtaMax.value()),
(('mp_tau', 'tauEnergyCalibLUT'), 'I_TauCalibration_11to18.mif', parseOfflineLUTfile(aModule.tauCalibrationLUTFile.value())),
(('mp_tau', 'tauIsoLUT'), 'H_TauIsolation_12to9.mif', parseOfflineLUTfile(aModule.tauIsoLUTFile.value()))
(('mp_tau', 'tauMaxEta'), 'tauMaxEta.mif', aModule.isoTauEtaMax.value()),
(('mp_tau', 'tauEnergyCalibLUT'), 'I_TauCalibration_11to18.mif', parseOfflineLUTfile(aModule.tauCalibrationLUTFile.value(), 2048, 0x0)),
(('mp_tau', 'tauIsoLUT'), 'H_TauIsolation_12to9.mif', parseOfflineLUTfile(aModule.tauIsoLUTFile.value(), 4096)),
(('mp_tau', 'tauTrimmingLUT'), 'P_TauTrimming_13to8.mif', parseOfflineLUTfile(aModule.tauTrimmingShapeVetoLUTFile.value(), 8192))
]

result += [
(('mp_jet', 'jetSeedThreshold'), '1_JetSeedThreshold.mif', divideByJetLsb(aModule.jetSeedThreshold)),
(('mp_jet', 'jetMaxEta'), '6_JetEtaMax.mif', 0x00028),
(('mp_jet', 'HTMHT_maxJetEta'), '7_RingEtaMax.mif', aModule.etSumEtaMax[1]), # assert == etSumEtaMax[3] ?
(('mp_jet', 'HTMHT_maxJetEta'), 'HTMHT_maxJetEta.mif', aModule.etSumEtaMax[1]), # assert == etSumEtaMax[3] ?
(('mp_jet', 'HT_jetThreshold'), '8_HtThreshold.mif', int(aModule.etSumEtThreshold[1] / aModule.etSumLsb.value())),
(('mp_jet', 'MHT_jetThreshold'), '9_MHtThreshold.mif', int(aModule.etSumEtThreshold[3] / aModule.etSumLsb.value())),
(('mp_jet', 'jetBypassPileUpSub'), 'BypassJetPUS.mif', bool(aModule.jetBypassPUS.value())),
(('mp_jet', 'jetEnergyCalibLUT'), 'L_JetCalibration_11to18.mif', aModule.jetCalibrationLUTFile)
(('mp_jet', 'jetEnergyCalibLUT'), 'L_JetCalibration_11to18.mif', parseOfflineLUTfile(aModule.jetCalibrationLUTFile.value(), 2048))
]

result += [
(('mp_sums', 'towerCountThreshold'), 'HeavyIonThr.mif', int(aModule.etSumEtThreshold[4] / aModule.etSumLsb.value()) ),
(('mp_sums', 'towerCountMaxEta'), 'HeavyIonEta.mif', aModule.etSumEtaMax[4]),
(('mp_sums', 'ETMET_maxTowerEta'), '7_RingEtaMax.mif', aModule.etSumEtaMax[0]), # assert == etSumEtaMax[2] ?
(('mp_sums', 'ecalET_towerThresholdLUT'), 'X_EcalTHR_11to9.mif', aModule.etSumEcalSumPUSLUTFile),
(('mp_sums', 'ET_towerThresholdLUT'), 'X_ETTHR_11to9.mif', aModule.etSumMetPUSLUTFile),
(('mp_sums', 'MET_towerThresholdLUT'), 'X_METTHR_11to9.mif', aModule.etSumMetPUSLUTFile)
(('mp_sums', 'towerCountThreshold'), 'HeavyIonThr.mif', int(aModule.etSumEtThreshold[4] / aModule.etSumLsb.value()) ),
(('mp_sums', 'towerCountMaxEta'), 'HeavyIonEta.mif', aModule.etSumEtaMax[4]),
(('mp_sums', 'ETMET_maxTowerEta'), 'ETMET_maxTowerEta.mif', aModule.etSumEtaMax[0]), # assert == etSumEtaMax[2] ?
(('mp_sums', 'ecalET_towerThresholdLUT'), 'X_EcalTHR_11to9.mif', parseOfflineLUTfile(aModule.etSumEcalSumPUSLUTFile.value(), 2048, aTruncate = True)),
(('mp_sums', 'ET_towerThresholdLUT'), 'X_ETTHR_11to9.mif', parseOfflineLUTfile(aModule.etSumEttPUSLUTFile.value(), 2048, aTruncate = True)),
(('mp_sums', 'MET_towerThresholdLUT'), 'X_METTHR_11to9.mif', parseOfflineLUTfile(aModule.etSumMetPUSLUTFile.value(), 2048))
]

result += [
Expand Down Expand Up @@ -223,9 +236,13 @@ def createXML(parameters, contextId, outputFilePath):
print("Importing calo params from module:", moduleName)
caloParams = import_module(moduleName).caloStage2Params

<<<<<<< HEAD
print(caloParams.egCalibrationLUTFile.value())
print(caloParams.egIsoLUTFile.value())
print(caloParams.egIsoLUTFile2.value())
=======
print
>>>>>>> Update offline to online conversion script from T.Williams
os.mkdir(args.output_dir)

if args.mif:
Expand Down
3 changes: 2 additions & 1 deletion L1Trigger/L1TCalorimeter/test/runCaloLayer2MPFWValidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@

# emulator
process.load('L1Trigger.L1TCalorimeter.simCaloStage2Digis_cfi')
process.simCaloStage2Digis.useStaticConfig = True
process.simCaloStage2Digis.towerToken = cms.InputTag("caloStage2Digis","CaloTower")

# emulator ES
process.load('L1Trigger.L1TCalorimeter.caloStage2Params_2017_v1_8_4_cfi')
process.load('L1Trigger.L1TCalorimeter.caloParams_2018_v1_3_cfi')

# histograms
process.load('L1Trigger.L1TCalorimeter.l1tStage2CaloAnalyzer_cfi')
Expand Down
2 changes: 1 addition & 1 deletion L1Trigger/L1TCalorimeter/test/runEmulator-CaloStage2.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
process.simCaloStage2Layer1Digis.hcalToken = cms.InputTag("hcalDigis")

# emulator ES
process.load('L1Trigger.L1TCalorimeter.caloStage2Params_2017_v1_8_4_cfi')
process.load('L1Trigger.L1TCalorimeter.caloParams_2018_v1_3_cfi')

# histograms
process.load('L1Trigger.L1TCalorimeter.l1tStage2CaloAnalyzer_cfi')
Expand Down

0 comments on commit 99e7807

Please sign in to comment.