23 "weta2",
"weta1",
"Rphi",
"Reta",
"wtots1",
"Rhad",
"Rhad1",
"f1",
"fracs1",
"DeltaE",
"Eratio"
53 unsigned long long key = eventNumber;
56 const long long phiBin =
static_cast<long long>(std::floor((
phi +
static_cast<float>(
M_PI)) * 100.0f));
57 key = eventNumber +
static_cast<unsigned long long>(phiBin);
60 return static_cast<int>(key %
m_nFolds);
75 const std::vector<float>&
ss)
const
82 static const SG::AuxElement::Accessor<int> acc_truthType(
"truthType");
83 if (!acc_truthType.isAvailable(photon)) {
84 ATH_MSG_WARNING(
"ApplyTo = TruthPhotons but truthType not available — skipping photon");
87 int truthType = acc_truthType(photon);
88 if (truthType < 13 || truthType > 15)
return false;
94 if (
ss[0] <= -10.f ||
ss[0] >= 10.f)
return false;
96 if (
ss[1] <= -10.f ||
ss[1] >= 10.f)
return false;
98 if (
ss[2] <= -10.f ||
ss[2] >= 10.f)
return false;
100 if (
ss[3] <= -10.f ||
ss[3] >= 10.f)
return false;
102 if (
ss[4] < -2.f ||
ss[4] >= 10.f)
return false;
104 if (
ss[5] < -2.f ||
ss[5] > 2.f)
return false;
106 if (
ss[6] < -2.f ||
ss[6] > 2.f)
return false;
108 if (
ss[7] <= -2.f ||
ss[7] >= 2.f)
return false;
110 if (
ss[8] <= -2.f ||
ss[8] >= 5.f)
return false;
112 if (
ss[9] < 0.f ||
ss[9] >= 5000.f)
return false;
114 if (
ss[10] < 0.f ||
ss[10] > 1.f)
return false;
126 ATH_MSG_ERROR(
"ConfigFile property is empty. Please provide a config file to the tool.");
127 return StatusCode::FAILURE;
131 if (resolvedConfig.empty()) {
133 return StatusCode::FAILURE;
138 env.ReadFile(resolvedConfig.c_str(), kEnvLocal);
139 env.IgnoreDuplicates(
false);
143 ATH_MSG_ERROR(
"NFolds not set or invalid in config: " << resolvedConfig);
144 return StatusCode::FAILURE;
147 TString pattern = env.GetValue(
"ONNXnamePattern",
"");
148 if (pattern.IsNull()) {
149 ATH_MSG_ERROR(
"ONNXnamePattern not set in config: " << resolvedConfig);
150 return StatusCode::FAILURE;
155 TString
fs = env.GetValue(
"FoldStrategy",
"eventNumber");
156 std::string fsStr =
fs.Data();
161 ATH_MSG_ERROR(
"FoldStrategy must be 'eventNumber' or 'eventNumber_phi', but got '" << fsStr <<
"' in config: " << resolvedConfig);
162 return StatusCode::FAILURE;
171 return StatusCode::FAILURE;
179 return StatusCode::FAILURE;
192 for (
int i = 0; i <
m_nFolds; ++i) {
204 m_accessors[i].original = std::make_unique<SG::AuxElement::Accessor<float>>(var +
"_original");
211 return StatusCode::SUCCESS;
220 std::vector<float>
ss(nSS);
223 for (
size_t i = 0; i < nSS; ++i) {
229 static const SG::AuxElement::Decorator<char> dec_pass(
"NFCorrectedShowerShapes");
234 dec_pass(photon) = pass ? 1 : 0;
249 const unsigned long long eventNumber =
h->eventNumber();
250 float ptGeV = photon.pt() / 1000.0f;
251 const float phi =
static_cast<float>(photon.phi());
263 std::vector<float> kinematic = {
265 static_cast<float>(photon.eta()),
266 static_cast<float>(photon.phi()),
267 static_cast<float>(isConv)
271 std::vector<Ort::Value> inputTensors;
276 int64_t batchSizeKin = onnxToolForward->getBatchSize(
277 static_cast<int64_t
>(kinematic.size()), 0);
278 if (onnxToolForward->addInput(inputTensors, kinematic, 0, batchSizeKin).isFailure()) {
279 ATH_MSG_ERROR(
"Fold " << fold <<
": failed to add kinematic input tensor");
284 int64_t batchSizeSS = onnxToolForward->getBatchSize(
285 static_cast<int64_t
>(
ss.size()), 1);
286 if (onnxToolForward->addInput(inputTensors,
ss, 1, batchSizeSS).isFailure()) {
287 ATH_MSG_ERROR(
"Fold " << fold <<
": failed to add shower shape input tensor");
291 std::vector<Ort::Value> outputTensors;
292 std::vector<float> outputData;
293 if (onnxToolForward->addOutput(outputTensors, outputData, 0, batchSizeKin).isFailure()) {
294 ATH_MSG_ERROR(
"Fold " << fold <<
": failed to add forward output tensor");
298 if (onnxToolForward->inference(inputTensors, outputTensors).isFailure()) {
299 ATH_MSG_ERROR(
"Fold " << fold <<
": forward inference failed");
303 float* zPtr = outputTensors[0].GetTensorMutableData<
float>();
304 std::vector<float> zVec(zPtr, zPtr + nSS);
308 std::vector<Ort::Value> inputTensorsBack;
309 std::vector<Ort::Value> outputTensorsBack;
310 std::vector<float> outputDataBack;
315 int64_t batchSizeKinBack = onnxToolBackward->getBatchSize(
316 static_cast<int64_t
>(kinematic.size()), 0);
317 if (onnxToolBackward->addInput(inputTensorsBack, kinematic, 0, batchSizeKinBack).isFailure()) {
318 ATH_MSG_ERROR(
"Fold " << fold <<
": failed to add kinematic input tensor for backward model");
323 int64_t batchSizeZBack = onnxToolBackward->getBatchSize(
static_cast<int64_t
>(zVec.size()), 1);
325 if (onnxToolBackward->addInput(inputTensorsBack, zVec, 1, batchSizeZBack).isFailure()) {
326 ATH_MSG_ERROR(
"Fold " << fold <<
": failed to add z input tensor for backward model");
331 if (onnxToolBackward->addInput(inputTensorsBack,
ss, 2, batchSizeKinBack).isFailure()) {
332 ATH_MSG_ERROR(
"Fold " << fold <<
": failed to add original SS input tensor for backward model");
336 if (onnxToolBackward->addOutput(outputTensorsBack, outputDataBack, 0, batchSizeZBack).isFailure()) {
337 ATH_MSG_ERROR(
"Fold " << fold <<
": failed to add backward output tensor");
341 if (onnxToolBackward->inference(inputTensorsBack, outputTensorsBack).isFailure()) {
342 ATH_MSG_ERROR(
"Fold " << fold <<
": backward inference failed");
346 const auto infoB = outputTensorsBack[0].GetTensorTypeAndShapeInfo();
347 const auto nElB = infoB.GetElementCount();
349 ATH_MSG_ERROR(
"Fold "<<fold <<
": backward output has " <<nElB<<
" elements, expected "<<nSS);
354 float* corrPtr = outputTensorsBack[0].GetTensorMutableData<
float>();
355 for (
size_t i = 0; i < nSS; ++i) {
356 photon.setShowerShapeValue(corrPtr[i],
s_ssEnums[i]);
368 ATH_MSG_ERROR(
"ElectronPhotonVariableNFCorrectionTool does not support electrons.");
385 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.
@ 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".