File indexing completed on 2024-04-06 12:19:16
0001 import FWCore.ParameterSet.Config as cms
0002
0003 class ValidFFTJetCorr:
0004 """
0005 A class which contains the info about a valid combination
0006 of ES record types, ES producer type, and jet type
0007 """
0008 def __init__(self, basename, jetType):
0009 self.basename = basename
0010 self.dbTag = "FFT" + basename + "CorrectorDBTag"
0011 self.dbRecord = "FFT" + basename + "CorrectorParametersRcd"
0012 self.correctorRecord = "FFT" + basename + "CorrectorSequenceRcd"
0013 self.esProducer = "FFT" + basename + "CorrectionESProducer"
0014 self.jetType = jetType
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 fftjet_corr_types = {
0033 "BasicJet" : ValidFFTJetCorr("BasicJet", "BasicJet"),
0034 "GenJet" : ValidFFTJetCorr("GenJet", "GenJet"),
0035 "CaloJet" : ValidFFTJetCorr("CaloJet", "CaloJet"),
0036 "PFJet" : ValidFFTJetCorr("PFJet", "PFJet"),
0037 "TrackJet" : ValidFFTJetCorr("TrackJet", "TrackJet"),
0038 "JPTJet" : ValidFFTJetCorr("JPTJet", "JPTJet"),
0039 "PFCHS0" : ValidFFTJetCorr("PFCHS0", "PFJet"),
0040 "PFCHS1" : ValidFFTJetCorr("PFCHS1", "PFJet"),
0041 "PFCHS2" : ValidFFTJetCorr("PFCHS2", "PFJet"),
0042 "BasicJetSys" : ValidFFTJetCorr("BasicJetSys", "BasicJet"),
0043 "GenJetSys" : ValidFFTJetCorr("GenJetSys", "GenJet"),
0044 "CaloJetSys" : ValidFFTJetCorr("CaloJetSys", "CaloJet"),
0045 "PFJetSys" : ValidFFTJetCorr("PFJetSys", "PFJet"),
0046 "TrackJetSys" : ValidFFTJetCorr("TrackJetSys", "TrackJet"),
0047 "JPTJetSys" : ValidFFTJetCorr("JPTJetSys", "JPTJet"),
0048 "PFCHS0Sys" : ValidFFTJetCorr("PFCHS0Sys", "PFJet"),
0049 "PFCHS1Sys" : ValidFFTJetCorr("PFCHS1Sys", "PFJet"),
0050 "PFCHS2Sys" : ValidFFTJetCorr("PFCHS2Sys", "PFJet"),
0051 "Gen0" : ValidFFTJetCorr("Gen0", "GenJet"),
0052 "Gen1" : ValidFFTJetCorr("Gen1", "GenJet"),
0053 "Gen2" : ValidFFTJetCorr("Gen2", "GenJet"),
0054 "PF0" : ValidFFTJetCorr("PF0", "PFJet"),
0055 "PF1" : ValidFFTJetCorr("PF1", "PFJet"),
0056 "PF2" : ValidFFTJetCorr("PF2", "PFJet"),
0057 "PF3" : ValidFFTJetCorr("PF3", "PFJet"),
0058 "PF4" : ValidFFTJetCorr("PF4", "PFJet"),
0059 "Calo0" : ValidFFTJetCorr("Calo0", "CaloJet"),
0060 "Calo1" : ValidFFTJetCorr("Calo1", "CaloJet"),
0061 "Calo2" : ValidFFTJetCorr("Calo2", "CaloJet"),
0062 "Calo3" : ValidFFTJetCorr("Calo3", "CaloJet"),
0063 "Calo4" : ValidFFTJetCorr("Calo4", "CaloJet"),
0064 "Gen0Sys" : ValidFFTJetCorr("Gen0Sys", "GenJet"),
0065 "Gen1Sys" : ValidFFTJetCorr("Gen1Sys", "GenJet"),
0066 "Gen2Sys" : ValidFFTJetCorr("Gen2Sys", "GenJet"),
0067 "PF0Sys" : ValidFFTJetCorr("PF0Sys", "PFJet"),
0068 "PF1Sys" : ValidFFTJetCorr("PF1Sys", "PFJet"),
0069 "PF2Sys" : ValidFFTJetCorr("PF2Sys", "PFJet"),
0070 "PF3Sys" : ValidFFTJetCorr("PF3Sys", "PFJet"),
0071 "PF4Sys" : ValidFFTJetCorr("PF4Sys", "PFJet"),
0072 "PF5Sys" : ValidFFTJetCorr("PF5Sys", "PFJet"),
0073 "PF6Sys" : ValidFFTJetCorr("PF6Sys", "PFJet"),
0074 "PF7Sys" : ValidFFTJetCorr("PF7Sys", "PFJet"),
0075 "PF8Sys" : ValidFFTJetCorr("PF8Sys", "PFJet"),
0076 "PF9Sys" : ValidFFTJetCorr("PF9Sys", "PFJet"),
0077 "Calo0Sys" : ValidFFTJetCorr("Calo0Sys", "CaloJet"),
0078 "Calo1Sys" : ValidFFTJetCorr("Calo1Sys", "CaloJet"),
0079 "Calo2Sys" : ValidFFTJetCorr("Calo2Sys", "CaloJet"),
0080 "Calo3Sys" : ValidFFTJetCorr("Calo3Sys", "CaloJet"),
0081 "Calo4Sys" : ValidFFTJetCorr("Calo4Sys", "CaloJet"),
0082 "Calo5Sys" : ValidFFTJetCorr("Calo5Sys", "CaloJet"),
0083 "Calo6Sys" : ValidFFTJetCorr("Calo6Sys", "CaloJet"),
0084 "Calo7Sys" : ValidFFTJetCorr("Calo7Sys", "CaloJet"),
0085 "Calo8Sys" : ValidFFTJetCorr("Calo8Sys", "CaloJet"),
0086 "Calo9Sys" : ValidFFTJetCorr("Calo9Sys", "CaloJet"),
0087 "CHS0Sys" : ValidFFTJetCorr("CHS0Sys", "PFJet"),
0088 "CHS1Sys" : ValidFFTJetCorr("CHS1Sys", "PFJet"),
0089 "CHS2Sys" : ValidFFTJetCorr("CHS2Sys", "PFJet"),
0090 "CHS3Sys" : ValidFFTJetCorr("CHS3Sys", "PFJet"),
0091 "CHS4Sys" : ValidFFTJetCorr("CHS4Sys", "PFJet"),
0092 "CHS5Sys" : ValidFFTJetCorr("CHS5Sys", "PFJet"),
0093 "CHS6Sys" : ValidFFTJetCorr("CHS6Sys", "PFJet"),
0094 "CHS7Sys" : ValidFFTJetCorr("CHS7Sys", "PFJet"),
0095 "CHS8Sys" : ValidFFTJetCorr("CHS8Sys", "PFJet"),
0096 "CHS9Sys" : ValidFFTJetCorr("CHS9Sys", "PFJet")
0097 }
0098
0099
0100
0101
0102
0103
0104
0105 def configure_L2L3_fftjet_esproducer(sequenceTag, tableName, tableCategory):
0106
0107
0108 esProducer = fftjet_corr_types[sequenceTag].esProducer
0109 config = cms.ESProducer(
0110 esProducer,
0111 sequence = cms.VPSet(
0112 cms.PSet(
0113 level = cms.uint32(2),
0114 applyTo = cms.string("DataOrMC"),
0115 adjuster = cms.PSet(
0116 Class = cms.string("FFTSimpleScalingAdjuster")
0117 ),
0118 scalers = cms.VPSet(
0119 cms.PSet(
0120 Class = cms.string("auto"),
0121 name = cms.string(tableName),
0122 nameIsRegex = cms.bool(False),
0123 category = cms.string(tableCategory),
0124 categoryIsRegex = cms.bool(False)
0125 )
0126 )
0127 )
0128 ),
0129 isArchiveCompressed = cms.bool(False),
0130 verbose = cms.untracked.bool(False)
0131 )
0132 return (config, esProducer)
0133
0134
0135
0136
0137 def configure_L2Res_fftjet_esproducer(sequenceTag, tableName, tableCategory):
0138
0139
0140 esProducer = fftjet_corr_types[sequenceTag].esProducer
0141 config = cms.ESProducer(
0142 esProducer,
0143 sequence = cms.VPSet(
0144 cms.PSet(
0145 level = cms.uint32(3),
0146 applyTo = cms.string("DataOnly"),
0147 adjuster = cms.PSet(
0148 Class = cms.string("FFTSimpleScalingAdjuster")
0149 ),
0150 scalers = cms.VPSet(
0151 cms.PSet(
0152 Class = cms.string("FFTSpecificScaleCalculator"),
0153 Subclass = cms.PSet(
0154 Class = cms.string("L2ResScaleCalculator"),
0155 radiusFactor = cms.double(1.0)
0156 ),
0157 name = cms.string(tableName),
0158 nameIsRegex = cms.bool(False),
0159 category = cms.string(tableCategory),
0160 categoryIsRegex = cms.bool(False)
0161 )
0162 )
0163 )
0164 ),
0165 isArchiveCompressed = cms.bool(False),
0166 verbose = cms.untracked.bool(False)
0167 )
0168 return (config, esProducer)
0169
0170
0171
0172
0173 def configure_L3Res_fftjet_esproducer(sequenceTag, tableName, tableCategory):
0174
0175
0176 esProducer = fftjet_corr_types[sequenceTag].esProducer
0177 config = cms.ESProducer(
0178 esProducer,
0179 sequence = cms.VPSet(
0180 cms.PSet(
0181 level = cms.uint32(4),
0182 applyTo = cms.string("DataOnly"),
0183 adjuster = cms.PSet(
0184 Class = cms.string("FFTSimpleScalingAdjuster")
0185 ),
0186 scalers = cms.VPSet(
0187 cms.PSet(
0188 Class = cms.string("FFTSpecificScaleCalculator"),
0189 Subclass = cms.PSet(
0190 Class = cms.string("L2RecoScaleCalculator"),
0191 radiusFactor = cms.double(1.0)
0192 ),
0193 name = cms.string(tableName),
0194 nameIsRegex = cms.bool(False),
0195 category = cms.string(tableCategory),
0196 categoryIsRegex = cms.bool(False)
0197 )
0198 )
0199 )
0200 ),
0201 isArchiveCompressed = cms.bool(False),
0202 verbose = cms.untracked.bool(False)
0203 )
0204 return (config, esProducer)
0205
0206
0207
0208
0209 def configure_FFTGenericScaleCalculator(variables, factorsForTheseVariables):
0210 if len(variables) == 0:
0211 raise ValueError("Must have at least one variable mapped")
0212 if len(variables) != len(factorsForTheseVariables):
0213 raise ValueError("Incompatible length of the input arguments")
0214 subclass = cms.PSet(
0215 Class = cms.string("FFTGenericScaleCalculator"),
0216 factors = cms.vdouble(factorsForTheseVariables),
0217 eta=cms.int32(-1),
0218 phi=cms.int32(-1),
0219 pt=cms.int32(-1),
0220 logPt=cms.int32(-1),
0221 mass=cms.int32(-1),
0222 logMass=cms.int32(-1),
0223 energy=cms.int32(-1),
0224 logEnergy=cms.int32(-1),
0225 gamma=cms.int32(-1),
0226 logGamma=cms.int32(-1),
0227 pileup=cms.int32(-1),
0228 ncells=cms.int32(-1),
0229 etSum=cms.int32(-1),
0230 etaWidth=cms.int32(-1),
0231 phiWidth=cms.int32(-1),
0232 averageWidth=cms.int32(-1),
0233 widthRatio=cms.int32(-1),
0234 etaPhiCorr=cms.int32(-1),
0235 fuzziness=cms.int32(-1),
0236 convergenceDistance=cms.int32(-1),
0237 recoScale=cms.int32(-1),
0238 recoScaleRatio=cms.int32(-1),
0239 membershipFactor=cms.int32(-1),
0240 magnitude=cms.int32(-1),
0241 logMagnitude=cms.int32(-1),
0242 magS1=cms.int32(-1),
0243 LogMagS1=cms.int32(-1),
0244 magS2=cms.int32(-1),
0245 LogMagS2=cms.int32(-1),
0246 driftSpeed=cms.int32(-1),
0247 magSpeed=cms.int32(-1),
0248 lifetime=cms.int32(-1),
0249 splitTime=cms.int32(-1),
0250 mergeTime=cms.int32(-1),
0251 scale=cms.int32(-1),
0252 logScale=cms.int32(-1),
0253 nearestNeighborDistance=cms.int32(-1),
0254 clusterRadius=cms.int32(-1),
0255 clusterSeparation=cms.int32(-1),
0256 dRFromJet=cms.int32(-1),
0257 LaplacianS1=cms.int32(-1),
0258 LaplacianS2=cms.int32(-1),
0259 LaplacianS3=cms.int32(-1),
0260 HessianS2=cms.int32(-1),
0261 HessianS4=cms.int32(-1),
0262 HessianS6=cms.int32(-1),
0263 nConstituents=cms.int32(-1),
0264 aveConstituentPt=cms.int32(-1),
0265 logAveConstituentPt=cms.int32(-1),
0266 constituentPtDistribution=cms.int32(-1),
0267 constituentEtaPhiSpread=cms.int32(-1),
0268 chargedHadronEnergyFraction=cms.int32(-1),
0269 neutralHadronEnergyFraction=cms.int32(-1),
0270 photonEnergyFraction=cms.int32(-1),
0271 electronEnergyFraction=cms.int32(-1),
0272 muonEnergyFraction=cms.int32(-1),
0273 HFHadronEnergyFraction=cms.int32(-1),
0274 HFEMEnergyFraction=cms.int32(-1),
0275 chargedHadronMultiplicity=cms.int32(-1),
0276 neutralHadronMultiplicity=cms.int32(-1),
0277 photonMultiplicity=cms.int32(-1),
0278 electronMultiplicity=cms.int32(-1),
0279 muonMultiplicity=cms.int32(-1),
0280 HFHadronMultiplicity=cms.int32(-1),
0281 HFEMMultiplicity=cms.int32(-1),
0282 chargedEmEnergyFraction=cms.int32(-1),
0283 chargedMuEnergyFraction=cms.int32(-1),
0284 neutralEmEnergyFraction=cms.int32(-1),
0285 EmEnergyFraction=cms.int32(-1),
0286 chargedMultiplicity=cms.int32(-1),
0287 neutralMultiplicity=cms.int32(-1)
0288 )
0289 for i, varname in enumerate(variables):
0290 setattr(subclass, varname, cms.int32(i))
0291 return subclass
0292
0293
0294
0295
0296
0297
0298 def configure_fftjet_pooldbessource(process, sequenceTag):
0299 config = cms.ESSource(
0300 "PoolDBESSource",
0301 process.CondDBCommon,
0302 toGet = cms.VPSet(cms.PSet(
0303 record = cms.string(fftjet_corr_types[sequenceTag].dbRecord),
0304 tag = cms.string(fftjet_corr_types[sequenceTag].dbTag),
0305 ))
0306 )
0307 sourceName = "FFT" + sequenceTag + "DBESSource"
0308 setattr(process, sourceName, config)
0309 return