ATLAS Offline Software
Loading...
Searching...
No Matches
TFCSGANXMLParameters.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6// TFCSGANXMLParameters.cxx, (c) ATLAS Detector software //
8
9// Class header include
11
14
16
18
20 int pid, int etaMid, const std::string& FastCaloGANInputFolderName) {
21
22 m_fastCaloGANInputFolderName = FastCaloGANInputFolderName;
23 std::string xmlFullFileName = FastCaloGANInputFolderName + "/binning.xml";
24
25 // Parse the XML file
27 std::unique_ptr<XMLCoreNode> doc = p.parse (xmlFullFileName);
28
29 if (!doc) {
30 ATH_MSG_WARNING("Failed to parse XML file: " << xmlFullFileName);
31 return;
32 }
33
34 for (const XMLCoreNode* nodeParticle : doc->get_children ("Bins/Particle")) {
35 if (nodeParticle->get_int_attrib ("pid") == pid) {
36 for (const XMLCoreNode* nodeBin : nodeParticle->get_children ("Bin")) {
37 int nodeEtaMin = nodeBin->get_int_attrib ("etaMin");
38 int nodeEtaMax = nodeBin->get_int_attrib ("etaMax");
39 int regionId = nodeBin->get_int_attrib ("regionId");
40
41 if (std::abs(etaMid) > nodeEtaMin &&
42 std::abs(etaMid) < nodeEtaMax)
43 {
44 m_symmetrisedAlpha = nodeBin->has_attrib ("symmetriseAlpha") &&
45 nodeBin->get_attrib ("symmetriseAlpha") == "true";
46 m_ganVersion = nodeBin->get_int_attrib ("ganVersion");
47 m_latentDim = nodeParticle->get_int_attrib ("latentDim");
48
49 for (const XMLCoreNode* nodeLayer : nodeBin->get_children ("Layer")) {
50 std::vector<double> edges;
51 std::string s = nodeLayer->get_attrib ("r_edges");
52 std::istringstream ss(s);
53 std::string token;
54
55 while (std::getline(ss, token, ',')) {
56 edges.push_back(std::stod(token));
57 }
58
59 int binsInAlpha = nodeLayer->get_int_attrib ("n_bin_alpha");
60 int layer = nodeLayer->get_int_attrib ("id");
61
62 std::string name = "hist_pid_" + std::to_string(pid) +
63 "_region_" + std::to_string(regionId) +
64 "_layer_" + std::to_string(layer);
65 int xBins = static_cast<int>(edges.size()) - 1;
66
67 if (xBins <= 0) {
69 "No bins defined in r for layer "
70 << layer
71 << ", setting to 1 bin to avoid empty histogram");
72 xBins = 1; // Remove warning and set a default bin
73 edges.push_back (edges.back()+1);
74 } else {
75 m_relevantlayers.push_back(layer);
76 }
77
78 double minAlpha = -M_PI;
79 if (m_symmetrisedAlpha && binsInAlpha > 1) {
80 minAlpha = 0;
81 }
82 // Create histogram and add to binning map
83 auto itr = m_binning.emplace(
84 layer,
85 TH2D(name.c_str(), name.c_str(), xBins, edges.data(),
86 binsInAlpha, minAlpha, M_PI));
87 itr.first->second.SetDirectory(nullptr);
88 }
89 }
90 }
91 }
92 }
93}
94
96 ATH_MSG_INFO("Parameters taken from XML");
97 ATH_MSG_INFO(" symmetrisedAlpha: " << m_symmetrisedAlpha);
98 ATH_MSG_INFO(" ganVersion:" << m_ganVersion);
99 ATH_MSG_INFO(" latentDim: " << m_latentDim);
100 ATH_MSG(INFO) << " relevantlayers: ";
101 for (const auto& l : m_relevantlayers) {
102 ATH_MSG(INFO) << l << " ";
103 }
104 ATH_MSG(INFO) << END_MSG(INFO);
105
106 for (const auto& element : m_binning) {
107 int layer = element.first;
108 const TH2D* h = &element.second;
109
110 // attempt to debug intermittent ci issues described in
111 // https://its.cern.ch/jira/browse/ATLASSIM-7031
112 if (h->IsZombie()) {
113 ATH_MSG_WARNING("Histogram pointer for layer "
114 << layer << " is broken. Skipping.");
115 continue;
116 }
117
118 int xBinNum = h->GetNbinsX();
119 const TAxis* x = h->GetXaxis();
120
121 if (xBinNum == 1) {
122 ATH_MSG_INFO("layer " << layer << " not used");
123 continue;
124 }
125 ATH_MSG_INFO("Binning along r for layer " << layer);
126 ATH_MSG(INFO) << "0,";
127 // First fill energies
128 for (int ix = 1; ix <= xBinNum; ++ix) {
129 ATH_MSG(INFO) << x->GetBinUpEdge(ix) << ",";
130 }
131 ATH_MSG(INFO) << END_MSG(INFO);
132 }
133}
#define M_PI
#define ATH_MSG(lvl)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t ss
#define END_MSG(lvl)
Definition MLogging.h:171
#define x
Simple DOM-like node structure to hold the result of XML parsing.
Header file for AthHistogramAlgorithm.
virtual ~TFCSGANXMLParameters()
void InitialiseFromXML(int pid, int etaMid, const std::string &FastCaloGANInputFolderName)
std::string m_fastCaloGANInputFolderName
std::vector< int > m_relevantlayers
Simple DOM-like node structure to hold the result of XML parsing.
Definition XMLCoreNode.h:46
std::vector< const XMLCoreNode * > get_children(const std::string &path="*") const
Return all children matching a pattern.