add Geant namespace

This commit is contained in:
AndreaRigoni
2026-03-14 14:01:44 +00:00
parent e5dfb75262
commit 692cdf7ae3
23 changed files with 76 additions and 26 deletions

View File

@@ -34,7 +34,9 @@
#cmakedefine HAVE_FLOOR
/* Having Geant4 installed */
#ifndef HAVE_GEANT4
#cmakedefine HAVE_GEANT4
#endif
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H

View File

@@ -162,7 +162,7 @@ find_package(Qt6 COMPONENTS Widgets REQUIRED)
find_package(Geant4)
if(Geant4_FOUND)
message(STATUS "Geant4 libs: ${Geant4_LIBRARIES}")
add_compile_definitions(HAVE_GEANT)
add_compile_definitions(HAVE_GEANT4)
set(HAVE_GEANT4 1)
# Sanitize Geant4 targets to remove Qt5 dependencies that conflict with VTK/Qt6

View File

@@ -41,7 +41,7 @@ int main(int argc, char** argv) {
d2.Translate(Vector3f(0, 0, 10));
Scene scene;
Geant::Scene scene;
scene.ConstructWorldBox(&world_box, "G4_AIR");
scene.Initialize();

View File

@@ -1,6 +1,9 @@
#include "ActionInitialization.hh"
#include "EmitterPrimary.hh"
namespace uLib {
namespace Geant {
ActionInitialization::ActionInitialization() : G4VUserActionInitialization() {}
ActionInitialization::~ActionInitialization() {}
@@ -22,4 +25,7 @@ void ActionInitialization::Build() const {
// SetUserAction(new RunAction());
// SetUserAction(new EventAction());
// SetUserAction(new SteppingAction());
}
}
} // namespace Geant
} // namespace uLib

View File

@@ -3,6 +3,9 @@
#include "G4VUserActionInitialization.hh"
namespace uLib {
namespace Geant {
class ActionInitialization : public G4VUserActionInitialization {
public:
ActionInitialization();
@@ -15,4 +18,7 @@ public:
virtual void Build() const;
};
} // namespace Geant
} // namespace uLib
#endif

View File

@@ -12,6 +12,7 @@
#include "G4SystemOfUnits.hh"
namespace uLib {
namespace Geant {
DetectorConstruction::DetectorConstruction(const char *name) : G4VUserDetectorConstruction() {}
@@ -21,9 +22,5 @@ G4VPhysicalVolume *DetectorConstruction::Construct() { return nullptr; }
void DetectorConstruction::ConstructSDandField() {}
}
} // namespace Geant
} // namespace uLib

View File

@@ -9,6 +9,7 @@ class G4VPhysicalVolume;
class G4LogicalVolume;
namespace uLib {
namespace Geant {
class DetectorConstruction : public G4VUserDetectorConstruction {
public:
@@ -20,6 +21,7 @@ public:
virtual void ConstructSDandField();
};
} // namespace Geant
} // namespace uLib
#endif

View File

@@ -10,6 +10,9 @@
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
namespace uLib {
namespace Geant {
EmitterPrimary::EmitterPrimary()
: G4VUserPrimaryGeneratorAction(), fParticleGun(nullptr) {
// Creiamo il ParticleGun impostandolo per sparare 1 particella alla volta
@@ -146,4 +149,7 @@ void QuadMeshEmitterPrimary::GeneratePrimaries(G4Event *anEvent) {
// Keep energy from base class or set here if needed
fParticleGun->GeneratePrimaryVertex(anEvent);
}
}
}
} // namespace Geant
} // namespace uLib

View File

@@ -4,9 +4,15 @@
#include "G4VUserPrimaryGeneratorAction.hh"
#include "globals.hh"
#include "Math/QuadMesh.h"
#include <vector> // Added for std::vector
class G4ParticleGun;
class G4Event;
namespace uLib {
namespace Geant {
class EmitterPrimary : public G4VUserPrimaryGeneratorAction
{
public:
@@ -21,14 +27,6 @@ class EmitterPrimary : public G4VUserPrimaryGeneratorAction
};
#include "Math/QuadMesh.h"
#include <vector> // Added for std::vector
namespace uLib {
class QuadMesh;
}
class QuadMeshEmitterPrimary : public EmitterPrimary
{
public:
@@ -48,6 +46,9 @@ class QuadMeshEmitterPrimary : public EmitterPrimary
void CalculateAreas();
};
} // namespace Geant
} // namespace uLib
#endif

View File

@@ -33,6 +33,7 @@
#include "Detectors/ChamberHitEvent.h"
namespace uLib {
namespace Geant {
class GeantEventData {
public:
@@ -56,6 +57,7 @@ public:
uLibRefMacro(ChEvents, Vector<ChamberHitEventData>)
};
} // namespace Geant
} // namespace uLib
#endif // GEANTEVENT_H

View File

@@ -34,6 +34,7 @@ class G4Element;
class G4Material;
namespace uLib {
namespace Geant {
////////////////////////////////////////////////////////////////////////////////
@@ -65,6 +66,7 @@ private:
}
}

