add geant4 scene and gcompose app
This commit is contained in:
23
src/HEP/Geant/testing/ActionInitialization.cpp
Normal file
23
src/HEP/Geant/testing/ActionInitialization.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "HEP/Geant/ActionInitialization.hh" // Il file appena creato
|
||||
#include "G4RunManagerFactory.hh" // Per il RunManager moderno
|
||||
// ... altri include (DetectorConstruction, PhysicsList, ecc.)
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// Creazione del Run Manager
|
||||
auto *runManager = G4RunManagerFactory::CreateRunManager();
|
||||
|
||||
// 1. Inizializzazione della Geometria
|
||||
// runManager->SetUserInitialization(new DetectorConstruction());
|
||||
|
||||
// 2. Inizializzazione della Fisica
|
||||
// runManager->SetUserInitialization(new PhysicsList());
|
||||
|
||||
// 3. INIZIALIZZAZIONE DELLE AZIONI (Il nostro generatore!)
|
||||
runManager->SetUserInitialization(new ActionInitialization());
|
||||
|
||||
// ... Inizializzazione del kernel ( runManager->Initialize(); ), UI manager,
|
||||
// vis manager, ecc.
|
||||
|
||||
delete runManager;
|
||||
return 0;
|
||||
}
|
||||
14
src/HEP/Geant/testing/CMakeLists.txt
Normal file
14
src/HEP/Geant/testing/CMakeLists.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
# TESTS
|
||||
set(TESTS
|
||||
SolidTest
|
||||
EventTest
|
||||
GeantApp
|
||||
)
|
||||
|
||||
set(LIBRARIES
|
||||
${PACKAGE_LIBPREFIX}Core
|
||||
${PACKAGE_LIBPREFIX}Math
|
||||
${PACKAGE_LIBPREFIX}Geant
|
||||
Eigen3::Eigen
|
||||
)
|
||||
uLib_add_tests(Geant)
|
||||
72
src/HEP/Geant/testing/EventTest.cpp
Normal file
72
src/HEP/Geant/testing/EventTest.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
#include "Geant/Solid.h"
|
||||
#include "HEP/Geant/GeantEvent.h"
|
||||
#include "Math/TriangleMesh.h"
|
||||
#include "testing-prototype.h"
|
||||
#include <Geant4/G4Material.hh>
|
||||
#include <Geant4/G4NistManager.hh>
|
||||
#include <Geant4/G4LogicalVolume.hh>
|
||||
#include <Geant4/G4TessellatedSolid.hh>
|
||||
#include <string.h>
|
||||
|
||||
using namespace uLib;
|
||||
|
||||
int main() {
|
||||
BEGIN_TESTING(Geant Event);
|
||||
|
||||
// Test Solid initialization and NIST material //
|
||||
{
|
||||
Solid solid("test_solid");
|
||||
TEST1(solid.GetLogical() != nullptr);
|
||||
|
||||
solid.SetNistMaterial("G4_AIR");
|
||||
TEST1(solid.GetMaterial() != nullptr);
|
||||
TEST1(solid.GetMaterial()->GetName() == "G4_AIR");
|
||||
}
|
||||
|
||||
// Test TessellatedSolid with a simple mesh //
|
||||
{
|
||||
TessellatedSolid tsolid("test_tessellated");
|
||||
TEST1(tsolid.GetLogical() != nullptr);
|
||||
TEST1(tsolid.GetSolid() != nullptr);
|
||||
|
||||
// cube mesh //
|
||||
TriangleMesh mesh;
|
||||
mesh.AddPoint(Vector3f(0,0,0));
|
||||
mesh.AddPoint(Vector3f(1,0,0));
|
||||
mesh.AddPoint(Vector3f(0,1,0));
|
||||
mesh.AddPoint(Vector3f(1,1,0));
|
||||
mesh.AddPoint(Vector3f(0,0,1));
|
||||
mesh.AddPoint(Vector3f(1,0,1));
|
||||
mesh.AddPoint(Vector3f(0,1,1));
|
||||
mesh.AddPoint(Vector3f(1,1,1));
|
||||
|
||||
// create triangles (consistent outward winding) //
|
||||
// bottom (z=0)
|
||||
mesh.AddTriangle(Vector3i(0,2,3));
|
||||
mesh.AddTriangle(Vector3i(0,3,1));
|
||||
// top (z=1)
|
||||
mesh.AddTriangle(Vector3i(4,5,7));
|
||||
mesh.AddTriangle(Vector3i(4,7,6));
|
||||
// left (x=0)
|
||||
mesh.AddTriangle(Vector3i(0,4,6));
|
||||
mesh.AddTriangle(Vector3i(0,6,2));
|
||||
// right (x=1)
|
||||
mesh.AddTriangle(Vector3i(1,3,7));
|
||||
mesh.AddTriangle(Vector3i(1,7,5));
|
||||
// front (y=0)
|
||||
mesh.AddTriangle(Vector3i(0,1,5));
|
||||
mesh.AddTriangle(Vector3i(0,5,4));
|
||||
// back (y=1)
|
||||
mesh.AddTriangle(Vector3i(2,6,7));
|
||||
mesh.AddTriangle(Vector3i(2,7,3));
|
||||
|
||||
|
||||
|
||||
tsolid.SetMesh(mesh);
|
||||
// GeantEvent geant_event;
|
||||
|
||||
|
||||
}
|
||||
|
||||
END_TESTING
|
||||
}
|
||||
18
src/HEP/Geant/testing/GeantApp.cpp
Normal file
18
src/HEP/Geant/testing/GeantApp.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
#include "Math/ContainerBox.h"
|
||||
#include "Math/Dense.h"
|
||||
#include "HEP/Geant/Scene.h"
|
||||
|
||||
using namespace uLib;
|
||||
|
||||
int main() {
|
||||
|
||||
uLib::ContainerBox world_box(Vector3f(100, 100, 100));
|
||||
uLib::Scene scene;
|
||||
|
||||
scene.ConstructWorldBox(&world_box, "G4_AIR");
|
||||
scene.Initialize();
|
||||
|
||||
return 0;
|
||||
}
|
||||
69
src/HEP/Geant/testing/SolidTest.cpp
Normal file
69
src/HEP/Geant/testing/SolidTest.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#include "Geant/Solid.h"
|
||||
#include "Math/TriangleMesh.h"
|
||||
#include "testing-prototype.h"
|
||||
#include <Geant4/G4Material.hh>
|
||||
#include <Geant4/G4NistManager.hh>
|
||||
#include <Geant4/G4LogicalVolume.hh>
|
||||
#include <Geant4/G4TessellatedSolid.hh>
|
||||
#include <string.h>
|
||||
|
||||
using namespace uLib;
|
||||
|
||||
int main() {
|
||||
BEGIN_TESTING(Geant Solid);
|
||||
|
||||
// Test Solid initialization and NIST material //
|
||||
{
|
||||
Solid solid("test_solid");
|
||||
TEST1(solid.GetLogical() != nullptr);
|
||||
|
||||
solid.SetNistMaterial("G4_AIR");
|
||||
TEST1(solid.GetMaterial() != nullptr);
|
||||
TEST1(solid.GetMaterial()->GetName() == "G4_AIR");
|
||||
}
|
||||
|
||||
// Test TessellatedSolid with a simple mesh //
|
||||
{
|
||||
TessellatedSolid tsolid("test_tessellated");
|
||||
TEST1(tsolid.GetLogical() != nullptr);
|
||||
TEST1(tsolid.GetSolid() != nullptr);
|
||||
|
||||
// cube mesh //
|
||||
TriangleMesh mesh;
|
||||
mesh.AddPoint(Vector3f(0,0,0));
|
||||
mesh.AddPoint(Vector3f(1,0,0));
|
||||
mesh.AddPoint(Vector3f(0,1,0));
|
||||
mesh.AddPoint(Vector3f(1,1,0));
|
||||
mesh.AddPoint(Vector3f(0,0,1));
|
||||
mesh.AddPoint(Vector3f(1,0,1));
|
||||
mesh.AddPoint(Vector3f(0,1,1));
|
||||
mesh.AddPoint(Vector3f(1,1,1));
|
||||
|
||||
// create triangles (consistent outward winding) //
|
||||
// bottom (z=0)
|
||||
mesh.AddTriangle(Vector3i(0,2,3));
|
||||
mesh.AddTriangle(Vector3i(0,3,1));
|
||||
// top (z=1)
|
||||
mesh.AddTriangle(Vector3i(4,5,7));
|
||||
mesh.AddTriangle(Vector3i(4,7,6));
|
||||
// left (x=0)
|
||||
mesh.AddTriangle(Vector3i(0,4,6));
|
||||
mesh.AddTriangle(Vector3i(0,6,2));
|
||||
// right (x=1)
|
||||
mesh.AddTriangle(Vector3i(1,3,7));
|
||||
mesh.AddTriangle(Vector3i(1,7,5));
|
||||
// front (y=0)
|
||||
mesh.AddTriangle(Vector3i(0,1,5));
|
||||
mesh.AddTriangle(Vector3i(0,5,4));
|
||||
// back (y=1)
|
||||
mesh.AddTriangle(Vector3i(2,6,7));
|
||||
mesh.AddTriangle(Vector3i(2,7,3));
|
||||
|
||||
|
||||
|
||||
tsolid.SetMesh(mesh);
|
||||
TEST1(tsolid.GetSolid()->GetNumberOfFacets() == 12);
|
||||
}
|
||||
|
||||
END_TESTING
|
||||
}
|
||||
37
src/HEP/Geant/testing/testing-prototype.h
Normal file
37
src/HEP/Geant/testing/testing-prototype.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
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.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define BEGIN_TESTING(name) \
|
||||
static int _fail = 0; \
|
||||
printf("..:: Testing " #name " ::..\n");
|
||||
|
||||
#define TEST1(val) _fail += (val)==0
|
||||
#define TEST0(val) _fail += (val)!=0
|
||||
#define END_TESTING return _fail;
|
||||
|
||||
Reference in New Issue
Block a user