Import Geant4 10.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-12-09 12:35:28 +01:00
parent 4ec577e5c4
commit a3452e42ac
3514 changed files with 210500 additions and 89628 deletions
@@ -48,7 +48,7 @@ B5ActionInitialization::~B5ActionInitialization()
void B5ActionInitialization::BuildForMaster() const
{
B5EventAction* eventAction = 0;
B5EventAction* eventAction = new B5EventAction;
SetUserAction(new B5RunAction(eventAction));
}
@@ -58,7 +58,7 @@ void B5ActionInitialization::Build() const
{
SetUserAction(new B5PrimaryGeneratorAction);
B5EventAction* eventAction = new B5EventAction;
auto eventAction = new B5EventAction;
SetUserAction(eventAction);
SetUserAction(new B5RunAction(eventAction));
+11 -11
View File
@@ -23,12 +23,13 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B5CellParameterisation.cc 76474 2013-11-11 10:36:34Z gcosmo $
// $Id: B5CellParameterisation.cc 101036 2016-11-04 09:00:23Z gcosmo $
//
/// \file B5CellParameterisation.cc
/// \brief Implementation of the B5CellParameterisation class
#include "B5CellParameterisation.hh"
#include "B5Constants.hh"
#include "G4VPhysicalVolume.hh"
#include "G4ThreeVector.hh"
@@ -39,13 +40,12 @@
B5CellParameterisation::B5CellParameterisation()
: G4VPVParameterisation()
{
for (G4int copyNo=0;copyNo<80;copyNo++)
{
G4int column = copyNo / 4;
G4int row = copyNo % 4;
fXCell[copyNo] = (column-9)*15.*cm - 7.5*cm;
fYCell[copyNo] = (row-1)*15*cm - 7.5*cm;
}
for (auto copyNo=0; copyNo<kNofEmCells; copyNo++) {
auto column = copyNo / kNofEmRows ;
auto row = copyNo % kNofEmRows;
fXCell[copyNo] = (column-9)*15.*cm - 7.5*cm;
fYCell[copyNo] = (row-1)*15*cm - 7.5*cm;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -55,10 +55,10 @@ B5CellParameterisation::~B5CellParameterisation()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5CellParameterisation::ComputeTransformation
(const G4int copyNo,G4VPhysicalVolume *physVol) const
void B5CellParameterisation::ComputeTransformation(
const G4int copyNo,G4VPhysicalVolume *physVol) const
{
physVol->SetTranslation(G4ThreeVector(fXCell[copyNo],fYCell[copyNo],0.));
physVol->SetTranslation(G4ThreeVector(fXCell[copyNo],fYCell[copyNo],0.));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+356 -365
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B5DetectorConstruction.cc 77656 2013-11-27 08:52:57Z gcosmo $
// $Id: B5DetectorConstruction.cc 101036 2016-11-04 09:00:23Z gcosmo $
//
/// \file B5DetectorConstruction.cc
/// \brief Implementation of the B5DetectorConstruction class
@@ -76,422 +76,413 @@ G4ThreadLocal G4FieldManager* B5DetectorConstruction::fFieldMgr = 0;
B5DetectorConstruction::B5DetectorConstruction()
: G4VUserDetectorConstruction(),
fMessenger(0),
fHodoscope1Logical(0), fHodoscope2Logical(0),
fWirePlane1Logical(0), fWirePlane2Logical(0),
fCellLogical(0), fHadCalScintiLogical(0),
fMagneticLogical(0),
fMessenger(nullptr),
fHodoscope1Logical(nullptr), fHodoscope2Logical(nullptr),
fWirePlane1Logical(nullptr), fWirePlane2Logical(nullptr),
fCellLogical(nullptr), fHadCalScintiLogical(nullptr),
fMagneticLogical(nullptr),
fVisAttributes(),
fArmAngle(30.*deg), fArmRotation(0), fSecondArmPhys(0)
fArmAngle(30.*deg), fArmRotation(nullptr), fSecondArmPhys(nullptr)
{
fArmRotation = new G4RotationMatrix();
fArmRotation->rotateY(fArmAngle);
// define commands for this class
DefineCommands();
fArmRotation = new G4RotationMatrix();
fArmRotation->rotateY(fArmAngle);
// define commands for this class
DefineCommands();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5DetectorConstruction::~B5DetectorConstruction()
{
delete fArmRotation;
delete fMessenger;
for (G4int i=0; i<G4int(fVisAttributes.size()); ++i)
{
delete fVisAttributes[i];
}
delete fArmRotation;
delete fMessenger;
for (auto visAttributes: fVisAttributes) {
delete visAttributes;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* B5DetectorConstruction::Construct()
{
// Construct materials
ConstructMaterials();
G4Material* air = G4Material::GetMaterial("G4_AIR");
//G4Material* argonGas = G4Material::GetMaterial("B5_Ar");
G4Material* argonGas = G4Material::GetMaterial("G4_Ar");
G4Material* scintillator
= G4Material::GetMaterial("G4_PLASTIC_SC_VINYLTOLUENE");
G4Material* csI = G4Material::GetMaterial("G4_CESIUM_IODIDE");
G4Material* lead = G4Material::GetMaterial("G4_Pb");
// Option to switch on/off checking of volumes overlaps
//
G4bool checkOverlaps = true;
// Construct materials
ConstructMaterials();
auto air = G4Material::GetMaterial("G4_AIR");
//auto argonGas = G4Material::GetMaterial("B5_Ar");
auto argonGas = G4Material::GetMaterial("G4_Ar");
auto scintillator = G4Material::GetMaterial("G4_PLASTIC_SC_VINYLTOLUENE");
auto csI = G4Material::GetMaterial("G4_CESIUM_IODIDE");
auto lead = G4Material::GetMaterial("G4_Pb");
// Option to switch on/off checking of volumes overlaps
//
G4bool checkOverlaps = true;
// geometries --------------------------------------------------------------
// experimental hall (world volume)
G4VSolid* worldSolid
= new G4Box("worldBox",10.*m,3.*m,10.*m);
G4LogicalVolume* worldLogical
= new G4LogicalVolume(worldSolid,air,"worldLogical");
G4VPhysicalVolume* worldPhysical
= new G4PVPlacement(0,G4ThreeVector(),worldLogical,"worldPhysical",0,
false,0,checkOverlaps);
// Tube with Local Magnetic field
G4VSolid* magneticSolid
= new G4Tubs("magneticTubs",0.,1.*m,1.*m,0.,360.*deg);
// geometries --------------------------------------------------------------
// experimental hall (world volume)
auto worldSolid
= new G4Box("worldBox",10.*m,3.*m,10.*m);
auto worldLogical
= new G4LogicalVolume(worldSolid,air,"worldLogical");
auto worldPhysical
= new G4PVPlacement(0,G4ThreeVector(),worldLogical,"worldPhysical",0,
false,0,checkOverlaps);
// Tube with Local Magnetic field
auto magneticSolid
= new G4Tubs("magneticTubs",0.,1.*m,1.*m,0.,360.*deg);
fMagneticLogical
= new G4LogicalVolume(magneticSolid, air, "magneticLogical");
fMagneticLogical
= new G4LogicalVolume(magneticSolid, air, "magneticLogical");
// placement of Tube
G4RotationMatrix* fieldRot = new G4RotationMatrix();
fieldRot->rotateX(90.*deg);
new G4PVPlacement(fieldRot,G4ThreeVector(),fMagneticLogical,
"magneticPhysical",worldLogical,
false,0,checkOverlaps);
// set step limit in tube with magnetic field
G4UserLimits* userLimits = new G4UserLimits(1*m);
fMagneticLogical->SetUserLimits(userLimits);
// first arm
G4VSolid* firstArmSolid
= new G4Box("firstArmBox",1.5*m,1.*m,3.*m);
G4LogicalVolume* firstArmLogical
= new G4LogicalVolume(firstArmSolid,air,"firstArmLogical");
new G4PVPlacement(0,G4ThreeVector(0.,0.,-5.*m),firstArmLogical,
"firstArmPhysical",worldLogical,
false,0,checkOverlaps);
// second arm
G4VSolid* secondArmSolid
= new G4Box("secondArmBox",2.*m,2.*m,3.5*m);
G4LogicalVolume* secondArmLogical
= new G4LogicalVolume(secondArmSolid,air,"secondArmLogical");
G4double x = -5.*m * std::sin(fArmAngle);
G4double z = 5.*m * std::cos(fArmAngle);
fSecondArmPhys
= new G4PVPlacement(fArmRotation,G4ThreeVector(x,0.,z),secondArmLogical,
"fSecondArmPhys",worldLogical,
false,0,checkOverlaps);
// hodoscopes in first arm
G4VSolid* hodoscope1Solid
= new G4Box("hodoscope1Box",5.*cm,20.*cm,0.5*cm);
fHodoscope1Logical
= new G4LogicalVolume(hodoscope1Solid,scintillator,"hodoscope1Logical");
for (G4int i=0;i<15;i++)
{
G4double x1 = (i-7)*10.*cm;
new G4PVPlacement(0,G4ThreeVector(x1,0.,-1.5*m),fHodoscope1Logical,
"hodoscope1Physical",firstArmLogical,
false,i,checkOverlaps);
}
// drift chambers in first arm
G4VSolid* chamber1Solid
= new G4Box("chamber1Box",1.*m,30.*cm,1.*cm);
G4LogicalVolume* chamber1Logical
= new G4LogicalVolume(chamber1Solid,argonGas,"chamber1Logical");
for (G4int i=0;i<5;i++)
{
G4double z1 = (i-2)*0.5*m;
new G4PVPlacement(0,G4ThreeVector(0.,0.,z1),chamber1Logical,
"chamber1Physical",firstArmLogical,
false,i,checkOverlaps);
}
// "virtual" wire plane
G4VSolid* wirePlane1Solid
= new G4Box("wirePlane1Box",1.*m,30.*cm,0.1*mm);
fWirePlane1Logical
= new G4LogicalVolume(wirePlane1Solid,argonGas,"wirePlane1Logical");
new G4PVPlacement(0,G4ThreeVector(0.,0.,0.),fWirePlane1Logical,
"wirePlane1Physical",chamber1Logical,
false,0,checkOverlaps);
// hodoscopes in second arm
G4VSolid* hodoscope2Solid
= new G4Box("hodoscope2Box",5.*cm,20.*cm,0.5*cm);
fHodoscope2Logical
= new G4LogicalVolume(hodoscope2Solid,scintillator,"hodoscope2Logical");
for (G4int i=0;i<25;i++)
{
G4double x2 = (i-12)*10.*cm;
new G4PVPlacement(0,G4ThreeVector(x2,0.,0.),fHodoscope2Logical,
"hodoscope2Physical",secondArmLogical,
false,i,checkOverlaps);
}
// drift chambers in second arm
G4VSolid* chamber2Solid
= new G4Box("chamber2Box",1.5*m,30.*cm,1.*cm);
G4LogicalVolume* chamber2Logical
= new G4LogicalVolume(chamber2Solid,argonGas,"chamber2Logical");
for (G4int i=0;i<5;i++)
{
G4double z2 = (i-2)*0.5*m - 1.5*m;
new G4PVPlacement(0,G4ThreeVector(0.,0.,z2),chamber2Logical,
"chamber2Physical",secondArmLogical,
false,i,checkOverlaps);
}
// "virtual" wire plane
G4VSolid* wirePlane2Solid
= new G4Box("wirePlane2Box",1.5*m,30.*cm,0.1*mm);
fWirePlane2Logical
= new G4LogicalVolume(wirePlane2Solid,argonGas,"wirePlane2Logical");
new G4PVPlacement(0,G4ThreeVector(0.,0.,0.),fWirePlane2Logical,
"wirePlane2Physical",chamber2Logical,
false,0,checkOverlaps);
// CsI calorimeter
G4VSolid* emCalorimeterSolid
= new G4Box("EMcalorimeterBox",1.5*m,30.*cm,15.*cm);
G4LogicalVolume* emCalorimeterLogical
= new G4LogicalVolume(emCalorimeterSolid,csI,"EMcalorimeterLogical");
new G4PVPlacement(0,G4ThreeVector(0.,0.,2.*m),emCalorimeterLogical,
"EMcalorimeterPhysical",secondArmLogical,
false,0,checkOverlaps);
// EMcalorimeter cells
G4VSolid* cellSolid
= new G4Box("cellBox",7.5*cm,7.5*cm,15.*cm);
fCellLogical
= new G4LogicalVolume(cellSolid,csI,"cellLogical");
G4VPVParameterisation* cellParam = new B5CellParameterisation();
new G4PVParameterised("cellPhysical",fCellLogical,emCalorimeterLogical,
kXAxis,80,cellParam);
// hadron calorimeter
G4VSolid* hadCalorimeterSolid
= new G4Box("HadCalorimeterBox",1.5*m,30.*cm,50.*cm);
G4LogicalVolume* hadCalorimeterLogical
= new G4LogicalVolume(hadCalorimeterSolid,lead,"HadCalorimeterLogical");
new G4PVPlacement(0,G4ThreeVector(0.,0.,3.*m),hadCalorimeterLogical,
"HadCalorimeterPhysical",secondArmLogical,
false,0,checkOverlaps);
// hadron calorimeter column
G4VSolid* HadCalColumnSolid
= new G4Box("HadCalColumnBox",15.*cm,30.*cm,50.*cm);
G4LogicalVolume* HadCalColumnLogical
= new G4LogicalVolume(HadCalColumnSolid,lead,"HadCalColumnLogical");
new G4PVReplica("HadCalColumnPhysical",HadCalColumnLogical,
hadCalorimeterLogical,kXAxis,10,30.*cm);
// hadron calorimeter cell
G4VSolid* HadCalCellSolid
= new G4Box("HadCalCellBox",15.*cm,15.*cm,50.*cm);
G4LogicalVolume* HadCalCellLogical
= new G4LogicalVolume(HadCalCellSolid,lead,"HadCalCellLogical");
new G4PVReplica("HadCalCellPhysical",HadCalCellLogical,
HadCalColumnLogical,kYAxis,2,30.*cm);
// hadron calorimeter layers
G4VSolid* HadCalLayerSolid
= new G4Box("HadCalLayerBox",15.*cm,15.*cm,2.5*cm);
G4LogicalVolume* HadCalLayerLogical
= new G4LogicalVolume(HadCalLayerSolid,lead,"HadCalLayerLogical");
new G4PVReplica("HadCalLayerPhysical",HadCalLayerLogical,
HadCalCellLogical,kZAxis,20,5.*cm);
// scintillator plates
G4VSolid* HadCalScintiSolid
= new G4Box("HadCalScintiBox",15.*cm,15.*cm,0.5*cm);
fHadCalScintiLogical
= new G4LogicalVolume(HadCalScintiSolid,scintillator,
"HadCalScintiLogical");
new G4PVPlacement(0,G4ThreeVector(0.,0.,2.*cm),fHadCalScintiLogical,
"HadCalScintiPhysical",HadCalLayerLogical,
false,0,checkOverlaps);
// visualization attributes ------------------------------------------------
G4VisAttributes* visAttributes = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
visAttributes->SetVisibility(false);
worldLogical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(0.9,0.9,0.9)); // LightGray
fMagneticLogical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
visAttributes->SetVisibility(false);
firstArmLogical->SetVisAttributes(visAttributes);
secondArmLogical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(0.8888,0.0,0.0));
fHodoscope1Logical->SetVisAttributes(visAttributes);
fHodoscope2Logical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(0.0,1.0,0.0));
chamber1Logical->SetVisAttributes(visAttributes);
chamber2Logical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(0.0,0.8888,0.0));
visAttributes->SetVisibility(false);
fWirePlane1Logical->SetVisAttributes(visAttributes);
fWirePlane2Logical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(0.8888,0.8888,0.0));
visAttributes->SetVisibility(false);
emCalorimeterLogical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(0.9,0.9,0.0));
fCellLogical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9));
hadCalorimeterLogical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9));
visAttributes->SetVisibility(false);
HadCalColumnLogical->SetVisAttributes(visAttributes);
HadCalCellLogical->SetVisAttributes(visAttributes);
HadCalLayerLogical->SetVisAttributes(visAttributes);
fHadCalScintiLogical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
// return the world physical volume ----------------------------------------
return worldPhysical;
// placement of Tube
G4RotationMatrix* fieldRot = new G4RotationMatrix();
fieldRot->rotateX(90.*deg);
new G4PVPlacement(fieldRot,G4ThreeVector(),fMagneticLogical,
"magneticPhysical",worldLogical,
false,0,checkOverlaps);
// set step limit in tube with magnetic field
G4UserLimits* userLimits = new G4UserLimits(1*m);
fMagneticLogical->SetUserLimits(userLimits);
// first arm
auto firstArmSolid
= new G4Box("firstArmBox",1.5*m,1.*m,3.*m);
auto firstArmLogical
= new G4LogicalVolume(firstArmSolid,air,"firstArmLogical");
new G4PVPlacement(0,G4ThreeVector(0.,0.,-5.*m),firstArmLogical,
"firstArmPhysical",worldLogical,
false,0,checkOverlaps);
// second arm
auto secondArmSolid
= new G4Box("secondArmBox",2.*m,2.*m,3.5*m);
auto secondArmLogical
= new G4LogicalVolume(secondArmSolid,air,"secondArmLogical");
auto x = -5.*m * std::sin(fArmAngle);
auto z = 5.*m * std::cos(fArmAngle);
fSecondArmPhys
= new G4PVPlacement(fArmRotation,G4ThreeVector(x,0.,z),secondArmLogical,
"fSecondArmPhys",worldLogical,
false,0,checkOverlaps);
// hodoscopes in first arm
auto hodoscope1Solid
= new G4Box("hodoscope1Box",5.*cm,20.*cm,0.5*cm);
fHodoscope1Logical
= new G4LogicalVolume(hodoscope1Solid,scintillator,"hodoscope1Logical");
for (auto i=0;i<kNofHodoscopes1;i++) {
G4double x1 = (i-kNofHodoscopes1/2)*10.*cm;
new G4PVPlacement(0,G4ThreeVector(x1,0.,-1.5*m),fHodoscope1Logical,
"hodoscope1Physical",firstArmLogical,
false,i,checkOverlaps);
}
// drift chambers in first arm
auto chamber1Solid
= new G4Box("chamber1Box",1.*m,30.*cm,1.*cm);
auto chamber1Logical
= new G4LogicalVolume(chamber1Solid,argonGas,"chamber1Logical");
for (auto i=0;i<kNofChambers;i++) {
G4double z1 = (i-kNofChambers/2)*0.5*m;
new G4PVPlacement(0,G4ThreeVector(0.,0.,z1),chamber1Logical,
"chamber1Physical",firstArmLogical,
false,i,checkOverlaps);
}
// "virtual" wire plane
auto wirePlane1Solid
= new G4Box("wirePlane1Box",1.*m,30.*cm,0.1*mm);
fWirePlane1Logical
= new G4LogicalVolume(wirePlane1Solid,argonGas,"wirePlane1Logical");
new G4PVPlacement(0,G4ThreeVector(0.,0.,0.),fWirePlane1Logical,
"wirePlane1Physical",chamber1Logical,
false,0,checkOverlaps);
// hodoscopes in second arm
auto hodoscope2Solid
= new G4Box("hodoscope2Box",5.*cm,20.*cm,0.5*cm);
fHodoscope2Logical
= new G4LogicalVolume(hodoscope2Solid,scintillator,"hodoscope2Logical");
for (auto i=0;i<kNofHodoscopes2;i++) {
G4double x2 = (i-kNofHodoscopes2/2)*10.*cm;
new G4PVPlacement(0,G4ThreeVector(x2,0.,0.),fHodoscope2Logical,
"hodoscope2Physical",secondArmLogical,
false,i,checkOverlaps);
}
// drift chambers in second arm
auto chamber2Solid
= new G4Box("chamber2Box",1.5*m,30.*cm,1.*cm);
auto chamber2Logical
= new G4LogicalVolume(chamber2Solid,argonGas,"chamber2Logical");
for (auto i=0;i<kNofChambers;i++) {
G4double z2 = (i-kNofChambers/2)*0.5*m - 1.5*m;
new G4PVPlacement(0,G4ThreeVector(0.,0.,z2),chamber2Logical,
"chamber2Physical",secondArmLogical,
false,i,checkOverlaps);
}
// "virtual" wire plane
auto wirePlane2Solid
= new G4Box("wirePlane2Box",1.5*m,30.*cm,0.1*mm);
fWirePlane2Logical
= new G4LogicalVolume(wirePlane2Solid,argonGas,"wirePlane2Logical");
new G4PVPlacement(0,G4ThreeVector(0.,0.,0.),fWirePlane2Logical,
"wirePlane2Physical",chamber2Logical,
false,0,checkOverlaps);
// CsI calorimeter
auto emCalorimeterSolid
= new G4Box("EMcalorimeterBox",1.5*m,30.*cm,15.*cm);
auto emCalorimeterLogical
= new G4LogicalVolume(emCalorimeterSolid,csI,"EMcalorimeterLogical");
new G4PVPlacement(0,G4ThreeVector(0.,0.,2.*m),emCalorimeterLogical,
"EMcalorimeterPhysical",secondArmLogical,
false,0,checkOverlaps);
// EMcalorimeter cells
auto cellSolid
= new G4Box("cellBox",7.5*cm,7.5*cm,15.*cm);
fCellLogical
= new G4LogicalVolume(cellSolid,csI,"cellLogical");
G4VPVParameterisation* cellParam = new B5CellParameterisation();
new G4PVParameterised("cellPhysical",fCellLogical,emCalorimeterLogical,
kXAxis,kNofEmCells,cellParam);
// hadron calorimeter
auto hadCalorimeterSolid
= new G4Box("HadCalorimeterBox",1.5*m,30.*cm,50.*cm);
auto hadCalorimeterLogical
= new G4LogicalVolume(hadCalorimeterSolid,lead,"HadCalorimeterLogical");
new G4PVPlacement(0,G4ThreeVector(0.,0.,3.*m),hadCalorimeterLogical,
"HadCalorimeterPhysical",secondArmLogical,
false,0,checkOverlaps);
// hadron calorimeter column
auto HadCalColumnSolid
= new G4Box("HadCalColumnBox",15.*cm,30.*cm,50.*cm);
auto HadCalColumnLogical
= new G4LogicalVolume(HadCalColumnSolid,lead,"HadCalColumnLogical");
new G4PVReplica("HadCalColumnPhysical",HadCalColumnLogical,
hadCalorimeterLogical,kXAxis,kNofHadColumns,30.*cm);
// hadron calorimeter cell
auto HadCalCellSolid
= new G4Box("HadCalCellBox",15.*cm,15.*cm,50.*cm);
auto HadCalCellLogical
= new G4LogicalVolume(HadCalCellSolid,lead,"HadCalCellLogical");
new G4PVReplica("HadCalCellPhysical",HadCalCellLogical,
HadCalColumnLogical,kYAxis,kNofHadRows,30.*cm);
// hadron calorimeter layers
auto HadCalLayerSolid
= new G4Box("HadCalLayerBox",15.*cm,15.*cm,2.5*cm);
auto HadCalLayerLogical
= new G4LogicalVolume(HadCalLayerSolid,lead,"HadCalLayerLogical");
new G4PVReplica("HadCalLayerPhysical",HadCalLayerLogical,
HadCalCellLogical,kZAxis,kNofHadCells,5.*cm);
// scintillator plates
auto HadCalScintiSolid
= new G4Box("HadCalScintiBox",15.*cm,15.*cm,0.5*cm);
fHadCalScintiLogical
= new G4LogicalVolume(HadCalScintiSolid,scintillator,
"HadCalScintiLogical");
new G4PVPlacement(0,G4ThreeVector(0.,0.,2.*cm),fHadCalScintiLogical,
"HadCalScintiPhysical",HadCalLayerLogical,
false,0,checkOverlaps);
// visualization attributes ------------------------------------------------
auto visAttributes = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
visAttributes->SetVisibility(false);
worldLogical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(0.9,0.9,0.9)); // LightGray
fMagneticLogical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
visAttributes->SetVisibility(false);
firstArmLogical->SetVisAttributes(visAttributes);
secondArmLogical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(0.8888,0.0,0.0));
fHodoscope1Logical->SetVisAttributes(visAttributes);
fHodoscope2Logical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(0.0,1.0,0.0));
chamber1Logical->SetVisAttributes(visAttributes);
chamber2Logical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(0.0,0.8888,0.0));
visAttributes->SetVisibility(false);
fWirePlane1Logical->SetVisAttributes(visAttributes);
fWirePlane2Logical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(0.8888,0.8888,0.0));
visAttributes->SetVisibility(false);
emCalorimeterLogical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(0.9,0.9,0.0));
fCellLogical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9));
hadCalorimeterLogical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
visAttributes = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9));
visAttributes->SetVisibility(false);
HadCalColumnLogical->SetVisAttributes(visAttributes);
HadCalCellLogical->SetVisAttributes(visAttributes);
HadCalLayerLogical->SetVisAttributes(visAttributes);
fHadCalScintiLogical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
// return the world physical volume ----------------------------------------
return worldPhysical;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5DetectorConstruction::ConstructSDandField()
{
// sensitive detectors -----------------------------------------------------
G4SDManager* SDman = G4SDManager::GetSDMpointer();
G4String SDname;
G4VSensitiveDetector* hodoscope1
= new B5HodoscopeSD(SDname="/hodoscope1");
SDman->AddNewDetector(hodoscope1);
fHodoscope1Logical->SetSensitiveDetector(hodoscope1);
// sensitive detectors -----------------------------------------------------
auto sdManager = G4SDManager::GetSDMpointer();
G4String SDname;
auto hodoscope1 = new B5HodoscopeSD(SDname="/hodoscope1");
sdManager->AddNewDetector(hodoscope1);
fHodoscope1Logical->SetSensitiveDetector(hodoscope1);
G4VSensitiveDetector* hodoscope2
= new B5HodoscopeSD(SDname="/hodoscope2");
SDman->AddNewDetector(hodoscope2);
fHodoscope2Logical->SetSensitiveDetector(hodoscope2);
G4VSensitiveDetector* chamber1
= new B5DriftChamberSD(SDname="/chamber1");
SDman->AddNewDetector(chamber1);
fWirePlane1Logical->SetSensitiveDetector(chamber1);
auto hodoscope2 = new B5HodoscopeSD(SDname="/hodoscope2");
sdManager->AddNewDetector(hodoscope2);
fHodoscope2Logical->SetSensitiveDetector(hodoscope2);
auto chamber1 = new B5DriftChamberSD(SDname="/chamber1");
sdManager->AddNewDetector(chamber1);
fWirePlane1Logical->SetSensitiveDetector(chamber1);
G4VSensitiveDetector* chamber2
= new B5DriftChamberSD(SDname="/chamber2");
SDman->AddNewDetector(chamber2);
fWirePlane2Logical->SetSensitiveDetector(chamber2);
G4VSensitiveDetector* emCalorimeter
= new B5EmCalorimeterSD(SDname="/EMcalorimeter");
SDman->AddNewDetector(emCalorimeter);
fCellLogical->SetSensitiveDetector(emCalorimeter);
G4VSensitiveDetector* hadCalorimeter
= new B5HadCalorimeterSD(SDname="/HadCalorimeter");
SDman->AddNewDetector(hadCalorimeter);
fHadCalScintiLogical->SetSensitiveDetector(hadCalorimeter);
auto chamber2 = new B5DriftChamberSD(SDname="/chamber2");
sdManager->AddNewDetector(chamber2);
fWirePlane2Logical->SetSensitiveDetector(chamber2);
auto emCalorimeter = new B5EmCalorimeterSD(SDname="/EMcalorimeter");
sdManager->AddNewDetector(emCalorimeter);
fCellLogical->SetSensitiveDetector(emCalorimeter);
auto hadCalorimeter = new B5HadCalorimeterSD(SDname="/HadCalorimeter");
sdManager->AddNewDetector(hadCalorimeter);
fHadCalScintiLogical->SetSensitiveDetector(hadCalorimeter);
// magnetic field ----------------------------------------------------------
fMagneticField = new B5MagneticField();
fFieldMgr = new G4FieldManager();
fFieldMgr->SetDetectorField(fMagneticField);
fFieldMgr->CreateChordFinder(fMagneticField);
G4bool forceToAllDaughters = true;
fMagneticLogical->SetFieldManager(fFieldMgr, forceToAllDaughters);
// magnetic field ----------------------------------------------------------
fMagneticField = new B5MagneticField();
fFieldMgr = new G4FieldManager();
fFieldMgr->SetDetectorField(fMagneticField);
fFieldMgr->CreateChordFinder(fMagneticField);
G4bool forceToAllDaughters = true;
fMagneticLogical->SetFieldManager(fFieldMgr, forceToAllDaughters);
// Register the field and its manager for deleting
G4AutoDelete::Register(fMagneticField);
G4AutoDelete::Register(fFieldMgr);
// Register the field and its manager for deleting
G4AutoDelete::Register(fMagneticField);
G4AutoDelete::Register(fFieldMgr);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5DetectorConstruction::ConstructMaterials()
{
G4NistManager* nistManager = G4NistManager::Instance();
auto nistManager = G4NistManager::Instance();
// Air
nistManager->FindOrBuildMaterial("G4_AIR");
// Air
nistManager->FindOrBuildMaterial("G4_AIR");
// Argon gas
nistManager->FindOrBuildMaterial("G4_Ar");
// With a density different from the one defined in NIST
// G4double density = 1.782e-03*g/cm3;
// nistManager->BuildMaterialWithNewDensity("B5_Ar","G4_Ar",density);
// !! cases segmentation fault
// Argon gas
nistManager->FindOrBuildMaterial("G4_Ar");
// With a density different from the one defined in NIST
// G4double density = 1.782e-03*g/cm3;
// nistManager->BuildMaterialWithNewDensity("B5_Ar","G4_Ar",density);
// !! cases segmentation fault
// Scintillator
// (PolyVinylToluene, C_9H_10)
nistManager->FindOrBuildMaterial("G4_PLASTIC_SC_VINYLTOLUENE");
// CsI
nistManager->FindOrBuildMaterial("G4_CESIUM_IODIDE");
// Lead
nistManager->FindOrBuildMaterial("G4_Pb");
// Vacuum "Galactic"
// nistManager->FindOrBuildMaterial("G4_Galactic");
// Scintillator
// (PolyVinylToluene, C_9H_10)
nistManager->FindOrBuildMaterial("G4_PLASTIC_SC_VINYLTOLUENE");
// CsI
nistManager->FindOrBuildMaterial("G4_CESIUM_IODIDE");
// Lead
nistManager->FindOrBuildMaterial("G4_Pb");
// Vacuum "Galactic"
// nistManager->FindOrBuildMaterial("G4_Galactic");
// Vacuum "Air with low density"
// G4Material* air = G4Material::GetMaterial("G4_AIR");
// G4double density = 1.0e-5*air->GetDensity();
// nistManager
// ->BuildMaterialWithNewDensity("Air_lowDensity", "G4_AIR", density);
// Vacuum "Air with low density"
// auto air = G4Material::GetMaterial("G4_AIR");
// G4double density = 1.0e-5*air->GetDensity();
// nistManager
// ->BuildMaterialWithNewDensity("Air_lowDensity", "G4_AIR", density);
G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5DetectorConstruction::SetArmAngle(G4double val)
{
if (!fSecondArmPhys)
{
G4cerr << "Detector has not yet been constructed." << G4endl;
return;
}
fArmAngle = val;
*fArmRotation = G4RotationMatrix(); // make it unit vector
fArmRotation->rotateY(fArmAngle);
G4double x = -5.*m * std::sin(fArmAngle);
G4double z = 5.*m * std::cos(fArmAngle);
fSecondArmPhys->SetTranslation(G4ThreeVector(x,0.,z));
// tell G4RunManager that we change the geometry
G4RunManager::GetRunManager()->GeometryHasBeenModified();
if (!fSecondArmPhys) {
G4cerr << "Detector has not yet been constructed." << G4endl;
return;
}
fArmAngle = val;
*fArmRotation = G4RotationMatrix(); // make it unit vector
fArmRotation->rotateY(fArmAngle);
auto x = -5.*m * std::sin(fArmAngle);
auto z = 5.*m * std::cos(fArmAngle);
fSecondArmPhys->SetTranslation(G4ThreeVector(x,0.,z));
// tell G4RunManager that we change the geometry
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5DetectorConstruction::DefineCommands()
{
// Define /B5/detector command directory using generic messenger class
fMessenger = new G4GenericMessenger(this,
"/B5/detector/",
"Detector control");
// Define /B5/detector command directory using generic messenger class
fMessenger = new G4GenericMessenger(this,
"/B5/detector/",
"Detector control");
// armAngle command
G4GenericMessenger::Command& armAngleCmd
= fMessenger->DeclareMethodWithUnit("armAngle","deg",
&B5DetectorConstruction::SetArmAngle,
"Set rotation angle of the second arm.");
armAngleCmd.SetParameterName("angle", true);
armAngleCmd.SetRange("angle>=0. && angle<180.");
armAngleCmd.SetDefaultValue("30.");
// armAngle command
auto& armAngleCmd
= fMessenger->DeclareMethodWithUnit("armAngle","deg",
&B5DetectorConstruction::SetArmAngle,
"Set rotation angle of the second arm.");
armAngleCmd.SetParameterName("angle", true);
armAngleCmd.SetRange("angle>=0. && angle<180.");
armAngleCmd.SetDefaultValue("30.");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+60 -59
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B5DriftChamberHit.cc 76474 2013-11-11 10:36:34Z gcosmo $
// $Id: B5DriftChamberHit.cc 101036 2016-11-04 09:00:23Z gcosmo $
//
/// \file B5DriftChamberHit.cc
/// \brief Implementation of the B5DriftChamberHit class
@@ -49,13 +49,15 @@ G4ThreadLocal G4Allocator<B5DriftChamberHit>* B5DriftChamberHitAllocator;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5DriftChamberHit::B5DriftChamberHit()
: G4VHit(), fLayerID(-1), fTime(0.), fLocalPos(0), fWorldPos(0)
: G4VHit(),
fLayerID(-1), fTime(0.), fLocalPos(0), fWorldPos(0)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5DriftChamberHit::B5DriftChamberHit(G4int z)
: G4VHit(), fLayerID(z), fTime(0.), fLocalPos(0), fWorldPos(0)
B5DriftChamberHit::B5DriftChamberHit(G4int layerID)
: G4VHit(),
fLayerID(layerID), fTime(0.), fLocalPos(0), fWorldPos(0)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -66,97 +68,96 @@ B5DriftChamberHit::~B5DriftChamberHit()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5DriftChamberHit::B5DriftChamberHit(const B5DriftChamberHit &right)
: G4VHit() {
fLayerID = right.fLayerID;
fWorldPos = right.fWorldPos;
fLocalPos = right.fLocalPos;
fTime = right.fTime;
}
: G4VHit(),
fLayerID(right.fLayerID),
fTime(right.fTime),
fLocalPos(right.fLocalPos),
fWorldPos(right.fWorldPos)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const B5DriftChamberHit& B5DriftChamberHit::operator=(const B5DriftChamberHit &right)
{
fLayerID = right.fLayerID;
fWorldPos = right.fWorldPos;
fLocalPos = right.fLocalPos;
fTime = right.fTime;
return *this;
fLayerID = right.fLayerID;
fTime = right.fTime;
fLocalPos = right.fLocalPos;
fWorldPos = right.fWorldPos;
return *this;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int B5DriftChamberHit::operator==(const B5DriftChamberHit &/*right*/) const
{
return 0;
return 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5DriftChamberHit::Draw()
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if(pVVisManager)
{
G4Circle circle(fWorldPos);
circle.SetScreenSize(2);
circle.SetFillStyle(G4Circle::filled);
G4Colour colour(1.,1.,0.);
G4VisAttributes attribs(colour);
circle.SetVisAttributes(attribs);
pVVisManager->Draw(circle);
}
auto visManager = G4VVisManager::GetConcreteInstance();
if (! visManager) return;
G4Circle circle(fWorldPos);
circle.SetScreenSize(2);
circle.SetFillStyle(G4Circle::filled);
G4Colour colour(1.,1.,0.);
G4VisAttributes attribs(colour);
circle.SetVisAttributes(attribs);
visManager->Draw(circle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const std::map<G4String,G4AttDef>* B5DriftChamberHit::GetAttDefs() const
{
G4bool isNew;
std::map<G4String,G4AttDef>* store
= G4AttDefStore::GetInstance("B5DriftChamberHit",isNew);
G4bool isNew;
auto store = G4AttDefStore::GetInstance("B5DriftChamberHit",isNew);
if (isNew) {
(*store)["HitType"]
= G4AttDef("HitType","Hit Type","Physics","","G4String");
(*store)["ID"]
= G4AttDef("ID","ID","Physics","","G4int");
(*store)["Time"]
= G4AttDef("Time","Time","Physics","G4BestUnit","G4double");
(*store)["Pos"]
= G4AttDef("Pos", "Position", "Physics","G4BestUnit","G4ThreeVector");
}
return store;
if (isNew) {
(*store)["HitType"]
= G4AttDef("HitType","Hit Type","Physics","","G4String");
(*store)["ID"]
= G4AttDef("ID","ID","Physics","","G4int");
(*store)["Time"]
= G4AttDef("Time","Time","Physics","G4BestUnit","G4double");
(*store)["Pos"]
= G4AttDef("Pos", "Position", "Physics","G4BestUnit","G4ThreeVector");
}
return store;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
std::vector<G4AttValue>* B5DriftChamberHit::CreateAttValues() const
{
std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
values
->push_back(G4AttValue("HitType","DriftChamberHit",""));
values
->push_back(G4AttValue("ID",G4UIcommand::ConvertToString(fLayerID),""));
values
->push_back(G4AttValue("Time",G4BestUnit(fTime,"Time"),""));
values
->push_back(G4AttValue("Pos",G4BestUnit(fWorldPos,"Length"),""));
return values;
auto values = new std::vector<G4AttValue>;
values
->push_back(G4AttValue("HitType","DriftChamberHit",""));
values
->push_back(G4AttValue("ID",G4UIcommand::ConvertToString(fLayerID),""));
values
->push_back(G4AttValue("Time",G4BestUnit(fTime,"Time"),""));
values
->push_back(G4AttValue("Pos",G4BestUnit(fWorldPos,"Length"),""));
return values;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5DriftChamberHit::Print()
{
G4cout << " Layer[" << fLayerID << "] : time " << fTime/ns
<< " (nsec) --- local (x,y) " << fLocalPos.x()
<< ", " << fLocalPos.y() << G4endl;
G4cout << " Layer[" << fLayerID << "] : time " << fTime/ns
<< " (nsec) --- local (x,y) " << fLocalPos.x()
<< ", " << fLocalPos.y() << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+30 -28
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B5DriftChamberSD.cc 76474 2013-11-11 10:36:34Z gcosmo $
// $Id: B5DriftChamberSD.cc 101036 2016-11-04 09:00:23Z gcosmo $
//
/// \file B5DriftChamberSD.cc
/// \brief Implementation of the B5DriftChamber class
@@ -41,9 +41,10 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5DriftChamberSD::B5DriftChamberSD(G4String name)
: G4VSensitiveDetector(name), fHitsCollection(0), fHCID(-1)
: G4VSensitiveDetector(name),
fHitsCollection(nullptr), fHCID(-1)
{
collectionName.insert("driftChamberColl");
collectionName.insert("driftChamberColl");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -55,39 +56,40 @@ B5DriftChamberSD::~B5DriftChamberSD()
void B5DriftChamberSD::Initialize(G4HCofThisEvent* hce)
{
fHitsCollection
= new B5DriftChamberHitsCollection(SensitiveDetectorName,collectionName[0]);
if (fHCID<0)
{ fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection); }
hce->AddHitsCollection(fHCID,fHitsCollection);
fHitsCollection
= new B5DriftChamberHitsCollection(SensitiveDetectorName,collectionName[0]);
if (fHCID<0) {
fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection);
}
hce->AddHitsCollection(fHCID,fHitsCollection);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool B5DriftChamberSD::ProcessHits(G4Step* step, G4TouchableHistory*)
{
G4double charge = step->GetTrack()->GetDefinition()->GetPDGCharge();
if (charge==0.) return true;
G4StepPoint* preStepPoint = step->GetPreStepPoint();
auto charge = step->GetTrack()->GetDefinition()->GetPDGCharge();
if (charge==0.) return true;
auto preStepPoint = step->GetPreStepPoint();
G4TouchableHistory* touchable
= (G4TouchableHistory*)(step->GetPreStepPoint()->GetTouchable());
G4VPhysicalVolume* motherPhysical = touchable->GetVolume(1); // mother
G4int copyNo = motherPhysical->GetCopyNo();
auto touchable = step->GetPreStepPoint()->GetTouchable();
auto motherPhysical = touchable->GetVolume(1); // mother
auto copyNo = motherPhysical->GetCopyNo();
G4ThreeVector worldPos = preStepPoint->GetPosition();
G4ThreeVector localPos
= touchable->GetHistory()->GetTopTransform().TransformPoint(worldPos);
B5DriftChamberHit* hit = new B5DriftChamberHit(copyNo);
hit->SetWorldPos(worldPos);
hit->SetLocalPos(localPos);
hit->SetTime(preStepPoint->GetGlobalTime());
fHitsCollection->insert(hit);
return true;
auto worldPos = preStepPoint->GetPosition();
auto localPos
= touchable->GetHistory()->GetTopTransform().TransformPoint(worldPos);
auto hit = new B5DriftChamberHit(copyNo);
hit->SetWorldPos(worldPos);
hit->SetLocalPos(localPos);
hit->SetTime(preStepPoint->GetGlobalTime());
fHitsCollection->insert(hit);
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+74 -74
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B5EmCalorimeterHit.cc 76474 2013-11-11 10:36:34Z gcosmo $
// $Id: B5EmCalorimeterHit.cc 101036 2016-11-04 09:00:23Z gcosmo $
//
/// \file B5EmCalorimeterHit.cc
/// \brief Implementation of the B5EmCalorimeterHit class
@@ -48,13 +48,15 @@ G4ThreadLocal G4Allocator<B5EmCalorimeterHit>* B5EmCalorimeterHitAllocator;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5EmCalorimeterHit::B5EmCalorimeterHit()
: G4VHit(), fCellID(-1), fEdep(0.), fPos(0), fPLogV(0)
: G4VHit(),
fCellID(-1), fEdep(0.), fPos(0.), fPLogV(nullptr)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5EmCalorimeterHit::B5EmCalorimeterHit(G4int z)
: G4VHit(), fCellID(z), fEdep(0.), fPos(0), fPLogV(0)
B5EmCalorimeterHit::B5EmCalorimeterHit(G4int cellID)
: G4VHit(),
fCellID(cellID), fEdep(0.), fPos(0.), fPLogV(nullptr)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -65,113 +67,111 @@ B5EmCalorimeterHit::~B5EmCalorimeterHit()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5EmCalorimeterHit::B5EmCalorimeterHit(const B5EmCalorimeterHit &right)
: G4VHit() {
fCellID = right.fCellID;
fEdep = right.fEdep;
fPos = right.fPos;
fRot = right.fRot;
fPLogV = right.fPLogV;
}
: G4VHit(),
fCellID(right.fCellID),
fEdep(right.fEdep),
fPos(right.fPos),
fRot(right.fRot),
fPLogV(right.fPLogV)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const B5EmCalorimeterHit& B5EmCalorimeterHit::operator=(const B5EmCalorimeterHit
&right)
{
fCellID = right.fCellID;
fEdep = right.fEdep;
fPos = right.fPos;
fRot = right.fRot;
fPLogV = right.fPLogV;
return *this;
fCellID = right.fCellID;
fEdep = right.fEdep;
fPos = right.fPos;
fRot = right.fRot;
fPLogV = right.fPLogV;
return *this;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int B5EmCalorimeterHit::operator==(const B5EmCalorimeterHit &right) const
{
return (fCellID==right.fCellID);
return (fCellID==right.fCellID);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5EmCalorimeterHit::Draw()
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if (pVVisManager&&(fEdep>0.))
{
// Draw a calorimeter cell with a color corresponding to its energy deposit
G4Transform3D trans(fRot.inverse(),fPos);
G4VisAttributes attribs;
const G4VisAttributes* pVA = fPLogV->GetVisAttributes();
if (pVA) attribs = *pVA;
G4double rcol = fEdep/(0.7*GeV);
if (rcol>1.) rcol = 1.;
if (rcol<0.4) rcol = 0.4;
G4Colour colour(rcol,0.,0.);
attribs.SetColour(colour);
attribs.SetForceSolid(true);
pVVisManager->Draw(*fPLogV,attribs,trans);
}
auto visManager = G4VVisManager::GetConcreteInstance();
if ( ! visManager || (fEdep==0.) ) return;
// Draw a calorimeter cell with a color corresponding to its energy deposit
G4Transform3D trans(fRot.inverse(),fPos);
G4VisAttributes attribs;
auto pVA = fPLogV->GetVisAttributes();
if (pVA) attribs = *pVA;
auto rcol = fEdep/(0.7*GeV);
if (rcol>1.) rcol = 1.;
if (rcol<0.4) rcol = 0.4;
G4Colour colour(rcol,0.,0.);
attribs.SetColour(colour);
attribs.SetForceSolid(true);
visManager->Draw(*fPLogV,attribs,trans);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const std::map<G4String,G4AttDef>* B5EmCalorimeterHit::GetAttDefs() const
{
G4bool isNew;
std::map<G4String,G4AttDef>* store
= G4AttDefStore::GetInstance("B5EmCalorimeterHit",isNew);
G4bool isNew;
auto store = G4AttDefStore::GetInstance("B5EmCalorimeterHit",isNew);
if (isNew) {
(*store)["HitType"]
= G4AttDef("HitType","Hit Type","Physics","","G4String");
(*store)["ID"]
= G4AttDef("ID","ID","Physics","","G4int");
(*store)["Energy"]
= G4AttDef("Energy", "Energy Deposited", "Physics", "G4BestUnit",
"G4double");
(*store)["Pos"]
= G4AttDef("Pos", "Position", "Physics","G4BestUnit",
"G4ThreeVector");
(*store)["LVol"]
= G4AttDef("LVol","Logical Volume","Physics","","G4String");
}
return store;
if (isNew) {
(*store)["HitType"]
= G4AttDef("HitType","Hit Type","Physics","","G4String");
(*store)["ID"]
= G4AttDef("ID","ID","Physics","","G4int");
(*store)["Energy"]
= G4AttDef("Energy", "Energy Deposited", "Physics", "G4BestUnit",
"G4double");
(*store)["Pos"]
= G4AttDef("Pos", "Position", "Physics","G4BestUnit",
"G4ThreeVector");
(*store)["LVol"]
= G4AttDef("LVol","Logical Volume","Physics","","G4String");
}
return store;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
std::vector<G4AttValue>* B5EmCalorimeterHit::CreateAttValues() const
{
std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
values
->push_back(G4AttValue("HitType","EmCalorimeterHit",""));
values
->push_back(G4AttValue("ID",G4UIcommand::ConvertToString(fCellID),""));
values
->push_back(G4AttValue("Energy",G4BestUnit(fEdep,"Energy"),""));
values
->push_back(G4AttValue("Pos",G4BestUnit(fPos,"Length"),""));
if (fPLogV)
values->push_back(G4AttValue("LVol",fPLogV->GetName(),""));
else
values->push_back(G4AttValue("LVol"," ",""));
return values;
auto values = new std::vector<G4AttValue>;
values
->push_back(G4AttValue("HitType","EmCalorimeterHit",""));
values
->push_back(G4AttValue("ID",G4UIcommand::ConvertToString(fCellID),""));
values
->push_back(G4AttValue("Energy",G4BestUnit(fEdep,"Energy"),""));
values
->push_back(G4AttValue("Pos",G4BestUnit(fPos,"Length"),""));
if (fPLogV)
values->push_back(G4AttValue("LVol",fPLogV->GetName(),""));
else
values->push_back(G4AttValue("LVol"," ",""));
return values;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5EmCalorimeterHit::Print()
{
G4cout << " Cell[" << fCellID << "] " << fEdep/MeV << " (MeV)" << G4endl;
G4cout << " Cell[" << fCellID << "] " << fEdep/MeV << " (MeV)" << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+37 -39
View File
@@ -23,13 +23,14 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B5EmCalorimeterSD.cc 76474 2013-11-11 10:36:34Z gcosmo $
// $Id: B5EmCalorimeterSD.cc 101036 2016-11-04 09:00:23Z gcosmo $
//
/// \file B5EmCalorimeterSD.cc
/// \brief Implementation of the B5EmCalorimeterSD class
#include "B5EmCalorimeterSD.hh"
#include "B5EmCalorimeterHit.hh"
#include "B5Constants.hh"
#include "G4HCofThisEvent.hh"
#include "G4TouchableHistory.hh"
@@ -41,9 +42,10 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5EmCalorimeterSD::B5EmCalorimeterSD(G4String name)
: G4VSensitiveDetector(name), fHitsCollection(0), fHCID(-1)
: G4VSensitiveDetector(name),
fHitsCollection(nullptr), fHCID(-1)
{
collectionName.insert("EMcalorimeterColl");
collectionName.insert("EMcalorimeterColl");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -55,48 +57,44 @@ B5EmCalorimeterSD::~B5EmCalorimeterSD()
void B5EmCalorimeterSD::Initialize(G4HCofThisEvent* hce)
{
fHitsCollection
= new B5EmCalorimeterHitsCollection(SensitiveDetectorName,collectionName[0]);
if (fHCID<0)
{ fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection); }
hce->AddHitsCollection(fHCID,fHitsCollection);
// fill calorimeter hits with zero energy deposition
for (G4int i=0;i<80;i++)
{
B5EmCalorimeterHit* hit = new B5EmCalorimeterHit(i);
fHitsCollection->insert(hit);
}
fHitsCollection
= new B5EmCalorimeterHitsCollection(SensitiveDetectorName,collectionName[0]);
if (fHCID<0) {
fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection);
}
hce->AddHitsCollection(fHCID,fHitsCollection);
// fill calorimeter hits with zero energy deposition
for (auto i=0;i<kNofEmCells;i++) {
fHitsCollection->insert(new B5EmCalorimeterHit(i));
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool B5EmCalorimeterSD::ProcessHits(G4Step*step, G4TouchableHistory*)
{
G4double edep = step->GetTotalEnergyDeposit();
if (edep==0.) return true;
G4TouchableHistory* touchable
= (G4TouchableHistory*)(step->GetPreStepPoint()->GetTouchable());
G4VPhysicalVolume* physical = touchable->GetVolume();
G4int copyNo = physical->GetCopyNo();
B5EmCalorimeterHit* hit = (*fHitsCollection)[copyNo];
// check if it is first touch
if (!(hit->GetLogV()))
{
// fill volume information
hit->SetLogV(physical->GetLogicalVolume());
G4AffineTransform transform
= touchable->GetHistory()->GetTopTransform();
transform.Invert();
hit->SetRot(transform.NetRotation());
hit->SetPos(transform.NetTranslation());
}
// add energy deposition
hit->AddEdep(edep);
return true;
auto edep = step->GetTotalEnergyDeposit();
if (edep==0.) return true;
auto touchable = step->GetPreStepPoint()->GetTouchable();
auto physical = touchable->GetVolume();
auto copyNo = physical->GetCopyNo();
auto hit = (*fHitsCollection)[copyNo];
// check if it is first touch
if (!(hit->GetLogV())) {
// fill volume information
hit->SetLogV(physical->GetLogicalVolume());
G4AffineTransform transform = touchable->GetHistory()->GetTopTransform();
transform.Invert();
hit->SetRot(transform.NetRotation());
hit->SetPos(transform.NetTranslation());
}
// add energy deposition
hit->AddEdep(edep);
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+166 -186
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B5EventAction.cc 94486 2015-11-19 08:33:37Z gcosmo $
// $Id: B5EventAction.cc 101036 2016-11-04 09:00:23Z gcosmo $
//
/// \file B5EventAction.cc
/// \brief Implementation of the B5EventAction class
@@ -33,6 +33,7 @@
#include "B5DriftChamberHit.hh"
#include "B5EmCalorimeterHit.hh"
#include "B5HadCalorimeterHit.hh"
#include "B5Constants.hh"
#include "B5Analysis.hh"
#include "G4Event.hh"
@@ -49,21 +50,17 @@
B5EventAction::B5EventAction()
: G4UserEventAction(),
fHHC1ID(-1),
fHHC2ID(-1),
fDHC1ID(-1),
fDHC2ID(-1),
fECHCID(-1),
fHCHCID(-1),
fEmCalEdep(),
fHadCalEdep()
fHodHC1ID(-1),
fHodHC2ID(-1),
fDriftHC1ID(-1),
fDriftHC2ID(-1),
fEmCalHCID(-1),
fHadCalHCID(-1),
fEmCalEdep(kNofEmCells, 0.),
fHadCalEdep(kNofHadCells, 0.)
{
// set printing per each event
G4RunManager::GetRunManager()->SetPrintProgress(1);
// initialize the vectors
fEmCalEdep.resize(80, 0.);
fHadCalEdep.resize(20, 0.);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -75,204 +72,187 @@ B5EventAction::~B5EventAction()
void B5EventAction::BeginOfEventAction(const G4Event*)
{
if (fHHC1ID==-1) {
G4SDManager* sdManager = G4SDManager::GetSDMpointer();
fHHC1ID = sdManager->GetCollectionID("hodoscope1/hodoscopeColl");
fHHC2ID = sdManager->GetCollectionID("hodoscope2/hodoscopeColl");
fDHC1ID = sdManager->GetCollectionID("chamber1/driftChamberColl");
fDHC2ID = sdManager->GetCollectionID("chamber2/driftChamberColl");
fECHCID = sdManager->GetCollectionID("EMcalorimeter/EMcalorimeterColl");
fHCHCID = sdManager->GetCollectionID("HadCalorimeter/HadCalorimeterColl");
}
if (fHodHC1ID==-1) {
auto sdManager = G4SDManager::GetSDMpointer();
fHodHC1ID = sdManager->GetCollectionID("hodoscope1/hodoscopeColl");
fHodHC2ID = sdManager->GetCollectionID("hodoscope2/hodoscopeColl");
fDriftHC1ID = sdManager->GetCollectionID("chamber1/driftChamberColl");
fDriftHC2ID = sdManager->GetCollectionID("chamber2/driftChamberColl");
fEmCalHCID = sdManager->GetCollectionID("EMcalorimeter/EMcalorimeterColl");
fHadCalHCID = sdManager->GetCollectionID("HadCalorimeter/HadCalorimeterColl");
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5EventAction::EndOfEventAction(const G4Event* event)
{
G4HCofThisEvent* hce = event->GetHCofThisEvent();
if (!hce)
{
G4ExceptionDescription msg;
msg << "No hits collection of this event found." << G4endl;
G4Exception("B5EventAction::EndOfEventAction()",
"B5Code001", JustWarning, msg);
return;
}
auto hce = event->GetHCofThisEvent();
if (!hce) {
G4ExceptionDescription msg;
msg << "No hits collection of this event found." << G4endl;
G4Exception("B5EventAction::EndOfEventAction()",
"B5Code001", JustWarning, msg);
return;
}
// Get hits collections
B5HodoscopeHitsCollection* hHC1
= static_cast<B5HodoscopeHitsCollection*>(hce->GetHC(fHHC1ID));
B5HodoscopeHitsCollection* hHC2
= static_cast<B5HodoscopeHitsCollection*>(hce->GetHC(fHHC2ID));
B5DriftChamberHitsCollection* dHC1
= static_cast<B5DriftChamberHitsCollection*>(hce->GetHC(fDHC1ID));
B5DriftChamberHitsCollection* dHC2
= static_cast<B5DriftChamberHitsCollection*>(hce->GetHC(fDHC2ID));
B5EmCalorimeterHitsCollection* ecHC
= static_cast<B5EmCalorimeterHitsCollection*>(hce->GetHC(fECHCID));
B5HadCalorimeterHitsCollection* hcHC
= static_cast<B5HadCalorimeterHitsCollection*>(hce->GetHC(fHCHCID));
if ( (!hHC1) || (!hHC2) || (!dHC1) || (!dHC2) || (!ecHC) || (!hcHC) )
{
G4ExceptionDescription msg;
msg << "Some of hits collections of this event not found." << G4endl;
G4Exception("B5EventAction::EndOfEventAction()",
"B5Code001", JustWarning, msg);
return;
}
// Get hits collections
auto hHC1
= static_cast<B5HodoscopeHitsCollection*>(hce->GetHC(fHodHC1ID));
//
// Fill histograms & ntuple
//
auto hHC2
= static_cast<B5HodoscopeHitsCollection*>(hce->GetHC(fHodHC2ID));
// Get analysis manager
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
auto dHC1
= static_cast<B5DriftChamberHitsCollection*>(hce->GetHC(fDriftHC1ID));
auto dHC2
= static_cast<B5DriftChamberHitsCollection*>(hce->GetHC(fDriftHC2ID));
auto ecHC
= static_cast<B5EmCalorimeterHitsCollection*>(hce->GetHC(fEmCalHCID));
auto hcHC
= static_cast<B5HadCalorimeterHitsCollection*>(hce->GetHC(fHadCalHCID));
if ( (!hHC1) || (!hHC2) || (!dHC1) || (!dHC2) || (!ecHC) || (!hcHC) ) {
G4ExceptionDescription msg;
msg << "Some of hits collections of this event not found." << G4endl;
G4Exception("B5EventAction::EndOfEventAction()",
"B5Code001", JustWarning, msg);
return;
}
//
// Fill histograms & ntuple
//
// Get analysis manager
auto analysisManager = G4AnalysisManager::Instance();
// Fill histograms
// Fill histograms
G4int n_hit = dHC1->entries();
analysisManager->FillH1(0, n_hit);
auto nhit = dHC1->entries();
analysisManager->FillH1(0, nhit );
for (G4int i=0;i<n_hit;i++)
{
B5DriftChamberHit* hit = (*dHC1)[i];
G4ThreeVector localPos = hit->GetLocalPos();
analysisManager->FillH2(0, localPos.x(), localPos.y());
}
for (auto i=0;i<nhit ;i++) {
auto hit = (*dHC1)[i];
auto localPos = hit->GetLocalPos();
analysisManager->FillH2(0, localPos.x(), localPos.y());
}
n_hit = dHC2->entries();
analysisManager->FillH1(1, n_hit);
nhit = dHC2->entries();
analysisManager->FillH1(1, nhit );
for (G4int i=0;i<n_hit;i++)
{
B5DriftChamberHit* hit = (*dHC2)[i];
G4ThreeVector localPos = hit->GetLocalPos();
analysisManager->FillH2(1, localPos.x(), localPos.y());
}
// Fill ntuple
// Dc1Hits
analysisManager->FillNtupleIColumn(0, dHC1->entries());
// Dc2Hits
analysisManager->FillNtupleIColumn(1, dHC1->entries());
// ECEnergy
G4int totalEmHit = 0;
G4double totalEmE = 0.;
for (G4int i=0;i<80;i++)
{
B5EmCalorimeterHit* hit = (*ecHC)[i];
G4double eDep = hit->GetEdep();
if (eDep>0.)
{
totalEmHit++;
totalEmE += eDep;
}
fEmCalEdep[i] = eDep;
}
analysisManager->FillNtupleDColumn(2, totalEmE);
// HCEnergy
G4int totalHadHit = 0;
G4double totalHadE = 0.;
for (G4int i=0;i<20;i++)
{
B5HadCalorimeterHit* hit = (*hcHC)[i];
G4double eDep = hit->GetEdep();
if (eDep>0.)
{
totalHadHit++;
totalHadE += eDep;
}
fHadCalEdep[i] = eDep;
}
analysisManager->FillNtupleDColumn(3, totalHadE);
// Time 1
for (G4int i=0;i<hHC1->entries();i++)
{
analysisManager->FillNtupleDColumn(4,(*hHC1)[i]->GetTime());
}
for (auto i=0;i<nhit ;i++) {
auto hit = (*dHC2)[i];
auto localPos = hit->GetLocalPos();
analysisManager->FillH2(1, localPos.x(), localPos.y());
}
// Time 2
for (G4int i=0;i<hHC2->entries();i++)
{
analysisManager->FillNtupleDColumn(5,(*hHC2)[i]->GetTime());
}
analysisManager->AddNtupleRow();
//
// Print diagnostics
//
G4int printModulo = G4RunManager::GetRunManager()->GetPrintProgress();
if ( printModulo==0 || event->GetEventID() % printModulo != 0) return;
G4PrimaryParticle* primary = event->GetPrimaryVertex(0)->GetPrimary(0);
G4cout << G4endl
<< ">>> Event " << event->GetEventID() << " >>> Simulation truth : "
<< primary->GetG4code()->GetParticleName()
<< " " << primary->GetMomentum() << G4endl;
// Hodoscope 1
n_hit = hHC1->entries();
G4cout << "Hodoscope 1 has " << n_hit << " hits." << G4endl;
for (G4int i=0;i<n_hit;i++)
{
B5HodoscopeHit* hit = (*hHC1)[i];
hit->Print();
// Fill ntuple
// Dc1Hits
analysisManager->FillNtupleIColumn(0, dHC1->entries());
// Dc2Hits
analysisManager->FillNtupleIColumn(1, dHC1->entries());
// ECEnergy
G4int totalEmHit = 0;
G4double totalEmE = 0.;
for (auto i=0;i<kNofEmCells;i++) {
auto hit = (*ecHC)[i];
auto edep = hit->GetEdep();
if (edep>0.) {
totalEmHit++;
totalEmE += edep;
}
fEmCalEdep[i] = edep;
}
analysisManager->FillNtupleDColumn(2, totalEmE);
// Hodoscope 2
n_hit = hHC2->entries();
G4cout << "Hodoscope 2 has " << n_hit << " hits." << G4endl;
for (G4int i=0;i<n_hit;i++)
{
B5HodoscopeHit* hit = (*hHC2)[i];
hit->Print();
// HCEnergy
G4int totalHadHit = 0;
G4double totalHadE = 0.;
for (auto i=0;i<kNofHadCells;i++) {
auto hit = (*hcHC)[i];
auto edep = hit->GetEdep();
if (edep>0.) {
totalHadHit++;
totalHadE += edep;
}
fHadCalEdep[i] = edep;
}
analysisManager->FillNtupleDColumn(3, totalHadE);
// Drift chamber 1
n_hit = dHC1->entries();
G4cout << "Drift Chamber 1 has " << n_hit << " hits." << G4endl;
for (G4int i2=0;i2<5;i2++)
{
for (G4int i=0;i<n_hit;i++)
{
B5DriftChamberHit* hit = (*dHC1)[i];
if (hit->GetLayerID()==i2) hit->Print();
}
// Time 1
for (auto i=0;i<hHC1->entries();i++) {
analysisManager->FillNtupleDColumn(4,(*hHC1)[i]->GetTime());
}
// Time 2
for (auto i=0;i<hHC2->entries();i++) {
analysisManager->FillNtupleDColumn(5,(*hHC2)[i]->GetTime());
}
analysisManager->AddNtupleRow();
//
// Print diagnostics
//
auto printModulo = G4RunManager::GetRunManager()->GetPrintProgress();
if ( printModulo==0 || event->GetEventID() % printModulo != 0) return;
auto primary = event->GetPrimaryVertex(0)->GetPrimary(0);
G4cout
<< G4endl
<< ">>> Event " << event->GetEventID() << " >>> Simulation truth : "
<< primary->GetG4code()->GetParticleName()
<< " " << primary->GetMomentum() << G4endl;
// Hodoscope 1
nhit = hHC1->entries();
G4cout << "Hodoscope 1 has " << nhit << " hits." << G4endl;
for (auto i=0;i<nhit ;i++) {
auto hit = (*hHC1)[i];
hit->Print();
}
// Hodoscope 2
nhit = hHC2->entries();
G4cout << "Hodoscope 2 has " << nhit << " hits." << G4endl;
for (auto i=0;i<nhit ;i++) {
auto hit = (*hHC2)[i];
hit->Print();
}
// Drift chamber 1
nhit = dHC1->entries();
G4cout << "Drift Chamber 1 has " << nhit << " hits." << G4endl;
for (auto layer=0;layer<kNofChambers;layer++) {
for (auto i=0;i<nhit ;i++) {
auto hit = (*dHC1)[i];
if (hit->GetLayerID()==layer) hit->Print();
}
}
// Drift chamber 2
n_hit = dHC2->entries();
G4cout << "Drift Chamber 2 has " << n_hit << " hits." << G4endl;
for (G4int i2=0;i2<5;i2++)
{
for (G4int i=0;i<n_hit;i++)
{
B5DriftChamberHit* hit = (*dHC2)[i];
if (hit->GetLayerID()==i2) hit->Print();
}
// Drift chamber 2
nhit = dHC2->entries();
G4cout << "Drift Chamber 2 has " << nhit << " hits." << G4endl;
for (auto layer=0;layer<kNofChambers;layer++) {
for (auto i=0;i<nhit ;i++) {
auto hit = (*dHC2)[i];
if (hit->GetLayerID()==layer) hit->Print();
}
}
// EM calorimeter
G4cout << "EM Calorimeter has " << totalEmHit << " hits. Total Edep is "
// EM calorimeter
G4cout << "EM Calorimeter has " << totalEmHit << " hits. Total Edep is "
<< totalEmE/MeV << " (MeV)" << G4endl;
// Had calorimeter
G4cout << "Hadron Calorimeter has " << totalHadHit << " hits. Total Edep is "
// Had calorimeter
G4cout << "Hadron Calorimeter has " << totalHadHit << " hits. Total Edep is "
<< totalHadE/MeV << " (MeV)" << G4endl;
}
+72 -72
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B5HadCalorimeterHit.cc 76474 2013-11-11 10:36:34Z gcosmo $
// $Id: B5HadCalorimeterHit.cc 101036 2016-11-04 09:00:23Z gcosmo $
//
/// \file B5HadCalorimeterHit.cc
/// \brief Implementation of the B5HadCalorimeterHit class
@@ -49,14 +49,16 @@ G4ThreadLocal G4Allocator<B5HadCalorimeterHit>* B5HadCalorimeterHitAllocator;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5HadCalorimeterHit::B5HadCalorimeterHit()\
: G4VHit(), fColumnID(-1), fRowID(-1), fEdep(0.), fPos(0)
B5HadCalorimeterHit::B5HadCalorimeterHit()
: G4VHit(),
fColumnID(-1), fRowID(-1), fEdep(0.), fPos(0)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5HadCalorimeterHit::B5HadCalorimeterHit(G4int iCol,G4int iRow)
: G4VHit(), fColumnID(iCol), fRowID(iRow), fEdep(0.), fPos(0)
B5HadCalorimeterHit::B5HadCalorimeterHit(G4int columnID,G4int rowID)
: G4VHit(),
fColumnID(columnID), fRowID(rowID), fEdep(0.), fPos(0)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -67,108 +69,106 @@ B5HadCalorimeterHit::~B5HadCalorimeterHit()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5HadCalorimeterHit::B5HadCalorimeterHit(const B5HadCalorimeterHit &right)
: G4VHit() {
fColumnID = right.fColumnID;
fRowID = right.fRowID;
fEdep = right.fEdep;
fPos = right.fPos;
fRot = right.fRot;
}
: G4VHit(),
fColumnID(right.fColumnID),
fRowID(right.fRowID),
fEdep(right.fEdep),
fPos(right.fPos),
fRot(right.fRot)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const B5HadCalorimeterHit& B5HadCalorimeterHit::operator=(const
B5HadCalorimeterHit &right)
const B5HadCalorimeterHit& B5HadCalorimeterHit::operator=(
const B5HadCalorimeterHit &right)
{
fColumnID = right.fColumnID;
fRowID = right.fRowID;
fEdep = right.fEdep;
fPos = right.fPos;
fRot = right.fRot;
return *this;
fColumnID = right.fColumnID;
fRowID = right.fRowID;
fEdep = right.fEdep;
fPos = right.fPos;
fRot = right.fRot;
return *this;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int B5HadCalorimeterHit::operator==(const B5HadCalorimeterHit &right) const
{
return (fColumnID==right.fColumnID&&fRowID==right.fRowID);
return (fColumnID==right.fColumnID&&fRowID==right.fRowID);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5HadCalorimeterHit::Draw()
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if (pVVisManager&&(fEdep>0.))
{
// Draw a calorimeter cell with depth propotional to the energy deposition
G4Transform3D trans(fRot.inverse(),fPos);
G4VisAttributes attribs;
G4Colour colour(1.,0.,0.);
attribs.SetColour(colour);
attribs.SetForceSolid(true);
G4Box box("dummy",15.*cm,15.*cm,1.*m*fEdep/(0.1*GeV));
pVVisManager->Draw(box,attribs,trans);
}
auto visManager = G4VVisManager::GetConcreteInstance();
if (! visManager || (fEdep==0.)) return;
// Draw a calorimeter cell with depth propotional to the energy deposition
G4Transform3D trans(fRot.inverse(),fPos);
G4VisAttributes attribs;
G4Colour colour(1.,0.,0.);
attribs.SetColour(colour);
attribs.SetForceSolid(true);
G4Box box("dummy",15.*cm,15.*cm,1.*m*fEdep/(0.1*GeV));
visManager->Draw(box,attribs,trans);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const std::map<G4String,G4AttDef>* B5HadCalorimeterHit::GetAttDefs() const
{
G4bool isNew;
std::map<G4String,G4AttDef>* store
= G4AttDefStore::GetInstance("B5HadCalorimeterHit",isNew);
G4bool isNew;
auto store = G4AttDefStore::GetInstance("B5HadCalorimeterHit",isNew);
if (isNew) {
(*store)["HitType"]
= G4AttDef("HitType","Hit Type","Physics","","G4String");
(*store)["Column"]
= G4AttDef("Column","Column ID","Physics","","G4int");
(*store)["Row"]
= G4AttDef("Row","Row ID","Physics","","G4int");
(*store)["Energy"]
= G4AttDef("Energy","Energy Deposited","Physics","G4BestUnit",
"G4double");
(*store)["Pos"]
= G4AttDef("Pos", "Position", "Physics","G4BestUnit",
"G4ThreeVector");
}
return store;
if (isNew) {
(*store)["HitType"]
= G4AttDef("HitType","Hit Type","Physics","","G4String");
(*store)["Column"]
= G4AttDef("Column","Column ID","Physics","","G4int");
(*store)["Row"]
= G4AttDef("Row","Row ID","Physics","","G4int");
(*store)["Energy"]
= G4AttDef("Energy","Energy Deposited","Physics","G4BestUnit",
"G4double");
(*store)["Pos"]
= G4AttDef("Pos", "Position", "Physics","G4BestUnit",
"G4ThreeVector");
}
return store;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
std::vector<G4AttValue>* B5HadCalorimeterHit::CreateAttValues() const
{
std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
values
->push_back(G4AttValue("HitType","HadCalorimeterHit",""));
values
->push_back(G4AttValue("Column",G4UIcommand::ConvertToString(fColumnID),
""));
values
->push_back(G4AttValue("Row",G4UIcommand::ConvertToString(fRowID),""));
values
->push_back(G4AttValue("Energy",G4BestUnit(fEdep,"Energy"),""));
values
->push_back(G4AttValue("Pos",G4BestUnit(fPos,"Length"),""));
return values;
auto values = new std::vector<G4AttValue>;
values
->push_back(G4AttValue("HitType","HadCalorimeterHit",""));
values
->push_back(G4AttValue("Column",G4UIcommand::ConvertToString(fColumnID),
""));
values
->push_back(G4AttValue("Row",G4UIcommand::ConvertToString(fRowID),""));
values
->push_back(G4AttValue("Energy",G4BestUnit(fEdep,"Energy"),""));
values
->push_back(G4AttValue("Pos",G4BestUnit(fPos,"Length"),""));
return values;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5HadCalorimeterHit::Print()
{
G4cout << " Cell[" << fRowID << ", " << fColumnID << "] "
G4cout << " Cell[" << fRowID << ", " << fColumnID << "] "
<< fEdep/MeV << " (MeV) " << fPos << G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+41 -44
View File
@@ -23,13 +23,14 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B5HadCalorimeterSD.cc 96048 2016-03-10 15:34:12Z gcosmo $
// $Id: B5HadCalorimeterSD.cc 101036 2016-11-04 09:00:23Z gcosmo $
//
/// \file B5HadCalorimeterSD.cc
/// \brief Implementation of the B5HadCalorimeterSD class
#include "B5HadCalorimeterSD.hh"
#include "B5HadCalorimeterHit.hh"
#include "B5Constants.hh"
#include "G4HCofThisEvent.hh"
#include "G4TouchableHistory.hh"
@@ -41,9 +42,10 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5HadCalorimeterSD::B5HadCalorimeterSD(G4String name)
: G4VSensitiveDetector(name), fHitsCollection(0), fHCID(-1)
: G4VSensitiveDetector(name),
fHitsCollection(nullptr), fHCID(-1)
{
collectionName.insert("HadCalorimeterColl");
collectionName.insert("HadCalorimeterColl");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -55,53 +57,48 @@ B5HadCalorimeterSD::~B5HadCalorimeterSD()
void B5HadCalorimeterSD::Initialize(G4HCofThisEvent* hce)
{
fHitsCollection
= new B5HadCalorimeterHitsCollection(SensitiveDetectorName,collectionName[0]);
if (fHCID<0)
{ fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection); }
hce->AddHitsCollection(fHCID,fHitsCollection);
// fill calorimeter hits with zero energy deposition
for (G4int iColumn=0;iColumn<10;iColumn++)
for (G4int iRow=0;iRow<2;iRow++)
{
B5HadCalorimeterHit* hit = new B5HadCalorimeterHit();
fHitsCollection->insert(hit);
}
fHitsCollection
= new B5HadCalorimeterHitsCollection(SensitiveDetectorName,collectionName[0]);
if (fHCID<0) {
fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection);
}
hce->AddHitsCollection(fHCID,fHitsCollection);
// fill calorimeter hits with zero energy deposition
for (auto column=0;column<kNofHadColumns;column++) {
for (auto row=0;row<kNofHadRows;row++) {
fHitsCollection->insert(new B5HadCalorimeterHit());
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool B5HadCalorimeterSD::ProcessHits(G4Step* step, G4TouchableHistory*)
{
G4double edep = step->GetTotalEnergyDeposit();
if (edep==0.) return true;
G4TouchableHistory* touchable
= (G4TouchableHistory*)(step->GetPreStepPoint()->GetTouchable());
G4int rowNo = touchable->GetCopyNumber(2);
G4int columnNo = touchable->GetCopyNumber(3);
G4int hitID = 2*columnNo+rowNo;
B5HadCalorimeterHit* hit = (*fHitsCollection)[hitID];
// check if it is first touch
if (hit->GetColumnID()<0)
{
hit->SetColumnID(columnNo);
hit->SetRowID(rowNo);
G4int depth = touchable->GetHistory()->GetDepth();
G4AffineTransform transform
= touchable->GetHistory()->GetTransform(depth-2);
transform.Invert();
hit->SetRot(transform.NetRotation());
hit->SetPos(transform.NetTranslation());
}
// add energy deposition
hit->AddEdep(edep);
return true;
auto edep = step->GetTotalEnergyDeposit();
if (edep==0.) return true;
auto touchable = step->GetPreStepPoint()->GetTouchable();
auto rowNo = touchable->GetCopyNumber(2);
auto columnNo = touchable->GetCopyNumber(3);
auto hitID = kNofHadRows*columnNo+rowNo;
auto hit = (*fHitsCollection)[hitID];
// check if it is first touch
if (hit->GetColumnID()<0) {
hit->SetColumnID(columnNo);
hit->SetRowID(rowNo);
auto depth = touchable->GetHistory()->GetDepth();
auto transform = touchable->GetHistory()->GetTransform(depth-2);
transform.Invert();
hit->SetRot(transform.NetRotation());
hit->SetPos(transform.NetTranslation());
}
// add energy deposition
hit->AddEdep(edep);
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+66 -67
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B5HodoscopeHit.cc 76474 2013-11-11 10:36:34Z gcosmo $
// $Id: B5HodoscopeHit.cc 101036 2016-11-04 09:00:23Z gcosmo $
//
/// \file B5HodoscopeHit.cc
/// \brief Implementation of the B5HodoscopeHit class
@@ -48,8 +48,9 @@ G4ThreadLocal G4Allocator<B5HodoscopeHit>* B5HodoscopeHitAllocator;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5HodoscopeHit::B5HodoscopeHit(G4int i,G4double t)
: G4VHit(), fId(i), fTime(t), fPos(0), fPLogV(0)
B5HodoscopeHit::B5HodoscopeHit(G4int id,G4double time)
: G4VHit(),
fId(id), fTime(time), fPos(0.), fPLogV(nullptr)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -60,106 +61,104 @@ B5HodoscopeHit::~B5HodoscopeHit()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5HodoscopeHit::B5HodoscopeHit(const B5HodoscopeHit &right)
: G4VHit() {
fId = right.fId;
fTime = right.fTime;
fPos = right.fPos;
fRot = right.fRot;
fPLogV = right.fPLogV;
}
: G4VHit(),
fId(right.fId),
fTime(right.fTime),
fPos(right.fPos),
fRot(right.fRot),
fPLogV(right.fPLogV)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const B5HodoscopeHit& B5HodoscopeHit::operator=(const B5HodoscopeHit &right)
{
fId = right.fId;
fTime = right.fTime;
fPos = right.fPos;
fRot = right.fRot;
fPLogV = right.fPLogV;
return *this;
fId = right.fId;
fTime = right.fTime;
fPos = right.fPos;
fRot = right.fRot;
fPLogV = right.fPLogV;
return *this;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int B5HodoscopeHit::operator==(const B5HodoscopeHit &/*right*/) const
{
return 0;
return 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5HodoscopeHit::Draw()
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if (pVVisManager)
{
G4Transform3D trans(fRot.inverse(),fPos);
G4VisAttributes attribs;
const G4VisAttributes* pVA = fPLogV->GetVisAttributes();
if (pVA) attribs = *pVA;
G4Colour colour(0.,1.,1.);
attribs.SetColour(colour);
attribs.SetForceSolid(true);
pVVisManager->Draw(*fPLogV,attribs,trans);
}
auto visManager = G4VVisManager::GetConcreteInstance();
if (! visManager) return;
G4Transform3D trans(fRot.inverse(),fPos);
G4VisAttributes attribs;
auto pVA = fPLogV->GetVisAttributes();
if (pVA) attribs = *pVA;
G4Colour colour(0.,1.,1.);
attribs.SetColour(colour);
attribs.SetForceSolid(true);
visManager->Draw(*fPLogV,attribs,trans);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const std::map<G4String,G4AttDef>* B5HodoscopeHit::GetAttDefs() const
{
G4bool isNew;
std::map<G4String,G4AttDef>* store
= G4AttDefStore::GetInstance("B5HodoscopeHit",isNew);
G4bool isNew;
auto store = G4AttDefStore::GetInstance("B5HodoscopeHit",isNew);
if (isNew) {
(*store)["HitType"]
= G4AttDef("HitType","Hit Type","Physics","","G4String");
(*store)["ID"]
= G4AttDef("ID","ID","Physics","","G4int");
(*store)["Time"]
= G4AttDef("Time","Time","Physics","G4BestUnit","G4double");
(*store)["Pos"]
= G4AttDef("Pos","Position","Physics","G4BestUnit","G4ThreeVector");
(*store)["LVol"]
= G4AttDef("LVol","Logical Volume","Physics","","G4String");
}
return store;
if (isNew) {
(*store)["HitType"]
= G4AttDef("HitType","Hit Type","Physics","","G4String");
(*store)["ID"]
= G4AttDef("ID","ID","Physics","","G4int");
(*store)["Time"]
= G4AttDef("Time","Time","Physics","G4BestUnit","G4double");
(*store)["Pos"]
= G4AttDef("Pos","Position","Physics","G4BestUnit","G4ThreeVector");
(*store)["LVol"]
= G4AttDef("LVol","Logical Volume","Physics","","G4String");
}
return store;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
std::vector<G4AttValue>* B5HodoscopeHit::CreateAttValues() const
{
std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
values
->push_back(G4AttValue("HitType","HodoscopeHit",""));
values
->push_back(G4AttValue("ID",G4UIcommand::ConvertToString(fId),""));
values
->push_back(G4AttValue("Time",G4BestUnit(fTime,"Time"),""));
values
->push_back(G4AttValue("Pos",G4BestUnit(fPos,"Length"),""));
if (fPLogV)
values->push_back(G4AttValue("LVol",fPLogV->GetName(),""));
else
values->push_back(G4AttValue("LVol"," ",""));
return values;
auto values = new std::vector<G4AttValue>;
values
->push_back(G4AttValue("HitType","HodoscopeHit",""));
values
->push_back(G4AttValue("ID",G4UIcommand::ConvertToString(fId),""));
values
->push_back(G4AttValue("Time",G4BestUnit(fTime,"Time"),""));
values
->push_back(G4AttValue("Pos",G4BestUnit(fPos,"Length"),""));
if (fPLogV)
values->push_back(G4AttValue("LVol",fPLogV->GetName(),""));
else
values->push_back(G4AttValue("LVol"," ",""));
return values;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5HodoscopeHit::Print()
{
G4cout << " Hodoscope[" << fId << "] " << fTime/ns << " (nsec)" << G4endl;
G4cout << " Hodoscope[" << fId << "] " << fTime/ns << " (nsec)" << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+42 -47
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B5HodoscopeSD.cc 76474 2013-11-11 10:36:34Z gcosmo $
// $Id: B5HodoscopeSD.cc 101036 2016-11-04 09:00:23Z gcosmo $
//
/// \file B5HodoscopeSD.cc
/// \brief Implementation of the B5HodoscopeSD class
@@ -41,10 +41,10 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5HodoscopeSD::B5HodoscopeSD(G4String name)
: G4VSensitiveDetector(name), fHitsCollection(0), fHCID(-1)
: G4VSensitiveDetector(name),
fHitsCollection(nullptr), fHCID(-1)
{
G4String HCname = "hodoscopeColl";
collectionName.insert(HCname);
collectionName.insert( "hodoscopeColl");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -56,58 +56,53 @@ B5HodoscopeSD::~B5HodoscopeSD()
void B5HodoscopeSD::Initialize(G4HCofThisEvent* hce)
{
fHitsCollection = new B5HodoscopeHitsCollection
(SensitiveDetectorName,collectionName[0]);
if (fHCID<0)
{ fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection); }
hce->AddHitsCollection(fHCID,fHitsCollection);
fHitsCollection = new B5HodoscopeHitsCollection
(SensitiveDetectorName,collectionName[0]);
if (fHCID<0) {
fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection);
}
hce->AddHitsCollection(fHCID,fHitsCollection);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool B5HodoscopeSD::ProcessHits(G4Step* step, G4TouchableHistory*)
{
G4double edep = step->GetTotalEnergyDeposit();
if (edep==0.) return true;
G4StepPoint* preStepPoint = step->GetPreStepPoint();
G4TouchableHistory* touchable
= (G4TouchableHistory*)(preStepPoint->GetTouchable());
G4int copyNo = touchable->GetVolume()->GetCopyNo();
G4double hitTime = preStepPoint->GetGlobalTime();
// check if this finger already has a hit
G4int ix = -1;
for (G4int i=0;i<fHitsCollection->entries();i++)
{
if ((*fHitsCollection)[i]->GetID()==copyNo)
{
ix = i;
break;
}
auto edep = step->GetTotalEnergyDeposit();
if (edep==0.) return true;
auto preStepPoint = step->GetPreStepPoint();
auto touchable = preStepPoint->GetTouchable();
auto copyNo = touchable->GetVolume()->GetCopyNo();
auto hitTime = preStepPoint->GetGlobalTime();
// check if this finger already has a hit
auto ix = -1;
for (auto i=0;i<fHitsCollection->entries();i++) {
if ((*fHitsCollection)[i]->GetID()==copyNo) {
ix = i;
break;
}
}
if (ix>=0)
// if it has, then take the earlier time
{
if ((*fHitsCollection)[ix]->GetTime()>hitTime)
{ (*fHitsCollection)[ix]->SetTime(hitTime); }
if (ix>=0) {
// if it has, then take the earlier time
if ((*fHitsCollection)[ix]->GetTime()>hitTime) {
(*fHitsCollection)[ix]->SetTime(hitTime);
}
else
// if not, create a new hit and set it to the collection
{
B5HodoscopeHit* hit = new B5HodoscopeHit(copyNo,hitTime);
G4VPhysicalVolume* physical = touchable->GetVolume();
hit->SetLogV(physical->GetLogicalVolume());
G4AffineTransform transform
= touchable->GetHistory()->GetTopTransform();
transform.Invert();
hit->SetRot(transform.NetRotation());
hit->SetPos(transform.NetTranslation());
fHitsCollection->insert(hit);
}
return true;
}
else {
// if not, create a new hit and set it to the collection
auto hit = new B5HodoscopeHit(copyNo,hitTime);
auto physical = touchable->GetVolume();
hit->SetLogV(physical->GetLogicalVolume());
auto transform = touchable->GetHistory()->GetTopTransform();
transform.Invert();
hit->SetRot(transform.NetRotation());
hit->SetPos(transform.NetTranslation());
fHitsCollection->insert(hit);
}
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+20 -19
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B5MagneticField.cc 77656 2013-11-27 08:52:57Z gcosmo $
// $Id: B5MagneticField.cc 101036 2016-11-04 09:00:23Z gcosmo $
//
/// \file B5MagneticField.cc
/// \brief Implementation of the B5MagneticField class
@@ -37,42 +37,43 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5MagneticField::B5MagneticField()
: G4MagneticField(), fMessenger(0), fBy(1.0*tesla)
: G4MagneticField(),
fMessenger(nullptr), fBy(1.0*tesla)
{
// define commands for this class
DefineCommands();
// define commands for this class
DefineCommands();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5MagneticField::~B5MagneticField()
{
delete fMessenger;
delete fMessenger;
}
void B5MagneticField::GetFieldValue(const G4double [4],double *bField) const
{
bField[0] = 0.;
bField[1] = fBy;
bField[2] = 0.;
bField[0] = 0.;
bField[1] = fBy;
bField[2] = 0.;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5MagneticField::DefineCommands()
{
// Define /B5/field command directory using generic messenger class
fMessenger = new G4GenericMessenger(this,
"/B5/field/",
"Field control");
// Define /B5/field command directory using generic messenger class
fMessenger = new G4GenericMessenger(this,
"/B5/field/",
"Field control");
// fieldValue command
G4GenericMessenger::Command& valueCmd
= fMessenger->DeclareMethodWithUnit("value","tesla",
&B5MagneticField::SetField,
"Set field strength.");
valueCmd.SetParameterName("field", true);
valueCmd.SetDefaultValue("1.");
// fieldValue command
auto& valueCmd
= fMessenger->DeclareMethodWithUnit("value","tesla",
&B5MagneticField::SetField,
"Set field strength.");
valueCmd.SetParameterName("field", true);
valueCmd.SetDefaultValue("1.");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+100 -104
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B5PrimaryGeneratorAction.cc 77781 2013-11-28 07:54:07Z gcosmo $
// $Id: B5PrimaryGeneratorAction.cc 101036 2016-11-04 09:00:23Z gcosmo $
//
/// \file B5PrimaryGeneratorAction.cc
/// \brief Implementation of the B5PrimaryGeneratorAction class
@@ -42,134 +42,130 @@
B5PrimaryGeneratorAction::B5PrimaryGeneratorAction()
: G4VUserPrimaryGeneratorAction(),
fParticleGun(0), fMessenger(0),
fPositron(0), fMuon(0), fPion(0), fKaon(0), fProton(0),
fParticleGun(nullptr), fMessenger(nullptr),
fPositron(nullptr), fMuon(nullptr), fPion(nullptr),
fKaon(nullptr), fProton(nullptr),
fMomentum(1000.*MeV),
fSigmaMomentum(50.*MeV),
fSigmaAngle(2.*deg),
fRandomizePrimary(true)
{
G4int n_particle = 1;
fParticleGun = new G4ParticleGun(n_particle);
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String particleName;
fPositron = particleTable->FindParticle(particleName="e+");
fMuon = particleTable->FindParticle(particleName="mu+");
fPion = particleTable->FindParticle(particleName="pi+");
fKaon = particleTable->FindParticle(particleName="kaon+");
fProton = particleTable->FindParticle(particleName="proton");
// default particle kinematics
fParticleGun->SetParticlePosition(G4ThreeVector(0.,0.,-8.*m));
fParticleGun->SetParticleDefinition(fPositron);
// define commands for this class
DefineCommands();
G4int nofParticles = 1;
fParticleGun = new G4ParticleGun(nofParticles);
auto particleTable = G4ParticleTable::GetParticleTable();
fPositron = particleTable->FindParticle("e+");
fMuon = particleTable->FindParticle("mu+");
fPion = particleTable->FindParticle("pi+");
fKaon = particleTable->FindParticle("kaon+");
fProton = particleTable->FindParticle("proton");
// default particle kinematics
fParticleGun->SetParticlePosition(G4ThreeVector(0.,0.,-8.*m));
fParticleGun->SetParticleDefinition(fPositron);
// define commands for this class
DefineCommands();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B5PrimaryGeneratorAction::~B5PrimaryGeneratorAction()
{
delete fParticleGun;
delete fMessenger;
delete fParticleGun;
delete fMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5PrimaryGeneratorAction::GeneratePrimaries(G4Event* event)
{
G4ParticleDefinition* particle;
if (fRandomizePrimary)
{
G4int i = (int)(5.*G4UniformRand());
switch(i)
{
case 0:
particle = fPositron;
break;
case 1:
particle = fMuon;
break;
case 2:
particle = fPion;
break;
case 3:
particle = fKaon;
break;
default:
particle = fProton;
break;
}
fParticleGun->SetParticleDefinition(particle);
G4ParticleDefinition* particle;
if (fRandomizePrimary) {
G4int i = (int)(5.*G4UniformRand());
switch(i) {
case 0:
particle = fPositron;
break;
case 1:
particle = fMuon;
break;
case 2:
particle = fPion;
break;
case 3:
particle = fKaon;
break;
default:
particle = fProton;
break;
}
else
{
particle = fParticleGun->GetParticleDefinition();
}
G4double pp = fMomentum + (G4UniformRand()-0.5)*fSigmaMomentum;
G4double mass = particle->GetPDGMass();
G4double Ekin = std::sqrt(pp*pp+mass*mass)-mass;
fParticleGun->SetParticleEnergy(Ekin);
G4double angle = (G4UniformRand()-0.5)*fSigmaAngle;
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(std::sin(angle),0.,
std::cos(angle)));
fParticleGun->GeneratePrimaryVertex(event);
fParticleGun->SetParticleDefinition(particle);
}
else {
particle = fParticleGun->GetParticleDefinition();
}
auto pp = fMomentum + (G4UniformRand()-0.5)*fSigmaMomentum;
auto mass = particle->GetPDGMass();
auto ekin = std::sqrt(pp*pp+mass*mass)-mass;
fParticleGun->SetParticleEnergy(ekin);
auto angle = (G4UniformRand()-0.5)*fSigmaAngle;
fParticleGun->SetParticleMomentumDirection(
G4ThreeVector(std::sin(angle),0.,std::cos(angle)));
fParticleGun->GeneratePrimaryVertex(event);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B5PrimaryGeneratorAction::DefineCommands()
{
// Define /B5/generator command directory using generic messenger class
fMessenger
= new G4GenericMessenger(this,
"/B5/generator/",
"Primary generator control");
// momentum command
G4GenericMessenger::Command& momentumCmd
= fMessenger->DeclarePropertyWithUnit("momentum", "GeV", fMomentum,
"Mean momentum of primaries.");
momentumCmd.SetParameterName("p", true);
momentumCmd.SetRange("p>=0.");
momentumCmd.SetDefaultValue("1.");
// ok
//momentumCmd.SetParameterName("p", true);
//momentumCmd.SetRange("p>=0.");
// sigmaMomentum command
G4GenericMessenger::Command& sigmaMomentumCmd
= fMessenger->DeclarePropertyWithUnit("sigmaMomentum",
"MeV", fSigmaMomentum, "Sigma momentum of primaries.");
sigmaMomentumCmd.SetParameterName("sp", true);
sigmaMomentumCmd.SetRange("sp>=0.");
sigmaMomentumCmd.SetDefaultValue("50.");
// Define /B5/generator command directory using generic messenger class
fMessenger
= new G4GenericMessenger(this,
"/B5/generator/",
"Primary generator control");
// momentum command
auto& momentumCmd
= fMessenger->DeclarePropertyWithUnit("momentum", "GeV", fMomentum,
"Mean momentum of primaries.");
momentumCmd.SetParameterName("p", true);
momentumCmd.SetRange("p>=0.");
momentumCmd.SetDefaultValue("1.");
// ok
//momentumCmd.SetParameterName("p", true);
//momentumCmd.SetRange("p>=0.");
// sigmaMomentum command
auto& sigmaMomentumCmd
= fMessenger->DeclarePropertyWithUnit("sigmaMomentum",
"MeV", fSigmaMomentum, "Sigma momentum of primaries.");
sigmaMomentumCmd.SetParameterName("sp", true);
sigmaMomentumCmd.SetRange("sp>=0.");
sigmaMomentumCmd.SetDefaultValue("50.");
// sigmaAngle command
G4GenericMessenger::Command& sigmaAngleCmd
= fMessenger->DeclarePropertyWithUnit("sigmaAngle", "deg", fSigmaAngle,
"Sigma angle divergence of primaries.");
sigmaAngleCmd.SetParameterName("t", true);
sigmaAngleCmd.SetRange("t>=0.");
sigmaAngleCmd.SetDefaultValue("2.");
// sigmaAngle command
auto& sigmaAngleCmd
= fMessenger->DeclarePropertyWithUnit("sigmaAngle", "deg", fSigmaAngle,
"Sigma angle divergence of primaries.");
sigmaAngleCmd.SetParameterName("t", true);
sigmaAngleCmd.SetRange("t>=0.");
sigmaAngleCmd.SetDefaultValue("2.");
// randomizePrimary command
G4GenericMessenger::Command& randomCmd
= fMessenger->DeclareProperty("randomizePrimary", fRandomizePrimary);
G4String guidance
= "Boolean flag for randomizing primary particle types.\n";
guidance
+= "In case this flag is false, you can select the primary particle\n";
guidance += " with /gun/particle command.";
randomCmd.SetGuidance(guidance);
randomCmd.SetParameterName("flg", true);
randomCmd.SetDefaultValue("true");
// randomizePrimary command
auto& randomCmd
= fMessenger->DeclareProperty("randomizePrimary", fRandomizePrimary);
G4String guidance
= "Boolean flag for randomizing primary particle types.\n";
guidance
+= "In case this flag is false, you can select the primary particle\n";
guidance += " with /gun/particle command.";
randomCmd.SetGuidance(guidance);
randomCmd.SetParameterName("flg", true);
randomCmd.SetDefaultValue("true");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//..oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+5 -3
View File
@@ -45,10 +45,12 @@ B5RunAction::B5RunAction(B5EventAction* eventAction)
// Create analysis manager
// The choice of analysis technology is done via selectin of a namespace
// in B5Analysis.hh
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
auto analysisManager = G4AnalysisManager::Instance();
G4cout << "Using " << analysisManager->GetType() << G4endl;
// Default settings
analysisManager->SetNtupleMerging(true);
// Note: merging ntuples is available only with Root output
analysisManager->SetVerboseLevel(1);
analysisManager->SetFileName("B5");
@@ -102,7 +104,7 @@ void B5RunAction::BeginOfRunAction(const G4Run* /*run*/)
//G4RunManager::GetRunManager()->SetRandomNumberStore(true);
// Get analysis manager
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
auto analysisManager = G4AnalysisManager::Instance();
// Open an output file
// The default file name is set in B5RunAction::B5RunAction(),
@@ -116,7 +118,7 @@ void B5RunAction::EndOfRunAction(const G4Run* /*run*/)
{
// save histograms & ntuple
//
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
auto analysisManager = G4AnalysisManager::Instance();
analysisManager->Write();
analysisManager->CloseFile();