EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EicEventManager.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EicEventManager.cxx
1 //
2 // AYK (ayk@bnl.gov), 2013/06/13
3 //
4 // A simple split interface to FairEventManager
5 //
6 
7 #include "TEveManager.h"
8 #include "TGeoManager.h"
9 #include "TEveGeoNode.h"
10 
11 #include <EicEventManager.h>
12 #include <EicRunAna.h>
13 
14 // ---------------------------------------------------------------------------------------
15 
17 {
18  // Figure out whether FairRunAna instance exists; initialize it if not (and save fRunAna);
19  if (!FairRunAna::Instance()) fRunAna = new EicRunAna();
20 
21  // I guess output is not needed?;
22  fRunAna->SetOutputFile("/dev/null");
23 } // EicEventManager::EicEventManager()
24 
25 // ---------------------------------------------------------------------------------------
26 
27 void EicEventManager::SetInputFile(TString fname)
28 {
29  fRunAna->SetInputFile(fname);
30 } // EicEventManager::SetInputFile()
31 
32 // ---------------------------------------------------------------------------------------
33 
35 {
36  TEveManager::Create();
37 
38  EicRunAna *fRun = dynamic_cast<EicRunAna*>(fRunAna);
39  if (fRun)
40  fRun->Init();
41  // Leave this fall-back option as well, so that both new-style (EicRunAna-based)
42  // and old-style (FairRunAna-based + all the crap to initialize FairRuntimeDb by hand)
43  // will hopefully work;
44  else
45  fRunAna->Init();
46 
47  // Make certain volumes either invisible or transparent; the rest of visual
48  // attributes should be encoded in geometry ROOT files (and propagated to
49  // the overall geometry tree of the simulation setup);
50  if(gGeoManager) {
51  TIter next( gGeoManager->GetListOfVolumes() );
52 
53  TGeoVolume *volume;
54 
55  while ((volume=(TGeoVolume*)next())) {
56  // Make 'cave' volume invisible; FIXME: yes, looks like a hack (may want to
57  // create cave.root files instead of cave.geo ones and fix this);
58  if (TString(volume->GetName()).BeginsWith("cave")) volume->SetVisibility(kFALSE);
59 
60  // Also do not want to see container volumes;
61  if (TString(volume->GetName()).Contains("ContainerVolume")) volume->SetVisibility(kFALSE);
62 
63  // For whatever reason TGeant3 mode in simulation.C requires this;
64  volume->SetLineColor(volume->GetFillColor());
65  volume->SetFillColor(volume->GetFillColor());
66 
67  // FIXME: base-4000 here also looks like a hack; also it should be kept in mind,
68  // that transparency value is set on per-material basis rather than on per-volume
69  // (see SetTransparency() call source code in TGeoVolume); so there better be no
70  // overlap in different subdetector materials (like iron yoke) which are meant to
71  // be transparent per default;
72  if (volume->IsTransparent()) volume->SetTransparency(volume->GetFillStyle()-4000);
73  } //while
74  } //if
75 
76  mInitCallHappened = true;
77 } // EicEventManager::Init()
78 
79 // ---------------------------------------------------------------------------------------
80 
81 void EicEventManager::Run(Int_t visopt, Int_t vislvl, Int_t maxvisnds)
82 {
83  if (!mInitCallHappened) Init();
84 
85  if(gGeoManager) {
86  TGeoNode* N= gGeoManager->GetTopNode();
87  TEveGeoTopNode* TNod=new TEveGeoTopNode(gGeoManager, N, visopt, vislvl, maxvisnds);
88  gEve->AddGlobalElement(TNod);
89  gEve->FullRedraw3D(kTRUE);
90  //gEve->FullRedraw3D(kTRUE, kTRUE);
91  //gGeoManager->SetNsegments(1000);
92  //printf("%d\n", gGeoManager->GetNsegments()); exit(0);
93 
94  fEvent= gEve->AddEvent(this);
95  }
96 } // EicEventManager::Run()
97 
98 // ---------------------------------------------------------------------------------------
99 
100 #if _SAVE_
101  fMan->Init();
102  // Change colors and/or visibility (transparency) if needed;
103  setColors();
104 fMan->Run(0, 6);
105 } // eventDisplay()
106 
107 setColors()
108 {
109  TIter next( gGeoManager->GetListOfVolumes() );
110 
111  while ((volume=(TGeoVolume*)next())) {
112  TString name = volume->GetName();
113 
114  if (name.BeginsWith("Whatever")) {
115  volume->SetLineColor(kMagenta);
116  volume->SetFillColor(kMagenta);
117  } //if
118  } //while
119 } // setColors()
120 #endif
121 
122 // ---------------------------------------------------------------------------------------
123