Import Geant4 11.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2024-06-28 13:08:51 +02:00
parent f7b23877ed
commit e58e650b32
5232 changed files with 239416 additions and 244360 deletions
+14 -15
View File
@@ -27,40 +27,39 @@
/// \file exampleB2a.cc
/// \brief Main program of the B2a example
#include "DetectorConstruction.hh"
#include "ActionInitialization.hh"
#include "DetectorConstruction.hh"
#include "FTFP_BERT.hh"
#include "G4RunManagerFactory.hh"
#include "G4SteppingVerbose.hh"
#include "G4UImanager.hh"
#include "FTFP_BERT.hh"
#include "G4StepLimiterPhysics.hh"
#include "Randomize.hh"
#include "G4VisExecutive.hh"
#include "G4SteppingVerbose.hh"
#include "G4UIExecutive.hh"
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
// #include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int main(int argc,char** argv)
int main(int argc, char** argv)
{
// Detect interactive mode (if no arguments) and define UI session
//
G4UIExecutive* ui = nullptr;
if ( argc == 1 ) { ui = new G4UIExecutive(argc, argv); }
if (argc == 1) {
ui = new G4UIExecutive(argc, argv);
}
// Optionally: choose a different Random engine...
// G4Random::setTheEngine(new CLHEP::MTwistEngine);
//use G4SteppingVerboseWithUnits
// use G4SteppingVerboseWithUnits
G4int precision = 4;
G4SteppingVerbose::UseBestUnit(precision);
// Construct the default run manager
//
auto runManager =
G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
auto runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
// Set mandatory initialization classes
//
@@ -87,11 +86,11 @@ int main(int argc,char** argv)
// Process macro or start UI session
//
if ( ! ui ) {
if (!ui) {
// batch mode
G4String command = "/control/execute ";
G4String fileName = argv[1];
UImanager->ApplyCommand(command+fileName);
UImanager->ApplyCommand(command + fileName);
}
else {
// interactive mode
+213 -206
View File
@@ -11,7 +11,7 @@ Environment variable "G4FORCE_RUN_MANAGER_TYPE" enabled with value == Serial. Fo
**************************************************************
Geant4 version Name: geant4-11-02-patch-02 (21-June-2024)
Geant4 version Name: geant4-11-02-ref-06 (28-June-2024)
Copyright : Geant4 Collaboration
References : NIM A 506 (2003), 250-303
: IEEE-TNS 53 (2006), 270-278
@@ -44,14 +44,21 @@ Registered graphics systems are:
RayTracerX (RayTracerX)
Qt3D (Qt3D)
TOOLSSG_X11_GLES (TSG_X11_GLES, TSGX11, TSG_XT_GLES_FALLBACK)
TOOLSSG_X11_ZB (TSG_X11_ZB, TSGX11ZB)
TOOLSSG_XT_GLES (TSG_XT_GLES, TSGXt, TSG_QT_GLES_FALLBACK)
TOOLSSG_XT_ZB (TSG_XT_ZB, TSGXtZB)
TOOLSSG_QT_GLES (TSG_QT_GLES, TSGQt, TSG)
TOOLSSG_QT_ZB (TSG_QT_ZB, TSGQtZB)
Default graphics system is: TSG_OFFSCREEN (based on batch session).
Default window size hint is: 600x600-0+0 (based on G4VisManager initialisation).
Note: Parameters specified on the command line will override these defaults.
Use "vis/open" without parameters to get these defaults.
You may choose a graphics system (driver) with a parameter of
the command "/vis/open" or "/vis/sceneHandler/create",
or you may omit the driver parameter and choose at run time:
- by argument in the construction of G4VisExecutive
- by environment variable "G4VIS_DEFAULT_DRIVER"
- by entry in "~/.g4session"
- by build flags.
- Note: This feature is not allowed in batch mode.
For further information see "examples/basic/B1/exampleB1.cc"
and "vis.mac".
Registering model factories...
@@ -304,7 +311,7 @@ eBrem: for e+ XStype:4 SubType=3
eBremSB : Emin= 0 eV Emax= 1 GeV ModifiedTsai
eBremLPM : Emin= 1 GeV Emax= 100 TeV ModifiedTsai
annihil: for e+ XStype:2 SubType=5 BuildTable=0
annihil: for e+ XStype:2 SubType=5 AtRestModel:Simple BuildTable=0
===== EM models for the G4Region DefaultRegionForTheWorld ======
eplus2gg : Emin= 0 eV Emax= 100 TeV
@@ -859,7 +866,7 @@ Min energy per nucleon for multifragmentation 200 GeV
Limit excitation energy for Fermi BreakUp 20 MeV
Level density (1/MeV) 0.075
Use simple level density model 1
Use discrete excitation energy of the residual 1
Use discrete excitation energy of the residual 0
Time limit for long lived isomeres 1 ns
Isomer production flag 1
Internal e- conversion flag 1
@@ -884,21 +891,21 @@ See commands in /vis/modeling/trajectories/ for other options.
>>> Event: 5
0 hits stored in this event
>>> Event: 6
54 hits stored in this event
0 hits stored in this event
>>> Event: 7
41 hits stored in this event
0 hits stored in this event
>>> Event: 8
0 hits stored in this event
>>> Event: 9
29 hits stored in this event
0 hits stored in this event
>>> Event: 10
43 hits stored in this event
0 hits stored in this event
>>> Event: 11
0 hits stored in this event
>>> Event: 12
0 hits stored in this event
>>> Event: 13
0 hits stored in this event
136 hits stored in this event
>>> Event: 14
0 hits stored in this event
>>> Event: 15
@@ -914,27 +921,27 @@ See commands in /vis/modeling/trajectories/ for other options.
>>> Event: 20
0 hits stored in this event
>>> Event: 21
179 hits stored in this event
0 hits stored in this event
>>> Event: 22
0 hits stored in this event
>>> Event: 23
49 hits stored in this event
0 hits stored in this event
>>> Event: 24
0 hits stored in this event
>>> Event: 25
131 hits stored in this event
0 hits stored in this event
>>> Event: 26
0 hits stored in this event
>>> Event: 27
162 hits stored in this event
17 hits stored in this event
>>> Event: 28
0 hits stored in this event
194 hits stored in this event
>>> Event: 29
0 hits stored in this event
>>> Event: 30
39 hits stored in this event
0 hits stored in this event
>>> Event: 31
137 hits stored in this event
9 hits stored in this event
>>> Event: 32
0 hits stored in this event
>>> Event: 33
@@ -944,7 +951,7 @@ See commands in /vis/modeling/trajectories/ for other options.
>>> Event: 35
0 hits stored in this event
>>> Event: 36
0 hits stored in this event
67 hits stored in this event
>>> Event: 37
0 hits stored in this event
>>> Event: 38
@@ -954,15 +961,15 @@ See commands in /vis/modeling/trajectories/ for other options.
>>> Event: 40
0 hits stored in this event
>>> Event: 41
63 hits stored in this event
>>> Event: 42
0 hits stored in this event
>>> Event: 42
9 hits stored in this event
>>> Event: 43
0 hits stored in this event
>>> Event: 44
0 hits stored in this event
>>> Event: 45
0 hits stored in this event
292 hits stored in this event
>>> Event: 46
0 hits stored in this event
>>> Event: 47
@@ -974,7 +981,7 @@ See commands in /vis/modeling/trajectories/ for other options.
>>> Event: 50
0 hits stored in this event
>>> Event: 51
95 hits stored in this event
0 hits stored in this event
>>> Event: 52
0 hits stored in this event
>>> Event: 53
@@ -982,15 +989,15 @@ See commands in /vis/modeling/trajectories/ for other options.
>>> Event: 54
0 hits stored in this event
>>> Event: 55
42 hits stored in this event
0 hits stored in this event
>>> Event: 56
85 hits stored in this event
0 hits stored in this event
>>> Event: 57
168 hits stored in this event
0 hits stored in this event
>>> Event: 58
0 hits stored in this event
>>> Event: 59
62 hits stored in this event
0 hits stored in this event
>>> Event: 60
0 hits stored in this event
>>> Event: 61
@@ -1000,23 +1007,23 @@ See commands in /vis/modeling/trajectories/ for other options.
>>> Event: 63
0 hits stored in this event
>>> Event: 64
0 hits stored in this event
172 hits stored in this event
>>> Event: 65
0 hits stored in this event
>>> Event: 66
40 hits stored in this event
0 hits stored in this event
>>> Event: 67
0 hits stored in this event
>>> Event: 68
0 hits stored in this event
>>> Event: 69
0 hits stored in this event
61 hits stored in this event
>>> Event: 70
28 hits stored in this event
0 hits stored in this event
>>> Event: 71
0 hits stored in this event
>>> Event: 72
0 hits stored in this event
87 hits stored in this event
>>> Event: 73
0 hits stored in this event
>>> Event: 74
@@ -1074,205 +1081,205 @@ See commands in /vis/modeling/trajectories/ for other options.
### Run 1 starts.
--> Event 0 starts.
>>> Event: 0
798 hits stored in this event
108 hits stored in this event
>>> Event: 1
76 hits stored in this event
91 hits stored in this event
>>> Event: 2
87 hits stored in this event
127 hits stored in this event
>>> Event: 3
2003 hits stored in this event
103 hits stored in this event
>>> Event: 4
66 hits stored in this event
169 hits stored in this event
>>> Event: 5
396 hits stored in this event
>>> Event: 6
8275 hits stored in this event
>>> Event: 7
123 hits stored in this event
>>> Event: 8
183 hits stored in this event
>>> Event: 9
736 hits stored in this event
>>> Event: 10
121 hits stored in this event
>>> Event: 11
141 hits stored in this event
>>> Event: 12
97 hits stored in this event
>>> Event: 13
237 hits stored in this event
>>> Event: 14
103 hits stored in this event
>>> Event: 15
605 hits stored in this event
>>> Event: 16
105 hits stored in this event
>>> Event: 17
403 hits stored in this event
>>> Event: 18
195 hits stored in this event
>>> Event: 19
213 hits stored in this event
>>> Event: 20
159 hits stored in this event
>>> Event: 21
52 hits stored in this event
>>> Event: 22
141 hits stored in this event
>>> Event: 23
171 hits stored in this event
>>> Event: 24
103 hits stored in this event
>>> Event: 25
153 hits stored in this event
>>> Event: 26
62 hits stored in this event
>>> Event: 27
226 hits stored in this event
>>> Event: 28
152 hits stored in this event
>>> Event: 29
134 hits stored in this event
>>> Event: 30
106 hits stored in this event
>>> Event: 31
92 hits stored in this event
>>> Event: 32
76 hits stored in this event
>>> Event: 33
117 hits stored in this event
>>> Event: 34
>>> Event: 6
96 hits stored in this event
>>> Event: 7
161 hits stored in this event
>>> Event: 8
91 hits stored in this event
>>> Event: 9
79 hits stored in this event
>>> Event: 10
80 hits stored in this event
>>> Event: 11
100 hits stored in this event
>>> Event: 12
119 hits stored in this event
>>> Event: 13
151 hits stored in this event
>>> Event: 14
84 hits stored in this event
>>> Event: 15
126 hits stored in this event
>>> Event: 16
99 hits stored in this event
>>> Event: 17
88 hits stored in this event
>>> Event: 18
65 hits stored in this event
>>> Event: 19
99 hits stored in this event
>>> Event: 20
220 hits stored in this event
>>> Event: 21
86 hits stored in this event
>>> Event: 22
315 hits stored in this event
>>> Event: 23
99 hits stored in this event
>>> Event: 24
109 hits stored in this event
>>> Event: 25
482 hits stored in this event
>>> Event: 26
63 hits stored in this event
>>> Event: 27
135 hits stored in this event
>>> Event: 28
105 hits stored in this event
>>> Event: 29
196 hits stored in this event
>>> Event: 30
638 hits stored in this event
>>> Event: 31
184 hits stored in this event
>>> Event: 32
105 hits stored in this event
>>> Event: 33
74 hits stored in this event
>>> Event: 34
102 hits stored in this event
>>> Event: 35
66 hits stored in this event
289 hits stored in this event
>>> Event: 36
328 hits stored in this event
301 hits stored in this event
>>> Event: 37
168 hits stored in this event
96 hits stored in this event
>>> Event: 38
73 hits stored in this event
172 hits stored in this event
>>> Event: 39
83 hits stored in this event
116 hits stored in this event
>>> Event: 40
4758 hits stored in this event
151 hits stored in this event
>>> Event: 41
90 hits stored in this event
119 hits stored in this event
>>> Event: 42
115 hits stored in this event
>>> Event: 43
3947 hits stored in this event
>>> Event: 44
90 hits stored in this event
>>> Event: 45
59 hits stored in this event
>>> Event: 46
345 hits stored in this event
>>> Event: 47
673 hits stored in this event
>>> Event: 48
166 hits stored in this event
>>> Event: 49
70 hits stored in this event
>>> Event: 50
77 hits stored in this event
>>> Event: 51
71 hits stored in this event
>>> Event: 52
>>> Event: 44
56 hits stored in this event
>>> Event: 45
81 hits stored in this event
>>> Event: 53
220 hits stored in this event
>>> Event: 54
156 hits stored in this event
>>> Event: 55
346 hits stored in this event
>>> Event: 56
347 hits stored in this event
>>> Event: 57
194 hits stored in this event
>>> Event: 58
181 hits stored in this event
>>> Event: 59
358 hits stored in this event
>>> Event: 60
49 hits stored in this event
>>> Event: 61
115 hits stored in this event
>>> Event: 62
157 hits stored in this event
>>> Event: 63
97 hits stored in this event
>>> Event: 64
131 hits stored in this event
>>> Event: 65
95 hits stored in this event
>>> Event: 66
67 hits stored in this event
>>> Event: 67
76 hits stored in this event
>>> Event: 68
72 hits stored in this event
>>> Event: 69
126 hits stored in this event
>>> Event: 70
81 hits stored in this event
>>> Event: 71
234 hits stored in this event
>>> Event: 72
63 hits stored in this event
>>> Event: 73
130 hits stored in this event
>>> Event: 74
302 hits stored in this event
>>> Event: 75
61 hits stored in this event
>>> Event: 76
50 hits stored in this event
>>> Event: 77
1287 hits stored in this event
>>> Event: 78
382 hits stored in this event
>>> Event: 79
>>> Event: 46
48 hits stored in this event
>>> Event: 80
147 hits stored in this event
>>> Event: 81
86 hits stored in this event
>>> Event: 82
90 hits stored in this event
>>> Event: 83
64 hits stored in this event
>>> Event: 84
147 hits stored in this event
>>> Event: 85
101 hits stored in this event
>>> Event: 86
74 hits stored in this event
>>> Event: 87
120 hits stored in this event
>>> Event: 88
74 hits stored in this event
>>> Event: 89
70 hits stored in this event
>>> Event: 90
70 hits stored in this event
>>> Event: 91
63 hits stored in this event
>>> Event: 92
69 hits stored in this event
>>> Event: 93
557 hits stored in this event
>>> Event: 94
>>> Event: 47
92 hits stored in this event
>>> Event: 48
124 hits stored in this event
>>> Event: 49
170 hits stored in this event
>>> Event: 50
67 hits stored in this event
>>> Event: 51
181 hits stored in this event
>>> Event: 52
461 hits stored in this event
>>> Event: 53
178 hits stored in this event
>>> Event: 54
357 hits stored in this event
>>> Event: 55
836 hits stored in this event
>>> Event: 56
115 hits stored in this event
>>> Event: 57
71 hits stored in this event
>>> Event: 58
59 hits stored in this event
>>> Event: 59
102 hits stored in this event
>>> Event: 60
1648 hits stored in this event
>>> Event: 61
970 hits stored in this event
>>> Event: 62
66 hits stored in this event
>>> Event: 63
105 hits stored in this event
>>> Event: 64
72 hits stored in this event
>>> Event: 65
97 hits stored in this event
>>> Event: 66
95 hits stored in this event
>>> Event: 67
235 hits stored in this event
>>> Event: 68
164 hits stored in this event
>>> Event: 69
174 hits stored in this event
>>> Event: 70
74 hits stored in this event
>>> Event: 71
1306 hits stored in this event
>>> Event: 72
85 hits stored in this event
>>> Event: 73
70 hits stored in this event
>>> Event: 74
47 hits stored in this event
>>> Event: 75
78 hits stored in this event
>>> Event: 76
153 hits stored in this event
>>> Event: 77
132 hits stored in this event
>>> Event: 78
148 hits stored in this event
>>> Event: 79
91 hits stored in this event
>>> Event: 80
59 hits stored in this event
>>> Event: 81
54 hits stored in this event
>>> Event: 82
72 hits stored in this event
>>> Event: 83
124 hits stored in this event
>>> Event: 84
72 hits stored in this event
>>> Event: 85
97 hits stored in this event
>>> Event: 86
174 hits stored in this event
>>> Event: 87
76 hits stored in this event
>>> Event: 88
63 hits stored in this event
>>> Event: 89
76 hits stored in this event
>>> Event: 90
82 hits stored in this event
>>> Event: 91
589 hits stored in this event
>>> Event: 92
61 hits stored in this event
>>> Event: 93
101 hits stored in this event
>>> Event: 94
69 hits stored in this event
>>> Event: 95
109 hits stored in this event
82 hits stored in this event
>>> Event: 96
62 hits stored in this event
170 hits stored in this event
>>> Event: 97
89 hits stored in this event
189 hits stored in this event
>>> Event: 98
157 hits stored in this event
178 hits stored in this event
>>> Event: 99
75 hits stored in this event
7434 hits stored in this event
### Run 2 starts.
--> Event 0 starts.
@@ -47,8 +47,6 @@ class ActionInitialization : public G4VUserActionInitialization
void Build() const override;
};
}
} // namespace B2
#endif
@@ -30,9 +30,9 @@
#ifndef B2aDetectorConstruction_h
#define B2aDetectorConstruction_h 1
#include "globals.hh"
#include "G4VUserDetectorConstruction.hh"
#include "tls.hh"
#include "G4Threading.hh"
#include "globals.hh"
class G4VPhysicalVolume;
class G4LogicalVolume;
@@ -59,10 +59,10 @@ class DetectorConstruction : public G4VUserDetectorConstruction
void ConstructSDandField() override;
// Set methods
void SetTargetMaterial (G4String );
void SetChamberMaterial(G4String );
void SetMaxStep (G4double );
void SetCheckOverlaps(G4bool );
void SetTargetMaterial(G4String);
void SetChamberMaterial(G4String);
void SetMaxStep(G4double);
void SetCheckOverlaps(G4bool);
private:
// methods
@@ -70,24 +70,24 @@ class DetectorConstruction : public G4VUserDetectorConstruction
G4VPhysicalVolume* DefineVolumes();
// static data members
static G4ThreadLocal G4GlobalMagFieldMessenger* fMagFieldMessenger;
// magnetic field messenger
static G4ThreadLocal G4GlobalMagFieldMessenger* fMagFieldMessenger;
// magnetic field messenger
// data members
G4int fNbOfChambers = 0;
G4LogicalVolume* fLogicTarget = nullptr; // pointer to the logical Target
G4LogicalVolume** fLogicChamber = nullptr; // pointer to the logical Chamber
G4LogicalVolume* fLogicTarget = nullptr; // pointer to the logical Target
G4LogicalVolume** fLogicChamber = nullptr; // pointer to the logical Chamber
G4Material* fTargetMaterial = nullptr; // pointer to the target material
G4Material* fChamberMaterial = nullptr; // pointer to the chamber material
G4Material* fTargetMaterial = nullptr; // pointer to the target material
G4Material* fChamberMaterial = nullptr; // pointer to the chamber material
G4UserLimits* fStepLimit = nullptr; // pointer to user step limits
G4UserLimits* fStepLimit = nullptr; // pointer to user step limits
DetectorMessenger* fMessenger = nullptr; // messenger
DetectorMessenger* fMessenger = nullptr; // messenger
G4bool fCheckOverlaps = true; // option to activate checking of volumes overlaps
G4bool fCheckOverlaps = true; // option to activate checking of volumes overlaps
};
}
} // namespace B2a
#endif
@@ -30,12 +30,12 @@
#ifndef B2aDetectorMessenger_h
#define B2aDetectorMessenger_h 1
#include "globals.hh"
#include "G4UImessenger.hh"
class G4UIdirectory;
class G4UIcmdWithAString;
class G4UIcmdWithADoubleAndUnit;
class G4UIcommand;
namespace B2a
{
@@ -49,26 +49,26 @@ class DetectorConstruction;
/// - /B2/det/setChamberMaterial name
/// - /B2/det/stepMax value unit
class DetectorMessenger: public G4UImessenger
class DetectorMessenger : public G4UImessenger
{
public:
DetectorMessenger(DetectorConstruction* );
DetectorMessenger(DetectorConstruction*);
~DetectorMessenger() override;
void SetNewValue(G4UIcommand*, G4String) override;
private:
DetectorConstruction* fDetectorConstruction = nullptr;
DetectorConstruction* fDetectorConstruction = nullptr;
G4UIdirectory* fDirectory = nullptr;
G4UIdirectory* fDetDirectory = nullptr;
G4UIdirectory* fDirectory = nullptr;
G4UIdirectory* fDetDirectory = nullptr;
G4UIcmdWithAString* fTargMatCmd = nullptr;
G4UIcmdWithAString* fChamMatCmd = nullptr;
G4UIcmdWithAString* fTargMatCmd = nullptr;
G4UIcmdWithAString* fChamMatCmd = nullptr;
G4UIcmdWithADoubleAndUnit* fStepMaxCmd = nullptr;
};
}
} // namespace B2a
#endif
+4 -4
View File
@@ -32,7 +32,7 @@
#include "G4UserEventAction.hh"
#include "globals.hh"
class G4Event;
namespace B2
{
@@ -45,10 +45,10 @@ class EventAction : public G4UserEventAction
EventAction() = default;
~EventAction() override = default;
void BeginOfEventAction(const G4Event* ) override;
void EndOfEventAction(const G4Event* ) override;
void BeginOfEventAction(const G4Event*) override;
void EndOfEventAction(const G4Event*) override;
};
}
} // namespace B2
#endif
@@ -31,7 +31,6 @@
#define B2PrimaryGeneratorAction_h 1
#include "G4VUserPrimaryGeneratorAction.hh"
#include "globals.hh"
class G4ParticleGun;
class G4Event;
@@ -52,14 +51,14 @@ class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
PrimaryGeneratorAction();
~PrimaryGeneratorAction() override;
void GeneratePrimaries(G4Event* ) override;
void GeneratePrimaries(G4Event*) override;
G4ParticleGun* GetParticleGun() {return fParticleGun;}
G4ParticleGun* GetParticleGun() { return fParticleGun; }
private:
G4ParticleGun* fParticleGun = nullptr; // G4 particle gun
G4ParticleGun* fParticleGun = nullptr; // G4 particle gun
};
}
} // namespace B2
#endif
+2 -3
View File
@@ -31,7 +31,6 @@
#define B2RunAction_h 1
#include "G4UserRunAction.hh"
#include "globals.hh"
class G4Run;
@@ -47,9 +46,9 @@ class RunAction : public G4UserRunAction
~RunAction() override = default;
void BeginOfRunAction(const G4Run* run) override;
void EndOfRunAction(const G4Run* run) override;
void EndOfRunAction(const G4Run* run) override;
};
}
} // namespace B2
#endif
+19 -20
View File
@@ -30,11 +30,11 @@
#ifndef B2TrackerHit_h
#define B2TrackerHit_h 1
#include "G4VHit.hh"
#include "G4THitsCollection.hh"
#include "G4Allocator.hh"
#include "G4THitsCollection.hh"
#include "G4Threading.hh"
#include "G4ThreeVector.hh"
#include "tls.hh"
#include "G4VHit.hh"
namespace B2
{
@@ -57,28 +57,28 @@ class TrackerHit : public G4VHit
G4bool operator==(const TrackerHit&) const;
inline void* operator new(size_t);
inline void operator delete(void*);
inline void operator delete(void*);
// methods from base class
void Draw() override;
void Print() override;
// Set methods
void SetTrackID (G4int track) { fTrackID = track; };
void SetChamberNb(G4int chamb) { fChamberNb = chamb; };
void SetEdep (G4double de) { fEdep = de; };
void SetPos (G4ThreeVector xyz){ fPos = xyz; };
void SetTrackID(G4int track) { fTrackID = track; };
void SetChamberNb(G4int chamb) { fChamberNb = chamb; };
void SetEdep(G4double de) { fEdep = de; };
void SetPos(G4ThreeVector xyz) { fPos = xyz; };
// Get methods
G4int GetTrackID() const { return fTrackID; };
G4int GetChamberNb() const { return fChamberNb; };
G4double GetEdep() const { return fEdep; };
G4int GetTrackID() const { return fTrackID; };
G4int GetChamberNb() const { return fChamberNb; };
G4double GetEdep() const { return fEdep; };
G4ThreeVector GetPos() const { return fPos; };
private:
G4int fTrackID = -1;
G4int fChamberNb = -1;
G4double fEdep = 0.;
G4int fTrackID = -1;
G4int fChamberNb = -1;
G4double fEdep = 0.;
G4ThreeVector fPos;
};
@@ -92,20 +92,19 @@ extern G4ThreadLocal G4Allocator<TrackerHit>* TrackerHitAllocator;
inline void* TrackerHit::operator new(size_t)
{
if(!TrackerHitAllocator)
TrackerHitAllocator = new G4Allocator<TrackerHit>;
return (void *) TrackerHitAllocator->MallocSingle();
if (!TrackerHitAllocator) TrackerHitAllocator = new G4Allocator<TrackerHit>;
return (void*)TrackerHitAllocator->MallocSingle();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
inline void TrackerHit::operator delete(void *hit)
inline void TrackerHit::operator delete(void* hit)
{
TrackerHitAllocator->FreeSingle((TrackerHit*) hit);
TrackerHitAllocator->FreeSingle((TrackerHit*)hit);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2
#endif
+6 -7
View File
@@ -30,10 +30,10 @@
#ifndef B2TrackerSD_h
#define B2TrackerSD_h 1
#include "G4VSensitiveDetector.hh"
#include "TrackerHit.hh"
#include "G4VSensitiveDetector.hh"
#include <vector>
class G4Step;
@@ -51,19 +51,18 @@ namespace B2
class TrackerSD : public G4VSensitiveDetector
{
public:
TrackerSD(const G4String& name,
const G4String& hitsCollectionName);
TrackerSD(const G4String& name, const G4String& hitsCollectionName);
~TrackerSD() override = default;
// methods from base class
void Initialize(G4HCofThisEvent* hitCollection) override;
void Initialize(G4HCofThisEvent* hitCollection) override;
G4bool ProcessHits(G4Step* step, G4TouchableHistory* history) override;
void EndOfEvent(G4HCofThisEvent* hitCollection) override;
void EndOfEvent(G4HCofThisEvent* hitCollection) override;
private:
TrackerHitsCollection* fHitsCollection = nullptr;
};
}
} // namespace B2
#endif
@@ -28,9 +28,10 @@
/// \brief Implementation of the B2::ActionInitialization class
#include "ActionInitialization.hh"
#include "EventAction.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
namespace B2
{
@@ -53,5 +54,4 @@ void ActionInitialization::Build() const
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2
+113 -133
View File
@@ -28,29 +28,25 @@
/// \brief Implementation of the B2a::DetectorConstruction class
#include "DetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "TrackerSD.hh"
#include "G4AutoDelete.hh"
#include "G4Box.hh"
#include "G4Colour.hh"
#include "G4GeometryManager.hh"
#include "G4GeometryTolerance.hh"
#include "G4GlobalMagFieldMessenger.hh"
#include "G4LogicalVolume.hh"
#include "G4Material.hh"
#include "G4NistManager.hh"
#include "G4SDManager.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4GlobalMagFieldMessenger.hh"
#include "G4AutoDelete.hh"
#include "G4GeometryTolerance.hh"
#include "G4GeometryManager.hh"
#include "G4UserLimits.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4SDManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4Tubs.hh"
#include "G4UserLimits.hh"
#include "G4VisAttributes.hh"
using namespace B2;
@@ -59,8 +55,7 @@ namespace B2a
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ThreadLocal
G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger = nullptr;
G4ThreadLocal G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger = nullptr;
DetectorConstruction::DetectorConstruction()
{
@@ -74,7 +69,7 @@ DetectorConstruction::DetectorConstruction()
DetectorConstruction::~DetectorConstruction()
{
delete [] fLogicChamber;
delete[] fLogicChamber;
delete fStepLimit;
delete fMessenger;
}
@@ -102,7 +97,7 @@ void DetectorConstruction::DefineMaterials()
nistManager->FindOrBuildMaterial("G4_AIR");
// Lead defined using NIST Manager
fTargetMaterial = nistManager->FindOrBuildMaterial("G4_Pb");
fTargetMaterial = nistManager->FindOrBuildMaterial("G4_Pb");
// Xenon gas defined using NIST Manager
fChamberMaterial = nistManager->FindOrBuildMaterial("G4_Xe");
@@ -115,22 +110,22 @@ void DetectorConstruction::DefineMaterials()
G4VPhysicalVolume* DetectorConstruction::DefineVolumes()
{
G4Material* air = G4Material::GetMaterial("G4_AIR");
G4Material* air = G4Material::GetMaterial("G4_AIR");
// Sizes of the principal geometrical components (solids)
G4double chamberSpacing = 80*cm; // from chamber center to center!
G4double chamberSpacing = 80 * cm; // from chamber center to center!
G4double chamberWidth = 20.0*cm; // width of the chambers
G4double targetLength = 5.0*cm; // full length of Target
G4double chamberWidth = 20.0 * cm; // width of the chambers
G4double targetLength = 5.0 * cm; // full length of Target
G4double trackerLength = (fNbOfChambers+1)*chamberSpacing;
G4double trackerLength = (fNbOfChambers + 1) * chamberSpacing;
G4double worldLength = 1.2 * (2*targetLength + trackerLength);
G4double worldLength = 1.2 * (2 * targetLength + trackerLength);
G4double targetRadius = 0.5*targetLength; // Radius of Target
targetLength = 0.5*targetLength; // Half length of the Target
G4double trackerSize = 0.5*trackerLength; // Half length of the Tracker
G4double targetRadius = 0.5 * targetLength; // Radius of Target
targetLength = 0.5 * targetLength; // Half length of the Target
G4double trackerSize = 0.5 * trackerLength; // Half length of the Tracker
// Definitions of Solids, Logical Volumes, Physical Volumes
@@ -139,114 +134,108 @@ G4VPhysicalVolume* DetectorConstruction::DefineVolumes()
G4GeometryManager::GetInstance()->SetWorldMaximumExtent(worldLength);
G4cout << "Computed tolerance = "
<< G4GeometryTolerance::GetInstance()->GetSurfaceTolerance()/mm
<< " mm" << G4endl;
<< G4GeometryTolerance::GetInstance()->GetSurfaceTolerance() / mm << " mm" << G4endl;
auto worldS = new G4Box("world", // its name
worldLength / 2, worldLength / 2, worldLength / 2); // its size
auto worldLV = new G4LogicalVolume(worldS, // its solid
air, // its material
"World"); // its name
auto worldS = new G4Box("world", // its name
worldLength / 2, worldLength / 2, worldLength / 2); // its size
auto worldLV = new G4LogicalVolume(worldS, // its solid
air, // its material
"World"); // its name
// Must place the World Physical volume unrotated at (0,0,0).
//
auto worldPV = new G4PVPlacement(nullptr, // no rotation
G4ThreeVector(), // at (0,0,0)
worldLV, // its logical volume
"World", // its name
nullptr, // its mother volume
false, // no boolean operations
0, // copy number
fCheckOverlaps); // checking overlaps
G4ThreeVector(), // at (0,0,0)
worldLV, // its logical volume
"World", // its name
nullptr, // its mother volume
false, // no boolean operations
0, // copy number
fCheckOverlaps); // checking overlaps
// Target
G4ThreeVector positionTarget = G4ThreeVector(0,0,-(targetLength+trackerSize));
G4ThreeVector positionTarget = G4ThreeVector(0, 0, -(targetLength + trackerSize));
auto targetS = new G4Tubs("target", 0., targetRadius, targetLength, 0. * deg, 360. * deg);
fLogicTarget = new G4LogicalVolume(targetS, fTargetMaterial, "Target", nullptr, nullptr, nullptr);
new G4PVPlacement(nullptr, // no rotation
positionTarget, // at (x,y,z)
fLogicTarget, // its logical volume
"Target", // its name
worldLV, // its mother volume
false, // no boolean operations
0, // copy number
fCheckOverlaps); // checking overlaps
positionTarget, // at (x,y,z)
fLogicTarget, // its logical volume
"Target", // its name
worldLV, // its mother volume
false, // no boolean operations
0, // copy number
fCheckOverlaps); // checking overlaps
G4cout << "Target is " << 2*targetLength/cm << " cm of "
<< fTargetMaterial->GetName() << G4endl;
G4cout << "Target is " << 2 * targetLength / cm << " cm of " << fTargetMaterial->GetName()
<< G4endl;
// Tracker
G4ThreeVector positionTracker = G4ThreeVector(0,0,0);
G4ThreeVector positionTracker = G4ThreeVector(0, 0, 0);
auto trackerS = new G4Tubs("tracker", 0, trackerSize, trackerSize, 0. * deg, 360. * deg);
auto trackerLV = new G4LogicalVolume(trackerS, air, "Tracker", nullptr, nullptr, nullptr);
new G4PVPlacement(nullptr, // no rotation
positionTracker, // at (x,y,z)
trackerLV, // its logical volume
"Tracker", // its name
worldLV, // its mother volume
false, // no boolean operations
0, // copy number
fCheckOverlaps); // checking overlaps
positionTracker, // at (x,y,z)
trackerLV, // its logical volume
"Tracker", // its name
worldLV, // its mother volume
false, // no boolean operations
0, // copy number
fCheckOverlaps); // checking overlaps
// Visualization attributes
G4VisAttributes boxVisAtt(G4Colour::White());
G4VisAttributes chamberVisAtt(G4Colour::Yellow());
worldLV ->SetVisAttributes(boxVisAtt);
fLogicTarget ->SetVisAttributes(boxVisAtt);
trackerLV ->SetVisAttributes(boxVisAtt);
worldLV->SetVisAttributes(boxVisAtt);
fLogicTarget->SetVisAttributes(boxVisAtt);
trackerLV->SetVisAttributes(boxVisAtt);
// Tracker segments
G4cout << "There are " << fNbOfChambers << " chambers in the tracker region. "
<< G4endl
<< "The chambers are " << chamberWidth/cm << " cm of "
<< fChamberMaterial->GetName() << G4endl
<< "The distance between chamber is " << chamberSpacing/cm << " cm"
<< G4endl;
G4cout << "There are " << fNbOfChambers << " chambers in the tracker region. " << G4endl
<< "The chambers are " << chamberWidth / cm << " cm of " << fChamberMaterial->GetName()
<< G4endl << "The distance between chamber is " << chamberSpacing / cm << " cm" << G4endl;
G4double firstPosition = -trackerSize + chamberSpacing;
G4double firstLength = trackerLength/10;
G4double lastLength = trackerLength;
G4double firstLength = trackerLength / 10;
G4double lastLength = trackerLength;
G4double halfWidth = 0.5*chamberWidth;
G4double halfWidth = 0.5 * chamberWidth;
G4double rmaxFirst = 0.5 * firstLength;
G4double rmaxIncr = 0.0;
if( fNbOfChambers > 0 ){
rmaxIncr = 0.5 * (lastLength-firstLength)/(fNbOfChambers-1);
if (chamberSpacing < chamberWidth) {
G4Exception("DetectorConstruction::DefineVolumes()",
"InvalidSetup", FatalException,
"Width>Spacing");
if (fNbOfChambers > 0) {
rmaxIncr = 0.5 * (lastLength - firstLength) / (fNbOfChambers - 1);
if (chamberSpacing < chamberWidth) {
G4Exception("DetectorConstruction::DefineVolumes()", "InvalidSetup", FatalException,
"Width>Spacing");
}
}
for (G4int copyNo=0; copyNo<fNbOfChambers; copyNo++) {
for (G4int copyNo = 0; copyNo < fNbOfChambers; copyNo++) {
G4double Zposition = firstPosition + copyNo * chamberSpacing;
G4double rmax = rmaxFirst + copyNo * rmaxIncr;
G4double Zposition = firstPosition + copyNo * chamberSpacing;
G4double rmax = rmaxFirst + copyNo * rmaxIncr;
auto chamberS = new G4Tubs("Chamber_solid", 0, rmax, halfWidth, 0. * deg, 360. * deg);
auto chamberS = new G4Tubs("Chamber_solid", 0, rmax, halfWidth, 0. * deg, 360. * deg);
fLogicChamber[copyNo] =
new G4LogicalVolume(chamberS, fChamberMaterial, "Chamber_LV", nullptr, nullptr, nullptr);
fLogicChamber[copyNo] =
new G4LogicalVolume(chamberS, fChamberMaterial, "Chamber_LV", nullptr, nullptr, nullptr);
fLogicChamber[copyNo]->SetVisAttributes(chamberVisAtt);
fLogicChamber[copyNo]->SetVisAttributes(chamberVisAtt);
new G4PVPlacement(nullptr, // no rotation
G4ThreeVector(0, 0, Zposition), // at (x,y,z)
fLogicChamber[copyNo], // its logical volume
"Chamber_PV", // its name
trackerLV, // its mother volume
false, // no boolean operations
copyNo, // copy number
fCheckOverlaps); // checking overlaps
new G4PVPlacement(nullptr, // no rotation
G4ThreeVector(0, 0, Zposition), // at (x,y,z)
fLogicChamber[copyNo], // its logical volume
"Chamber_PV", // its name
trackerLV, // its mother volume
false, // no boolean operations
copyNo, // copy number
fCheckOverlaps); // checking overlaps
}
// Example of User Limits
@@ -256,7 +245,7 @@ G4VPhysicalVolume* DetectorConstruction::DefineVolumes()
//
// Sets a max step length in the tracker region, with G4StepLimiter
G4double maxStep = 0.5*chamberWidth;
G4double maxStep = 0.5 * chamberWidth;
fStepLimit = new G4UserLimits(maxStep);
trackerLV->SetUserLimits(fStepLimit);
@@ -280,11 +269,11 @@ void DetectorConstruction::ConstructSDandField()
// Sensitive detectors
G4String trackerChamberSDname = "/TrackerChamberSD";
auto aTrackerSD = new TrackerSD(trackerChamberSDname, "TrackerHitsCollection");
G4SDManager::GetSDMpointer()->AddNewDetector(aTrackerSD);
// Setting aTrackerSD to all logical volumes with the same name
auto trackerSD = new TrackerSD(trackerChamberSDname, "TrackerHitsCollection");
G4SDManager::GetSDMpointer()->AddNewDetector(trackerSD);
// Setting trackerSD to all logical volumes with the same name
// of "Chamber_LV".
SetSensitiveDetector("Chamber_LV", aTrackerSD, true);
SetSensitiveDetector("Chamber_LV", trackerSD, true);
// Create global magnetic field messenger.
// Uniform magnetic field is then created automatically if
@@ -303,22 +292,18 @@ void DetectorConstruction::SetTargetMaterial(G4String materialName)
{
G4NistManager* nistManager = G4NistManager::Instance();
G4Material* pttoMaterial =
nistManager->FindOrBuildMaterial(materialName);
G4Material* pttoMaterial = nistManager->FindOrBuildMaterial(materialName);
if (fTargetMaterial != pttoMaterial) {
if ( pttoMaterial ) {
fTargetMaterial = pttoMaterial;
if (fLogicTarget) fLogicTarget->SetMaterial(fTargetMaterial);
G4cout
<< G4endl
<< "----> The target is made of " << materialName << G4endl;
} else {
G4cout
<< G4endl
<< "--> WARNING from SetTargetMaterial : "
<< materialName << " not found" << G4endl;
}
if (pttoMaterial) {
fTargetMaterial = pttoMaterial;
if (fLogicTarget) fLogicTarget->SetMaterial(fTargetMaterial);
G4cout << G4endl << "----> The target is made of " << materialName << G4endl;
}
else {
G4cout << G4endl << "--> WARNING from SetTargetMaterial : " << materialName << " not found"
<< G4endl;
}
}
}
@@ -328,25 +313,20 @@ void DetectorConstruction::SetChamberMaterial(G4String materialName)
{
G4NistManager* nistManager = G4NistManager::Instance();
G4Material* pttoMaterial =
nistManager->FindOrBuildMaterial(materialName);
G4Material* pttoMaterial = nistManager->FindOrBuildMaterial(materialName);
if (fChamberMaterial != pttoMaterial) {
if ( pttoMaterial ) {
fChamberMaterial = pttoMaterial;
for (G4int copyNo=0; copyNo<fNbOfChambers; copyNo++) {
if (fLogicChamber[copyNo]) fLogicChamber[copyNo]->
SetMaterial(fChamberMaterial);
}
G4cout
<< G4endl
<< "----> The chambers are made of " << materialName << G4endl;
} else {
G4cout
<< G4endl
<< "--> WARNING from SetChamberMaterial : "
<< materialName << " not found" << G4endl;
}
if (pttoMaterial) {
fChamberMaterial = pttoMaterial;
for (G4int copyNo = 0; copyNo < fNbOfChambers; copyNo++) {
if (fLogicChamber[copyNo]) fLogicChamber[copyNo]->SetMaterial(fChamberMaterial);
}
G4cout << G4endl << "----> The chambers are made of " << materialName << G4endl;
}
else {
G4cout << G4endl << "--> WARNING from SetChamberMaterial : " << materialName << " not found"
<< G4endl;
}
}
}
@@ -354,7 +334,7 @@ void DetectorConstruction::SetChamberMaterial(G4String materialName)
void DetectorConstruction::SetMaxStep(G4double maxStep)
{
if ((fStepLimit)&&(maxStep>0.)) fStepLimit->SetMaxAllowedStep(maxStep);
if ((fStepLimit) && (maxStep > 0.)) fStepLimit->SetMaxAllowedStep(maxStep);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -366,4 +346,4 @@ void DetectorConstruction::SetCheckOverlaps(G4bool checkOverlaps)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2a
+22 -21
View File
@@ -28,19 +28,19 @@
/// \brief Implementation of the B2a::DetectorMessenger class
#include "DetectorMessenger.hh"
#include "DetectorConstruction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIdirectory.hh"
namespace B2a
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::DetectorMessenger(DetectorConstruction* det)
: fDetectorConstruction(det)
DetectorMessenger::DetectorMessenger(DetectorConstruction* det) : fDetectorConstruction(det)
{
fDirectory = new G4UIdirectory("/B2/");
fDirectory->SetGuidance("UI commands specific to this example.");
@@ -48,19 +48,19 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction* det)
fDetDirectory = new G4UIdirectory("/B2/det/");
fDetDirectory->SetGuidance("Detector construction control");
fTargMatCmd = new G4UIcmdWithAString("/B2/det/setTargetMaterial",this);
fTargMatCmd = new G4UIcmdWithAString("/B2/det/setTargetMaterial", this);
fTargMatCmd->SetGuidance("Select Material of the Target.");
fTargMatCmd->SetParameterName("choice",false);
fTargMatCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fTargMatCmd->SetParameterName("choice", false);
fTargMatCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fChamMatCmd = new G4UIcmdWithAString("/B2/det/setChamberMaterial",this);
fChamMatCmd = new G4UIcmdWithAString("/B2/det/setChamberMaterial", this);
fChamMatCmd->SetGuidance("Select Material of the Chamber.");
fChamMatCmd->SetParameterName("choice",false);
fChamMatCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fChamMatCmd->SetParameterName("choice", false);
fChamMatCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fStepMaxCmd = new G4UIcmdWithADoubleAndUnit("/B2/det/stepMax",this);
fStepMaxCmd = new G4UIcmdWithADoubleAndUnit("/B2/det/stepMax", this);
fStepMaxCmd->SetGuidance("Define a step max");
fStepMaxCmd->SetParameterName("stepMax",false);
fStepMaxCmd->SetParameterName("stepMax", false);
fStepMaxCmd->SetUnitCategory("Length");
fStepMaxCmd->AvailableForStates(G4State_Idle);
}
@@ -78,20 +78,21 @@ DetectorMessenger::~DetectorMessenger()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if( command == fTargMatCmd )
{ fDetectorConstruction->SetTargetMaterial(newValue);}
if (command == fTargMatCmd) {
fDetectorConstruction->SetTargetMaterial(newValue);
}
if( command == fChamMatCmd )
{ fDetectorConstruction->SetChamberMaterial(newValue);}
if (command == fChamMatCmd) {
fDetectorConstruction->SetChamberMaterial(newValue);
}
if( command == fStepMaxCmd ) {
fDetectorConstruction
->SetMaxStep(fStepMaxCmd->GetNewDoubleValue(newValue));
if (command == fStepMaxCmd) {
fDetectorConstruction->SetMaxStep(fStepMaxCmd->GetNewDoubleValue(newValue));
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2a
+7 -13
View File
@@ -30,9 +30,7 @@
#include "EventAction.hh"
#include "G4Event.hh"
#include "G4EventManager.hh"
#include "G4TrajectoryContainer.hh"
#include "G4Trajectory.hh"
#include "G4ios.hh"
namespace B2
@@ -40,8 +38,7 @@ namespace B2
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventAction::BeginOfEventAction(const G4Event*)
{}
void EventAction::BeginOfEventAction(const G4Event*) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -56,19 +53,16 @@ void EventAction::EndOfEventAction(const G4Event* event)
// periodic printing
G4int eventID = event->GetEventID();
if ( eventID < 100 || eventID % 100 == 0) {
G4cout << ">>> Event: " << eventID << G4endl;
if ( trajectoryContainer ) {
G4cout << " " << n_trajectories
<< " trajectories stored in this event." << G4endl;
if (eventID < 100 || eventID % 100 == 0) {
G4cout << ">>> Event: " << eventID << G4endl;
if (trajectoryContainer) {
G4cout << " " << n_trajectories << " trajectories stored in this event." << G4endl;
}
G4VHitsCollection* hc = event->GetHCofThisEvent()->GetHC(0);
G4cout << " "
<< hc->GetSize() << " hits stored in this event" << G4endl;
G4cout << " " << hc->GetSize() << " hits stored in this event" << G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2
@@ -29,15 +29,12 @@
#include "PrimaryGeneratorAction.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4LogicalVolume.hh"
#include "G4Box.hh"
#include "G4Event.hh"
#include "G4LogicalVolume.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
namespace B2
{
@@ -51,12 +48,12 @@ PrimaryGeneratorAction::PrimaryGeneratorAction()
// default particle kinematic
G4ParticleDefinition* particleDefinition
= G4ParticleTable::GetParticleTable()->FindParticle("proton");
G4ParticleDefinition* particleDefinition =
G4ParticleTable::GetParticleTable()->FindParticle("proton");
fParticleGun->SetParticleDefinition(particleDefinition);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
fParticleGun->SetParticleEnergy(3.0*GeV);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.));
fParticleGun->SetParticleEnergy(3.0 * GeV);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -68,7 +65,7 @@ PrimaryGeneratorAction::~PrimaryGeneratorAction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* event)
{
// This function is called at the begining of event
@@ -77,12 +74,12 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
// from G4LogicalVolumeStore.
G4double worldZHalfLength = 0;
G4LogicalVolume* worldLV
= G4LogicalVolumeStore::GetInstance()->GetVolume("World");
G4LogicalVolume* worldLV = G4LogicalVolumeStore::GetInstance()->GetVolume("World");
G4Box* worldBox = nullptr;
if ( worldLV ) worldBox = dynamic_cast<G4Box*>(worldLV->GetSolid());
if ( worldBox ) worldZHalfLength = worldBox->GetZHalfLength();
else {
if (worldLV) worldBox = dynamic_cast<G4Box*>(worldLV->GetSolid());
if (worldBox)
worldZHalfLength = worldBox->GetZHalfLength();
else {
G4cerr << "World volume of box not found." << G4endl;
G4cerr << "Perhaps you have changed geometry." << G4endl;
G4cerr << "The gun will be place in the center." << G4endl;
@@ -90,12 +87,11 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
// Starting a primary particle close to the world boundary.
//
fParticleGun->SetParticlePosition(G4ThreeVector(0., 0., -worldZHalfLength+1*um));
fParticleGun->SetParticlePosition(G4ThreeVector(0., 0., -worldZHalfLength + 1 * um));
fParticleGun->GeneratePrimaryVertex(anEvent);
fParticleGun->GeneratePrimaryVertex(event);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2
+3 -6
View File
@@ -29,7 +29,6 @@
#include "RunAction.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
namespace B2
@@ -47,16 +46,14 @@ RunAction::RunAction()
void RunAction::BeginOfRunAction(const G4Run*)
{
//inform the runManager to save random number seed
// inform the runManager to save random number seed
G4RunManager::GetRunManager()->SetRandomNumberStore(false);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::EndOfRunAction(const G4Run* )
{}
void RunAction::EndOfRunAction(const G4Run*) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2
+9 -13
View File
@@ -28,10 +28,11 @@
/// \brief Implementation of the B2::TrackerHit class
#include "TrackerHit.hh"
#include "G4UnitsTable.hh"
#include "G4VVisManager.hh"
#include "G4Circle.hh"
#include "G4Colour.hh"
#include "G4UnitsTable.hh"
#include "G4VVisManager.hh"
#include "G4VisAttributes.hh"
#include <iomanip>
@@ -45,7 +46,7 @@ G4ThreadLocal G4Allocator<TrackerHit>* TrackerHitAllocator = nullptr;
G4bool TrackerHit::operator==(const TrackerHit& right) const
{
return ( this == &right ) ? true : false;
return (this == &right) ? true : false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -53,8 +54,7 @@ G4bool TrackerHit::operator==(const TrackerHit& right) const
void TrackerHit::Draw()
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if(pVVisManager)
{
if (pVVisManager) {
G4Circle circle(fPos);
circle.SetScreenSize(4.);
circle.SetFillStyle(G4Circle::filled);
@@ -68,15 +68,11 @@ void TrackerHit::Draw()
void TrackerHit::Print()
{
G4cout
<< " trackID: " << fTrackID << " chamberNb: " << fChamberNb
<< "Edep: "
<< std::setw(7) << G4BestUnit(fEdep,"Energy")
<< " Position: "
<< std::setw(7) << G4BestUnit( fPos,"Length")
<< G4endl;
G4cout << " trackID: " << fTrackID << " chamberNb: " << fChamberNb << "Edep: " << std::setw(7)
<< G4BestUnit(fEdep, "Energy") << " Position: " << std::setw(7)
<< G4BestUnit(fPos, "Length") << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2
+22 -27
View File
@@ -28,10 +28,11 @@
/// \brief Implementation of the B2::TrackerSD class
#include "TrackerSD.hh"
#include "G4HCofThisEvent.hh"
#include "G4SDManager.hh"
#include "G4Step.hh"
#include "G4ThreeVector.hh"
#include "G4SDManager.hh"
#include "G4ios.hh"
namespace B2
@@ -39,9 +40,8 @@ namespace B2
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
TrackerSD::TrackerSD(const G4String& name,
const G4String& hitsCollectionName)
: G4VSensitiveDetector(name)
TrackerSD::TrackerSD(const G4String& name, const G4String& hitsCollectionName)
: G4VSensitiveDetector(name)
{
collectionName.insert(hitsCollectionName);
}
@@ -52,37 +52,33 @@ void TrackerSD::Initialize(G4HCofThisEvent* hce)
{
// Create hits collection
fHitsCollection
= new TrackerHitsCollection(SensitiveDetectorName, collectionName[0]);
fHitsCollection = new TrackerHitsCollection(SensitiveDetectorName, collectionName[0]);
// Add this collection in hce
G4int hcID
= G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
hce->AddHitsCollection( hcID, fHitsCollection );
G4int hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
hce->AddHitsCollection(hcID, fHitsCollection);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool TrackerSD::ProcessHits(G4Step* aStep,
G4TouchableHistory*)
G4bool TrackerSD::ProcessHits(G4Step* step, G4TouchableHistory*)
{
// energy deposit
G4double edep = aStep->GetTotalEnergyDeposit();
G4double edep = step->GetTotalEnergyDeposit();
if (edep==0.) return false;
if (edep == 0.) return false;
auto newHit = new TrackerHit();
newHit->SetTrackID (aStep->GetTrack()->GetTrackID());
newHit->SetChamberNb(aStep->GetPreStepPoint()->GetTouchableHandle()
->GetCopyNumber());
newHit->SetTrackID(step->GetTrack()->GetTrackID());
newHit->SetChamberNb(step->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber());
newHit->SetEdep(edep);
newHit->SetPos (aStep->GetPostStepPoint()->GetPosition());
newHit->SetPos(step->GetPostStepPoint()->GetPosition());
fHitsCollection->insert( newHit );
fHitsCollection->insert(newHit);
//newHit->Print();
// newHit->Print();
return true;
}
@@ -91,16 +87,15 @@ G4bool TrackerSD::ProcessHits(G4Step* aStep,
void TrackerSD::EndOfEvent(G4HCofThisEvent*)
{
if ( verboseLevel>1 ) {
std::size_t nofHits = fHitsCollection->entries();
G4cout << G4endl
<< "-------->Hits Collection: in this event they are " << nofHits
<< " hits in the tracker chambers: " << G4endl;
for ( std::size_t i=0; i<nofHits; i++ ) (*fHitsCollection)[i]->Print();
if (verboseLevel > 1) {
std::size_t nofHits = fHitsCollection->entries();
G4cout << G4endl << "-------->Hits Collection: in this event they are " << nofHits
<< " hits in the tracker chambers: " << G4endl;
for (std::size_t i = 0; i < nofHits; i++)
(*fHitsCollection)[i]->Print();
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2