Skip to content

Commit

Permalink
Merge pull request #105 from rest-for-physics/new-version
Browse files Browse the repository at this point in the history
Upgrading version to 2.1
  • Loading branch information
jgalan authored Jun 15, 2023
2 parents b875da5 + 0760aa1 commit 8a10aa1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 45 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(LibraryVersion "2.0")
set(LibraryVersion "2.1")
add_definitions(-DLIBRARY_VERSION="${LibraryVersion}")

if (${REST_DECAY0} MATCHES "ON")
Expand Down
4 changes: 0 additions & 4 deletions inc/TRestGeant4AnalysisProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ class TRestGeant4AnalysisProcess : public TRestEventProcess {
Bool_t fPerProcessSensitiveEnergy = false;
Bool_t fPerProcessSensitiveEnergyNorm = false;

// vectors for size and dimensions of prism used to compute "primaryOriginDistanceToPrism"
TVector3 fPrismCenter = {0, 0, 0};
TVector3 fPrismSize = {0, 0, 0};

void Initialize() override;

void LoadDefaultConfig();
Expand Down
2 changes: 1 addition & 1 deletion inc/TRestGeant4PrimaryGeneratorInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ EnergyDistributionTypes StringToEnergyDistributionTypes(const std::string&);

enum class EnergyDistributionFormulas {
COSMIC_NEUTRONS,
COSMIC,
COSMIC_GAMMAS,
};

std::string EnergyDistributionFormulasToString(const EnergyDistributionFormulas&);
Expand Down
27 changes: 0 additions & 27 deletions src/TRestGeant4AnalysisProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,6 @@ void TRestGeant4AnalysisProcess::InitProcess() {
fTracksEDepObservables.push_back(fObservables[i]);
fParticleTrackEdep.emplace_back(particleName.Data());
}

if (fObservables[i].find("primaryOriginDistanceToPrism") != string::npos) {
fPrismCenter = Get3DVectorParameterWithUnits("prismCenter");
fPrismSize = Get3DVectorParameterWithUnits("prismSizeXYZ");
}
}
}

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

std::string eventPrimaryParticleName = fOutputG4Event->GetPrimaryEventParticleName(0).Data();
SetObservableValue("eventPrimaryParticleName", eventPrimaryParticleName);

std::string subEventPrimaryParticleName = fOutputG4Event->GetSubEventPrimaryEventParticleName().Data();
SetObservableValue("subEventPrimaryParticleName", subEventPrimaryParticleName);

auto observables = TRestEventProcess::ReadObservables();
auto it = std::find(observables.begin(), observables.end(), "primaryOriginDistanceToPrism");
if (it != observables.end()) {
TVector3 positionCentered = fOutputG4Event->GetPrimaryEventOrigin() - fPrismCenter;
double mx = TMath::Max(0., TMath::Max(-fPrismSize.X() / 2 - positionCentered.X(),
-fPrismSize.X() / 2 + positionCentered.X()));
double my = TMath::Max(0., TMath::Max(-fPrismSize.Y() / 2 - positionCentered.Y(),
-fPrismSize.Y() / 2 + positionCentered.Y()));
double mz = TMath::Max(0., TMath::Max(-fPrismSize.Z() / 2 - positionCentered.Z(),
-fPrismSize.Z() / 2 + positionCentered.Z()));

auto distance = TMath::Sqrt(mx * mx + my * my + mz * mz);

SetObservableValue("primaryOriginDistanceToPrism", distance);
}

// process names as named by Geant4
// processes present here will be added to the list of observables which can be used to see if the event
// contains the process of interest.
Expand Down
20 changes: 8 additions & 12 deletions src/TRestGeant4PrimaryGeneratorInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ string TRestGeant4PrimaryGeneratorTypes::EnergyDistributionFormulasToString(
switch (type) {
case EnergyDistributionFormulas::COSMIC_NEUTRONS:
return "CosmicNeutrons";
case EnergyDistributionFormulas::COSMIC:
return "Cosmic";
case EnergyDistributionFormulas::COSMIC_GAMMAS:
return "CosmicGammas";
}
cout << "TRestGeant4PrimaryGeneratorTypes::EnergyDistributionFormulasToString - Error - Unknown energy "
"distribution formula"
Expand All @@ -177,9 +177,10 @@ EnergyDistributionFormulas TRestGeant4PrimaryGeneratorTypes::StringToEnergyDistr
if (TString(type).EqualTo(EnergyDistributionFormulasToString(EnergyDistributionFormulas::COSMIC_NEUTRONS),
TString::ECaseCompare::kIgnoreCase)) {
return EnergyDistributionFormulas::COSMIC_NEUTRONS;
} else if (TString(type).EqualTo(EnergyDistributionFormulasToString(EnergyDistributionFormulas::COSMIC),
TString::ECaseCompare::kIgnoreCase)) {
return EnergyDistributionFormulas::COSMIC;
} else if (TString(type).EqualTo(
EnergyDistributionFormulasToString(EnergyDistributionFormulas::COSMIC_GAMMAS),
TString::ECaseCompare::kIgnoreCase)) {
return EnergyDistributionFormulas::COSMIC_GAMMAS;
} else {
cout << "TRestGeant4PrimaryGeneratorTypes::StringToEnergyDistributionFormulas - Error - Unknown "
"energyDistributionFormulas: "
Expand All @@ -206,13 +207,8 @@ TF1 TRestGeant4PrimaryGeneratorTypes::EnergyDistributionFormulasToRootFormula(
distribution.GetXaxis()->SetTitle("Energy (keV)");
return distribution;
}
case EnergyDistributionFormulas::COSMIC:
const char* title = "Cosmic distribution approximation";
auto distribution = TF1(title, "TMath::Power(x, -2.7)", 1E2, 1E9);
distribution.SetNormalized(true); // Normalized, not really necessary
distribution.SetTitle(title);
distribution.GetXaxis()->SetTitle("Energy (keV)");
return distribution;
case EnergyDistributionFormulas::COSMIC_GAMMAS:
exit(1);
}
cout << "TRestGeant4PrimaryGeneratorTypes::EnergyDistributionFormulasToRootFormula - Error - Unknown "
"energy distribution formula"
Expand Down

0 comments on commit 8a10aa1

Please sign in to comment.