Skip to content

Commit b901456

Browse files
authored
Merge pull request #96 from rest-for-physics/lobis-analysis
Add observables to record particle names and depth inside shielding
2 parents 393f6fe + cd0ef28 commit b901456

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

inc/TRestGeant4AnalysisProcess.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ class TRestGeant4AnalysisProcess : public TRestEventProcess {
8080
Bool_t fPerProcessSensitiveEnergy = false;
8181
Bool_t fPerProcessSensitiveEnergyNorm = false;
8282

83+
// vectors for size and dimensions of prism used to compute "primaryOriginDistanceToPrism"
84+
TVector3 fPrismCenter = {0, 0, 0};
85+
TVector3 fPrismSize = {0, 0, 0};
86+
8387
void Initialize() override;
8488

8589
void LoadDefaultConfig();

src/TRestGeant4AnalysisProcess.cxx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,11 @@ void TRestGeant4AnalysisProcess::InitProcess() {
387387
fTracksEDepObservables.push_back(fObservables[i]);
388388
fParticleTrackEdep.emplace_back(particleName.Data());
389389
}
390+
391+
if (fObservables[i].find("primaryOriginDistanceToPrism") != string::npos) {
392+
fPrismCenter = Get3DVectorParameterWithUnits("prismCenter");
393+
fPrismSize = Get3DVectorParameterWithUnits("prismSizeXYZ");
394+
}
390395
}
391396
}
392397

@@ -437,6 +442,28 @@ TRestEvent* TRestGeant4AnalysisProcess::ProcessEvent(TRestEvent* inputEvent) {
437442
Double_t size = fOutputG4Event->GetBoundingBoxSize();
438443
SetObservableValue("boundingSize", size);
439444

445+
std::string eventPrimaryParticleName = fOutputG4Event->GetPrimaryEventParticleName(0).Data();
446+
SetObservableValue("eventPrimaryParticleName", eventPrimaryParticleName);
447+
448+
std::string subEventPrimaryParticleName = fOutputG4Event->GetSubEventPrimaryEventParticleName().Data();
449+
SetObservableValue("subEventPrimaryParticleName", subEventPrimaryParticleName);
450+
451+
auto observables = TRestEventProcess::ReadObservables();
452+
auto it = std::find(observables.begin(), observables.end(), "primaryOriginDistanceToPrism");
453+
if (it != observables.end()) {
454+
TVector3 positionCentered = fOutputG4Event->GetPrimaryEventOrigin() - fPrismCenter;
455+
double mx = TMath::Max(0., TMath::Max(-fPrismSize.X() / 2 - positionCentered.X(),
456+
-fPrismSize.X() / 2 + positionCentered.X()));
457+
double my = TMath::Max(0., TMath::Max(-fPrismSize.Y() / 2 - positionCentered.Y(),
458+
-fPrismSize.Y() / 2 + positionCentered.Y()));
459+
double mz = TMath::Max(0., TMath::Max(-fPrismSize.Z() / 2 - positionCentered.Z(),
460+
-fPrismSize.Z() / 2 + positionCentered.Z()));
461+
462+
auto distance = TMath::Sqrt(mx * mx + my * my + mz * mz);
463+
464+
SetObservableValue("primaryOriginDistanceToPrism", distance);
465+
}
466+
440467
// process names as named by Geant4
441468
// processes present here will be added to the list of observables which can be used to see if the event
442469
// contains the process of interest.

0 commit comments

Comments
 (0)