18 #include "TRestGeant4Hits.h"
20 #include "TRestGeant4Event.h"
26 TRestGeant4Hits::TRestGeant4Hits() :
TRestHits() {}
28 TRestGeant4Hits::~TRestGeant4Hits() =
default;
30 void TRestGeant4Hits::RemoveG4Hits() {
35 fKineticEnergy.clear();
38 Double_t TRestGeant4Hits::GetEnergyInVolume(Int_t volumeID)
const {
41 for (
size_t n = 0; n < GetNumberOfHits(); n++) {
42 if (fVolumeID[n] == volumeID) {
43 energy += GetEnergy(n);
50 TVector3 TRestGeant4Hits::GetMeanPositionInVolume(Int_t volumeID)
const {
53 for (
size_t n = 0; n < GetNumberOfHits(); n++)
54 if (fVolumeID[n] == volumeID) {
56 energy += GetEnergy(n);
60 Double_t nan = TMath::QuietNaN();
61 return {nan, nan, nan};
64 pos = (1. / energy) * pos;
68 TVector3 TRestGeant4Hits::GetFirstPositionInVolume(Int_t volumeID)
const {
69 for (
size_t n = 0; n < GetNumberOfHits(); n++)
70 if (fVolumeID[n] == volumeID)
return GetPosition(n);
72 Double_t nan = TMath::QuietNaN();
73 return {nan, nan, nan};
76 TVector3 TRestGeant4Hits::GetLastPositionInVolume(Int_t volumeID)
const {
77 for (
int n = GetNumberOfHits() - 1; n >= 0; n--) {
78 if (fVolumeID[n] == volumeID) {
82 Double_t nan = TMath::QuietNaN();
83 return {nan, nan, nan};
86 size_t TRestGeant4Hits::GetNumberOfHitsInVolume(Int_t volumeID)
const {
88 for (
size_t n = 0; n < GetNumberOfHits(); n++) {
89 if (fVolumeID[n] == volumeID) {
98 if (fTrack !=
nullptr) {
99 event = fTrack->GetEvent();
103 if (event ==
nullptr) {
109 TString TRestGeant4Hits::GetProcessName(
size_t n)
const {
110 const auto metadata = GetGeant4Metadata();
111 return metadata ==
nullptr ?
"" : metadata->GetGeant4PhysicsInfo().GetProcessName(GetProcessId(n));
114 TString TRestGeant4Hits::GetVolumeName(
size_t n)
const {
115 const auto metadata = GetGeant4Metadata();
116 return metadata ==
nullptr ?
"" : metadata->GetGeant4GeometryInfo().GetVolumeFromID(GetVolumeId(n));
An event class to store geant4 generated event information.
It saves a 3-coordinate position and an energy for each punctual deposition.
virtual void RemoveHits()
It removes all hits inside the class.
TVector3 GetPosition(int n) const
It returns the position of hit number n.