Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update interfaces for insertion of data from restG4 to Geant4Lib #42

Closed
wants to merge 8 commits into from
297 changes: 119 additions & 178 deletions inc/TRestGeant4Event.h

Large diffs are not rendered by default.

32 changes: 17 additions & 15 deletions inc/TRestGeant4Hits.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include "TObject.h"

class G4Step;

class TRestGeant4Hits : public TRestHits {
protected:
TArrayI fVolumeID;
Expand All @@ -37,32 +39,32 @@ class TRestGeant4Hits : public TRestHits {
TArrayF fMomentumDirectionY;
TArrayF fMomentumDirectionZ;

TVector3 GetMomentumDirection(int n) {
return TVector3(fMomentumDirectionX[n], fMomentumDirectionY[n], fMomentumDirectionZ[n]);
TVector3 GetMomentumDirection(int n) const {
return {fMomentumDirectionX[n], fMomentumDirectionY[n], fMomentumDirectionZ[n]};
}

Int_t GetProcess(int n) { return fProcessID[n]; }

void AddG4Hit(TVector3 pos, Double_t en, Double_t hit_global_time, Int_t process, Int_t volume,
Double_t eKin, TVector3 momentumDirection);
void RemoveG4Hits();
Int_t GetProcess(int n) const { return fProcessID[n]; }

Int_t GetHitProcess(int n) { return fProcessID[n]; }
Int_t GetHitVolume(int n) { return fVolumeID[n]; }
Int_t GetVolumeId(int n) { return fVolumeID[n]; }
Double_t GetKineticEnergy(int n) { return fKineticEnergy[n]; }
Int_t GetHitProcess(int n) const { return fProcessID[n]; }
Int_t GetHitVolume(int n) const { return fVolumeID[n]; }
Int_t GetVolumeId(int n) const { return fVolumeID[n]; }
Double_t GetKineticEnergy(int n) const { return fKineticEnergy[n]; }

Double_t GetEnergyInVolume(Int_t volID);
Double_t GetEnergyInVolume(Int_t volID) const;

TVector3 GetMeanPositionInVolume(Int_t volID);
TVector3 GetFirstPositionInVolume(Int_t volID);
TVector3 GetLastPositionInVolume(Int_t volID);
TVector3 GetMeanPositionInVolume(Int_t volID) const;
TVector3 GetFirstPositionInVolume(Int_t volID) const;
TVector3 GetLastPositionInVolume(Int_t volID) const;

// Constructor
TRestGeant4Hits();
// Destructor
virtual ~TRestGeant4Hits();

ClassDef(TRestGeant4Hits, 6); // REST event superclass

public:
/* these methods should only be called from a package linking Geant4, and so they can't be defined here */
void InsertStep(const G4Step*); //!
};
#endif
213 changes: 109 additions & 104 deletions inc/TRestGeant4Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "TObject.h"

class G4Step;
// Perhaps there might be need for a mother class TRestTrack (if there is future
// need)
class TRestGeant4Track : public TObject {
Expand All @@ -36,7 +37,7 @@ class TRestGeant4Track : public TObject {

Int_t fSubEventId;

// We must change this to save space! (Might be not needed afterall)
// We must change this to save space! (Might be not needed after all)
// Int_t fParticle_ID;
TString fParticleName;

Expand All @@ -49,207 +50,211 @@ class TRestGeant4Track : public TObject {
TVector3 fTrackOrigin;

public:
void Initialize() {
inline void Initialize() {
RemoveHits();
fSubEventId = 0.;
}

TRestGeant4Hits* GetHits() { return &fHits; }
inline const TRestGeant4Hits& GetHits() const { return fHits; }

Double_t GetEnergy() { return GetHits()->GetEnergy(); }
inline Double_t GetEnergy() const { return fHits.GetEnergy(); }

Int_t GetNumberOfHits(Int_t volID = -1);
Int_t GetTrackID() { return fTrack_ID; }
Int_t GetParentID() { return fParent_ID; }
Int_t GetNumberOfHits(Int_t volID = -1) const;
inline Int_t GetTrackID() const { return fTrack_ID; }
inline Int_t GetParentID() const { return fParent_ID; }

TString GetParticleName() { return fParticleName; }
EColor GetParticleColor();
inline TString GetParticleName() const { return fParticleName; }
EColor GetParticleColor() const;

Double_t GetGlobalTime() { return fGlobalTimestamp; }
Double_t GetTrackTimeLength() { return fTrackTimestamp; }
Double_t GetKineticEnergy() { return fKineticEnergy; }
Double_t GetTotalDepositedEnergy() { return fHits.GetTotalDepositedEnergy(); }
TVector3 GetTrackOrigin() { return fTrackOrigin; }
Int_t GetSubEventID() { return fSubEventId; }
inline Double_t GetGlobalTime() const { return fGlobalTimestamp; }
inline Double_t GetTrackTimeLength() const { return fTrackTimestamp; }
inline Double_t GetKineticEnergy() const { return fKineticEnergy; }
inline Double_t GetTotalDepositedEnergy() const { return fHits.GetTotalDepositedEnergy(); }
inline TVector3 GetTrackOrigin() const { return fTrackOrigin; }
inline Int_t GetSubEventID() const { return fSubEventId; }

Double_t GetEnergyInVolume(Int_t volID) { return GetHits()->GetEnergyInVolume(volID); }
TVector3 GetMeanPositionInVolume(Int_t volID) { return GetHits()->GetMeanPositionInVolume(volID); }
TVector3 GetFirstPositionInVolume(Int_t volID) { return GetHits()->GetFirstPositionInVolume(volID); }
TVector3 GetLastPositionInVolume(Int_t volID) { return GetHits()->GetLastPositionInVolume(volID); }
inline Double_t GetEnergyInVolume(Int_t volID) const { return fHits.GetEnergyInVolume(volID); }
inline TVector3 GetMeanPositionInVolume(Int_t volID) const {
return fHits.GetMeanPositionInVolume(volID);
}
inline TVector3 GetFirstPositionInVolume(Int_t volID) const {
return fHits.GetFirstPositionInVolume(volID);
}
inline TVector3 GetLastPositionInVolume(Int_t volID) const {
return fHits.GetLastPositionInVolume(volID);
}

void SetSubEventID(Int_t id) { fSubEventId = id; }

void SetTrackID(Int_t id) { fTrack_ID = id; }
void SetParentID(Int_t id) { fParent_ID = id; }
// void SetParticleID( Int_t id ) { fParticle_ID = id; }
void SetParticleName(TString ptcleName) { fParticleName = ptcleName; }
void SetParticleName(const TString& particleName) { fParticleName = particleName; }
void SetGlobalTrackTime(Double_t time) { fGlobalTimestamp = time; }
void SetTrackTimeLength(Double_t time) { fTrackTimestamp = time; }
void SetKineticEnergy(Double_t en) { fKineticEnergy = en; }
void SetTrackOrigin(TVector3 pos) { fTrackOrigin = pos; }
void SetTrackOrigin(const TVector3& pos) { fTrackOrigin = pos; }
void SetTrackOrigin(Double_t x, Double_t y, Double_t z) { fTrackOrigin.SetXYZ(x, y, z); }

void AddG4Hit(TVector3 pos, Double_t en, Double_t hit_global_time, Int_t pcs, Int_t vol, Double_t eKin,
TVector3 momentumDirection) {
fHits.AddG4Hit(pos, en, hit_global_time, pcs, vol, eKin, momentumDirection);
}

Double_t GetTrackLength();
Double_t GetTrackLength() const;

Double_t GetDistance(TVector3 v1, TVector3 v2) {
inline static Double_t GetDistance(const TVector3& v1, const TVector3& v2) {
return TMath::Sqrt((v1.X() - v2.X()) * (v1.X() - v2.X()) + (v1.Y() - v2.Y()) * (v1.Y() - v2.Y()) +
(v1.Z() - v2.Z()) * (v1.Z() - v2.Z()));
}

void RemoveHits() { fHits.RemoveHits(); }
inline void RemoveHits() { fHits.RemoveHits(); }

// TODO move this to a namespace header??
Int_t GetProcessID(TString pcsName);
TString GetProcessName(Int_t id);
Int_t GetProcessID(const TString& pcsName);
TString GetProcessName(Int_t id) const;

Bool_t isRadiactiveDecay() {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if (GetHits()->GetHitProcess(n) == 11) return true;
inline Bool_t isRadiactiveDecay() const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if (fHits.GetHitProcess(n) == 11) return true;
return false;
}
Bool_t isPhotoElectric() {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if (GetHits()->GetHitProcess(n) == 3) return true;
inline Bool_t isPhotoElectric() const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if (fHits.GetHitProcess(n) == 3) return true;
return false;
}
Bool_t isCompton() {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if (GetHits()->GetHitProcess(n) == 7) return true;
inline Bool_t isCompton() const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if (fHits.GetHitProcess(n) == 7) return true;
return false;
}
Bool_t isBremstralung() {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if (GetHits()->GetHitProcess(n) == 5) return true;
inline Bool_t isBremstralung() const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if (fHits.GetHitProcess(n) == 5) return true;
return false;
}

Bool_t ishadElastic() {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if (GetHits()->GetHitProcess(n) == 36) return true;
inline Bool_t ishadElastic() const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if (fHits.GetHitProcess(n) == 36) return true;
return false;
}
Bool_t isneutronInelastic() {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if (GetHits()->GetHitProcess(n) == 37) return true;
inline Bool_t isneutronInelastic() const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if (fHits.GetHitProcess(n) == 37) return true;
return false;
}
Bool_t isnCapture() {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if (GetHits()->GetHitProcess(n) == 38) return true;
inline Bool_t isnCapture() const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if (fHits.GetHitProcess(n) == 38) return true;
return false;
}

Bool_t ishIoni() {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if (GetHits()->GetHitProcess(n) == 33) return true;
inline Bool_t ishIoni() const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if (fHits.GetHitProcess(n) == 33) return true;
return false;
}
Bool_t isphotonNuclear() {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if (GetHits()->GetHitProcess(n) == 42) return true;
inline Bool_t isphotonNuclear() const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if (fHits.GetHitProcess(n) == 42) return true;
return false;
}
// Processes in active volume
Bool_t isRadiactiveDecayInVolume(Int_t volID) {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if ((GetHits()->GetHitProcess(n) == 11) && (GetHits()->GetHitVolume(n)) == volID) return true;
inline Bool_t isRadiactiveDecayInVolume(Int_t volID) const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if ((fHits.GetHitProcess(n) == 11) && (fHits.GetHitVolume(n)) == volID) return true;
return false;
}
Bool_t isPhotoElectricInVolume(Int_t volID) {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if ((GetHits()->GetHitProcess(n) == 3) && (GetHits()->GetHitVolume(n)) == volID) return true;
inline Bool_t isPhotoElectricInVolume(Int_t volID) const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if ((fHits.GetHitProcess(n) == 3) && (fHits.GetHitVolume(n)) == volID) return true;
return false;
}
Bool_t isPhotonNuclearInVolume(Int_t volID) {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if ((GetHits()->GetHitProcess(n) == 42) && (GetHits()->GetHitVolume(n)) == volID) return true;
inline Bool_t isPhotonNuclearInVolume(Int_t volID) const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if ((fHits.GetHitProcess(n) == 42) && (fHits.GetHitVolume(n)) == volID) return true;
return false;
}

Bool_t isComptonInVolume(Int_t volID) {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if ((GetHits()->GetHitProcess(n) == 7) && (GetHits()->GetHitVolume(n)) == volID) return true;
inline Bool_t isComptonInVolume(Int_t volID) const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if ((fHits.GetHitProcess(n) == 7) && (fHits.GetHitVolume(n)) == volID) return true;
return false;
}
Bool_t isBremstralungInVolume(Int_t volID) {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if ((GetHits()->GetHitProcess(n) == 5) && (GetHits()->GetHitVolume(n)) == volID) return true;
inline Bool_t isBremstralungInVolume(Int_t volID) const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if ((fHits.GetHitProcess(n) == 5) && (fHits.GetHitVolume(n)) == volID) return true;
return false;
}

Bool_t isHadElasticInVolume(Int_t volID) {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if ((GetHits()->GetHitProcess(n) == 36) && (GetHits()->GetHitVolume(n)) == volID) return true;
inline Bool_t isHadElasticInVolume(Int_t volID) const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if ((fHits.GetHitProcess(n) == 36) && (fHits.GetHitVolume(n)) == volID) return true;
return false;
}
Bool_t isNeutronInelasticInVolume(Int_t volID) {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if ((GetHits()->GetHitProcess(n) == 37) && (GetHits()->GetHitVolume(n)) == volID) return true;
inline Bool_t isNeutronInelasticInVolume(Int_t volID) const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if ((fHits.GetHitProcess(n) == 37) && (fHits.GetHitVolume(n)) == volID) return true;
return false;
}

Bool_t isNCaptureInVolume(Int_t volID) {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if ((GetHits()->GetHitProcess(n) == 38) && (GetHits()->GetHitVolume(n)) == volID) return true;
inline Bool_t isNCaptureInVolume(Int_t volID) const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if ((fHits.GetHitProcess(n) == 38) && (fHits.GetHitVolume(n)) == volID) return true;
return false;
}

Bool_t isHIoniInVolume(Int_t volID) {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if ((GetHits()->GetHitProcess(n) == 33) && (GetHits()->GetHitVolume(n)) == volID) return true;
inline Bool_t isHIoniInVolume(Int_t volID) const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if ((fHits.GetHitProcess(n) == 33) && (fHits.GetHitVolume(n)) == volID) return true;
return false;
}

Bool_t isAlphaInVolume(Int_t volID) {
inline Bool_t isAlphaInVolume(Int_t volID) const {
if (GetParticleName() == "alpha") {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if ((GetHits()->GetHitVolume(n)) == volID) return true;
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if ((fHits.GetHitVolume(n)) == volID) return true;
}
return false;
}

Bool_t isNeutronInVolume(Int_t volID) {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if ((GetHits()->GetHitVolume(n) == volID) && (GetParticleName() == "neutron")) return true;
inline Bool_t isNeutronInVolume(Int_t volID) const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if ((fHits.GetHitVolume(n) == volID) && (GetParticleName() == "neutron")) return true;
return false;
}

Bool_t isArgonInVolume(Int_t volID) {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if ((GetHits()->GetHitVolume(n) == volID) && (GetParticleName().Contains("Ar"))) return true;
inline Bool_t isArgonInVolume(Int_t volID) const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if ((fHits.GetHitVolume(n) == volID) && (GetParticleName().Contains("Ar"))) return true;
return false;
}

Bool_t isNeonInVolume(Int_t volID) {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if ((GetHits()->GetHitVolume(n) == volID) && (GetParticleName().Contains("Ne"))) return true;
inline Bool_t isNeonInVolume(Int_t volID) const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if ((fHits.GetHitVolume(n) == volID) && (GetParticleName().Contains("Ne"))) return true;
return false;
}

Bool_t isXenonInVolume(Int_t volID) {
for (int n = 0; n < GetHits()->GetNumberOfHits(); n++)
if ((GetHits()->GetHitVolume(n) == volID) && (GetParticleName().Contains("Xe"))) return true;
inline Bool_t isXenonInVolume(Int_t volID) const {
for (int n = 0; n < fHits.GetNumberOfHits(); n++)
if ((fHits.GetHitVolume(n) == volID) && (GetParticleName().Contains("Xe"))) return true;
return false;
}
/////////////////////////////////

/// Prints the track information. N number of hits to print, 0 = all
void PrintTrack(int maxHits = 0);
void PrintTrack(int maxHits = 0) const;

// Int_t GetElement( Int_t n ) { return X.At(n); }

// Int_t GetParticleID();
// Construtor
// Constructor
TRestGeant4Track();
// Destructor
virtual ~TRestGeant4Track();

ClassDef(TRestGeant4Track, 2); // REST event superclass
ClassDef(TRestGeant4Track, 3); // REST event superclass

public:
/* these methods should only be called from a package linking Geant4, and so they can't be defined here */
void InsertStep(const G4Step*); //!
};

#endif
Loading