ATLAS Offline Software
Public Types | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
TFCSGANXMLParameters Class Reference

#include <TFCSGANXMLParameters.h>

Inheritance diagram for TFCSGANXMLParameters:
Collaboration diagram for TFCSGANXMLParameters:

Public Types

typedef std::map< int, TH2D > Binning
 

Public Member Functions

 TFCSGANXMLParameters ()
 
virtual ~TFCSGANXMLParameters ()
 
void InitialiseFromXML (int pid, int etaMid, const std::string &FastCaloGANInputFolderName)
 
void Print () const
 
const std::vector< int > & GetRelevantLayers () const
 
const BinningGetBinning () const
 
int GetLatentSpaceSize () const
 
int GetGANVersion () const
 
bool IsSymmetrisedAlpha () const
 
const std::string & GetInputFolder () const
 
bool msgLvl (const MSG::Level lvl) const
 Check whether the logging system is active at the provided verbosity level. More...
 
MsgStream & msg () const
 Return a stream for sending messages directly (no decoration) More...
 
MsgStream & msg (const MSG::Level lvl) const
 Return a decorated starting stream for sending messages. More...
 
MSG::Level level () const
 Retrieve output level. More...
 
virtual void setLevel (MSG::Level lvl)
 Update outputlevel. More...
 

Static Public Member Functions

static std::string startMsg (MSG::Level lvl, const std::string &file, int line)
 Make a message to decorate the start of logging. More...
 

Static Private Member Functions

static bool ReadBooleanAttribute (const std::string &name, xmlNodePtr node)
 

Private Attributes

bool m_symmetrisedAlpha {}
 
Binning m_binning
 
std::vector< int > m_relevantlayers
 
int m_ganVersion {}
 
int m_latentDim {}
 
std::string m_fastCaloGANInputFolderName
 
std::string m_nm
 Message source name. More...
 

Static Private Attributes

static boost::thread_specific_ptr< MsgStream > m_msg_tls ATLAS_THREAD_SAFE
 Do not persistify! More...
 

Detailed Description

Definition at line 21 of file TFCSGANXMLParameters.h.

Member Typedef Documentation

◆ Binning

typedef std::map<int, TH2D> TFCSGANXMLParameters::Binning

Definition at line 23 of file TFCSGANXMLParameters.h.

Constructor & Destructor Documentation

◆ TFCSGANXMLParameters()

TFCSGANXMLParameters::TFCSGANXMLParameters ( )
default

◆ ~TFCSGANXMLParameters()

TFCSGANXMLParameters::~TFCSGANXMLParameters ( )
virtualdefault

Member Function Documentation

◆ GetBinning()

const Binning& TFCSGANXMLParameters::GetBinning ( ) const
inline

Definition at line 33 of file TFCSGANXMLParameters.h.

33 { return m_binning; };

◆ GetGANVersion()

int TFCSGANXMLParameters::GetGANVersion ( ) const
inline

Definition at line 35 of file TFCSGANXMLParameters.h.

35 { return m_ganVersion; };

◆ GetInputFolder()

const std::string& TFCSGANXMLParameters::GetInputFolder ( ) const
inline

Definition at line 37 of file TFCSGANXMLParameters.h.

◆ GetLatentSpaceSize()

int TFCSGANXMLParameters::GetLatentSpaceSize ( ) const
inline

Definition at line 34 of file TFCSGANXMLParameters.h.

34 { return m_latentDim; };

◆ GetRelevantLayers()

const std::vector<int>& TFCSGANXMLParameters::GetRelevantLayers ( ) const
inline

Definition at line 32 of file TFCSGANXMLParameters.h.

32 { return m_relevantlayers; };

◆ InitialiseFromXML()

void TFCSGANXMLParameters::InitialiseFromXML ( int  pid,
int  etaMid,
const std::string &  FastCaloGANInputFolderName 
)

Definition at line 16 of file TFCSGANXMLParameters.cxx.

