Import Geant4 11.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2024-12-06 11:11:40 +01:00
parent e58e650b32
commit 32390e802b
1984 changed files with 98713 additions and 83996 deletions
@@ -70,12 +70,15 @@ const G4int kMaxBin = 500;
ExGflashDetectorConstruction::ExGflashDetectorConstruction()
{
G4cout << "ExGflashDetectorConstruction::Detector constructor" << G4endl;
if (fVerbose > 3) G4cout << "ExGflashDetectorConstruction::Detector constructor" << G4endl;
fGflashMessenger = new ExGflashMessenger(this);
// Crystall
fCrystalWidth = 3 * cm;
fCrystalLength = 24 * cm;
fCrystalLength = 140 * cm;
DefineMaterials();
SetMaterial("G4_PbWO4");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -91,25 +94,28 @@ ExGflashDetectorConstruction::~ExGflashDetectorConstruction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* ExGflashDetectorConstruction::Construct()
void ExGflashDetectorConstruction::DefineMaterials()
{
//--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
G4cout << "Defining the materials" << G4endl;
if (fVerbose > 3) G4cout << "Defining the materials" << G4endl;
// Get nist material manager
G4NistManager* nistManager = G4NistManager::Instance();
// Build materials
G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
G4Material* pbWO4 = nistManager->FindOrBuildMaterial("G4_PbWO4");
fHallMat = nistManager->FindOrBuildMaterial("G4_AIR");
fDetMat = nistManager->FindOrBuildMaterial("G4_PbWO4");
nistManager->FindOrBuildMaterial("G4_CESIUM_IODIDE");
}
fDetMat = pbWO4;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* ExGflashDetectorConstruction::Construct()
{
//--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
//------------------------------
// Calorimeter segments
//------------------------------
// Simplified `CMS-like` PbWO4 crystal calorimeter
// Simplified `CMS-like` PbWO4 crystal calorimeter
// Calorimeter
G4double calo_xside = (fCrystalWidth * fNbOfCrystals);
G4double calo_yside = (fCrystalWidth * fNbOfCrystals);
@@ -125,7 +131,7 @@ G4VPhysicalVolume* ExGflashDetectorConstruction::Construct()
experimentalHall_y, // y size
experimentalHall_z); // z size
auto experimentalHall_log = new G4LogicalVolume(experimentalHall_box, air, "expHall_log",
auto experimentalHall_log = new G4LogicalVolume(experimentalHall_box, fHallMat, "expHall_log",
nullptr, // opt: fieldManager
nullptr, // opt: SensitiveDetector
nullptr); // opt: UserLimits
@@ -138,7 +144,7 @@ G4VPhysicalVolume* ExGflashDetectorConstruction::Construct()
calo_xside / 2., // size
calo_yside / 2., calo_zside / 2.);
auto calo_log = new G4LogicalVolume(calo_box, // its solid
air, // its material
fHallMat, // its material
"calo_log", // its name
nullptr, // opt: fieldManager
nullptr, // opt: SensitiveDetector
@@ -173,11 +179,11 @@ G4VPhysicalVolume* ExGflashDetectorConstruction::Construct()
}
G4cout << "There are " << fNbOfCrystals << " crystals per row in the calorimeter, so in total "
<< fNbOfCrystals * fNbOfCrystals << " crystals" << G4endl;
G4cout << "Total Calorimeter size" << calo_xside / cm << " cm x " << calo_yside / cm << " cm x "
<< calo_zside / cm << " cm" << G4endl;
G4cout << "They have width of " << fCrystalWidth / cm << " cm and a length of "
<< fCrystalLength / cm << " cm. The Material is " << fDetMat
<< " Total: " << fCrystalLength / fDetMat->GetRadlen() << " X0" << G4endl;
<< fCrystalLength / cm << " cm." << G4endl;
G4cout << fDetMat << G4endl;
G4cout << "Total Calorimeter size " << calo_xside / cm << " cm x " << calo_yside / cm << " cm x "
<< calo_zside / cm << " cm" << G4endl;
experimentalHall_log->SetVisAttributes(G4VisAttributes::GetInvisible());
auto caloVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
@@ -186,7 +192,7 @@ G4VPhysicalVolume* ExGflashDetectorConstruction::Construct()
fCrystal_log->SetVisAttributes(crystalVisAtt);
// define the fParameterisation region
G4cout << "\n ---> DetectorConstruction Region Definition" << G4endl;
// G4cout << "\n ---> DetectorConstruction Region Definition" << G4endl;
fRegion = new G4Region("crystals");
calo_log->SetRegion(fRegion);
fRegion->AddRootLogicalVolume(calo_log);
@@ -198,35 +204,52 @@ G4VPhysicalVolume* ExGflashDetectorConstruction::Construct()
void ExGflashDetectorConstruction::ConstructSDandField()
{
// -- sensitive detectors:
G4SDManager* SDman = G4SDManager::GetSDMpointer();
auto SD = new ExGflashSensitiveDetector("Calorimeter", this);
SDman->AddNewDetector(SD);
if (fCrystal_log != nullptr) {
fCrystal_log->SetSensitiveDetector(SD);
}
// -- fast simulation models:
// **********************************************
// * Initializing shower modell
// ***********************************************
G4cout << "\n--> Creating shower parameterization models" << G4endl;
fFastShowerModel = new GFlashShowerModel("fFastShowerModel", fRegion);
fParameterisation = new GFlashHomoShowerParameterisation(fDetMat, new ExGflashHomoShowerTuning());
fFastShowerModel->SetParameterisation(*fParameterisation);
// Energy Cuts to kill particles:
fParticleBounds = new GFlashParticleBounds();
fFastShowerModel->SetParticleBounds(*fParticleBounds);
// Makes the EnergieSpots
fHitMaker = new GFlashHitMaker();
fFastShowerModel->SetHitMaker(*fHitMaker);
G4cout << "end shower parameterization." << G4endl;
if (fParameterisation != nullptr) {
fParameterisation->SetMaterial(fDetMat);
if (fVerbose > 3) G4cout << "Info " << __func__ << " Param Mat " << fDetMat << G4endl;
fParameterisation->PrintMaterial(fDetMat);
}
else {
// -- sensitive detectors:
G4SDManager* SDman = G4SDManager::GetSDMpointer();
auto SD = new ExGflashSensitiveDetector("Calorimeter", this);
SDman->AddNewDetector(SD);
if (fCrystal_log != nullptr) {
fCrystal_log->SetSensitiveDetector(SD);
}
if (fVerbose > 3) G4cout << "\n--> Creating shower parameterization models" << G4endl;
fFastShowerModel = new GFlashShowerModel("fFastShowerModel", fRegion);
fParameterisation =
new GFlashHomoShowerParameterisation(fDetMat, new ExGflashHomoShowerTuning());
fFastShowerModel->SetParameterisation(*fParameterisation);
// Energy Cuts to kill particles:
fParticleBounds = new GFlashParticleBounds();
fFastShowerModel->SetParticleBounds(*fParticleBounds);
// Makes the EnergieSpots
fHitMaker = new GFlashHitMaker();
fFastShowerModel->SetHitMaker(*fHitMaker);
if (fVerbose > 3) G4cout << "end shower parameterization." << G4endl;
}
// **********************************************
// Get Rad Len and R molere ?
fSDRadLen = fDetMat->GetRadlen();
// Get Rad Len and R moliere from parameterisation
fSDRadLen = fParameterisation->GetX0();
fSDRm = fParameterisation->GetRm();
if (fVerbose > 2) {
G4cout << "Info " << __func__ << "Total Calorimeter size" << G4endl;
auto calo_xyside = fCrystalWidth * fNbOfCrystals;
G4cout << "Info Z " << __func__ << " " << fCrystalLength / cm << " cm "
<< fCrystalLength / fSDRadLen << " RadLen " << G4endl;
G4cout << "Info XY " << __func__ << " " << calo_xyside / cm << " cm " << calo_xyside / fSDRm
<< " Rm " << G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -267,12 +290,6 @@ void ExGflashDetectorConstruction::SetMaterial(G4String mat)
if (fCrystal_log != nullptr) {
fCrystal_log->SetMaterial(fDetMat);
}
if (fParameterisation != nullptr) {
fParameterisation->SetMaterial(fDetMat);
fParameterisation->PrintMaterial(fDetMat);
// Get Rad Len and R molere ?
fSDRadLen = fDetMat->GetRadlen();
}
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
}
}
@@ -83,8 +83,7 @@ void ExGflashEventAction::EndOfEventAction(const G4Event* evt)
if (THC != nullptr) {
/// Hits in sensitive Detector
int n_hit = THC->entries();
// G4cout<<" " << n_hit<< " hits are stored in ExGflashHitsCollection
// "<<G4endl;
G4PrimaryVertex* pvertex = evt->GetPrimaryVertex();
// Computing (x,y,z) of vertex of initial particles
G4ThreeVector vtx = pvertex->GetPosition();
@@ -101,7 +100,9 @@ void ExGflashEventAction::EndOfEventAction(const G4Event* evt)
G4double dLradl = fDet->GetdLradl();
G4double dRradl = fDet->GetdRradl();
G4double SDRadl = fDet->GetSDRadLen(); // SD matrial
G4double SDRadl = fDet->GetSDRadLen(); // SD matrial rad len
G4double SDRm = fDet->GetSDRm(); // SD Radius Moliere
// init to to 0.0
MyVector dEdL(nLbin, 0.0);
MyVector dEdR(nRbin, 0.0);
@@ -128,10 +129,12 @@ void ExGflashEventAction::EndOfEventAction(const G4Event* evt)
G4ThreeVector radial = l - longitudinal;
auto SlideNb = G4int((longitudinal.mag() / SDRadl) / dLradl);
auto RingNb = G4int((radial.mag() / SDRadl) / dRradl);
auto RingNb = G4int((radial.mag() / SDRm) / dRradl);
if (SlideNb >= 0 && SlideNb < nLbin) dEdL[SlideNb] += estep;
if (RingNb >= 0 && RingNb < nLbin) dEdR[RingNb] += estep;
if ((SlideNb >= 0 && SlideNb < nLbin) && (RingNb >= 0 && RingNb < nRbin)) {
dEdL[SlideNb] += estep;
dEdR[RingNb] += estep;
}
}
}
@@ -61,25 +61,18 @@ void ExGflashHistoManager::Book()
//
// Creating histograms
//
// const G4int kMaxHisto = 9;
// const G4int kMaxProf = 2;
G4int nLbin = fDet->GetnLtot();
G4int nRbin = fDet->GetnRtot();
G4double dLradl = fDet->GetdLradl();
G4double dRradl = fDet->GetdRradl();
fVerbose = fDet->GetVerbose();
fAnalysisManager->CreateH1("h0", "total energy deposit(percent of Einc)", 100, 95., 105.);
fAnalysisManager->CreateH1("h0", "total energy deposit(percent of Einc)", 100, 85., 105.);
fAnalysisManager->CreateH1("h1", "The number of Hits per event", 200, 0., 4.0e5);
fAnalysisManager->CreateH1("h2", "The energy of Hit (in MeV)", 200, 0., 10.);
// fAnalysisManager->CreateH1( "h3","longit energy profile (% of E inc)",
// nLbin,0.,nLbin*dLradl);
// fAnalysisManager->CreateH1( "h4","radial energy profile (% of E inc)",
// nRbin,0.,nRbin*dRradl);
fAnalysisManager->CreateP1("p0", "longit energy profile (% of E inc)", nLbin, 0., nLbin * dLradl,
0., 2000.);
@@ -92,12 +85,24 @@ void ExGflashHistoManager::Book()
fAnalysisManager->CreateP1("p3", "Cuml radial energy profile (% of E inc)", nRbin, 0.,
nRbin * dRradl, 0., 20000.);
// Create all histograms as inactivated
// for (G4int k=0; k<kMaxHisto; k++) {
// fAnalysisManager->SetH1Activation(k, false);
// }
// for (G4int k=0; k<kMaxProf; k++) {
// fAnalysisManager->SetP1Activation(k, false);
// }
G4cout << "\n----> Histogram file " << fFileName << G4endl;
if (fVerbose > 1) G4cout << "\n----> Histogram file " << fFileName << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExGflashHistoManager::SetBinning()
{
G4int nLbin = fDet->GetnLtot();
G4int nRbin = fDet->GetnRtot();
G4double dLradl = fDet->GetdLradl();
G4double dRradl = fDet->GetdRradl();
// Get analysis manager
auto analysisManager = G4AnalysisManager::Instance();
// Redifine profiles
analysisManager->SetP1(0, nLbin, 0., nLbin * dLradl, 0., 2000.);
analysisManager->SetP1(1, nRbin, 0., nRbin * dRradl, 0., 2000.);
analysisManager->SetP1(2, nLbin, 0., nLbin * dLradl, 0., 2000.);
analysisManager->SetP1(3, nRbin, 0., nRbin * dRradl, 0., 2000.);
}
@@ -60,12 +60,6 @@ ExGflashHit::ExGflashHit(const ExGflashHit& right) : G4VHit(right)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflashHit& ExGflashHit::operator=(const ExGflashHit& right) = default;
// {
// G4VHit::operator=(right);
// fEdep = right.fEdep;
// fPos = right.fPos;
// return *this;
// }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -50,7 +50,7 @@ ExGflashMessenger::ExGflashMessenger(ExGflashDetectorConstruction* Det) : fDetec
fVerbose = new G4UIcmdWithAnInteger("/exgflash/verbose", this);
fVerbose->SetGuidance("set exglash verbosity");
fVerbose->SetGuidance("0- silent, 1 - on exit, 2 - run , 3 - event");
fVerbose->SetGuidance("0- silent, 1 - init, 2 - run, 3 - event");
fVerbose->SetParameterName("ver", false);
fVerbose->SetRange("ver >= 0");
fVerbose->AvailableForStates(G4State_PreInit, G4State_Idle);
@@ -59,37 +59,73 @@ ExGflashMessenger::ExGflashMessenger(ExGflashDetectorConstruction* Det) : fDetec
fDetDir = new G4UIdirectory("/exgflash/det/");
fDetDir->SetGuidance("detector construction commands");
fMaterCmd = new G4UIcmdWithAString("/exgflash/det/setMat", this);
fMaterCmd->SetGuidance("Select Material.");
fMaterCmd->SetParameterName("material", false);
fMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fMaterCmd->SetToBeBroadcasted(false);
fLBinCmd = new G4UIcmdWith3Vector("/exgflash/det/setLbin", this);
fLBinCmd->SetGuidance("set longitudinal bining");
fLBinCmd->SetGuidance("nb of bins; bin thickness (in radl)");
// must have omitable==true we use 2 values only
fLBinCmd->SetParameterName("nLtot", "dLradl", " ", true);
fLBinCmd->SetGuidance("nLtot - nb of bins; bin thickness (in Radl)");
fLBinCmd->SetGuidance("dLradl - bin thickness (in fraction of Radl)");
fLBinCmd->SetGuidance("LStart - dummy");
fLBinCmd->SetParameterName("nLtot", "dLradl", "LStart", true);
fLBinCmd->SetDefaultValue(G4ThreeVector{100.0, 0.25, 0.0});
fLBinCmd->SetRange("nLtot>=1 && dLradl>0");
fLBinCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fLBinCmd->SetToBeBroadcasted(false);
fRBinCmd = new G4UIcmdWith3Vector("/exgflash/det/setRbin", this);
fRBinCmd->SetGuidance("set radial bining");
fRBinCmd->SetGuidance("nb of bins; bin thickness (in radl)");
fRBinCmd->SetParameterName("nRtot", "dRradl", " ", true);
fRBinCmd->SetGuidance("nRtot - nb of bins; bin thickness (in Rm)");
fRBinCmd->SetGuidance("dRradl - bin thickness (in fraction of Rm)");
fRBinCmd->SetGuidance("RStart - dummy");
fRBinCmd->SetParameterName("nRtot", "dRradl", "RStart", true);
fRBinCmd->SetDefaultValue(G4ThreeVector{80.0, 0.05, 0.0});
fRBinCmd->SetRange("nRtot>=1 && dRradl>0");
fRBinCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fRBinCmd->SetToBeBroadcasted(false);
fMaterCmd = new G4UIcmdWithAString("/exgflash/det/setMat", this);
fMaterCmd->SetGuidance("Select Material.");
fMaterCmd->SetParameterName("material", false);
fMaterCmd->AvailableForStates(G4State_PreInit);
fMaterCmd->SetToBeBroadcasted(false);
fNbCrysCmd = new G4UIcmdWithAnInteger("/exgflash/det/setNbCrys", this);
fNbCrysCmd->SetGuidance("set numbber of crystals in row/col");
fNbCrysCmd->SetGuidance("ncrys - number of crystals ");
fNbCrysCmd->SetParameterName("ncrys", false);
fNbCrysCmd->SetRange("ncrys > 0");
fNbCrysCmd->AvailableForStates(G4State_PreInit);
fNbCrysCmd->SetToBeBroadcasted(false);
fWCrysCmd = new G4UIcmdWithADoubleAndUnit("/exgflash/det/setCrysWidth", this);
fWCrysCmd->SetGuidance("set crystal width (cm)");
fWCrysCmd->SetGuidance("wcrys - width of crystal ");
fWCrysCmd->SetParameterName("wcrys", false);
fWCrysCmd->SetRange("wcrys > 0");
fWCrysCmd->SetUnitCategory("Length");
fWCrysCmd->SetDefaultUnit("cm");
fWCrysCmd->AvailableForStates(G4State_PreInit);
fWCrysCmd->SetToBeBroadcasted(false);
fLCrysCmd = new G4UIcmdWithADoubleAndUnit("/exgflash/det/setCrysLength", this);
fLCrysCmd->SetGuidance("set crystal length (cm)");
fLCrysCmd->SetGuidance("lcrys - crystal length ");
fLCrysCmd->SetParameterName("lcrys", false);
fLCrysCmd->SetRange("lcrys > 0");
fLCrysCmd->SetUnitCategory("Length");
fLCrysCmd->SetDefaultUnit("cm");
fLCrysCmd->AvailableForStates(G4State_PreInit);
fLCrysCmd->SetToBeBroadcasted(false);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflashMessenger::~ExGflashMessenger()
{
delete fLCrysCmd;
delete fWCrysCmd;
delete fNbCrysCmd;
delete fMaterCmd;
delete fRBinCmd;
delete fLBinCmd;
delete fMaterCmd;
delete fDetDir;
delete fVerbose;
delete fExGflashDir;
@@ -103,6 +139,18 @@ void ExGflashMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
fDetector->SetMaterial(newValue);
}
if (command == fNbCrysCmd) {
fDetector->SetNbOfCrystals(fNbCrysCmd->GetNewIntValue(newValue));
}
if (command == fWCrysCmd) {
fDetector->SetCrystalWidth(fWCrysCmd->GetNewDoubleValue(newValue));
}
if (command == fLCrysCmd) {
fDetector->SetCrystalLength(fLCrysCmd->GetNewDoubleValue(newValue));
}
if (command == fVerbose) {
fDetector->SetVerbose(fVerbose->GetNewIntValue(newValue));
}
@@ -28,14 +28,22 @@
//
#include "ExGflashPrimaryGeneratorAction.hh"
#include "G4Electron.hh"
#include "G4Event.hh"
#include "G4GeneralParticleSource.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflashPrimaryGeneratorAction::ExGflashPrimaryGeneratorAction()
{
fParticleGun = new G4GeneralParticleSource;
// fParticleGun->SetVerbosity(2);
auto cursrc = fParticleGun->GetCurrentSource();
cursrc->SetParticleDefinition(G4Electron::Definition());
cursrc->GetAngDist()->SetParticleMomentumDirection(G4ParticleMomentum(0., 0., 1.));
cursrc->GetEneDist()->SetMonoEnergy(50.0 * GeV);
// fParticleGun->ListSource();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -54,6 +54,7 @@ void ExGflashRunAction::BeginOfRunAction(const G4Run* aRun)
// histograms file
G4AnalysisManager* analysis = G4AnalysisManager::Instance();
if (analysis->IsActive()) {
fHistoManager->SetBinning();
analysis->OpenFile();
}
@@ -101,7 +101,6 @@ G4bool ExGflashSensitiveDetector::ProcessHits(G4GFlashSpot* aSpot, G4TouchableHi
caloHit->SetEdep(e);
caloHit->SetPos(aSpot->GetEnergySpot()->GetPosition());
fCaloHitsCollection->insert(caloHit);
// if (ROhist){;}
return true;
}