Import Geant4 11.3.0.beta source tree
This commit is contained in:
@@ -33,63 +33,57 @@
|
||||
|
||||
#include "ExP01ChamberParameterisation.hh"
|
||||
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01ChamberParameterisation::ExP01ChamberParameterisation(
|
||||
G4int NoChambers,
|
||||
G4double startZ, // Z of center of first
|
||||
G4double spacingZ, // Z spacing of centers
|
||||
G4double widthChamber,
|
||||
G4double lengthInitial,
|
||||
G4double lengthFinal )
|
||||
: G4VPVParameterisation()
|
||||
ExP01ChamberParameterisation::ExP01ChamberParameterisation(
|
||||
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;
|
||||
fHalfWidth = widthChamber*0.5;
|
||||
fSpacing = spacingZ;
|
||||
fHalfLengthFirst = 0.5 * lengthInitial;
|
||||
// fHalfLengthLast = lengthFinal;
|
||||
fHalfLengthIncr = 0;
|
||||
if( NoChambers > 0 ){
|
||||
fHalfLengthIncr = 0.5 * (lengthFinal-lengthInitial)/NoChambers;
|
||||
fNoChambers = NoChambers;
|
||||
fStartZ = startZ;
|
||||
fHalfWidth = widthChamber * 0.5;
|
||||
fSpacing = spacingZ;
|
||||
fHalfLengthFirst = 0.5 * lengthInitial;
|
||||
// fHalfLengthLast = lengthFinal;
|
||||
fHalfLengthIncr = 0;
|
||||
if (NoChambers > 0) {
|
||||
fHalfLengthIncr = 0.5 * (lengthFinal - lengthInitial) / NoChambers;
|
||||
|
||||
if (spacingZ < widthChamber) {
|
||||
G4Exception(
|
||||
"ExN02ChamberParameterisation::ExN02ChamberParameterisation()",
|
||||
"InvalidSetup", FatalException,
|
||||
"Width>Spacing");
|
||||
}
|
||||
}
|
||||
|
||||
if (spacingZ < widthChamber) {
|
||||
G4Exception("ExN02ChamberParameterisation::ExN02ChamberParameterisation()", "InvalidSetup",
|
||||
FatalException, "Width>Spacing");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01ChamberParameterisation::~ExP01ChamberParameterisation()
|
||||
{}
|
||||
ExP01ChamberParameterisation::~ExP01ChamberParameterisation() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExP01ChamberParameterisation::ComputeTransformation
|
||||
(const G4int copyNo, G4VPhysicalVolume* physVol) const
|
||||
void ExP01ChamberParameterisation::ComputeTransformation(const G4int copyNo,
|
||||
G4VPhysicalVolume* physVol) const
|
||||
{
|
||||
G4double Zposition= fStartZ + (copyNo+1) * fSpacing;
|
||||
G4ThreeVector origin(0,0,Zposition);
|
||||
G4double Zposition = fStartZ + (copyNo + 1) * fSpacing;
|
||||
G4ThreeVector origin(0, 0, Zposition);
|
||||
physVol->SetTranslation(origin);
|
||||
physVol->SetRotation(0);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExP01ChamberParameterisation::ComputeDimensions
|
||||
(G4Box& trackerChamber, const G4int copyNo, const G4VPhysicalVolume*) const
|
||||
void ExP01ChamberParameterisation::ComputeDimensions(G4Box& trackerChamber, const G4int copyNo,
|
||||
const G4VPhysicalVolume*) const
|
||||
{
|
||||
G4double halfLength= fHalfLengthFirst + copyNo * fHalfLengthIncr;
|
||||
G4double halfLength = fHalfLengthFirst + copyNo * fHalfLengthIncr;
|
||||
trackerChamber.SetXHalfLength(halfLength);
|
||||
trackerChamber.SetYHalfLength(halfLength);
|
||||
trackerChamber.SetZHalfLength(fHalfWidth);
|
||||
|
||||
@@ -28,267 +28,276 @@
|
||||
//
|
||||
//
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "ExP01DetectorConstruction.hh"
|
||||
#include "ExP01DetectorMessenger.hh"
|
||||
|
||||
#include "ExP01ChamberParameterisation.hh"
|
||||
#include "ExP01DetectorMessenger.hh"
|
||||
#include "ExP01MagneticField.hh"
|
||||
#include "ExP01TrackerSD.hh"
|
||||
|
||||
#include "G4Material.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4PVParameterised.hh"
|
||||
#include "G4SDManager.hh"
|
||||
|
||||
#include "G4UserLimits.hh"
|
||||
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4PVParameterised.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4UserLimits.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
ExP01DetectorConstruction::ExP01DetectorConstruction()
|
||||
:G4VUserDetectorConstruction(),
|
||||
fSolidWorld(0), fLogicWorld(0), fPhysiWorld(0),
|
||||
fSolidTarget(0), fLogicTarget(0), fPhysiTarget(0),
|
||||
fSolidTracker(0), fLogicTracker(0), fPhysiTracker(0),
|
||||
fSolidChamber(0), fLogicChamber(0), fPhysiChamber(0),
|
||||
fTargetMater(0), fChamberMater(0), fPMagField(0), fDetectorMessenger(0),
|
||||
fWorldLength(0.), fTargetLength(0.), fTrackerLength(0.),
|
||||
fNbOfChambers(0), fChamberWidth(0.), fChamberSpacing(0.)
|
||||
: G4VUserDetectorConstruction(),
|
||||
fSolidWorld(0),
|
||||
fLogicWorld(0),
|
||||
fPhysiWorld(0),
|
||||
fSolidTarget(0),
|
||||
fLogicTarget(0),
|
||||
fPhysiTarget(0),
|
||||
fSolidTracker(0),
|
||||
fLogicTracker(0),
|
||||
fPhysiTracker(0),
|
||||
fSolidChamber(0),
|
||||
fLogicChamber(0),
|
||||
fPhysiChamber(0),
|
||||
fTargetMater(0),
|
||||
fChamberMater(0),
|
||||
fPMagField(0),
|
||||
fDetectorMessenger(0),
|
||||
fWorldLength(0.),
|
||||
fTargetLength(0.),
|
||||
fTrackerLength(0.),
|
||||
fNbOfChambers(0),
|
||||
fChamberWidth(0.),
|
||||
fChamberSpacing(0.)
|
||||
{
|
||||
fPMagField = new ExP01MagneticField();
|
||||
fDetectorMessenger = new ExP01DetectorMessenger(this);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
ExP01DetectorConstruction::~ExP01DetectorConstruction()
|
||||
{
|
||||
delete fPMagField;
|
||||
delete fDetectorMessenger;
|
||||
delete fDetectorMessenger;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
G4VPhysicalVolume* ExP01DetectorConstruction::Construct()
|
||||
{
|
||||
//--------- Material definition ---------
|
||||
//--------- Material definition ---------
|
||||
|
||||
G4double a, z;
|
||||
G4double density, temperature, pressure;
|
||||
G4int nel;
|
||||
|
||||
//Air
|
||||
G4Element* N = new G4Element("Nitrogen", "N", z=7., a= 14.01*g/mole);
|
||||
G4Element* O = new G4Element("Oxygen" , "O", z=8., a= 16.00*g/mole);
|
||||
|
||||
G4Material* Air = new G4Material("Air", density= 1.29*mg/cm3, nel=2);
|
||||
Air->AddElement(N, 70*perCent);
|
||||
Air->AddElement(O, 30*perCent);
|
||||
// Air
|
||||
G4Element* N = new G4Element("Nitrogen", "N", z = 7., a = 14.01 * g / mole);
|
||||
G4Element* O = new G4Element("Oxygen", "O", z = 8., a = 16.00 * g / mole);
|
||||
|
||||
//Lead
|
||||
G4Material* Pb =
|
||||
new G4Material("Lead", z=82., a= 207.19*g/mole, density= 11.35*g/cm3);
|
||||
|
||||
//Xenon gas
|
||||
G4Material* Xenon =
|
||||
new G4Material("XenonGas", z=54., a=131.29*g/mole, density= 5.458*mg/cm3,
|
||||
kStateGas, temperature= 293.15*kelvin, pressure= 1*atmosphere);
|
||||
G4Material* Air = new G4Material("Air", density = 1.29 * mg / cm3, nel = 2);
|
||||
Air->AddElement(N, 70 * perCent);
|
||||
Air->AddElement(O, 30 * perCent);
|
||||
|
||||
// Lead
|
||||
G4Material* Pb =
|
||||
new G4Material("Lead", z = 82., a = 207.19 * g / mole, density = 11.35 * g / cm3);
|
||||
|
||||
// Xenon gas
|
||||
G4Material* Xenon =
|
||||
new G4Material("XenonGas", z = 54., a = 131.29 * g / mole, density = 5.458 * mg / cm3,
|
||||
kStateGas, temperature = 293.15 * kelvin, pressure = 1 * atmosphere);
|
||||
|
||||
// Print all the materials defined.
|
||||
//
|
||||
G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
|
||||
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
|
||||
|
||||
//--------- Sizes of the principal geometrical components (solids) ---------
|
||||
|
||||
fNbOfChambers = 5;
|
||||
fChamberWidth = 20*cm;
|
||||
fChamberSpacing = 80*cm;
|
||||
|
||||
fTrackerLength = (fNbOfChambers+1)*fChamberSpacing; // Full length of Tracker
|
||||
fTargetLength = 5.0 * cm; // Full length of Target
|
||||
|
||||
fTargetMater = Pb;
|
||||
fChamberMater = Xenon;
|
||||
|
||||
fWorldLength= 1.2 *(fTargetLength+fTrackerLength);
|
||||
|
||||
G4double targetSize = 0.5*fTargetLength; // Half length of the Target
|
||||
G4double trackerSize = 0.5*fTrackerLength; // Half length of the Tracker
|
||||
|
||||
//--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
|
||||
|
||||
//------------------------------
|
||||
// World
|
||||
//------------------------------
|
||||
//--------- Sizes of the principal geometrical components (solids) ---------
|
||||
|
||||
fNbOfChambers = 5;
|
||||
fChamberWidth = 20 * cm;
|
||||
fChamberSpacing = 80 * cm;
|
||||
|
||||
fTrackerLength = (fNbOfChambers + 1) * fChamberSpacing; // Full length of Tracker
|
||||
fTargetLength = 5.0 * cm; // Full length of Target
|
||||
|
||||
fTargetMater = Pb;
|
||||
fChamberMater = Xenon;
|
||||
|
||||
fWorldLength = 1.2 * (fTargetLength + fTrackerLength);
|
||||
|
||||
G4double targetSize = 0.5 * fTargetLength; // Half length of the Target
|
||||
G4double trackerSize = 0.5 * fTrackerLength; // Half length of the Tracker
|
||||
|
||||
//--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
|
||||
|
||||
//------------------------------
|
||||
// World
|
||||
//------------------------------
|
||||
|
||||
G4double HalfWorldLength = 0.5 * fWorldLength;
|
||||
|
||||
fSolidWorld = new G4Box("world", HalfWorldLength, HalfWorldLength, HalfWorldLength);
|
||||
fLogicWorld = new G4LogicalVolume(fSolidWorld, Air, "World", 0, 0, 0);
|
||||
|
||||
G4double HalfWorldLength = 0.5*fWorldLength;
|
||||
|
||||
fSolidWorld= new G4Box("world",HalfWorldLength,HalfWorldLength,HalfWorldLength);
|
||||
fLogicWorld= new G4LogicalVolume( fSolidWorld, Air, "World", 0, 0, 0);
|
||||
|
||||
// Must place the World Physical volume unrotated at (0,0,0).
|
||||
//
|
||||
fPhysiWorld = new G4PVPlacement(0, // no rotation
|
||||
G4ThreeVector(), // at (0,0,0)
|
||||
fLogicWorld, // its logical volume
|
||||
"World", // its name
|
||||
0, // its mother volume
|
||||
false, // no boolean operations
|
||||
0); // copy number
|
||||
|
||||
//------------------------------
|
||||
//
|
||||
fPhysiWorld = new G4PVPlacement(0, // no rotation
|
||||
G4ThreeVector(), // at (0,0,0)
|
||||
fLogicWorld, // its logical volume
|
||||
"World", // its name
|
||||
0, // its mother volume
|
||||
false, // no boolean operations
|
||||
0); // copy number
|
||||
|
||||
//------------------------------
|
||||
// Target
|
||||
//------------------------------
|
||||
|
||||
G4ThreeVector positionTarget = G4ThreeVector(0,0,-(targetSize+trackerSize));
|
||||
|
||||
fSolidTarget = new G4Box("target",targetSize,targetSize,targetSize);
|
||||
fLogicTarget = new G4LogicalVolume(fSolidTarget,fTargetMater,"Target",0,0,0);
|
||||
fPhysiTarget = new G4PVPlacement(0, // no rotation
|
||||
positionTarget, // at (x,y,z)
|
||||
fLogicTarget, // its logical volume
|
||||
"Target", // its name
|
||||
fLogicWorld, // its mother volume
|
||||
false, // no boolean operations
|
||||
0); // copy number
|
||||
|
||||
G4cout << "Target is " << fTargetLength/cm << " cm of "
|
||||
<< fTargetMater->GetName() << G4endl;
|
||||
G4ThreeVector positionTarget = G4ThreeVector(0, 0, -(targetSize + trackerSize));
|
||||
|
||||
//------------------------------
|
||||
fSolidTarget = new G4Box("target", targetSize, targetSize, targetSize);
|
||||
fLogicTarget = new G4LogicalVolume(fSolidTarget, fTargetMater, "Target", 0, 0, 0);
|
||||
fPhysiTarget = new G4PVPlacement(0, // no rotation
|
||||
positionTarget, // at (x,y,z)
|
||||
fLogicTarget, // its logical volume
|
||||
"Target", // its name
|
||||
fLogicWorld, // its mother volume
|
||||
false, // no boolean operations
|
||||
0); // copy number
|
||||
|
||||
G4cout << "Target is " << fTargetLength / cm << " cm of " << fTargetMater->GetName() << G4endl;
|
||||
|
||||
//------------------------------
|
||||
// Tracker
|
||||
//------------------------------
|
||||
|
||||
G4ThreeVector positionTracker = G4ThreeVector(0,0,0);
|
||||
|
||||
fSolidTracker = new G4Box("tracker",trackerSize,trackerSize,trackerSize);
|
||||
fLogicTracker = new G4LogicalVolume(fSolidTracker , Air, "Tracker",0,0,0);
|
||||
fPhysiTracker = new G4PVPlacement(0, // no rotation
|
||||
positionTracker, // at (x,y,z)
|
||||
fLogicTracker, // its logical volume
|
||||
"Tracker", // its name
|
||||
fLogicWorld, // its mother volume
|
||||
false, // no boolean operations
|
||||
0); // copy number
|
||||
|
||||
//------------------------------
|
||||
G4ThreeVector positionTracker = G4ThreeVector(0, 0, 0);
|
||||
|
||||
fSolidTracker = new G4Box("tracker", trackerSize, trackerSize, trackerSize);
|
||||
fLogicTracker = new G4LogicalVolume(fSolidTracker, Air, "Tracker", 0, 0, 0);
|
||||
fPhysiTracker = new G4PVPlacement(0, // no rotation
|
||||
positionTracker, // at (x,y,z)
|
||||
fLogicTracker, // its logical volume
|
||||
"Tracker", // its name
|
||||
fLogicWorld, // its mother volume
|
||||
false, // no boolean operations
|
||||
0); // copy number
|
||||
|
||||
//------------------------------
|
||||
// Tracker segments
|
||||
//------------------------------
|
||||
//
|
||||
//
|
||||
// An example of Parameterised volumes
|
||||
// dummy values for G4Box -- modified by parameterised volume
|
||||
|
||||
fSolidChamber = new G4Box("chamber", 100*cm, 100*cm, 10*cm);
|
||||
fLogicChamber = new G4LogicalVolume(fSolidChamber, fChamberMater,"Chamber",0,0,0);
|
||||
|
||||
G4double firstPosition = -trackerSize + 0.5*fChamberWidth;
|
||||
G4double firstLength = fTrackerLength/10;
|
||||
G4double lastLength = fTrackerLength;
|
||||
|
||||
G4VPVParameterisation* chamberParam = new ExP01ChamberParameterisation(
|
||||
fNbOfChambers, // NoChambers
|
||||
firstPosition, // Z of center of first
|
||||
fChamberSpacing, // Z spacing of centers
|
||||
fChamberWidth, // Width Chamber
|
||||
firstLength, // lengthInitial
|
||||
lastLength); // lengthFinal
|
||||
|
||||
fSolidChamber = new G4Box("chamber", 100 * cm, 100 * cm, 10 * cm);
|
||||
fLogicChamber = new G4LogicalVolume(fSolidChamber, fChamberMater, "Chamber", 0, 0, 0);
|
||||
|
||||
G4double firstPosition = -trackerSize + 0.5 * fChamberWidth;
|
||||
G4double firstLength = fTrackerLength / 10;
|
||||
G4double lastLength = fTrackerLength;
|
||||
|
||||
G4VPVParameterisation* chamberParam =
|
||||
new ExP01ChamberParameterisation(fNbOfChambers, // NoChambers
|
||||
firstPosition, // Z of center of first
|
||||
fChamberSpacing, // Z spacing of centers
|
||||
fChamberWidth, // Width Chamber
|
||||
firstLength, // lengthInitial
|
||||
lastLength); // lengthFinal
|
||||
|
||||
// dummy value : kZAxis -- modified by parameterised volume
|
||||
//
|
||||
fPhysiChamber = new G4PVParameterised(
|
||||
"Chamber", // their name
|
||||
fLogicChamber, // their logical volume
|
||||
fLogicTracker, // Mother logical volume
|
||||
kZAxis, // Are placed along this axis
|
||||
fNbOfChambers, // Number of chambers
|
||||
chamberParam); // The parametrisation
|
||||
fPhysiChamber = new G4PVParameterised("Chamber", // their name
|
||||
fLogicChamber, // their logical volume
|
||||
fLogicTracker, // Mother logical volume
|
||||
kZAxis, // Are placed along this axis
|
||||
fNbOfChambers, // Number of chambers
|
||||
chamberParam); // The parametrisation
|
||||
|
||||
G4cout << "There are " << fNbOfChambers << " chambers in the tracker region. "
|
||||
<< "The chambers are " << fChamberWidth/mm << " mm of "
|
||||
<< fChamberMater->GetName() << "\n The distance between chamber is "
|
||||
<< fChamberSpacing/cm << " cm" << G4endl;
|
||||
|
||||
//------------------------------------------------
|
||||
<< "The chambers are " << fChamberWidth / mm << " mm of " << fChamberMater->GetName()
|
||||
<< "\n The distance between chamber is " << fChamberSpacing / cm << " cm" << G4endl;
|
||||
|
||||
//------------------------------------------------
|
||||
// Sensitive detectors
|
||||
//------------------------------------------------
|
||||
//------------------------------------------------
|
||||
|
||||
G4SDManager* SDman = G4SDManager::GetSDMpointer();
|
||||
|
||||
G4String trackerChamberSDname = "ExP01/TrackerChamberSD";
|
||||
ExP01TrackerSD* aTrackerSD = new ExP01TrackerSD( trackerChamberSDname );
|
||||
SDman->AddNewDetector( aTrackerSD );
|
||||
fLogicChamber->SetSensitiveDetector( aTrackerSD );
|
||||
ExP01TrackerSD* aTrackerSD = new ExP01TrackerSD(trackerChamberSDname);
|
||||
SDman->AddNewDetector(aTrackerSD);
|
||||
fLogicChamber->SetSensitiveDetector(aTrackerSD);
|
||||
|
||||
//--------- Visualization attributes -------------------------------
|
||||
//--------- Visualization attributes -------------------------------
|
||||
|
||||
G4VisAttributes* BoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
|
||||
fLogicWorld ->SetVisAttributes(BoxVisAtt);
|
||||
fLogicTarget ->SetVisAttributes(BoxVisAtt);
|
||||
G4VisAttributes* BoxVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
|
||||
fLogicWorld->SetVisAttributes(BoxVisAtt);
|
||||
fLogicTarget->SetVisAttributes(BoxVisAtt);
|
||||
fLogicTracker->SetVisAttributes(BoxVisAtt);
|
||||
|
||||
G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,0.0));
|
||||
|
||||
G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0));
|
||||
fLogicChamber->SetVisAttributes(ChamberVisAtt);
|
||||
|
||||
//--------- example of User Limits -------------------------------
|
||||
|
||||
//--------- example of User Limits -------------------------------
|
||||
|
||||
// below is an example of how to set tracking constraints in a given
|
||||
// logical volume(see also in N02PhysicsList how to setup the processes
|
||||
// G4StepLimiter or G4UserSpecialCuts).
|
||||
|
||||
|
||||
// Sets a max Step length in the tracker region, with G4StepLimiter
|
||||
//
|
||||
G4double maxStep = 0.5*fChamberWidth;
|
||||
G4double maxStep = 0.5 * fChamberWidth;
|
||||
fLogicTracker->SetUserLimits(new G4UserLimits(maxStep));
|
||||
|
||||
|
||||
// Set additional contraints on the track, with G4UserSpecialCuts
|
||||
//
|
||||
// G4double maxLength = 2*fTrackerLength, maxTime = 0.1*ns, minEkin = 10*MeV;
|
||||
// logicTracker->SetUserLimits(new G4UserLimits(maxStep,maxLength,maxTime,
|
||||
// minEkin));
|
||||
|
||||
|
||||
return fPhysiWorld;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
void ExP01DetectorConstruction::SetTargetMaterial(G4String materialName)
|
||||
{
|
||||
// search the material by its name
|
||||
G4Material* pttoMaterial = G4Material::GetMaterial(materialName);
|
||||
if (pttoMaterial)
|
||||
{fTargetMater = pttoMaterial;
|
||||
fLogicTarget->SetMaterial(pttoMaterial);
|
||||
G4cout << "\n----> The target is " << fTargetLength/cm << " cm of "
|
||||
<< materialName << G4endl;
|
||||
}
|
||||
// search the material by its name
|
||||
G4Material* pttoMaterial = G4Material::GetMaterial(materialName);
|
||||
if (pttoMaterial) {
|
||||
fTargetMater = pttoMaterial;
|
||||
fLogicTarget->SetMaterial(pttoMaterial);
|
||||
G4cout << "\n----> The target is " << fTargetLength / cm << " cm of " << materialName << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExP01DetectorConstruction::SetChamberMaterial(G4String materialName)
|
||||
{
|
||||
// search the material by its name
|
||||
G4Material* pttoMaterial = G4Material::GetMaterial(materialName);
|
||||
if (pttoMaterial)
|
||||
{fChamberMater = pttoMaterial;
|
||||
fLogicChamber->SetMaterial(pttoMaterial);
|
||||
G4cout << "\n----> The chambers are " << fChamberWidth/cm << " cm of "
|
||||
<< materialName << G4endl;
|
||||
}
|
||||
// search the material by its name
|
||||
G4Material* pttoMaterial = G4Material::GetMaterial(materialName);
|
||||
if (pttoMaterial) {
|
||||
fChamberMater = pttoMaterial;
|
||||
fLogicChamber->SetMaterial(pttoMaterial);
|
||||
G4cout << "\n----> The chambers are " << fChamberWidth / cm << " cm of " << materialName
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
void ExP01DetectorConstruction::SetMagField(G4double fieldValue)
|
||||
{
|
||||
fPMagField->SetFieldValue(fieldValue);
|
||||
|
||||
@@ -27,51 +27,52 @@
|
||||
/// \brief Implementation of the ExP01DetectorMessenger class
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "ExP01DetectorMessenger.hh"
|
||||
|
||||
#include "ExP01DetectorConstruction.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01DetectorMessenger::ExP01DetectorMessenger(ExP01DetectorConstruction* myDet)
|
||||
: G4UImessenger(),
|
||||
fDetector(myDet),
|
||||
fN02Dir(0),
|
||||
fDetDir(0),
|
||||
fTargMatCmd(0),
|
||||
fChamMatCmd(0),
|
||||
fFieldCmd(0)
|
||||
{
|
||||
: G4UImessenger(),
|
||||
fDetector(myDet),
|
||||
fN02Dir(0),
|
||||
fDetDir(0),
|
||||
fTargMatCmd(0),
|
||||
fChamMatCmd(0),
|
||||
fFieldCmd(0)
|
||||
{
|
||||
fN02Dir = new G4UIdirectory("/P01/");
|
||||
fN02Dir->SetGuidance("UI commands specific to this example.");
|
||||
|
||||
|
||||
fDetDir = new G4UIdirectory("/P01/det/");
|
||||
fDetDir->SetGuidance("detector control.");
|
||||
|
||||
fTargMatCmd = new G4UIcmdWithAString("/P01/det/setTargetMate",this);
|
||||
|
||||
fTargMatCmd = new G4UIcmdWithAString("/P01/det/setTargetMate", this);
|
||||
fTargMatCmd->SetGuidance("Select Material of the Target.");
|
||||
fTargMatCmd->SetParameterName("choice",false);
|
||||
fTargMatCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
fChamMatCmd = new G4UIcmdWithAString("/P01/det/setChamberMate",this);
|
||||
fTargMatCmd->SetParameterName("choice", false);
|
||||
fTargMatCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
fChamMatCmd = new G4UIcmdWithAString("/P01/det/setChamberMate", this);
|
||||
fChamMatCmd->SetGuidance("Select Material of the Target.");
|
||||
fChamMatCmd->SetParameterName("choice",false);
|
||||
fChamMatCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
fFieldCmd = new G4UIcmdWithADoubleAndUnit("/P01/det/setField",this);
|
||||
fChamMatCmd->SetParameterName("choice", false);
|
||||
fChamMatCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
fFieldCmd = new G4UIcmdWithADoubleAndUnit("/P01/det/setField", this);
|
||||
fFieldCmd->SetGuidance("Define magnetic field.");
|
||||
fFieldCmd->SetGuidance("Magnetic field will be in X direction.");
|
||||
fFieldCmd->SetParameterName("Bx",false);
|
||||
fFieldCmd->SetParameterName("Bx", false);
|
||||
fFieldCmd->SetUnitCategory("Magnetic flux density");
|
||||
fFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fFieldCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -87,16 +88,19 @@ ExP01DetectorMessenger::~ExP01DetectorMessenger()
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExP01DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
|
||||
{
|
||||
if( command == fTargMatCmd )
|
||||
{ fDetector->SetTargetMaterial(newValue);}
|
||||
|
||||
if( command == fChamMatCmd )
|
||||
{ fDetector->SetChamberMaterial(newValue);}
|
||||
|
||||
if( command == fFieldCmd )
|
||||
{ fDetector->SetMagField(fFieldCmd->GetNewDoubleValue(newValue));}
|
||||
void ExP01DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
{
|
||||
if (command == fTargMatCmd) {
|
||||
fDetector->SetTargetMaterial(newValue);
|
||||
}
|
||||
|
||||
if (command == fChamMatCmd) {
|
||||
fDetector->SetChamberMaterial(newValue);
|
||||
}
|
||||
|
||||
if (command == fFieldCmd) {
|
||||
fDetector->SetMagField(fFieldCmd->GetNewDoubleValue(newValue));
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -30,49 +30,44 @@
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
#include "ExP01EventAction.hh"
|
||||
|
||||
#include "G4Event.hh"
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4TrajectoryContainer.hh"
|
||||
#include "G4Trajectory.hh"
|
||||
#include "G4TrajectoryContainer.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01EventAction::ExP01EventAction()
|
||||
: G4UserEventAction()
|
||||
{}
|
||||
|
||||
ExP01EventAction::ExP01EventAction() : G4UserEventAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01EventAction::~ExP01EventAction()
|
||||
{}
|
||||
|
||||
ExP01EventAction::~ExP01EventAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExP01EventAction::BeginOfEventAction(const G4Event*)
|
||||
{}
|
||||
|
||||
void ExP01EventAction::BeginOfEventAction(const G4Event*) {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
void ExP01EventAction::EndOfEventAction(const G4Event* evt)
|
||||
{
|
||||
G4int event_id = evt->GetEventID();
|
||||
|
||||
|
||||
// get number of stored trajectories
|
||||
//
|
||||
G4TrajectoryContainer* trajectoryContainer = evt->GetTrajectoryContainer();
|
||||
G4int n_trajectories = 0;
|
||||
if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();
|
||||
|
||||
|
||||
// periodic printing
|
||||
//
|
||||
if (event_id < 100 || event_id%100 == 0) {
|
||||
if (event_id < 100 || event_id % 100 == 0) {
|
||||
G4cout << ">>> Event " << evt->GetEventID() << G4endl;
|
||||
G4cout << " " << n_trajectories
|
||||
<< " trajectories stored in this event." << G4endl;
|
||||
G4cout << " " << n_trajectories << " trajectories stored in this event." << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,19 +27,19 @@
|
||||
/// \brief Implementation of the ExP01MagneticField class
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// User Field class implementation.
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "ExP01MagneticField.hh"
|
||||
|
||||
#include "G4FieldManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01MagneticField::ExP01MagneticField()
|
||||
: G4UniformMagField(G4ThreeVector())
|
||||
ExP01MagneticField::ExP01MagneticField() : G4UniformMagField(G4ThreeVector())
|
||||
{
|
||||
GetGlobalFieldManager()->SetDetectorField(this);
|
||||
GetGlobalFieldManager()->CreateChordFinder(this);
|
||||
@@ -47,10 +47,9 @@ ExP01MagneticField::ExP01MagneticField()
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01MagneticField::ExP01MagneticField(G4ThreeVector fieldVector)
|
||||
: G4UniformMagField(fieldVector)
|
||||
ExP01MagneticField::ExP01MagneticField(G4ThreeVector fieldVector) : G4UniformMagField(fieldVector)
|
||||
{
|
||||
GetGlobalFieldManager()->SetDetectorField(this);
|
||||
GetGlobalFieldManager()->SetDetectorField(this);
|
||||
GetGlobalFieldManager()->CreateChordFinder(this);
|
||||
}
|
||||
|
||||
@@ -60,7 +59,7 @@ ExP01MagneticField::ExP01MagneticField(G4ThreeVector fieldVector)
|
||||
//
|
||||
void ExP01MagneticField::SetFieldValue(G4double fieldValue)
|
||||
{
|
||||
G4UniformMagField::SetFieldValue(G4ThreeVector(fieldValue,0,0));
|
||||
G4UniformMagField::SetFieldValue(G4ThreeVector(fieldValue, 0, 0));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -70,13 +69,13 @@ void ExP01MagneticField::SetFieldValue(G4double fieldValue)
|
||||
void ExP01MagneticField::SetFieldValue(G4ThreeVector fieldVector)
|
||||
{
|
||||
// Find the Field Manager for the global field
|
||||
G4FieldManager* fieldMgr= GetGlobalFieldManager();
|
||||
|
||||
if(fieldVector!=G4ThreeVector(0.,0.,0.))
|
||||
{
|
||||
G4FieldManager* fieldMgr = GetGlobalFieldManager();
|
||||
|
||||
if (fieldVector != G4ThreeVector(0., 0., 0.)) {
|
||||
G4UniformMagField::SetFieldValue(fieldVector);
|
||||
fieldMgr->SetDetectorField(this);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// If the new field's value is Zero, then it is best to
|
||||
// insure that it is not used for propagation.
|
||||
G4MagneticField* magField = NULL;
|
||||
@@ -95,7 +94,7 @@ ExP01MagneticField::~ExP01MagneticField()
|
||||
|
||||
#include "G4TransportationManager.hh"
|
||||
|
||||
G4FieldManager* ExP01MagneticField::GetGlobalFieldManager()
|
||||
G4FieldManager* ExP01MagneticField::GetGlobalFieldManager()
|
||||
{
|
||||
return G4TransportationManager::GetTransportationManager()->GetFieldManager();
|
||||
}
|
||||
|
||||
@@ -32,33 +32,32 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "ExP01PrimaryGeneratorAction.hh"
|
||||
|
||||
#include "ExP01DetectorConstruction.hh"
|
||||
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01PrimaryGeneratorAction::ExP01PrimaryGeneratorAction(
|
||||
ExP01DetectorConstruction* myDC)
|
||||
:G4VUserPrimaryGeneratorAction(),
|
||||
fParticleGun(0), fMyDetector(myDC)
|
||||
ExP01PrimaryGeneratorAction::ExP01PrimaryGeneratorAction(ExP01DetectorConstruction* myDC)
|
||||
: G4VUserPrimaryGeneratorAction(), fParticleGun(0), fMyDetector(myDC)
|
||||
{
|
||||
G4int n_particle = 1;
|
||||
fParticleGun = new G4ParticleGun(n_particle);
|
||||
|
||||
// default particle
|
||||
// default particle
|
||||
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
G4ParticleDefinition* particle = particleTable->FindParticle("proton");
|
||||
|
||||
|
||||
fParticleGun->SetParticleDefinition(particle);
|
||||
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......
|
||||
@@ -71,12 +70,11 @@ ExP01PrimaryGeneratorAction::~ExP01PrimaryGeneratorAction()
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExP01PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
G4double position = -0.5*(fMyDetector->GetWorldFullLength());
|
||||
fParticleGun->SetParticlePosition(G4ThreeVector(0.*cm,0.*cm,position));
|
||||
|
||||
{
|
||||
G4double position = -0.5 * (fMyDetector->GetWorldFullLength());
|
||||
fParticleGun->SetParticlePosition(G4ThreeVector(0. * cm, 0. * cm, position));
|
||||
|
||||
fParticleGun->GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/// \brief Implementation of the ExP01RunAction class
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -37,14 +37,11 @@
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01RunAction::ExP01RunAction()
|
||||
: G4UserRunAction()
|
||||
{}
|
||||
ExP01RunAction::ExP01RunAction() : G4UserRunAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01RunAction::~ExP01RunAction()
|
||||
{}
|
||||
ExP01RunAction::~ExP01RunAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -55,8 +52,6 @@ void ExP01RunAction::BeginOfRunAction(const G4Run* aRun)
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExP01RunAction::EndOfRunAction(const G4Run*)
|
||||
{ }
|
||||
void ExP01RunAction::EndOfRunAction(const G4Run*) {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
@@ -27,24 +27,20 @@
|
||||
/// \brief Implementation of the ExP01SteppingAction class
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "ExP01SteppingAction.hh"
|
||||
|
||||
#include "G4SteppingManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01SteppingAction::ExP01SteppingAction()
|
||||
: G4UserSteppingAction()
|
||||
{ }
|
||||
ExP01SteppingAction::ExP01SteppingAction() : G4UserSteppingAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExP01SteppingAction::UserSteppingAction(const G4Step*)
|
||||
{
|
||||
}
|
||||
void ExP01SteppingAction::UserSteppingAction(const G4Step*) {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
@@ -38,104 +38,87 @@
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01SteppingVerbose::ExP01SteppingVerbose()
|
||||
: G4SteppingVerbose()
|
||||
{}
|
||||
ExP01SteppingVerbose::ExP01SteppingVerbose() : G4SteppingVerbose() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01SteppingVerbose::~ExP01SteppingVerbose()
|
||||
{}
|
||||
|
||||
ExP01SteppingVerbose::~ExP01SteppingVerbose() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExP01SteppingVerbose::StepInfo()
|
||||
{
|
||||
CopyState();
|
||||
|
||||
|
||||
G4int prec = G4cout.precision(3);
|
||||
|
||||
if( verboseLevel >= 1 ){
|
||||
if( verboseLevel >= 4 ) VerboseTrack();
|
||||
if( verboseLevel >= 3 ){
|
||||
G4cout << G4endl;
|
||||
G4cout << std::setw( 5) << "#Step#" << " "
|
||||
<< std::setw( 6) << "X" << " "
|
||||
<< std::setw( 6) << "Y" << " "
|
||||
<< std::setw( 6) << "Z" << " "
|
||||
<< std::setw( 9) << "KineE" << " "
|
||||
<< std::setw( 9) << "dEStep" << " "
|
||||
<< std::setw(10) << "StepLeng"
|
||||
<< std::setw(10) << "TrakLeng"
|
||||
<< std::setw(10) << "Volume" << " "
|
||||
<< std::setw(10) << "Process" << G4endl;
|
||||
if (verboseLevel >= 1) {
|
||||
if (verboseLevel >= 4) VerboseTrack();
|
||||
if (verboseLevel >= 3) {
|
||||
G4cout << G4endl;
|
||||
G4cout << std::setw(5) << "#Step#"
|
||||
<< " " << std::setw(6) << "X"
|
||||
<< " " << std::setw(6) << "Y"
|
||||
<< " " << std::setw(6) << "Z"
|
||||
<< " " << std::setw(9) << "KineE"
|
||||
<< " " << std::setw(9) << "dEStep"
|
||||
<< " " << std::setw(10) << "StepLeng" << std::setw(10) << "TrakLeng" << std::setw(10)
|
||||
<< "Volume"
|
||||
<< " " << std::setw(10) << "Process" << G4endl;
|
||||
}
|
||||
|
||||
G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
|
||||
<< " ";
|
||||
G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " " << std::setw(6)
|
||||
<< G4BestUnit(fTrack->GetPosition().x(), "Length") << std::setw(6)
|
||||
<< G4BestUnit(fTrack->GetPosition().y(), "Length") << std::setw(6)
|
||||
<< G4BestUnit(fTrack->GetPosition().z(), "Length") << std::setw(6)
|
||||
<< G4BestUnit(fTrack->GetKineticEnergy(), "Energy") << std::setw(6)
|
||||
<< G4BestUnit(fStep->GetTotalEnergyDeposit(), "Energy") << std::setw(6)
|
||||
<< G4BestUnit(fStep->GetStepLength(), "Length") << std::setw(6)
|
||||
<< G4BestUnit(fTrack->GetTrackLength(), "Length") << " ";
|
||||
|
||||
// if( fStepStatus != fWorldBoundary){
|
||||
if( fTrack->GetNextVolume() != 0 ) {
|
||||
// if( fStepStatus != fWorldBoundary){
|
||||
if (fTrack->GetNextVolume() != 0) {
|
||||
G4cout << std::setw(10) << fTrack->GetVolume()->GetName();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
G4cout << std::setw(10) << "OutOfWorld";
|
||||
}
|
||||
|
||||
if(fStep->GetPostStepPoint()->GetProcessDefinedStep() != NULL){
|
||||
G4cout << " "
|
||||
<< std::setw(10) << fStep->GetPostStepPoint()->GetProcessDefinedStep()
|
||||
->GetProcessName();
|
||||
} else {
|
||||
if (fStep->GetPostStepPoint()->GetProcessDefinedStep() != NULL) {
|
||||
G4cout << " " << std::setw(10)
|
||||
<< fStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName();
|
||||
}
|
||||
else {
|
||||
G4cout << " UserLimit";
|
||||
}
|
||||
|
||||
G4cout << G4endl;
|
||||
|
||||
if( verboseLevel == 2 ){
|
||||
G4int tN2ndariesTot = fN2ndariesAtRestDoIt +
|
||||
fN2ndariesAlongStepDoIt +
|
||||
fN2ndariesPostStepDoIt;
|
||||
if(tN2ndariesTot>0){
|
||||
if (verboseLevel == 2) {
|
||||
G4int tN2ndariesTot = fN2ndariesAtRestDoIt + fN2ndariesAlongStepDoIt + fN2ndariesPostStepDoIt;
|
||||
if (tN2ndariesTot > 0) {
|
||||
G4cout << " :----- List of 2ndaries - "
|
||||
<< "#SpawnInStep=" << std::setw(3) << tN2ndariesTot
|
||||
<< "(Rest=" << std::setw(2) << fN2ndariesAtRestDoIt
|
||||
<< ",Along=" << std::setw(2) << fN2ndariesAlongStepDoIt
|
||||
<< ",Post=" << std::setw(2) << fN2ndariesPostStepDoIt
|
||||
<< "), "
|
||||
<< "#SpawnTotal=" << std::setw(3) << (*fSecondary).size()
|
||||
<< " ---------------"
|
||||
<< "#SpawnInStep=" << std::setw(3) << tN2ndariesTot << "(Rest=" << std::setw(2)
|
||||
<< fN2ndariesAtRestDoIt << ",Along=" << std::setw(2) << fN2ndariesAlongStepDoIt
|
||||
<< ",Post=" << std::setw(2) << fN2ndariesPostStepDoIt << "), "
|
||||
<< "#SpawnTotal=" << std::setw(3) << (*fSecondary).size() << " ---------------"
|
||||
<< G4endl;
|
||||
|
||||
for(size_t lp1=(*fSecondary).size()-tN2ndariesTot;
|
||||
lp1<(*fSecondary).size(); lp1++){
|
||||
G4cout << " : "
|
||||
<< std::setw(6)
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetPosition().x(),"Length")
|
||||
<< std::setw(6)
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetPosition().y(),"Length")
|
||||
<< std::setw(6)
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetPosition().z(),"Length")
|
||||
<< std::setw(6)
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(),"Energy")
|
||||
<< std::setw(10)
|
||||
for (size_t lp1 = (*fSecondary).size() - tN2ndariesTot; lp1 < (*fSecondary).size(); lp1++) {
|
||||
G4cout << " : " << std::setw(6)
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetPosition().x(), "Length") << std::setw(6)
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetPosition().y(), "Length") << std::setw(6)
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetPosition().z(), "Length") << std::setw(6)
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(), "Energy") << std::setw(10)
|
||||
<< (*fSecondary)[lp1]->GetDefinition()->GetParticleName();
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
|
||||
G4cout << " :-----------------------------"
|
||||
<< "----------------------------------"
|
||||
<< "-- EndOf2ndaries Info ---------------"
|
||||
<< G4endl;
|
||||
<< "-- EndOf2ndaries Info ---------------" << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
G4cout.precision(prec);
|
||||
}
|
||||
@@ -144,38 +127,35 @@ void ExP01SteppingVerbose::StepInfo()
|
||||
|
||||
void ExP01SteppingVerbose::TrackingStarted()
|
||||
{
|
||||
|
||||
CopyState();
|
||||
G4int prec = G4cout.precision(3);
|
||||
if( verboseLevel > 0 ){
|
||||
G4int prec = G4cout.precision(3);
|
||||
if (verboseLevel > 0) {
|
||||
G4cout << std::setw(5) << "Step#"
|
||||
<< " " << std::setw(6) << "X"
|
||||
<< " " << std::setw(6) << "Y"
|
||||
<< " " << std::setw(6) << "Z"
|
||||
<< " " << std::setw(9) << "KineE"
|
||||
<< " " << std::setw(9) << "dEStep"
|
||||
<< " " << std::setw(10) << "StepLeng" << std::setw(10) << "TrakLeng" << std::setw(10)
|
||||
<< "Volume"
|
||||
<< " " << std::setw(10) << "Process" << G4endl;
|
||||
|
||||
G4cout << std::setw( 5) << "Step#" << " "
|
||||
<< std::setw( 6) << "X" << " "
|
||||
<< std::setw( 6) << "Y" << " "
|
||||
<< std::setw( 6) << "Z" << " "
|
||||
<< std::setw( 9) << "KineE" << " "
|
||||
<< std::setw( 9) << "dEStep" << " "
|
||||
<< std::setw(10) << "StepLeng"
|
||||
<< std::setw(10) << "TrakLeng"
|
||||
<< std::setw(10) << "Volume" << " "
|
||||
<< std::setw(10) << "Process" << G4endl;
|
||||
G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " " << std::setw(6)
|
||||
<< G4BestUnit(fTrack->GetPosition().x(), "Length") << std::setw(6)
|
||||
<< G4BestUnit(fTrack->GetPosition().y(), "Length") << std::setw(6)
|
||||
<< G4BestUnit(fTrack->GetPosition().z(), "Length") << std::setw(6)
|
||||
<< G4BestUnit(fTrack->GetKineticEnergy(), "Energy") << std::setw(6)
|
||||
<< G4BestUnit(fStep->GetTotalEnergyDeposit(), "Energy") << std::setw(6)
|
||||
<< G4BestUnit(fStep->GetStepLength(), "Length") << std::setw(6)
|
||||
<< G4BestUnit(fTrack->GetTrackLength(), "Length") << " ";
|
||||
|
||||
G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
|
||||
<< " ";
|
||||
|
||||
if(fTrack->GetNextVolume()){
|
||||
if (fTrack->GetNextVolume()) {
|
||||
G4cout << std::setw(10) << fTrack->GetVolume()->GetName();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
G4cout << std::setw(10) << "OutOfWorld";
|
||||
}
|
||||
G4cout << " initStep" << G4endl;
|
||||
G4cout << " initStep" << G4endl;
|
||||
}
|
||||
G4cout.precision(prec);
|
||||
}
|
||||
|
||||
@@ -32,18 +32,19 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "ExP01TrackerHit.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
|
||||
#include "G4Circle.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
|
||||
G4ThreadLocal G4Allocator<ExP01TrackerHit>* ExP01TrackerHitAllocator = 0;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01TrackerHit::ExP01TrackerHit()
|
||||
: G4VHit(), fTrackID(0), fChamberNb(0), fEdep(0), fPos(0,0,0) {}
|
||||
ExP01TrackerHit::ExP01TrackerHit() : G4VHit(), fTrackID(0), fChamberNb(0), fEdep(0), fPos(0, 0, 0)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -51,23 +52,22 @@ ExP01TrackerHit::~ExP01TrackerHit() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01TrackerHit::ExP01TrackerHit(const ExP01TrackerHit& right)
|
||||
: G4VHit()
|
||||
ExP01TrackerHit::ExP01TrackerHit(const ExP01TrackerHit& right) : G4VHit()
|
||||
{
|
||||
fTrackID = right.fTrackID;
|
||||
fTrackID = right.fTrackID;
|
||||
fChamberNb = right.fChamberNb;
|
||||
fEdep = right.fEdep;
|
||||
fPos = right.fPos;
|
||||
fEdep = right.fEdep;
|
||||
fPos = right.fPos;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
const ExP01TrackerHit& ExP01TrackerHit::operator=(const ExP01TrackerHit& right)
|
||||
{
|
||||
fTrackID = right.fTrackID;
|
||||
fTrackID = right.fTrackID;
|
||||
fChamberNb = right.fChamberNb;
|
||||
fEdep = right.fEdep;
|
||||
fPos = right.fPos;
|
||||
fEdep = right.fEdep;
|
||||
fPos = right.fPos;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ const ExP01TrackerHit& ExP01TrackerHit::operator=(const ExP01TrackerHit& right)
|
||||
|
||||
G4bool ExP01TrackerHit::operator==(const ExP01TrackerHit& right) const
|
||||
{
|
||||
return (this==&right) ? true : false;
|
||||
return (this == &right) ? true : false;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -83,12 +83,11 @@ G4bool ExP01TrackerHit::operator==(const ExP01TrackerHit& right) const
|
||||
void ExP01TrackerHit::Draw()
|
||||
{
|
||||
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
|
||||
if(pVVisManager)
|
||||
{
|
||||
if (pVVisManager) {
|
||||
G4Circle circle(fPos);
|
||||
circle.SetScreenSize(2.);
|
||||
circle.SetFillStyle(G4Circle::filled);
|
||||
G4Colour colour(1.,0.,0.);
|
||||
G4Colour colour(1., 0., 0.);
|
||||
G4VisAttributes attribs(colour);
|
||||
circle.SetVisAttributes(attribs);
|
||||
pVVisManager->Draw(circle);
|
||||
@@ -100,9 +99,7 @@ void ExP01TrackerHit::Draw()
|
||||
void ExP01TrackerHit::Print()
|
||||
{
|
||||
G4cout << " trackID: " << fTrackID << " chamberNb: " << fChamberNb
|
||||
<< " energy deposit[MeV]: " << fEdep
|
||||
<< " position[mm]: " << fPos << G4endl;
|
||||
<< " energy deposit[MeV]: " << fEdep << " position[mm]: " << fPos << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
@@ -32,30 +32,31 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "ExP01TrackerSD.hh"
|
||||
#include "G4HCofThisEvent.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
#include "RootIO.hh"
|
||||
|
||||
#include "G4HCofThisEvent.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01TrackerSD::ExP01TrackerSD(G4String name)
|
||||
:G4VSensitiveDetector(name), fTrackerCollection(0), fHCID(0)
|
||||
: G4VSensitiveDetector(name), fTrackerCollection(0), fHCID(0)
|
||||
{
|
||||
G4String HCname = name + "_HC";
|
||||
collectionName.insert(HCname);
|
||||
G4cout << collectionName.size() << " CalorimeterSD name: " << name << " collection Name: "
|
||||
<< HCname << G4endl;
|
||||
G4cout << collectionName.size() << " CalorimeterSD name: " << name
|
||||
<< " collection Name: " << HCname << G4endl;
|
||||
fHCID = -1;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExP01TrackerSD::~ExP01TrackerSD()
|
||||
{
|
||||
{
|
||||
RootIO::GetInstance()->Close();
|
||||
}
|
||||
|
||||
@@ -63,35 +64,32 @@ ExP01TrackerSD::~ExP01TrackerSD()
|
||||
|
||||
void ExP01TrackerSD::Initialize(G4HCofThisEvent* HCE)
|
||||
{
|
||||
fTrackerCollection = new ExP01TrackerHitsCollection
|
||||
(SensitiveDetectorName,collectionName[0]);
|
||||
fTrackerCollection = new ExP01TrackerHitsCollection(SensitiveDetectorName, collectionName[0]);
|
||||
if (fHCID < 0) {
|
||||
G4cout << "CalorimeterSD::Initialize: " << SensitiveDetectorName << " "
|
||||
<< collectionName[0] << G4endl;
|
||||
G4cout << "CalorimeterSD::Initialize: " << SensitiveDetectorName << " " << collectionName[0]
|
||||
<< G4endl;
|
||||
fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
|
||||
|
||||
}
|
||||
HCE->AddHitsCollection(fHCID, fTrackerCollection);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4bool ExP01TrackerSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
|
||||
G4bool ExP01TrackerSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
|
||||
{
|
||||
G4double edep = aStep->GetTotalEnergyDeposit();
|
||||
|
||||
if(edep==0.) return false;
|
||||
if (edep == 0.) return false;
|
||||
|
||||
ExP01TrackerHit* newHit = new ExP01TrackerHit();
|
||||
newHit->SetTrackID (aStep->GetTrack()->GetTrackID());
|
||||
newHit->SetChamberNb(aStep->GetPreStepPoint()->GetTouchable()
|
||||
->GetReplicaNumber());
|
||||
newHit->SetEdep (edep);
|
||||
newHit->SetPos (aStep->GetPostStepPoint()->GetPosition());
|
||||
fTrackerCollection->insert( newHit );
|
||||
|
||||
//newHit->Print();
|
||||
//newHit->Draw();
|
||||
newHit->SetTrackID(aStep->GetTrack()->GetTrackID());
|
||||
newHit->SetChamberNb(aStep->GetPreStepPoint()->GetTouchable()->GetReplicaNumber());
|
||||
newHit->SetEdep(edep);
|
||||
newHit->SetPos(aStep->GetPostStepPoint()->GetPosition());
|
||||
fTrackerCollection->insert(newHit);
|
||||
|
||||
// newHit->Print();
|
||||
// newHit->Draw();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -104,20 +102,19 @@ void ExP01TrackerSD::EndOfEvent(G4HCofThisEvent*)
|
||||
G4int NbHits = fTrackerCollection->entries();
|
||||
std::vector<ExP01TrackerHit*> hitsVector;
|
||||
|
||||
{
|
||||
G4cout << "\n-------->Storing hits in the ROOT file: in this event there are " << NbHits
|
||||
{
|
||||
G4cout << "\n-------->Storing hits in the ROOT file: in this event there are " << NbHits
|
||||
<< " hits in the tracker chambers: " << G4endl;
|
||||
for (G4int i=0;i<NbHits;i++) (*fTrackerCollection)[i]->Print();
|
||||
}
|
||||
for (G4int i = 0; i < NbHits; i++)
|
||||
(*fTrackerCollection)[i]->Print();
|
||||
}
|
||||
|
||||
|
||||
for (G4int i=0;i<NbHits;i++)
|
||||
for (G4int i = 0; i < NbHits; i++)
|
||||
hitsVector.push_back((*fTrackerCollection)[i]);
|
||||
|
||||
|
||||
RootIO::GetInstance()->Write(&hitsVector);
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
@@ -30,14 +30,14 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "RootIO.hh"
|
||||
|
||||
#include <sstream>
|
||||
//
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4HCofThisEvent.hh"
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4HCofThisEvent.hh"
|
||||
#include "G4SDManager.hh"
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -46,28 +46,26 @@ static RootIO* instance = 0;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RootIO::RootIO():fNevents(0)
|
||||
RootIO::RootIO() : fNevents(0)
|
||||
{
|
||||
// initialize ROOT
|
||||
TSystem ts;
|
||||
gSystem->Load("libExP01ClassesDict");
|
||||
|
||||
//gDebug = 1;
|
||||
// gDebug = 1;
|
||||
|
||||
fFile = new TFile("hits.root","RECREATE");
|
||||
fFile = new TFile("hits.root", "RECREATE");
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RootIO::~RootIO()
|
||||
{}
|
||||
RootIO::~RootIO() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RootIO* RootIO::GetInstance()
|
||||
{
|
||||
if (instance == 0 )
|
||||
{
|
||||
if (instance == 0) {
|
||||
instance = new RootIO();
|
||||
}
|
||||
return instance;
|
||||
@@ -81,13 +79,12 @@ void RootIO::Write(std::vector<ExP01TrackerHit*>* hcont)
|
||||
|
||||
std::ostringstream os;
|
||||
os << fNevents;
|
||||
std::string stevt = "Event_" + os.str();
|
||||
std::string stevt = "Event_" + os.str();
|
||||
const char* chevt = stevt.c_str();
|
||||
|
||||
G4cout << "writing " << stevt << G4endl;
|
||||
|
||||
fFile->WriteObject(hcont, chevt);
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Reference in New Issue
Block a user