File indexing completed on 2024-04-06 12:31:10
0001 import FWCore.ParameterSet.Config as cms
0002
0003
0004 def getHcalDigitizer(process):
0005 if hasattr(process,'mixData'):
0006 return process.mixData
0007 if hasattr(process,'mix') and hasattr(process.mix,'digitizers') and hasattr(process.mix.digitizers,'hcal'):
0008 return process.mix.digitizers.hcal
0009 return None
0010
0011 def getHGCalDigitizer(process,section):
0012 if hasattr(process,'mix') and hasattr(process.mix,'digitizers'):
0013 if section == 'EE' and hasattr(process.mix.digitizers,'hgceeDigitizer'):
0014 return process.mix.digitizers.hgceeDigitizer
0015 elif section == 'FH' and hasattr(process.mix.digitizers,'hgchefrontDigitizer'):
0016 return process.mix.digitizers.hgchefrontDigitizer
0017 elif section == 'BH' and hasattr(process.mix.digitizers,'hgchebackDigitizer'):
0018 return process.mix.digitizers.hgchebackDigitizer
0019 elif section == 'HFNose' and hasattr(process.mix.digitizers,'hfnoseDigitizer'):
0020 return process.mix.digitizers.hfnoseDigitizer
0021 return None
0022
0023
0024 def setScenarioHLLHC(module,scenarioHLLHC):
0025 if scenarioHLLHC=="nominal":
0026 from CalibCalorimetry.HcalPlugins.HBHEDarkening_cff import _years_LHC, _years_HLLHC_nominal
0027 module.years = _years_LHC + _years_HLLHC_nominal
0028 elif scenarioHLLHC=="ultimate":
0029 from CalibCalorimetry.HcalPlugins.HBHEDarkening_cff import _years_LHC, _years_HLLHC_ultimate
0030 module.years = _years_LHC + _years_HLLHC_ultimate
0031 return module
0032
0033
0034
0035 def ageHB(process,turnon,scenarioHLLHC):
0036 if turnon:
0037 from CalibCalorimetry.HcalPlugins.HBHEDarkening_cff import HBDarkeningEP
0038 process.HBDarkeningEP = HBDarkeningEP
0039 process.HBDarkeningEP = setScenarioHLLHC(process.HBDarkeningEP,scenarioHLLHC)
0040 hcaldigi = getHcalDigitizer(process)
0041 if hcaldigi is not None: hcaldigi.HBDarkening = cms.bool(turnon)
0042 if hasattr(process,'es_hardcode'):
0043 process.es_hardcode.HBRecalibration = cms.bool(turnon)
0044 return process
0045
0046 def ageHE(process,turnon,scenarioHLLHC):
0047 if turnon:
0048 from CalibCalorimetry.HcalPlugins.HBHEDarkening_cff import HEDarkeningEP
0049 process.HEDarkeningEP = HEDarkeningEP
0050 process.HEDarkeningEP = setScenarioHLLHC(process.HEDarkeningEP,scenarioHLLHC)
0051 hcaldigi = getHcalDigitizer(process)
0052 if hcaldigi is not None: hcaldigi.HEDarkening = cms.bool(turnon)
0053 if hasattr(process,'es_hardcode'):
0054 process.es_hardcode.HERecalibration = cms.bool(turnon)
0055 return process
0056
0057 def ageHF(process,turnon):
0058 hcaldigi = getHcalDigitizer(process)
0059 if hcaldigi is not None: hcaldigi.HFDarkening = cms.bool(turnon)
0060 if hasattr(process,'es_hardcode'):
0061 process.es_hardcode.HFRecalibration = cms.bool(turnon)
0062 return process
0063
0064 def agedHFNose(process,algo=0):
0065 from SimCalorimetry.HGCalSimProducers.hgcalDigitizer_cfi import HFNose_setEndOfLifeNoise
0066 process = HFNose_setEndOfLifeNoise(process,byDose=True,byDoseAlgo=algo)
0067 return process
0068
0069 def agedHGCal(process,algo=0):
0070 from SimCalorimetry.HGCalSimProducers.hgcalDigitizer_cfi import HGCal_setEndOfLifeNoise
0071 process = HGCal_setEndOfLifeNoise(process,byDose=True,byDoseAlgo=algo)
0072 return process
0073
0074 def realisticHGCalStartup(process):
0075 from SimCalorimetry.HGCalSimProducers.hgcalDigitizer_cfi import HGCal_setRealisticStartupNoise
0076 process = HGCal_setRealisticStartupNoise(process)
0077 return process
0078
0079
0080 def ageSiPM(process,turnon,lumi):
0081 process.es_hardcode.hbUpgrade.doRadiationDamage = turnon
0082 process.es_hardcode.heUpgrade.doRadiationDamage = turnon
0083
0084
0085
0086
0087
0088 hcal_lumis = [300, 1000, 3000, 4500, 1e10]
0089 hcal_thresholds = {
0090 300: {
0091 "seed": [0.5, 0.625, 0.75, 0.75],
0092 "rec": [0.4, 0.5, 0.6, 0.6],
0093 },
0094 1000: {
0095 "seed": [1.0, 1.5, 1.5, 1.5],
0096 "rec": [0.8, 1.2, 1.2, 1.2],
0097 },
0098 3000: {
0099 "seed": [1.25, 2.5, 2.5, 2.5],
0100 "rec": [1.0, 2.0, 2.0, 2.0],
0101 },
0102 4500: {
0103 "seed": [1.5, 3.0, 3.0, 3.0],
0104 "rec": [1.25, 2.5, 2.5, 2.5],
0105 },
0106 }
0107 ctmodules = ['calotowermaker','caloTowerForTrk','caloTowerForTrkPreSplitting','towerMaker','towerMakerWithHO']
0108 for ilumi, hcal_lumi in enumerate(hcal_lumis[:-1]):
0109 if lumi >= hcal_lumi and lumi < hcal_lumis[ilumi+1]:
0110 if hasattr(process,'particleFlowClusterHBHE'):
0111 process.particleFlowClusterHBHE.seedFinder.thresholdsByDetector[0].seedingThreshold = hcal_thresholds[hcal_lumi]["seed"]
0112 process.particleFlowClusterHBHE.initialClusteringStep.thresholdsByDetector[0].gatheringThreshold = hcal_thresholds[hcal_lumi]["rec"]
0113 process.particleFlowClusterHBHE.pfClusterBuilder.recHitEnergyNorms[0].recHitEnergyNorm = hcal_thresholds[hcal_lumi]["rec"]
0114 process.particleFlowClusterHBHE.pfClusterBuilder.positionCalc.logWeightDenominatorByDetector[0].logWeightDenominator = hcal_thresholds[hcal_lumi]["rec"]
0115 process.particleFlowClusterHBHE.pfClusterBuilder.allCellsPositionCalc.logWeightDenominatorByDetector[0].logWeightDenominator = hcal_thresholds[hcal_lumi]["rec"]
0116 if hasattr(process,'particleFlowClusterHCAL'):
0117 process.particleFlowClusterHCAL.pfClusterBuilder.allCellsPositionCalc.logWeightDenominatorByDetector[0].logWeightDenominator = hcal_thresholds[hcal_lumi]["rec"]
0118 if hasattr(process,'particleFlowRecHitHBHE'):
0119 process.particleFlowRecHitHBHE.producers[0].qualityTests[0].cuts[0].threshold = hcal_thresholds[hcal_lumi]["rec"]
0120 for ctmod in ctmodules:
0121 if hasattr(process,ctmod):
0122 getattr(process,ctmod).HBThreshold1 = hcal_thresholds[hcal_lumi]["rec"][0]
0123 getattr(process,ctmod).HBThreshold2 = hcal_thresholds[hcal_lumi]["rec"][1]
0124 getattr(process,ctmod).HBThreshold = hcal_thresholds[hcal_lumi]["rec"][-1]
0125 break
0126
0127 return process
0128
0129 def ageHcal(process,lumi,instLumi,scenarioHLLHC):
0130 hcaldigi = getHcalDigitizer(process)
0131 if hcaldigi is not None: hcaldigi.DelivLuminosity = cms.double(float(lumi))
0132
0133
0134 if hasattr(process,'g4SimHits'):
0135 process.g4SimHits.HCalSD.InstLuminosity = cms.double(float(instLumi))
0136 process.g4SimHits.HCalSD.DelivLuminosity = cms.double(float(lumi))
0137
0138
0139 if hasattr(process,'es_hardcode'):
0140 process.es_hardcode.iLumi = cms.double(float(lumi))
0141
0142
0143 process = ageHB(process,True,scenarioHLLHC)
0144 process = ageHE(process,True,scenarioHLLHC)
0145 process = ageHF(process,True)
0146 process = ageSiPM(process,True,lumi)
0147
0148 return process
0149
0150 def turn_on_HB_aging(process):
0151 process = ageHB(process,True,"")
0152 return process
0153
0154 def turn_off_HB_aging(process):
0155 process = ageHB(process,False,"")
0156 return process
0157
0158 def turn_on_HE_aging(process):
0159 process = ageHE(process,True,"")
0160 return process
0161
0162 def turn_off_HE_aging(process):
0163 process = ageHE(process,False,"")
0164 return process
0165
0166 def turn_on_HF_aging(process):
0167 process = ageHF(process,True)
0168 return process
0169
0170 def turn_off_HF_aging(process):
0171 process = ageHF(process,False)
0172 return process
0173
0174 def turn_off_SiPM_aging(process):
0175 process = ageSiPM(process,False,0.0)
0176 return process
0177
0178 def hf_complete_aging(process):
0179 if hasattr(process,'g4SimHits'):
0180 process.g4SimHits.HCalSD.HFDarkening = cms.untracked.bool(True)
0181 hcaldigi = getHcalDigitizer(process)
0182 if hcaldigi is not None: hcaldigi.HFDarkening = cms.untracked.bool(False)
0183 return process
0184
0185 def ageEcal(process,lumi,instLumi):
0186 if hasattr(process,'g4SimHits'):
0187
0188 process.g4SimHits.ECalSD.InstLuminosity = cms.double(instLumi)
0189 process.g4SimHits.ECalSD.DelivLuminosity = cms.double(float(lumi))
0190
0191
0192 ecal_lumis = [300,1000,3000,4500]
0193 ecal_conditions = [
0194 ['EcalIntercalibConstantsRcd','EcalIntercalibConstants_TL{:d}_upgrade_8deg_v2_mc'],
0195 ['EcalIntercalibConstantsMCRcd','EcalIntercalibConstantsMC_TL{:d}_upgrade_8deg_v2_mc'],
0196 ['EcalLaserAPDPNRatiosRcd','EcalLaserAPDPNRatios_TL{:d}_upgrade_8deg_mc'],
0197 ['EcalPedestalsRcd','EcalPedestals_TL{:d}_upgradeTIA_8deg_mc'],
0198 ['EcalTPGLinearizationConstRcd','EcalTPGLinearizationConst_TL{:d}_upgrade_8deg_mc'],
0199 ]
0200
0201
0202 ecal_thresholds = {
0203 300 : 0.103,
0204 1000 : 0.175,
0205 3000 : 0.435,
0206 4500 : 0.707,
0207 }
0208 ecal_seed_multiplier = 2.5
0209
0210
0211 if int(lumi) in ecal_lumis:
0212 if not hasattr(process.GlobalTag,'toGet'):
0213 process.GlobalTag.toGet=cms.VPSet()
0214 for ecal_condition in ecal_conditions:
0215 process.GlobalTag.toGet.append(cms.PSet(
0216 record = cms.string(ecal_condition[0]),
0217 tag = cms.string(ecal_condition[1].format(int(lumi))),
0218 connect = cms.string("frontier://FrontierProd/CMS_CONDITIONS")
0219 )
0220 )
0221 if hasattr(process,"particleFlowClusterECALUncorrected"):
0222 _seeds = process.particleFlowClusterECALUncorrected.seedFinder.thresholdsByDetector
0223 for iseed in range(0,len(_seeds)):
0224 if _seeds[iseed].detector.value()=="ECAL_BARREL":
0225 _seeds[iseed].seedingThreshold = cms.double(ecal_thresholds[int(lumi)]*ecal_seed_multiplier)
0226 _clusters = process.particleFlowClusterECALUncorrected.initialClusteringStep.thresholdsByDetector
0227 for icluster in range(0,len(_clusters)):
0228 if _clusters[icluster].detector.value()=="ECAL_BARREL":
0229 _clusters[icluster].gatheringThreshold = cms.double(ecal_thresholds[int(lumi)])
0230
0231 return process
0232
0233 def ecal_complete_aging(process):
0234 if hasattr(process,'g4SimHits'):
0235 process.g4SimHits.ECalSD.AgeingWithSlopeLY = cms.untracked.bool(True)
0236 if hasattr(process,'ecal_digi_parameters'):
0237 process.ecal_digi_parameters.UseLCcorrection = cms.untracked.bool(False)
0238 return process
0239
0240 def customise_aging_300(process):
0241 process=ageHcal(process,300,5.0e34,"nominal")
0242 process=ageEcal(process,300,5.0e34)
0243 return process
0244
0245 def customise_aging_1000(process):
0246 process=ageHcal(process,1000,5.0e34,"nominal")
0247 process=turn_off_HE_aging(process)
0248 process=ageEcal(process,1000,5.0e34)
0249 return process
0250
0251 def customise_aging_3000(process):
0252 process=ageHcal(process,3000,5.0e34,"nominal")
0253 process=turn_off_HE_aging(process)
0254 process=ageEcal(process,3000,5.0e34)
0255 process=agedHGCal(process)
0256 process=agedHFNose(process)
0257 return process
0258
0259 def customise_aging_3000_ultimate(process):
0260 process=ageHcal(process,3000,7.5e34,"ultimate")
0261 process=turn_off_HE_aging(process)
0262 process=ageEcal(process,3000,7.5e34)
0263 process=agedHGCal(process)
0264 process=agedHFNose(process)
0265 return process
0266
0267 def customise_aging_4500_ultimate(process):
0268 process=ageHcal(process,4500,7.5e34,"ultimate")
0269 process=turn_off_HE_aging(process)
0270 process=ageEcal(process,4500,7.5e34)
0271 process=agedHGCal(process)
0272 process=agedHFNose(process)
0273 return process