REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorHitsEventViewer.cxx
1 
15 #include "TRestDetectorHitsEventViewer.h"
16 
17 using namespace std;
18 using namespace TMath;
19 
21 
22 TRestDetectorHitsEventViewer::TRestDetectorHitsEventViewer() { Initialize(); }
23 
24 TRestDetectorHitsEventViewer::~TRestDetectorHitsEventViewer() {
25  // TRestDetectorHitsEventViewer destructor
26 }
27 
28 void TRestDetectorHitsEventViewer::Initialize() {
29  fHitsEvent = new TRestDetectorHitsEvent();
30  fEvent = fHitsEvent;
31 }
32 
33 void TRestDetectorHitsEventViewer::DeleteCurrentEvent() {
34  TRestEveEventViewer::DeleteCurrentEvent();
35  cout << "Removing event" << endl;
36 }
37 
38 void TRestDetectorHitsEventViewer::AddEvent(TRestEvent* ev) {
39  DeleteCurrentEvent();
40 
41  fHitsEvent = (TRestDetectorHitsEvent*)ev;
42 
43  Double_t eDepMin = 1.e6;
44  Double_t eDepMax = 0;
45  Double_t totalEDep = 0;
46 
47  for (unsigned int hit = 0; hit < fHitsEvent->GetNumberOfHits(); hit++) {
48  Double_t eDep = fHitsEvent->GetEnergy(hit);
49  if (eDep > eDepMax) eDepMax = eDep;
50  if (eDep < eDepMin) eDepMin = eDep;
51  totalEDep += eDep;
52  }
53 
54  Double_t slope;
55  if (eDepMin == eDepMax)
56  slope = 0;
57  else
58  slope = (fMaxRadius - fMinRadius) / (eDepMax - eDepMin);
59 
60  Double_t bias = fMinRadius - slope * eDepMin;
61 
62  for (unsigned int hit = 0; hit < fHitsEvent->GetNumberOfHits(); hit++) {
63  Float_t x = fHitsEvent->GetX(hit);
64  Float_t y = fHitsEvent->GetY(hit);
65  Float_t energy = fHitsEvent->GetEnergy(hit);
66  Float_t z = fHitsEvent->GetZ(hit);
67 
68  Float_t radius = slope * energy + bias;
69 
70  if (IsNaN(x)) x = 0;
71  if (IsNaN(y)) y = 0;
72  if (IsNaN(z)) z = 0;
73 
74  AddSphericalHit(x, y, z, radius, energy);
75  }
76 
77  Update();
78 }
A base class for any REST event.
Definition: TRestEvent.h:38