Skip to content

Commit f211017

Browse files
authored
Merge branch 'master' into lobis-quenching
2 parents cc25927 + 714c067 commit f211017

9 files changed

+49
-66
lines changed

.github/pr-badge.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@
1313
message: "Ok: $additions"
1414
color: "green"
1515
when: "$additions < 100"
16-
- imageUrl: "https://gitlab.cern.ch/rest-for-physics/geant4lib/badges/$branchName/pipeline.svg"
17-
url: "https://gitlab.cern.ch/rest-for-physics/geant4lib/-/commits/$branchName"
18-
- imageUrl: "https://github.com/rest-for-physics/geant4lib/actions/workflows/validation.yml/badge.svg?branch=$branchName"
16+
- imageUrl: "https://github.com/rest-for-physics/geant4lib/actions/workflows/frameworkValidation.yml/badge.svg?branch=$branchName"
1917
url: "https://github.com/rest-for-physics/geant4lib/commits/$branchName"

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(LibraryVersion "2.0")
1+
set_library_version(LibraryVersion)
22
add_definitions(-DLIBRARY_VERSION="${LibraryVersion}")
33

44
if (${REST_DECAY0} MATCHES "ON")

inc/TRestGeant4AnalysisProcess.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ 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-
8783
void Initialize() override;
8884

8985
void LoadDefaultConfig();

inc/TRestGeant4EventViewer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#ifndef RestCore_TRestGeant4EventViewer
1616
#define RestCore_TRestGeant4EventViewer
1717

18+
#include "TEveStraightLineSet.h"
1819
#include "TRestEveEventViewer.h"
1920
#include "TRestGeant4Event.h"
2021

@@ -25,6 +26,8 @@ class TRestGeant4EventViewer : public TRestEveEventViewer {
2526
TRestGeant4Event* fG4Event = nullptr;
2627
const TRestGeant4Metadata* fG4Metadata = nullptr;
2728

29+
TEveStraightLineSet* GetTrackEveDrawable(const TRestGeant4Track& track);
30+
2831
public:
2932
void Initialize();
3033
void DeleteCurrentEvent();

inc/TRestGeant4PrimaryGeneratorInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ EnergyDistributionTypes StringToEnergyDistributionTypes(const std::string&);
4848

4949
enum class EnergyDistributionFormulas {
5050
COSMIC_NEUTRONS,
51-
COSMIC,
51+
COSMIC_GAMMAS,
5252
};
5353

5454
std::string EnergyDistributionFormulasToString(const EnergyDistributionFormulas&);

macros/REST_Geant4_ViewEvent.C

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,26 @@
1010
//*** This macro might need update/revision.
1111
//***
1212
//*******************************************************************************************************
13-
Int_t REST_Geant4_ViewEvent(TString fName) {
14-
TRestBrowser* browser = new TRestBrowser("TRestGeant4EventViewer");
13+
Int_t REST_Geant4_ViewEvent(TString fName, Double_t geomScale = 0.1) {
14+
15+
TFile* f = TFile::Open(fName);
16+
17+
TIter nextkey(f->GetListOfKeys());
18+
TKey* key;
19+
Bool_t containsGeometry = false;
20+
while ((key = (TKey*)nextkey())) {
21+
RESTDebug << "Reading key with name : " << key->GetName() << RESTendl;
22+
RESTDebug << "Key type (class) : " << key->GetClassName() << RESTendl;
23+
24+
if (key->GetClassName() == (TString) "TGeoManager") containsGeometry = true;
25+
}
26+
27+
if (!containsGeometry) {
28+
RESTWarning << "The file you are trying to visualize does not contain a geometry file!" << RESTendl;
29+
RESTWarning << "Are you opening the file generated direcly with restG4?" << RESTendl;
30+
}
31+
32+
TRestBrowser* browser = new TRestBrowser("TRestGeant4EventViewer", geomScale);
1533

1634
TRestEvent* eve = new TRestGeant4Event();
1735
browser->SetInputEvent(eve);

src/TRestGeant4AnalysisProcess.cxx

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,6 @@ 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-
}
395390
}
396391
}
397392

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

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-
467440
// process names as named by Geant4
468441
// processes present here will be added to the list of observables which can be used to see if the event
469442
// contains the process of interest.

src/TRestGeant4EventViewer.cxx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include "TRestGeant4EventViewer.h"
1616

17-
#include <TEveStraightLineSet.h>
1817
#include <TRestStringOutput.h>
1918

2019
using namespace std;
@@ -93,20 +92,20 @@ TrackVisualConfiguration GetTrackVisualConfiguration(const TRestGeant4Track& tra
9392
return config;
9493
}
9594

