115def getJetCalibTool(jetdef, context, data_type, calibseq = "", rhoname = "", pvname = "PrimaryVertices", gscdepth = "auto"):
116
117 jetcollection = jetdef.basename
118
119
120 if data_type not in ['data','mc','afii']:
121 jetcaliblog.error("JetCalibConfig accepts data_type values: 'data', 'mc', 'afii'")
122 raise ValueError("Unsupported data_type provided: '{0}".format(data_type))
123
124 if jetcollection.endswith("Jets"):
125 jetcaliblog.error("Jet collection '{0}'should be specified w/o 'Jets' in the name.".format(jetcollection))
126 raise ValueError("Bad jet collection formatting in getJetCalibTool.")
127
128 jetcaliblog.debug("Preparing calibration for {0}, in context {1} on sample type {2}".format(jetcollection,context,data_type))
129
130 jetcontexts = calibcontexts[jetcollection]
131
132 if jetcollection == "AntiKt4EMTopo" and context == "T0":
133 if jetdef._cflags.GeoModel.Run >= LHCPeriod.Run4:
134 context = "HLLHC"
135
136 try:
137 configfile, calibarea, calibseq_def = jetcontexts[context]
138 _calibseq = calibseq if calibseq else calibseq_def
139
140
141
142
143 if _calibseq.endswith("Insitu"):
144 if data_type == 'data':
145 if jetcollection not in hasInSitu:
146 raise ValueError("In situ calibration does not exist for {0}, context {1}".format(jetcollection,context))
147 else:
148 raise ValueError("In situ calibration requested for MC on {0}, context {1}".format(jetcollection,context))
149 _configfile = configfile
150 if data_type == "afii" and jetcollection in af2configs.keys():
151 _configfile = af2configs[jetcollection]
152 _data_type = data_type
153
154
155
156 if context == "T0":
157 _data_type = "data"
158 _pvname = ""
159 if "Residual" in _calibseq or "GSC" in _calibseq and gscdepth!="EM3" or "LargeRDNN" in _calibseq:
160 _pvname = pvname
161
162 if context == "TrigHIUPC":
163 _pvname = pvname
164
165 _jetcollection = jetcollection
166 if "PFlow" in jetcollection and (context=="TrigSoftDrop" or context=="TrigHLTSoftDrop"):
167 _jetcollection = jetcollection.replace("EMPFlow","UFO")
168 if "_noElectrons" in jetcollection :
169 _jetcollection = _jetcollection.replace("_noElectrons","")
170 if "_noMuons" in jetcollection :
171 _jetcollection = _jetcollection.replace("_noMuons","")
172 if "_noLeptons" in jetcollection :
173 _jetcollection = _jetcollection.replace("_noLeptons","")
174 if "_inclMuons" in jetcollection :
175 _jetcollection = _jetcollection.replace("_inclMuons","")
176 if "_tauSeedEleRM" in jetcollection :
177 _jetcollection = _jetcollection.replace("_tauSeedEleRM","")
178
179 if "ByVertex" in jetcollection:
180 _jetcollection = jetcollection.replace("ByVertex","")
181 return defineJetCalibTool(_jetcollection, context, _configfile, calibarea, _calibseq, _data_type, rhoname, _pvname, gscdepth)
182 except KeyError as e:
183 jetcaliblog.error("Context '{0}' not found for jet collection '{1}'".format(context,jetcollection))
184 jetcaliblog.error("Options are '{0}".format(','.join(jetcontexts.keys())))
185 raise e
186 return None
187
188