17  {
18 
19  m_fastCaloGANInputFolderName = FastCaloGANInputFolderName;
20  std::string xmlFullFileName = FastCaloGANInputFolderName + "/binning.xml";
21 
22  // Parse the XML file
23  xmlDocPtr doc = xmlParseFile(xmlFullFileName.c_str());
24  if (!doc) {
25  ATH_MSG_WARNING("Failed to parse XML file: " << xmlFullFileName);
26  return;
27  }
28 
29  for (xmlNodePtr nodeRoot = doc->children; nodeRoot != nullptr;
30  nodeRoot = nodeRoot->next) {
31  if (xmlStrEqual(nodeRoot->name, BAD_CAST "Bins")) {
32  for (xmlNodePtr nodeParticle = nodeRoot->children;
33  nodeParticle != nullptr; nodeParticle = nodeParticle->next) {
34  if (xmlStrEqual(nodeParticle->name, BAD_CAST "Particle")) {
35  int nodePid = std::stoi(reinterpret_cast<const char*>(
36  xmlGetProp(nodeParticle, BAD_CAST "pid")));
37 
38  if (nodePid == pid) {
39  for (xmlNodePtr nodeBin = nodeParticle->children;
40  nodeBin != nullptr; nodeBin = nodeBin->next) {
41  if (xmlStrEqual(nodeBin->name, BAD_CAST "Bin")) {
42  int nodeEtaMin = std::stoi(reinterpret_cast<const char*>(
43  xmlGetProp(nodeBin, BAD_CAST "etaMin")));
44  int nodeEtaMax = std::stoi(reinterpret_cast<const char*>(
45  xmlGetProp(nodeBin, BAD_CAST "etaMax")));
46  int regionId = std::stoi(reinterpret_cast<const char*>(
47  xmlGetProp(nodeBin, BAD_CAST "regionId")));
48 
49  if (std::abs(etaMid) > nodeEtaMin &&
50  std::abs(etaMid) < nodeEtaMax) {
51 
53  ReadBooleanAttribute("symmetriseAlpha", nodeParticle);
54  m_ganVersion = std::stod(reinterpret_cast<const char*>(
55  xmlGetProp(nodeBin, BAD_CAST "ganVersion")));
56  m_latentDim = std::stod(reinterpret_cast<const char*>(
57  xmlGetProp(nodeParticle, BAD_CAST "latentDim")));
58 
59  for (xmlNodePtr nodeLayer = nodeBin->children;
60  nodeLayer != nullptr; nodeLayer = nodeLayer->next) {
61  if (xmlStrEqual(nodeLayer->name, BAD_CAST "Layer")) {
62  std::vector<double> edges;
63  std::string s(reinterpret_cast<const char*>(
64  xmlGetProp(nodeLayer, BAD_CAST "r_edges")));
65 
66  std::istringstream ss(s);
67  std::string token;
68 
69  while (std::getline(ss, token, ',')) {
70  edges.push_back(std::stod(token));
71  }
72 
73  int binsInAlpha = std::stoi(reinterpret_cast<const char*>(
74  xmlGetProp(nodeLayer, BAD_CAST "n_bin_alpha")));
75  int layer = std::stoi(reinterpret_cast<const char*>(
76  xmlGetProp(nodeLayer, BAD_CAST "id")));
77 
78  std::string name = "hist_pid_" + std::to_string(nodePid) +
79  "_region_" + std::to_string(regionId) +
80  "_layer_" + std::to_string(layer);
81  int xBins = static_cast<int>(edges.size()) - 1;
82 
83  if (xBins <= 0) {
85  "No bins defined in r for layer "
86  << layer
87  << ", setting to 1 bin to avoid empty histogram");
88  xBins = 1; // Remove warning and set a default bin
89  } else {
90  m_relevantlayers.push_back(layer);
91  }
92 
93  double minAlpha = -M_PI;
94  if (m_symmetrisedAlpha && binsInAlpha > 1) {
95  minAlpha = 0;
96  }
97  // Create histogram and add to binning map
98  m_binning.emplace(
99  layer,
100  TH2D(name.c_str(), name.c_str(), xBins, edges.data(),
101  binsInAlpha, minAlpha, M_PI));
102  }
103  }
104  }
105  }
106  }
107  }
108  }
109  }
110  }
111  }
112 
113  // Free XML document after parsing
114  xmlFreeDoc(doc);
115 }

◆ IsSymmetrisedAlpha()

bool TFCSGANXMLParameters::IsSymmetrisedAlpha ( ) const
inline

Definition at line 36 of file TFCSGANXMLParameters.h.

36 { return m_symmetrisedAlpha; };

◆ level()

MSG::Level ISF_FCS::MLogging::level ( ) const
inlineinherited

Retrieve output level.

Definition at line 201 of file MLogging.h.

201 { return msg().level(); }

◆ msg() [1/2]

MsgStream & ISF_FCS::MLogging::msg ( ) const
inlineinherited

