Import Geant4 11.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2021-12-10 14:46:44 +01:00
committed by Ben Morgan
parent 6399a014b6
commit 80e2389dd8
3932 changed files with 202519 additions and 246221 deletions
-230
View File
@@ -1,230 +0,0 @@
///\file "B2/.README.txt"
///\brief Example B2 README page
/*! \page ExampleB2 Example B2
This example simulates a simplified fixed target experiment.
\section B2_s1 GEOMETRY DEFINITION
The setup consists of a target followed by six chambers of increasing
transverse size at defined instances from the target. These chambers are
located in a region called the Tracker region.
Their shape are cylinders, constructed as simple cylinders
(in B2aDetectorConstruction) and as parametrised volumes
(in B2bDetectorConstruction), see also B2bChamberParameterisation class.
In addition, a global, uniform, and transverse magnetic field can be
applied using G4GlobalMagFieldMessenger, instantiated in
B2aDetectorConstruction::ConstructSDandField with a non zero field value,
or via interactive commands.
For example:
\verbatim
/globalField/setValue 0.2 0 0 tesla
\endverbatim
An instance of the B2TrackerSD class is created and associated with each
logical chamber volume (in B2a) and with the one G4LogicalVolume associated
with G4PVParameterised (in B2b).
One can change the materials of the target and the chambers
interactively via the commands defined in B2aDetectorMessenger
(or B2bDetectorMessenger). For example:
\verbatim
/B2/det/setTargetMaterial G4_WATER
/B2/det/setChamberMaterial G4_Ar
\endverbatim
\section B2_s2 PHYSICS LIST
The particle's type and the physic processes which will be available
in this example are set in the FTFP_BERT physics list. This physics list
requires data files for electromagnetic and hadronic processes.
See more on installation of the datasets in
<a href="http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/InstallationGuide/html/ch03s03.html">
Geant4 Installation Guide, Chapter 3.3: Note On Geant4 Datasets </a>.
The following datasets: G4LEDATA, G4LEVELGAMMADATA, G4SAIDXSDATA and
G4ENSDFSTATEDATA are mandatory for this example.
In addition, the build-in interactive command:
\verbatim
/process/(in)activate processName
\endverbatim
allows the user to activate/inactivate the processes one by one.
\section B2_s3 ACTION INITALIZATION
A newly introduced class, B2ActionInitialization,
instantiates and registers to Geant4 kernel all user action classes.
While in sequential mode the action classes are instatiated just once,
via invoking the method:
B2ActionInitialization::Build()
in multi-threading mode the same method is invoked for each thread worker
and so all user action classes are defined thread-local.
A run action class is instantiated both thread-local
and global that's why its instance is created also in the method
B2ActionInitialization::BuildForMaster()
which is invoked only in multi-threading mode.
\section B2_s4 PRIMARY GENERATOR
The primary generator action class employs the G4ParticleGun.
The primary kinematics consists of a single particle which starts at the world boundary
and hits the target perpendicular to the entrance face. The type of the particle
and its energy can be changed via the G4 built-in commands of
the G4ParticleGun class.
Note that this particular case of starting a primary particle on the world boundary
requires shooting in a direction towards inside the world.
\section B2_s5 RUNS and EVENTS
A run is a set of events.
The user has control:
- at Begin and End of each run (class B2RunAction)
- at Begin and End of each event (class B2EventAction)
- at Begin and End of each track (class TrackingAction, not used here)
- at End of each step (class SteppingAction, not used here)
The event number is written to the log file every requested number
of events in B2EventAction::BeginOfEventAction() and
B2EventAction::EndOfEventAction().
Moreover, for the first 100 events and every 100 events thereafter
information about the number of stored trajectories in the event
is printed as well as the number of hits stored in the G4VHitsCollection.
The run number is printed at B2RunAction::BeginOfRunAction(), where the
G4RunManager is also informed how to SetRandomNumberStore for storing
initial random number seeds per run or per event.
\section B2_s6 USER LIMITS
This example also illustrates how to introduce tracking constraints
like maximum step length, minimum kinetic energy etc. via the G4UserLimits
class and associated G4StepLimiter and G4UserSpecialCuts processes.
See B2aDetectorConstruction (or B2bDetectorConstruction).
The maximum step limit in the tracker region can be set by the interactive
command (see B2aDetectorMessenger, B2bDetectorMessenger classes).
For example:
\verbatim
/B2/det/stepMax 1.0 mm
\endverbatim
\section B2_s7 DETECTOR RESPONSE
A HIT is a step per step record of all the information needed to
simulate and analyse the detector response.
In this example the Tracker chambers are considered to be the detector.
Therefore, the chambers are declared 'sensitive detectors' (SD) in
the B2aDetectorConstruction (or B2bDetectorConstruction) class.
They are associated with an instance of the B2TrackerSD class.
Then, a Hit is defined as a set of 4 informations per step, inside
the chambers, namely:
- the track identifier (an integer),
- the chamber number,
- the total energy deposit in this step, and
- the position of the energy deposit.
A given hit is an instance of the class B2TrackerHit which is created
during the tracking of a particle, step by step, in the method
B2TrackerSD::ProcessHits(). This hit is inserted in a HitsCollection.
The HitsCollection is printed at the end of each event (via the method
B2TrackerSD::EndOfEvent()), under the control of the command:
\verbatim
/hits/verbose 2
\endverbatim
<hr>
The following paragraphs are common to all basic examples
\section B2_A VISUALISATION
The visualization manager is set via the G4VisExecutive class
in the main () function in exampleB2a.cc (or exampleB2b.cc).
The initialisation of the drawing is done via a set of /vis/ commands
in the macro vis.mac. This macro is automatically read from
the main function when the example is used in interactive running mode.
By default, vis.mac opens an OpenGL viewer (/vis/open OGL).
The user can change the initial viewer by commenting out this line
and instead uncommenting one of the other /vis/open statements, such as
HepRepFile or DAWNFILE (which produce files that can be viewed with the
HepRApp and DAWN viewers, respectively). Note that one can always
open new viewers at any time from the command line. For example, if
you already have a view in, say, an OpenGL window with a name
"viewer-0", then
\verbatim
/vis/open DAWNFILE
\endverbatim
then to get the same view
\verbatim
/vis/viewer/copyView viewer-0
\endverbatim
or to get the same view *plus* scene-modifications
\verbatim
/vis/viewer/set/all viewer-0
\endverbatim
then to see the result
\verbatim
/vis/viewer/flush
\endverbatim
The DAWNFILE, HepRepFile drivers are always available
(since they require no external libraries), but the OGL driver requires
that the Geant4 libraries have been built with the OpenGL option.
For more information on visualization, including information on how to
install and run DAWN, OpenGL and HepRApp, see the visualization tutorials,
for example,\n
- <a href="http://geant4.slac.stanford.edu/Presentations/vis/G4OpenGLTutorial/G4OpenGLTutorial.html">
OpenGL Tutorial </a>
- <a href="http://geant4.slac.stanford.edu/Presentations/vis/G4DAWNTutorial/G4DAWNTutorial.html">
DAWN Tutorial </a>
- <a href="http://geant4.slac.stanford.edu/Presentations/vis/G4HepRAppTutorial/G4HepRAppTutorial.html">
HepRApp Tutorial </a>
The tracks are automatically drawn at the end of each event, accumulated
for all events and erased at the beginning of the next run.
\section B2_B USER INTERFACES
The user command interface is set via the G4UIExecutive class
in the main () function in exampleB2a.cc
The selection of the user command interface is then done automatically
according to the Geant4 configuration or it can be done explicitly via
the third argument of the G4UIExecutive constructor (see exampleB2a.cc).
\section B2_C HOW TO RUN
- Execute exampleB2a in the 'interactive mode' with visualization
\verbatim
% exampleB2a
and type in the commands from run1.mac line by line:
Idle> /tracking/verbose 1
Idle> /run/beamOn 1
Idle> ...
Idle> exit
\endverbatim
or
\verbatim
Idle> /control/execute run1.mac
....
Idle> exit
\endverbatim
- Execute exampleB2a in the 'batch' mode from macro files
(without visualization)
\verbatim
% exampleB2a run2.mac
% exampleB2a exampleB2.in > exampleB2.out
\endverbatim
*/
+1 -1
View File
@@ -1,7 +1,7 @@
#----------------------------------------------------------------------------
# Setup the project
#
cmake_minimum_required(VERSION 3.12...3.20)
cmake_minimum_required(VERSION 3.16...3.21)
project(B2a)
#----------------------------------------------------------------------------
+4 -4
View File
@@ -27,8 +27,8 @@
/// \file exampleB2a.cc
/// \brief Main program of the B2a example
#include "B2aDetectorConstruction.hh"
#include "B2ActionInitialization.hh"
#include "DetectorConstruction.hh"
#include "ActionInitialization.hh"
#include "G4RunManagerFactory.hh"
#include "G4SteppingVerbose.hh"
@@ -64,14 +64,14 @@ int main(int argc,char** argv)
// Set mandatory initialization classes
//
runManager->SetUserInitialization(new B2aDetectorConstruction());
runManager->SetUserInitialization(new B2a::DetectorConstruction());
G4VModularPhysicsList* physicsList = new FTFP_BERT;
physicsList->RegisterPhysics(new G4StepLimiterPhysics());
runManager->SetUserInitialization(physicsList);
// Set user action classes
runManager->SetUserInitialization(new B2ActionInitialization());
runManager->SetUserInitialization(new B2::ActionInitialization());
// Initialize visualization
//
File diff suppressed because it is too large Load Diff
@@ -24,29 +24,31 @@
// ********************************************************************
//
//
/// \file B2ActionInitialization.hh
/// \brief Definition of the B2ActionInitialization class
/// \file ActionInitialization.hh
/// \brief Definition of the B2::ActionInitialization class
#ifndef B2ActionInitialization_h
#define B2ActionInitialization_h 1
#include "G4VUserActionInitialization.hh"
class B4DetectorConstruction;
namespace B2
{
/// Action initialization class.
///
class B2ActionInitialization : public G4VUserActionInitialization
class ActionInitialization : public G4VUserActionInitialization
{
public:
B2ActionInitialization();
virtual ~B2ActionInitialization();
ActionInitialization();
~ActionInitialization() override;
virtual void BuildForMaster() const;
virtual void Build() const;
void BuildForMaster() const override;
void Build() const override;
};
}
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
/// \file B2aDetectorConstruction.hh
/// \brief Definition of the B2aDetectorConstruction class
/// \file DetectorConstruction.hh
/// \brief Definition of the B2a::DetectorConstruction class
#ifndef B2aDetectorConstruction_h
#define B2aDetectorConstruction_h 1
@@ -40,20 +40,23 @@ class G4Material;
class G4UserLimits;
class G4GlobalMagFieldMessenger;
class B2aDetectorMessenger;
namespace B2a
{
class DetectorMessenger;
/// Detector construction class to define materials, geometry
/// and global uniform magnetic field.
class B2aDetectorConstruction : public G4VUserDetectorConstruction
class DetectorConstruction : public G4VUserDetectorConstruction
{
public:
B2aDetectorConstruction();
virtual ~B2aDetectorConstruction();
DetectorConstruction();
~DetectorConstruction() override;
public:
virtual G4VPhysicalVolume* Construct();
virtual void ConstructSDandField();
G4VPhysicalVolume* Construct() override;
void ConstructSDandField() override;
// Set methods
void SetTargetMaterial (G4String );
@@ -66,25 +69,25 @@ class B2aDetectorConstruction : public G4VUserDetectorConstruction
void DefineMaterials();
G4VPhysicalVolume* DefineVolumes();
// data members
G4int fNbOfChambers;
G4LogicalVolume* fLogicTarget; // pointer to the logical Target
G4LogicalVolume** fLogicChamber; // pointer to the logical Chamber
G4Material* fTargetMaterial; // pointer to the target material
G4Material* fChamberMaterial; // pointer to the chamber material
G4UserLimits* fStepLimit; // pointer to user step limits
B2aDetectorMessenger* fMessenger; // messenger
// static data members
static G4ThreadLocal G4GlobalMagFieldMessenger* fMagFieldMessenger;
// magnetic field messenger
// data members
G4int fNbOfChambers = 0;
G4bool fCheckOverlaps; // option to activate checking of volumes overlaps
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
G4UserLimits* fStepLimit = nullptr; // pointer to user step limits
DetectorMessenger* fMessenger = nullptr; // messenger
G4bool fCheckOverlaps = true; // option to activate checking of volumes overlaps
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
/// \file B2aDetectorMessenger.hh
/// \brief Definition of the B2aDetectorMessenger class
/// \file DetectorMessenger.hh
/// \brief Definition of the B2a::DetectorMessenger class
#ifndef B2aDetectorMessenger_h
#define B2aDetectorMessenger_h 1
@@ -33,40 +33,42 @@
#include "globals.hh"
#include "G4UImessenger.hh"
class B2aDetectorConstruction;
class G4UIdirectory;
class G4UIcmdWithAString;
class G4UIcmdWithADoubleAndUnit;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
namespace B2a
{
/// Messenger class that defines commands for B2aDetectorConstruction.
class DetectorConstruction;
/// Messenger class that defines commands for DetectorConstruction.
///
/// It implements commands:
/// - /B2/det/setTargetMaterial name
/// - /B2/det/setChamberMaterial name
/// - /B2/det/stepMax value unit
/// - //det/setTargetMaterial name
/// - //det/setChamberMaterial name
/// - //det/stepMax value unit
class B2aDetectorMessenger: public G4UImessenger
class DetectorMessenger: public G4UImessenger
{
public:
B2aDetectorMessenger(B2aDetectorConstruction* );
virtual ~B2aDetectorMessenger();
DetectorMessenger(DetectorConstruction* );
~DetectorMessenger() override;
virtual void SetNewValue(G4UIcommand*, G4String);
void SetNewValue(G4UIcommand*, G4String) override;
private:
B2aDetectorConstruction* fDetectorConstruction;
DetectorConstruction* fDetectorConstruction = nullptr;
G4UIdirectory* fB2Directory;
G4UIdirectory* fDetDirectory;
G4UIdirectory* fDirectory = nullptr;
G4UIdirectory* fDetDirectory = nullptr;
G4UIcmdWithAString* fTargMatCmd;
G4UIcmdWithAString* fChamMatCmd;
G4UIcmdWithAString* fTargMatCmd = nullptr;
G4UIcmdWithAString* fChamMatCmd = nullptr;
G4UIcmdWithADoubleAndUnit* fStepMaxCmd;
G4UIcmdWithADoubleAndUnit* fStepMaxCmd = nullptr;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
/// \file B2EventAction.hh
/// \brief Definition of the B2EventAction class
/// \file EventAction.hh
/// \brief Definition of the B2::EventAction class
#ifndef B2EventAction_h
#define B2EventAction_h 1
@@ -34,18 +34,21 @@
#include "globals.hh"
namespace B2
{
/// Event action class
class B2EventAction : public G4UserEventAction
class EventAction : public G4UserEventAction
{
public:
B2EventAction();
virtual ~B2EventAction();
EventAction();
~EventAction() override;
virtual void BeginOfEventAction(const G4Event* );
virtual void EndOfEventAction(const G4Event* );
void BeginOfEventAction(const G4Event* ) override;
void EndOfEventAction(const G4Event* ) override;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
/// \file B2PrimaryGeneratorAction.hh
/// \brief Definition of the B2PrimaryGeneratorAction class
/// \file PrimaryGeneratorAction.hh
/// \brief Definition of the B2::PrimaryGeneratorAction class
#ifndef B2PrimaryGeneratorAction_h
#define B2PrimaryGeneratorAction_h 1
@@ -36,6 +36,9 @@
class G4ParticleGun;
class G4Event;
namespace B2
{
/// The primary generator action class with particle gum.
///
/// It defines a single particle which hits the Tracker
@@ -43,13 +46,13 @@ class G4Event;
/// can be changed via the G4 build-in commands of G4ParticleGun class
/// (see the macros provided with this example).
class B2PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
B2PrimaryGeneratorAction();
virtual ~B2PrimaryGeneratorAction();
PrimaryGeneratorAction();
~PrimaryGeneratorAction() override;
virtual void GeneratePrimaries(G4Event* );
void GeneratePrimaries(G4Event* ) override;
G4ParticleGun* GetParticleGun() {return fParticleGun;}
@@ -57,9 +60,9 @@ class B2PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
void SetRandomFlag(G4bool );
private:
G4ParticleGun* fParticleGun; // G4 particle gun
G4ParticleGun* fParticleGun = nullptr; // G4 particle gun
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
/// \file B2RunAction.hh
/// \brief Definition of the B2RunAction class
/// \file RunAction.hh
/// \brief Definition of the B2::RunAction class
#ifndef B2RunAction_h
#define B2RunAction_h 1
@@ -33,22 +33,23 @@
#include "G4UserRunAction.hh"
#include "globals.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class G4Run;
namespace B2
{
/// Run action class
class B2RunAction : public G4UserRunAction
class RunAction : public G4UserRunAction
{
public:
B2RunAction();
virtual ~B2RunAction();
RunAction();
~RunAction() override;
virtual void BeginOfRunAction(const G4Run* run);
virtual void EndOfRunAction(const G4Run* run);
void BeginOfRunAction(const G4Run* run) override;
void EndOfRunAction(const G4Run* run) override;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
/// \file B2TrackerHit.hh
/// \brief Definition of the B2TrackerHit class
/// \file TrackerHit.hh
/// \brief Definition of the B2::TrackerHit class
#ifndef B2TrackerHit_h
#define B2TrackerHit_h 1
@@ -36,29 +36,32 @@
#include "G4ThreeVector.hh"
#include "tls.hh"
namespace B2
{
/// Tracker hit class
///
/// It defines data members to store the trackID, chamberNb, energy deposit,
/// and position of charged particles in a selected volume:
/// - fTrackID, fChamberNB, fEdep, fPos
class B2TrackerHit : public G4VHit
class TrackerHit : public G4VHit
{
public:
B2TrackerHit();
B2TrackerHit(const B2TrackerHit&);
virtual ~B2TrackerHit();
TrackerHit();
TrackerHit(const TrackerHit&) = default;
~TrackerHit() override;
// operators
const B2TrackerHit& operator=(const B2TrackerHit&);
G4bool operator==(const B2TrackerHit&) const;
TrackerHit& operator=(const TrackerHit&) = default;
G4bool operator==(const TrackerHit&) const;
inline void* operator new(size_t);
inline void operator delete(void*);
// methods from base class
virtual void Draw();
virtual void Print();
void Draw() override;
void Print() override;
// Set methods
void SetTrackID (G4int track) { fTrackID = track; };
@@ -73,35 +76,36 @@ class B2TrackerHit : public G4VHit
G4ThreeVector GetPos() const { return fPos; };
private:
G4int fTrackID;
G4int fChamberNb;
G4double fEdep;
G4ThreeVector fPos;
G4int fTrackID = -1;
G4int fChamberNb = -1;
G4double fEdep = 0.;
G4ThreeVector fPos;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
typedef G4THitsCollection<B2TrackerHit> B2TrackerHitsCollection;
typedef G4THitsCollection<TrackerHit> TrackerHitsCollection;
extern G4ThreadLocal G4Allocator<B2TrackerHit>* B2TrackerHitAllocator;
extern G4ThreadLocal G4Allocator<TrackerHit>* TrackerHitAllocator;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
inline void* B2TrackerHit::operator new(size_t)
inline void* TrackerHit::operator new(size_t)
{
if(!B2TrackerHitAllocator)
B2TrackerHitAllocator = new G4Allocator<B2TrackerHit>;
return (void *) B2TrackerHitAllocator->MallocSingle();
if(!TrackerHitAllocator)
TrackerHitAllocator = new G4Allocator<TrackerHit>;
return (void *) TrackerHitAllocator->MallocSingle();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
inline void B2TrackerHit::operator delete(void *hit)
inline void TrackerHit::operator delete(void *hit)
{
B2TrackerHitAllocator->FreeSingle((B2TrackerHit*) hit);
TrackerHitAllocator->FreeSingle((TrackerHit*) hit);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
#endif
@@ -24,45 +24,46 @@
// ********************************************************************
//
//
/// \file B2TrackerSD.hh
/// \brief Definition of the B2TrackerSD class
/// \file TrackerSD.hh
/// \brief Definition of the B2::TrackerSD class
#ifndef B2TrackerSD_h
#define B2TrackerSD_h 1
#include "G4VSensitiveDetector.hh"
#include "B2TrackerHit.hh"
#include "TrackerHit.hh"
#include <vector>
class G4Step;
class G4HCofThisEvent;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
namespace B2
{
/// B2Tracker sensitive detector class
/// Tracker sensitive detector class
///
/// The hits are accounted in hits in ProcessHits() function which is called
/// by Geant4 kernel at each step. A hit is created with each step with non zero
/// energy deposit.
class B2TrackerSD : public G4VSensitiveDetector
class TrackerSD : public G4VSensitiveDetector
{
public:
B2TrackerSD(const G4String& name,
TrackerSD(const G4String& name,
const G4String& hitsCollectionName);
virtual ~B2TrackerSD();
~TrackerSD() override;
// methods from base class
virtual void Initialize(G4HCofThisEvent* hitCollection);
virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* history);
virtual void EndOfEvent(G4HCofThisEvent* hitCollection);
void Initialize(G4HCofThisEvent* hitCollection) override;
G4bool ProcessHits(G4Step* step, G4TouchableHistory* history) override;
void EndOfEvent(G4HCofThisEvent* hitCollection) override;
private:
B2TrackerHitsCollection* fHitsCollection;
TrackerHitsCollection* fHitsCollection = nullptr;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
#endif
@@ -24,39 +24,44 @@
// ********************************************************************
//
//
/// \file B2ActionInitialization.cc
/// \brief Implementation of the B2ActionInitialization class
/// \file ActionInitialization.cc
/// \brief Implementation of the B2::ActionInitialization class
#include "B2ActionInitialization.hh"
#include "B2PrimaryGeneratorAction.hh"
#include "B2RunAction.hh"
#include "B2EventAction.hh"
#include "ActionInitialization.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
namespace B2
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2ActionInitialization::B2ActionInitialization()
: G4VUserActionInitialization()
ActionInitialization::ActionInitialization()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2ActionInitialization::~B2ActionInitialization()
ActionInitialization::~ActionInitialization()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2ActionInitialization::BuildForMaster() const
void ActionInitialization::BuildForMaster() const
{
SetUserAction(new B2RunAction);
SetUserAction(new RunAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2ActionInitialization::Build() const
void ActionInitialization::Build() const
{
SetUserAction(new B2PrimaryGeneratorAction);
SetUserAction(new B2RunAction);
SetUserAction(new B2EventAction);
SetUserAction(new PrimaryGeneratorAction);
SetUserAction(new RunAction);
SetUserAction(new EventAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
@@ -24,12 +24,12 @@
// ********************************************************************
//
//
/// \file B2aDetectorConstruction.cc
/// \brief Implementation of the B2aDetectorConstruction class
/// \file DetectorConstruction.cc
/// \brief Implementation of the B2a::DetectorConstruction class
#include "B2aDetectorConstruction.hh"
#include "B2aDetectorMessenger.hh"
#include "B2TrackerSD.hh"
#include "DetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "TrackerSD.hh"
#include "G4Material.hh"
#include "G4NistManager.hh"
@@ -52,20 +52,19 @@
#include "G4SystemOfUnits.hh"
using namespace B2;
namespace B2a
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ThreadLocal
G4GlobalMagFieldMessenger* B2aDetectorConstruction::fMagFieldMessenger = nullptr;
G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger = nullptr;
B2aDetectorConstruction::B2aDetectorConstruction()
:G4VUserDetectorConstruction(),
fNbOfChambers(0),
fLogicTarget(nullptr), fLogicChamber(nullptr),
fTargetMaterial(nullptr), fChamberMaterial(nullptr),
fStepLimit(nullptr),
fCheckOverlaps(true)
DetectorConstruction::DetectorConstruction()
{
fMessenger = new B2aDetectorMessenger(this);
fMessenger = new DetectorMessenger(this);
fNbOfChambers = 5;
fLogicChamber = new G4LogicalVolume*[fNbOfChambers];
@@ -73,7 +72,7 @@ B2aDetectorConstruction::B2aDetectorConstruction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2aDetectorConstruction::~B2aDetectorConstruction()
DetectorConstruction::~DetectorConstruction()
{
delete [] fLogicChamber;
delete fStepLimit;
@@ -82,7 +81,7 @@ B2aDetectorConstruction::~B2aDetectorConstruction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* B2aDetectorConstruction::Construct()
G4VPhysicalVolume* DetectorConstruction::Construct()
{
// Define materials
DefineMaterials();
@@ -93,7 +92,7 @@ G4VPhysicalVolume* B2aDetectorConstruction::Construct()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2aDetectorConstruction::DefineMaterials()
void DetectorConstruction::DefineMaterials()
{
// Material definition
@@ -114,7 +113,7 @@ void B2aDetectorConstruction::DefineMaterials()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* B2aDetectorConstruction::DefineVolumes()
G4VPhysicalVolume* DetectorConstruction::DefineVolumes()
{
G4Material* air = G4Material::GetMaterial("G4_AIR");
@@ -231,7 +230,7 @@ G4VPhysicalVolume* B2aDetectorConstruction::DefineVolumes()
if( fNbOfChambers > 0 ){
rmaxIncr = 0.5 * (lastLength-firstLength)/(fNbOfChambers-1);
if (chamberSpacing < chamberWidth) {
G4Exception("B2aDetectorConstruction::DefineVolumes()",
G4Exception("DetectorConstruction::DefineVolumes()",
"InvalidSetup", FatalException,
"Width>Spacing");
}
@@ -287,12 +286,12 @@ G4VPhysicalVolume* B2aDetectorConstruction::DefineVolumes()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2aDetectorConstruction::ConstructSDandField()
void DetectorConstruction::ConstructSDandField()
{
// Sensitive detectors
G4String trackerChamberSDname = "B2/TrackerChamberSD";
B2TrackerSD* aTrackerSD = new B2TrackerSD(trackerChamberSDname,
G4String trackerChamberSDname = "/TrackerChamberSD";
TrackerSD* aTrackerSD = new TrackerSD(trackerChamberSDname,
"TrackerHitsCollection");
G4SDManager::GetSDMpointer()->AddNewDetector(aTrackerSD);
// Setting aTrackerSD to all logical volumes with the same name
@@ -312,7 +311,7 @@ void B2aDetectorConstruction::ConstructSDandField()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2aDetectorConstruction::SetTargetMaterial(G4String materialName)
void DetectorConstruction::SetTargetMaterial(G4String materialName)
{
G4NistManager* nistManager = G4NistManager::Instance();
@@ -337,7 +336,7 @@ void B2aDetectorConstruction::SetTargetMaterial(G4String materialName)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2aDetectorConstruction::SetChamberMaterial(G4String materialName)
void DetectorConstruction::SetChamberMaterial(G4String materialName)
{
G4NistManager* nistManager = G4NistManager::Instance();
@@ -365,14 +364,18 @@ void B2aDetectorConstruction::SetChamberMaterial(G4String materialName)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2aDetectorConstruction::SetMaxStep(G4double maxStep)
void DetectorConstruction::SetMaxStep(G4double maxStep)
{
if ((fStepLimit)&&(maxStep>0.)) fStepLimit->SetMaxAllowedStep(maxStep);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2aDetectorConstruction::SetCheckOverlaps(G4bool checkOverlaps)
void DetectorConstruction::SetCheckOverlaps(G4bool checkOverlaps)
{
fCheckOverlaps = checkOverlaps;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
@@ -24,39 +24,41 @@
// ********************************************************************
//
//
/// \file B2bDetectorMessenger.cc
/// \brief Implementation of the B2bDetectorMessenger class
/// \file DetectorMessenger.cc
/// \brief Implementation of the B2a::DetectorMessenger class
#include "B2bDetectorMessenger.hh"
#include "B2bDetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "DetectorConstruction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
namespace B2a
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2bDetectorMessenger::B2bDetectorMessenger(B2bDetectorConstruction* Det)
: G4UImessenger(),
fDetectorConstruction(Det)
DetectorMessenger::DetectorMessenger(DetectorConstruction* det)
: fDetectorConstruction(det)
{
fB2Directory = new G4UIdirectory("/B2/");
fB2Directory->SetGuidance("UI commands specific to this example.");
fDirectory = new G4UIdirectory("//");
fDirectory->SetGuidance("UI commands specific to this example.");
fDetDirectory = new G4UIdirectory("/B2/det/");
fDetDirectory = new G4UIdirectory("//det/");
fDetDirectory->SetGuidance("Detector construction control");
fTargMatCmd = new G4UIcmdWithAString("/B2/det/setTargetMaterial",this);
fTargMatCmd = new G4UIcmdWithAString("//det/setTargetMaterial",this);
fTargMatCmd->SetGuidance("Select Material of the Target.");
fTargMatCmd->SetParameterName("choice",false);
fTargMatCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fChamMatCmd = new G4UIcmdWithAString("/B2/det/setChamberMaterial",this);
fChamMatCmd = new G4UIcmdWithAString("//det/setChamberMaterial",this);
fChamMatCmd->SetGuidance("Select Material of the Chamber.");
fChamMatCmd->SetParameterName("choice",false);
fChamMatCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fStepMaxCmd = new G4UIcmdWithADoubleAndUnit("/B2/det/stepMax",this);
fStepMaxCmd = new G4UIcmdWithADoubleAndUnit("//det/stepMax",this);
fStepMaxCmd->SetGuidance("Define a step max");
fStepMaxCmd->SetParameterName("stepMax",false);
fStepMaxCmd->SetUnitCategory("Length");
@@ -65,18 +67,18 @@ B2bDetectorMessenger::B2bDetectorMessenger(B2bDetectorConstruction* Det)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2bDetectorMessenger::~B2bDetectorMessenger()
DetectorMessenger::~DetectorMessenger()
{
delete fTargMatCmd;
delete fChamMatCmd;
delete fStepMaxCmd;
delete fB2Directory;
delete fDirectory;
delete fDetDirectory;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2bDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
{
if( command == fTargMatCmd )
{ fDetectorConstruction->SetTargetMaterial(newValue);}
@@ -91,3 +93,5 @@ void B2bDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
@@ -24,10 +24,10 @@
// ********************************************************************
//
//
/// \file B2EventAction.cc
/// \brief Implementation of the B2EventAction class
/// \file EventAction.cc
/// \brief Implementation of the B2::EventAction class
#include "B2EventAction.hh"
#include "EventAction.hh"
#include "G4Event.hh"
#include "G4EventManager.hh"
@@ -35,25 +35,27 @@
#include "G4Trajectory.hh"
#include "G4ios.hh"
namespace B2
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2EventAction::B2EventAction()
: G4UserEventAction()
EventAction::EventAction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2EventAction::~B2EventAction()
EventAction::~EventAction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2EventAction::BeginOfEventAction(const G4Event*)
void EventAction::BeginOfEventAction(const G4Event*)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2EventAction::EndOfEventAction(const G4Event* event)
void EventAction::EndOfEventAction(const G4Event* event)
{
// get number of stored trajectories
@@ -77,3 +79,6 @@ void B2EventAction::EndOfEventAction(const G4Event* event)
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
@@ -24,10 +24,10 @@
// ********************************************************************
//
//
/// \file B2PrimaryGeneratorAction.cc
/// \brief Implementation of the B2PrimaryGeneratorAction class
/// \file PrimaryGeneratorAction.cc
/// \brief Implementation of the B2::PrimaryGeneratorAction class
#include "B2PrimaryGeneratorAction.hh"
#include "PrimaryGeneratorAction.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4LogicalVolume.hh"
@@ -37,13 +37,14 @@
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
namespace B2
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2PrimaryGeneratorAction::B2PrimaryGeneratorAction()
: G4VUserPrimaryGeneratorAction()
PrimaryGeneratorAction::PrimaryGeneratorAction()
{
G4int nofParticles = 1;
fParticleGun = new G4ParticleGun(nofParticles);
@@ -60,14 +61,14 @@ B2PrimaryGeneratorAction::B2PrimaryGeneratorAction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2PrimaryGeneratorAction::~B2PrimaryGeneratorAction()
PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
delete fParticleGun;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
// This function is called at the begining of event
@@ -95,3 +96,6 @@ void B2PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
@@ -24,18 +24,20 @@
// ********************************************************************
//
//
/// \file B2RunAction.cc
/// \brief Implementation of the B2RunAction class
/// \file RunAction.cc
/// \brief Implementation of the B2::RunAction class
#include "B2RunAction.hh"
#include "RunAction.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
namespace B2
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2RunAction::B2RunAction()
: G4UserRunAction()
RunAction::RunAction()
{
// set printing event number per each 100 events
G4RunManager::GetRunManager()->SetPrintProgress(1000);
@@ -43,12 +45,12 @@ B2RunAction::B2RunAction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2RunAction::~B2RunAction()
RunAction::~RunAction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2RunAction::BeginOfRunAction(const G4Run*)
void RunAction::BeginOfRunAction(const G4Run*)
{
//inform the runManager to save random number seed
G4RunManager::GetRunManager()->SetRandomNumberStore(false);
@@ -56,7 +58,10 @@ void B2RunAction::BeginOfRunAction(const G4Run*)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2RunAction::EndOfRunAction(const G4Run* )
void RunAction::EndOfRunAction(const G4Run* )
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
@@ -24,10 +24,10 @@
// ********************************************************************
//
//
/// \file B2TrackerHit.cc
/// \brief Implementation of the B2TrackerHit class
/// \file TrackerHit.cc
/// \brief Implementation of the B2::TrackerHit class
#include "B2TrackerHit.hh"
#include "TrackerHit.hh"
#include "G4UnitsTable.hh"
#include "G4VVisManager.hh"
#include "G4Circle.hh"
@@ -36,55 +36,30 @@
#include <iomanip>
G4ThreadLocal G4Allocator<B2TrackerHit>* B2TrackerHitAllocator = nullptr;
namespace B2
{
G4ThreadLocal G4Allocator<TrackerHit>* TrackerHitAllocator = nullptr;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2TrackerHit::B2TrackerHit()
: G4VHit(),
fTrackID(-1),
fChamberNb(-1),
fEdep(0.),
fPos(G4ThreeVector())
TrackerHit::TrackerHit()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2TrackerHit::~B2TrackerHit() {}
TrackerHit::~TrackerHit() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2TrackerHit::B2TrackerHit(const B2TrackerHit& right)
: G4VHit()
{
fTrackID = right.fTrackID;
fChamberNb = right.fChamberNb;
fEdep = right.fEdep;
fPos = right.fPos;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const B2TrackerHit& B2TrackerHit::operator=(const B2TrackerHit& right)
{
fTrackID = right.fTrackID;
fChamberNb = right.fChamberNb;
fEdep = right.fEdep;
fPos = right.fPos;
return *this;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool B2TrackerHit::operator==(const B2TrackerHit& right) const
G4bool TrackerHit::operator==(const TrackerHit& right) const
{
return ( this == &right ) ? true : false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2TrackerHit::Draw()
void TrackerHit::Draw()
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if(pVVisManager)
@@ -101,7 +76,7 @@ void B2TrackerHit::Draw()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2TrackerHit::Print()
void TrackerHit::Print()
{
G4cout
<< " trackID: " << fTrackID << " chamberNb: " << fChamberNb
@@ -113,3 +88,5 @@ void B2TrackerHit::Print()
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
@@ -24,39 +24,41 @@
// ********************************************************************
//
//
/// \file B2TrackerSD.cc
/// \brief Implementation of the B2TrackerSD class
/// \file TrackerSD.cc
/// \brief Implementation of the B2::TrackerSD class
#include "B2TrackerSD.hh"
#include "TrackerSD.hh"
#include "G4HCofThisEvent.hh"
#include "G4Step.hh"
#include "G4ThreeVector.hh"
#include "G4SDManager.hh"
#include "G4ios.hh"
namespace B2
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2TrackerSD::B2TrackerSD(const G4String& name,
const G4String& hitsCollectionName)
: G4VSensitiveDetector(name),
fHitsCollection(nullptr)
TrackerSD::TrackerSD(const G4String& name,
const G4String& hitsCollectionName)
: G4VSensitiveDetector(name)
{
collectionName.insert(hitsCollectionName);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2TrackerSD::~B2TrackerSD()
TrackerSD::~TrackerSD()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2TrackerSD::Initialize(G4HCofThisEvent* hce)
void TrackerSD::Initialize(G4HCofThisEvent* hce)
{
// Create hits collection
fHitsCollection
= new B2TrackerHitsCollection(SensitiveDetectorName, collectionName[0]);
= new TrackerHitsCollection(SensitiveDetectorName, collectionName[0]);
// Add this collection in hce
@@ -67,7 +69,7 @@ void B2TrackerSD::Initialize(G4HCofThisEvent* hce)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool B2TrackerSD::ProcessHits(G4Step* aStep,
G4bool TrackerSD::ProcessHits(G4Step* aStep,
G4TouchableHistory*)
{
// energy deposit
@@ -75,7 +77,7 @@ G4bool B2TrackerSD::ProcessHits(G4Step* aStep,
if (edep==0.) return false;
B2TrackerHit* newHit = new B2TrackerHit();
TrackerHit* newHit = new TrackerHit();
newHit->SetTrackID (aStep->GetTrack()->GetTrackID());
newHit->SetChamberNb(aStep->GetPreStepPoint()->GetTouchableHandle()
@@ -92,7 +94,7 @@ G4bool B2TrackerSD::ProcessHits(G4Step* aStep,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2TrackerSD::EndOfEvent(G4HCofThisEvent*)
void TrackerSD::EndOfEvent(G4HCofThisEvent*)
{
if ( verboseLevel>1 ) {
G4int nofHits = fHitsCollection->entries();
@@ -104,3 +106,6 @@ void B2TrackerSD::EndOfEvent(G4HCofThisEvent*)
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
+1 -1
View File
@@ -1,7 +1,7 @@
#----------------------------------------------------------------------------
# Setup the project
#
cmake_minimum_required(VERSION 3.12...3.20)
cmake_minimum_required(VERSION 3.16...3.21)
project(B2b)
#----------------------------------------------------------------------------
+4 -4
View File
@@ -27,8 +27,8 @@
/// \file exampleB2b.cc
/// \brief Main program of the B2b example
#include "B2bDetectorConstruction.hh"
#include "B2ActionInitialization.hh"
#include "DetectorConstruction.hh"
#include "ActionInitialization.hh"
#include "G4RunManagerFactory.hh"
#include "G4SteppingVerbose.hh"
@@ -64,14 +64,14 @@ int main(int argc,char** argv)
// Set mandatory initialization classes
//
runManager->SetUserInitialization(new B2bDetectorConstruction());
runManager->SetUserInitialization(new B2b::DetectorConstruction());
G4VModularPhysicsList* physicsList = new FTFP_BERT;
physicsList->RegisterPhysics(new G4StepLimiterPhysics());
runManager->SetUserInitialization(physicsList);
// Set user action classes
runManager->SetUserInitialization(new B2ActionInitialization());
runManager->SetUserInitialization(new B2::ActionInitialization());
// Initialize visualization
//
File diff suppressed because it is too large Load Diff
@@ -24,29 +24,31 @@
// ********************************************************************
//
//
/// \file B2ActionInitialization.hh
/// \brief Definition of the B2ActionInitialization class
/// \file ActionInitialization.hh
/// \brief Definition of the B2::ActionInitialization class
#ifndef B2ActionInitialization_h
#define B2ActionInitialization_h 1
#include "G4VUserActionInitialization.hh"
class B4DetectorConstruction;
namespace B2
{
/// Action initialization class.
///
class B2ActionInitialization : public G4VUserActionInitialization
class ActionInitialization : public G4VUserActionInitialization
{
public:
B2ActionInitialization();
virtual ~B2ActionInitialization();
ActionInitialization();
~ActionInitialization() override;
virtual void BuildForMaster() const;
virtual void Build() const;
void BuildForMaster() const override;
void Build() const override;
};
}
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
/// \file B2bChamberParameterisation.hh
/// \brief Definition of the B2bChamberParameterisation class
/// \file ChamberParameterisation.hh
/// \brief Definition of the B2b::ChamberParameterisation class
#ifndef B2bChamberParameterisation_h
#define B2bChamberParameterisation_h 1
@@ -50,56 +50,59 @@ class G4Tubs;
class G4Polycone;
class G4Polyhedra;
namespace B2b
{
/// A parameterisation that describes a series of boxes along Z.
///
/// The boxes have equal width, & their lengths are a linear equation.
/// They are spaced an equal distance apart, starting from given location.
class B2bChamberParameterisation : public G4VPVParameterisation
class ChamberParameterisation : public G4VPVParameterisation
{
public:
B2bChamberParameterisation(G4int noChambers,
ChamberParameterisation(G4int noChambers,
G4double startZ,
G4double spacing,
G4double widthChamber,
G4double lengthInitial,
G4double lengthFinal );
virtual ~B2bChamberParameterisation();
~ChamberParameterisation() override;
void ComputeTransformation (const G4int copyNo,
G4VPhysicalVolume* physVol) const;
G4VPhysicalVolume* physVol) const override;
void ComputeDimensions (G4Tubs & trackerLayer, const G4int copyNo,
const G4VPhysicalVolume* physVol) const;
const G4VPhysicalVolume* physVol) const override;
private: // Dummy declarations to get rid of warnings ...
void ComputeDimensions (G4Box&,const G4int,
const G4VPhysicalVolume*) const {}
const G4VPhysicalVolume*) const override {}
void ComputeDimensions (G4Trd&,const G4int,
const G4VPhysicalVolume*) const {}
const G4VPhysicalVolume*) const override {}
void ComputeDimensions (G4Trap&,const G4int,
const G4VPhysicalVolume*) const {}
const G4VPhysicalVolume*) const override {}
void ComputeDimensions (G4Cons&,const G4int,
const G4VPhysicalVolume*) const {}
const G4VPhysicalVolume*) const override {}
void ComputeDimensions (G4Sphere&,const G4int,
const G4VPhysicalVolume*) const {}
const G4VPhysicalVolume*) const override {}
void ComputeDimensions (G4Orb&,const G4int,
const G4VPhysicalVolume*) const {}
const G4VPhysicalVolume*) const override {}
void ComputeDimensions (G4Ellipsoid&,const G4int,
const G4VPhysicalVolume*) const {}
const G4VPhysicalVolume*) const override {}
void ComputeDimensions (G4Torus&,const G4int,
const G4VPhysicalVolume*) const {}
const G4VPhysicalVolume*) const override {}
void ComputeDimensions (G4Para&,const G4int,
const G4VPhysicalVolume*) const {}
const G4VPhysicalVolume*) const override {}
void ComputeDimensions (G4Hype&,const G4int,
const G4VPhysicalVolume*) const {}
const G4VPhysicalVolume*) const override {}
void ComputeDimensions (G4Polycone&,const G4int,
const G4VPhysicalVolume*) const {}
const G4VPhysicalVolume*) const override {}
void ComputeDimensions (G4Polyhedra&,const G4int,
const G4VPhysicalVolume*) const {}
const G4VPhysicalVolume*) const override {}
private:
@@ -111,6 +114,6 @@ class B2bChamberParameterisation : public G4VPVParameterisation
G4double fRmaxIncr; // The Increment for the half-length
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
/// \file B2bDetectorConstruction.hh
/// \brief Definition of the B2bDetectorConstruction class
/// \file DetectorConstruction.hh
/// \brief Definition of the B2b::DetectorConstruction class
#ifndef B2bDetectorConstruction_h
#define B2bDetectorConstruction_h 1
@@ -40,20 +40,23 @@ class G4Material;
class G4UserLimits;
class G4GlobalMagFieldMessenger;
class B2bDetectorMessenger;
namespace B2b
{
class DetectorMessenger;
/// Detector construction class to define materials, geometry
/// and global uniform magnetic field.
class B2bDetectorConstruction : public G4VUserDetectorConstruction
class DetectorConstruction : public G4VUserDetectorConstruction
{
public:
B2bDetectorConstruction();
virtual ~B2bDetectorConstruction();
DetectorConstruction();
~DetectorConstruction() override;
public:
virtual G4VPhysicalVolume* Construct();
virtual void ConstructSDandField();
G4VPhysicalVolume* Construct() override;
void ConstructSDandField() override;
// Set methods
void SetTargetMaterial (G4String );
@@ -66,23 +69,23 @@ class B2bDetectorConstruction : public G4VUserDetectorConstruction
void DefineMaterials();
G4VPhysicalVolume* DefineVolumes();
// data members
G4LogicalVolume* fLogicTarget; // pointer to the logical Target
G4LogicalVolume* fLogicChamber; // pointer to the logical Chamber
G4Material* fTargetMaterial; // pointer to the target material
G4Material* fChamberMaterial; // pointer to the chamber material
G4UserLimits* fStepLimit; // pointer to user step limits
B2bDetectorMessenger* fMessenger; // detector messenger
// static data members
static G4ThreadLocal G4GlobalMagFieldMessenger* fMagFieldMessenger;
// magnetic field messenger
// data members
G4LogicalVolume* fLogicTarget = nullptr; // pointer to the logical Target
G4LogicalVolume* fLogicChamber = nullptr; // pointer to the logical Chamber
G4bool fCheckOverlaps; // option to activate checking of volumes overlaps
G4Material* fTargetMaterial = nullptr; // pointer to the target material
G4Material* fChamberMaterial = nullptr; // pointer to the chamber material
G4UserLimits* fStepLimit = nullptr; // pointer to user step limits
DetectorMessenger* fMessenger = nullptr; // messenger
G4bool fCheckOverlaps = true; // option to activate checking of volumes overlaps
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
/// \file B2bDetectorMessenger.hh
/// \brief Definition of the B2bDetectorMessenger class
/// \file DetectorMessenger.hh
/// \brief Definition of the B2b::DetectorMessenger class
#ifndef B2bDetectorMessenger_h
#define B2bDetectorMessenger_h 1
@@ -33,40 +33,42 @@
#include "globals.hh"
#include "G4UImessenger.hh"
class B2bDetectorConstruction;
class G4UIdirectory;
class G4UIcmdWithAString;
class G4UIcmdWithADoubleAndUnit;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
namespace B2b
{
/// Messenger class that defines commands for B2bDetectorConstruction.
class DetectorConstruction;
/// Messenger class that defines commands for B2b::DetectorConstruction.
///
/// It implements commands:
/// - /B2/det/setTargetMaterial name
/// - /B2/det/setChamberMaterial name
/// - /B2/det/stepMax value unit
class B2bDetectorMessenger: public G4UImessenger
class DetectorMessenger: public G4UImessenger
{
public:
B2bDetectorMessenger(B2bDetectorConstruction* );
virtual ~B2bDetectorMessenger();
DetectorMessenger(DetectorConstruction* );
~DetectorMessenger() override;
virtual void SetNewValue(G4UIcommand*, G4String);
void SetNewValue(G4UIcommand*, G4String) override;
private:
B2bDetectorConstruction* fDetectorConstruction;
DetectorConstruction* fDetectorConstruction = nullptr;
G4UIdirectory* fB2Directory;
G4UIdirectory* fDetDirectory;
G4UIdirectory* fDirectory = nullptr;
G4UIdirectory* fDetDirectory = nullptr;
G4UIcmdWithAString* fTargMatCmd;
G4UIcmdWithAString* fChamMatCmd;
G4UIcmdWithAString* fTargMatCmd = nullptr;
G4UIcmdWithAString* fChamMatCmd = nullptr;
G4UIcmdWithADoubleAndUnit* fStepMaxCmd;
G4UIcmdWithADoubleAndUnit* fStepMaxCmd = nullptr;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
/// \file B2EventAction.hh
/// \brief Definition of the B2EventAction class
/// \file EventAction.hh
/// \brief Definition of the B2::EventAction class
#ifndef B2EventAction_h
#define B2EventAction_h 1
@@ -34,18 +34,21 @@
#include "globals.hh"
namespace B2
{
/// Event action class
class B2EventAction : public G4UserEventAction
class EventAction : public G4UserEventAction
{
public:
B2EventAction();
virtual ~B2EventAction();
EventAction();
~EventAction() override;
virtual void BeginOfEventAction(const G4Event* );
virtual void EndOfEventAction(const G4Event* );
void BeginOfEventAction(const G4Event* ) override;
void EndOfEventAction(const G4Event* ) override;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
/// \file B2PrimaryGeneratorAction.hh
/// \brief Definition of the B2PrimaryGeneratorAction class
/// \file PrimaryGeneratorAction.hh
/// \brief Definition of the B2::PrimaryGeneratorAction class
#ifndef B2PrimaryGeneratorAction_h
#define B2PrimaryGeneratorAction_h 1
@@ -36,6 +36,9 @@
class G4ParticleGun;
class G4Event;
namespace B2
{
/// The primary generator action class with particle gum.
///
/// It defines a single particle which hits the Tracker
@@ -43,13 +46,13 @@ class G4Event;
/// can be changed via the G4 build-in commands of G4ParticleGun class
/// (see the macros provided with this example).
class B2PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
B2PrimaryGeneratorAction();
virtual ~B2PrimaryGeneratorAction();
PrimaryGeneratorAction();
~PrimaryGeneratorAction() override;
virtual void GeneratePrimaries(G4Event* );
void GeneratePrimaries(G4Event* ) override;
G4ParticleGun* GetParticleGun() {return fParticleGun;}
@@ -57,9 +60,9 @@ class B2PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
void SetRandomFlag(G4bool );
private:
G4ParticleGun* fParticleGun; // G4 particle gun
G4ParticleGun* fParticleGun = nullptr; // G4 particle gun
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
/// \file B2RunAction.hh
/// \brief Definition of the B2RunAction class
/// \file RunAction.hh
/// \brief Definition of the B2::RunAction class
#ifndef B2RunAction_h
#define B2RunAction_h 1
@@ -33,22 +33,23 @@
#include "G4UserRunAction.hh"
#include "globals.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class G4Run;
namespace B2
{
/// Run action class
class B2RunAction : public G4UserRunAction
class RunAction : public G4UserRunAction
{
public:
B2RunAction();
virtual ~B2RunAction();
RunAction();
~RunAction() override;
virtual void BeginOfRunAction(const G4Run* run);
virtual void EndOfRunAction(const G4Run* run);
void BeginOfRunAction(const G4Run* run) override;
void EndOfRunAction(const G4Run* run) override;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
/// \file B2TrackerHit.hh
/// \brief Definition of the B2TrackerHit class
/// \file TrackerHit.hh
/// \brief Definition of the B2::TrackerHit class
#ifndef B2TrackerHit_h
#define B2TrackerHit_h 1
@@ -36,29 +36,32 @@
#include "G4ThreeVector.hh"
#include "tls.hh"
namespace B2
{
/// Tracker hit class
///
/// It defines data members to store the trackID, chamberNb, energy deposit,
/// and position of charged particles in a selected volume:
/// - fTrackID, fChamberNB, fEdep, fPos
class B2TrackerHit : public G4VHit
class TrackerHit : public G4VHit
{
public:
B2TrackerHit();
B2TrackerHit(const B2TrackerHit&);
virtual ~B2TrackerHit();
TrackerHit();
TrackerHit(const TrackerHit&) = default;
~TrackerHit() override;
// operators
const B2TrackerHit& operator=(const B2TrackerHit&);
G4bool operator==(const B2TrackerHit&) const;
TrackerHit& operator=(const TrackerHit&) = default;
G4bool operator==(const TrackerHit&) const;
inline void* operator new(size_t);
inline void operator delete(void*);
// methods from base class
virtual void Draw();
virtual void Print();
void Draw() override;
void Print() override;
// Set methods
void SetTrackID (G4int track) { fTrackID = track; };
@@ -73,35 +76,36 @@ class B2TrackerHit : public G4VHit
G4ThreeVector GetPos() const { return fPos; };
private:
G4int fTrackID;
G4int fChamberNb;
G4double fEdep;
G4ThreeVector fPos;
G4int fTrackID = -1;
G4int fChamberNb = -1;
G4double fEdep = 0.;
G4ThreeVector fPos;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
typedef G4THitsCollection<B2TrackerHit> B2TrackerHitsCollection;
typedef G4THitsCollection<TrackerHit> TrackerHitsCollection;
extern G4ThreadLocal G4Allocator<B2TrackerHit>* B2TrackerHitAllocator;
extern G4ThreadLocal G4Allocator<TrackerHit>* TrackerHitAllocator;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
inline void* B2TrackerHit::operator new(size_t)
inline void* TrackerHit::operator new(size_t)
{
if(!B2TrackerHitAllocator)
B2TrackerHitAllocator = new G4Allocator<B2TrackerHit>;
return (void *) B2TrackerHitAllocator->MallocSingle();
if(!TrackerHitAllocator)
TrackerHitAllocator = new G4Allocator<TrackerHit>;
return (void *) TrackerHitAllocator->MallocSingle();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
inline void B2TrackerHit::operator delete(void *hit)
inline void TrackerHit::operator delete(void *hit)
{
B2TrackerHitAllocator->FreeSingle((B2TrackerHit*) hit);
TrackerHitAllocator->FreeSingle((TrackerHit*) hit);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
#endif
@@ -24,45 +24,46 @@
// ********************************************************************
//
//
/// \file B2TrackerSD.hh
/// \brief Definition of the B2TrackerSD class
/// \file TrackerSD.hh
/// \brief Definition of the B2::TrackerSD class
#ifndef B2TrackerSD_h
#define B2TrackerSD_h 1
#include "G4VSensitiveDetector.hh"
#include "B2TrackerHit.hh"
#include "TrackerHit.hh"
#include <vector>
class G4Step;
class G4HCofThisEvent;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
namespace B2
{
/// B2Tracker sensitive detector class
/// Tracker sensitive detector class
///
/// The hits are accounted in hits in ProcessHits() function which is called
/// by Geant4 kernel at each step. A hit is created with each step with non zero
/// energy deposit.
class B2TrackerSD : public G4VSensitiveDetector
class TrackerSD : public G4VSensitiveDetector
{
public:
B2TrackerSD(const G4String& name,
TrackerSD(const G4String& name,
const G4String& hitsCollectionName);
virtual ~B2TrackerSD();
~TrackerSD() override;
// methods from base class
virtual void Initialize(G4HCofThisEvent* hitCollection);
virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* history);
virtual void EndOfEvent(G4HCofThisEvent* hitCollection);
void Initialize(G4HCofThisEvent* hitCollection) override;
G4bool ProcessHits(G4Step* step, G4TouchableHistory* history) override;
void EndOfEvent(G4HCofThisEvent* hitCollection) override;
private:
B2TrackerHitsCollection* fHitsCollection;
TrackerHitsCollection* fHitsCollection = nullptr;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
#endif
@@ -24,39 +24,44 @@
// ********************************************************************
//
//
/// \file B2ActionInitialization.cc
/// \brief Implementation of the B2ActionInitialization class
/// \file ActionInitialization.cc
/// \brief Implementation of the B2::ActionInitialization class
#include "B2ActionInitialization.hh"
#include "B2PrimaryGeneratorAction.hh"
#include "B2RunAction.hh"
#include "B2EventAction.hh"
#include "ActionInitialization.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
namespace B2
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2ActionInitialization::B2ActionInitialization()
: G4VUserActionInitialization()
ActionInitialization::ActionInitialization()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2ActionInitialization::~B2ActionInitialization()
ActionInitialization::~ActionInitialization()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2ActionInitialization::BuildForMaster() const
void ActionInitialization::BuildForMaster() const
{
SetUserAction(new B2RunAction);
SetUserAction(new RunAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2ActionInitialization::Build() const
void ActionInitialization::Build() const
{
SetUserAction(new B2PrimaryGeneratorAction);
SetUserAction(new B2RunAction);
SetUserAction(new B2EventAction);
SetUserAction(new PrimaryGeneratorAction);
SetUserAction(new RunAction);
SetUserAction(new EventAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
@@ -24,26 +24,28 @@
// ********************************************************************
//
//
/// \file B2bChamberParameterisation.cc
/// \brief Implementation of the B2bChamberParameterisation class
/// \file ChamberParameterisation.cc
/// \brief Implementation of the B2b::ChamberParameterisation class
#include "B2bChamberParameterisation.hh"
#include "ChamberParameterisation.hh"
#include "G4VPhysicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4Tubs.hh"
#include "G4SystemOfUnits.hh"
namespace B2b
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2bChamberParameterisation::B2bChamberParameterisation(
ChamberParameterisation::ChamberParameterisation(
G4int noChambers,
G4double startZ, // Z of center of first
G4double spacingZ, // Z spacing of centers
G4double widthChamber,
G4double lengthInitial,
G4double lengthFinal )
: G4VPVParameterisation()
{
fNoChambers = noChambers;
fStartZ = startZ;
@@ -53,7 +55,7 @@ B2bChamberParameterisation::B2bChamberParameterisation(
if( noChambers > 0 ){
fRmaxIncr = 0.5 * (lengthFinal-lengthInitial)/(noChambers-1);
if (spacingZ < widthChamber) {
G4Exception("B2bChamberParameterisation::B2bChamberParameterisation()",
G4Exception("ChamberParameterisation::ChamberParameterisation()",
"InvalidSetup", FatalException,
"Width>Spacing");
}
@@ -62,12 +64,12 @@ B2bChamberParameterisation::B2bChamberParameterisation(
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2bChamberParameterisation::~B2bChamberParameterisation()
ChamberParameterisation::~ChamberParameterisation()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2bChamberParameterisation::ComputeTransformation
void ChamberParameterisation::ComputeTransformation
(const G4int copyNo, G4VPhysicalVolume* physVol) const
{
// Note: copyNo will start with zero!
@@ -79,7 +81,7 @@ void B2bChamberParameterisation::ComputeTransformation
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2bChamberParameterisation::ComputeDimensions
void ChamberParameterisation::ComputeDimensions
(G4Tubs& trackerChamber, const G4int copyNo, const G4VPhysicalVolume*) const
{
// Note: copyNo will start with zero!
@@ -92,3 +94,5 @@ void B2bChamberParameterisation::ComputeDimensions
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
@@ -24,13 +24,13 @@
// ********************************************************************
//
//
/// \file B2bDetectorConstruction.cc
/// \brief Implementation of the B2bDetectorConstruction class
/// \file DetectorConstruction.cc
/// \brief Implementation of the B2b::DetectorConstruction class
#include "B2bDetectorConstruction.hh"
#include "B2bDetectorMessenger.hh"
#include "B2bChamberParameterisation.hh"
#include "B2TrackerSD.hh"
#include "DetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "ChamberParameterisation.hh"
#include "TrackerSD.hh"
#include "G4Material.hh"
#include "G4NistManager.hh"
@@ -54,24 +54,24 @@
#include "G4SystemOfUnits.hh"
using namespace B2;
namespace B2b
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ThreadLocal
G4GlobalMagFieldMessenger* B2bDetectorConstruction::fMagFieldMessenger = nullptr;
G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger = nullptr;
B2bDetectorConstruction::B2bDetectorConstruction()
:G4VUserDetectorConstruction(),
fLogicTarget(nullptr), fLogicChamber(nullptr),
fTargetMaterial(nullptr), fChamberMaterial(nullptr),
fStepLimit(nullptr),
fCheckOverlaps(true)
DetectorConstruction::DetectorConstruction()
{
fMessenger = new B2bDetectorMessenger(this);
fMessenger = new DetectorMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2bDetectorConstruction::~B2bDetectorConstruction()
DetectorConstruction::~DetectorConstruction()
{
delete fStepLimit;
delete fMessenger;
@@ -79,7 +79,7 @@ B2bDetectorConstruction::~B2bDetectorConstruction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* B2bDetectorConstruction::Construct()
G4VPhysicalVolume* DetectorConstruction::Construct()
{
// Define materials
DefineMaterials();
@@ -90,7 +90,7 @@ G4VPhysicalVolume* B2bDetectorConstruction::Construct()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2bDetectorConstruction::DefineMaterials()
void DetectorConstruction::DefineMaterials()
{
// Material definition
@@ -111,7 +111,7 @@ void B2bDetectorConstruction::DefineMaterials()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* B2bDetectorConstruction::DefineVolumes()
G4VPhysicalVolume* DetectorConstruction::DefineVolumes()
{
G4Material* air = G4Material::GetMaterial("G4_AIR");
@@ -215,7 +215,7 @@ G4VPhysicalVolume* B2bDetectorConstruction::DefineVolumes()
G4double lastLength = trackerLength;
G4VPVParameterisation* chamberParam =
new B2bChamberParameterisation(
new ChamberParameterisation(
NbOfChambers, // NoChambers
firstPosition, // Z of center of first
chamberSpacing, // Z spacing of centers
@@ -276,13 +276,13 @@ G4VPhysicalVolume* B2bDetectorConstruction::DefineVolumes()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2bDetectorConstruction::ConstructSDandField()
void DetectorConstruction::ConstructSDandField()
{
// Sensitive detectors
G4String trackerChamberSDname = "B2/TrackerChamberSD";
B2TrackerSD* aTrackerSD = new B2TrackerSD(trackerChamberSDname,
"TrackerHitsCollection");
TrackerSD* aTrackerSD = new TrackerSD(trackerChamberSDname,
"TrackerHitsCollection");
G4SDManager::GetSDMpointer()->AddNewDetector(aTrackerSD);
SetSensitiveDetector( fLogicChamber, aTrackerSD );
@@ -299,7 +299,7 @@ void B2bDetectorConstruction::ConstructSDandField()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2bDetectorConstruction::SetTargetMaterial(G4String materialName)
void DetectorConstruction::SetTargetMaterial(G4String materialName)
{
G4NistManager* nistManager = G4NistManager::Instance();
@@ -324,7 +324,7 @@ void B2bDetectorConstruction::SetTargetMaterial(G4String materialName)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2bDetectorConstruction::SetChamberMaterial(G4String materialName)
void DetectorConstruction::SetChamberMaterial(G4String materialName)
{
G4NistManager* nistManager = G4NistManager::Instance();
@@ -349,9 +349,11 @@ void B2bDetectorConstruction::SetChamberMaterial(G4String materialName)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2bDetectorConstruction::SetMaxStep(G4double maxStep)
void DetectorConstruction::SetMaxStep(G4double maxStep)
{
if ((fStepLimit)&&(maxStep>0.)) fStepLimit->SetMaxAllowedStep(maxStep);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
@@ -24,24 +24,26 @@
// ********************************************************************
//
//
/// \file B2aDetectorMessenger.cc
/// \brief Implementation of the B2aDetectorMessenger class
/// \file DetectorMessenger.cc
/// \brief Implementation of the B2b::DetectorMessenger class
#include "B2aDetectorMessenger.hh"
#include "B2aDetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "DetectorConstruction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
namespace B2b
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2aDetectorMessenger::B2aDetectorMessenger(B2aDetectorConstruction* Det)
: G4UImessenger(),
fDetectorConstruction(Det)
DetectorMessenger::DetectorMessenger(DetectorConstruction* Det)
: fDetectorConstruction(Det)
{
fB2Directory = new G4UIdirectory("/B2/");
fB2Directory->SetGuidance("UI commands specific to this example.");
fDirectory = new G4UIdirectory("/B2/");
fDirectory->SetGuidance("UI commands specific to this example.");
fDetDirectory = new G4UIdirectory("/B2/det/");
fDetDirectory->SetGuidance("Detector construction control");
@@ -65,18 +67,18 @@ B2aDetectorMessenger::B2aDetectorMessenger(B2aDetectorConstruction* Det)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2aDetectorMessenger::~B2aDetectorMessenger()
DetectorMessenger::~DetectorMessenger()
{
delete fTargMatCmd;
delete fChamMatCmd;
delete fStepMaxCmd;
delete fB2Directory;
delete fDirectory;
delete fDetDirectory;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2aDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
{
if( command == fTargMatCmd )
{ fDetectorConstruction->SetTargetMaterial(newValue);}
@@ -91,3 +93,5 @@ void B2aDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
@@ -24,10 +24,10 @@
// ********************************************************************
//
//
/// \file B2EventAction.cc
/// \brief Implementation of the B2EventAction class
/// \file EventAction.cc
/// \brief Implementation of the B2::EventAction class
#include "B2EventAction.hh"
#include "EventAction.hh"
#include "G4Event.hh"
#include "G4EventManager.hh"
@@ -35,25 +35,27 @@
#include "G4Trajectory.hh"
#include "G4ios.hh"
namespace B2
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2EventAction::B2EventAction()
: G4UserEventAction()
EventAction::EventAction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2EventAction::~B2EventAction()
EventAction::~EventAction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2EventAction::BeginOfEventAction(const G4Event*)
void EventAction::BeginOfEventAction(const G4Event*)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2EventAction::EndOfEventAction(const G4Event* event)
void EventAction::EndOfEventAction(const G4Event* event)
{
// get number of stored trajectories
@@ -77,3 +79,6 @@ void B2EventAction::EndOfEventAction(const G4Event* event)
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
@@ -24,10 +24,10 @@
// ********************************************************************
//
//
/// \file B2PrimaryGeneratorAction.cc
/// \brief Implementation of the B2PrimaryGeneratorAction class
/// \file PrimaryGeneratorAction.cc
/// \brief Implementation of the B2::PrimaryGeneratorAction class
#include "B2PrimaryGeneratorAction.hh"
#include "PrimaryGeneratorAction.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4LogicalVolume.hh"
@@ -37,13 +37,14 @@
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
namespace B2
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2PrimaryGeneratorAction::B2PrimaryGeneratorAction()
: G4VUserPrimaryGeneratorAction()
PrimaryGeneratorAction::PrimaryGeneratorAction()
{
G4int nofParticles = 1;
fParticleGun = new G4ParticleGun(nofParticles);
@@ -60,14 +61,14 @@ B2PrimaryGeneratorAction::B2PrimaryGeneratorAction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2PrimaryGeneratorAction::~B2PrimaryGeneratorAction()
PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
delete fParticleGun;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
// This function is called at the begining of event
@@ -95,3 +96,6 @@ void B2PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
@@ -24,18 +24,20 @@
// ********************************************************************
//
//
/// \file B2RunAction.cc
/// \brief Implementation of the B2RunAction class
/// \file RunAction.cc
/// \brief Implementation of the B2::RunAction class
#include "B2RunAction.hh"
#include "RunAction.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
namespace B2
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2RunAction::B2RunAction()
: G4UserRunAction()
RunAction::RunAction()
{
// set printing event number per each 100 events
G4RunManager::GetRunManager()->SetPrintProgress(1000);
@@ -43,12 +45,12 @@ B2RunAction::B2RunAction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2RunAction::~B2RunAction()
RunAction::~RunAction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2RunAction::BeginOfRunAction(const G4Run*)
void RunAction::BeginOfRunAction(const G4Run*)
{
//inform the runManager to save random number seed
G4RunManager::GetRunManager()->SetRandomNumberStore(false);
@@ -56,7 +58,10 @@ void B2RunAction::BeginOfRunAction(const G4Run*)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2RunAction::EndOfRunAction(const G4Run* )
void RunAction::EndOfRunAction(const G4Run* )
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
@@ -24,10 +24,10 @@
// ********************************************************************
//
//
/// \file B2TrackerHit.cc
/// \brief Implementation of the B2TrackerHit class
/// \file TrackerHit.cc
/// \brief Implementation of the B2::TrackerHit class
#include "B2TrackerHit.hh"
#include "TrackerHit.hh"
#include "G4UnitsTable.hh"
#include "G4VVisManager.hh"
#include "G4Circle.hh"
@@ -36,55 +36,30 @@
#include <iomanip>
G4ThreadLocal G4Allocator<B2TrackerHit>* B2TrackerHitAllocator = nullptr;
namespace B2
{
G4ThreadLocal G4Allocator<TrackerHit>* TrackerHitAllocator = nullptr;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2TrackerHit::B2TrackerHit()
: G4VHit(),
fTrackID(-1),
fChamberNb(-1),
fEdep(0.),
fPos(G4ThreeVector())
TrackerHit::TrackerHit()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2TrackerHit::~B2TrackerHit() {}
TrackerHit::~TrackerHit() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2TrackerHit::B2TrackerHit(const B2TrackerHit& right)
: G4VHit()
{
fTrackID = right.fTrackID;
fChamberNb = right.fChamberNb;
fEdep = right.fEdep;
fPos = right.fPos;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const B2TrackerHit& B2TrackerHit::operator=(const B2TrackerHit& right)
{
fTrackID = right.fTrackID;
fChamberNb = right.fChamberNb;
fEdep = right.fEdep;
fPos = right.fPos;
return *this;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool B2TrackerHit::operator==(const B2TrackerHit& right) const
G4bool TrackerHit::operator==(const TrackerHit& right) const
{
return ( this == &right ) ? true : false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2TrackerHit::Draw()
void TrackerHit::Draw()
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if(pVVisManager)
@@ -101,7 +76,7 @@ void B2TrackerHit::Draw()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2TrackerHit::Print()
void TrackerHit::Print()
{
G4cout
<< " trackID: " << fTrackID << " chamberNb: " << fChamberNb
@@ -113,3 +88,5 @@ void B2TrackerHit::Print()
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
@@ -24,39 +24,41 @@
// ********************************************************************
//
//
/// \file B2TrackerSD.cc
/// \brief Implementation of the B2TrackerSD class
/// \file TrackerSD.cc
/// \brief Implementation of the B2::TrackerSD class
#include "B2TrackerSD.hh"
#include "TrackerSD.hh"
#include "G4HCofThisEvent.hh"
#include "G4Step.hh"
#include "G4ThreeVector.hh"
#include "G4SDManager.hh"
#include "G4ios.hh"
namespace B2
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2TrackerSD::B2TrackerSD(const G4String& name,
const G4String& hitsCollectionName)
: G4VSensitiveDetector(name),
fHitsCollection(nullptr)
TrackerSD::TrackerSD(const G4String& name,
const G4String& hitsCollectionName)
: G4VSensitiveDetector(name)
{
collectionName.insert(hitsCollectionName);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2TrackerSD::~B2TrackerSD()
TrackerSD::~TrackerSD()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2TrackerSD::Initialize(G4HCofThisEvent* hce)
void TrackerSD::Initialize(G4HCofThisEvent* hce)
{
// Create hits collection
fHitsCollection
= new B2TrackerHitsCollection(SensitiveDetectorName, collectionName[0]);
= new TrackerHitsCollection(SensitiveDetectorName, collectionName[0]);
// Add this collection in hce
@@ -67,7 +69,7 @@ void B2TrackerSD::Initialize(G4HCofThisEvent* hce)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool B2TrackerSD::ProcessHits(G4Step* aStep,
G4bool TrackerSD::ProcessHits(G4Step* aStep,
G4TouchableHistory*)
{
// energy deposit
@@ -75,7 +77,7 @@ G4bool B2TrackerSD::ProcessHits(G4Step* aStep,
if (edep==0.) return false;
B2TrackerHit* newHit = new B2TrackerHit();
TrackerHit* newHit = new TrackerHit();
newHit->SetTrackID (aStep->GetTrack()->GetTrackID());
newHit->SetChamberNb(aStep->GetPreStepPoint()->GetTouchableHandle()
@@ -92,16 +94,18 @@ G4bool B2TrackerSD::ProcessHits(G4Step* aStep,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2TrackerSD::EndOfEvent(G4HCofThisEvent*)
void TrackerSD::EndOfEvent(G4HCofThisEvent*)
{
if ( verboseLevel>1 ) {
G4int nofHits = fHitsCollection->entries();
G4cout
<< G4endl
<< "-------->Hits Collection: in this event they are " << nofHits
<< " hits in the tracker chambers: " << G4endl;
G4cout << G4endl
<< "-------->Hits Collection: in this event they are " << nofHits
<< " hits in the tracker chambers: " << G4endl;
for ( G4int i=0; i<nofHits; i++ ) (*fHitsCollection)[i]->Print();
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
+1 -1
View File
@@ -1,6 +1,6 @@
#---Adding example B2 subdirectories explicitly
# and a custom target to for building all example B2 options ----------
cmake_minimum_required(VERSION 3.12...3.20)
cmake_minimum_required(VERSION 3.16...3.21)
add_subdirectory(B2a)
add_subdirectory(B2b)
+4
View File
@@ -14,6 +14,10 @@ track of all tags.
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
13-07-21 I. Hrivnacova (exampleB2-V10-07-02)
- Introduced namespace instead of a class names prefix
- Declare overriding functions 'override' (and removed 'virtual' keyword)
31-05-21 I. Hrivnacova (exampleB2-V10-07-01)
- Use nullptr instead of 0, NULL
- Clean trailing whitespaces from all files
-205
View File
@@ -1,205 +0,0 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Example B2
----------
This example simulates a simplified fixed target experiment.
1- GEOMETRY DEFINITION
The setup consists of a target followed by six chambers of increasing
transverse size at defined instances from the target. These chambers are
located in a region called the Tracker region.
Their shape are cylinders, constructed as simple cylinders
(in B2aDetectorConstruction) and as parametrised volumes
(in B2bDetectorConstruction), see also B2bChamberParameterisation class.
In addition, a global, uniform, and transverse magnetic field can be
applied using G4GlobalMagFieldMessenger, instantiated in
B2[a,b]DetectorConstruction::ConstructSDandField with a non zero field value,
or via interactive commands.
For example:
/globalField/setValue 0.2 0 0 tesla
An instance of the B2TrackerSD class is created and associated with each
logical chamber volume (in B2a) and with the one G4LogicalVolume associated
with G4PVParameterised (in B2b).
One can change the materials of the target and the chambers
interactively via the commands defined in B2aDetectorMessenger
(or B2bDetectorMessenger). For example:
/B2/det/setTargetMaterial G4_WATER
/B2/det/setChamberMaterial G4_Ar
2- PHYSICS LIST
The particle's type and the physic processes which will be available
in this example are set in the FTFP_BERT physics list. This physics list
requires data files for electromagnetic and hadronic processes.
See more on installation of the datasets in Geant4 Installation Guide,
Chapter 3.3: Note On Geant4 Datasets:
http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/InstallationGuide/html/ch03s03.html
The following datasets: G4LEDATA, G4LEVELGAMMADATA, G4SAIDXSDATA and
G4ENSDFSTATEDATA are mandatory for this example.
In addition, the build-in interactive command:
/process/(in)activate processName
allows the user to activate/inactivate the processes one by one.
3- ACTION INITALIZATION
A newly introduced class, B2ActionInitialization,
instantiates and registers to Geant4 kernel all user action classes.
While in sequential mode the action classes are instatiated just once,
via invoking the method:
B2ActionInitialization::Build()
in multi-threading mode the same method is invoked for each thread worker
and so all user action classes are defined thread-local.
A run action class is instantiated both thread-local
and global that's why its instance has is created also in the method
B2ActionInitialization::BuildForMaster()
which is invoked only in multi-threading mode.
4- PRIMARY GENERATOR
The primary generator action class employs the G4ParticleGun.
The primary kinematics consists of a single particle which starts at the world boundary
and hits the target perpendicular to the entrance face. The type of the particle
and its energy can be changed via the G4 built-in commands of
the G4ParticleGun class.
Note that this particular case of starting a primary particle on the world boundary
requires shooting in a direction towards inside the world.
5- RUNS and EVENTS
A run is a set of events.
The user has control:
- at Begin and End of each run (class B2RunAction)
- at Begin and End of each event (class B2EventAction)
- at Begin and End of each track (class TrackingAction, not used here)
- at End of each step (class SteppingAction, not used here)
The event number is written to the log file every requested number
of events in B2EventAction::BeginOfEventAction() and
B2EventAction::EndOfEventAction().
Moreover, for the first 100 events and every 100 events thereafter
information about the number of stored trajectories in the event
is printed as well as the number of hits stored in the G4VHitsCollection.
The run number is printed at B2RunAction::BeginOfRunAction(), where the
G4RunManager is also informed how to SetRandomNumberStore for storing
initial random number seeds per run or per event.
6- USER LIMITS
This example also illustrates how to introduce tracking constraints
like maximum step length, minimum kinetic energy etc. via the G4UserLimits
class and associated G4StepLimiter and G4UserSpecialCuts processes.
See B2aDetectorConstruction (or B2bDetectorConstruction).
The maximum step limit in the tracker region can be set by the interactive
command (see B2aDetectorMessenger, B2bDetectorMessenger classes).
For example:
/B2/det/stepMax 1.0 mm
7- DETECTOR RESPONSE
A HIT is a step per step record of all the information needed to
simulate and analyse the detector response.
In this example the Tracker chambers are considered to be the detector.
Therefore, the chambers are declared 'sensitive detectors' (SD) in
the B2aDetectorConstruction (or B2bDetectorConstruction) class.
They are associated with an instance of the B2TrackerSD class.
Then, a Hit is defined as a set of 4 informations per step, inside
the chambers, namely:
- the track identifier (an integer),
- the chamber number,
- the total energy deposit in this step, and
- the position of the energy deposit.
A given hit is an instance of the class B2TrackerHit which is created
during the tracking of a particle, step by step, in the method
B2TrackerSD::ProcessHits(). This hit is inserted in a HitsCollection.
The HitsCollection is printed at the end of each event (via the method
B2TrackerSD::EndOfEvent()), under the control of the command:
/hits/verbose 2
The following paragraphs are common to all basic examples
A- VISUALISATION
The visualization manager is set via the G4VisExecutive class
in the main() function in exampleB2a.cc (or exampleB2b.cc).
The initialisation of the drawing is done via a set of /vis/ commands
in the macro vis.mac. This macro is automatically read from
the main function when the example is used in interactive running mode.
By default, vis.mac opens an OpenGL viewer (/vis/open OGL).
The user can change the initial viewer by commenting out this line
and instead uncommenting one of the other /vis/open statements, such as
HepRepFile or DAWNFILE (which produce files that can be viewed with the
HepRApp and DAWN viewers, respectively). Note that one can always
open new viewers at any time from the command line. For example, if
you already have a view in, say, an OpenGL window with a name
"viewer-0", then
/vis/open DAWNFILE
then to get the same view
/vis/viewer/copyView viewer-0
or to get the same view *plus* scene-modifications
/vis/viewer/set/all viewer-0
then to see the result
/vis/viewer/flush
The DAWNFILE, HepRepFile drivers are always available
(since they require no external libraries), but the OGL driver requires
that the Geant4 libraries have been built with the OpenGL option.
For more information on visualization, including information on how to
install and run DAWN, OpenGL and HepRApp, see the visualization tutorials,
for example,
http://geant4.slac.stanford.edu/Presentations/vis/G4[VIS]Tutorial/G4[VIS]Tutorial.html
(where [VIS] can be replaced by DAWN, OpenGL and HepRApp)
The tracks are automatically drawn at the end of each event, accumulated
for all events and erased at the beginning of the next run.
B- USER INTERFACES
The user command interface is set via the G4UIExecutive class
in the main() function in exampleB2a.cc
The selection of the user command interface is then done automatically
according to the Geant4 configuration or it can be done explicitly via
the third argument of the G4UIExecutive constructor (see exampleB4a.cc).
C- HOW TO RUN
- Execute exampleB2a in the 'interactive mode' with visualization
% exampleB2a
and type in the commands from run1.mac line by line:
Idle> /tracking/verbose 1
Idle> /run/beamOn 1
Idle> ...
Idle> exit
or
Idle> /control/execute run1.mac or run2.mac
....
Idle> exit
- Execute exampleB2a in the 'batch' mode from macro files
(without visualization)
% exampleB2a run2.mac
% exampleB2a exampleB2.in > exampleB2.out