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
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B4PrimaryGeneratorAction.cc 75215 2013-10-29 16:07:06Z gcosmo $
// $Id: B4PrimaryGeneratorAction.cc 100946 2016-11-03 11:28:08Z gcosmo $
//
/// \file B4PrimaryGeneratorAction.cc
/// \brief Implementation of the B4PrimaryGeneratorAction class
@@ -45,14 +45,14 @@
B4PrimaryGeneratorAction::B4PrimaryGeneratorAction()
: G4VUserPrimaryGeneratorAction(),
fParticleGun(0)
fParticleGun(nullptr)
{
G4int nofParticles = 1;
fParticleGun = new G4ParticleGun(nofParticles);
// default particle kinematic
//
G4ParticleDefinition* particleDefinition
auto particleDefinition
= G4ParticleTable::GetParticleTable()->FindParticle("e-");
fParticleGun->SetParticleDefinition(particleDefinition);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
@@ -73,20 +73,24 @@ void B4PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
// This function is called at the begining of event
// In order to avoid dependence of PrimaryGeneratorAction
// on DetectorConstruction class we get world volume
// on DetectorConstruction class we get world volume
// from G4LogicalVolumeStore
//
G4double worldZHalfLength = 0;
G4LogicalVolume* worlLV
= G4LogicalVolumeStore::GetInstance()->GetVolume("World");
G4Box* worldBox = 0;
if ( worlLV) worldBox = dynamic_cast< G4Box*>(worlLV->GetSolid());
G4double worldZHalfLength = 0.;
auto worldLV = G4LogicalVolumeStore::GetInstance()->GetVolume("World");
// Check that the world volume has box shape
G4Box* worldBox = nullptr;
if ( worldLV ) {
worldBox = dynamic_cast<G4Box*>(worldLV->GetSolid());
}
if ( worldBox ) {
worldZHalfLength = worldBox->GetZHalfLength();
}
else {
G4ExceptionDescription msg;
msg << "World volume of box not found." << G4endl;
msg << "World volume of box shape not found." << G4endl;
msg << "Perhaps you have changed geometry." << G4endl;
msg << "The gun will be place in the center.";
G4Exception("B4PrimaryGeneratorAction::GeneratePrimaries()",
+20 -20
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B4RunAction.cc 87359 2014-12-01 16:04:27Z gcosmo $
// $Id: B4RunAction.cc 100946 2016-11-03 11:28:08Z gcosmo $
//
/// \file B4RunAction.cc
/// \brief Implementation of the B4RunAction class
@@ -47,23 +47,24 @@ B4RunAction::B4RunAction()
// Create analysis manager
// The choice of analysis technology is done via selectin of a namespace
// in B4Analysis.hh
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
auto analysisManager = G4AnalysisManager::Instance();
G4cout << "Using " << analysisManager->GetType() << G4endl;
// Create directories
//analysisManager->SetHistoDirectoryName("histograms");
//analysisManager->SetNtupleDirectoryName("ntuple");
analysisManager->SetVerboseLevel(1);
analysisManager->SetFirstHistoId(1);
analysisManager->SetNtupleMerging(true);
// Note: merging ntuples is available only with Root output
// Book histograms, ntuple
//
// Creating histograms
analysisManager->CreateH1("1","Edep in absorber", 100, 0., 800*MeV);
analysisManager->CreateH1("2","Edep in gap", 100, 0., 100*MeV);
analysisManager->CreateH1("3","trackL in absorber", 100, 0., 1*m);
analysisManager->CreateH1("4","trackL in gap", 100, 0., 50*cm);
analysisManager->CreateH1("Eabs","Edep in absorber", 100, 0., 800*MeV);
analysisManager->CreateH1("Egap","Edep in gap", 100, 0., 100*MeV);
analysisManager->CreateH1("Labs","trackL in absorber", 100, 0., 1*m);
analysisManager->CreateH1("Lgap","trackL in gap", 100, 0., 50*cm);
// Creating ntuple
//
@@ -90,7 +91,7 @@ void B4RunAction::BeginOfRunAction(const G4Run* /*run*/)
//G4RunManager::GetRunManager()->SetRandomNumberStore(true);
// Get analysis manager
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
auto analysisManager = G4AnalysisManager::Instance();
// Open an output file
//
@@ -104,7 +105,7 @@ void B4RunAction::EndOfRunAction(const G4Run* /*run*/)
{
// print histogram statistics
//
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
auto analysisManager = G4AnalysisManager::Instance();
if ( analysisManager->GetH1(1) ) {
G4cout << G4endl << " ----> print histograms statistic ";
if(isMaster) {
@@ -115,31 +116,30 @@ void B4RunAction::EndOfRunAction(const G4Run* /*run*/)
}
G4cout << " EAbs : mean = "
<< G4BestUnit(analysisManager->GetH1(0)->mean(), "Energy")
<< " rms = "
<< G4BestUnit(analysisManager->GetH1(0)->rms(), "Energy") << G4endl;
G4cout << " EGap : mean = "
<< G4BestUnit(analysisManager->GetH1(1)->mean(), "Energy")
<< " rms = "
<< G4BestUnit(analysisManager->GetH1(1)->rms(), "Energy") << G4endl;
G4cout << " EGap : mean = "
<< G4BestUnit(analysisManager->GetH1(2)->mean(), "Energy")
<< " rms = "
<< G4BestUnit(analysisManager->GetH1(2)->rms(), "Energy") << G4endl;
G4cout << " LAbs : mean = "
<< G4BestUnit(analysisManager->GetH1(2)->mean(), "Length")
<< " rms = "
<< G4BestUnit(analysisManager->GetH1(2)->rms(), "Length") << G4endl;
G4cout << " LGap : mean = "
<< G4BestUnit(analysisManager->GetH1(3)->mean(), "Length")
<< " rms = "
<< G4BestUnit(analysisManager->GetH1(3)->rms(), "Length") << G4endl;
G4cout << " LGap : mean = "
<< G4BestUnit(analysisManager->GetH1(4)->mean(), "Length")
<< " rms = "
<< G4BestUnit(analysisManager->GetH1(4)->rms(), "Length") << G4endl;
}
// save histograms & ntuple
//
analysisManager->Write();
analysisManager->CloseFile();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+9 -10
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B4cCalorimeterSD.cc 87359 2014-12-01 16:04:27Z gcosmo $
// $Id: B4cCalorimeterSD.cc 100946 2016-11-03 11:28:08Z gcosmo $
//
/// \file B4cCalorimeterSD.cc
/// \brief Implementation of the B4cCalorimeterSD class
@@ -42,7 +42,7 @@ B4cCalorimeterSD::B4cCalorimeterSD(
const G4String& hitsCollectionName,
G4int nofCells)
: G4VSensitiveDetector(name),
fHitsCollection(0),
fHitsCollection(nullptr),
fNofCells(nofCells)
{
collectionName.insert(hitsCollectionName);
@@ -63,7 +63,7 @@ void B4cCalorimeterSD::Initialize(G4HCofThisEvent* hce)
= new B4cCalorHitsCollection(SensitiveDetectorName, collectionName[0]);
// Add this collection in hce
G4int hcID
auto hcID
= G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
hce->AddHitsCollection( hcID, fHitsCollection );
@@ -80,7 +80,7 @@ G4bool B4cCalorimeterSD::ProcessHits(G4Step* step,
G4TouchableHistory*)
{
// energy deposit
G4double edep = step->GetTotalEnergyDeposit();
auto edep = step->GetTotalEnergyDeposit();
// step length
G4double stepLength = 0.;
@@ -90,14 +90,13 @@ G4bool B4cCalorimeterSD::ProcessHits(G4Step* step,
if ( edep==0. && stepLength == 0. ) return false;
G4TouchableHistory* touchable
= (G4TouchableHistory*)(step->GetPreStepPoint()->GetTouchable());
auto touchable = (step->GetPreStepPoint()->GetTouchable());
// Get calorimeter cell id
G4int layerNumber = touchable->GetReplicaNumber(1);
auto layerNumber = touchable->GetReplicaNumber(1);
// Get hit accounting data for this cell
B4cCalorHit* hit = (*fHitsCollection)[layerNumber];
auto hit = (*fHitsCollection)[layerNumber];
if ( ! hit ) {
G4ExceptionDescription msg;
msg << "Cannot access hit " << layerNumber;
@@ -106,7 +105,7 @@ G4bool B4cCalorimeterSD::ProcessHits(G4Step* step,
}
// Get hit for total accounting
B4cCalorHit* hitTotal
auto hitTotal
= (*fHitsCollection)[fHitsCollection->entries()-1];
// Add values
@@ -121,7 +120,7 @@ G4bool B4cCalorimeterSD::ProcessHits(G4Step* step,
void B4cCalorimeterSD::EndOfEvent(G4HCofThisEvent*)
{
if ( verboseLevel>1 ) {
G4int nofHits = fHitsCollection->entries();
auto nofHits = fHitsCollection->entries();
G4cout
<< G4endl
<< "-------->Hits Collection: in this event they are " << nofHits
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B4cDetectorConstruction.cc 87359 2014-12-01 16:04:27Z gcosmo $
// $Id: B4cDetectorConstruction.cc 101905 2016-12-07 11:34:39Z gunter $
//
/// \file B4cDetectorConstruction.cc
/// \brief Implementation of the B4cDetectorConstruction class
@@ -84,7 +84,7 @@ G4VPhysicalVolume* B4cDetectorConstruction::Construct()
void B4cDetectorConstruction::DefineMaterials()
{
// Lead material defined using NIST Manager
G4NistManager* nistManager = G4NistManager::Instance();
auto nistManager = G4NistManager::Instance();
nistManager->FindOrBuildMaterial("G4_Pb");
// Liquid argon material
@@ -112,15 +112,15 @@ G4VPhysicalVolume* B4cDetectorConstruction::DefineVolumes()
G4double gapThickness = 5.*mm;
G4double calorSizeXY = 10.*cm;
G4double layerThickness = absoThickness + gapThickness;
G4double calorThickness = fNofLayers * layerThickness;
G4double worldSizeXY = 1.2 * calorSizeXY;
G4double worldSizeZ = 1.2 * calorThickness;
auto layerThickness = absoThickness + gapThickness;
auto calorThickness = fNofLayers * layerThickness;
auto worldSizeXY = 1.2 * calorSizeXY;
auto worldSizeZ = 1.2 * calorThickness;
// Get materials
G4Material* defaultMaterial = G4Material::GetMaterial("Galactic");
G4Material* absorberMaterial = G4Material::GetMaterial("G4_Pb");
G4Material* gapMaterial = G4Material::GetMaterial("liquidArgon");
auto defaultMaterial = G4Material::GetMaterial("Galactic");
auto absorberMaterial = G4Material::GetMaterial("G4_Pb");
auto gapMaterial = G4Material::GetMaterial("liquidArgon");
if ( ! defaultMaterial || ! absorberMaterial || ! gapMaterial ) {
G4ExceptionDescription msg;
@@ -132,17 +132,17 @@ G4VPhysicalVolume* B4cDetectorConstruction::DefineVolumes()
//
// World
//
G4VSolid* worldS
auto worldS
= new G4Box("World", // its name
worldSizeXY/2, worldSizeXY/2, worldSizeZ/2); // its size
G4LogicalVolume* worldLV
auto worldLV
= new G4LogicalVolume(
worldS, // its solid
defaultMaterial, // its material
"World"); // its name
G4VPhysicalVolume* worldPV
auto worldPV
= new G4PVPlacement(
0, // no rotation
G4ThreeVector(), // at (0,0,0)
@@ -156,11 +156,11 @@ G4VPhysicalVolume* B4cDetectorConstruction::DefineVolumes()
//
// Calorimeter
//
G4VSolid* calorimeterS
auto calorimeterS
= new G4Box("Calorimeter", // its name
calorSizeXY/2, calorSizeXY/2, calorThickness/2); // its size
G4LogicalVolume* calorLV
auto calorLV
= new G4LogicalVolume(
calorimeterS, // its solid
defaultMaterial, // its material
@@ -179,11 +179,11 @@ G4VPhysicalVolume* B4cDetectorConstruction::DefineVolumes()
//
// Layer
//
G4VSolid* layerS
auto layerS
= new G4Box("Layer", // its name
calorSizeXY/2, calorSizeXY/2, layerThickness/2); //its size
G4LogicalVolume* layerLV
auto layerLV
= new G4LogicalVolume(
layerS, // its solid
defaultMaterial, // its material
@@ -200,11 +200,11 @@ G4VPhysicalVolume* B4cDetectorConstruction::DefineVolumes()
//
// Absorber
//
G4VSolid* absorberS
auto absorberS
= new G4Box("Abso", // its name
calorSizeXY/2, calorSizeXY/2, absoThickness/2); // its size
G4LogicalVolume* absorberLV
auto absorberLV
= new G4LogicalVolume(
absorberS, // its solid
absorberMaterial, // its material
@@ -223,11 +223,11 @@ G4VPhysicalVolume* B4cDetectorConstruction::DefineVolumes()
//
// Gap
//
G4VSolid* gapS
auto gapS
= new G4Box("Gap", // its name
calorSizeXY/2, calorSizeXY/2, gapThickness/2); // its size
G4LogicalVolume* gapLV
auto gapLV
= new G4LogicalVolume(
gapS, // its solid
gapMaterial, // its material
@@ -258,9 +258,9 @@ G4VPhysicalVolume* B4cDetectorConstruction::DefineVolumes()
//
// Visualization attributes
//
worldLV->SetVisAttributes (G4VisAttributes::Invisible);
worldLV->SetVisAttributes (G4VisAttributes::GetInvisible());
G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
auto simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
simpleBoxVisAtt->SetVisibility(true);
calorLV->SetVisAttributes(simpleBoxVisAtt);
@@ -279,12 +279,14 @@ void B4cDetectorConstruction::ConstructSDandField()
//
// Sensitive detectors
//
B4cCalorimeterSD* absoSD
auto absoSD
= new B4cCalorimeterSD("AbsorberSD", "AbsorberHitsCollection", fNofLayers);
G4SDManager::GetSDMpointer()->AddNewDetector(absoSD);
SetSensitiveDetector("AbsoLV",absoSD);
B4cCalorimeterSD* gapSD
auto gapSD
= new B4cCalorimeterSD("GapSD", "GapHitsCollection", fNofLayers);
G4SDManager::GetSDMpointer()->AddNewDetector(gapSD);
SetSensitiveDetector("GapLV",gapSD);
//
@@ -293,7 +295,7 @@ void B4cDetectorConstruction::ConstructSDandField()
// Create global magnetic field messenger.
// Uniform magnetic field is then created automatically if
// the field value is not zero.
G4ThreeVector fieldValue = G4ThreeVector();
G4ThreeVector fieldValue;
fMagFieldMessenger = new G4GlobalMagFieldMessenger(fieldValue);
fMagFieldMessenger->SetVerboseLevel(1);
+13 -13
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: B4cEventAction.cc 88427 2015-02-19 08:19:38Z gcosmo $
// $Id: B4cEventAction.cc 100946 2016-11-03 11:28:08Z gcosmo $
//
/// \file B4cEventAction.cc
/// \brief Implementation of the B4cEventAction class
@@ -61,7 +61,7 @@ B4cCalorHitsCollection*
B4cEventAction::GetHitsCollection(G4int hcID,
const G4Event* event) const
{
B4cCalorHitsCollection* hitsCollection
auto hitsCollection
= static_cast<B4cCalorHitsCollection*>(
event->GetHCofThisEvent()->GetHC(hcID));
@@ -113,17 +113,17 @@ void B4cEventAction::EndOfEventAction(const G4Event* event)
}
// Get hits collections
B4cCalorHitsCollection* absoHC = GetHitsCollection(fAbsHCID, event);
B4cCalorHitsCollection* gapHC = GetHitsCollection(fGapHCID, event);
auto absoHC = GetHitsCollection(fAbsHCID, event);
auto gapHC = GetHitsCollection(fGapHCID, event);
// Get hit with total values
B4cCalorHit* absoHit = (*absoHC)[absoHC->entries()-1];
B4cCalorHit* gapHit = (*gapHC)[gapHC->entries()-1];
auto absoHit = (*absoHC)[absoHC->entries()-1];
auto gapHit = (*gapHC)[gapHC->entries()-1];
// Print per event (modulo n)
//
G4int eventID = event->GetEventID();
G4int printModulo = G4RunManager::GetRunManager()->GetPrintProgress();
auto eventID = event->GetEventID();
auto printModulo = G4RunManager::GetRunManager()->GetPrintProgress();
if ( ( printModulo > 0 ) && ( eventID % printModulo == 0 ) ) {
G4cout << "---> End of event: " << eventID << G4endl;
@@ -136,13 +136,13 @@ void B4cEventAction::EndOfEventAction(const G4Event* event)
//
// get analysis manager
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
auto analysisManager = G4AnalysisManager::Instance();
// fill histograms
analysisManager->FillH1(1, absoHit->GetEdep());
analysisManager->FillH1(2, gapHit->GetEdep());
analysisManager->FillH1(3, absoHit->GetTrackLength());
analysisManager->FillH1(4, gapHit->GetTrackLength());
analysisManager->FillH1(0, absoHit->GetEdep());
analysisManager->FillH1(1, gapHit->GetEdep());
analysisManager->FillH1(2, absoHit->GetTrackLength());
analysisManager->FillH1(3, gapHit->GetTrackLength());
// fill ntuple
analysisManager->FillNtupleDColumn(0, absoHit->GetEdep());