96-
TEveStraightLineSet* GetTrackEveDrawable(const TRestGeant4Track& track) {
95+
TEveStraightLineSet* TRestGeant4EventViewer::GetTrackEveDrawable(const TRestGeant4Track& track) {
9796
auto lineSet = new TEveStraightLineSet(
9897
TString::Format("ID %d | %s | Created by %s | KE: %s", //
9998
track.GetTrackID(), track.GetParticleName().Data(), track.GetCreatorProcess().Data(),
10099
ToEnergyString(track.GetInitialKineticEnergy()).c_str()));
101100

102101
const auto& hits = track.GetHits();
103102
for (unsigned int i = 0; i < hits.GetNumberOfHits() - 1; i++) {
104-
lineSet->AddLine({static_cast<float>(GEOM_SCALE * hits.GetPosition(i).x()),
105-
static_cast<float>(GEOM_SCALE * hits.GetPosition(i).y()),
106-
static_cast<float>(GEOM_SCALE * hits.GetPosition(i).z())}, //
107-
{static_cast<float>(GEOM_SCALE * hits.GetPosition(i + 1).x()),
108-
static_cast<float>(GEOM_SCALE * hits.GetPosition(i + 1).y()),
109-
static_cast<float>(GEOM_SCALE * hits.GetPosition(i + 1).z())});
103+
lineSet->AddLine({static_cast<float>(fGeomScale * hits.GetPosition(i).x()),
104+
static_cast<float>(fGeomScale * hits.GetPosition(i).y()),
105+
static_cast<float>(fGeomScale * hits.GetPosition(i).z())}, //
106+
{static_cast<float>(fGeomScale * hits.GetPosition(i + 1).x()),
107+
static_cast<float>(fGeomScale * hits.GetPosition(i + 1).y()),
108+
static_cast<float>(fGeomScale * hits.GetPosition(i + 1).z())});
110109

111110
const auto config = GetTrackVisualConfiguration(track);
112111
lineSet->SetMainColor(config.fColor);
@@ -213,8 +212,8 @@ void TRestGeant4EventViewer::AddEvent(TRestEvent* event) {
213212
gEve->AddElement(hitPoints, hitsType[processType]);
214213
}
215214
hitsPoints.at(processName)
216-
->SetNextPoint(GEOM_SCALE * position.X(), GEOM_SCALE * position.Y(),
217-
GEOM_SCALE * position.Z());
215+
->SetNextPoint(fGeomScale * position.X(), fGeomScale * position.Y(),
216+
fGeomScale * position.Z());
218217
hitsCounter++;
219218
}
220219
}
@@ -237,8 +236,8 @@ void TRestGeant4EventViewer::AddText(TString text, TVector3 at) {
237236
TEveText* evText = new TEveText(text);
238237
evText->SetName("Event title");
239238
evText->SetFontSize(12);
240-
evText->RefMainTrans().SetPos((at.X() + 15) * GEOM_SCALE, (at.Y() + 15) * GEOM_SCALE,
241-
(at.Z() + 15) * GEOM_SCALE);
239+
evText->RefMainTrans().SetPos((at.X() + 15) * fGeomScale, (at.Y() + 15) * fGeomScale,
240+
(at.Z() + 15) * fGeomScale);
242241

243242
gEve->AddElement(evText);
244243
}
@@ -248,13 +247,13 @@ void TRestGeant4EventViewer::AddMarker(Int_t trkID, TVector3 at, TString name) {
248247
marker->SetName(name);
249248
marker->SetMarkerColor(kMagenta);
250249
marker->SetMarkerStyle(3);
251-
marker->SetPoint(0, at.X() * GEOM_SCALE, at.Y() * GEOM_SCALE, at.Z() * GEOM_SCALE);
250+
marker->SetPoint(0, at.X() * fGeomScale, at.Y() * fGeomScale, at.Z() * fGeomScale);
252251
marker->SetMarkerSize(0.4);
253252
fHitConnectors[trkID]->AddElement(marker);
254253
}
255254

256255
void TRestGeant4EventViewer::NextTrackVertex(Int_t trkID, TVector3 to) {
257-
fHitConnectors[trkID]->SetNextPoint(to.X() * GEOM_SCALE, to.Y() * GEOM_SCALE, to.Z() * GEOM_SCALE);
256+
fHitConnectors[trkID]->SetNextPoint(to.X() * fGeomScale, to.Y() * fGeomScale, to.Z() * fGeomScale);
258257
}
259258

260259
void TRestGeant4EventViewer::AddTrack(Int_t trkID, Int_t parentID, TVector3 from, TString name) {
@@ -271,7 +270,7 @@ void TRestGeant4EventViewer::AddTrack(Int_t trkID, Int_t parentID, TVector3 from
271270
if (name.Contains("alpha")) fHitConnectors[trkID]->SetMainColor(kYellow);
272271
if (name.Contains("neutron")) fHitConnectors[trkID]->SetMainColor(kBlue);
273272

274-
fHitConnectors[trkID]->SetNextPoint(from.X() * GEOM_SCALE, from.Y() * GEOM_SCALE, from.Z() * GEOM_SCALE);
273+
fHitConnectors[trkID]->SetNextPoint(from.X() * fGeomScale, from.Y() * fGeomScale, from.Z() * fGeomScale);
275274

276275
if (parentID >= 0 && fHitConnectors.size() > (unsigned int)parentID)
277276
fHitConnectors[parentID]->AddElement(fHitConnectors[trkID]);
@@ -289,7 +288,7 @@ void TRestGeant4EventViewer::AddParentTrack(Int_t trkID, TVector3 from, TString
289288

290289
fHitConnectors[trkID]->SetMainColor(kWhite);
291290
fHitConnectors[trkID]->SetLineWidth(4);
292-
fHitConnectors[trkID]->SetNextPoint(from.X() * GEOM_SCALE, from.Y() * GEOM_SCALE, from.Z() * GEOM_SCALE);
291+
fHitConnectors[trkID]->SetNextPoint(from.X() * fGeomScale, from.Y() * fGeomScale, from.Z() * fGeomScale);
293292

294293
gEve->AddElement(fHitConnectors[trkID]);
295294
}

src/TRestGeant4PrimaryGeneratorInfo.cxx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ string TRestGeant4PrimaryGeneratorTypes::EnergyDistributionFormulasToString(
163163
switch (type) {
164164
case EnergyDistributionFormulas::COSMIC_NEUTRONS:
165165
return "CosmicNeutrons";
166-
case EnergyDistributionFormulas::COSMIC:
167-
return "Cosmic";
166+
case EnergyDistributionFormulas::COSMIC_GAMMAS:
167+
return "CosmicGammas";
168168
}
169169
cout << "TRestGeant4PrimaryGeneratorTypes::EnergyDistributionFormulasToString - Error - Unknown energy "
170170
"distribution formula"
@@ -177,9 +177,10 @@ EnergyDistributionFormulas TRestGeant4PrimaryGeneratorTypes::StringToEnergyDistr
177177
if (TString(type).EqualTo(EnergyDistributionFormulasToString(EnergyDistributionFormulas::COSMIC_NEUTRONS),
178178
TString::ECaseCompare::kIgnoreCase)) {
179179
return EnergyDistributionFormulas::COSMIC_NEUTRONS;
180-
} else if (TString(type).EqualTo(EnergyDistributionFormulasToString(EnergyDistributionFormulas::COSMIC),
181-
TString::ECaseCompare::kIgnoreCase)) {
182-
return EnergyDistributionFormulas::COSMIC;
180+
} else if (TString(type).EqualTo(
181+
EnergyDistributionFormulasToString(EnergyDistributionFormulas::COSMIC_GAMMAS),
182+
TString::ECaseCompare::kIgnoreCase)) {
183+
return EnergyDistributionFormulas::COSMIC_GAMMAS;
183184
} else {
184185
cout << "TRestGeant4PrimaryGeneratorTypes::StringToEnergyDistributionFormulas - Error - Unknown "
185186
"energyDistributionFormulas: "
@@ -206,13 +207,8 @@ TF1 TRestGeant4PrimaryGeneratorTypes::EnergyDistributionFormulasToRootFormula(
206207
distribution.GetXaxis()->SetTitle("Energy (keV)");
207208
return distribution;
208209
}
209-
case EnergyDistributionFormulas::COSMIC:
210-
const char* title = "Cosmic distribution approximation";
211-
auto distribution = TF1(title, "TMath::Power(x, -2.7)", 1E2, 1E9);
212-
distribution.SetNormalized(true); // Normalized, not really necessary
213-
distribution.SetTitle(title);
214-
distribution.GetXaxis()->SetTitle("Energy (keV)");
215-
return distribution;
210+
case EnergyDistributionFormulas::COSMIC_GAMMAS:
211+
exit(1);
216212
}
217213
cout << "TRestGeant4PrimaryGeneratorTypes::EnergyDistributionFormulasToRootFormula - Error - Unknown "
218214
"energy distribution formula"

0 commit comments

Comments
 (0)