diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8bb469d098..bb4c67088f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,17 @@ All notable changes to FairRoot will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
+## 19.0.1 - 2024-07-22
+
+### Breaking Changes
+* Event display
+ * Removed void FairEventManager::LoadXMLDetector(TGeoNode* node, FairXMLNode* xml, Int_t depth = 0)
+
+### Deprecations
+* Event display
+ * Deprecated FairEventManager::LoadXMLSettings
+
+
## 19.0.0 - 2024-05-17
### Breaking Changes
diff --git a/examples/advanced/propagator/macros/conf.xml b/examples/advanced/propagator/macros/conf.xml
index 218aad73b1..3a87cbb7b6 100644
--- a/examples/advanced/propagator/macros/conf.xml
+++ b/examples/advanced/propagator/macros/conf.xml
@@ -5,15 +5,21 @@
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/common/eventdisplay/FairEveMCTracks.cxx b/examples/common/eventdisplay/FairEveMCTracks.cxx
index 63336eb2eb..bd54ff6eb9 100644
--- a/examples/common/eventdisplay/FairEveMCTracks.cxx
+++ b/examples/common/eventdisplay/FairEveMCTracks.cxx
@@ -88,7 +88,7 @@ void FairEveMCTracks::DrawTrack(Int_t id)
auto tr = static_cast(fContainer->UncheckedAt(id));
if (!CheckCuts(tr))
return;
- Color_t color = GetEventManager()->Color(tr->GetPdgCode());
+ Color_t color = fPdgColor.GetColor(tr->GetPdgCode());
TEveTrackList* trList = FindTrackGroup(Form("%i", tr->GetPdgCode()), color);
TParticle p(tr->GetPdgCode(),
0,
@@ -149,6 +149,9 @@ InitStatus FairEveMCTracks::Init()
if (status != kSUCCESS)
return status;
FairEventManager* eveManager = GetEventManager();
+ auto colorConf = eveManager->GetXMLConfigNode("MCTrackColors");
+ if (colorConf)
+ fPdgColor = FairXMLPdgColor(colorConf);
FairRootManager* mngr = &(eveManager->GetRootManager());
fContainer = dynamic_cast(mngr->GetObject("MCTrack"));
if (!fContainer) {
diff --git a/examples/common/eventdisplay/FairEveMCTracks.h b/examples/common/eventdisplay/FairEveMCTracks.h
index a3159871c5..84bf712cff 100644
--- a/examples/common/eventdisplay/FairEveMCTracks.h
+++ b/examples/common/eventdisplay/FairEveMCTracks.h
@@ -16,8 +16,9 @@
#ifndef FAIREVEMCTRACKS_H_
#define FAIREVEMCTRACKS_H_
-#include "FairEveTracks.h" // for FairEveTracks
-#include "FairTask.h" // for InitStatus
+#include "FairEveTracks.h" // for FairEveTracks
+#include "FairTask.h" // for InitStatus
+#include "FairXMLPdgColor.h" //for pdg color
#include
#include // for THashConsistencyHolder, ClassDef
@@ -37,11 +38,12 @@ class FairEveMCTracks : public FairEveTracks
Bool_t fShowSecondary;
Bool_t fUsePdg;
Int_t fPdgCut;
+ FairXMLPdgColor fPdgColor;
std::unique_ptr fRK{};
TDatabasePDG* fPDG{nullptr};
protected:
- Bool_t CheckCuts(FairMCTrack *tr);
+ Bool_t CheckCuts(FairMCTrack* tr);
void DrawTrack(Int_t id);
public:
diff --git a/fairroot/eventdisplay/CMakeLists.txt b/fairroot/eventdisplay/CMakeLists.txt
index 429ac118df..167ee152a7 100644
--- a/fairroot/eventdisplay/CMakeLists.txt
+++ b/fairroot/eventdisplay/CMakeLists.txt
@@ -41,6 +41,7 @@ set(sources
tracks/FairGeoTrackHandler.cxx
xml/FairXMLEveConf.cxx
xml/FairXMLPdgColor.cxx
+ xml/FairXMLDetectorColor.cxx
)
fair_change_extensions_if_exists(.cxx .h FILES "${sources}" OUTVAR headers)
diff --git a/fairroot/eventdisplay/FairEventManager.cxx b/fairroot/eventdisplay/FairEventManager.cxx
index afd6da4e06..4933967472 100644
--- a/fairroot/eventdisplay/FairEventManager.cxx
+++ b/fairroot/eventdisplay/FairEventManager.cxx
@@ -15,6 +15,7 @@
#include "FairRootManager.h" // for FairRootManager
#include "FairRunAna.h" // for FairRunAna
#include "FairXMLNode.h"
+#include "xml/FairXMLDetectorColor.h"
#include // for TDatabasePDG
#include
@@ -64,7 +65,6 @@ FairEventManager::FairEventManager()
, fRhoZPlane{-1, 0, 0, 0}
, fRphiCam(TGLViewer::kCameraOrthoXOY)
, fRhoCam(TGLViewer::kCameraOrthoZOY)
- , fXMLConfig("")
{
fgRinstance = this;
AddParticlesToPdgDataBase();
@@ -84,7 +84,7 @@ void FairEventManager::Init(Int_t visopt, Int_t vislvl, Int_t maxvisnds)
fWorldSizeY = box->GetDY();
fWorldSizeZ = box->GetDZ();
}
- if (!fXMLConfig.EqualTo(""))
+ if (fXMLFile)
LoadXMLSettings();
gEve->AddGlobalElement(TNod);
gEve->FullRedraw3D(kTRUE);
@@ -174,6 +174,11 @@ FairEventManager::~FairEventManager()
void FairEventManager::Open() {}
+void FairEventManager::SetXMLConfig(TString xml_config)
+{
+ if (xml_config.Length())
+ fXMLFile = std::make_unique(xml_config);
+}
void FairEventManager::GotoEvent(Int_t event)
{
fEntry = event;
@@ -297,69 +302,20 @@ void FairEventManager::SetRhoZPlane(Double_t a, Double_t b, Double_t c, Double_t
void FairEventManager::LoadXMLSettings()
{
- FairXMLFile xmlfile(fXMLConfig, "read");
- FairXMLNode *xml = xmlfile.GetRootNode();
- for (int i = 0; i < xml->GetNChildren(); i++) {
- TString nodename = xml->GetChild(i)->GetName();
- if (nodename.EqualTo("Detectors")) {
- TGeoNode *top = gGeoManager->GetTopNode();
- FairXMLNode *top_xml = xml->GetChild(i)->GetChild(0);
- if (top_xml != nullptr)
- LoadXMLDetector(top, top_xml);
- } else if (nodename.EqualTo("MCTracksColors")) {
- FairXMLNode *colors = xml->GetChild(i);
- for (int j = 0; j < colors->GetNChildren(); j++) {
- FairXMLNode *color = colors->GetChild(j);
- TString pgd_code = color->GetAttrib("pdg")->GetValue();
- TString color_code = color->GetAttrib("color")->GetValue();
- fPDGColor.SetColor(pgd_code.Atoi(), FairXMLPdgColor::StringToColor(color_code));
- }
+ auto colors = GetXMLConfigNode("MCTracksColors");
+ auto detectors = GetXMLConfigNode("Detectors");
+ if (colors)
+ fPDGColor = FairXMLPdgColor(colors);
+ if (detectors) {
+ auto cave = detectors->GetChild(0);
+ if (cave) {
+ FairXMLDetectorColor detCol(cave);
+ detCol.Colorize(gGeoManager->GetTopNode());
}
}
gEve->Redraw3D();
}
-void FairEventManager::LoadXMLDetector(TGeoNode* node, FairXMLNode* xml, Int_t depth)
-{
- TString name = xml->GetAttrib("name")->GetValue();
- TString node_name = node->GetName();
- Bool_t recursive = (xml->GetAttrib("recursive")->GetValue().Length() != 0 && !name.EqualTo(node_name));
- if (recursive && depth == 0)
- return;
- TString transparency = xml->GetAttrib("transparency")->GetValue();
- TString color = xml->GetAttrib("color")->GetValue();
- if (!color.EqualTo("")) {
- node->GetVolume()->SetFillColor(FairXMLPdgColor::StringToColor(color));
- node->GetVolume()->SetLineColor(FairXMLPdgColor::StringToColor(color));
- }
- if (!transparency.EqualTo("")) {
- node->GetVolume()->SetTransparency((Char_t)(transparency.Atoi()));
- }
- if (xml->GetAttrib("recursive")->GetValue().Length() > 0) {
- TString val = xml->GetAttrib("recursive")->GetValue();
- Int_t xml_depth = val.Atoi();
- if (recursive) {
- xml_depth = depth - 1;
- }
- for (int i = 0; i < node->GetNdaughters(); i++) {
- TGeoNode *daughter_node = node->GetDaughter(i);
- LoadXMLDetector(daughter_node, xml, xml_depth);
- }
- }
- if (xml->GetNChildren() > 0 && !recursive) {
- for (int i = 0; i < node->GetNdaughters(); i++) {
- TString subdetector_name = node->GetDaughter(i)->GetName();
- for (int j = 0; j < xml->GetNChildren(); j++) {
- FairXMLNode *subnode = xml->GetChild(j);
- TString subnode_name = subnode->GetAttrib("name")->GetValue();
- if (subnode_name == subdetector_name) {
- LoadXMLDetector(node->GetDaughter(i), subnode);
- }
- }
- }
- }
-}
-
void FairEventManager::SetTransparency(Bool_t use_xml, Int_t trans)
{
if (!use_xml) { // high transparency
@@ -367,7 +323,7 @@ void FairEventManager::SetTransparency(Bool_t use_xml, Int_t trans)
TGeoNode* top = gGeoManager->GetTopNode();
SetTransparencyForLayer(top, vis_level, trans);
} else { // normal transparency
- if (fXMLConfig != "") {
+ if (fXMLFile) {
LoadXMLSettings();
} else {
Int_t vis_level = gGeoManager->GetVisLevel();
@@ -466,3 +422,13 @@ void FairEventManager::SetEvtNumberText(Int_t evtNumber)
text += evtNumber;
fEventNumberText->SetText(text);
}
+
+FairXMLNode* FairEventManager::GetXMLConfigNode(TString name) const
+{
+ if (fXMLFile) {
+ auto root = fXMLFile->GetRootNode();
+ if (root)
+ return root->GetChild(name);
+ }
+ return nullptr;
+}
diff --git a/fairroot/eventdisplay/FairEventManager.h b/fairroot/eventdisplay/FairEventManager.h
index f4b8004628..0aedaebd40 100644
--- a/fairroot/eventdisplay/FairEventManager.h
+++ b/fairroot/eventdisplay/FairEventManager.h
@@ -34,6 +34,7 @@ class TEveViewer;
class TEveText;
class TGeoNode;
class TGListTreeItem;
+class FairXMLFile;
/**
* \ingroup eventdisplay fairroot_singleton
@@ -44,14 +45,17 @@ class FairEventManager : public TEveEventManager
static FairEventManager* Instance();
FairEventManager();
virtual ~FairEventManager();
- virtual void SetXMLConfig(TString xml_config) { fXMLConfig = xml_config; };
+ virtual void SetXMLConfig(TString xml_config);
virtual void Open();
virtual void GotoEvent(Int_t event); // *MENU*
virtual void NextEvent(); // *MENU*
virtual void PrevEvent(); // *MENU*
virtual void Close();
virtual void DisplaySettings(); // *Menu*
- virtual Int_t Color(Int_t pdg) { return fPDGColor.GetColor(pdg); }
+ [[deprecated("Use FairEventManager::GetXMLConfig")]] virtual Int_t Color(Int_t pdg)
+ {
+ return fPDGColor.GetColor(pdg);
+ }
void AddTask(FairTask* t) { fRunAna->AddTask(t); }
virtual void Init(Int_t visopt = 1, Int_t vislvl = 3, Int_t maxvisnds = 10000);
virtual Int_t GetCurrentEvent() { return fEntry; }
@@ -126,6 +130,7 @@ class FairEventManager : public TEveEventManager
Bool_t GetUseTimeOfEvent() const { return fUseTimeOfEvent; }
Bool_t GetDrawAnimatedTracks() const { return fAnimatedTracks; }
Bool_t GetClearHandler() const { return fClearHandler; }
+ FairXMLNode* GetXMLConfigNode(TString name) const;
FairRootManager& GetRootManager() { return fRootManager; }
FairRootManager const& GetRootManager() const { return fRootManager; }
@@ -151,7 +156,6 @@ class FairEventManager : public TEveEventManager
TEveProjectionAxes* GetRPhiAxes() const { return fAxesPhi; };
TEveProjectionAxes* GetRhoZAxes() const { return fAxesRho; };
virtual void LoadXMLSettings();
- void LoadXMLDetector(TGeoNode* node, FairXMLNode* xml, Int_t depth = 0);
[[deprecated("Use FairXMLPdgColor::StringToColor")]] Int_t StringToColor(const TString& color) const
{
return FairXMLPdgColor::StringToColor(color);
@@ -186,7 +190,7 @@ class FairEventManager : public TEveEventManager
TEveText* fEventTimeText{nullptr}; //!
TEveText* fEventNumberText{nullptr}; //!
FairXMLPdgColor fPDGColor{}; //!
- TString fXMLConfig;
+ std::unique_ptr fXMLFile; //!
void SetTransparencyForLayer(TGeoNode* node, Int_t depth, Char_t transparency);
static FairEventManager* fgRinstance; //!
FairEventManager(const FairEventManager&);
diff --git a/fairroot/eventdisplay/tracks/FairEveGeoTracks.cxx b/fairroot/eventdisplay/tracks/FairEveGeoTracks.cxx
index a245b6a798..4dbcf78630 100644
--- a/fairroot/eventdisplay/tracks/FairEveGeoTracks.cxx
+++ b/fairroot/eventdisplay/tracks/FairEveGeoTracks.cxx
@@ -20,6 +20,7 @@
#include "FairEventManager.h" // for FairEventManager
#include "FairGetEventTime.h"
#include "FairRootManager.h" // for FairRootManager
+#include "FairXMLNode.h"
#include
#include // for TClonesArray
@@ -51,6 +52,10 @@ InitStatus FairEveGeoTracks::Init()
if (status != kSUCCESS)
return status;
FairEventManager* eveManager = GetEventManager();
+ auto confColors = eveManager->GetXMLConfigNode("GeoTracksColors");
+ if (confColors) {
+ fPdgColor = FairXMLPdgColor(confColors);
+ }
auto& mngr = eveManager->GetRootManager();
fContainer = dynamic_cast(mngr.GetObject("GeoTracks"));
if (!fContainer) {
@@ -68,7 +73,7 @@ void FairEveGeoTracks::DrawTrack(Int_t id)
if (!CheckCuts(tr))
return;
auto p = static_cast(tr->GetParticle());
- Color_t color = GetEventManager()->Color(p->GetPdgCode());
+ Color_t color = fPdgColor.GetColor(p->GetPdgCode());
TEveTrackList* trList = FindTrackGroup(p->GetName(), color);
auto track = new FairEveTrack(p, p->GetPdgCode(), trList->GetPropagator());
@@ -100,7 +105,7 @@ void FairEveGeoTracks::DrawAnimatedTrack(TGeoTrack* tr, double t0)
if (tr->GetPoint(0)[3] * timeScale + t0 > fTMax)
return; // first point after tmax
auto p = static_cast(tr->GetParticle());
- Color_t color = GetEventManager()->Color(p->GetPdgCode());
+ Color_t color = fPdgColor.GetColor(p->GetPdgCode());
TEveTrackList* trList = FindTrackGroup(p->GetName(), color);
auto track = new FairEveTrack(p, p->GetPdgCode(), trList->GetPropagator());
track->SetElementTitle(Form("p={%4.3f,%4.3f,%4.3f}", p->Px(), p->Py(), p->Pz()));
diff --git a/fairroot/eventdisplay/tracks/FairEveGeoTracks.h b/fairroot/eventdisplay/tracks/FairEveGeoTracks.h
index 0735dbb2ee..3e4b472d43 100644
--- a/fairroot/eventdisplay/tracks/FairEveGeoTracks.h
+++ b/fairroot/eventdisplay/tracks/FairEveGeoTracks.h
@@ -18,10 +18,12 @@
#include "FairEveTracks.h" // for FairEveTracks
#include "FairTask.h" // for InitStatus
+#include "FairXMLPdgColor.h"
#include
#include // for THashConsistencyHolder, ClassDef
#include // for Bool_t, Int_t, Double_t
+
class TBuffer;
class TClass;
class TClonesArray;
@@ -41,6 +43,7 @@ class FairEveGeoTracks : public FairEveTracks
Int_t fPdgCut;
Double_t fTMin, fTMax;
TBranch* fBranch = nullptr;
+ FairXMLPdgColor fPdgColor;
FairTimebasedDataHandlerT fGeoTrackHandler;
protected:
diff --git a/fairroot/eventdisplay/xml/FairXMLDetectorColor.cxx b/fairroot/eventdisplay/xml/FairXMLDetectorColor.cxx
new file mode 100644
index 0000000000..1dac22b275
--- /dev/null
+++ b/fairroot/eventdisplay/xml/FairXMLDetectorColor.cxx
@@ -0,0 +1,104 @@
+/********************************************************************************
+ * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
+ * *
+ * This software is distributed under the terms of the *
+ * GNU Lesser General Public Licence (LGPL) version 3, *
+ * copied verbatim in the file "LICENSE" *
+ ********************************************************************************/
+/*
+ * FairXMLDetColor.cxx
+ *
+ * Created on: 17 lip 2024
+ * Author: daniel
+ */
+
+#include "FairXMLDetectorColor.h"
+
+#include "FairXMLNode.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+Int_t FairXMLDetectorColor::ApplyToNode(TGeoNode& node, const FairXMLNode& xml) const
+{
+ if (auto transparency_atrib = xml.GetAttrib("transparency")) {
+ Char_t transparency = 0;
+ if (transparency_atrib->GetValue().Length()) {
+ transparency = transparency_atrib->GetValue().Atoi();
+ node.GetVolume()->SetTransparency(transparency);
+ }
+ }
+
+ if (auto color_atrib = xml.GetAttrib("color")) {
+ TString color = xml.GetAttrib("color")->GetValue();
+ if (!color.EqualTo("")) {
+ node.GetVolume()->SetFillColor(FairXMLEveConf::StringToColor(color));
+ node.GetVolume()->SetLineColor(FairXMLEveConf::StringToColor(color));
+ }
+ }
+
+ if (auto rec_atrib = xml.GetAttrib("recursive")) {
+ TString rec = xml.GetAttrib("recursive")->GetValue();
+ if (rec.Length() == 0)
+ return 0;
+ return rec.Atoi();
+ }
+ return 0;
+}
+
+void FairXMLDetectorColor::ColorizeNode(TGeoNode& node, const FairXMLNode& xml, Int_t depth) const
+{
+ switch (depth) {
+ case 0: { // recursive mode of
+ return;
+ } break;
+ case -1: { // standard mode
+ Int_t newDepth = ApplyToNode(node, xml);
+ if (newDepth) {
+ ColorizeDaughters(node, xml, newDepth);
+ } else {
+ ColorizeDaughters(node, xml, -1);
+ }
+ } break;
+ default: { // recusrive mode
+ ApplyToNode(node, xml);
+ ColorizeDaughters(node, xml, depth);
+ } break;
+ }
+}
+
+FairXMLDetectorColor::FairXMLDetectorColor(FairXMLNode* node)
+{
+ if (node)
+ fNode = *node;
+}
+
+void FairXMLDetectorColor::Colorize(TGeoNode* node)
+{
+ if (!node)
+ return;
+ ColorizeNode(*node, fNode, -1);
+}
+
+void FairXMLDetectorColor::ColorizeDaughters(TGeoNode& node, const FairXMLNode& xml, Int_t depth) const
+{
+ if (depth == -1) {
+ for (int i = 0; i < node.GetNdaughters(); i++) {
+ TString subdetector_name = node.GetDaughter(i)->GetName();
+ for (int j = 0; j < xml.GetNChildren(); j++) {
+ FairXMLNode* subnode = xml.GetChild(j);
+ TString subnode_name = subnode->GetAttrib("name")->GetValue();
+ if (subnode_name.EqualTo(subdetector_name)) {
+ ColorizeNode(*node.GetDaughter(i), *subnode, -1);
+ }
+ }
+ }
+ } else {
+ for (int i = 0; i < node.GetNdaughters(); i++) {
+ ColorizeNode(*node.GetDaughter(i), xml, depth - 1);
+ }
+ }
+}
diff --git a/fairroot/eventdisplay/xml/FairXMLDetectorColor.h b/fairroot/eventdisplay/xml/FairXMLDetectorColor.h
new file mode 100644
index 0000000000..25fad43527
--- /dev/null
+++ b/fairroot/eventdisplay/xml/FairXMLDetectorColor.h
@@ -0,0 +1,55 @@
+/********************************************************************************
+ * Copyright (C) 2020-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
+ * *
+ * This software is distributed under the terms of the *
+ * GNU Lesser General Public Licence (LGPL) version 3, *
+ * copied verbatim in the file "LICENSE" *
+ ********************************************************************************/
+/*
+ * FairXMLDetColor.h
+ *
+ * Created on: 17 lip 2024
+ * Author: daniel
+ */
+
+#ifndef FAIRROOT_EVENTDISPLAY_XML_FAIRXMLDETECTORCOLOR_H_
+#define FAIRROOT_EVENTDISPLAY_XML_FAIRXMLDETECTORCOLOR_H_
+
+#include "FairXMLEveConf.h"
+#include "FairXMLNode.h"
+
+class TGeoNode;
+
+class FairXMLDetectorColor : public FairXMLEveConf
+{
+ protected:
+ FairXMLNode fNode;
+ /**
+ * applies setting to node with some cross-checks
+ * @param node geo node
+ * @param xml xml node
+ * @param depth depth of node (used in recursion mode)
+ */
+ void ColorizeNode(TGeoNode& node, const FairXMLNode& xml, Int_t depth) const;
+ /**
+ * applies settings to node without any cross-checks
+ * @param node
+ * @param xml
+ * @return recurency value, return 0 if recursive atribute has not been found
+ */
+ Int_t ApplyToNode(TGeoNode& node, const FairXMLNode& xml) const;
+ /**
+ * apply color to daughters
+ * @param node geo node
+ * @param xml xml node
+ * @param depth depth - if equal to -1 colorize according to xml daughters
+ */
+ void ColorizeDaughters(TGeoNode& node, const FairXMLNode& xml, Int_t depth) const;
+
+ public:
+ explicit FairXMLDetectorColor(FairXMLNode* node = nullptr);
+ ~FairXMLDetectorColor() override = default;
+ virtual void Colorize(TGeoNode* node);
+};
+
+#endif /* FAIRROOT_EVENTDISPLAY_XML_FAIRXMLDETECTORCOLOR_H_ */