CMS 3D CMS Logo

aging.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 # handle normal mixing or premixing
4 def getHcalDigitizer(process):
5  if hasattr(process,'mixData'):
6  return process.mixData
7  if hasattr(process,'mix') and hasattr(process.mix,'digitizers') and hasattr(process.mix.digitizers,'hcal'):
8  return process.mix.digitizers.hcal
9  return None
10 
11 def getHGCalDigitizer(process,section):
12  if hasattr(process,'mix') and hasattr(process.mix,'digitizers'):
13  if section == 'EE' and hasattr(process.mix.digitizers,'hgceeDigitizer'):
14  return process.mix.digitizers.hgceeDigitizer
15  elif section == 'FH' and hasattr(process.mix.digitizers,'hgchefrontDigitizer'):
16  return process.mix.digitizers.hgchefrontDigitizer
17  elif section == 'BH' and hasattr(process.mix.digitizers,'hgchebackDigitizer'):
18  return process.mix.digitizers.hgchebackDigitizer
19  return None
20 
21 # change assumptions about lumi rate
22 def setScenarioHLLHC(module,scenarioHLLHC):
23  if scenarioHLLHC=="nominal":
24  from CalibCalorimetry.HcalPlugins.HBHEDarkening_cff import _years_LHC, _years_HLLHC_nominal
25  module.years = _years_LHC + _years_HLLHC_nominal
26  elif scenarioHLLHC=="ultimate":
27  from CalibCalorimetry.HcalPlugins.HBHEDarkening_cff import _years_LHC, _years_HLLHC_ultimate
28  module.years = _years_LHC + _years_HLLHC_ultimate
29  return module
30 
31 # turnon = True enables default, False disables
32 # recalibration and darkening always together
33 def ageHB(process,turnon,scenarioHLLHC):
34  if turnon:
35  from CalibCalorimetry.HcalPlugins.HBHEDarkening_cff import HBDarkeningEP
36  process.HBDarkeningEP = HBDarkeningEP
37  process.HBDarkeningEP = setScenarioHLLHC(process.HBDarkeningEP,scenarioHLLHC)
38  hcaldigi = getHcalDigitizer(process)
39  if hcaldigi is not None: hcaldigi.HBDarkening = cms.bool(turnon)
40  if hasattr(process,'es_hardcode'):
41  process.es_hardcode.HBRecalibration = cms.bool(turnon)
42  return process
43 
44 def ageHE(process,turnon,scenarioHLLHC):
45  if turnon:
46  from CalibCalorimetry.HcalPlugins.HBHEDarkening_cff import HEDarkeningEP
47  process.HEDarkeningEP = HEDarkeningEP
48  process.HEDarkeningEP = setScenarioHLLHC(process.HEDarkeningEP,scenarioHLLHC)
49  hcaldigi = getHcalDigitizer(process)
50  if hcaldigi is not None: hcaldigi.HEDarkening = cms.bool(turnon)
51  if hasattr(process,'es_hardcode'):
52  process.es_hardcode.HERecalibration = cms.bool(turnon)
53  return process
54 
55 def ageHF(process,turnon):
56  hcaldigi = getHcalDigitizer(process)
57  if hcaldigi is not None: hcaldigi.HFDarkening = cms.bool(turnon)
58  if hasattr(process,'es_hardcode'):
59  process.es_hardcode.HFRecalibration = cms.bool(turnon)
60  return process
61 
62 def agedHGCal(process):
63  from SimCalorimetry.HGCalSimProducers.hgcalDigitizer_cfi import HGCal_setEndOfLifeNoise
64  process = HGCal_setEndOfLifeNoise(process)
65  return process
66 
67 # needs lumi to set proper ZS thresholds (tbd)
68 def ageSiPM(process,turnon,lumi):
69  process.es_hardcode.hbUpgrade.doRadiationDamage = turnon
70  process.es_hardcode.heUpgrade.doRadiationDamage = turnon
71 
72  # todo: determine ZS threshold adjustments
73 
74  # adjust PF thresholds for increased noise
75  # based on: https://baylor.box.com/s/w32ja75krcbxcycyifexu28dwlgrj7wg
76  hcal_lumis = [300, 1000, 3000, 4500, 1e10]
77  hcal_thresholds = {
78  300: {
79  "seed": [0.5, 0.625, 0.75, 0.75],
80  "rec": [0.4, 0.5, 0.6, 0.6],
81  },
82  1000: {
83  "seed": [1.0, 1.5, 1.5, 1.5],
84  "rec": [0.8, 1.2, 1.2, 1.2],
85  },
86  3000: {
87  "seed": [1.25, 2.5, 2.5, 2.5],
88  "rec": [1.0, 2.0, 2.0, 2.0],
89  },
90  4500: {
91  "seed": [1.5, 3.0, 3.0, 3.0],
92  "rec": [1.25, 2.5, 2.5, 2.5],
93  },
94  }
95  ctmodules = ['calotowermaker','caloTowerForTrk','caloTowerForTrkPreSplitting','towerMaker','towerMakerWithHO']
96  for ilumi, hcal_lumi in enumerate(hcal_lumis[:-1]):
97  if lumi >= hcal_lumi and lumi < hcal_lumis[ilumi+1]:
98  if hasattr(process,'particleFlowClusterHBHE'):
99  process.particleFlowClusterHBHE.seedFinder.thresholdsByDetector[0].seedingThreshold = hcal_thresholds[hcal_lumi]["seed"]
100  process.particleFlowClusterHBHE.initialClusteringStep.thresholdsByDetector[0].gatheringThreshold = hcal_thresholds[hcal_lumi]["rec"]
101  process.particleFlowClusterHBHE.pfClusterBuilder.recHitEnergyNorms[0].recHitEnergyNorm = hcal_thresholds[hcal_lumi]["rec"]
102  process.particleFlowClusterHBHE.pfClusterBuilder.positionCalc.logWeightDenominatorByDetector[0].logWeightDenominator = hcal_thresholds[hcal_lumi]["rec"]
103  process.particleFlowClusterHBHE.pfClusterBuilder.allCellsPositionCalc.logWeightDenominatorByDetector[0].logWeightDenominator = hcal_thresholds[hcal_lumi]["rec"]
104  if hasattr(process,'particleFlowClusterHCAL'):
105  process.particleFlowClusterHCAL.pfClusterBuilder.allCellsPositionCalc.logWeightDenominatorByDetector[0].logWeightDenominator = hcal_thresholds[hcal_lumi]["rec"]
106  if hasattr(process,'particleFlowRecHitHBHE'):
107  process.particleFlowRecHitHBHE.producers[0].qualityTests[0].cuts[0].threshold = hcal_thresholds[hcal_lumi]["rec"]
108  for ctmod in ctmodules:
109  if hasattr(process,ctmod):
110  getattr(process,ctmod).HBThreshold1 = hcal_thresholds[hcal_lumi]["rec"][0]
111  getattr(process,ctmod).HBThreshold2 = hcal_thresholds[hcal_lumi]["rec"][1]
112  getattr(process,ctmod).HBThreshold = hcal_thresholds[hcal_lumi]["rec"][-1]
113  break
114 
115  return process
116 
117 def ageHcal(process,lumi,instLumi,scenarioHLLHC):
118  hcaldigi = getHcalDigitizer(process)
119  if hcaldigi is not None: hcaldigi.DelivLuminosity = cms.double(float(lumi)) # integrated lumi in fb-1
120 
121  # these lines need to be further activated by turning on 'complete' aging for HF
122  if hasattr(process,'g4SimHits'):
123  process.g4SimHits.HCalSD.InstLuminosity = cms.double(float(instLumi))
124  process.g4SimHits.HCalSD.DelivLuminosity = cms.double(float(lumi))
125 
126  # recalibration and darkening always together
127  if hasattr(process,'es_hardcode'):
128  process.es_hardcode.iLumi = cms.double(float(lumi))
129 
130  # functions to enable individual subdet aging
131  process = ageHB(process,True,scenarioHLLHC)
132  process = ageHE(process,True,scenarioHLLHC)
133  process = ageHF(process,True)
134  process = ageSiPM(process,True,lumi)
135 
136  return process
137 
138 def turn_on_HB_aging(process):
139  process = ageHB(process,True,"")
140  return process
141 
142 def turn_off_HB_aging(process):
143  process = ageHB(process,False,"")
144  return process
145 
146 def turn_on_HE_aging(process):
147  process = ageHE(process,True,"")
148  return process
149 
150 def turn_off_HE_aging(process):
151  process = ageHE(process,False,"")
152  return process
153 
154 def turn_on_HF_aging(process):
155  process = ageHF(process,True)
156  return process
157 
158 def turn_off_HF_aging(process):
159  process = ageHF(process,False)
160  return process
161 
162 def turn_off_SiPM_aging(process):
163  process = ageSiPM(process,False,0.0)
164  return process
165 
166 def hf_complete_aging(process):
167  if hasattr(process,'g4SimHits'):
168  process.g4SimHits.HCalSD.HFDarkening = cms.untracked.bool(True)
169  hcaldigi = getHcalDigitizer(process)
170  if hcaldigi is not None: hcaldigi.HFDarkening = cms.untracked.bool(False)
171  return process
172 
173 def ageEcal(process,lumi,instLumi):
174  if hasattr(process,'g4SimHits'):
175  #these lines need to be further activiated by tuning on 'complete' aging for ecal
176  process.g4SimHits.ECalSD.InstLuminosity = cms.double(instLumi)
177  process.g4SimHits.ECalSD.DelivLuminosity = cms.double(float(lumi))
178 
179  # available conditions
180  ecal_lumis = [300,1000,3000,4500]
181  ecal_conditions = [
182  ['EcalIntercalibConstantsRcd','EcalIntercalibConstants_TL{:d}_upgrade_8deg_v2_mc'],
183  ['EcalIntercalibConstantsMCRcd','EcalIntercalibConstantsMC_TL{:d}_upgrade_8deg_v2_mc'],
184  ['EcalLaserAPDPNRatiosRcd','EcalLaserAPDPNRatios_TL{:d}_upgrade_8deg_mc'],
185  ['EcalPedestalsRcd','EcalPedestals_TL{:d}_upgradeTIA_8deg_mc'],
186  ['EcalTPGLinearizationConstRcd','EcalTPGLinearizationConst_TL{:d}_upgrade_8deg_mc'],
187  ]
188 
189  # update PF thresholds, based on https://indico.cern.ch/event/653123/contributions/2659235/attachments/1491385/2318364/170711_upsg_ledovskoy.pdf
190  ecal_thresholds = {
191  300 : 0.103,
192  1000 : 0.175,
193  3000 : 0.435,
194  4500 : 0.707,
195  }
196  ecal_seed_multiplier = 2.5
197 
198  # try to get conditions
199  if int(lumi) in ecal_lumis:
200  if not hasattr(process.GlobalTag,'toGet'):
201  process.GlobalTag.toGet=cms.VPSet()
202  for ecal_condition in ecal_conditions:
203  process.GlobalTag.toGet.append(cms.PSet(
204  record = cms.string(ecal_condition[0]),
205  tag = cms.string(ecal_condition[1].format(int(lumi))),
206  connect = cms.string("frontier://FrontierProd/CMS_CONDITIONS")
207  )
208  )
209  if hasattr(process,"particleFlowClusterECALUncorrected"):
210  _seeds = process.particleFlowClusterECALUncorrected.seedFinder.thresholdsByDetector
211  for iseed in range(0,len(_seeds)):
212  if _seeds[iseed].detector.value()=="ECAL_BARREL":
213  _seeds[iseed].seedingThreshold = cms.double(ecal_thresholds[int(lumi)]*ecal_seed_multiplier)
214  _clusters = process.particleFlowClusterECALUncorrected.initialClusteringStep.thresholdsByDetector
215  for icluster in range(0,len(_clusters)):
216  if _clusters[icluster].detector.value()=="ECAL_BARREL":
217  _clusters[icluster].gatheringThreshold = cms.double(ecal_thresholds[int(lumi)])
218 
219  return process
220 
221 def ecal_complete_aging(process):
222  if hasattr(process,'g4SimHits'):
223  process.g4SimHits.ECalSD.AgeingWithSlopeLY = cms.untracked.bool(True)
224  if hasattr(process,'ecal_digi_parameters'):
225  process.ecal_digi_parameters.UseLCcorrection = cms.untracked.bool(False)
226  return process
227 
228 def customise_aging_300(process):
229  process=ageHcal(process,300,5.0e34,"nominal")
230  process=ageEcal(process,300,5.0e34)
231  return process
232 
233 def customise_aging_1000(process):
234  process=ageHcal(process,1000,5.0e34,"nominal")
235  process=ageEcal(process,1000,5.0e34)
236  return process
237 
238 def customise_aging_3000(process):
239  process=ageHcal(process,3000,5.0e34,"nominal")
240  process=ageEcal(process,3000,5.0e34)
241  process=agedHGCal(process)
242  return process
243 
245  process=ageHcal(process,3000,7.5e34,"ultimate")
246  process=ageEcal(process,3000,7.5e34)
247  process=agedHGCal(process)
248  return process
249 
251  process=ageHcal(process,4500,7.5e34,"ultimate")
252  process=ageEcal(process,4500,7.5e34)
253  process=agedHGCal(process)
254  return process
def ageEcal(process, lumi, instLumi)
Definition: aging.py:173
def ageHB(process, turnon, scenarioHLLHC)
Definition: aging.py:33
def customise_aging_4500_ultimate(process)
Definition: aging.py:250
def turn_off_HE_aging(process)
Definition: aging.py:150
def getHGCalDigitizer(process, section)
Definition: aging.py:11
def getHcalDigitizer(process)
Definition: aging.py:4
def turn_off_HF_aging(process)
Definition: aging.py:158
def turn_on_HB_aging(process)
Definition: aging.py:138
def agedHGCal(process)
Definition: aging.py:62
def turn_off_SiPM_aging(process)
Definition: aging.py:162
def customise_aging_1000(process)
Definition: aging.py:233
def customise_aging_3000_ultimate(process)
Definition: aging.py:244
def setScenarioHLLHC(module, scenarioHLLHC)
Definition: aging.py:22
def customise_aging_300(process)
Definition: aging.py:228
def ageSiPM(process, turnon, lumi)
Definition: aging.py:68
def ecal_complete_aging(process)
Definition: aging.py:221
def turn_off_HB_aging(process)
Definition: aging.py:142
def hf_complete_aging(process)
Definition: aging.py:166
def ageHcal(process, lumi, instLumi, scenarioHLLHC)
Definition: aging.py:117
def HGCal_setEndOfLifeNoise(process)
def ageHF(process, turnon)
Definition: aging.py:55
def ageHE(process, turnon, scenarioHLLHC)
Definition: aging.py:44
def turn_on_HF_aging(process)
Definition: aging.py:154
def customise_aging_3000(process)
Definition: aging.py:238
def turn_on_HE_aging(process)
Definition: aging.py:146