Return a stream for sending messages directly (no decoration)

Definition at line 231 of file MLogging.h.

231  {
232  MsgStream *ms = m_msg_tls.get();
233  if (!ms) {
234  ms = new MsgStream(Athena::getMessageSvc(), m_nm);
235  m_msg_tls.reset(ms);
236  }
237  return *ms;
238 }

◆ msg() [2/2]

MsgStream & ISF_FCS::MLogging::msg ( const MSG::Level  lvl) const
inlineinherited

Return a decorated starting stream for sending messages.

Definition at line 240 of file MLogging.h.

240  {
241  return msg() << lvl;
242 }

◆ msgLvl()

bool ISF_FCS::MLogging::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Check whether the logging system is active at the provided verbosity level.

Definition at line 222 of file MLogging.h.

222  {
223  if (msg().level() <= lvl) {
224  msg() << lvl;
225  return true;
226  } else {
227  return false;
228  }
229 }

◆ Print()

void TFCSGANXMLParameters::Print ( ) const

Definition at line 124 of file TFCSGANXMLParameters.cxx.

124  {
125  ATH_MSG_INFO("Parameters taken from XML");
126  ATH_MSG_INFO(" symmetrisedAlpha: " << m_symmetrisedAlpha);
127  ATH_MSG_INFO(" ganVersion:" << m_ganVersion);
128  ATH_MSG_INFO(" latentDim: " << m_latentDim);
129  ATH_MSG(INFO) << " relevantlayers: ";
130  for (const auto& l : m_relevantlayers) {
131  ATH_MSG(INFO) << l << " ";
132  }
133  ATH_MSG(INFO) << END_MSG(INFO);
134 
135  for (const auto& element : m_binning) {
136  int layer = element.first;
137  const TH2D* h = &element.second;
138 
139  // attempt to debug intermittent ci issues described in
140  // https://its.cern.ch/jira/browse/ATLASSIM-7031
141  if (h->IsZombie()) {
142  ATH_MSG_WARNING("Histogram pointer for layer "
143  << layer << " is broken. Skipping.");
144  continue;
145  }
146 
147  int xBinNum = h->GetNbinsX();
148  const TAxis* x = h->GetXaxis();
149 
150  if (xBinNum == 1) {
151  ATH_MSG_INFO("layer " << layer << " not used");
152  continue;
153  }
154  ATH_MSG_INFO("Binning along r for layer " << layer);
155  ATH_MSG(INFO) << "0,";
156  // First fill energies
157  for (int ix = 1; ix <= xBinNum; ++ix) {
158  ATH_MSG(INFO) << x->GetBinUpEdge(ix) << ",";
159  }
160  ATH_MSG(INFO) << END_MSG(INFO);
161  }
162 }

◆ ReadBooleanAttribute()

bool TFCSGANXMLParameters::ReadBooleanAttribute ( const std::string &  name,
xmlNodePtr  node 
)
staticprivate

Definition at line 117 of file TFCSGANXMLParameters.cxx.

118  {
119  std::string attribute =
120  reinterpret_cast<const char*>(xmlGetProp(node, BAD_CAST name.c_str()));
121  return attribute == "true";
122 }

◆ setLevel()

void ISF_FCS::MLogging::setLevel ( MSG::Level  lvl)
virtualinherited

Update outputlevel.

Definition at line 105 of file MLogging.cxx.

105  {
106  lvl = (lvl >= MSG::NUM_LEVELS) ? MSG::ALWAYS
107  : (lvl < MSG::NIL) ? MSG::NIL
108  : lvl;
109  msg().setLevel(lvl);
110 }

◆ startMsg()

std::string ISF_FCS::MLogging::startMsg ( MSG::Level  lvl,
const std::string &  file,
int  line 
)
staticinherited

Make a message to decorate the start of logging.

Print a message for the start of logging.

Definition at line 116 of file MLogging.cxx.

116  {
117  int col1_len = 20;
118  int col2_len = 5;
119  int col3_len = 10;
120  auto last_slash = file.find_last_of('/');
121  int path_len = last_slash == std::string::npos ? 0 : last_slash;
122  int trim_point = path_len;
123  int total_len = file.length();
124  if (total_len - path_len > col1_len)
125  trim_point = total_len - col1_len;
126  std::string trimmed_name = file.substr(trim_point);
127  const char *LevelNames[MSG::NUM_LEVELS] = {
128  "NIL", "VERBOSE", "DEBUG", "INFO", "WARNING", "ERROR", "FATAL", "ALWAYS"};
129  std::string level = LevelNames[lvl];
130  std::string level_string = std::string("(") + level + ") ";
131  std::stringstream output;
132  output << std::setw(col1_len) << std::right << trimmed_name << ":"
133  << std::setw(col2_len) << std::left << line << std::setw(col3_len)
134  << std::right << level_string;
135  return output.str();
136 }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

