Import Geant4 10.4.0.beta source tree
This commit is contained in:
@@ -47,9 +47,7 @@ ActionInitialization::~ActionInitialization()
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::BuildForMaster() const
|
||||
{
|
||||
// No specific action for Master
|
||||
}
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -63,5 +61,3 @@ void ActionInitialization::Build() const
|
||||
|
||||
SetUserAction(new SteppingAction(runAction,fDetectorConstruction));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -25,11 +25,22 @@
|
||||
//
|
||||
// Please cite the following paper if you use this software
|
||||
// Nucl.Instrum.Meth.B260:20-27, 2007
|
||||
//
|
||||
// Based on purging magnet advanced example.
|
||||
//
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
|
||||
#include "G4PhysicalConstants.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4NistManager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
// Field
|
||||
#include "G4Mag_UsualEqRhs.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4ClassicalRK4.hh"
|
||||
#include "G4PropagatorInField.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
@@ -40,16 +51,15 @@ G4ThreadLocal TabulatedField3D* DetectorConstruction::fField = 0;
|
||||
DetectorConstruction::DetectorConstruction()
|
||||
{
|
||||
fDetectorMessenger = new DetectorMessenger(this);
|
||||
fGradientsInitialized=false;
|
||||
|
||||
//Default values (square field, coef calculation, profile)
|
||||
// Default values (square field, coef calculation, profile)
|
||||
|
||||
fModel=1;
|
||||
fG1=-11.964623;
|
||||
fG2=16.494652;
|
||||
fG3=9.866770;
|
||||
fG4=-6.244493;
|
||||
fCoef=1;
|
||||
fCoef=0;
|
||||
fProfile=1;
|
||||
fGrid=0;
|
||||
|
||||
@@ -88,6 +98,7 @@ void DetectorConstruction::DefineMaterials()
|
||||
man->SetVerbose(1);
|
||||
|
||||
//
|
||||
|
||||
G4cout << G4endl << *(G4Material::GetMaterialTable()) << G4endl;
|
||||
|
||||
// Default materials in setup.
|
||||
@@ -237,7 +248,8 @@ G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
|
||||
|
||||
void DetectorConstruction::SetG1(G4float value)
|
||||
{
|
||||
fG1 = value;
|
||||
fG1 = value;
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
@@ -245,6 +257,7 @@ void DetectorConstruction::SetG1(G4float value)
|
||||
void DetectorConstruction::SetG2(G4float value)
|
||||
{
|
||||
fG2 = value;
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
@@ -252,6 +265,7 @@ void DetectorConstruction::SetG2(G4float value)
|
||||
void DetectorConstruction::SetG3(G4float value)
|
||||
{
|
||||
fG3 = value;
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
@@ -259,33 +273,25 @@ void DetectorConstruction::SetG3(G4float value)
|
||||
void DetectorConstruction::SetG4(G4float value)
|
||||
{
|
||||
fG4 = value;
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void DetectorConstruction::SetModel(G4int modelChoice)
|
||||
{
|
||||
if (modelChoice==1) fModel=1;
|
||||
if (modelChoice==2) fModel=2;
|
||||
if (modelChoice==3) fModel=3;
|
||||
if (modelChoice==1) fModel=1;
|
||||
if (modelChoice==2) fModel=2;
|
||||
if (modelChoice==3) fModel=3;
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
void DetectorConstruction::UpdateGeometry()
|
||||
{
|
||||
fGradientsInitialized=true;
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
|
||||
}
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void DetectorConstruction::SetCoef(G4int val)
|
||||
{
|
||||
fCoef=val;
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
@@ -300,6 +306,7 @@ G4int DetectorConstruction::GetCoef()
|
||||
void DetectorConstruction::SetProfile(G4int myProfile)
|
||||
{
|
||||
fProfile=myProfile;
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
@@ -307,35 +314,49 @@ void DetectorConstruction::SetProfile(G4int myProfile)
|
||||
void DetectorConstruction::SetGrid(G4int myGrid)
|
||||
{
|
||||
fGrid=myGrid;
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void DetectorConstruction::ConstructSDandField()
|
||||
{
|
||||
// static G4bool fieldIsInitialized = false;
|
||||
// if(!fieldIsInitialized && fGradientsInitialized)
|
||||
fField = new TabulatedField3D(fG1, fG2, fG3, fG4, fModel);
|
||||
|
||||
//This is thread-local
|
||||
G4FieldManager* fFieldMgr =
|
||||
G4TransportationManager::GetTransportationManager()->GetFieldManager();
|
||||
|
||||
G4Mag_UsualEqRhs* fEquation = new G4Mag_UsualEqRhs (fField);
|
||||
|
||||
if(!fField) fField = new TabulatedField3D(fG1, fG2, fG3, fG4, fModel);
|
||||
|
||||
fEquation = new G4Mag_UsualEqRhs (fField);
|
||||
G4ClassicalRK4* fStepper = new G4ClassicalRK4 (fEquation);
|
||||
|
||||
fStepper = new G4ClassicalRK4 (fEquation);
|
||||
G4ChordFinder* fChordFinder = new G4ChordFinder(fField,1e-9*m,fStepper);
|
||||
|
||||
fFieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager();
|
||||
|
||||
fChordFinder = new G4ChordFinder(fField,1e-9*m,fStepper);
|
||||
|
||||
fFieldMgr->SetChordFinder(fChordFinder);
|
||||
fFieldMgr->SetDetectorField(fField);
|
||||
fFieldMgr->GetChordFinder()->SetDeltaChord(1e-9*m);
|
||||
fFieldMgr->SetDeltaIntersection(1e-9*m);
|
||||
fFieldMgr->SetDeltaOneStep(1e-9*m);
|
||||
fFieldMgr->SetChordFinder(fChordFinder);
|
||||
fFieldMgr->SetDetectorField(fField);
|
||||
|
||||
fFieldMgr->GetChordFinder()->SetDeltaChord(1e-9*m);
|
||||
fFieldMgr->SetDeltaIntersection(1e-9*m);
|
||||
fFieldMgr->SetDeltaOneStep(1e-9*m);
|
||||
|
||||
fPropInField =
|
||||
G4TransportationManager::GetTransportationManager()->GetPropagatorInField();
|
||||
fPropInField->SetMinimumEpsilonStep(1e-11);
|
||||
fPropInField->SetMaximumEpsilonStep(1e-10);
|
||||
// To avoid G4MagIntegratorDriver::OneGoodStep:Stepsize underflows in Stepper
|
||||
|
||||
if (fCoef==1)
|
||||
{
|
||||
G4PropagatorInField* fPropInField =
|
||||
G4TransportationManager::GetTransportationManager()->GetPropagatorInField();
|
||||
fPropInField->SetMinimumEpsilonStep(1e-11);
|
||||
fPropInField->SetMaximumEpsilonStep(1e-10);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
G4PropagatorInField* fPropInField =
|
||||
G4TransportationManager::GetTransportationManager()->GetPropagatorInField();
|
||||
fPropInField->SetMinimumEpsilonStep(1e-9);
|
||||
fPropInField->SetMaximumEpsilonStep(1e-8);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,11 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
|
||||
fGridCmd->SetParameterName("grid",false);
|
||||
fGridCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
fCoefCmd = new G4UIcmdWithAnInteger("/setCoef",this);
|
||||
fCoefCmd->SetGuidance("Calculate aberration coefficients.");
|
||||
fCoefCmd->SetParameterName("coef",false);
|
||||
fCoefCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
fG1Cmd = new G4UIcmdWithADouble("/quad/setG1",this);
|
||||
fG1Cmd->SetGuidance("Set G1.");
|
||||
fG1Cmd->SetParameterName("G1",false);
|
||||
@@ -72,11 +77,6 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
|
||||
fG4Cmd->SetParameterName("G4",false);
|
||||
fG4Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
fUpdateCmd = new G4UIcmdWithoutParameter("/quad/update",this);
|
||||
fUpdateCmd->SetGuidance("Update calorimeter geometry.");
|
||||
fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
|
||||
fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
|
||||
fUpdateCmd->AvailableForStates(G4State_Idle);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -87,11 +87,11 @@ DetectorMessenger::~DetectorMessenger()
|
||||
delete fG2Cmd;
|
||||
delete fG3Cmd;
|
||||
delete fG4Cmd;
|
||||
delete fUpdateCmd;
|
||||
delete fQuadDir;
|
||||
delete fModelCmd;
|
||||
delete fProfileCmd;
|
||||
delete fGridCmd;
|
||||
delete fCoefCmd;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -107,6 +107,9 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
|
||||
if( command == fGridCmd )
|
||||
{ fDetector->SetGrid(fGridCmd->GetNewIntValue(newValue));}
|
||||
|
||||
if( command == fCoefCmd )
|
||||
{ fDetector->SetCoef(fGridCmd->GetNewIntValue(newValue));}
|
||||
|
||||
if( command == fG1Cmd )
|
||||
{ fDetector->SetG1(fG1Cmd->GetNewDoubleValue(newValue));}
|
||||
|
||||
@@ -119,6 +122,4 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
|
||||
if( command == fG4Cmd )
|
||||
{ fDetector->SetG4(fG1Cmd->GetNewDoubleValue(newValue));}
|
||||
|
||||
if( command == fUpdateCmd )
|
||||
{ fDetector->UpdateGeometry();}
|
||||
}
|
||||
|
||||
@@ -51,11 +51,6 @@ PhysicsList::~PhysicsList()
|
||||
|
||||
void PhysicsList::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();
|
||||
ConstructBarions();
|
||||
@@ -65,7 +60,6 @@ void PhysicsList::ConstructParticle()
|
||||
|
||||
void PhysicsList::ConstructBosons()
|
||||
{
|
||||
|
||||
// gamma
|
||||
G4Gamma::GammaDefinition();
|
||||
|
||||
@@ -138,12 +132,14 @@ void PhysicsList::ConstructEM()
|
||||
// Identical to G4EmStandardPhysics but added G4StepLimiter process
|
||||
// ****************************************************************
|
||||
|
||||
|
||||
auto particleIterator=GetParticleIterator();
|
||||
particleIterator->reset();
|
||||
|
||||
while( (*particleIterator)() ){
|
||||
|
||||
G4ParticleDefinition* particle = particleIterator->value();
|
||||
|
||||
G4String particleName = particle->GetParticleName();
|
||||
|
||||
if (particleName == "gamma") {
|
||||
@@ -214,77 +210,19 @@ void PhysicsList::SetCuts()
|
||||
G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl;
|
||||
}
|
||||
|
||||
// set cut values for gamma at first and for e- second and next for e+,
|
||||
// because some processes for e+/e- need cut values for gamma
|
||||
SetCutValue(fCutForGamma, "gamma");
|
||||
SetCutValue(fCutForElectron, "e-");
|
||||
SetCutValue(fCutForPositron, "e+");
|
||||
|
||||
// set cut values for proton and anti_proton before all other hadrons
|
||||
// because some processes for hadrons need cut values for proton/anti_proton
|
||||
SetCutValue(fCutForProton, "proton");
|
||||
SetCutValue(fCutForProton, "anti_proton");
|
||||
|
||||
//SetCutValueForOthers(defaultCutValue);
|
||||
|
||||
if (verboseLevel>0) DumpCutValuesTable();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void PhysicsList::SetGammaLowLimit(G4double lowcut)
|
||||
{
|
||||
if (verboseLevel >0){
|
||||
G4cout << "PhysicsList::SetCuts:";
|
||||
G4cout << "Gamma cut in energy: " << lowcut*MeV << " (MeV)" << G4endl;
|
||||
}
|
||||
|
||||
// G4Gamma::SetEnergyRange(lowcut,1e5);
|
||||
SetGELowLimit(lowcut);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void PhysicsList::SetElectronLowLimit(G4double lowcut)
|
||||
{
|
||||
if (verboseLevel >0){
|
||||
|
||||
G4cout << "PhysicsList::SetCuts:";
|
||||
G4cout << "Electron cut in energy: " << lowcut*MeV << " (MeV)" << G4endl;
|
||||
}
|
||||
|
||||
// G4Electron::SetEnergyRange(lowcut,1e5);
|
||||
SetGELowLimit(lowcut);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void PhysicsList::SetGEPLowLimit(G4double lowcut)
|
||||
{
|
||||
if (verboseLevel >0){
|
||||
G4cout << "PhysicsList::SetGEPLowLimit:";
|
||||
G4cout << "Gamma and Electron cut in energy: " << lowcut*MeV << " (MeV)" << G4endl;
|
||||
}
|
||||
|
||||
this->SetGELowLimit(lowcut);
|
||||
|
||||
G4cerr << " SetGEPLowLimit : Uncertain whether setting Positron low limit " << G4endl;
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
void PhysicsList::SetGELowLimit(G4double lowcut)
|
||||
{
|
||||
if (verboseLevel >0){
|
||||
G4cout << "PhysicsList::SetGELowLimit:";
|
||||
G4cout << "Gamma and Electron cut in energy: " << lowcut*MeV << " (MeV)" << G4endl;
|
||||
}
|
||||
|
||||
G4ProductionCutsTable::GetProductionCutsTable()->SetEnergyRange(lowcut,1e5);
|
||||
}
|
||||
void PhysicsList::SetGammaCut(G4double val)
|
||||
{
|
||||
ResetCuts();
|
||||
fCutForGamma = val;
|
||||
}
|
||||
|
||||
@@ -292,7 +230,6 @@ void PhysicsList::SetGammaCut(G4double val)
|
||||
|
||||
void PhysicsList::SetElectronCut(G4double val)
|
||||
{
|
||||
// ResetCuts();
|
||||
fCutForElectron = val;
|
||||
}
|
||||
|
||||
@@ -300,7 +237,6 @@ void PhysicsList::SetElectronCut(G4double val)
|
||||
|
||||
void PhysicsList::SetPositronCut(G4double val)
|
||||
{
|
||||
// ResetCuts();
|
||||
fCutForPositron = val;
|
||||
}
|
||||
|
||||
@@ -308,8 +244,5 @@ void PhysicsList::SetPositronCut(G4double val)
|
||||
|
||||
void PhysicsList::SetProtonCut(G4double val)
|
||||
{
|
||||
//ResetCuts();
|
||||
fCutForProton = val;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
@@ -43,7 +43,7 @@ using namespace std;
|
||||
|
||||
RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* pri)
|
||||
:fDetector(det),fPrimary(pri)
|
||||
{;}
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
@@ -63,23 +63,21 @@ void RunAction::BeginOfRunAction(const G4Run* /*aRun*/)
|
||||
fThetaVector = CLHEP::HepVector(32);
|
||||
fPhiVector = CLHEP::HepVector(32);
|
||||
|
||||
// Histograms
|
||||
// Histograms
|
||||
|
||||
// Get/create analysis manager
|
||||
G4cout << "##### Create analysis manager " << " " << this << G4endl;
|
||||
// Get/create analysis manager
|
||||
G4cout << "##### Create analysis manager " << " " << this << G4endl;
|
||||
|
||||
G4AnalysisManager* man = G4AnalysisManager::Instance();
|
||||
G4AnalysisManager* man = G4AnalysisManager::Instance();
|
||||
|
||||
G4cout << "Using " << man->GetType() << " analysis manager" << G4endl;
|
||||
G4cout << "Using " << man->GetType() << " analysis manager" << G4endl;
|
||||
|
||||
|
||||
// Open an output file
|
||||
man->OpenFile("nanobeam");
|
||||
man->SetFirstHistoId(1);
|
||||
man->SetFirstNtupleId(1);
|
||||
|
||||
// Create 1st ntuple (id = 1)
|
||||
//
|
||||
man->CreateNtuple("ntuple0", "BeamProfile");
|
||||
man->CreateNtupleDColumn("xIn");
|
||||
man->CreateNtupleDColumn("yIn");
|
||||
@@ -88,7 +86,6 @@ void RunAction::BeginOfRunAction(const G4Run* /*aRun*/)
|
||||
G4cout << "Ntuple-1 created" << G4endl;
|
||||
|
||||
// Create 2nd htuple (id = 2)
|
||||
//
|
||||
man->CreateNtuple("ntuple1","Grid");
|
||||
man->CreateNtupleDColumn("xIn");
|
||||
man->CreateNtupleDColumn("yIn");
|
||||
|
||||
@@ -62,13 +62,13 @@ if ( (step->GetTrack()->GetDynamicParticle()->GetDefinition() ==
|
||||
|
||||
// for triplet and whole line
|
||||
|
||||
&& (step->GetPostStepPoint()->GetPosition().z()/mm>249.99999)
|
||||
&& (step->GetPostStepPoint()->GetPosition().z()/mm>249.99999)
|
||||
&& (step->GetPostStepPoint()->GetPosition().z()/mm<250.00001)
|
||||
&& (step->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->
|
||||
GetLogicalVolume()->GetName() == fDetector->GetLogicalVol()->GetName())
|
||||
&& (step->GetPostStepPoint()->GetTouchableHandle()->GetVolume()->
|
||||
GetLogicalVolume()->GetName() == fDetector->GetLogicalWorld()->GetName())
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
fXIn = step->GetPostStepPoint()->GetPosition().x();
|
||||
@@ -111,12 +111,12 @@ if (fDetector->GetProfile()==1)
|
||||
{
|
||||
|
||||
if (
|
||||
(step->GetTrack()->GetDynamicParticle()->GetDefinition()
|
||||
== G4Proton::ProtonDefinition())
|
||||
(step->GetTrack()->GetDynamicParticle()->GetDefinition()== G4Proton::ProtonDefinition())
|
||||
&& (step->GetPreStepPoint()->GetTouchableHandle()
|
||||
->GetVolume()->GetLogicalVolume()->GetName() == fDetector->GetLogicalVol()->GetName())
|
||||
&& (step->GetPostStepPoint()->GetTouchableHandle()
|
||||
->GetVolume()->GetLogicalVolume()->GetName() == fDetector->GetLogicalVol()->GetName()) )
|
||||
->GetVolume()->GetLogicalVolume()->GetName() == fDetector->GetLogicalVol()->GetName())
|
||||
)
|
||||
{
|
||||
fXIn = step->GetPostStepPoint()->GetPosition().x();
|
||||
fYIn = step->GetPostStepPoint()->GetPosition().y();
|
||||
@@ -134,12 +134,12 @@ if (fDetector->GetGrid()==1)
|
||||
{
|
||||
|
||||
if (
|
||||
(step->GetTrack()->GetDynamicParticle()->GetDefinition()
|
||||
== G4Proton::ProtonDefinition())
|
||||
(step->GetTrack()->GetDynamicParticle()->GetDefinition()== G4Proton::ProtonDefinition())
|
||||
&& (step->GetPreStepPoint()->GetTouchableHandle()
|
||||
->GetVolume()->GetLogicalVolume()->GetName() == fDetector->GetLogicalGrid()->GetName())
|
||||
&& (step->GetPostStepPoint()->GetTouchableHandle()
|
||||
->GetVolume()->GetLogicalVolume()->GetName() == fDetector->GetLogicalWorld()->GetName()) )
|
||||
->GetVolume()->GetLogicalVolume()->GetName() == fDetector->GetLogicalWorld()->GetName())
|
||||
)
|
||||
{
|
||||
fXIn = step->GetPostStepPoint()->GetPosition().x();
|
||||
fYIn = step->GetPostStepPoint()->GetPosition().y();
|
||||
|
||||
@@ -26,11 +26,21 @@
|
||||
// Please cite the following papers if you use this software
|
||||
// Nucl.Instrum.Meth.B260:20-27, 2007
|
||||
// IEEE TNS 51, 4:1395-1401, 2004
|
||||
//
|
||||
// Based on purging magnet advanced example
|
||||
//
|
||||
|
||||
#include "TabulatedField3D.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Exp.hh"
|
||||
|
||||
#include "G4AutoLock.hh"
|
||||
|
||||
namespace
|
||||
{
|
||||
G4Mutex myTabulatedField3DLock = G4MUTEX_INITIALIZER;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
TabulatedField3D::TabulatedField3D(G4float gr1, G4float gr2, G4float gr3, G4float gr4, G4int choiceModel)
|
||||
@@ -58,6 +68,12 @@ TabulatedField3D::TabulatedField3D(G4float gr1, G4float gr2, G4float gr3, G4floa
|
||||
|
||||
if (fModel==2)
|
||||
{
|
||||
//
|
||||
//This is a thread-local class and we have to avoid that all workers open the
|
||||
//file at the same time
|
||||
G4AutoLock lock(&myTabulatedField3DLock);
|
||||
//
|
||||
|
||||
const char * filename ="OM50.grid";
|
||||
|
||||
double lenUnit= mm;
|
||||
@@ -80,11 +96,13 @@ TabulatedField3D::TabulatedField3D(G4float gr1, G4float gr2, G4float gr3, G4floa
|
||||
fYField.resize( fNx );
|
||||
fZField.resize( fNx );
|
||||
int ix, iy, iz;
|
||||
for (ix=0; ix<fNx; ix++) {
|
||||
for (ix=0; ix<fNx; ix++)
|
||||
{
|
||||
fXField[ix].resize(fNy);
|
||||
fYField[ix].resize(fNy);
|
||||
fZField[ix].resize(fNy);
|
||||
for (iy=0; iy<fNy; iy++) {
|
||||
for (iy=0; iy<fNy; iy++)
|
||||
{
|
||||
fXField[ix][iy].resize(fNz);
|
||||
fYField[ix][iy].resize(fNz);
|
||||
fZField[ix][iy].resize(fNz);
|
||||
@@ -94,11 +112,15 @@ TabulatedField3D::TabulatedField3D(G4float gr1, G4float gr2, G4float gr3, G4floa
|
||||
// Read in the data
|
||||
double xval,yval,zval,bx,by,bz;
|
||||
double permeability; // Not used in this example.
|
||||
for (ix=0; ix<fNx; ix++) {
|
||||
for (iy=0; iy<fNy; iy++) {
|
||||
for (iz=0; iz<fNz; iz++) {
|
||||
for (ix=0; ix<fNx; ix++)
|
||||
{
|
||||
for (iy=0; iy<fNy; iy++)
|
||||
{
|
||||
for (iz=0; iz<fNz; iz++)
|
||||
{
|
||||
file >> xval >> yval >> zval >> bx >> by >> bz >> permeability;
|
||||
if ( ix==0 && iy==0 && iz==0 ) {
|
||||
if ( ix==0 && iy==0 && iz==0 )
|
||||
{
|
||||
fMinix = xval * lenUnit;
|
||||
fMiniy = yval * lenUnit;
|
||||
fMiniz = zval * lenUnit;
|
||||
@@ -111,6 +133,10 @@ TabulatedField3D::TabulatedField3D(G4float gr1, G4float gr2, G4float gr3, G4floa
|
||||
}
|
||||
file.close();
|
||||
|
||||
//
|
||||
lock.unlock();
|
||||
//
|
||||
|
||||
fMaxix = xval * lenUnit;
|
||||
fMaxiy = yval * lenUnit;
|
||||
fMaxiz = zval * lenUnit;
|
||||
@@ -118,6 +144,7 @@ TabulatedField3D::TabulatedField3D(G4float gr1, G4float gr2, G4float gr3, G4floa
|
||||
G4cout << "\n ---> ... done reading " << endl;
|
||||
|
||||
// G4cout << " Read values of field from file " << filename << endl;
|
||||
|
||||
G4cout << " ---> assumed the order: x, y, z, Bx, By, Bz "
|
||||
<< "\n ---> Min values x,y,z: "
|
||||
<< fMinix/cm << " " << fMiniy/cm << " " << fMiniz/cm << " cm "
|
||||
@@ -127,12 +154,14 @@ TabulatedField3D::TabulatedField3D(G4float gr1, G4float gr2, G4float gr3, G4floa
|
||||
fDx = fMaxix - fMinix;
|
||||
fDy = fMaxiy - fMiniy;
|
||||
fDz = fMaxiz - fMiniz;
|
||||
|
||||
G4cout << "\n ---> Dif values x,y,z (range): "
|
||||
<< fDx/cm << " " << fDy/cm << " " << fDz/cm << " cm in z "
|
||||
<< "\n-----------------------------------------------------------" << endl;
|
||||
|
||||
|
||||
// Table normalization
|
||||
|
||||
for (ix=0; ix<fNx; ix++)
|
||||
{
|
||||
for (iy=0; iy<fNy; iy++)
|
||||
@@ -144,7 +173,7 @@ TabulatedField3D::TabulatedField3D(G4float gr1, G4float gr2, G4float gr3, G4floa
|
||||
fYField[ix][iy][iz] = (fYField[ix][iy][iz]/197.736);
|
||||
fZField[ix][iy][iz] = (fZField[ix][iy][iz]/197.736);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,6 +187,11 @@ TabulatedField3D::TabulatedField3D(G4float gr1, G4float gr2, G4float gr3, G4floa
|
||||
void TabulatedField3D::GetFieldValue(const double point[4],
|
||||
double *Bfield ) const
|
||||
{
|
||||
//G4cout << fGradient1 << G4endl;
|
||||
//G4cout << fGradient2 << G4endl;
|
||||
//G4cout << fGradient3 << G4endl;
|
||||
//G4cout << fGradient4 << G4endl;
|
||||
//G4cout << "---------" << G4endl;
|
||||
|
||||
G4double coef, G0;
|
||||
G0 = 0;
|
||||
@@ -168,6 +202,7 @@ void TabulatedField3D::GetFieldValue(const double point[4],
|
||||
//******************************************************************
|
||||
|
||||
// MAP
|
||||
|
||||
if (fModel==2)
|
||||
{
|
||||
Bfield[0] = 0.0;
|
||||
@@ -225,9 +260,15 @@ if (fModel==2)
|
||||
|
||||
// The indices of the nearest tabulated point whose coordinates
|
||||
// are all less than those of the given point
|
||||
int xindex = static_cast<int>(xdindex);
|
||||
int yindex = static_cast<int>(ydindex);
|
||||
int zindex = static_cast<int>(zdindex);
|
||||
|
||||
//int xindex = static_cast<int>(xdindex);
|
||||
//int yindex = static_cast<int>(ydindex);
|
||||
//int zindex = static_cast<int>(zdindex);
|
||||
|
||||
// SI 15/12/2016: modified according to bugzilla 1879
|
||||
int xindex = static_cast<int>(std::floor(xdindex));
|
||||
int yindex = static_cast<int>(std::floor(ydindex));
|
||||
int zindex = static_cast<int>(std::floor(zdindex));
|
||||
|
||||
// Interpolated field
|
||||
Bfield[0] =
|
||||
@@ -435,22 +476,22 @@ if (fModel==3)
|
||||
for (G4int i=0;i<5; i++) // LOOP ON MAGNETS
|
||||
{
|
||||
|
||||
if (i<2) // (if Doublet)
|
||||
{
|
||||
if (i<2) // (if Doublet)
|
||||
{
|
||||
zoprime = lineZ + i*140*mm; // centre of magnet nbr i
|
||||
x_local = x;
|
||||
y_local = y;
|
||||
z_local = (z - zoprime);
|
||||
}
|
||||
else // else the current magnet is in the triplet
|
||||
{
|
||||
}
|
||||
else // else the current magnet is in the triplet
|
||||
{
|
||||
zoprime = lineZ + i*140*mm +(3150-40)*mm;
|
||||
|
||||
x_local = x;
|
||||
y_local = y;
|
||||
z_local = (z - zoprime);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( z_local < -z2[i] || z_local > z2[i]) // Outside the fringing field
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user