FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairEventManager.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 //______________________________________________________________________________
13 #include "FairEventManager.h"
14 
15 #include "FairRootManager.h" // for FairRootManager
16 #include "FairRunAna.h" // for FairRunAna
17 #include "FairXMLNode.h"
18 
19 #include <TDatabasePDG.h> // for TDatabasePDG
20 #include <TEveBrowser.h>
21 #include <TEveGeoNode.h> // for TEveGeoTopNode
22 #include <TEveManager.h> // for TEveManager, gEve
23 #include <TEveProjectionManager.h>
24 #include <TEveProjections.h> // for TEveProjection, TEveProjection::k...
25 #include <TEveScene.h>
26 #include <TEveText.h>
27 #include <TEveTrans.h>
28 #include <TEveViewer.h>
29 #include <TEveWindow.h> // for TEveWindowPack, TEveWindowSlot
30 #include <TGFileDialog.h>
31 #include <TGLCameraOverlay.h>
32 #include <TGLClip.h> // for TGLClip, TGLClip::kClipPlane, TGL...
33 #include <TGLFontManager.h>
34 #include <TGLLightSet.h>
35 #include <TGLViewer.h>
36 #include <TGeoBBox.h>
37 #include <TGeoManager.h> // for gGeoManager, TGeoManager
38 #include <TGeoNode.h>
39 #include <TGeoVolume.h> // for TGeoVolume
40 #include <TVector3.h>
41 
43 
44 FairEventManager *FairEventManager::fgRinstance = 0;
45 
46 FairEventManager *FairEventManager::Instance() { return fgRinstance; }
47 
49  : TEveEventManager("FairEventManager", "")
50  , fRootManager(FairRootManager::Instance())
51  , fEntry(0)
52  , fWorldSizeX(2000)
53  , fWorldSizeY(2000)
54  , fWorldSizeZ(2000)
55  , fTimeMin(0)
56  , fTimeMax(DBL_MAX)
57  , fUseTimeOfEvent(kTRUE)
58  , fTimeEvent(-1.)
59  , fAnimatedTracks(kFALSE)
60  , fClearHandler(kTRUE)
61  , fRunAna(FairRunAna::Instance())
62  , fEvent(0)
63  , fRPhiPlane{0, 0, 10, 0}
64  , fRhoZPlane{-1, 0, 0, 0}
65  , fRphiCam(TGLViewer::kCameraOrthoXOY)
66  , fRhoCam(TGLViewer::kCameraOrthoZOY)
67  , fRPhiView(nullptr)
68  , fRhoZView(nullptr)
69  , fMultiView(nullptr)
70  , fMultiRPhiView(nullptr)
71  , fMultiRhoZView(nullptr)
72  , fRPhiScene(nullptr)
73  , fRhoZScene(nullptr)
74  , fRPhiProjManager(nullptr)
75  , fRhoZProjManager(nullptr)
76  , fAxesPhi(nullptr)
77  , fAxesRho(nullptr)
78  , fXMLConfig("")
79 {
80  fgRinstance = this;
81  AddParticlesToPdgDataBase();
82  fPDGToColor[22] = 623; // photon
83  fPDGToColor[-2112] = 2; // anti-neutron
84  fPDGToColor[-11] = 3; // e+
85  fPDGToColor[-3122] = 4; // anti-lambda
86  fPDGToColor[11] = 5; // e-
87  fPDGToColor[-3222] = 6; // Sigma -
88  fPDGToColor[12] = 7; // e-neutrino
89  fPDGToColor[-3212] = 8; // Sigma0
90  fPDGToColor[-13] = 9; // mu+
91  fPDGToColor[-3112] = 10; // Sigma+ (PB
92  fPDGToColor[13] = 11; // mu-
93  fPDGToColor[-3322] = 12; // Xi0
94  fPDGToColor[111] = 13; // pi0
95  fPDGToColor[-3312] = 14; // Xi+
96  fPDGToColor[211] = 15; // pi+
97  fPDGToColor[-3334] = 16; // Omega+ (PB)
98  fPDGToColor[-211] = 17; // pi-
99  fPDGToColor[-15] = 18; // tau+
100  fPDGToColor[130] = 19; // K long
101  fPDGToColor[15] = 20; // tau -
102  fPDGToColor[321] = 21; // K+
103  fPDGToColor[411] = 22; // D+
104  fPDGToColor[-321] = 23; // K-
105  fPDGToColor[-411] = 24; // D-
106  fPDGToColor[2112] = 25; // n
107  fPDGToColor[421] = 26; // D0
108  fPDGToColor[2212] = 27; // p
109  fPDGToColor[-421] = 28; // D0
110  fPDGToColor[-2212] = 29; // anti-proton
111  fPDGToColor[431] = 30; // Ds+
112  fPDGToColor[310] = 31; // K short
113  fPDGToColor[-431] = 32; // anti Ds-
114  fPDGToColor[221] = 33; // eta
115  fPDGToColor[4122] = 34; // Lambda_C+
116  fPDGToColor[3122] = 35; // Lambda
117  fPDGToColor[24] = 36; // W+
118  fPDGToColor[3222] = 37; // Sigma+
119  fPDGToColor[-24] = 38; // W-
120  fPDGToColor[3212] = 39; // Sigma0
121  fPDGToColor[23] = 40; // Z
122  fPDGToColor[3112] = 41; // Sigma -
123  fPDGToColor[3322] = 42; // Xi0
124  fPDGToColor[3312] = 43; // Xi-
125  fPDGToColor[3334] = 44; // Omega- (PB)
126  fPDGToColor[50000050] = 801; // Cerenkov
127  fPDGToColor[1000010020] = 45;
128  fPDGToColor[1000010030] = 48;
129  fPDGToColor[1000020040] = 50;
130  fPDGToColor[1000020030] = 55;
131 }
132 
133 void FairEventManager::Init(Int_t visopt, Int_t vislvl, Int_t maxvisnds)
134 {
135  TEveManager::Create();
136  fRunAna->Init();
137  if (gGeoManager == nullptr)
138  return;
139  TGeoNode *N = gGeoManager->GetTopNode();
140  TEveGeoTopNode *TNod = new TEveGeoTopNode(gGeoManager, N, visopt, vislvl, maxvisnds);
141  TGeoBBox *box = dynamic_cast<TGeoBBox *>(gGeoManager->GetTopNode()->GetVolume()->GetShape());
142  if (box) {
143  fWorldSizeX = box->GetDX();
144  fWorldSizeY = box->GetDY();
145  fWorldSizeZ = box->GetDZ();
146  }
147  if (!fXMLConfig.EqualTo(""))
148  LoadXMLSettings();
149  gEve->AddGlobalElement(TNod);
150  gEve->FullRedraw3D(kTRUE);
151  fEvent = gEve->AddEvent(this);
152 
153  fRPhiProjManager = new TEveProjectionManager(TEveProjection::kPT_RPhi);
154  fRhoZProjManager = new TEveProjectionManager(TEveProjection::kPT_RhoZ);
155  gEve->AddToListTree(fRPhiProjManager, kFALSE);
156  gEve->AddToListTree(fRhoZProjManager, kFALSE);
157  fAxesPhi = new TEveProjectionAxes(fRPhiProjManager);
158  fAxesRho = new TEveProjectionAxes(fRhoZProjManager);
159 
160  TEveWindowSlot *RPhiSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
161  TEveWindowPack *RPhiPack = RPhiSlot->MakePack();
162  RPhiPack->SetElementName("RPhi View");
163  RPhiPack->SetShowTitleBar(kFALSE);
164  RPhiPack->NewSlot()->MakeCurrent();
165  fRPhiView = gEve->SpawnNewViewer("RPhi View", "");
166  fRPhiScene = gEve->SpawnNewScene("RPhi", "Scene holding axis.");
167  fRPhiScene->AddElement(fAxesPhi);
168 
169  TEveWindowSlot *RhoZSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
170  TEveWindowPack *RhoZPack = RhoZSlot->MakePack();
171  RhoZPack->SetElementName("RhoZ View");
172  RhoZPack->SetShowTitleBar(kFALSE);
173  RhoZPack->NewSlot()->MakeCurrent();
174  fRhoZView = gEve->SpawnNewViewer("RhoZ View", "");
175  fRhoZScene = gEve->SpawnNewScene("RhoZ", "Scene holding axis.");
176  fRhoZScene->AddElement(fAxesRho);
177 
178  SetViewers(fRPhiView, fRhoZView);
179 
180  TEveWindowSlot *MultiSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
181  TEveWindowPack *MultiPack = MultiSlot->MakePack();
182  MultiPack->SetElementName("Multi View");
183  MultiPack->SetHorizontal();
184  MultiPack->SetShowTitleBar(kFALSE);
185  MultiPack->NewSlot()->MakeCurrent();
186  fMultiView = gEve->SpawnNewViewer("3D View (multi)", "");
187  // switch off left and right light sources for 3D MultiView
188  fMultiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
189  fMultiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
190  // add 3D scenes (first tab) to 3D MultiView
191  fMultiView->AddScene(gEve->GetGlobalScene());
192  fMultiView->AddScene(gEve->GetEventScene());
193 
194  // add slot for RPhi projection on Multi View tab
195  MultiPack = MultiPack->NewSlot()->MakePack();
196  MultiPack->SetShowTitleBar(kFALSE);
197  MultiPack->NewSlot()->MakeCurrent();
198  fMultiRPhiView = gEve->SpawnNewViewer("RPhi View (multi)", "");
199  MultiPack->NewSlot()->MakeCurrent();
200  fMultiRhoZView = gEve->SpawnNewViewer("RhoZ View (multi)", "");
201 
202  SetViewers(fMultiRPhiView, fMultiRhoZView);
203 
204  // don't change reposition camera on each update
205  fRPhiView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
206  fRhoZView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
207  fMultiView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
208  fMultiRPhiView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
209  fMultiRhoZView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
210  fMultiView->GetEveFrame()->HideAllDecorations();
211  fMultiRPhiView->GetEveFrame()->HideAllDecorations();
212  fMultiRhoZView->GetEveFrame()->HideAllDecorations();
213 
214  fEventTimeText = new TEveText("Event Time: ");
215  fEventTimeText->PtrMainTrans()->SetPos(-100, 80, 0);
216  fEventTimeText->SetMainColor(kOrange - 2);
217  fEventTimeText->SetFontFile("ariali");
218  fEventTimeText->SetFontSize(20);
219  fEventTimeText->SetFontMode(TGLFont::kPixmap);
220  fEventTimeText->SetLighting(kTRUE);
221  fEventTimeText->SetRnrState(kFALSE);
222  gEve->AddElement(fEventTimeText);
223 
224  fEventNumberText = new TEveText("Event Number: ");
225  fEventNumberText->PtrMainTrans()->SetPos(-100, 100, 0);
226  fEventNumberText->SetMainColor(kOrange - 2);
227  fEventNumberText->SetFontFile("ariali");
228  fEventNumberText->SetFontSize(20);
229  fEventNumberText->SetFontMode(TGLFont::kPixmap);
230  fEventNumberText->SetLighting(kTRUE);
231  fEventNumberText->SetRnrState(kFALSE);
232  gEve->AddElement(fEventNumberText);
233 }
234 
236 
238 
240 
242 {
243  fEntry = event;
244  fTimeMin = 0;
245  fTimeMax = DBL_MAX;
246  fRunAna->Run(static_cast<Long64_t>(event));
247 }
248 
250 {
251  fEntry += 1;
252  fTimeMin = 0;
253  fTimeMax = DBL_MAX;
254  fRunAna->Run(static_cast<Long64_t>(fEntry));
255 }
256 
258 {
259  fEntry -= 1;
260  fTimeMin = 0;
261  fTimeMax = DBL_MAX;
262  fRunAna->Run(static_cast<Long64_t>(fEntry));
263 }
264 
266 
268 
270 {
271  if (fPDGToColor.find(pdg) != fPDGToColor.end()) {
272  return fPDGToColor[pdg];
273  }
274  return 0;
275 }
276 
278 {
279  // Add particles to the PDG data base
280 
281  TDatabasePDG *pdgDB = TDatabasePDG::Instance();
282 
283  const Double_t kAu2Gev = 0.9314943228;
284  const Double_t khSlash = 1.0545726663e-27;
285  const Double_t kErg2Gev = 1 / 1.6021773349e-3;
286  const Double_t khShGev = khSlash * kErg2Gev;
287  const Double_t kYear2Sec = 3600 * 24 * 365.25;
288 
289  // Ions
290 
291  if (!pdgDB->GetParticle(1000010020))
292  pdgDB->AddParticle("Deuteron", "Deuteron", 2 * kAu2Gev + 8.071e-3, kTRUE, 0, 3, "Ion", 1000010020);
293 
294  if (!pdgDB->GetParticle(1000010030))
295  pdgDB->AddParticle(
296  "Triton", "Triton", 3 * kAu2Gev + 14.931e-3, kFALSE, khShGev / (12.33 * kYear2Sec), 3, "Ion", 1000010030);
297 
298  if (!pdgDB->GetParticle(1000020040))
299  pdgDB->AddParticle(
300  "Alpha", "Alpha", 4 * kAu2Gev + 2.424e-3, kTRUE, khShGev / (12.33 * kYear2Sec), 6, "Ion", 1000020040);
301 
302  if (!pdgDB->GetParticle(1000020030))
303  pdgDB->AddParticle("HE3", "HE3", 3 * kAu2Gev + 14.931e-3, kFALSE, 0, 6, "Ion", 1000020030);
304 
305  // Special particles
306  //
307  if (!pdgDB->GetParticle(50000050))
308  pdgDB->AddParticle("Cherenkov", "Cherenkov", 0, kFALSE, 0, 0, "Special", 50000050);
309 
310  if (!pdgDB->GetParticle(50000051))
311  pdgDB->AddParticle("FeedbackPhoton", "FeedbackPhoton", 0, kFALSE, 0, 0, "Special", 50000051);
312 }
313 
314 TVector3 FairEventManager::GetWorldSize() const { return TVector3(fWorldSizeX, fWorldSizeY, fWorldSizeZ); }
315 
316 void FairEventManager::SetViewers(TEveViewer *RPhi, TEveViewer *RhoZ)
317 {
318  RPhi->GetGLViewer()->SetCurrentCamera(fRphiCam);
319  // set clip plane and camera parameters
320  // RPhi->GetGLViewer()->GetClipSet()->SetClipType(TGLClip::kClipPlane);
321  // RPhi->GetGLViewer()->GetClipSet()->SetClipState(TGLClip::kClipPlane, fRPhiPlane);
322  RPhi->GetGLViewer()->GetCameraOverlay()->SetOrthographicMode(TGLCameraOverlay::kAxis);
323  RPhi->GetGLViewer()->GetCameraOverlay()->SetShowOrthographic(kTRUE);
324  // switch off left, right, top and bottom light sources
325  RPhi->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
326  RPhi->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
327  RPhi->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightTop, false);
328  RPhi->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightBottom, false);
329 
330  RhoZ->GetGLViewer()->SetCurrentCamera(fRhoCam);
331  // set clip plane and camera parameters
332  // RhoZ->GetGLViewer()->GetClipSet()->SetClipType(TGLClip::kClipPlane);
333  // RhoZ->GetGLViewer()->GetClipSet()->SetClipState(TGLClip::kClipPlane, fRhoZPlane);
334  RhoZ->GetGLViewer()->GetCameraOverlay()->SetOrthographicMode(TGLCameraOverlay::kAxis);
335  RhoZ->GetGLViewer()->GetCameraOverlay()->SetShowOrthographic(kTRUE);
336  // switch off left, right and front light sources
337  RhoZ->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
338  RhoZ->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
339  RhoZ->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightFront, false);
340 
341  RPhi->AddScene(fRPhiScene);
342  RPhi->AddScene(gEve->GetGlobalScene());
343  RPhi->AddScene(gEve->GetEventScene());
344  RhoZ->AddScene(fRhoZScene);
345  RhoZ->AddScene(gEve->GetGlobalScene());
346  RhoZ->AddScene(gEve->GetEventScene());
347 }
348 
349 void FairEventManager::SetRPhiPlane(Double_t a, Double_t b, Double_t c, Double_t d, TGLViewer::ECameraType camtype)
350 {
351  fRPhiPlane[0] = a;
352  fRPhiPlane[1] = b;
353  fRPhiPlane[2] = c;
354  fRPhiPlane[3] = d;
355  fRphiCam = camtype;
356 }
357 
358 void FairEventManager::SetRhoZPlane(Double_t a, Double_t b, Double_t c, Double_t d, TGLViewer::ECameraType camtype)
359 {
360  fRhoZPlane[0] = a;
361  fRhoZPlane[1] = b;
362  fRhoZPlane[2] = c;
363  fRhoZPlane[3] = d;
364  fRhoCam = camtype;
365 }
366 
368 {
369  FairXMLFile xmlfile(fXMLConfig, "read");
370  FairXMLNode *xml = xmlfile.GetRootNode();
371  for (int i = 0; i < xml->GetNChildren(); i++) {
372  TString nodename = xml->GetChild(i)->GetName();
373  if (nodename.EqualTo("Detectors")) {
374  TGeoNode *top = gGeoManager->GetTopNode();
375  FairXMLNode *top_xml = xml->GetChild(i)->GetChild(0);
376  if (top_xml != nullptr)
377  LoadXMLDetector(top, top_xml);
378  } else if (nodename.EqualTo("MCTracksColors")) {
379  FairXMLNode *colors = xml->GetChild(i);
380  for (int j = 0; j < colors->GetNChildren(); j++) {
381  FairXMLNode *color = colors->GetChild(j);
382  TString pgd_code = color->GetAttrib("pdg")->GetValue();
383  TString color_code = color->GetAttrib("color")->GetValue();
384  fPDGToColor[pgd_code.Atoi()] = StringToColor(color_code);
385  }
386  }
387  }
388  gEve->Redraw3D();
389 }
390 
391 void FairEventManager::LoadXMLDetector(TGeoNode *node, FairXMLNode *xml, Int_t depth)
392 {
393  TString name = xml->GetAttrib("name")->GetValue();
394  TString node_name = node->GetName();
395  Bool_t recursive = (xml->GetAttrib("recursive")->GetValue().Length() != 0 && !name.EqualTo(node_name));
396  if (recursive && depth == 0)
397  return;
398  TString transparency = xml->GetAttrib("transparency")->GetValue();
399  TString color = xml->GetAttrib("color")->GetValue();
400  if (!color.EqualTo("")) {
401  node->GetVolume()->SetFillColor(StringToColor(color));
402  node->GetVolume()->SetLineColor(StringToColor(color));
403  }
404  if (!transparency.EqualTo("")) {
405  node->GetVolume()->SetTransparency((Char_t)(transparency.Atoi()));
406  }
407  if (xml->GetAttrib("recursive")->GetValue().Length() > 0) {
408  TString val = xml->GetAttrib("recursive")->GetValue();
409  Int_t xml_depth = val.Atoi();
410  if (recursive) {
411  xml_depth = depth - 1;
412  }
413  for (int i = 0; i < node->GetNdaughters(); i++) {
414  TGeoNode *daughter_node = node->GetDaughter(i);
415  LoadXMLDetector(daughter_node, xml, xml_depth);
416  }
417  }
418  if (xml->GetNChildren() > 0 && !recursive) {
419  for (int i = 0; i < node->GetNdaughters(); i++) {
420  TString subdetector_name = node->GetDaughter(i)->GetName();
421  for (int j = 0; j < xml->GetNChildren(); j++) {
422  FairXMLNode *subnode = xml->GetChild(j);
423  TString subnode_name = subnode->GetAttrib("name")->GetValue();
424  if (subnode_name == subdetector_name) {
425  LoadXMLDetector(node->GetDaughter(i), subnode);
426  }
427  }
428  }
429  }
430 }
431 
432 Int_t FairEventManager::StringToColor(TString color) const
433 {
434  if (color.Contains("k")) {
435  Int_t plus_index = color.First('+');
436  Int_t minus_index = color.First('-');
437  Int_t cut = plus_index;
438  if (cut == -1)
439  cut = minus_index;
440  if (cut == -1)
441  cut = color.Length();
442  TString col_name(color(0, cut));
443  Int_t col_val = 0;
444  if (col_name.EqualTo("kWhite")) {
445  col_val = 0;
446  } else if (col_name.EqualTo("kBlack")) {
447  col_val = 1;
448  } else if (col_name.EqualTo("kGray")) {
449  col_val = 920;
450  } else if (col_name.EqualTo("kRed")) {
451  col_val = 632;
452  } else if (col_name.EqualTo("kGreen")) {
453  col_val = 416;
454  } else if (col_name.EqualTo("kBlue")) {
455  col_val = 600;
456  } else if (col_name.EqualTo("kYellow")) {
457  col_val = 400;
458  } else if (col_name.EqualTo("kMagenta")) {
459  col_val = 616;
460  } else if (col_name.EqualTo("kCyan")) {
461  col_val = 432;
462  } else if (col_name.EqualTo("kOrange")) {
463  col_val = 800;
464  } else if (col_name.EqualTo("kSpring")) {
465  col_val = 820;
466  } else if (col_name.EqualTo("kTeal")) {
467  col_val = 840;
468  } else if (col_name.EqualTo("kAzure")) {
469  col_val = 860;
470  } else if (col_name.EqualTo("kViolet")) {
471  col_val = 880;
472  } else if (col_name.EqualTo("kPink")) {
473  col_val = 900;
474  }
475  TString col_num(color(cut + 1, color.Length()));
476  if (col_num.Length() > 0) {
477  if (color.Contains("+")) {
478  col_val += col_num.Atoi();
479  } else {
480  col_val -= col_num.Atoi();
481  }
482  }
483  return col_val;
484  } else {
485  return color.Atoi();
486  }
487 }
488 
489 void FairEventManager::SetTransparency(Bool_t use_xml, Int_t trans)
490 {
491  if (use_xml == kFALSE) { // high transparency
492  Int_t vis_level = gGeoManager->GetVisLevel();
493  TGeoNode *top = gGeoManager->GetTopNode();
494  SetTransparencyForLayer(top, vis_level, trans);
495  } else { // normal transparency
496  if (fXMLConfig != "") {
497  LoadXMLSettings();
498  } else {
499  Int_t vis_level = gGeoManager->GetVisLevel();
500  TGeoNode *top = gGeoManager->GetTopNode();
501  SetTransparencyForLayer(top, vis_level, 0);
502  }
503  }
504  if (gEve->GetGlobalScene()->GetRnrState()) {
505  gEve->GetGlobalScene()->SetRnrState(kFALSE);
506  gEve->GetGlobalScene()->SetRnrState(kTRUE);
507  gEve->Redraw3D();
508  }
509 }
510 
511 void FairEventManager::SwitchBackground(Bool_t light) { gEve->GetViewers()->SwitchColorSet(); }
512 
513 void FairEventManager::SetTransparencyForLayer(TGeoNode *node, Int_t depth, Char_t transparency)
514 {
515  node->GetVolume()->SetTransparency(transparency);
516  if (depth <= 0)
517  return;
518  for (int i = 0; i < node->GetNdaughters(); i++) {
519  TGeoNode *dau = node->GetDaughter(i);
520  SetTransparencyForLayer(dau, depth - 1, transparency);
521  }
522 }
523 
525 {
526  TString filename;
527  if (path == "") {
528  const char *filetypes[] = {"PNG", "*.png", "JPG", "*.jpg", 0, 0};
529  TGFileInfo fi;
530  fi.fFileTypes = filetypes;
531  fi.fIniDir = StrDup(".");
532  new TGFileDialog(gClient->GetRoot(), gEve->GetMainWindow(), kFDSave, &fi);
533  if (fi.fFilename == nullptr)
534  return;
535  filename = fi.fFilename;
536  } else {
537  filename = path;
538  }
539  switch (proj) {
540  case FairEveAnimationControl::eScreenshotType::k3D: {
541  gEve->GetDefaultGLViewer()->SavePicture(filename);
542  } break;
543  case FairEveAnimationControl::eScreenshotType::kXY: {
544  TEveViewer *view = GetRPhiView();
545  TGLViewer *gl = view->GetGLViewer();
546  gl->SavePicture(filename);
547  } break;
548  case FairEveAnimationControl::eScreenshotType::kZ: {
549  TEveViewer *view = GetRhoZView();
550  TGLViewer *gl = view->GetGLViewer();
551  gl->SavePicture(filename);
552  } break;
553  case FairEveAnimationControl::eScreenshotType::kAll: {
554  TString filename_path = filename(0, filename.Last('.'));
555  TString filename_ext = filename(filename.Last('.') + 1, 3);
556  TString filename3d = Form("%s_3d.%s", filename_path.Data(), filename_ext.Data());
557  TString filenameRphi = Form("%s_XY.%s", filename_path.Data(), filename_ext.Data());
558  TString filenameRhoz = Form("%s_Z.%s", filename_path.Data(), filename_ext.Data());
559  gEve->GetDefaultGLViewer()->SavePicture(filename3d);
560  TEveViewer *view = GetRPhiView();
561  TGLViewer *gl = view->GetGLViewer();
562  gl->SavePicture(filenameRphi);
563  view = GetRhoZView();
564  gl = view->GetGLViewer();
565  gl->SavePicture(filenameRhoz);
566  } break;
567  }
568 }
569 
571 {
572  if (fUseTimeOfEvent == kTRUE) {
573  fTimeEvent = FairRootManager::Instance()->GetEventTime();
574  }
575  return fTimeEvent;
576 }
577 
579 {
580  TString stime;
581  stime.Form("%.2f", time);
582  stime += " ns";
583  fEventTimeText->SetText(stime);
584 }
585 
587 {
588  TString text = "Event: ";
589  text += evtNumber;
590  fEventNumberText->SetText(text);
591 }
virtual void PrevEvent()
Int_t GetNChildren() const
Definition: FairXMLNode.h:108
FairXMLNode * GetRootNode() const
Definition: FairXMLNode.h:185
virtual void SetTransparency(Bool_t use_xml, Int_t trans)
void LoadXMLDetector(TGeoNode *node, FairXMLNode *xml, Int_t depth=0)
void Init()
Definition: FairRunAna.cxx:127
TString GetValue() const
Definition: FairXMLNode.h:48
TEveViewer * GetRPhiView() const
virtual void SetEvtTimeText(Double_t time)
Float_t GetEvtTime()
current time in ns to display in the event display. Either set value or event time taken from FairRoo...
void MakeScreenshot(FairEveAnimationControl::eScreenshotType screen, TString def_path="")
FairXMLAttrib * GetAttrib(TString name) const
static FairRootManager * Instance()
ClassImp(FairEventBuilder)
void Run(Int_t NStart=0, Int_t NStop=0)
Definition: FairRunAna.cxx:275
virtual void SetRPhiPlane(Double_t a, Double_t b, Double_t c, Double_t d, TGLViewer::ECameraType camtype)
virtual void Open()
virtual void LoadXMLSettings()
virtual Int_t Color(Int_t pdg)
FairXMLNode * GetChild(TString name, Int_t count=0) const
Double_t GetEventTime()
virtual void Init(Int_t visopt=1, Int_t vislvl=3, Int_t maxvisnds=10000)
Int_t StringToColor(TString color) const
virtual void SwitchBackground(Bool_t light)
virtual void NextEvent()
TVector3 GetWorldSize() const
virtual void DisplaySettings()
virtual void AddParticlesToPdgDataBase(Int_t pdg=0)
static FairEventManager * Instance()
virtual void GotoEvent(Int_t event)
virtual void Close()
virtual void SetEvtNumberText(Int_t evtNumber)
virtual void SetRhoZPlane(Double_t a, Double_t b, Double_t c, Double_t d, TGLViewer::ECameraType camtype)
TEveViewer * GetRhoZView() const