Function executing the algorithm.
46 std::unique_ptr<jFEXDBCondData> writeDBTool(std::make_unique<jFEXDBCondData>() );
50 if (writeCHandle.isValid()) {
52 return StatusCode::SUCCESS;
57 bool validTimeStamp = (ctx.eventID().time_stamp() <
m_dbBeginTimestamp) ?
false :
true;
59 validTimeStamp =
true;
64 bool useDBparams = (!anyKeyEmpty && validTimeStamp);
71 std::vector<std::vector<int>> jJCalibParams(6, std::vector<int>(25, 0));
77 if (load_jFexModuleSet.isValid() and load_jFexModuleSet->size() == 6) {
80 writeCHandle.addDependency(load_jFexModuleSet);
83 for (
auto itr = load_jFexModuleSet->begin(); itr != load_jFexModuleSet->end(); ++itr) {
86 const std::string
s((
char*)
blob.startingAddress(),
blob.size());
89 if(attrList[
"JetCalib"] ==
nullptr) {
91 return StatusCode::FAILURE;
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;
100 jJCalibParams[
mod] = v_tmp;
107 return StatusCode::FAILURE;
113 for(
unsigned int fex=0; fex<6; fex++){
115 jJCalibParams[fex][
range] = jDBdefaults::jJCalibParams[fex][
range];
120 writeDBTool->set_jJCalibParam(jJCalibParams);
130 bool PileUpCorrectionJet = jDBdefaults::PileUpCorrectionJet;
131 bool PileUpCorrectionMET = jDBdefaults::PileUpCorrectionMET;
132 int PileUpThresholdLowEm = jDBdefaults::PileUpThresholdLowEm;
133 int PileUpThresholdHighEm = jDBdefaults::PileUpThresholdHighEm;
134 int PileUpThresholdLowHadLar = jDBdefaults::PileUpThresholdLowHadLar;
135 int PileUpThresholdHighHadLar = jDBdefaults::PileUpThresholdHighHadLar;
136 int PileUpThresholdLowHadHecOverlap = jDBdefaults::PileUpThresholdLowHadHecOverlap;
137 int PileUpThresholdHighHadHecOverlap = jDBdefaults::PileUpThresholdHighHadHecOverlap;
138 int PileUpThresholdLowHadTrex = jDBdefaults::PileUpThresholdLowHadTrex;
139 int PileUpThresholdHighHadTrex = jDBdefaults::PileUpThresholdHighHadTrex;
140 int PileUpThresholdLowFcal = jDBdefaults::PileUpThresholdLowFcal;
141 int PileUpThresholdHighFcal = jDBdefaults::PileUpThresholdHighFcal;
147 const std::vector<std::string> myStrings{
"PileUpCorrectionJet",
"PileUpCorrectionMET",
"PileUpThresholdLowEm",
"PileUpThresholdHighEm",
"PileUpThresholdLowHadLar",
"PileUpThresholdHighHadLar",
"PileUpThresholdLowHadHecOverlap",
"PileUpThresholdHighHadHecOverlap",
"PileUpThresholdLowHadTrex",
"PileUpThresholdHighHadTrex",
"PileUpThresholdLowFcal",
"PileUpThresholdHighFcal" };
149 if (load_SystemSet.isValid()) {
152 writeCHandle.addDependency(load_SystemSet);
154 for (
auto itr = load_SystemSet->begin(); itr != load_SystemSet->end(); ++itr) {
157 const std::string
s((
char*)
blob.startingAddress(),
blob.size());
163 bool allitemsPresent =
true;
164 for(
const auto &
name:myStrings ) {
165 allitemsPresent = allitemsPresent && attrList.contains(
name);
167 if(allitemsPresent) {
168 PileUpCorrectionJet = (
bool) attrList[myStrings.at( 0)];
169 PileUpCorrectionMET = (
bool) attrList[myStrings.at( 1)];
170 PileUpThresholdLowEm = (
int) attrList[myStrings.at( 2)];
171 PileUpThresholdHighEm = (
int) attrList[myStrings.at( 3)];
172 PileUpThresholdLowHadLar = (
int) attrList[myStrings.at( 4)];
173 PileUpThresholdHighHadLar = (
int) attrList[myStrings.at( 5)];
174 PileUpThresholdLowHadHecOverlap = (
int) attrList[myStrings.at( 6)];
175 PileUpThresholdHighHadHecOverlap = (
int) attrList[myStrings.at( 7)];
176 PileUpThresholdLowHadTrex = (
int) attrList[myStrings.at( 8)];
177 PileUpThresholdHighHadTrex = (
int) attrList[myStrings.at( 9)];
178 PileUpThresholdLowFcal = (
int) attrList[myStrings.at(10)];
179 PileUpThresholdHighFcal = (
int) attrList[myStrings.at(11)];
187 ATH_MSG_DEBUG(
"Loading Pileup values for jFEX ID A:"<<errTower <<
". Some towers are not used anymore. Skipping");
193 return StatusCode::FAILURE;
197 writeDBTool->set_doPileUpJet(PileUpCorrectionJet);
198 writeDBTool->set_doPileUpMet(PileUpCorrectionMET);
199 writeDBTool->set_PUThrLowEm(PileUpThresholdLowEm);
200 writeDBTool->set_PUThrHighEm(PileUpThresholdHighEm);
201 writeDBTool->set_PUThrLowHadLar(PileUpThresholdLowHadLar);
202 writeDBTool->set_PUThrHighHadLar(PileUpThresholdHighHadLar);
203 writeDBTool->set_PUThrLowHadHecOverlap(PileUpThresholdLowHadHecOverlap);
204 writeDBTool->set_PUThrHighHadHecOverlap(PileUpThresholdHighHadHecOverlap);
205 writeDBTool->set_PUThrLowHadTrex(PileUpThresholdLowHadTrex);
206 writeDBTool->set_PUThrHighHadTrex(PileUpThresholdHighHadTrex);
207 writeDBTool->set_PUThrLowFcal(PileUpThresholdLowFcal);
208 writeDBTool->set_PUThrHighFcal(PileUpThresholdHighFcal);
218 std::unordered_map< uint16_t, std::array<uint16_t,4> > NoiseCuts;
222 std::unordered_map< uint16_t, std::array<uint16_t,4> > PileUpWeight;
229 std::vector<std::string> myStringsNoise;
231 if (PileUpCorrectionJet == 0 and PileUpCorrectionMET == 0)
232 myStringsNoise = {
"CutJetEM",
"CutJetHad",
"CutMetEM",
"CutMetHad" };
233 else if (PileUpCorrectionJet == 1 and PileUpCorrectionMET == 0)
234 myStringsNoise = {
"CutJetPUEM",
"CutJetPUHad",
"CutMetEM",
"CutMetHad" };
235 else if (PileUpCorrectionJet == 0 and PileUpCorrectionMET == 1)
236 myStringsNoise = {
"CutJetEM",
"CutJetHad",
"CutMetPUEM",
"CutMetPUHad" };
238 myStringsNoise = {
"CutJetPUEM",
"CutJetPUHad",
"CutMetPUEM",
"CutMetPUHad" };
240 const std::vector<std::string> myStringsPileup{
"PileUpWeightEM",
"PileUpWeightHad",
"InverseWeightEM",
"InverseWeightHad" };
243 if (load_jFexNoiseCut.isValid()) {
246 writeCHandle.addDependency(load_jFexNoiseCut);
248 writeDBTool->set_sendDefaults(
false);
250 for (
auto itr = load_jFexNoiseCut->begin(); itr != load_jFexNoiseCut->end(); ++itr) {
253 const std::string
s((
char*)
blob.startingAddress(),
blob.size());
260 bool allitemsPresent =
true;
261 for(
const auto &
name:myStringsNoise ) {
262 allitemsPresent = allitemsPresent && attrList.contains(
name);
265 if( allitemsPresent ) {
266 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)]} };
273 ATH_MSG_DEBUG(
"Loading Pileup values for jFEX ID B:"<<errTower <<
". Some towers are not used anymore. Skipping");
274 NoiseCuts[ (
uint16_t) itr->first ] = {0, 0, 0, 0};
281 bool allitemsPresent =
true;
282 for(
const auto &
name:myStringsPileup ) {
283 allitemsPresent = allitemsPresent && attrList.contains(
name);
286 if( allitemsPresent ) {
287 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)]} };
294 ATH_MSG_DEBUG(
"Loading Pileup values for jFEX ID C:"<<errTower <<
". Some towers are not used anymore. Skipping");
295 PileUpWeight[ (
uint16_t) itr->first ] = {0, 0, 0, 0};
302 return StatusCode::FAILURE;
306 NoiseCuts[0x0000] = jDBdefaults::PileUpWeight_default;
307 NoiseCuts[0x00f0] = jDBdefaults::NoiseCuts_LATOME_TILE;
308 NoiseCuts[0x0f00] = jDBdefaults::NoiseCuts_LATOME_HEC;
309 NoiseCuts[0xf000] = jDBdefaults::NoiseCuts_FCAL;
311 PileUpWeight[0x0000] = jDBdefaults::PileUpWeight_default;
312 PileUpWeight[0x00f0] = jDBdefaults::PileUpWeight_default;
313 PileUpWeight[0x0f00] = jDBdefaults::PileUpWeight_default;
314 PileUpWeight[0xf000] = jDBdefaults::PileUpWeight_default;
318 writeDBTool->set_NoiseCuts(NoiseCuts);
319 writeDBTool->set_PileUpValues(PileUpWeight);
323 std::stringstream myprint;
327 myprint <<
"JfexModuleSettings obtained from jDBdefaults"<< std::endl;
328 myprint <<
"jJCalibParam:" << std::endl;
331 myprint <<
"jFEX"<<
mod<<
" - ";
333 myprint << writeDBTool->get_jJCalibParam(
mod,
range)<<
" ";
335 myprint << std::endl;
337 myprint << std::endl;
342 std::stringstream myprint1;
347 myprint1 <<
"JfexSystemSettings obtained from jDBdefaults"<< std::endl;
349 myprint1 <<
"System setting parameters: " <<std::endl;
350 myprint1 <<
"PileUpCorrectionJet: " << writeDBTool->get_doPileUpJet() <<std::endl;
351 myprint1 <<
"PileUpCorrectionMET: " << writeDBTool->get_doPileUpMet() <<std::endl;
352 myprint1 <<
"PileUpThresholdLowEm: " << writeDBTool->get_PUThrLowEm() <<std::endl;
353 myprint1 <<
"PileUpThresholdHighEm: " << writeDBTool->get_PUThrHighEm() <<std::endl;
354 myprint1 <<
"PileUpThresholdLowHadLar: " << writeDBTool->get_PUThrLowHadLar() <<std::endl;
355 myprint1 <<
"PileUpThresholdHighHadLar: " << writeDBTool->get_PUThrHighHadLar() <<std::endl;
356 myprint1 <<
"PileUpThresholdLowHadHecOverlap: " << writeDBTool->get_PUThrLowHadHecOverlap() <<std::endl;
357 myprint1 <<
"PileUpThresholdHighHadHecOverlap: "<< writeDBTool->get_PUThrHighHadHecOverlap()<<std::endl;
358 myprint1 <<
"PileUpThresholdLowHadTrex: " << writeDBTool->get_PUThrLowHadTrex() <<std::endl;
359 myprint1 <<
"PileUpThresholdHighHadTrex: " << writeDBTool->get_PUThrHighHadTrex() <<std::endl;
360 myprint1 <<
"PileUpThresholdLowFcal: " << writeDBTool->get_PUThrLowFcal() <<std::endl;
361 myprint1 <<
"PileUpThresholdHighFcal: " << writeDBTool->get_PUThrHighFcal() <<std::endl;
365 std::stringstream myprint2;
368 myprint2 <<
"Parameters obtained from m_JfexNoiseCutsKey: "<<
m_JfexNoiseCutsKey << std::endl;
370 myprint2 <<
"JfexNoiseCuts obtained from jDBdefaults"<< std::endl;
372 for(
const auto& [
key,
value] : NoiseCuts) {
373 const auto [CutJetEM, CutJetHad, CutMetEM, CutMetHad] =
value;
374 const auto [PileUpWeightEM, PileUpWeightHad, InverseWeightEM, InverseWeightHad] = PileUpWeight[
key];
376 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;
391 if (writeCHandle.record(std::move(writeDBTool)).isFailure()) {
392 ATH_MSG_ERROR(
"Could not record " << writeCHandle.key() <<
" with EventRange " << writeCHandle.getRange() <<
" into Conditions Store");
393 return StatusCode::FAILURE;
395 ATH_MSG_INFO(
"Recorded " << writeCHandle.key() <<
" with EventRange " << writeCHandle.getRange() <<
" into Conditions Store");
397 return StatusCode::SUCCESS;