Skip to content

Commit

Permalink
Merge pull request #38 from rest-for-physics/lobis-add-const-to-getters
Browse files Browse the repository at this point in the history
Made small changes necessary for rest-for-physics/geant4lib#41
  • Loading branch information
lobis authored Apr 5, 2022
2 parents 587294f + 81f9df1 commit 49d0345
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
29 changes: 14 additions & 15 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
image: ghcr.io/lobis/root-geant4-garfield:cpp17_ROOT-v6-26-00_Geant4-v10.4.3_Garfield-af4a1451
#image: nkx1231/root6-geant4-garfield:0.8
image: ghcr.io/lobis/root-geant4-garfield:rest-for-physics

stages:
- build
Expand All @@ -19,7 +18,7 @@ before_script:

# This is the one we use to run validations tests. We save the installation as an artifact.
Build and Install:
type: build
stage: build
script:
- echo "**${CI_PROJECT_DIR}**"
- git clone https://github.com/rest-for-physics/framework.git framework
Expand Down Expand Up @@ -51,7 +50,7 @@ Build and Install:
expire_in: 1 day

Build Standalone:
type: build-standalone
stage: build-standalone
script:
- echo "**${CI_PROJECT_DIR}**"
- cd ${CI_PROJECT_DIR}/
Expand All @@ -65,13 +64,13 @@ Build Standalone:
- rm -rf ${CI_PROJECT_DIR}/install-standalone

Load REST Libraries:
type: loadRESTLibs
stage: loadRESTLibs
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- restRoot -b -q

01_NLDBD:
type: examples
stage: examples
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/install/examples/restG4/01.NLDBD/
Expand All @@ -80,7 +79,7 @@ Load REST Libraries:
- restRoot -b -q Validate.C'("Run00001_NLDBD_Test.root")'

03_Fluorescence:
type: examples
stage: examples
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/install/examples/restG4/03.Fluorescence/
Expand All @@ -90,7 +89,7 @@ Load REST Libraries:
- restRoot -b -q Validate.C'("Run00111_g4Analysis_Gamma_rest.root")'

04_MuonScan:
type: examples
stage: examples
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/install/examples/restG4/04.MuonScan/
Expand All @@ -101,23 +100,23 @@ Load REST Libraries:
- restRoot -b -q ValidateWall.C'("Run00111_restG4_MuonsFromWall_rest.root")'

05_PandaXIII:
type: examples
stage: examples
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/install/examples/restG4/05.PandaXIII/
- restG4 Xe136bb0n.rml
- restRoot -b -q ValidateG4.C'("Xe136bb0n_n2E06.root")'

06_IonRecoils:
type: examples
stage: examples
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/install/examples/restG4/06.IonRecoils/
- restG4 recoils.rml
- restRoot -b -q Validate.C'("Run00001_F20_Recoils.root")'

07_FullChainDecay:
type: examples
stage: examples
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/install/examples/restG4/07.FullChainDecay/
Expand All @@ -130,7 +129,7 @@ Load REST Libraries:
- restRoot -b -q Validate.C'("Run00002_Be7_SingleChainDecay.root", 1)'

08_Alphas:
type: examples
stage: examples
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/install/examples/restG4/08.Alphas/
Expand All @@ -151,23 +150,23 @@ Load REST Libraries:
- restRoot -b -q Validate.C

09_Pb210_Shielding:
type: examples
stage: examples
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/install/examples/restG4/09.Pb210_Shield/
- restG4 Pb210.rml
- restRoot -b -q Validate.C'("Run00001_Pb210_Shielding.root")'

10_Geometries:
type: examples
stage: examples
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/install/examples/restG4/10.Geometries/
- restG4 Assembly.rml
- restRoot -b -q Validate.C'("Run00001_Assembly_Assembly.root")'

11_Xrays:
type: examples
stage: examples
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/install/examples/restG4/11.Xrays/
Expand Down
24 changes: 12 additions & 12 deletions src/EventAction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ void EventAction::FillSubEvent(Int_t subId) {
}

for (int n = 0; n < restG4Event->GetNumberOfTracks(); n++) {
TRestGeant4Track* tck = restG4Event->GetTrack(n);
const auto& tck = restG4Event->GetTrack(n);

if (tck->GetSubEventID() == subId)
if (tck->GetNumberOfHits() > 0 || restG4Metadata->RegisterEmptyTracks()) {
subRestG4Event->AddTrack(*tck);
if (tck.GetSubEventID() == subId)
if (tck.GetNumberOfHits() > 0 || restG4Metadata->RegisterEmptyTracks()) {
subRestG4Event->AddTrack(tck);
}
}

Expand All @@ -206,10 +206,10 @@ void EventAction::ReOrderTrackIds(Int_t subId) {

if (subId > 0) {
for (int n = 0; n < restG4Event->GetNumberOfTracks(); n++) {
TRestGeant4Track* tck = restG4Event->GetTrack(n);
const auto& tck = restG4Event->GetTrack(n);

if (tck->GetSubEventID() == subId - 1)
if (tck->isRadiactiveDecay()) subRestG4Event->SetSubEventTag(tck->GetParticleName());
if (tck.GetSubEventID() == subId - 1)
if (tck.isRadiactiveDecay()) subRestG4Event->SetSubEventTag(tck.GetParticleName());
}
}

Expand All @@ -218,27 +218,27 @@ void EventAction::ReOrderTrackIds(Int_t subId) {
Int_t nTracks = subRestG4Event->GetNumberOfTracks();

for (int i = 0; i < nTracks; i++) {
TRestGeant4Track* tr = subRestG4Event->GetTrack(i);
const auto& tr = subRestG4Event->GetTrackPointer(i);
tr->SetTrackID(tr->GetTrackID() - lowestID + 1);
tr->SetParentID(tr->GetParentID() - lowestID + 1);
if (tr->GetParentID() < 0) tr->SetParentID(0);
}

for (int i = 0; i < nTracks; i++) {
TRestGeant4Track* tr = subRestG4Event->GetTrack(i);
TRestGeant4Track* tr = subRestG4Event->GetTrackPointer(i);
Int_t id = tr->GetTrackID();

if (id - i != 1) {
// Changing track ids
tr->SetTrackID(i + 1);
for (int t = i + 1; t < subRestG4Event->GetNumberOfTracks(); t++) {
TRestGeant4Track* tr2 = subRestG4Event->GetTrack(t);
TRestGeant4Track* tr2 = subRestG4Event->GetTrackPointer(t);
if (tr2->GetTrackID() == i + 1) tr2->SetTrackID(id);
}

// Changing parent ids
for (int t = 0; t < subRestG4Event->GetNumberOfTracks(); t++) {
TRestGeant4Track* tr2 = subRestG4Event->GetTrack(t);
TRestGeant4Track* tr2 = subRestG4Event->GetTrackPointer(t);
if (tr2->GetParentID() == id)
tr2->SetParentID(i + 1);
else if (tr2->GetParentID() == i + 1)
Expand All @@ -255,7 +255,7 @@ int EventAction::SetTrackSubEventIDs() {
// reorder tracks
map<int, TRestGeant4Track*> tracks;
for (int n = 0; n < nTracks; n++) {
TRestGeant4Track* track = restG4Event->GetTrack(n);
TRestGeant4Track* track = restG4Event->GetTrackPointer(n);
tracks[track->GetTrackID()] = track;
}

Expand Down

0 comments on commit 49d0345

Please sign in to comment.