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