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