18#include "TRestGeant4Hits.h"
20#include "TRestGeant4Event.h"
26TRestGeant4Hits::TRestGeant4Hits() :
TRestHits() {}
28TRestGeant4Hits::~TRestGeant4Hits() =
default;
30void TRestGeant4Hits::RemoveG4Hits() {
35 fKineticEnergy.clear();
38Double_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);
50TVector3 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;
68TVector3 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};
76TVector3 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};
86size_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) {
109TString TRestGeant4Hits::GetProcessName(
size_t n)
const {
110 const auto metadata = GetGeant4Metadata();
111 return metadata ==
nullptr ?
"" : metadata->GetGeant4PhysicsInfo().GetProcessName(GetProcessId(n));
114TString 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.