TEventDisplay.cxx
Go to the documentation of this file.
1 #include "TEventDisplay.hxx"
2 #include "TGUIManager.hxx"
6 
7 
8 #include <TEveManager.h>
9 #include <TColor.h>
10 #include <TGLViewer.h>
11 
12 #include <algorithm>
13 #include <cmath>
14 #include <iostream>
15 
17 
19  if (!fEventDisplay) {
22  }
23  return *fEventDisplay;
24 }
25 
27 
29  TEveManager::Create();
30 
31  TGLViewer* glViewer = gEve->GetDefaultGLViewer();
32  glViewer->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
33  glViewer->SetGuideState(TGLUtil::kAxesEdge,kTRUE,kFALSE,0);
34  glViewer->SetDrawCameraCenter(kTRUE);
35 
36  // This is accessed through the GUI() method.
37  fGUIManager = new TGUIManager();
38 
39  // Create the event display manager. This needs the GUI, so it has to be
40  // done after TGUIManager is created.
44 
45  // Create the color palette. This is split into two halves. The first
46  // half is from dark to white and is used for negative values on the
47  // digitization plots, as well has the reconstruction objects. The second
48  // halve is from white to dark and is used for positive values on the
49  // digitization plot.
50  Double_t s[] = { 0.00, 0.20, 0.35, 0.43, 0.45, 0.50, 1.00};
51  Double_t r[] = { 0.00, 0.90, 1.00, 1.00, 1.00, 1.00, 0.00};
52  Double_t g[] = { 0.50, 0.10, 0.75, 0.90, 1.00, 1.00, 0.00};
53  Double_t b[] = { 0.30, 0.00, 0.00, 0.00, 0.00, 1.00, 0.00};
54  fColorCount = 200;
55  unsigned int abc = sizeof(s)/sizeof(s[0]);
56 
57  fColorBase = TColor::CreateGradientColorTable(abc, s, r, g, b,
58  fColorCount);
59 
60  fEnergyPerCharge = 1.0;
61 
62  std::cout << "Event display constructed" << std::endl;
63 
64 
65 }
66 
68  std::cout << "Event display deconstructed" << std::endl;
69 }
70 
71 int EDep::TEventDisplay::LinearColor(double value, double minVal, double maxVal) {
72  int nCol = fColorCount/2;
73  int iValue = nCol*(value - minVal)/(maxVal - minVal);
74  nCol = std::max(0,std::min(iValue,nCol));
75  return fColorBase + nCol;
76 }
77 
78 int EDep::TEventDisplay::LogColor(double value, double minVal, double maxVal,
79  double magScale) {
80  int nCol = fColorCount/2;
81  double scale = std::pow(10.0,magScale);
82  double nvalue = std::max(0.0,std::min((value-minVal)/(maxVal-minVal),1.0));
83  double lValue = std::log10(1.0+scale*nvalue)/magScale;
84  int iValue = nCol*lValue;
85  iValue = std::max(0,std::min(iValue,nCol-1));
86  return fColorBase + iValue;
87 }
static constexpr double g
Definition: Units.h:144
TEventChangeManager * fEventChangeManager
virtual ~TEventDisplay()
Deconstruct the event display.
Handle drawing the GEANT4 (truth) hits.
constexpr T pow(T x)
Definition: pow.h:72
Handle drawing the trajectories.
TGUIManager * fGUIManager
static TEventDisplay & Get(void)
static int max(int a, int b)
int LinearColor(double val, double minVal, double maxVal)
Get a color from the palette using a linear value scale.
static EDep::TEventDisplay * fEventDisplay
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
int LogColor(double val, double minVal, double maxVal, double magScale=5.0)
Get a color from the palette using a logarithmic value scale.
static bool * b
Definition: config.cpp:1043
A singleton class for an event display based on EVE.
static QCString * s
Definition: config.cpp:1042
QTextStream & endl(QTextStream &s)
void AddUpdateHandler(EDep::TVEventChangeHandler *handler)