9 #include "GaudiKernel/SystemOfUnits.h"
12 #include <nlohmann/json.hpp>
20 const std::string&
name,
25 declareInterface<IEFlowCellEOverPTool>(
this);
36 std::ifstream binBoundariesFile(
path+
"binBoundaries.json");
38 binBoundariesFile >> json_binBoundaries;
41 auto fillBinValues = [](
auto && binBoundaries,
const nlohmann::json &json_binBoundaries,
const std::string &binName){
42 if (json_binBoundaries.contains(binName)){
43 for (
auto binBoundary : json_binBoundaries[binName]) binBoundaries.push_back(binBoundary);
50 std::string energyBinBoundaries =
"energyBinBoundaries";
51 std::string etaBinBoundaries =
"etaBinBoundaries";
52 std::string firstIntBinBoundaries =
"firstIntBinBoundaries";
53 std::string caloLayerBinBoundaries =
"caloLayerBinBoundaries";
59 ATH_MSG_ERROR(
"Could not bin boundaries in json file: " << energyBinBoundaries);
60 return StatusCode::FAILURE;
73 ATH_MSG_ERROR(
"Could not bin boundaries in json file: " << etaBinBoundaries);
74 return StatusCode::FAILURE;
78 ATH_MSG_ERROR(
"Could not bin boundaries in json file: " << firstIntBinBoundaries);
79 return StatusCode::FAILURE;
83 ATH_MSG_ERROR(
"Could not bin boundaries in json file: " << caloLayerBinBoundaries);
84 return StatusCode::FAILURE;
92 return StatusCode::SUCCESS;
97 if (binnedParameters) {
101 std::vector<double> energyBinLowerBoundaries_GeV;
108 std::ifstream inputFile_eoverp(
path+
"eOverP.json");
110 inputFile_eoverp >> json_eoverp;
112 std::ifstream inputFile_cellOrdering(
path+
"cellOrdering.json");
114 inputFile_cellOrdering >> json_cellOrdering;
118 int energyBinCounter = -1;
121 std::stringstream currentEBinStream;
122 currentEBinStream << std::fixed << std::setprecision(0) << thisEBin;
123 std::string currentEBin = currentEBinStream.str();
124 int etaBinCounter = -1;
127 std::stringstream currentEtaBinStream;
128 currentEtaBinStream << std::fixed << std::setprecision(1) << thisEtaBin;
129 std::string currentEtaBin = currentEtaBinStream.str();
134 std::string currentFirstIntBin =
std::to_string(thisFirstIntRegionBin_Int);
135 std::string eOverPBin =
"energyBinLowerBound_"+currentEBin+
"_etaBinLowerBound_"+currentEtaBin+
"_firstIntBinLowerBound_"+currentFirstIntBin;
136 if (json_eoverp.contains(eOverPBin+
"_mean")){
137 binnedParameters->
setFudgeMean(energyBinCounter,etaBinCounter,thisFirstIntRegionBin,json_eoverp[eOverPBin+
"_mean"]);
138 ATH_MSG_DEBUG(
"Setting mean for bin " << eOverPBin <<
" to " << json_eoverp[eOverPBin+
"_mean"]);
142 if (json_eoverp.contains(eOverPBin+
"_sigma")){
143 binnedParameters->
setFudgeStdDev(energyBinCounter,etaBinCounter,thisFirstIntRegionBin,json_eoverp[eOverPBin+
"_sigma"]);
144 ATH_MSG_DEBUG(
"Setting sigma for bin " << eOverPBin <<
" to " << json_eoverp[eOverPBin+
"_sigma"]);
150 std::string cellOrderingBin = eOverPBin +
"_caloLayer_"+
std::to_string(thisLayerBin);
151 if (json_cellOrdering.contains(cellOrderingBin+
"_norm1")){
152 binnedParameters->
setShapeParam(energyBinCounter,etaBinCounter,thisFirstIntRegionBin,thisLayerBinEnum,
NORM1,json_cellOrdering[cellOrderingBin+
"_norm1"]);
153 ATH_MSG_DEBUG(
"Setting norm1 for bin " << cellOrderingBin <<
" to " << json_cellOrdering[cellOrderingBin+
"_norm1"]);
155 else ATH_MSG_DEBUG(
"No norm1 found for bin " << cellOrderingBin);
156 if (json_cellOrdering.contains(cellOrderingBin+
"_sigma1")){
157 binnedParameters->
setShapeParam(energyBinCounter,etaBinCounter,thisFirstIntRegionBin,thisLayerBinEnum,
WIDTH1,json_cellOrdering[cellOrderingBin+
"_sigma1"]);
158 ATH_MSG_DEBUG(
"Setting sigma1 for bin " << cellOrderingBin <<
" to " << json_cellOrdering[cellOrderingBin+
"_sigma1"]);
160 else ATH_MSG_DEBUG(
"No sigma1 found for bin " << cellOrderingBin);
161 if (json_cellOrdering.contains(cellOrderingBin+
"_norm2")){
162 binnedParameters->
setShapeParam(energyBinCounter,etaBinCounter,thisFirstIntRegionBin,thisLayerBinEnum,
NORM2,json_cellOrdering[cellOrderingBin+
"_norm2"]);
163 ATH_MSG_DEBUG(
"Setting norm2 for bin " << cellOrderingBin <<
" to " << json_cellOrdering[cellOrderingBin+
"_norm2"]);
165 else ATH_MSG_DEBUG(
"No norm2 found for bin " << cellOrderingBin);
166 if (json_cellOrdering.contains(cellOrderingBin+
"_sigma2")){
167 binnedParameters->
setShapeParam(energyBinCounter,etaBinCounter,thisFirstIntRegionBin,thisLayerBinEnum,
WIDTH2,json_cellOrdering[cellOrderingBin+
"_sigma2"]);
168 ATH_MSG_DEBUG(
"Setting sigma2 for bin " << cellOrderingBin <<
" to " << json_cellOrdering[cellOrderingBin+
"_sigma2"]);
170 else ATH_MSG_DEBUG(
"No sigma2 found for bin " << cellOrderingBin);
177 return StatusCode::SUCCESS;
182 return StatusCode::SUCCESS;