Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing compilation warnings #89

Merged
merged 7 commits into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/04.MuonScan/ValidateCosmicMuonsFromWall.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Int_t ValidateCosmicMuonsFromWall(const char* filename) {
}

cout << "Run entries: " << run.GetEntries() << endl;
std::pair<double, double> nEntriesRange = {900., 1000.};
std::pair<double, double> nEntriesRange = {900., 1050.};
const int entries = run.GetEntries();
if (entries < nEntriesRange.first || entries > nEntriesRange.second) {
cout << "The number of entries (" << entries << ") is out of range: [" << nEntriesRange.first << " - "
Expand Down
2 changes: 1 addition & 1 deletion include/SimulationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class OutputManager {

void RecordStep(const G4Step*);

void AddSensitiveEnergy(Double_t energy, const char* physicalVolumeName);
void AddSensitiveEnergy(Double_t energy);
void AddEnergyToVolumeForParticleForProcess(Double_t energy, const char* volumeName,
const char* particleName, const char* processName);

Expand Down
2 changes: 1 addition & 1 deletion src/DetectorConstruction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ G4VPhysicalVolume* DetectorConstruction::Construct() {
}
}

for (int id = 0; id < restG4Metadata->GetNumberOfActiveVolumes(); id++) {
for (unsigned int id = 0; id < restG4Metadata->GetNumberOfActiveVolumes(); id++) {
TString activeVolumeName = restG4Metadata->GetActiveVolumeName(id);
G4VPhysicalVolume* pVol = GetPhysicalVolume((G4String)activeVolumeName);
if (pVol != nullptr) {
Expand Down
18 changes: 9 additions & 9 deletions src/PhysicsList.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ using namespace std;
PhysicsList::PhysicsList(SimulationManager* simulationManager, TRestGeant4PhysicsLists* physicsLists)
: G4VModularPhysicsList(), fSimulationManager(simulationManager) {
// add new units for radioActive decays
const G4double minute = 60 * second;
const G4double hour = 60 * minute;
const G4double day = 24 * hour;
const G4double year = 365 * day;
new G4UnitDefinition("minute", "min", "Time", minute);
new G4UnitDefinition("hour", "h", "Time", hour);
new G4UnitDefinition("day", "d", "Time", day);
new G4UnitDefinition("year", "y", "Time", year);
const G4double G4minute = 60 * second;
const G4double G4hour = 60 * G4minute;
const G4double G4day = 24 * G4hour;
const G4double G4year = 365 * G4day;
new G4UnitDefinition("minute", "min", "Time", G4minute);
new G4UnitDefinition("hour", "h", "Time", G4hour);
new G4UnitDefinition("day", "d", "Time", G4day);
new G4UnitDefinition("year", "y", "Time", G4year);

defaultCutValue = 0.1 * mm;

Expand Down Expand Up @@ -279,7 +279,7 @@ void PhysicsList::ConstructProcess() {
G4VProcess* decay = nullptr;
G4ProcessManager* tritiumProcessManager = tritium->GetProcessManager();
G4ProcessVector* tritiumProcessVector = tritiumProcessManager->GetAtRestProcessVector();
for (int i = 0; i < tritiumProcessVector->size() && decay == nullptr; i++) {
for (unsigned int i = 0; i < tritiumProcessVector->size() && decay == nullptr; i++) {
if ((*tritiumProcessVector)[i]->GetProcessName() == "Decay")
decay = (*tritiumProcessVector)[i];
}
Expand Down
40 changes: 25 additions & 15 deletions src/PrimaryGeneratorAction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ PrimaryGeneratorAction::PrimaryGeneratorAction(SimulationManager* simulationMana

const auto& primaryGeneratorInfo = restG4Metadata->GetGeant4PrimaryGeneratorInfo();
const string& spatialGeneratorTypeName = primaryGeneratorInfo.GetSpatialGeneratorType().Data();
const auto spatialGeneratorTypeEnum = StringToSpatialGeneratorTypes(spatialGeneratorTypeName);
// const auto spatialGeneratorTypeEnum = StringToSpatialGeneratorTypes(spatialGeneratorTypeName);

const string angularDistTypeName = source->GetAngularDistributionType().Data();
const auto angularDistTypeEnum = StringToAngularDistributionTypes(angularDistTypeName);
Expand Down Expand Up @@ -223,7 +223,7 @@ void PrimaryGeneratorAction::SetEnergyDistributionHistogram(const TH1D* h, doubl
void PrimaryGeneratorAction::SetGeneratorSpatialDensity(TString str) {
auto expression = (string)str;
delete fGeneratorSpatialDensityFunction;
if (expression.find_first_of("xyz") == -1) {
if (expression.find_first_of("xyz") == string::npos) {
fGeneratorSpatialDensityFunction = nullptr;
return;
}
Expand All @@ -248,6 +248,8 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* event) {
const auto& primaryGeneratorInfo = restG4Metadata->GetGeant4PrimaryGeneratorInfo();
const string& spatialGeneratorTypeName = primaryGeneratorInfo.GetSpatialGeneratorType().Data();
const auto spatialGeneratorTypeEnum = StringToSpatialGeneratorTypes(spatialGeneratorTypeName);
// Apparently not used. I comment to avoid compilation warning
// Int_t nParticles = restG4Metadata->GetNumberOfSources();

if (spatialGeneratorTypeEnum == SpatialGeneratorTypes::COSMIC) {
if (fCosmicCircumscribedSphereRadius == 0.) {
Expand Down Expand Up @@ -318,7 +320,8 @@ G4ParticleDefinition* PrimaryGeneratorAction::SetParticleDefinition(Int_t partic
}

if (!fParticle) {
cout << "Particle definition : " << particleName << " not found!" << endl;
G4cout << "Particle definition : " << particleName << " not found!" << G4endl;
G4cout << "Particle source index " << particleSourceIndex << G4endl;
exit(1);
}
}
Expand All @@ -334,8 +337,6 @@ void PrimaryGeneratorAction::SetParticleDirection(Int_t particleSourceIndex,
TRestGeant4Metadata* restG4Metadata = simulationManager->GetRestMetadata();
TRestGeant4ParticleSource* source = restG4Metadata->GetParticleSource(0);

const auto& primaryGeneratorInfo = restG4Metadata->GetGeant4PrimaryGeneratorInfo();

G4ThreeVector direction = {source->GetDirection().X(), source->GetDirection().Y(),
source->GetDirection().Z()};

Expand All @@ -347,11 +348,16 @@ void PrimaryGeneratorAction::SetParticleDirection(Int_t particleSourceIndex,
}

// generator type
const string& spatialGeneratorTypeName = primaryGeneratorInfo.GetSpatialGeneratorType().Data();
const auto spatialGeneratorTypeEnum = StringToSpatialGeneratorTypes(spatialGeneratorTypeName);
/* Apparently not used

const string& spatialGeneratorShapeName = primaryGeneratorInfo.GetSpatialGeneratorShape().Data();
const auto spatialGeneratorShapeEnum = StringToSpatialGeneratorShapes(spatialGeneratorShapeName);
const auto& primaryGeneratorInfo = restG4Metadata->GetGeant4PrimaryGeneratorInfo();

const string& spatialGeneratorTypeName = primaryGeneratorInfo.GetSpatialGeneratorType().Data();
const auto spatialGeneratorTypeEnum = StringToSpatialGeneratorTypes(spatialGeneratorTypeName);

const string& spatialGeneratorShapeName = primaryGeneratorInfo.GetSpatialGeneratorShape().Data();
const auto spatialGeneratorShapeEnum = StringToSpatialGeneratorShapes(spatialGeneratorShapeName);
*/

if (angularDistTypeEnum == AngularDistributionTypes::ISOTROPIC) {
direction = GetIsotropicVector();
Expand Down Expand Up @@ -402,6 +408,9 @@ void PrimaryGeneratorAction::SetParticleDirection(Int_t particleSourceIndex,
// first source is back to back we set it to isotropic
// TVector3 v = restG4Event->GetPrimaryEventDirection(particleSourceIndex - 1);
// v = v.Unit();
//
G4cout << "Back to Back is not implemented now. particleSourceIndex: " << particleSourceIndex
<< G4endl;

// direction.set(-v.X(), -v.Y(), -v.Z());
exit(1);
Expand All @@ -418,8 +427,9 @@ void PrimaryGeneratorAction::SetParticleEnergy(Int_t particleSourceIndex,
auto simulationManager = fSimulationManager;

TRestGeant4Metadata* restG4Metadata = simulationManager->GetRestMetadata();
TRestGeant4ParticleSource* source = restG4Metadata->GetParticleSource(0);
const auto& primaryGeneratorInfo = restG4Metadata->GetGeant4PrimaryGeneratorInfo();
// Apparently not used
// TRestGeant4ParticleSource* source = restG4Metadata->GetParticleSource(0);
// const auto& primaryGeneratorInfo = restG4Metadata->GetGeant4PrimaryGeneratorInfo();

const string angularDistTypeName =
restG4Metadata->GetParticleSource(particleSourceIndex)->GetAngularDistributionType().Data();
Expand Down Expand Up @@ -640,12 +650,12 @@ void PrimaryGeneratorAction::GenPositionOnBoxVolume(double& x, double& y, double
}

void PrimaryGeneratorAction::GenPositionOnBoxSurface(double& x, double& y, double& z) {
cout << __PRETTY_FUNCTION__ << ": not implemented!" << endl;
cout << __PRETTY_FUNCTION__ << ": not implemented! -> " << x << "," << y << "," << z << endl;
exit(1);
}

void PrimaryGeneratorAction::GenPositionOnSphereVolume(double& x, double& y, double& z) {
cout << __PRETTY_FUNCTION__ << ": not implemented!" << endl;
cout << __PRETTY_FUNCTION__ << ": not implemented! -> " << x << "," << y << "," << z << endl;
exit(1);
}

Expand All @@ -665,7 +675,7 @@ void PrimaryGeneratorAction::GenPositionOnSphereSurface(double& x, double& y, do
}

void PrimaryGeneratorAction::GenPositionOnCylinderVolume(double& x, double& y, double& z) {
cout << __PRETTY_FUNCTION__ << ": not implemented!" << endl;
cout << __PRETTY_FUNCTION__ << ": not implemented! -> " << x << "," << y << "," << z << endl;
exit(1);
}

Expand Down Expand Up @@ -759,7 +769,7 @@ void PrimaryGeneratorAction::SetParticleEnergyAndDirection(Int_t particleSourceI

TRestGeant4Metadata* restG4Metadata = simulationManager->GetRestMetadata();
TRestGeant4ParticleSource* source = restG4Metadata->GetParticleSource(0);
const auto& primaryGeneratorInfo = restG4Metadata->GetGeant4PrimaryGeneratorInfo();
// const auto& primaryGeneratorInfo = restG4Metadata->GetGeant4PrimaryGeneratorInfo();

const string angularDistTypeName =
restG4Metadata->GetParticleSource(particleSourceIndex)->GetAngularDistributionType().Data();
Expand Down
6 changes: 3 additions & 3 deletions src/SensitiveDetector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ G4bool SensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*) {
// Since geantinos don't deposit energy, the length traveled inside the volumes is stored as energy
// (mm as keV)
const auto length = step->GetStepLength() / CLHEP::mm;
fSimulationManager->GetOutputManager()->AddSensitiveEnergy(length, volumeName);
fSimulationManager->GetOutputManager()->AddSensitiveEnergy(length);
return true;
} else {
auto energy = step->GetTotalEnergyDeposit() / keV;

if (energy <= 0) {
return true;
}
fSimulationManager->GetOutputManager()->AddSensitiveEnergy(energy, volumeName);
fSimulationManager->GetOutputManager()->AddSensitiveEnergy(energy);
return true;
}
}
}
6 changes: 3 additions & 3 deletions src/SimulationManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ void OutputManager::RecordTrack(const G4Track* track) {
fEvent->InsertTrack(track);

if (fEvent->fSubEventID > 0) {
const auto& lastTrack = fEvent->fTracks.back();
assert(lastTrack.GetTrackID() == track->GetTrackID());
// const auto& lastTrack = ;
assert(fEvent->fTracks.back().GetTrackID() == track->GetTrackID());
// TODO
/*
bool isSubEventPrimary = fEvent->IsTrackSubEventPrimary(lastTrack.fTrackID);
Expand All @@ -358,7 +358,7 @@ void OutputManager::UpdateTrack(const G4Track* track) {

void OutputManager::RecordStep(const G4Step* step) { fEvent->InsertStep(step); }

void OutputManager::AddSensitiveEnergy(Double_t energy, const char* physicalVolumeName) {
void OutputManager::AddSensitiveEnergy(Double_t energy) {
fEvent->AddEnergyToSensitiveVolume(energy);
/*
const TString physicalVolumeNameNew = fSimulationManager->GetRestMetadata()->GetGeant4GeometryInfo()
Expand Down
8 changes: 5 additions & 3 deletions src/StackingAction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ StackingAction::StackingAction(SimulationManager* simulationManager) : fSimulati
G4NeutrinoE::Definition(), G4AntiNeutrinoE::Definition(), G4NeutrinoMu::Definition(),
G4AntiNeutrinoMu::Definition(), G4NeutrinoTau::Definition(), G4AntiNeutrinoTau::Definition(),
};
for (const auto& particle : fParticlesToIgnore) {
//
}

/*
for (const auto& particle : fParticlesToIgnore) {
}
*/
}

G4ClassificationOfNewTrack StackingAction::ClassifyNewTrack(const G4Track* track) {
Expand Down