boost::thread_specific_ptr<MsgStream> m_msg_tls ISF_FCS::MLogging::ATLAS_THREAD_SAFE
inlinestaticprivateinherited

Do not persistify!

MsgStream instance (a std::cout like with print-out levels)

Definition at line 215 of file MLogging.h.

◆ m_binning

Binning TFCSGANXMLParameters::m_binning
private

Definition at line 43 of file TFCSGANXMLParameters.h.

◆ m_fastCaloGANInputFolderName

std::string TFCSGANXMLParameters::m_fastCaloGANInputFolderName
private

Definition at line 47 of file TFCSGANXMLParameters.h.

◆ m_ganVersion

int TFCSGANXMLParameters::m_ganVersion {}
private

Definition at line 45 of file TFCSGANXMLParameters.h.

◆ m_latentDim

int TFCSGANXMLParameters::m_latentDim {}
private

Definition at line 46 of file TFCSGANXMLParameters.h.

◆ m_nm

std::string ISF_FCS::MLogging::m_nm
privateinherited

Message source name.

Definition at line 211 of file MLogging.h.

◆ m_relevantlayers

std::vector<int> TFCSGANXMLParameters::m_relevantlayers
private

Definition at line 44 of file TFCSGANXMLParameters.h.

◆ m_symmetrisedAlpha

bool TFCSGANXMLParameters::m_symmetrisedAlpha {}
private

Definition at line 42 of file TFCSGANXMLParameters.h.


The documentation for this class was generated from the following files:
TFCSGANXMLParameters::m_symmetrisedAlpha
bool m_symmetrisedAlpha
Definition: TFCSGANXMLParameters.h:42
checkFileSG.line
line
Definition: checkFileSG.py:75
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
ATH_MSG
#define ATH_MSG(lvl)
Definition: AthMsgStreamMacros.h:38
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ISF_FCS::MLogging::level
MSG::Level level() const
Retrieve output level.
Definition: MLogging.h:201
M_PI
#define M_PI
Definition: ActiveFraction.h:11
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
x
#define x
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
TFCSGANXMLParameters::m_binning
Binning m_binning
Definition: TFCSGANXMLParameters.h:43
TFCSGANXMLParameters::m_fastCaloGANInputFolderName
std::string m_fastCaloGANInputFolderName
Definition: TFCSGANXMLParameters.h:47
ISF_FCS::MLogging::msg
MsgStream & msg() const
Return a stream for sending messages directly (no decoration)
Definition: MLogging.h:231
TFCSGANXMLParameters::ReadBooleanAttribute
static bool ReadBooleanAttribute(const std::string &name, xmlNodePtr node)
Definition: TFCSGANXMLParameters.cxx:117
TrigConf::MSGTC::ALWAYS
@ ALWAYS
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:29
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
ISF_FCS::MLogging::m_nm
std::string m_nm
Message source name.
Definition: MLogging.h:211
ParticleGun_EoverP_Config.pid
pid
Definition: ParticleGun_EoverP_Config.py:62
file
TFile * file
Definition: tile_monitor.h:29
merge.output
output
Definition: merge.py:17
TrigConf::MSGTC::NUM_LEVELS
@ NUM_LEVELS
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:30
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TFCSGANXMLParameters::m_relevantlayers
std::vector< int > m_relevantlayers
Definition: TFCSGANXMLParameters.h:44
END_MSG
#define END_MSG(lvl)
Definition: MLogging.h:171
h
TFCSGANXMLParameters::m_latentDim
int m_latentDim
Definition: TFCSGANXMLParameters.h:46
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:16
TrigConf::MSGTC::NIL
@ NIL
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:22
MakeTH3DFromTH2Ds.xBins
list xBins
Definition: MakeTH3DFromTH2Ds.py:76
node
Definition: memory_hooks-stdcmalloc.h:74
TFCSGANXMLParameters::m_ganVersion
int m_ganVersion
Definition: TFCSGANXMLParameters.h:45