Import Geant4 11.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2023-12-08 10:43:34 +01:00
parent dd1f179cda
commit 860a2b92bf
3962 changed files with 139318 additions and 164259 deletions
@@ -11,7 +11,7 @@
The rotation matrices themselves, direct or inverse, can be explicitely computed
by users, or built with various G4 build-in transformations methods,
like axial rotations.
\section Transforms_s1 Geometry construction
Two G4Trd volumes (daughters) are placed within a G4Tubs (mother), in such a way
@@ -20,7 +20,7 @@
The various ways of placement are implemented in the DetectorConstruction class
in the following private functions:
- \link DetectorConstruction::PlaceWithDirectMatrix() PlaceWithDirectMatrix() \endlink \n
This method is using G4PVPlacement with G4Transform3D, which is constructed from a rotation matrix (G4RotationMatrix) and a translation vector (G4ThreeVector). The rotation and translation in this case represent the active transformation: the solid itself is moved by rotating and translating it to bring it into the system of coordinates of the mother volume.\n
The rotation matrix is defined via the daughter frame axes with respect to the mother frame.\n\n
@@ -31,7 +31,7 @@
The rotation matrix is defined again via the daughter frame axes with respect to the mother frame. \n\n
- \link DetectorConstruction::PlaceWithAxialRotations() PlaceWithAxialRotations() \endlink \n
This method is using G4PVPlacement with G4Transform3D again, but in difference from
This method is using G4PVPlacement with G4Transform3D again, but in difference from
PlaceWithDirectMatrix(), the rotation matrix is defined via rotate[X,Y,Z]() member functions of G4RotationMatrix. \n\n
- \link DetectorConstruction::PlaceWithEulerAngles() PlaceWithEulerAngles() \endlink \n
@@ -39,66 +39,66 @@
- \link DetectorConstruction::PlaceWithReflections() PlaceWithReflections() \endlink \n
In this method, in addition to two positions defined via "PlaceWithAxialRotations" method, two more positions including reflection symmetry are defined.
When reflections are present in geometry, the placements have to be applied
When reflections are present in geometry, the placements have to be applied
via G4ReflectionFactory::Place() method, where a G4Transform3D with reflection
can be used.
can be used.
These functions are then called from the Construct() function.
All methods define exactly same geometry except for the placement
with reflection where trapezoids are placed with their symmetry axis
in parallel with z-axis in order to make easier to check reflection
visually.
All methods define exactly same geometry except for the placement
with reflection where trapezoids are placed with their symmetry axis
in parallel with z-axis in order to make easier to check reflection
visually.
The method of placement can be selected interactively via the command
(see DetectorMessenger and transforms.in):
\verbatim
\verbatim
/placement/setMethod method
where method = WithDirectMatrix, WithInverseMatrix, WithAxialRotations,
WithEulerAngles, WithReflections
\endverbatim
\section Transforms_s2 Physics list
PhysicsList.cc defines only geantino and transportation process.
\section Transforms_s3 Primary generator
Default kinematic is a geantino, at coordinate origin.
Can be changed with particleGun commands.
\section Transforms_s4 Physics
No physics; only transportation.
\section Transforms_s5 Visualisation
In interactive mode, visualization manager is set in the main().
Initialisation of the drawing is done via the commands
/vis/.. in the macro vis.mac : /control/execute vis.mac
\section Transforms_s6 How to start ?
- Execute transforms in 'interactive mode' with visualization
\verbatim
\verbatim
% transforms
....
Idle> ---> type your commands. For instance:
Idle> /placement/setMethod WithInverseMatrix
Idle> /control/execute vis.mac
Idle> /tracking/verbose 1
Idle> /run/beamOn 1
Idle> /run/beamOn 1
Idle> exit
\endverbatim
\endverbatim
or, simply
\verbatim
Idle> /control/execute rotations.mac
\verbatim
Idle> /control/execute rotations.mac
Idle> /control/execute reflections.mac
\endverbatim
\endverbatim
- Execute transforms in 'batch' mode from macro files
\verbatim
% transforms transforms.in
\verbatim
% transforms transforms.in
\endverbatim
*/
@@ -1,6 +1,6 @@
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 3.16...3.21)
cmake_minimum_required(VERSION 3.16...3.27)
project(transforms)
#----------------------------------------------------------------------------
@@ -23,7 +23,7 @@ include(${Geant4_USE_FILE})
#----------------------------------------------------------------------------
# Locate sources and headers for this project
#
include_directories(${PROJECT_SOURCE_DIR}/include
include_directories(${PROJECT_SOURCE_DIR}/include
${Geant4_INCLUDE_DIR})
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
+18 -14
View File
@@ -5,13 +5,17 @@ which **must** added in reverse chronological order (newest at the top). It must
be used as a substitute for writing good git commit messages!
## 2023-07-04 Hrivnacova (exTransforms-V11-01-00)
- Clang-tidy fixes, new coding guidelines
- Clean-up trailing whitespaces
## 2021-12-10 Ben Morgan (exTransforms-V11-00-00)
- Change to new Markdown History format
---
# History entries prior to 11.0
04-06-21 I. Hrivnacova (exTransforms-V10-07-02)
- added cleaning of the reflection factory
@@ -19,11 +23,11 @@ be used as a substitute for writing good git commit messages!
- transforms.cc : initialize visualization only in interactive mode
- PlaceWithReflections : permute z-positions
- DetectorMessenger : AvailableForStates(G4State_PreInit,G4State_Idle)
- new macros : rotations.mac reflections.mac
- new macros : rotations.mac reflections.mac
20-04-21 mma (exTransforms-V10-07-00)
- transforms.cc : use G4SteppingVerboseWithUnits
01-10-18 mma, I. Hrivnacova (exTransforms-V10-04-02)
- DetectorConstruction::PlaceWithAxialRotations : use rotate(angle, axis)
- Added descriptions for placement methods in README
@@ -51,16 +55,16 @@ be used as a substitute for writing good git commit messages!
08-06-13 mma (exTransforms-V09-06-04)
- Cosmetic in SteppingAction.
24/03/2013 mma (exTransforms-V09-06-03)
- polish coding conventions
17/03/2013 mma (exTransforms-V09-06-02)
- G4 coding conventions
28/02/13 I. Hrivnacova (exTransforms-V09-06-01)
28/02/13 I. Hrivnacova (exTransforms-V09-06-01)
- When building materials with NistManager
do not set fromIsotopes argument (which was set to false),
do not set fromIsotopes argument (which was set to false),
as since 9.6 all materials have to be built from isotopes.
(Thanks to V. Ivantchenko for pointing at this.)
@@ -72,15 +76,15 @@ be used as a substitute for writing good git commit messages!
04/09/2012 I. Hrivnacova (exTransforms-V09-05-02)
- Updated CMakeLists.txt:
adding visualization, copying macros, install target and comment lines
- Minor fixes in .README
adding visualization, copying macros, install target and comment lines
- Minor fixes in .README
25/06/2012 mma (exTransforms-V09-05-01)
- update readme and .readme
12/03/2012 mma (exTransforms-V09-05-00)
- simplified version, limited to geometry functionalities
15/11/2011 I. Hrivnacova (exTransforms-V09-04-00)
First version of Transforms examples implemented by M.Maire;
the reflection option added by I. Hrivnacova.
the reflection option added by I. Hrivnacova.
+28 -28
View File
@@ -4,7 +4,7 @@
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
transforms
transforms
----------
This example illustrates various ways to place a volume.
@@ -19,21 +19,21 @@
Two G4Trd volumes (daughters) are placed within a G4Tubs (mother), in such a way
that their z_axis are in the mother xy plane.
To see the picture, run the example in interactive mode.
The various ways of placement are implemented in the DetectorConstruction class
in the following private functions:
- PlaceWithDirectMatrix()
This method is using G4PVPlacement with G4Transform3D, which is constructed from a rotation matrix (G4RotationMatrix) and a translation vector (G4ThreeVector). The rotation and translation in this case represent the active transformation: the solid itself is moved by rotating and translating it to bring it into the system of coordinates of the mother volume.
This method is using G4PVPlacement with G4Transform3D, which is constructed from a rotation matrix (G4RotationMatrix) and a translation vector (G4ThreeVector). The rotation and translation in this case represent the active transformation: the solid itself is moved by rotating and translating it to bring it into the system of coordinates of the mother volume.
The rotation matrix is defined via the daughter frame axes with respect to the mother frame.
- PlaceWithInverseMatrix()
This method is using G4PVPlacement with a rotation matrix (G4RotationMatrix) and a translation vector (G4ThreeVector). The rotation Matrix represents the rotation of the reference frame of the considered volume relatively to its mother volumes reference frame. The translation Vector represents the translation of the current volume in the reference frame of its mother volume.
- If compared to the previous construct, the transformation in this case is generated by specifying the same translation with respect to its mother volume and the inverse of the rotation matrix.
This method is using G4PVPlacement with a rotation matrix (G4RotationMatrix) and a translation vector (G4ThreeVector). The rotation Matrix represents the rotation of the reference frame of the considered volume relatively to its mother volumes reference frame. The translation Vector represents the translation of the current volume in the reference frame of its mother volume.
- If compared to the previous construct, the transformation in this case is generated by specifying the same translation with respect to its mother volume and the inverse of the rotation matrix.
The rotation matrix is defined again via the daughter frame axes with respect to the mother frame.
- PlaceWithAxialRotations()
This method is using G4PVPlacement with G4Transform3D again, but in difference from
This method is using G4PVPlacement with G4Transform3D again, but in difference from
PlaceWithDirectMatrix(), the rotation matrix is defined via rotate[X,Y,Z]() member functions of G4RotationMatrix.
- PlaceWithEulerAngles()
@@ -41,54 +41,54 @@
- PlaceWithReflections()
In this method, in addition to two positions defined via "PlaceWithAxialRotations" method, two more positions including reflection symmetry are defined.
When reflections are present in geometry, the placements have to be applied
When reflections are present in geometry, the placements have to be applied
via G4ReflectionFactory::Place() method, where a G4Transform3D with reflection
can be used.
can be used.
These functions are then called from the Construct() function.
All methods define exactly same geometry except for the placement
with reflection where trapezoids are placed with their symmetry axis
in parallel with z-axis in order to make easier to check reflection
visually.
All methods define exactly same geometry except for the placement
with reflection where trapezoids are placed with their symmetry axis
in parallel with z-axis in order to make easier to check reflection
visually.
The method of placement can be selected interactively via the command
(see DetectorMessenger):
/placement/setMethod method (see transfoms.in)
2- Physics list
------------
PhysicsList.cc defines only geantino and transportation process.
3- Primary generator
-----------------
-----------------
Default kinematic is a geantino at coordinate origin.
Can be changed with particleGun commands.
4- Physics
-------
No physics; only transportation.
5- Visualisation
-------------
-------------
In interactive mode, visualization manager is set in the main().
Initialisation of the drawing is done via the commands
/vis/.. in the macro vis.mac : /control/execute vis.mac
6- How to start ?
--------------
--------------
- execute transforms in 'interactive mode' with visualization
% transforms
....
Idle> ---> type your commands. For example:
Idle> /placement/setMethod WithInverseMatrix
Idle> /control/execute vis.mac
Idle> /tracking/verbose 1
Idle> /run/beamOn 1
Idle> /tracking/verbose 1
Idle> /run/beamOn 1
Idle> exit
or, simply
Idle> /control/execute rotations.mac
Idle> /control/execute rotations.mac
Idle> /control/execute reflections.mac
- execute transforms in 'batch' mode from macro files
% transforms transforms.in
% transforms transforms.in
@@ -10,7 +10,7 @@
**************************************************************
Geant4 version Name: geant4-11-01-ref-06 (30-June-2023)
Geant4 version Name: geant4-11-02-ref-00 (8-December-2023)
Copyright : Geant4 Collaboration
References : NIM A 506 (2003), 250-303
: IEEE-TNS 53 (2006), 270-278
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
/// \file DetectorConstruction.hh
/// \brief Definition of the DetectorConstruction class
@@ -40,9 +40,9 @@ class G4VPhysicalVolume;
/// Detector construction class to demonstrate various ways of placement
///
/// The geometry setup consists of two trapezoid volumes which are placed
/// in a world so that their axial symmetry axis is in given theta and phi
/// polar angles. The various ways of placement are implemented in the
/// The geometry setup consists of two trapezoid volumes which are placed
/// in a world so that their axial symmetry axis is in given theta and phi
/// polar angles. The various ways of placement are implemented in the
/// DetectorConstruction class in the following private functions:
/// - PlaceWithDirectMatrix()
/// - PlaceWithInverseMatrix()
@@ -51,10 +51,10 @@ class G4VPhysicalVolume;
/// - PlaceWithReflections()
///
/// which are then called from the Construct() function.
/// All method defines exactly same geometry except for the placement
/// with reflection where trapezoids are placed with their symmetry axis
/// in parallel with z-axis in order to make easier to check reflection
/// visually.
/// All method defines exactly same geometry except for the placement
/// with reflection where trapezoids are placed with their symmetry axis
/// in parallel with z-axis in order to make easier to check reflection
/// visually.
class DetectorConstruction : public G4VUserDetectorConstruction
{
@@ -65,19 +65,19 @@ class DetectorConstruction : public G4VUserDetectorConstruction
kWithAxialRotations,
kWithEulerAngles,
kWithReflections
};
};
public:
DetectorConstruction();
~DetectorConstruction();
~DetectorConstruction() override;
public:
// methods from base class
virtual G4VPhysicalVolume* Construct();
// methods from base class
G4VPhysicalVolume* Construct() override;
// set methods
void SetMethod(EMethod method);
private:
// methods
void PlaceWithDirectMatrix();
@@ -87,10 +87,10 @@ class DetectorConstruction : public G4VUserDetectorConstruction
void PlaceWithReflections();
// data members
DetectorMessenger* fMessenger;
EMethod fMethod;
G4LogicalVolume* fWorldVolume;
G4LogicalVolume* fTrdVolume;
DetectorMessenger* fMessenger = nullptr;
EMethod fMethod = kWithDirectMatrix;
G4LogicalVolume* fWorldVolume = nullptr;
G4LogicalVolume* fTrdVolume = nullptr;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -50,14 +50,14 @@ class DetectorMessenger: public G4UImessenger
{
public:
DetectorMessenger(DetectorConstruction* );
~DetectorMessenger();
virtual void SetNewValue(G4UIcommand* command, G4String newValue);
~DetectorMessenger() override;
void SetNewValue(G4UIcommand* command, G4String newValue) override;
private:
DetectorConstruction* fDetectorConstruction;
G4UIdirectory* fDirectory;
G4UIcmdWithAString* fSetMethodCmd;
DetectorConstruction* fDetectorConstruction = nullptr;
G4UIdirectory* fDirectory = nullptr;
G4UIcmdWithAString* fSetMethodCmd = nullptr;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -27,9 +27,9 @@
/// \brief Definition of the PhysicsList class
//
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef PhysicsList_h
#define PhysicsList_h 1
@@ -42,14 +42,14 @@
class PhysicsList: public G4VUserPhysicsList
{
public:
PhysicsList();
~PhysicsList();
PhysicsList() = default;
~PhysicsList() override = default;
protected:
// Construct particle and physics
virtual void ConstructParticle();
virtual void ConstructProcess();
virtual void SetCuts();
void ConstructParticle() override;
void ConstructProcess() override;
void SetCuts() override;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -28,7 +28,7 @@
//
//
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -47,14 +47,14 @@ class G4Event;
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
PrimaryGeneratorAction();
~PrimaryGeneratorAction();
PrimaryGeneratorAction();
~PrimaryGeneratorAction() override;
public:
virtual void GeneratePrimaries(G4Event*);
void GeneratePrimaries(G4Event*) override;
private:
G4ParticleGun* fParticleGun;
G4ParticleGun* fParticleGun = nullptr;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -50,12 +50,6 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::DetectorConstruction()
: G4VUserDetectorConstruction(),
fMessenger(0),
fMethod(kWithDirectMatrix),
fWorldVolume(0),
fTrdVolume(0)
{
fMessenger = new DetectorMessenger(this);
}
@@ -63,7 +57,7 @@ DetectorConstruction::DetectorConstruction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::~DetectorConstruction()
{
{
delete fMessenger;
}
@@ -74,7 +68,7 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
// Materials
G4NistManager* nist = G4NistManager::Instance();
G4Material* material = nist->FindOrBuildMaterial("G4_AIR");
// Clean old geometry, if any
//
G4GeometryManager::GetInstance()->OpenGeometry();
@@ -82,42 +76,42 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
G4LogicalVolumeStore::GetInstance()->Clean();
G4SolidStore::GetInstance()->Clean();
G4ReflectionFactory::Instance()->Clean();
// World
//
//
G4double rmin = 0.;
G4double rmax = 5*cm;
G4double hz = 5*cm;
G4double phiMin = 0.;
G4double deltaPhi = 360*degree;
G4Tubs* solidWorld
auto solidWorld
= new G4Tubs("World", //name
rmin, rmax, hz, phiMin, deltaPhi); //size
fWorldVolume
fWorldVolume
= new G4LogicalVolume(solidWorld, //solid
material, //material
"World"); //name
G4VPhysicalVolume* physiWorld
= new G4PVPlacement(0, //no rotation
= new G4PVPlacement(nullptr, //no rotation
G4ThreeVector(), //at (0,0,0)
fWorldVolume, //logical volume
"World", //name
0, //mother volume
nullptr, //mother volume
false, //no boolean operation
0); //copy number
// Trd volume
//
// Trd volume
//
G4double dX1 = 1*cm;
G4double dX2 = 1*cm;
G4double dY1 = 1*cm;
G4double dY1 = 1*cm;
G4double dY2 = 2*cm;
G4double dZ = 3*cm;
G4double dZ = 3*cm;
G4Trd* solidTrd
auto solidTrd
= new G4Trd("trd", //name
dX1/2, dX2/2, dY1/2, dY2/2, dZ/2); //size
@@ -125,10 +119,10 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
= new G4LogicalVolume(solidTrd, //solid
material, //material
"trd"); //name
// Place Volume1 and Volume2 according to selected methods
//
//
switch ( fMethod ) {
case kWithDirectMatrix: PlaceWithDirectMatrix(); break;
case kWithInverseMatrix: PlaceWithInverseMatrix(); break;
@@ -147,9 +141,9 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
void DetectorConstruction::PlaceWithDirectMatrix()
{
G4double og = 3*cm;
G4double og = 3*cm;
// 1st position
// 1st position
//
G4double phi = 30*deg;
// u, v, w are the daughter axes, projected on the mother frame
@@ -158,18 +152,18 @@ void DetectorConstruction::PlaceWithDirectMatrix()
G4ThreeVector w = G4ThreeVector( std::cos(phi), std::sin(phi),0.);
G4RotationMatrix rotm1 = G4RotationMatrix(u, v, w);
G4cout << "\n --> phi = " << phi/deg << " deg; direct rotation matrix : ";
rotm1.print(G4cout);
rotm1.print(G4cout);
G4ThreeVector position1 = og*w;
G4Transform3D transform1 = G4Transform3D(rotm1,position1);
new G4PVPlacement(transform1, //position, rotation
new G4PVPlacement(transform1, //position, rotation
fTrdVolume, //logical volume
"Trd", //name
fWorldVolume, //mother volume
false, //no boolean operation
1); //copy number
1); //copy number
// 2nd position
// 2nd position
//
phi = phi + 90*deg;
v = G4ThreeVector(-std::sin(phi), std::cos(phi),0.);
@@ -177,31 +171,31 @@ void DetectorConstruction::PlaceWithDirectMatrix()
G4RotationMatrix rotm2 = G4RotationMatrix(u, v, w);
G4ThreeVector position2 = og*w;
G4Transform3D transform2 = G4Transform3D(rotm2,position2);
new G4PVPlacement(transform2, //position, rotation
new G4PVPlacement(transform2, //position, rotation
fTrdVolume, //logical volume
"Trd", //name
fWorldVolume, //mother volume
false, //no boolean operation
2); //copy number
2); //copy number
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::PlaceWithInverseMatrix()
{
G4double og = 3*cm;
G4double og = 3*cm;
// 1st position
//
G4double phi = 30*deg;
// u, v, w are the daughter axes, projected on the mother frame
// u, v, w are the daughter axes, projected on the mother frame
G4ThreeVector u = G4ThreeVector(0, 0, -1);
G4ThreeVector v = G4ThreeVector(-std::sin(phi), std::cos(phi),0.);
G4ThreeVector w = G4ThreeVector( std::cos(phi), std::sin(phi),0.);
G4RotationMatrix rotm1 = G4RotationMatrix(u, v, w);
G4RotationMatrix* rotm1Inv = new G4RotationMatrix(rotm1.inverse());
G4RotationMatrix rotm1 = G4RotationMatrix(u, v, w);
auto rotm1Inv = new G4RotationMatrix(rotm1.inverse());
G4cout << "\n --> phi = " << phi/deg << " deg; inverse rotation matrix : ";
rotm1Inv->print(G4cout);
rotm1Inv->print(G4cout);
G4ThreeVector position1 = og*w;
new G4PVPlacement(rotm1Inv,
@@ -210,7 +204,7 @@ void DetectorConstruction::PlaceWithInverseMatrix()
"Trd", //name
fWorldVolume, //mother volume
false, //no boolean operation
1); //copy number
1); //copy number
// 2nd position
//
@@ -218,11 +212,11 @@ void DetectorConstruction::PlaceWithInverseMatrix()
v = G4ThreeVector(-std::sin(phi), std::cos(phi),0.);
w = G4ThreeVector( std::cos(phi), std::sin(phi),0.);
G4RotationMatrix rotm2 = G4RotationMatrix(u, v, w);
G4RotationMatrix* rotm2Inv = new G4RotationMatrix(rotm2.inverse());
auto rotm2Inv = new G4RotationMatrix(rotm2.inverse());
G4ThreeVector position2 = og*w;
new G4PVPlacement(rotm2Inv, //rotation
position2, //position
position2, //position
fTrdVolume, //logical volume
"Trd", //name
fWorldVolume, //mother volume
@@ -234,7 +228,7 @@ void DetectorConstruction::PlaceWithInverseMatrix()
void DetectorConstruction::PlaceWithAxialRotations()
{
G4double og = 3*cm;
G4double og = 3*cm;
// 1st position (with first G4PVPlacement constructor)
//
@@ -243,11 +237,11 @@ void DetectorConstruction::PlaceWithAxialRotations()
G4ThreeVector(std::sin(theta-pi/2), 0., std::cos(theta-pi/2));
G4RotationMatrix rotm1 = G4RotationMatrix();
rotm1.rotateY(theta);
rotm1.rotate (phi, rotAxis);
rotm1.rotate (phi, rotAxis);
G4cout << "\n --> direct rotation matrix : "
<< " theta = " << theta/deg << " deg;"
<< " phi = " << phi/deg << " deg;";
rotm1.print(G4cout);
rotm1.print(G4cout);
G4ThreeVector w = G4ThreeVector( std::sin(theta)*std::cos(phi),
std::sin(phi), std::cos(theta)*std::cos(phi));
G4ThreeVector position1 = og*w;
@@ -265,13 +259,13 @@ void DetectorConstruction::PlaceWithAxialRotations()
phi = phi + 90*deg;
//rotm2Inv could be calculated with rotm2.inverse()
//but also by the following :
G4RotationMatrix* rotm2Inv = new G4RotationMatrix();
rotm2Inv->rotate (-phi, rotAxis);
auto rotm2Inv = new G4RotationMatrix();
rotm2Inv->rotate (-phi, rotAxis);
rotm2Inv->rotateY(-theta);
w = G4ThreeVector( std::sin(theta)*std::cos(phi),
std::sin(phi), std::cos(theta)*std::cos(phi));
G4ThreeVector position2 = og*w;
new G4PVPlacement(rotm2Inv, //rotation
position2, //position
fTrdVolume, //logical volume
@@ -290,13 +284,13 @@ void DetectorConstruction::PlaceWithEulerAngles()
// phi_euler = (x,n) : precession
// theta_euler = (z,w) : nutation
// psi_euler = (n,u) : proper rotation
G4double og = 3*cm;
G4double og = 3*cm;
// 1st position (with first G4PVPlacement constructor)
//
G4double phi = 30*deg;
G4double phi_euler = phi + pi/2;
G4double phi = 30*deg;
G4double phi_euler = phi + pi/2;
G4double theta_euler = 90*deg;
G4double psi_euler = -90*deg;
//attention : clhep Euler constructor build inverse matrix !
@@ -304,35 +298,35 @@ void DetectorConstruction::PlaceWithEulerAngles()
G4RotationMatrix rotm1 = rotm1Inv.inverse();
//remark : could be built as rotm1 = G4RotationMatrix(-psi, -theta, -phi)
G4cout << "\n --> phi = " << phi/deg << " deg; direct rotation matrix : ";
rotm1.print(G4cout);
rotm1.print(G4cout);
G4ThreeVector w = G4ThreeVector(std::cos(phi), std::sin(phi),0.);
G4ThreeVector position1 = og*w;
G4Transform3D transform1 = G4Transform3D(rotm1,position1);
new G4PVPlacement(transform1, //position, rotation
new G4PVPlacement(transform1, //position, rotation
fTrdVolume, //logical volume
"Trd", //name
fWorldVolume, //mother volume
false, //no boolean operation
1); //copy number
1); //copy number
// 2nd position (with second G4PVPlacement constructor)
//
phi = phi + 90*deg;
phi_euler = phi + pi/2;
G4RotationMatrix* rotm2Inv
= new G4RotationMatrix(phi_euler,theta_euler,psi_euler);
phi_euler = phi + pi/2;
auto rotm2Inv
= new G4RotationMatrix(phi_euler,theta_euler,psi_euler);
w = G4ThreeVector(std::cos(phi), std::sin(phi),0.);
G4ThreeVector position2 = og*w;
new G4PVPlacement(rotm2Inv, //rotation
position2, //position
position2, //position
fTrdVolume, //logical volume
"Trd", //name
fWorldVolume, //mother volume
false, //no boolean operation
2); //copy number
2); //copy number
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -341,9 +335,9 @@ void DetectorConstruction::PlaceWithReflections()
{
/// Placement with reflections.
/// In order to better show the reflection symmetry we do not apply
/// the rotation along Y axis.
/// the rotation along Y axis.
G4double og = 3*cm;
G4double og = 3*cm;
// Place first two positionz in z = + 3cm
//
@@ -351,9 +345,9 @@ void DetectorConstruction::PlaceWithReflections()
// 1st position
G4double phi = 30*deg;
G4RotationMatrix rotm1;
//rotm1.rotateY(90*deg);
rotm1.rotateZ(phi);
G4ThreeVector uz = G4ThreeVector(std::cos(phi), std::sin(phi), 0);
//rotm1.rotateY(90*deg);
rotm1.rotateZ(phi);
G4ThreeVector uz = G4ThreeVector(std::cos(phi), std::sin(phi), 0);
G4ThreeVector position = og*uz;
G4Transform3D transform1(rotm1,position);
G4Transform3D translateZ = HepGeom::Translate3D(0, 0, 3.*cm);
@@ -368,12 +362,12 @@ void DetectorConstruction::PlaceWithReflections()
// 2nd position
phi = phi + pi/2 ;
G4RotationMatrix rotm2;
//rotm2.rotateY(90*deg);
rotm2.rotateZ(phi);
uz = G4ThreeVector(std::cos(phi), std::sin(phi), 0.);
//rotm2.rotateY(90*deg);
rotm2.rotateZ(phi);
uz = G4ThreeVector(std::cos(phi), std::sin(phi), 0.);
position = og*uz;
G4Transform3D transform2 = G4Transform3D(rotm2, position);
new G4PVPlacement(translateZ * transform2, //rotation, position
fTrdVolume, //logical volume
"Trd", //name
@@ -382,7 +376,7 @@ void DetectorConstruction::PlaceWithReflections()
2); //copy number
// Place next two positionz in z = - 3cm with reflection
// Place next two positionz in z = - 3cm with reflection
//
// 3rd position
@@ -411,9 +405,9 @@ void DetectorConstruction::PlaceWithReflections()
#include "G4RunManager.hh"
void DetectorConstruction::SetMethod(EMethod method) {
void DetectorConstruction::SetMethod(EMethod method) {
fMethod = method;
G4RunManager::GetRunManager()->DefineWorldVolume(Construct());
}
G4RunManager::GetRunManager()->DefineWorldVolume(Construct());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -37,21 +37,18 @@
DetectorMessenger::DetectorMessenger(
DetectorConstruction* detectorConstruction)
: G4UImessenger(),
fDetectorConstruction(detectorConstruction),
fDirectory(0),
fSetMethodCmd(0)
{
: fDetectorConstruction(detectorConstruction)
{
fDirectory = new G4UIdirectory("/placement/");
fDirectory->SetGuidance("Transform example detector control");
fSetMethodCmd
fSetMethodCmd
= new G4UIcmdWithAString("/placement/setMethod",this);
fSetMethodCmd->SetGuidance("Select method for definition of transformations.");
fSetMethodCmd->SetParameterName("Method", false);
fSetMethodCmd->SetCandidates(
"WithDirectMatrix WithInverseMatrix WithAxialRotations WithEulerAngles WithReflections");
fSetMethodCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fSetMethodCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -64,22 +61,22 @@ DetectorMessenger::~DetectorMessenger()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorMessenger::SetNewValue(G4UIcommand* command,
void DetectorMessenger::SetNewValue(G4UIcommand* command,
G4String newValue)
{
if( command == fSetMethodCmd ) {
{
if( command == fSetMethodCmd ) {
DetectorConstruction::EMethod method;
if ( newValue == "WithDirectMatrix" )
if ( newValue == "WithDirectMatrix" )
method = DetectorConstruction::kWithDirectMatrix;
else if ( newValue == "WithInverseMatrix" )
else if ( newValue == "WithInverseMatrix" )
method = DetectorConstruction::kWithInverseMatrix;
else if ( newValue == "WithAxialRotations" )
else if ( newValue == "WithAxialRotations" )
method = DetectorConstruction::kWithAxialRotations;
else if ( newValue == "WithEulerAngles" )
else if ( newValue == "WithEulerAngles" )
method = DetectorConstruction::kWithEulerAngles;
else if ( newValue == "WithReflections" )
else if ( newValue == "WithReflections" )
method = DetectorConstruction::kWithReflections;
else return;
else return;
fDetectorConstruction->SetMethod(method);
}
}
@@ -27,26 +27,15 @@
/// \brief Implementation of the PhysicsList class
//
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "PhysicsList.hh"
#include "G4ParticleTypes.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsList::PhysicsList()
: G4VUserPhysicsList()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsList::~PhysicsList()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::ConstructParticle()
{
G4Geantino::GeantinoDefinition();
@@ -63,7 +52,7 @@ void PhysicsList::ConstructProcess()
void PhysicsList::SetCuts()
{
SetCutsWithDefault();
SetCutsWithDefault();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -28,7 +28,7 @@
//
//
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -45,12 +45,10 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::PrimaryGeneratorAction()
: G4VUserPrimaryGeneratorAction(),
fParticleGun(0)
{
G4int n_particle = 1;
fParticleGun = new G4ParticleGun(n_particle);
// default particle kinematic
G4ParticleDefinition* particle
@@ -74,7 +72,7 @@ PrimaryGeneratorAction::~PrimaryGeneratorAction()
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
//this function is called at the begining of event
//
//
fParticleGun->GeneratePrimaryVertex(anEvent);
}
@@ -57,9 +57,9 @@ int main(int argc,char** argv) {
//use G4SteppingVerboseWithUnits
G4int precision = 4;
G4SteppingVerbose::UseBestUnit(precision);
//construct the default run manager
G4RunManager * runManager = new G4RunManager;
auto runManager = new G4RunManager;
//set mandatory initialization classes
runManager->SetUserInitialization(new DetectorConstruction);
@@ -74,21 +74,21 @@ int main(int argc,char** argv) {
//initialize visualization
G4VisManager* visManager = nullptr;
//get the pointer to the User Interface manager
//get the pointer to the User Interface manager
G4UImanager* UImanager = G4UImanager::GetUIpointer();
if (ui) {
//interactive mode
visManager = new G4VisExecutive;
visManager->Initialize();
///UImanager->ApplyCommand("/control/execute vis.mac");
ui->SessionStart();
delete ui;
//interactive mode
visManager = new G4VisExecutive;
visManager->Initialize();
///UImanager->ApplyCommand("/control/execute vis.mac");
ui->SessionStart();
delete ui;
} else {
//batch mode
G4String command = "/control/execute ";
G4String fileName = argv[1];
UImanager->ApplyCommand(command+fileName);
//batch mode
G4String command = "/control/execute ";
G4String fileName = argv[1];
UImanager->ApplyCommand(command+fileName);
}
//job termination
+4 -14
View File
@@ -7,20 +7,10 @@
/control/verbose 2
/run/verbose 2
#
# Use this open statement to create an OpenGL view:
/vis/open OGL 600x600-0+0
#
# Use this open statement to create a .prim file suitable for
# viewing in DAWN:
#/vis/open DAWNFILE
#
# Use this open statement to create a .heprep file suitable for
# viewing in HepRApp:
#/vis/open HepRepFile
#
# Use this open statement to create a .wrl file suitable for
# viewing in a VRML viewer:
#/vis/open VRML2FILE
# Open a viewer
/vis/open
# This opens the default viewer - see examples/basic/B1/vis.mac for a
# more comprehensive overview of options. Also the documentation.
#
# Disable auto refresh and quieten vis messages whilst scene and
# trajectories are established: