Function executing the algorithm.
42 {
43
44
45
46 std::unique_ptr<jFEXDBCondData> writeDBTool(std::make_unique<jFEXDBCondData>() );
47
48
50 if (writeCHandle.isValid()) {
52 return StatusCode::SUCCESS;
53 }
54
55
56
57 bool validTimeStamp = (ctx.eventID().time_stamp() <
m_dbBeginTimestamp) ? false :
true;
59 validTimeStamp = true;
60
61
63
64 bool useDBparams = (!anyKeyEmpty && validTimeStamp);
65
66
67
68
69
70
71 std::vector<std::vector<int>> jJCalibParams(6, std::vector<int>(25, 0));
72
75
76
77 if (load_jFexModuleSet.
isValid() and load_jFexModuleSet->size() == 6) {
78
79
80 writeCHandle.addDependency(load_jFexModuleSet);
81
83 for (auto itr = load_jFexModuleSet->begin(); itr != load_jFexModuleSet->end(); ++itr) {
84
86 const std::string
s((
char*)
blob.startingAddress(),
blob.size());
87 nlohmann::json attrList = nlohmann::json::parse(s);
88
89 if(attrList["JetCalib"] == nullptr) {
91 return StatusCode::FAILURE;
92 }
93
94 const std::vector<int> v_tmp(attrList["JetCalib"]);
95 if ( not(v_tmp.size() == 9 || v_tmp.size() == 8 || v_tmp.size() == 25 ) ){
97 return StatusCode::FAILURE;
98 }
99
100 jJCalibParams[
mod] = std::move(v_tmp);
102 }
103
104 }
105 else{
107 return StatusCode::FAILURE;
108 }
109 }
110 else{
111
112
113 for(unsigned int fex=0; fex<6; fex++){
116 }
117 }
118 }
119
120 writeDBTool->set_jJCalibParam(jJCalibParams);
121
122
123
124
125
126
127
128
129
142
143
146
147 const std::vector<std::string> myStrings{ "PileUpCorrectionJet", "PileUpCorrectionMET", "PileUpThresholdLowEm", "PileUpThresholdHighEm", "PileUpThresholdLowHadLar", "PileUpThresholdHighHadLar", "PileUpThresholdLowHadHecOverlap", "PileUpThresholdHighHadHecOverlap", "PileUpThresholdLowHadTrex", "PileUpThresholdHighHadTrex", "PileUpThresholdLowFcal", "PileUpThresholdHighFcal" };
148
149 if (load_SystemSet.
isValid()) {
150
151
152 writeCHandle.addDependency(load_SystemSet);
153
154 for (auto itr = load_SystemSet->begin(); itr != load_SystemSet->end(); ++itr) {
155
157 const std::string
s((
char*)
blob.startingAddress(),
blob.size());
158 nlohmann::json attrList = nlohmann::json::parse(s);
159
160
161 bool allitemsPresent = true;
162 for(const auto & name:myStrings ) {
163 allitemsPresent = allitemsPresent && attrList.contains(name);
164 }
165 if(allitemsPresent) {
166 PileUpCorrectionJet = (
bool) attrList[myStrings.at( 0)];
167 PileUpCorrectionMET = (
bool) attrList[myStrings.at( 1)];
168 PileUpThresholdLowEm = (
int) attrList[myStrings.at( 2)];
169 PileUpThresholdHighEm = (
int) attrList[myStrings.at( 3)];
170 PileUpThresholdLowHadLar = (
int) attrList[myStrings.at( 4)];
171 PileUpThresholdHighHadLar = (
int) attrList[myStrings.at( 5)];
172 PileUpThresholdLowHadHecOverlap = (
int) attrList[myStrings.at( 6)];
173 PileUpThresholdHighHadHecOverlap = (
int) attrList[myStrings.at( 7)];
174 PileUpThresholdLowHadTrex = (
int) attrList[myStrings.at( 8)];
175 PileUpThresholdHighHadTrex = (
int) attrList[myStrings.at( 9)];
176 PileUpThresholdLowFcal = (
int) attrList[myStrings.at(10)];
177 PileUpThresholdHighFcal = (
int) attrList[myStrings.at(11)];
178 }
179 else {
180 ATH_MSG_DEBUG(
"Loading Pileup values for jFEX ID A:"<<itr->first <<
". Some towers are not used anymore. Skipping");
181 }
182 }
183 }
184 else {
186 return StatusCode::FAILURE;
187 }
188 }
189
190 writeDBTool->set_doPileUpJet(PileUpCorrectionJet);
191 writeDBTool->set_doPileUpMet(PileUpCorrectionMET);
192 writeDBTool->set_PUThrLowEm(PileUpThresholdLowEm);
193 writeDBTool->set_PUThrHighEm(PileUpThresholdHighEm);
194 writeDBTool->set_PUThrLowHadLar(PileUpThresholdLowHadLar);
195 writeDBTool->set_PUThrHighHadLar(PileUpThresholdHighHadLar);
196 writeDBTool->set_PUThrLowHadHecOverlap(PileUpThresholdLowHadHecOverlap);
197 writeDBTool->set_PUThrHighHadHecOverlap(PileUpThresholdHighHadHecOverlap);
198 writeDBTool->set_PUThrLowHadTrex(PileUpThresholdLowHadTrex);
199 writeDBTool->set_PUThrHighHadTrex(PileUpThresholdHighHadTrex);
200 writeDBTool->set_PUThrLowFcal(PileUpThresholdLowFcal);
201 writeDBTool->set_PUThrHighFcal(PileUpThresholdHighFcal);
202
203
204
205
206
207
208
209
210
211 std::unordered_map< uint16_t, std::array<uint16_t,4> > NoiseCuts;
212
213
214
215 std::unordered_map< uint16_t, std::array<uint16_t,4> > PileUpWeight;
216
217
219
220 SG::ReadCondHandle <CondAttrListCollection> load_jFexNoiseCut{
m_JfexNoiseCutsKey, ctx };
221
222 std::vector<std::string> myStringsNoise;
223
224 if (PileUpCorrectionJet == 0 and PileUpCorrectionMET == 0)
225 myStringsNoise = { "CutJetEM", "CutJetHad", "CutMetEM", "CutMetHad" };
226 else if (PileUpCorrectionJet == 1 and PileUpCorrectionMET == 0)
227 myStringsNoise = { "CutJetPUEM", "CutJetPUHad", "CutMetEM", "CutMetHad" };
228 else if (PileUpCorrectionJet == 0 and PileUpCorrectionMET == 1)
229 myStringsNoise = { "CutJetEM", "CutJetHad", "CutMetPUEM", "CutMetPUHad" };
230 else
231 myStringsNoise = { "CutJetPUEM", "CutJetPUHad", "CutMetPUEM", "CutMetPUHad" };
232
233 const std::vector<std::string> myStringsPileup{ "PileUpWeightEM", "PileUpWeightHad", "InverseWeightEM", "InverseWeightHad" };
234
235
236 if (load_jFexNoiseCut.
isValid()) {
237
238
239 writeCHandle.addDependency(load_jFexNoiseCut);
240
241 writeDBTool->set_sendDefaults(false);
242
243 for (auto itr = load_jFexNoiseCut->begin(); itr != load_jFexNoiseCut->end(); ++itr) {
244
246 const std::string
s((
char*)
blob.startingAddress(),
blob.size());
247 nlohmann::json attrList = nlohmann::json::parse(s);
248
249
250
251 bool allitemsPresent = true;
252 for(const auto & name:myStringsNoise ) {
253 allitemsPresent = allitemsPresent && attrList.contains(name);
254 }
255
256 if( allitemsPresent ) {
257 NoiseCuts[ (
uint16_t) itr->first ]= { {(uint16_t) attrList[myStringsNoise.at(0)],(
uint16_t) attrList[myStringsNoise.at(1)],(
uint16_t) attrList[myStringsNoise.at(2)],(
uint16_t) attrList[myStringsNoise.at(3)]} };
258 }
259 else {
260 ATH_MSG_DEBUG(
"Loading Pileup values for jFEX ID B:"<<itr->first <<
". Some towers are not used anymore. Skipping");
261 NoiseCuts[ (
uint16_t) itr->first ] = {0, 0, 0, 0};
262 }
263
264
265 allitemsPresent = true;
266 for(const auto & name:myStringsPileup ) {
267 allitemsPresent = allitemsPresent && attrList.contains(name);
268 }
269
270 if( allitemsPresent ) {
271 PileUpWeight[ (
uint16_t) itr->first ]= { {(uint16_t) attrList[myStringsPileup.at(0)],(
uint16_t) attrList[myStringsPileup.at(1)],(
uint16_t) attrList[myStringsPileup.at(2)],(
uint16_t) attrList[myStringsPileup.at(3)]} };
272 }
273 else {
274 ATH_MSG_DEBUG(
"Loading Pileup values for jFEX ID C:"<<itr->first <<
". Some towers are not used anymore. Skipping");
275 PileUpWeight[ (
uint16_t) itr->first ] = {0, 0, 0, 0};
276 }
277 }
278
279 }
280 else {
282 return StatusCode::FAILURE;
283 }
284 }
285 else{
290
295 }
296
297
298 writeDBTool->set_NoiseCuts(NoiseCuts);
299 writeDBTool->set_PileUpValues(PileUpWeight);
300
302
303 std::stringstream myprint;
304 if (useDBparams)
306 else
307 myprint << "JfexModuleSettings obtained from jDBdefaults"<< std::endl;
308 myprint << "jJCalibParam:" << std::endl;
309
310 for(
int mod=0;
mod<6;
mod++) {
311 myprint <<
"jFEX"<<
mod<<
" - ";
313 myprint << writeDBTool->get_jJCalibParam(mod,range)<< " ";
314 }
315 myprint << std::endl;
316 }
317 myprint << std::endl;
318
320
321
322 std::stringstream myprint1;
323
324 if (useDBparams)
326 else
327 myprint1 << "JfexSystemSettings obtained from jDBdefaults"<< std::endl;
328
329 myprint1 << "System setting parameters: " <<std::endl;
330 myprint1 << "PileUpCorrectionJet: " << writeDBTool->get_doPileUpJet() <<std::endl;
331 myprint1 << "PileUpCorrectionMET: " << writeDBTool->get_doPileUpMet() <<std::endl;
332 myprint1 << "PileUpThresholdLowEm: " << writeDBTool->get_PUThrLowEm() <<std::endl;
333 myprint1 << "PileUpThresholdHighEm: " << writeDBTool->get_PUThrHighEm() <<std::endl;
334 myprint1 << "PileUpThresholdLowHadLar: " << writeDBTool->get_PUThrLowHadLar() <<std::endl;
335 myprint1 << "PileUpThresholdHighHadLar: " << writeDBTool->get_PUThrHighHadLar() <<std::endl;
336 myprint1 << "PileUpThresholdLowHadHecOverlap: " << writeDBTool->get_PUThrLowHadHecOverlap() <<std::endl;
337 myprint1 << "PileUpThresholdHighHadHecOverlap: "<< writeDBTool->get_PUThrHighHadHecOverlap()<<std::endl;
338 myprint1 << "PileUpThresholdLowHadTrex: " << writeDBTool->get_PUThrLowHadTrex() <<std::endl;
339 myprint1 << "PileUpThresholdHighHadTrex: " << writeDBTool->get_PUThrHighHadTrex() <<std::endl;
340 myprint1 << "PileUpThresholdLowFcal: " << writeDBTool->get_PUThrLowFcal() <<std::endl;
341 myprint1 << "PileUpThresholdHighFcal: " << writeDBTool->get_PUThrHighFcal() <<std::endl;
342
344
345 std::stringstream myprint2;
346
347 if (useDBparams)
348 myprint2 <<
"Parameters obtained from m_JfexNoiseCutsKey: "<<
m_JfexNoiseCutsKey << std::endl;
349 else
350 myprint2 << "JfexNoiseCuts obtained from jDBdefaults"<< std::endl;
351
352 for( const auto& [key, value] : NoiseCuts) {
353 const auto [CutJetEM, CutJetHad, CutMetEM, CutMetHad] =
value;
354 const auto [PileUpWeightEM, PileUpWeightHad, InverseWeightEM, InverseWeightHad] = PileUpWeight[
key];
355
356 myprint2 <<
"OnlineID: 0x"<< std::hex<<
key<<std::dec<<
" - CutJetEM: "<< CutJetEM<<
", CutJetHad:"<< CutJetHad<<
", CutMetEM:"<< CutMetEM<<
", CutMetHad:"<< CutMetHad<<
", PileUpWeightEM: "<< PileUpWeightEM<<
", PileUpWeightHad:"<< PileUpWeightHad<<
", InverseWeightEM:"<< InverseWeightEM<<
", InverseWeightHad:"<< InverseWeightHad<< std::endl;
357 }
358
360
361 }
362
363
364
365
366 if (!useDBparams) {
368 }
369
370
371 if (writeCHandle.record(std::move(writeDBTool)).isFailure()) {
372 ATH_MSG_ERROR(
"Could not record " << writeCHandle.key() <<
" with EventRange " << writeCHandle.getRange() <<
" into Conditions Store");
373 return StatusCode::FAILURE;
374 }
375 ATH_MSG_INFO(
"Recorded " << writeCHandle.key() <<
" with EventRange " << writeCHandle.getRange() <<
" into Conditions Store");
376
377 return StatusCode::SUCCESS;
378
379}
char data[hepevt_bytes_allocation_ATLAS]
bool msgLvl(const MSG::Level lvl) const
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
SG::ReadCondHandleKey< CondAttrListCollection > m_JfexNoiseCutsKey
SG::ReadCondHandleKey< CondAttrListCollection > m_JfexSystemSettingsKey
SG::WriteCondHandleKey< jFEXDBCondData > m_jFEXDBParamsKey
Gaudi::Property< bool > m_isMC
UnsignedIntegerProperty m_dbBeginTimestamp
SG::ReadCondHandleKey< CondAttrListCollection > m_JfexModuleSettingsKey
static constexpr int PileUpThresholdHighHadLar
static constexpr int PileUpThresholdHighEm
static constexpr std::array< uint16_t, 4 > NoiseCuts_LATOME_HEC
static constexpr bool PileUpCorrectionJet
static constexpr int PileUpThresholdLowFcal
static constexpr int PileUpThresholdLowHadTrex
static constexpr int PileUpThresholdLowHadHecOverlap
static constexpr std::array< uint16_t, 4 > NoiseCuts_FCAL
static constexpr std::array< uint16_t, 4 > PileUpWeight_default
static constexpr std::array< uint16_t, 4 > NoiseCuts_LATOME_TILE
static constexpr int PileUpThresholdHighHadTrex
static constexpr int PileUpThresholdHighFcal
static constexpr int PileUpThresholdLowEm
static constexpr int jJCalibParams[6][25]
static constexpr bool PileUpCorrectionMET
static constexpr int PileUpThresholdLowHadLar
static constexpr int PileUpThresholdHighHadHecOverlap
setBGCode setTAP setLVL2ErrorBits bool