View File

@@ -4,6 +4,9 @@
#include "G4EmStandardPhysics.hh"
#include "G4RadioactiveDecayPhysics.hh"
namespace uLib {
namespace Geant {
PhysicsList::PhysicsList() : G4VModularPhysicsList() {
SetVerboseLevel(1);
@@ -20,3 +23,6 @@ PhysicsList::PhysicsList() : G4VModularPhysicsList() {
PhysicsList::~PhysicsList() {}
void PhysicsList::SetCuts() { G4VModularPhysicsList::SetCuts(); }
} // namespace Geant
} // namespace uLib

View File

@@ -3,6 +3,9 @@
#include "G4VModularPhysicsList.hh"
namespace uLib {
namespace Geant {
class PhysicsList : public G4VModularPhysicsList {
public:
PhysicsList();
@@ -11,4 +14,7 @@ public:
virtual void SetCuts();
};
} // namespace Geant
} // namespace uLib
#endif

View File

@@ -44,6 +44,7 @@
#include "ActionInitialization.hh"
namespace uLib {
namespace Geant {
class SceneDetectorConstruction : public DetectorConstruction {
public:
@@ -146,4 +147,5 @@ void Scene::Initialize() {
d->Initialize();
}
} // namespace Geant
} // namespace uLib

View File

@@ -35,6 +35,7 @@
class G4VPhysicalVolume;
namespace uLib {
namespace Geant {
class Scene : public Object {
public:
@@ -51,5 +52,6 @@ private:
class SceneImpl *d;
};
} // namespace Geant
} // namespace uLib
#endif // SCENE_H

View File

@@ -43,6 +43,7 @@
#include "Solid.h"
namespace uLib {
namespace Geant {
class DetectorsSolidImpl {
public:
@@ -175,4 +176,5 @@ void BoxSolid::Update() {
}
} // namespace Geant
} // namespace uLib

View File

@@ -9,7 +9,7 @@
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
@@ -39,6 +39,7 @@ class G4TessellatedSolid;
class G4Box;
namespace uLib {
namespace Geant {
class Solid : public Object {
public:
@@ -109,6 +110,7 @@ private:
G4Box *m_Solid;
};
} // namespace Geant
} // namespace uLib
#endif // SOLID_H

View File

@@ -13,7 +13,7 @@ int main(int argc, char **argv) {
// runManager->SetUserInitialization(new PhysicsList());
// 3. INIZIALIZZAZIONE DELLE AZIONI (Il nostro generatore!)
runManager->SetUserInitialization(new ActionInitialization());
runManager->SetUserInitialization(new uLib::Geant::ActionInitialization());
// ... Inizializzazione del kernel ( runManager->Initialize(); ), UI manager,
// vis manager, ecc.

View File

@@ -3,6 +3,7 @@ set(TESTS
SolidTest
EventTest
GeantApp
ActionInitialization
)
set(LIBRARIES

View File

@@ -15,7 +15,7 @@ int main() {
// Test Solid initialization and NIST material //
{
Solid solid("test_solid");
Geant::Solid solid("test_solid");
TEST1(solid.GetLogical() != nullptr);
solid.SetNistMaterial("G4_AIR");
@@ -25,7 +25,7 @@ int main() {
// Test TessellatedSolid with a simple mesh //
{
TessellatedSolid tsolid("test_tessellated");
Geant::TessellatedSolid tsolid("test_tessellated");
TEST1(tsolid.GetLogical() != nullptr);
TEST1(tsolid.GetSolid() != nullptr);

View File

@@ -9,7 +9,7 @@ using namespace uLib;
int main() {
uLib::ContainerBox world_box(Vector3f(100, 100, 100));
uLib::Scene scene;
uLib::Geant::Scene scene;
scene.ConstructWorldBox(&world_box, "G4_AIR");
scene.Initialize();

View File

@@ -14,7 +14,7 @@ int main() {
// Test Solid initialization and NIST material //
{
Solid solid("test_solid");
Geant::Solid solid("test_solid");
TEST1(solid.GetLogical() != nullptr);
solid.SetNistMaterial("G4_AIR");
@@ -24,7 +24,7 @@ int main() {
// Test TessellatedSolid with a simple mesh //
{
TessellatedSolid tsolid("test_tessellated");
Geant::TessellatedSolid tsolid("test_tessellated");
TEST1(tsolid.GetLogical() != nullptr);
TEST1(tsolid.GetSolid() != nullptr);

View File

@@ -1,6 +1,9 @@
#if !defined(HAVE_GEANT4) && !defined(HEP_SYSTEM_OF_UNITS_H) && !defined(HEP_PHYSICAL_CONSTANTS_H)
#ifndef CLHEP_defs_h
#define CLHEP_defs_h
namespace CLHEP {
@@ -365,4 +368,6 @@ static constexpr double universe_mean_density = 1.e-25*g/cm3;
} // namespace CLHEP
#endif
#endif // CLHEP_defs_h
#endif // HAVE_GEANT4 / CLHEP checks