Import Geant4 4.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:39:52 +02:00
parent 921d3b1cda
commit 330b82b769
4524 changed files with 178689 additions and 43575 deletions
@@ -0,0 +1,167 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: CadDetectorConstruction.cc,v 1.1 2002/06/20 10:00:55 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
// ------------------------------------------------------------
#include "G4AssemblyCreator.hh"
#include "G4Assembly.hh"
#include "CadDetectorConstruction.hh"
#include "CadDetectorMessenger.hh"
#include "G4PVPlacement.hh"
#include "G4LogicalVolume.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4Material.hh"
#include "G4Element.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
CadDetectorConstruction::CadDetectorConstruction()
: detectorChoice(0)
{
expHall_x = 1111600.*cm;
expHall_y = 1111600.*cm;
expHall_z = 1111600.*cm;
calBox_x = 50.*cm;
calBox_y = 50.*cm;
calBox_z = 50.*cm;
rotAngle = 30.*deg;
calPos = 200.*cm;
trackerRadius = 50.*cm;
trackerHight = 100.*cm;
trackerPos = -200.*cm;
detectorMessenger = new CadDetectorMessenger(this);
}
CadDetectorConstruction::~CadDetectorConstruction()
{;}
G4VPhysicalVolume* CadDetectorConstruction::Construct()
{
//------------------------------------------------------ materials
G4double a, iz, z, density;
G4String name, symbol;
G4int nel;
a = 14.01*g/mole;
G4Element* elN = new G4Element(name="Nitrogen", symbol="N", iz=7., a);
a = 16.00*g/mole;
G4Element* elO = new G4Element(name="Oxygen", symbol="O", iz=8., a);
density = 1.29e-03*g/cm3;
G4Material* Air = new G4Material(name="Air", density, nel=2);
Air->AddElement(elN, .7);
Air->AddElement(elO, .3);
a = 207.19*g/mole;
density = 11.35*g/cm3;
G4Material* Lead = new G4Material(name="Lead", z=82., a, density);
a = 39.95*g/mole;
density = 1.782e-03*g/cm3;
G4Material* Ar = new G4Material(name="ArgonGas", z=18., a, density);
//------------------------------------------------------ volumes
//------------------------------ experimental hall
G4Box * experimentalHall_box
= new G4Box("expHall_b",expHall_x,expHall_y,expHall_z);
G4LogicalVolume * experimentalHall_log
= new G4LogicalVolume(experimentalHall_box,Air,"expHall_L",0,0,0);
G4VPhysicalVolume * experimentalHall_phys
= new G4PVPlacement(0,G4ThreeVector(),"expHall_P",
experimentalHall_log,0,false,0);
experimentalHall_log->SetVisAttributes (G4VisAttributes::Invisible);
//------------------------------ STEP assembly creation
const char * stepfile;
switch(detectorChoice)
{
default:
stepfile = "stepfiles/G4rod_place_asm.stp";
break;
case 1:
stepfile = "stepfiles/G4rod_solid.stp";
break;
}
G4AssemblyCreator MyAC(stepfile);
MyAC.ReadStepFile();
STEPentity* ent=0;
MyAC.CreateG4Geometry(*ent);
void *tmp = MyAC.GetCreatedObject();
G4Assembly* assembly = new G4Assembly();
assembly->SetPlacedVector(*(G4PlacedVector*)tmp);
// Set vis attribute to "transparent" blue
G4VisAttributes * visAttr = new G4VisAttributes(G4Colour(0.,0.,1.,.5));
visAttr->SetVisibility(true);
G4PlacedSolid* ps=0;
G4int solids = assembly->GetNumberOfSolids();
G4cout << "Now placing " << solids << " logical volumes... ";
for(G4int c=0;c<solids;c++)
{
ps = assembly->GetPlacedSolid(c);
G4LogicalVolume* lv = new G4LogicalVolume(ps->GetSolid(),Lead,"STEPlog");
HepRotation* hr = ps->GetRotation();
G4ThreeVector* tr = ps->GetTranslation();
new G4PVPlacement(hr,
*tr,
"STEPphys", // ps->GetSolid()->GetName(),
// no name assigned in sample STEP files
lv,
experimentalHall_phys,
false,
c);
lv->SetVisAttributes(visAttr);
}
G4cout << "Done !" << G4endl;
return experimentalHall_phys;
}
void CadDetectorConstruction::SelectDetector(G4String val)
{
if(val=="rod_solid")
{ detectorChoice = 1; }
else
{ detectorChoice = 0; }
G4cout << "Now Detector is " << val << G4endl;
}
@@ -0,0 +1,74 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: CadDetectorMessenger.cc,v 1.1 2002/06/20 10:00:55 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
// ------------------------------------------------------------
#include "CadDetectorConstruction.hh"
#include "CadDetectorMessenger.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
CadDetectorMessenger::CadDetectorMessenger(CadDetectorConstruction * myDC)
: myDetector(myDC)
{
G4String defParam;
mydetDir = new G4UIdirectory("/mydet/");
mydetDir->SetGuidance("Detector setup commands.");
selDetCmd = new G4UIcmdWithAString("/mydet/SelectDetector",this);
selDetCmd->SetGuidance("Select Detector Setup.");
selDetCmd->SetGuidance(" Choice : rod_place_asm / rod_solid ");
selDetCmd->SetParameterName("choice",true);
selDetCmd->SetDefaultValue("rod_place_asm");
selDetCmd->SetCandidates("rod_place_asm rod_solid");
selDetCmd->AvailableForStates(PreInit,Idle);
switchCmd = new G4UIcmdWithAString("/mydet/SwitchDetector",this);
switchCmd->SetGuidance("Assign the selected geometry to G4RunManager.");
switchCmd->SetGuidance("In cese detector name is associated to this command,");
switchCmd->SetGuidance("\"/mydet/SelectDetector\" will be invoked and then switched.");
switchCmd->SetParameterName("choice",true);
switchCmd->SetDefaultValue(" ");
switchCmd->SetCandidates("rod_place_asm rod_solid \" \"");
switchCmd->AvailableForStates(PreInit,Idle);
myDetector->SelectDetector(defParam="rod_place_asm");
}
void CadDetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
{
if( command == selDetCmd )
{
myDetector->SelectDetector(newValues);
}
if( command == switchCmd )
{
if(newValues=="rod_place_asm" || newValues=="CMSTracker")
{ myDetector->SelectDetector(newValues); }
}
return;
}
@@ -0,0 +1,207 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: CadPhysicsList.cc,v 1.1 2002/06/20 10:00:56 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
// ------------------------------------------------------------
#include "CadPhysicsList.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleWithCuts.hh"
#include "G4ProcessManager.hh"
#include "G4ProcessVector.hh"
#include "G4ParticleTypes.hh"
#include "G4ParticleTable.hh"
#include "G4BosonConstructor.hh"
#include "G4LeptonConstructor.hh"
#include "G4MesonConstructor.hh"
#include "G4BaryonConstructor.hh"
#include "G4IonConstructor.hh"
#include "G4Material.hh"
#include "G4MaterialTable.hh"
CadPhysicsList::CadPhysicsList(): G4VUserPhysicsList()
{
SetVerboseLevel(1);
}
CadPhysicsList::~CadPhysicsList()
{
}
void CadPhysicsList::ConstructParticle()
{
// In this method, static member functions should be called
// for all particles which you want to use.
// This ensures that objects of these particle types will be
// created in the program.
ConstructBosons();
ConstructLeptons();
ConstructMesons();
ConstructBaryons();
ConstructIons();
}
void CadPhysicsList::ConstructBosons()
{
// Construct all bosons
G4BosonConstructor pConstructor;
pConstructor.ConstructParticle();
}
void CadPhysicsList::ConstructLeptons()
{
// Construct all leptons
G4LeptonConstructor pConstructor;
pConstructor.ConstructParticle();
}
void CadPhysicsList::ConstructMesons()
{
// Construct all mesons
G4MesonConstructor pConstructor;
pConstructor.ConstructParticle();
}
void CadPhysicsList::ConstructBaryons()
{
// Construct all barions
G4BaryonConstructor pConstructor;
pConstructor.ConstructParticle();
}
void CadPhysicsList::ConstructIons()
{
// Construct light ions
G4IonConstructor pConstructor;
pConstructor.ConstructParticle();
}
void CadPhysicsList::ConstructProcess()
{
AddTransportation();
ConstructEM();
ConstructLeptHad();
ConstructHad();
ConstructGeneral();
}
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4MultipleScattering.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
#include "G4MuIonisation.hh"
#include "G4MuBremsstrahlung.hh"
#include "G4MuPairProduction.hh"
#include "G4hIonisation.hh"
void CadPhysicsList::ConstructEM()
{
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
G4String particleName = particle->GetParticleName();
if (particleName == "gamma") {
// gamma
// Construct processes for gamma
pmanager->AddDiscreteProcess(new G4GammaConversion());
pmanager->AddDiscreteProcess(new G4ComptonScattering());
pmanager->AddDiscreteProcess(new G4PhotoElectricEffect());
} else if (particleName == "e-") {
//electron
// Construct processes for electron
pmanager->AddProcess(new G4MultipleScattering(),-1,1,1);
pmanager->AddProcess(new G4eIonisation(),-1,2,2);
pmanager->AddProcess(new G4eBremsstrahlung(),-1,-1,3);
} else if (particleName == "e+") {
//positron
// Construct processes for positron
pmanager->AddProcess(new G4MultipleScattering(),-1,1,1);
pmanager->AddProcess(new G4eIonisation(),-1,2,2);
pmanager->AddProcess(new G4eBremsstrahlung(),-1,-1,3);
pmanager->AddProcess(new G4eplusAnnihilation(),0,-1,4);
} else if( particleName == "mu+" ||
particleName == "mu-" ) {
//muon
// Construct processes for muon+
pmanager->AddProcess(new G4MultipleScattering(),-1,1,1);
pmanager->AddProcess(new G4MuIonisation(),-1,2,2);
pmanager->AddProcess(new G4MuBremsstrahlung(),-1,-1,3);
pmanager->AddProcess(new G4MuPairProduction(),-1,-1,4);
} else {
if ((particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
// all others charged particles except geantino
pmanager->AddProcess(new G4MultipleScattering(),-1,1,1);
pmanager->AddProcess(new G4hIonisation(),-1,2,2);
}
}
}
}
void CadPhysicsList::ConstructHad()
{;}
void CadPhysicsList::ConstructLeptHad()
{;}
#include "G4Decay.hh"
void CadPhysicsList::ConstructGeneral()
{
G4Decay* theDecayProcess = new G4Decay();
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if (theDecayProcess->IsApplicable(*particle)) {
pmanager->AddProcess(theDecayProcess, INT_MAX, -1, INT_MAX);
}
}
}
void CadPhysicsList::SetCuts()
{
if (verboseLevel >0){
G4cout << "CadPhysicsList::SetCuts:";
G4cout << "CutLength : " << defaultCutValue/mm << " (mm)" << G4endl;
}
// " G4VUserPhysicsList::SetCutsWithDefault" method sets
// the default cut value for all particle types
SetCutsWithDefault();
}
@@ -0,0 +1,61 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: CadPrimaryGeneratorAction.cc,v 1.1 2002/06/20 10:00:56 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
// ------------------------------------------------------------
#include "CadPrimaryGeneratorAction.hh"
#include "globals.hh"
#include "G4Event.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
CadPrimaryGeneratorAction::CadPrimaryGeneratorAction()
{
G4int n_particle = 1;
particleGun = new G4ParticleGun(n_particle);
// default particle
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String particleName;
G4ParticleDefinition* particle
= particleTable->FindParticle(particleName="e-");
particleGun->SetParticleDefinition(particle);
particleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.));
particleGun->SetParticleEnergy(20.*MeV);
particleGun->SetParticlePosition(G4ThreeVector(0.*cm,0.*cm,0.*cm));
}
CadPrimaryGeneratorAction::~CadPrimaryGeneratorAction()
{
delete particleGun;
}
void CadPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
particleGun->GeneratePrimaryVertex(anEvent);
}
@@ -0,0 +1,51 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: CadRunAction.cc,v 1.1 2002/06/20 10:00:56 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
// ------------------------------------------------------------
// Make this appear first!
#include "G4Timer.hh"
#include "CadRunAction.hh"
#include "G4Run.hh"
CadRunAction::CadRunAction()
{
timer = new G4Timer;
}
CadRunAction::~CadRunAction()
{
delete timer;
}
void CadRunAction::BeginOfRunAction(const G4Run* aRun)
{
timer->Start();
}
void CadRunAction::EndOfRunAction(const G4Run* aRun)
{
timer->Stop();
}
@@ -0,0 +1,60 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: CadVisManager.cc,v 1.1 2002/06/20 10:00:56 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
// --------------------------------------------------------------------
#ifdef G4VIS_USE
#include "CadVisManager.hh"
// Visualization drivers...
#include "G4ASCIITree.hh"
#include "G4DAWNFILE.hh"
#include "G4GAGTree.hh"
#include "G4HepRepFile.hh"
#include "G4RayTracer.hh"
CadVisManager::CadVisManager () {}
void CadVisManager::RegisterGraphicsSystems ()
{
RegisterGraphicsSystem (new G4ASCIITree);
RegisterGraphicsSystem (new G4DAWNFILE);
RegisterGraphicsSystem (new G4GAGTree);
RegisterGraphicsSystem (new G4HepRepFile);
RegisterGraphicsSystem (new G4RayTracer);
if (fVerbose > 0)
{
G4cout << G4endl
<< "You have successfully chosen to use"
<< " the following graphics systems:"
<< G4endl;
PrintAvailableGraphicsSystems ();
}
}
#endif