Skip to content

Commit

Permalink
fix for #4
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Apr 28, 2021
1 parent 1c92c6e commit 14b245a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/08.RestGenerator/Pb210FromGenerator.rml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<parameter name="seed" value="17021981"/>
<parameter name="Nevents" value="10"/>

<generator>
<generator type="Custom">
<source use="Pb210FromShielding.root"/>
</generator>

Expand Down
17 changes: 7 additions & 10 deletions restG4.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ int main(int argc, char** argv) {

TH1D* h = (TH1D*)fin.Get(sptName);
;
if (h == NULL) {
if (h == nullptr) {
cout << "REST ERROR when trying to find energy spectrum" << endl;
cout << "File : " << fileFullPath << endl;
cout << "Spectrum name : " << sptName << endl;
Expand All @@ -223,7 +223,7 @@ int main(int argc, char** argv) {
TString sptName = restG4Metadata->GetParticleSource(0).GetAngularName();
TH1D* h = (TH1D*)fin.Get(sptName);
;
if (h == NULL) {
if (h == nullptr) {
cout << "REST ERROR when trying to find angular spectrum" << endl;
cout << "File : " << fileFullPath << endl;
cout << "Spectrum name : " << sptName << endl;
Expand Down Expand Up @@ -271,7 +271,7 @@ int main(int argc, char** argv) {
step->SetSpatialDistribution(spatialDistribution[biasing - 1]);
}

time_t systime = time(NULL);
time_t systime = time(nullptr);
restRun->SetStartTimeStamp((Double_t)systime);

cout << "Events : " << N_events << endl;
Expand Down Expand Up @@ -442,12 +442,9 @@ throw std::exception();
#endif

// job termination
//
delete runManager;

// restRun->CloseOutputFile();

systime = time(NULL);
systime = time(nullptr);
restRun->SetEndTimeStamp((Double_t)systime);
TString Filename = restRun->GetOutputFileName();

Expand Down Expand Up @@ -490,10 +487,10 @@ throw std::exception();
}
// father process
else {
int stat_val = 0;
pid_t child_pid;
// int stat_val = 0;
// pid_t child_pid;

printf("Writing geometry ... \n");
// printf("Writing geometry ... \n");

// child_pid = wait(&stat_val);

Expand Down
12 changes: 4 additions & 8 deletions src/PrimaryGeneratorAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* geant4_event) {
generator_type_name = g4_metadata_parameters::CleanString(generator_type_name);
g4_metadata_parameters::generator_types generator_type;

if (restG4Metadata->GetVerboseLevel() >= REST_Debug) {
cout << "DEBUG: Generator type: " << generator_type_name << endl;
}
debug << "DEBUG: Generator type: " << generator_type_name << endl;

if (g4_metadata_parameters::generator_types_map.count(generator_type_name)) {
generator_type = g4_metadata_parameters::generator_types_map[generator_type_name];
Expand All @@ -73,7 +71,7 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* geant4_event) {
}
cout << endl;

throw "Invalid generator type";
exit(1);
}

// If there are particle collections stored is because we are using a
Expand All @@ -82,8 +80,8 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* geant4_event) {
Int_t rndCollection;
if (generator_type ==
g4_metadata_parameters::generator_types::CUSTOM) { // Generator type "file": no randomisation
static int nEvts = 0;
rndCollection = nEvts++;
static int nEvents = 0;
rndCollection = nEvents++;
} else
rndCollection = (Int_t)(G4UniformRand() * nCollections);

Expand All @@ -104,10 +102,8 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* geant4_event) {

// ParticleDefinition should be always declared first (after position).
SetParticleDefinition(j);

// Particle Direction must be always set before energy
SetParticleEnergy(j);

SetParticleDirection(j);

fParticleGun->GeneratePrimaryVertex(geant4_event);
Expand Down

0 comments on commit 14b245a

Please sign in to comment.