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)
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  return process
77 
78 def ageHcal(process,lumi,instLumi,scenarioHLLHC):
79  hcaldigi = getHcalDigitizer(process)
80  if hcaldigi is not None: hcaldigi.DelivLuminosity = cms.double(float(lumi)) # integrated lumi in fb-1
81 
82  # these lines need to be further activated by turning on 'complete' aging for HF
83  if hasattr(process,'g4SimHits'):
84  process.g4SimHits.HCalSD.InstLuminosity = cms.double(float(instLumi))
85  process.g4SimHits.HCalSD.DelivLuminosity = cms.double(float(lumi))
86 
87  # recalibration and darkening always together
88  if hasattr(process,'es_hardcode'):
89  process.es_hardcode.iLumi = cms.double(float(lumi))
90 
91  # functions to enable individual subdet aging
92  process = ageHB(process,True,scenarioHLLHC)
93  process = ageHE(process,True,scenarioHLLHC)
94  process = ageHF(process,True)
95  process = ageSiPM(process,True,lumi)
96 
97  return process
98 
99 def turn_on_HB_aging(process):
100  process = ageHB(process,True,"")
101  return process
102 
103 def turn_off_HB_aging(process):
104  process = ageHB(process,False,"")
105  return process
106 
107 def turn_on_HE_aging(process):
108  process = ageHE(process,True,"")
109  return process
110 
111 def turn_off_HE_aging(process):
112  process = ageHE(process,False,"")
113  return process
114 
115 def turn_on_HF_aging(process):
116  process = ageHF(process,True)
117  return process
118 
119 def turn_off_HF_aging(process):
120  process = ageHF(process,False)
121  return process
122 
123 def turn_off_SiPM_aging(process):
124  process = ageSiPM(process,False,0.0)
125  return process
126 
127 def hf_complete_aging(process):
128  if hasattr(process,'g4SimHits'):
129  process.g4SimHits.HCalSD.HFDarkening = cms.untracked.bool(True)
130  hcaldigi = getHcalDigitizer(process)
131  if hcaldigi is not None: hcaldigi.HFDarkening = cms.untracked.bool(False)
132  return process
133 
134 def ageEcal(process,lumi,instLumi):
135  if hasattr(process,'g4SimHits'):
136  #these lines need to be further activiated by tuning on 'complete' aging for ecal
137  process.g4SimHits.ECalSD.InstLuminosity = cms.double(instLumi)
138  process.g4SimHits.ECalSD.DelivLuminosity = cms.double(float(lumi))
139 
140  # available conditions
141  ecal_lumis = [300,1000,3000,4500]
142  ecal_conditions = [
143  ['EcalIntercalibConstantsRcd','EcalIntercalibConstants_TL{:d}_upgrade_8deg_v2_mc'],
144  ['EcalIntercalibConstantsMCRcd','EcalIntercalibConstantsMC_TL{:d}_upgrade_8deg_v2_mc'],
145  ['EcalLaserAPDPNRatiosRcd','EcalLaserAPDPNRatios_TL{:d}_upgrade_8deg_mc'],
146  ['EcalPedestalsRcd','EcalPedestals_TL{:d}_upgradeTIA_8deg_mc'],
147  ['EcalTPGLinearizationConstRcd','EcalTPGLinearizationConst_TL{:d}_upgrade_8deg_mc'],
148  ]
149 
150  # update PF thresholds, based on https://indico.cern.ch/event/653123/contributions/2659235/attachments/1491385/2318364/170711_upsg_ledovskoy.pdf
151  ecal_thresholds = {
152  300 : 0.103,
153  1000 : 0.175,
154  3000 : 0.435,
155  4500 : 0.707,
156  }
157  ecal_seed_multiplier = 2.5
158 
159  # try to get conditions
160  if int(lumi) in ecal_lumis:
161  if not hasattr(process.GlobalTag,'toGet'):
162  process.GlobalTag.toGet=cms.VPSet()
163  for ecal_condition in ecal_conditions:
164  process.GlobalTag.toGet.append(cms.PSet(
165  record = cms.string(ecal_condition[0]),
166  tag = cms.string(ecal_condition[1].format(int(lumi))),
167  connect = cms.string("frontier://FrontierProd/CMS_CONDITIONS")
168  )
169  )
170  if hasattr(process,"particleFlowClusterECALUncorrected"):
171  _seeds = process.particleFlowClusterECALUncorrected.seedFinder.thresholdsByDetector
172  for iseed in range(0,len(_seeds)):
173  if _seeds[iseed].detector.value()=="ECAL_BARREL":
174  _seeds[iseed].seedingThreshold = cms.double(ecal_thresholds[int(lumi)]*ecal_seed_multiplier)
175  _clusters = process.particleFlowClusterECALUncorrected.initialClusteringStep.thresholdsByDetector
176  for icluster in range(0,len(_clusters)):
177  if _clusters[icluster].detector.value()=="ECAL_BARREL":
178  _clusters[icluster].gatheringThreshold = cms.double(ecal_thresholds[int(lumi)])
179 
180  return process
181 
182 def ecal_complete_aging(process):
183  if hasattr(process,'g4SimHits'):
184  process.g4SimHits.ECalSD.AgeingWithSlopeLY = cms.untracked.bool(True)
185  if hasattr(process,'ecal_digi_parameters'):
186  process.ecal_digi_parameters.UseLCcorrection = cms.untracked.bool(False)
187  return process
188 
189 def customise_aging_300(process):
190  process=ageHcal(process,300,5.0e34,"nominal")
191  process=ageEcal(process,300,5.0e34)
192  return process
193 
194 def customise_aging_1000(process):
195  process=ageHcal(process,1000,5.0e34,"nominal")
196  process=ageEcal(process,1000,5.0e34)
197  return process
198 
199 def customise_aging_3000(process):
200  process=ageHcal(process,3000,5.0e34,"nominal")
201  process=ageEcal(process,3000,5.0e34)
202  process=agedHGCal(process)
203  return process
204 
206  process=ageHcal(process,3000,7.5e34,"ultimate")
207  process=ageEcal(process,3000,7.5e34)
208  process=agedHGCal(process)
209  return process
210 
212  process=ageHcal(process,4500,7.5e34,"ultimate")
213  process=ageEcal(process,4500,7.5e34)
214  process=agedHGCal(process)
215  return process
def ageEcal(process, lumi, instLumi)
Definition: aging.py:134
def ageHB(process, turnon, scenarioHLLHC)
Definition: aging.py:33
def customise_aging_4500_ultimate(process)
Definition: aging.py:211
def turn_off_HE_aging(process)
Definition: aging.py:111
def getHGCalDigitizer(process, section)
Definition: aging.py:11
def getHcalDigitizer(process)
Definition: aging.py:4
def turn_off_HF_aging(process)
Definition: aging.py:119
def HGCal_setEndOfLifeNoise(digitizer)
def turn_on_HB_aging(process)
Definition: aging.py:99
def agedHGCal(process)
Definition: aging.py:62
def turn_off_SiPM_aging(process)
Definition: aging.py:123
def customise_aging_1000(process)
Definition: aging.py:194
def customise_aging_3000_ultimate(process)
Definition: aging.py:205
def setScenarioHLLHC(module, scenarioHLLHC)
Definition: aging.py:22
def customise_aging_300(process)
Definition: aging.py:189
def ageSiPM(process, turnon, lumi)
Definition: aging.py:70
def ecal_complete_aging(process)
Definition: aging.py:182
def turn_off_HB_aging(process)
Definition: aging.py:103
def hf_complete_aging(process)
Definition: aging.py:127
def ageHcal(process, lumi, instLumi, scenarioHLLHC)
Definition: aging.py:78
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:115
def customise_aging_3000(process)
Definition: aging.py:199
def turn_on_HE_aging(process)
Definition: aging.py:107