Import Geant4 11.3.0.beta source tree
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -29,65 +29,62 @@
|
||||
|
||||
#include "ChamberParameterisation.hh"
|
||||
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
|
||||
namespace B2b
|
||||
{
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ChamberParameterisation::ChamberParameterisation(
|
||||
G4int noChambers,
|
||||
G4double startZ, // Z of center of first
|
||||
G4double spacingZ, // Z spacing of centers
|
||||
G4double widthChamber,
|
||||
G4double lengthInitial,
|
||||
G4double lengthFinal )
|
||||
ChamberParameterisation::ChamberParameterisation(G4int noChambers,
|
||||
G4double startZ, // Z of center of first
|
||||
G4double spacingZ, // Z spacing of centers
|
||||
G4double widthChamber, G4double lengthInitial,
|
||||
G4double lengthFinal)
|
||||
{
|
||||
fNoChambers = noChambers;
|
||||
fStartZ = startZ;
|
||||
fHalfWidth = 0.5*widthChamber;
|
||||
fSpacing = spacingZ;
|
||||
fRmaxFirst = 0.5 * lengthInitial;
|
||||
if( noChambers > 0 ){
|
||||
fRmaxIncr = 0.5 * (lengthFinal-lengthInitial)/(noChambers-1);
|
||||
if (spacingZ < widthChamber) {
|
||||
G4Exception("ChamberParameterisation::ChamberParameterisation()",
|
||||
"InvalidSetup", FatalException,
|
||||
"Width>Spacing");
|
||||
}
|
||||
}
|
||||
fNoChambers = noChambers;
|
||||
fStartZ = startZ;
|
||||
fHalfWidth = 0.5 * widthChamber;
|
||||
fSpacing = spacingZ;
|
||||
fRmaxFirst = 0.5 * lengthInitial;
|
||||
if (noChambers > 0) {
|
||||
fRmaxIncr = 0.5 * (lengthFinal - lengthInitial) / (noChambers - 1);
|
||||
if (spacingZ < widthChamber) {
|
||||
G4Exception("ChamberParameterisation::ChamberParameterisation()", "InvalidSetup",
|
||||
FatalException, "Width>Spacing");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ChamberParameterisation::ComputeTransformation
|
||||
(const G4int copyNo, G4VPhysicalVolume* physVol) const
|
||||
void ChamberParameterisation::ComputeTransformation(const G4int copyNo,
|
||||
G4VPhysicalVolume* physVol) const
|
||||
{
|
||||
// Note: copyNo will start with zero!
|
||||
G4double Zposition = fStartZ + copyNo * fSpacing;
|
||||
G4ThreeVector origin(0,0,Zposition);
|
||||
G4ThreeVector origin(0, 0, Zposition);
|
||||
physVol->SetTranslation(origin);
|
||||
physVol->SetRotation(nullptr);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ChamberParameterisation::ComputeDimensions
|
||||
(G4Tubs& trackerChamber, const G4int copyNo, const G4VPhysicalVolume*) const
|
||||
void ChamberParameterisation::ComputeDimensions(G4Tubs& trackerChamber, const G4int copyNo,
|
||||
const G4VPhysicalVolume*) const
|
||||
{
|
||||
// Note: copyNo will start with zero!
|
||||
G4double rmax = fRmaxFirst + copyNo * fRmaxIncr;
|
||||
trackerChamber.SetInnerRadius(0);
|
||||
trackerChamber.SetOuterRadius(rmax);
|
||||
trackerChamber.SetZHalfLength(fHalfWidth);
|
||||
trackerChamber.SetStartPhiAngle(0.*deg);
|
||||
trackerChamber.SetDeltaPhiAngle(360.*deg);
|
||||
trackerChamber.SetStartPhiAngle(0. * deg);
|
||||
trackerChamber.SetDeltaPhiAngle(360. * deg);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
}
|
||||
} // namespace B2b
|
||||
|
||||
@@ -28,31 +28,28 @@
|
||||
/// \brief Implementation of the B2b::DetectorConstruction class
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "DetectorMessenger.hh"
|
||||
|
||||
#include "ChamberParameterisation.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 "G4PVParameterised.hh"
|
||||
#include "G4GlobalMagFieldMessenger.hh"
|
||||
#include "G4AutoDelete.hh"
|
||||
|
||||
#include "G4GeometryTolerance.hh"
|
||||
#include "G4GeometryManager.hh"
|
||||
|
||||
#include "G4UserLimits.hh"
|
||||
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4UserLimits.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
|
||||
using namespace B2;
|
||||
|
||||
@@ -61,8 +58,7 @@ namespace B2b
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4ThreadLocal
|
||||
G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger = nullptr;
|
||||
G4ThreadLocal G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger = nullptr;
|
||||
|
||||
DetectorConstruction::DetectorConstruction()
|
||||
{
|
||||
@@ -100,7 +96,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");
|
||||
@@ -113,23 +109,23 @@ 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)
|
||||
|
||||
G4int NbOfChambers = 5;
|
||||
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 = (NbOfChambers+1)*chamberSpacing;
|
||||
G4double trackerLength = (NbOfChambers + 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
|
||||
|
||||
@@ -138,58 +134,57 @@ 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
|
||||
|
||||
// Tracker segments
|
||||
|
||||
@@ -201,42 +196,38 @@ G4VPhysicalVolume* DetectorConstruction::DefineVolumes()
|
||||
new G4LogicalVolume(chamberS, fChamberMaterial, "Chamber", nullptr, nullptr, nullptr);
|
||||
|
||||
G4double firstPosition = -trackerSize + chamberSpacing;
|
||||
G4double firstLength = trackerLength/10;
|
||||
G4double lastLength = trackerLength;
|
||||
G4double firstLength = trackerLength / 10;
|
||||
G4double lastLength = trackerLength;
|
||||
|
||||
G4VPVParameterisation* chamberParam =
|
||||
new ChamberParameterisation(
|
||||
NbOfChambers, // NoChambers
|
||||
firstPosition, // Z of center of first
|
||||
chamberSpacing, // Z spacing of centers
|
||||
chamberWidth, // chamber width
|
||||
firstLength, // initial length
|
||||
lastLength); // final length
|
||||
new ChamberParameterisation(NbOfChambers, // NoChambers
|
||||
firstPosition, // Z of center of first
|
||||
chamberSpacing, // Z spacing of centers
|
||||
chamberWidth, // chamber width
|
||||
firstLength, // initial length
|
||||
lastLength); // final length
|
||||
|
||||
// dummy value : kZAxis -- modified by parameterised volume
|
||||
|
||||
new G4PVParameterised("Chamber", // their name
|
||||
fLogicChamber, // their logical volume
|
||||
trackerLV, // Mother logical volume
|
||||
kZAxis, // Are placed along this axis
|
||||
NbOfChambers, // Number of chambers
|
||||
chamberParam, // The parametrisation
|
||||
fCheckOverlaps); // checking overlaps
|
||||
new G4PVParameterised("Chamber", // their name
|
||||
fLogicChamber, // their logical volume
|
||||
trackerLV, // Mother logical volume
|
||||
kZAxis, // Are placed along this axis
|
||||
NbOfChambers, // Number of chambers
|
||||
chamberParam, // The parametrisation
|
||||
fCheckOverlaps); // checking overlaps
|
||||
|
||||
G4cout << "There are " << NbOfChambers << " 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 " << NbOfChambers << " 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;
|
||||
|
||||
// Visualization attributes
|
||||
|
||||
G4VisAttributes boxVisAtt(G4Colour::White());
|
||||
|
||||
worldLV ->SetVisAttributes(boxVisAtt);
|
||||
fLogicTarget ->SetVisAttributes(boxVisAtt);
|
||||
trackerLV ->SetVisAttributes(boxVisAtt);
|
||||
worldLV->SetVisAttributes(boxVisAtt);
|
||||
fLogicTarget->SetVisAttributes(boxVisAtt);
|
||||
trackerLV->SetVisAttributes(boxVisAtt);
|
||||
|
||||
G4VisAttributes chamberVisAtt(G4Colour::Yellow());
|
||||
fLogicChamber->SetVisAttributes(chamberVisAtt);
|
||||
@@ -248,7 +239,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);
|
||||
|
||||
@@ -272,9 +263,9 @@ void DetectorConstruction::ConstructSDandField()
|
||||
// Sensitive detectors
|
||||
|
||||
G4String trackerChamberSDname = "B2/TrackerChamberSD";
|
||||
auto aTrackerSD = new TrackerSD(trackerChamberSDname, "TrackerHitsCollection");
|
||||
G4SDManager::GetSDMpointer()->AddNewDetector(aTrackerSD);
|
||||
SetSensitiveDetector( fLogicChamber, aTrackerSD );
|
||||
auto trackerSD = new TrackerSD(trackerChamberSDname, "TrackerHitsCollection");
|
||||
G4SDManager::GetSDMpointer()->AddNewDetector(trackerSD);
|
||||
SetSensitiveDetector(fLogicChamber, trackerSD);
|
||||
|
||||
// Create global magnetic field messenger.
|
||||
// Uniform magnetic field is then created automatically if
|
||||
@@ -293,22 +284,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,22 +305,18 @@ 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;
|
||||
if (fLogicChamber) fLogicChamber->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;
|
||||
if (fLogicChamber) fLogicChamber->SetMaterial(fChamberMaterial);
|
||||
G4cout << G4endl << "----> The chambers are made of " << materialName << G4endl;
|
||||
}
|
||||
else {
|
||||
G4cout << G4endl << "--> WARNING from SetChamberMaterial : " << materialName << " not found"
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,9 +324,9 @@ 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......
|
||||
|
||||
}
|
||||
} // namespace B2b
|
||||
|
||||
@@ -28,19 +28,19 @@
|
||||
/// \brief Implementation of the B2b::DetectorMessenger class
|
||||
|
||||
#include "DetectorMessenger.hh"
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
|
||||
namespace B2b
|
||||
{
|
||||
|
||||
//....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 B2b
|
||||
|
||||
@@ -30,18 +30,15 @@
|
||||
#include "EventAction.hh"
|
||||
|
||||
#include "G4Event.hh"
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4TrajectoryContainer.hh"
|
||||
#include "G4Trajectory.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
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,13 @@
|
||||
|
||||
#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"
|
||||
#include "globals.hh"
|
||||
|
||||
namespace B2
|
||||
{
|
||||
@@ -51,12 +49,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 +66,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 +75,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 +88,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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -28,20 +28,18 @@
|
||||
/// \brief Implementation of the B2::TrackerSD class
|
||||
|
||||
#include "TrackerSD.hh"
|
||||
|
||||
#include "G4HCofThisEvent.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4Step.hh"
|
||||
|
||||
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 +50,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 +85,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
|
||||
|
||||
Reference in New Issue
Block a user