23 "weta2",
"weta1",
"Rphi",
"Reta",
"wtots1",
"Rhad",
"Rhad1",
"f1",
"fracs1",
"DeltaE",
"Eratio"
52 unsigned long long key = eventNumber;
55 const long long phiBin =
static_cast<long long>(std::floor((
phi +
static_cast<float>(
M_PI)) * 100.0f));
56 key = eventNumber +
static_cast<unsigned long long>(phiBin);
59 return static_cast<int>(key %
m_nFolds);
74 const std::vector<float>&
ss)
const
83 ATH_MSG_WARNING(
"ApplyTo = TruthPhotons but truthType not available — skipping photon");
86 int truthType = acc_truthType(photon);
87 if (truthType < 13 || truthType > 15)
return false;
93 if (
ss[0] <= -10.f ||
ss[0] >= 10.f)
return false;
95 if (
ss[1] <= -10.f ||
ss[1] >= 10.f)
return false;
97 if (
ss[2] <= -10.f ||
ss[2] >= 10.f)
return false;
99 if (
ss[3] <= -10.f ||
ss[3] >= 10.f)
return false;
101 if (
ss[4] < -2.f ||
ss[4] >= 10.f)
return false;
103 if (
ss[5] < -2.f ||
ss[5] > 2.f)
return false;
105 if (
ss[6] < -2.f ||
ss[6] > 2.f)
return false;
107 if (
ss[7] <= -2.f ||
ss[7] >= 2.f)
return false;
109 if (
ss[8] <= -2.f ||
ss[8] >= 5.f)
return false;
111 if (
ss[9] < 0.f ||
ss[9] >= 5000.f)
return false;
113 if (
ss[10] < 0.f ||
ss[10] > 1.f)
return false;
125 ATH_MSG_ERROR(
"ConfigFile property is empty. Please provide a config file to the tool.");
126 return StatusCode::FAILURE;
130 if (resolvedConfig.empty()) {
132 return StatusCode::FAILURE;
137 env.ReadFile(resolvedConfig.c_str(), kEnvLocal);
138 env.IgnoreDuplicates(
false);
140 m_nFolds = env.GetValue(
"NFolds", 0);
142 ATH_MSG_ERROR(
"NFolds not set or invalid in config: " << resolvedConfig);
143 return StatusCode::FAILURE;
146 TString pattern = env.GetValue(
"ONNXnamePattern",
"");
147 if (pattern.IsNull()) {
148 ATH_MSG_ERROR(
"ONNXnamePattern not set in config: " << resolvedConfig);
149 return StatusCode::FAILURE;
154 TString
fs = env.GetValue(
"FoldStrategy",
"eventNumber");
155 std::string fsStr =
fs.Data();
160 ATH_MSG_ERROR(
"FoldStrategy must be 'eventNumber' or 'eventNumber_phi', but got '" << fsStr <<
"' in config: " << resolvedConfig);
161 return StatusCode::FAILURE;
170 return StatusCode::FAILURE;
178 return StatusCode::FAILURE;
191 for (
int i = 0; i <
m_nFolds; ++i) {
203 m_accessors[i].original = std::make_unique<SG::AuxElement::Accessor<float>>(var +
"_original");
210 return StatusCode::SUCCESS;
219 std::vector<float>
ss(nSS);
222 for (
size_t i = 0; i < nSS; ++i) {
233 dec_pass(photon) = pass ? 1 : 0;
248 const unsigned long long eventNumber =
h->eventNumber();
249 float ptGeV = photon.pt() / 1000.0f;
250 const float phi =
static_cast<float>(photon.phi());
262 std::vector<float> kinematic = {
264 static_cast<float>(photon.eta()),
265 static_cast<float>(photon.phi()),
266 static_cast<float>(isConv)
270 std::vector<Ort::Value> inputTensors;
275 int64_t batchSizeKin = onnxToolForward->getBatchSize(
276 static_cast<int64_t
>(kinematic.size()), 0);
277 if (onnxToolForward->addInput(inputTensors, kinematic, 0, batchSizeKin).isFailure()) {
278 ATH_MSG_ERROR(
"Fold " << fold <<
": failed to add kinematic input tensor");
283 int64_t batchSizeSS = onnxToolForward->getBatchSize(
284 static_cast<int64_t
>(
ss.size()), 1);
285 if (onnxToolForward->addInput(inputTensors,
ss, 1, batchSizeSS).isFailure()) {
286 ATH_MSG_ERROR(
"Fold " << fold <<
": failed to add shower shape input tensor");
290 std::vector<Ort::Value> outputTensors;
291 std::vector<float> outputData;
292 if (onnxToolForward->addOutput(outputTensors, outputData, 0, batchSizeKin).isFailure()) {
293 ATH_MSG_ERROR(
"Fold " << fold <<
": failed to add forward output tensor");
297 if (onnxToolForward->inference(inputTensors, outputTensors).isFailure()) {
298 ATH_MSG_ERROR(
"Fold " << fold <<
": forward inference failed");
302 float* zPtr = outputTensors[0].GetTensorMutableData<
float>();
303 std::vector<float> zVec(zPtr, zPtr + nSS);
307 std::vector<Ort::Value> inputTensorsBack;
308 std::vector<Ort::Value> outputTensorsBack;
309 std::vector<float> outputDataBack;
314 int64_t batchSizeKinBack = onnxToolBackward->getBatchSize(
315 static_cast<int64_t
>(kinematic.size()), 0);
316 if (onnxToolBackward->addInput(inputTensorsBack, kinematic, 0, batchSizeKinBack).isFailure()) {
317 ATH_MSG_ERROR(
"Fold " << fold <<
": failed to add kinematic input tensor for backward model");
322 int64_t batchSizeZBack = onnxToolBackward->getBatchSize(
static_cast<int64_t
>(zVec.size()), 1);
324 if (onnxToolBackward->addInput(inputTensorsBack, zVec, 1, batchSizeZBack).isFailure()) {
325 ATH_MSG_ERROR(
"Fold " << fold <<
": failed to add z input tensor for backward model");
330 if (onnxToolBackward->addInput(inputTensorsBack,
ss, 2, batchSizeKinBack).isFailure()) {
331 ATH_MSG_ERROR(
"Fold " << fold <<
": failed to add original SS input tensor for backward model");
335 if (onnxToolBackward->addOutput(outputTensorsBack, outputDataBack, 0, batchSizeZBack).isFailure()) {
336 ATH_MSG_ERROR(
"Fold " << fold <<
": failed to add backward output tensor");
340 if (onnxToolBackward->inference(inputTensorsBack, outputTensorsBack).isFailure()) {
341 ATH_MSG_ERROR(
"Fold " << fold <<
": backward inference failed");
345 const auto infoB = outputTensorsBack[0].GetTensorTypeAndShapeInfo();
346 const auto nElB = infoB.GetElementCount();
348 ATH_MSG_ERROR(
"Fold "<<fold <<
": backward output has " <<nElB<<
" elements, expected "<<nSS);
353 float* corrPtr = outputTensorsBack[0].GetTensorMutableData<
float>();
354 for (
size_t i = 0; i < nSS; ++i) {
355 photon.setShowerShapeValue(corrPtr[i],
s_ssEnums[i]);
367 ATH_MSG_ERROR(
"ElectronPhotonVariableNFCorrectionTool does not support electrons.");
384 ATH_MSG_ERROR(
"ElectronPhotonVariableNFCorrectionTool cannot correct electrons.");
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
bool msgLvl(const MSG::Level lvl) const
Header file for AthHistogramAlgorithm.
Return value from object correction CP tools.
@ Error
Some error happened during the object correction.
@ Ok
The correction was done successfully.
SG::Decorator< T, ALLOC > Decorator
SG::Accessor< T, ALLOC > Accessor
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
@ unconverted
unconverted photon
@ wtots1
shower width is determined in a window detaxdphi = 0,0625 ×~0,2, corresponding typically to 20 strips...
@ f1
E1/E = fraction of energy reconstructed in the first sampling, where E1 is energy in all strips belon...
@ Eratio
(emaxs1-e2tsts1)/(emaxs1+e2tsts1)
@ fracs1
shower shape in the shower core : [E(+/-3)-E(+/-1)]/E(+/-1), where E(+/-n) is the energy in ± n strip...
@ weta2
the lateral width is calculated with a window of 3x5 cells using the energy weighted sum over all cel...
@ weta1
shower width using +/-3 strips around the one with the maximal energy deposit: w3 strips = sqrt{sum(E...
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".