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 # change assumptions about lumi rate
12 def setScenarioHLLHC(module,scenarioHLLHC):
13  if scenarioHLLHC=="nominal":
14  from CalibCalorimetry.HcalPlugins.HBHEDarkening_cff import _years_LHC, _years_HLLHC_nominal
15  module.years = _years_LHC + _years_HLLHC_nominal
16  elif scenarioHLLHC=="ultimate":
17  from CalibCalorimetry.HcalPlugins.HBHEDarkening_cff import _years_LHC, _years_HLLHC_ultimate
18  module.years = _years_LHC + _years_HLLHC_ultimate
19  return module
20 
21 # turnon = True enables default, False disables
22 # recalibration and darkening always together
23 def ageHB(process,turnon,scenarioHLLHC):
24  if turnon:
25  from CalibCalorimetry.HcalPlugins.HBHEDarkening_cff import HBDarkeningEP
26  process.HBDarkeningEP = HBDarkeningEP
27  process.HBDarkeningEP = setScenarioHLLHC(process.HBDarkeningEP,scenarioHLLHC)
28  hcaldigi = getHcalDigitizer(process)
29  if hcaldigi is not None: hcaldigi.HBDarkening = cms.bool(turnon)
30  if hasattr(process,'es_hardcode'):
31  process.es_hardcode.HBRecalibration = cms.bool(turnon)
32  return process
33 
34 def ageHE(process,turnon,scenarioHLLHC):
35  if turnon:
36  from CalibCalorimetry.HcalPlugins.HBHEDarkening_cff import HEDarkeningEP
37  process.HEDarkeningEP = HEDarkeningEP
38  process.HEDarkeningEP = setScenarioHLLHC(process.HEDarkeningEP,scenarioHLLHC)
39  hcaldigi = getHcalDigitizer(process)
40  if hcaldigi is not None: hcaldigi.HEDarkening = cms.bool(turnon)
41  if hasattr(process,'es_hardcode'):
42  process.es_hardcode.HERecalibration = cms.bool(turnon)
43  return process
44 
45 def ageHF(process,turnon):
46  hcaldigi = getHcalDigitizer(process)
47  if hcaldigi is not None: hcaldigi.HFDarkening = cms.bool(turnon)
48  if hasattr(process,'es_hardcode'):
49  process.es_hardcode.HFRecalibration = cms.bool(turnon)
50  return process
51 
52 # needs lumi to set proper ZS thresholds (tbd)
53 def ageSiPM(process,turnon,lumi):
54  process.es_hardcode.hbUpgrade.doRadiationDamage = turnon
55  process.es_hardcode.heUpgrade.doRadiationDamage = turnon
56 
57  # todo: determine ZS threshold adjustments
58 
59  return process
60 
61 def ageHcal(process,lumi,instLumi,scenarioHLLHC):
62  hcaldigi = getHcalDigitizer(process)
63  if hcaldigi is not None: hcaldigi.DelivLuminosity = cms.double(float(lumi)) # integrated lumi in fb-1
64 
65  # these lines need to be further activated by turning on 'complete' aging for HF
66  if hasattr(process,'g4SimHits'):
67  process.g4SimHits.HCalSD.InstLuminosity = cms.double(float(instLumi))
68  process.g4SimHits.HCalSD.DelivLuminosity = cms.double(float(lumi))
69 
70  # recalibration and darkening always together
71  if hasattr(process,'es_hardcode'):
72  process.es_hardcode.iLumi = cms.double(float(lumi))
73 
74  # functions to enable individual subdet aging
75  process = ageHB(process,True,scenarioHLLHC)
76  process = ageHE(process,True,scenarioHLLHC)
77  process = ageHF(process,True)
78  process = ageSiPM(process,True,lumi)
79 
80  return process
81 
82 def turn_on_HB_aging(process):
83  process = ageHB(process,True,"")
84  return process
85 
86 def turn_off_HB_aging(process):
87  process = ageHB(process,False,"")
88  return process
89 
90 def turn_on_HE_aging(process):
91  process = ageHE(process,True,"")
92  return process
93 
94 def turn_off_HE_aging(process):
95  process = ageHE(process,False,"")
96  return process
97 
98 def turn_on_HF_aging(process):
99  process = ageHF(process,True)
100  return process
101 
102 def turn_off_HF_aging(process):
103  process = ageHF(process,False)
104  return process
105 
106 def turn_off_SiPM_aging(process):
107  process = ageSiPM(process,False,0.0)
108  return process
109 
110 def hf_complete_aging(process):
111  if hasattr(process,'g4SimHits'):
112  process.g4SimHits.HCalSD.HFDarkening = cms.untracked.bool(True)
113  hcaldigi = getHcalDigitizer(process)
114  if hcaldigi is not None: hcaldigi.HFDarkening = cms.untracked.bool(False)
115  return process
116 
117 def ageEcal(process,lumi,instLumi):
118  if hasattr(process,'g4SimHits'):
119  #these lines need to be further activiated by tuning on 'complete' aging for ecal
120  process.g4SimHits.ECalSD.InstLuminosity = cms.double(instLumi)
121  process.g4SimHits.ECalSD.DelivLuminosity = cms.double(float(lumi))
122 
123  # available conditions
124  ecal_lumis = [300,1000,3000,4500]
125  ecal_conditions = [
126  ['EcalIntercalibConstantsRcd','EcalIntercalibConstants_TL{:d}_upgrade_8deg_mc'],
127  ['EcalIntercalibConstantsMCRcd','EcalIntercalibConstantsMC_TL{:d}_upgrade_8deg_mc'],
128  ['EcalLaserAPDPNRatiosRcd','EcalLaserAPDPNRatios_TL{:d}_upgrade_8deg_mc'],
129  ['EcalPedestalsRcd','EcalPedestals_TL{:d}_upgradeTIA_8deg_mc'],
130  ['EcalTPGLinearizationConstRcd','EcalTPGLinearizationConst_TL{:d}_upgrade_8deg_mc'],
131  ]
132 
133  # try to get conditions
134  if int(lumi) in ecal_lumis:
135  if not hasattr(process.GlobalTag,'toGet'):
136  process.GlobalTag.toGet=cms.VPSet()
137  for ecal_condition in ecal_conditions:
138  process.GlobalTag.toGet.append(cms.PSet(
139  record = cms.string(ecal_condition[0]),
140  tag = cms.string(ecal_condition[1].format(int(lumi))),
141  connect = cms.string("frontier://FrontierProd/CMS_CONDITIONS")
142  )
143  )
144 
145  return process
146 
147 def ecal_complete_aging(process):
148  if hasattr(process,'g4SimHits'):
149  process.g4SimHits.ECalSD.AgeingWithSlopeLY = cms.untracked.bool(True)
150  if hasattr(process,'ecal_digi_parameters'):
151  process.ecal_digi_parameters.UseLCcorrection = cms.untracked.bool(False)
152  return process
153 
154 def customise_aging_300(process):
155  process=ageHcal(process,300,5.0e34,"nominal")
156  process=ageEcal(process,300,5.0e34)
157  return process
158 
159 def customise_aging_1000(process):
160  process=ageHcal(process,1000,5.0e34,"nominal")
161  process=ageEcal(process,1000,5.0e34)
162  return process
163 
164 def customise_aging_3000(process):
165  process=ageHcal(process,3000,5.0e34,"nominal")
166  process=ageEcal(process,3000,5.0e34)
167  return process
168 
170  process=ageHcal(process,3000,7.5e34,"ultimate")
171  process=ageEcal(process,3000,7.5e34)
172  return process
173 
175  process=ageHcal(process,4500,7.5e34,"ultimate")
176  process=ageEcal(process,4500,7.5e34)
177  return process
def ageEcal(process, lumi, instLumi)
Definition: aging.py:117
def ageHB(process, turnon, scenarioHLLHC)
Definition: aging.py:23
def customise_aging_4500_ultimate(process)
Definition: aging.py:174
def turn_off_HE_aging(process)
Definition: aging.py:94
def getHcalDigitizer(process)
Definition: aging.py:4
def turn_off_HF_aging(process)
Definition: aging.py:102
def turn_on_HB_aging(process)
Definition: aging.py:82
def turn_off_SiPM_aging(process)
Definition: aging.py:106
def customise_aging_1000(process)
Definition: aging.py:159
def customise_aging_3000_ultimate(process)
Definition: aging.py:169
def setScenarioHLLHC(module, scenarioHLLHC)
Definition: aging.py:12
def customise_aging_300(process)
Definition: aging.py:154
def ageSiPM(process, turnon, lumi)
Definition: aging.py:53
def ecal_complete_aging(process)
Definition: aging.py:147
def turn_off_HB_aging(process)
Definition: aging.py:86
def hf_complete_aging(process)
Definition: aging.py:110
def ageHcal(process, lumi, instLumi, scenarioHLLHC)
Definition: aging.py:61
def ageHF(process, turnon)
Definition: aging.py:45
def ageHE(process, turnon, scenarioHLLHC)
Definition: aging.py:34
def turn_on_HF_aging(process)
Definition: aging.py:98
def customise_aging_3000(process)
Definition: aging.py:164
def turn_on_HE_aging(process)
Definition: aging.py:90