Skip to content

Commit 7d93ba4

Browse files
ChristianTackeGSIkarabowi
authored andcommitted
feat(eventdisplay): Add FairXMLPdgColor::SetColorsFromXML
Currently only used in the ctor. Exposed for possible other users. Also added a bit of const.
1 parent 1b5ae3e commit 7d93ba4

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

fairroot/eventdisplay/xml/FairXMLPdgColor.cxx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2020-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -20,7 +20,7 @@
2020

2121
#include <TString.h>
2222

23-
FairXMLPdgColor::FairXMLPdgColor(FairXMLNode* node)
23+
FairXMLPdgColor::FairXMLPdgColor(const FairXMLNode* node)
2424
{
2525
if (!node) {
2626
SetDefColor();
@@ -32,8 +32,13 @@ FairXMLPdgColor::FairXMLPdgColor(FairXMLNode* node)
3232
return;
3333
}
3434

35-
for (int i = 0; i < node->GetNChildren(); i++) {
36-
FairXMLNode* colors = node->GetChild(i);
35+
SetColorsFromXML(*node);
36+
}
37+
38+
void FairXMLPdgColor::SetColorsFromXML(const FairXMLNode& node)
39+
{
40+
for (int i = 0; i < node.GetNChildren(); i++) {
41+
const FairXMLNode* colors = node.GetChild(i);
3742
TString pgd_code = colors->GetAttrib("pdg")->GetValue();
3843
TString color_code = colors->GetAttrib("color")->GetValue();
3944
fPDGToColor[pgd_code.Atoi()] = StringToColor(color_code);

fairroot/eventdisplay/xml/FairXMLPdgColor.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2020-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -28,8 +28,9 @@ class FairXMLPdgColor : public FairXMLEveConf
2828
void SetDefColor();
2929

3030
public:
31-
explicit FairXMLPdgColor(FairXMLNode* node = nullptr);
31+
explicit FairXMLPdgColor(const FairXMLNode* node = nullptr);
3232
~FairXMLPdgColor() override = default;
33+
void SetColorsFromXML(const FairXMLNode& node);
3334
void SetColor(Int_t pdg, Int_t color) { fPDGToColor[pdg] = color; }
3435
Int_t GetColor(Int_t pdg) const;
3536
};

0 commit comments

Comments
 (0)