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