Import Geant4 9.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 15:58:43 +02:00
parent 96c8bcd0af
commit b79225fb37
7544 changed files with 245407 additions and 91099 deletions
+340
View File
@@ -0,0 +1,340 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// -------------------------------------------------------------------
// $Id: DetectorConstruction.cc,v 1.3 2008/12/18 12:56:24 gunter Exp $
// -------------------------------------------------------------------
#include "DetectorConstruction.hh"
#include "G4NistManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
DetectorConstruction::DetectorConstruction()
{
detectorMessenger = new DetectorMessenger(this);
gradientsInitialized=false;
G1=0; G2=0; G3=0; G4=0; coef=0; profile=0; grid=0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
DetectorConstruction::~DetectorConstruction()
{ delete detectorMessenger;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VPhysicalVolume* DetectorConstruction::Construct()
{
DefineMaterials();
return ConstructVolumes();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void DetectorConstruction::DefineMaterials()
{
G4String name, symbol;
G4double density;
G4int ncomponents, natoms;
G4double z, a;
// Define Elements
G4Element* H = new G4Element ("Hydrogen", "H", 1. , 1.01*g/mole);
G4Element* O = new G4Element ("Oxygen" , "O", 8. , 16.00*g/mole);
// Water
density = 1.000*g/cm3;
G4Material* H2O = new G4Material(name="H2O" , density, ncomponents=2);
H2O->AddElement(H, natoms=2);
H2O->AddElement(O, natoms=1);
// Vacuum standard definition...
density = universe_mean_density;
G4Material* vacuum = new G4Material(name="Vacuum", z=1., a=1.01*g/mole,
density);
// NIST
G4NistManager *man=G4NistManager::Instance();
man->SetVerbose(1);
G4cout << G4endl << *(G4Material::GetMaterialTable()) << G4endl;
// Default materials in setup.
defaultMaterial = vacuum;
waterMaterial = H2O;
gridMaterial = man->FindOrBuildMaterial("G4_Ni");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
{
static G4bool fieldIsInitialized = false;
if(!fieldIsInitialized && gradientsInitialized)
{
G4FieldManager* pFieldMgr;
G4MagIntegratorStepper* pStepper;
G4Mag_UsualEqRhs* pEquation;
G4MagneticField* Field= new TabulatedField3D(G1, G2, G3, G4, model);
pEquation = new G4Mag_UsualEqRhs (Field);
pStepper = new G4ClassicalRK4 (pEquation);
pFieldMgr=G4TransportationManager::GetTransportationManager()->GetFieldManager();
G4ChordFinder *pChordFinder = new G4ChordFinder(Field,1e-9*m,pStepper);
pFieldMgr->SetChordFinder( pChordFinder );
pFieldMgr->SetDetectorField(Field);
fieldIsInitialized = true;
// tuned parameters
pFieldMgr->GetChordFinder()->SetDeltaChord(1.e-9*m);
pFieldMgr->SetDeltaIntersection(1.e-9*m);
pFieldMgr->SetDeltaOneStep(1.e-9*m);
G4PropagatorInField *propInField;
propInField =
G4TransportationManager::GetTransportationManager()->GetPropagatorInField();
propInField->SetMinimumEpsilonStep(1e-11);
propInField->SetMaximumEpsilonStep(1e-10);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
solidWorld = new G4Box("World", //its name
12*m/2,12*m/2,22*m/2); //its size
logicWorld = new G4LogicalVolume(solidWorld, //its solid
defaultMaterial, //its material
"World"); //its name
physiWorld = new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
"World", //its name
logicWorld, //its logical volume
NULL, //its mother volume
false, //no boolean operation
0); //copy number
// MAGNET VOLUME
solidVol = new G4Box("Vol", //its name
10*m/2,10*m/2,9.120*m/2); //its size
logicVol = new G4LogicalVolume(solidVol, //its solid
defaultMaterial, //its material
"Vol"); //its name
physiVol = new G4PVPlacement(0, //no rotation
G4ThreeVector(0,0,-4310*mm), //at (0,0,0)
"Vol", //its name
logicVol, //its logical volume
physiWorld, //its mother volume
false, //no boolean operation
0); //copy number
// GRID
if (grid==1)
{
G4cout << G4endl;
G4cout << " ********************** " << G4endl;
G4cout << " **** GRID IN PLACE *** " << G4endl;
G4cout << " ********************** " << G4endl;
G4double x_grid=5.0*mm;
G4double y_grid=5.0*mm;
G4double grid_Zpos=(250+200)*mm; // 250+10 mm for object size of 50µm diam
//G4double thickness_grid=10*micrometer;
G4double thickness_grid=100*micrometer;
G4double z_grid=thickness_grid/2.0;
solidGridVol= new G4Box("GridVolume",x_grid,y_grid,z_grid); //its size
logicGridVol = new G4LogicalVolume(solidGridVol, //its solid
gridMaterial, //its material
"GridVolume"); //its name
physiGridVol = new G4PVPlacement(0, //no rotation
G4ThreeVector(0,0,grid_Zpos), // origin
logicGridVol, //its logical volume
"GridVolume", //its name
logicWorld, //its mother volume
false, //no boolean operation
0);
// Holes in grid
G4double holeSize= 9e-3*mm;
G4double pix_grid=1.3e-2*mm;
G4int num_half_grid=100;
solidGridVol_Hole= new G4Box("GridHole",holeSize/2,holeSize/2,z_grid); //its size
logicGridVol_Hole = new G4LogicalVolume(solidGridVol_Hole, //its solid
defaultMaterial, //its material
"GridHole"); //its name
for(int i=-num_half_grid;i<num_half_grid;i++)
{
for (int j=-num_half_grid;j<num_half_grid;j++)
{
G4double x0_grid,y0_grid,z0_grid;
G4int number_index_grid;
x0_grid=pix_grid*i;
y0_grid=pix_grid*j;
z0_grid=0.0*mm;
number_index_grid=(i+num_half_grid)*1000+(j+num_half_grid);
physiGridVol_Hole = new G4PVPlacement(0, //no rotation
G4ThreeVector(x0_grid,y0_grid,z0_grid),//origin
logicGridVol_Hole, //its logical volume
"GridHole", //its name
logicGridVol, //its mother volume
false, //no boolean operation
number_index_grid);
}
}
// Grid imaging plane
G4double ContVolSizeXY = 1*m;
G4double ImPlaneWidth = 0.001*mm;
solidControlVol_GridShadow =
new G4Box
("ControlVol_GridShadow", ContVolSizeXY/2, ContVolSizeXY/2 , ImPlaneWidth/2);
logicControlVol_GridShadow =
new G4LogicalVolume
(solidControlVol_GridShadow, defaultMaterial, "ControlVol_GridShadow");
physiControlVol_GridShadow =
new G4PVPlacement
//( 0, G4ThreeVector(0,0,(250+250)*mm), logicControlVol_GridShadow, "ControlVol_GridShadow",logicWorld, false, 0);
( 0, G4ThreeVector(0,0,(250+300)*mm), logicControlVol_GridShadow, "ControlVol_GridShadow",logicWorld, false, 0);
} // end GRID
// STEP MINIMUM SIZE
logicVol->SetUserLimits(new G4UserLimits(1*mm));
return physiWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void DetectorConstruction::SetG1(G4float value)
{
G1 = value;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void DetectorConstruction::SetG2(G4float value)
{
G2 = value;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void DetectorConstruction::SetG3(G4float value)
{
G3 = value;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void DetectorConstruction::SetG4(G4float value)
{
G4 = value;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void DetectorConstruction::SetModel(G4int modelChoice)
{
if (modelChoice==1) model=1;
if (modelChoice==2) model=2;
if (modelChoice==3) model=3;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#include "G4RunManager.hh"
void DetectorConstruction::UpdateGeometry()
{
gradientsInitialized=true;
G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void DetectorConstruction::SetCoef()
{
coef=1;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4int DetectorConstruction::GetCoef()
{
return coef;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void DetectorConstruction::SetProfile(G4int myProfile)
{
profile=myProfile;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void DetectorConstruction::SetGrid(G4int myGrid)
{
grid=myGrid;
}
@@ -0,0 +1,125 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// -------------------------------------------------------------------
// $Id: DetectorMessenger.cc,v 1.2 2008/01/25 20:49:24 sincerti Exp $
// -------------------------------------------------------------------
#include "DetectorMessenger.hh"
#include "DetectorConstruction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
:Detector(Det)
{
quadDir = new G4UIdirectory("/quad/");
quadDir->SetGuidance("Quadrupole control.");
modelCmd = new G4UIcmdWithAnInteger("/quad/setModel",this);
modelCmd->SetGuidance("Select magnetic field model.");
modelCmd->SetParameterName("model",false);
modelCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
profileCmd = new G4UIcmdWithAnInteger("/displayProfile",this);
profileCmd->SetGuidance("Display beam profile.");
profileCmd->SetParameterName("profile",false);
profileCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
gridCmd = new G4UIcmdWithAnInteger("/setGrid",this);
gridCmd->SetGuidance("Put grid and shadow plane.");
gridCmd->SetParameterName("grid",false);
gridCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
G1Cmd = new G4UIcmdWithADouble("/quad/setG1",this);
G1Cmd->SetGuidance("Set G1.");
G1Cmd->SetParameterName("G1",false);
G1Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
G2Cmd = new G4UIcmdWithADouble("/quad/setG2",this);
G2Cmd->SetGuidance("Set G2.");
G2Cmd->SetParameterName("G2",false);
G2Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
G3Cmd = new G4UIcmdWithADouble("/quad/setG3",this);
G3Cmd->SetGuidance("Set G3.");
G3Cmd->SetParameterName("G3",false);
G3Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
G4Cmd = new G4UIcmdWithADouble("/quad/setG4",this);
G4Cmd->SetGuidance("Set G4.");
G4Cmd->SetParameterName("G4",false);
G4Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
UpdateCmd = new G4UIcmdWithoutParameter("/quad/update",this);
UpdateCmd->SetGuidance("Update calorimeter geometry.");
UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
UpdateCmd->SetGuidance("if you changed geometrical value(s).");
UpdateCmd->AvailableForStates(G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::~DetectorMessenger()
{
delete G1Cmd;
delete G2Cmd;
delete G3Cmd;
delete G4Cmd;
delete UpdateCmd;
delete quadDir;
delete modelCmd;
delete profileCmd;
delete gridCmd;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
{
if( command == modelCmd )
{ Detector->SetModel(modelCmd->GetNewIntValue(newValue));}
if( command == profileCmd )
{ Detector->SetProfile(profileCmd->GetNewIntValue(newValue));}
if( command == gridCmd )
{ Detector->SetGrid(gridCmd->GetNewIntValue(newValue));}
if( command == G1Cmd )
{ Detector->SetG1(G1Cmd->GetNewDoubleValue(newValue));}
if( command == G2Cmd )
{ Detector->SetG2(G1Cmd->GetNewDoubleValue(newValue));}
if( command == G3Cmd )
{ Detector->SetG3(G1Cmd->GetNewDoubleValue(newValue));}
if( command == G4Cmd )
{ Detector->SetG4(G1Cmd->GetNewDoubleValue(newValue));}
if( command == UpdateCmd )
{ Detector->UpdateGeometry();}
}
+52
View File
@@ -0,0 +1,52 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// -------------------------------------------------------------------
// $Id: EventAction.cc,v 1.2 2008/01/25 20:49:24 sincerti Exp $
// -------------------------------------------------------------------
#include "EventAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
EventAction::EventAction(RunAction* run)
:Run(run)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
EventAction::~EventAction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void EventAction::BeginOfEventAction(const G4Event* /*evt*/)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void EventAction::EndOfEventAction(const G4Event* /*evt*/)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+323
View File
@@ -0,0 +1,323 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// -------------------------------------------------------------------
// $Id: PhysicsList.cc,v 1.4 2008/12/18 12:56:26 gunter Exp $
// -------------------------------------------------------------------
#include "PhysicsList.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
PhysicsList::PhysicsList(): G4VUserPhysicsList()
{
defaultCutValue = 1*micrometer;
cutForGamma = defaultCutValue;
cutForElectron = defaultCutValue;
cutForPositron = defaultCutValue;
cutForProton = defaultCutValue;
SetVerboseLevel(1);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
PhysicsList::~PhysicsList()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
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();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void PhysicsList::ConstructBosons()
{
// gamma
G4Gamma::GammaDefinition();
// optical photon
G4OpticalPhoton::OpticalPhotonDefinition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void PhysicsList::ConstructLeptons()
{
// leptons
G4Electron::ElectronDefinition();
G4Positron::PositronDefinition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void PhysicsList::ConstructBarions()
{
// barions
G4Proton::ProtonDefinition();
G4AntiProton::AntiProtonDefinition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void PhysicsList::ConstructProcess()
{
AddTransportation();
ConstructEM();
ConstructGeneral();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#include "G4PhotoElectricEffect.hh"
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4MultipleScattering.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
#include "G4MuIonisation.hh"
#include "G4MuBremsstrahlung.hh"
#include "G4MuPairProduction.hh"
#include "G4hMultipleScattering.hh"
#include "G4ionIonisation.hh"
#include "G4hIonisation.hh"
#include "G4StepLimiter.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void PhysicsList::ConstructEM()
{
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
G4String particleName = particle->GetParticleName();
if (particleName == "gamma") {
pmanager->AddDiscreteProcess(new G4PhotoElectricEffect);
pmanager->AddDiscreteProcess(new G4ComptonScattering);
pmanager->AddDiscreteProcess(new G4GammaConversion);
} else if (particleName == "e-") {
pmanager->AddProcess(new G4MultipleScattering, -1, 1, 1);
pmanager->AddProcess(new G4eIonisation, -1, 2, 2);
pmanager->AddProcess(new G4eBremsstrahlung, -1, 3, 3);
} else if (particleName == "e+") {
pmanager->AddProcess(new G4MultipleScattering, -1, 1, 1);
pmanager->AddProcess(new G4eIonisation, -1, 2, 2);
pmanager->AddProcess(new G4eBremsstrahlung, -1, 3, 3);
pmanager->AddProcess(new G4eplusAnnihilation, 0,-1, 4);
} else if( particleName == "mu+" ||
particleName == "mu-" ) {
pmanager->AddProcess(new G4hMultipleScattering,-1, 1, 1);
pmanager->AddProcess(new G4MuIonisation, -1, 2, 2);
pmanager->AddProcess(new G4MuBremsstrahlung, -1, 3, 3);
pmanager->AddProcess(new G4MuPairProduction, -1, 4, 4);
} else if (particleName == "alpha" ||
particleName == "He3" ||
particleName == "GenericIon") {
// ions with charge >= +2
pmanager->AddProcess(new G4hMultipleScattering,-1, 1, 1);
pmanager->AddProcess(new G4ionIonisation, -1, 2, 2);
} else if ((!particle->IsShortLived()) &&
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
//all others charged particles except geantino and short-lived
pmanager->AddProcess(new G4hMultipleScattering,-1, 1, 1);
pmanager->AddProcess(new G4hIonisation, -1, 2, 2);
pmanager->AddProcess(new G4StepLimiter(),-1,-1,3);
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void PhysicsList::ConstructGeneral()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void PhysicsList::SetCuts()
{
if (verboseLevel >0){
G4cout << "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(cutForGamma, "gamma");
SetCutValue(cutForElectron, "e-");
SetCutValue(cutForPositron, "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(cutForProton, "proton");
SetCutValue(cutForProton, "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::SetPositronLowLimit(G4double lowcut)
{
if (verboseLevel >0){
G4cout << "PhysicsList::SetCuts:";
G4cout << "Positron cut in energy: " << lowcut*MeV << " (MeV)" << G4endl;
}
G4cerr << "PhysicsList::SetPositronLowLimit: Not currently able to set Positron LowLimit." << G4endl;
G4Exception("Positron Low Limit: not implemented in PhysicsList");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void PhysicsList::SetProtonLowLimit(G4double lowcut)
{
if (verboseLevel >0){
G4cout << "PhysicsList::SetCuts:";
G4cout << "Proton cut in energy: " << lowcut*MeV << " (MeV)" << G4endl;
}
G4cerr << "PhysicsList::SetProtonLowLimit: Not currently able to set Proton LowLimit." << G4endl;
G4Exception("Proton Low Limit: not implemented in PhysicsList");
}
//....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();
cutForGamma = val;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void PhysicsList::SetElectronCut(G4double val)
{
// ResetCuts();
cutForElectron = val;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void PhysicsList::SetPositronCut(G4double val)
{
// ResetCuts();
cutForPositron = val;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void PhysicsList::SetProtonCut(G4double val)
{
//ResetCuts();
cutForProton = val;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+260
View File
@@ -0,0 +1,260 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// -------------------------------------------------------------------
// $Id: PrimaryGeneratorAction.cc,v 1.4 2008/03/01 09:04:29 sincerti Exp $
// -------------------------------------------------------------------
#include "PrimaryGeneratorAction.hh"
#include "PrimaryGeneratorMessenger.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* DC)
:detector(DC)
{
angleMax = 0.09;
emission =0;
G4int n_particle = 1;
particleGun = new G4ParticleGun(n_particle);
G4ParticleDefinition* particle =
G4ParticleTable::GetParticleTable()->FindParticle("proton");
particleGun->SetParticleDefinition(particle);
particleGun->SetParticleEnergy(3*MeV);
particleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
gunMessenger = new PrimaryGeneratorMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
delete particleGun;
delete gunMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
G4int numEvent;
numEvent=anEvent->GetEventID()+1;
G4double x0,y0,z0,theta,phi,xMom0,yMom0,zMom0,e0,de;
shoot=false;
x0=0; y0=0; z0=0; theta=0; phi=0; e0=0;
// Coefficient computation
if (emission==1)
{
detector->SetCoef();
shoot=true;
de = 0;
if (numEvent== 1) {theta = -0.00500; phi = -0.00500; de = -0.0050; }
if (numEvent== 2) {theta = -0.005/3; phi = -0.00500; de = -0.0050; }
if (numEvent== 3) {theta = 0.005/3; phi = -0.00500; de = -0.0050; }
if (numEvent== 4) {theta = 0.00500; phi = -0.00500; de = -0.0050; }
if (numEvent== 5) {theta = -0.00500; phi = -0.005/3; de = -0.0050; }
if (numEvent== 6) {theta = -0.005/3; phi = -0.005/3; de = -0.0050; }
if (numEvent== 7) {theta = 0.005/3; phi = -0.005/3; de = -0.0050; }
if (numEvent== 8) {theta = 0.00500; phi = -0.005/3; de = -0.0050; }
if (numEvent== 9) {theta = -0.00500; phi = 0.005/3; de = -0.0050; }
if (numEvent== 10) {theta = -0.005/3; phi = 0.005/3; de = -0.0050; }
if (numEvent== 11) {theta = 0.005/3; phi = 0.005/3; de = -0.0050; }
if (numEvent== 12) {theta = 0.00500; phi = 0.005/3; de = -0.0050; }
if (numEvent== 13) {theta = -0.00500; phi = 0.00500; de = -0.0050; }
if (numEvent== 14) {theta = -0.005/3; phi = 0.00500; de = -0.0050; }
if (numEvent== 15) {theta = 0.005/3; phi = 0.00500; de = -0.0050; }
if (numEvent== 16) {theta = 0.00500; phi = 0.00500; de = -0.0050; }
if (numEvent== 17) {theta = -0.00500; phi = -0.00500; de = 0.0050; }
if (numEvent== 18) {theta = -0.005/3; phi = -0.00500; de = 0.0050; }
if (numEvent== 19) {theta = 0.005/3; phi = -0.00500; de = 0.0050; }
if (numEvent== 20) {theta = 0.00500; phi = -0.00500; de = 0.0050; }
if (numEvent== 21) {theta = -0.00500; phi = -0.005/3; de = 0.0050; }
if (numEvent== 22) {theta = -0.005/3; phi = -0.005/3; de = 0.0050; }
if (numEvent== 23) {theta = 0.005/3; phi = -0.005/3; de = 0.0050; }
if (numEvent== 24) {theta = 0.00500; phi = -0.005/3; de = 0.0050; }
if (numEvent== 25) {theta = -0.00500; phi = 0.005/3; de = 0.0050; }
if (numEvent== 26) {theta = -0.005/3; phi = 0.005/3; de = 0.0050; }
if (numEvent== 27) {theta = 0.005/3; phi = 0.005/3; de = 0.0050; }
if (numEvent== 28) {theta = 0.00500; phi = 0.005/3; de = 0.0050; }
if (numEvent== 29) {theta = -0.00500; phi = 0.00500; de = 0.0050; }
if (numEvent== 30) {theta = -0.005/3; phi = 0.00500; de = 0.0050; }
if (numEvent== 31) {theta = 0.005/3; phi = 0.00500; de = 0.0050; }
if (numEvent== 32) {theta = 0.00500; phi = 0.00500; de = 0.0050; }
theta=theta*200*angleMax*1e-3;
phi=phi*200*angleMax*1e-3;
de=de/100;
e0 = 3*MeV + 2*de*3*MeV;
x0 = 0;
y0 = 0;
z0 = -8870*mm;
// triplet only
//z0 = -3230*mm;
G4float cte = 1 ;
G4float DE = 100*de;
phi = phi * 1000;
theta = theta * 1000;
FILE *myFile;
myFile=fopen ("results/matrix.txt","a");
fprintf(myFile,
"%e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e \n",
cte,
theta,
phi,
DE,
theta * theta,
theta * phi,
phi * phi,
theta * DE,
phi * DE,
theta * theta * theta,
theta * theta * phi,
theta * phi * phi,
phi * phi * phi,
theta * theta * DE,
theta * phi * DE,
phi * phi * DE,
theta * theta * theta * phi,
theta * theta * phi * phi,
theta * phi * phi * phi,
theta * theta * theta * DE,
theta * theta * phi * DE,
theta * phi * phi * DE,
phi * phi * phi * DE,
theta * theta * theta * phi * phi,
theta * theta * phi * phi * phi,
theta * theta * theta * phi * DE,
theta * theta * phi * phi * DE,
theta * phi * phi * phi * DE,
theta * theta * theta * phi * phi * phi,
theta * theta * theta * phi * phi * DE,
theta * theta * phi * phi * phi * DE,
theta * theta * theta * phi * phi * phi * DE
);
phi = phi / 1000;
theta = theta / 1000;
fclose (myFile);
} // end coefficient
// Full beam
if (emission==2)
{
shoot=false;
G4double aR, angle, rR;
aR = -1;
e0= G4RandGauss::shoot(3*MeV,5.0955e-5*MeV); // AIFIRA ENERGY RESOLUTION
while (aR < 0) aR = G4RandGauss::shoot(0.10e-3 , 0.06e-3/2.35) * rad; // old =0.08e-3 displacement
angle = G4UniformRand() * 2 * CLHEP::pi *rad;
theta = aR * std::cos(angle);
phi = aR * std::sin(angle);
rR = XYofAngle(aR);
x0 = rR*std::cos(angle);
y0 = rR*std::sin(angle);
x0 = G4RandGauss::shoot(x0,220/2.35) *micrometer;
theta = G4RandGauss::shoot(theta,0.03e-3/2.35);
y0 = G4RandGauss::shoot(y0,220/2.35) *micrometer;
phi = G4RandGauss::shoot(phi,0.03e-3/2.35);
z0 = (-9120+250)*mm; //position C0
if (std::sqrt(x0*x0+y0*y0)/micrometer<2000) shoot=true;
/*
xMom0 = std::sin(theta);
yMom0 = std::sin(phi);
zMom0 = std::cos(theta);
*/
} // end full beam
// shoot
if (shoot)
{
G4cout << "-> Event= " << numEvent<< ": X0(mm)= " << x0/mm << " X0(mm) = " << y0/mm << " Z0(m) = " << z0/m
<< " THETA(mrad)= " << theta/mrad << " PHI(mrad)= " << phi/mrad << " E0(MeV)= " << e0/MeV << G4endl;
xMom0 = std::sin(theta);
yMom0 = std::sin(phi);
zMom0 = std::sqrt(1.-xMom0*xMom0-yMom0*yMom0);
particleGun->SetParticleEnergy(e0);
particleGun->SetParticleMomentumDirection(G4ThreeVector(xMom0,yMom0,zMom0));
particleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
G4ParticleDefinition* particle=
G4ParticleTable::GetParticleTable()->FindParticle("proton");
particleGun->SetParticleDefinition(particle);
particleGun->GeneratePrimaryVertex(anEvent);
}
// end shoot
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void PrimaryGeneratorAction::SetEmission(G4int value)
{
emission = value;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double PrimaryGeneratorAction::XYofAngle(G4double angle)// returns position in micrometers
{
return std::pow(20000*angle, 13);
}
@@ -0,0 +1,68 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// -------------------------------------------------------------------
// $Id: PrimaryGeneratorMessenger.cc,v 1.2 2008/01/25 20:49:24 sincerti Exp $
// -------------------------------------------------------------------
#include "PrimaryGeneratorMessenger.hh"
#include "PrimaryGeneratorAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorMessenger::PrimaryGeneratorMessenger(
PrimaryGeneratorAction* Gun)
:Action(Gun)
{
gunDir = new G4UIdirectory("/beam/");
gunDir->SetGuidance("beam control");
emissionCmd = new G4UIcmdWithAnInteger("/beam/emission",this);
emissionCmd->SetGuidance("Select emission model.");
emissionCmd->SetParameterName("emission",false);
emissionCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger()
{
delete emissionCmd;
delete gunDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command,
G4String newValue)
{
if (command == emissionCmd)
{Action->SetEmission(emissionCmd->GetNewIntValue(newValue));}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+242
View File
@@ -0,0 +1,242 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// -------------------------------------------------------------------
// $Id: RunAction.cc,v 1.3 2008/04/10 12:02:57 sincerti Exp $
// -------------------------------------------------------------------
#include "G4SteppingManager.hh"
#include "G4Run.hh"
#include "G4Material.hh"
#include "G4UImanager.hh"
#include "G4ios.hh"
#include "G4UnitsTable.hh"
#include "Randomize.hh"
#include <iomanip>
#include <assert.h>
#include "RunAction.hh"
// MATRIX
#define MATRIX_BOUND_CHECK
#include "globals.hh"
#include <iostream>
#include "CLHEP/Matrix/Matrix.h"
#include "CLHEP/Matrix/Vector.h"
#include <fstream>
#include "G4ios.hh"
#include <fstream>
#include <vector>
#include <cmath>
using namespace std;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
RunAction::RunAction(DetectorConstruction* det)
:detector(det)
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
RunAction::~RunAction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void RunAction::BeginOfRunAction(const G4Run* /*aRun*/)
{
// Cleaning result files
system ("rm -rf ./results/x.txt");
system ("rm -rf ./results/y.txt");
system ("rm -rf ./results/theta.txt");
system ("rm -rf ./results/phi.txt");
system ("rm -rf ./results/image.txt");
system ("rm -rf ./results/matrix.txt");
system ("rm -rf ./results/profile.txt");
system ("rm -rf ./results/grid.txt");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void RunAction::EndOfRunAction(const G4Run* /*aRun*/)
{
if (detector->GetCoef()==1)
{
CLHEP::HepMatrix m,s;
m = CLHEP::HepMatrix(32,32);
s = CLHEP::HepMatrix(32,32);
CLHEP::HepVector v;
v = CLHEP::HepVector(32);
float aa,ab,ac,ad,ae,af,ag,ah,ai,aj;
float ba,bb,bc,bd,be,bf,bg,bh,bi,bj;
float ca,cb,cc,cd,ce,cf,cg,ch,ci,cj;
float da,db;
float vv;
// MATRIX READING
int ncols;
int nlines=1;
FILE * fp1 = fopen("results/matrix.txt","r");
while (1)
{
ncols = fscanf(fp1,
"%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f",
&aa,&ab,&ac,&ad,&ae,&af,&ag,&ah,&ai,&aj,
&ba,&bb,&bc,&bd,&be,&bf,&bg,&bh,&bi,&bj,
&ca,&cb,&cc,&cd,&ce,&cf,&cg,&ch,&ci,&cj,
&da,&db
);
if (ncols<0) break;
if (nlines>32) G4Exception("Try to read more than 32 lines in matrix file !");
m(nlines,1)=aa;
m(nlines,2)=ab;
m(nlines,3)=ac;
m(nlines,4)=ad;
m(nlines,5)=ae;
m(nlines,6)=af;
m(nlines,7)=ag;
m(nlines,8)=ah;
m(nlines,9)=ai;
m(nlines,10)=aj;
m(nlines,11)=ba;
m(nlines,12)=bb;
m(nlines,13)=bc;
m(nlines,14)=bd;
m(nlines,15)=be;
m(nlines,16)=bf;
m(nlines,17)=bg;
m(nlines,18)=bh;
m(nlines,19)=bi;
m(nlines,20)=bj;
m(nlines,21)=ca;
m(nlines,22)=cb;
m(nlines,23)=cc;
m(nlines,24)=cd;
m(nlines,25)=ce;
m(nlines,26)=cf;
m(nlines,27)=cg;
m(nlines,28)=ch;
m(nlines,29)=ci;
m(nlines,30)=cj;
m(nlines,31)=da;
m(nlines,32)=db;
nlines++;
}
fclose(fp1);
// VECTOR READING
G4cout << G4endl;
G4cout << "===> NANOBEAM LINE INTRINSIC ABERRATION COEFFICIENTS (units of micrometer and mrad) :" << G4endl;
G4cout << G4endl;
int inv;
nlines = 1;
FILE * fp2 = fopen("results/x.txt","r");
while (1)
{
ncols = fscanf(fp2,"%f", &vv);
if (ncols<0) break;
v(nlines)=vv;
nlines++;
}
fclose(fp2);
m.invert(inv);
CLHEP::HepVector seb(32,0);
seb=m*v;
CLHEP::HepVector b;
b=seb.sub(2,2); G4cout << "<x|theta>=" << b << G4endl;
b=seb.sub(8,8); G4cout << "<x|theta*delta>=" << b << G4endl;
b=seb.sub(10,10); G4cout << "<x|theta^3>=" << b << G4endl;
b=seb.sub(12,12); G4cout << "<x|theta*phi^2>=" << b << G4endl;
m.invert(inv);
nlines = 1;
FILE * fp3 = fopen("results/theta.txt","r");
while (1)
{
ncols = fscanf(fp3,"%f", &vv);
if (ncols<0) break;
v(nlines)=vv;
nlines++;
}
fclose(fp3);
m.invert(inv);
seb = m*v;
m.invert(inv);
b=seb.sub(2,2); G4cout << "<x|x>=" << b << G4endl;
nlines = 1;
FILE * fp4 = fopen("results/y.txt","r");
while (1)
{
ncols = fscanf(fp4,"%f", &vv);
if (ncols<0) break;
v(nlines)=vv;
nlines++;
}
fclose(fp4);
m.invert(inv);
seb=m*v;
b=seb.sub(3,3); G4cout << "<y|phi>=" << b << G4endl;
b=seb.sub(9,9); G4cout << "<y|phi*delta>=" << b << G4endl;
b=seb.sub(11,11); G4cout << "<y|theta^2*phi>=" << b << G4endl;
b=seb.sub(13,13); G4cout << "<y|phi^3>=" << b << G4endl;
m.invert(inv);
nlines = 1;
FILE * fp5 = fopen("results/phi.txt","r");
while (1)
{
ncols = fscanf(fp5,"%f", &vv);
if (ncols<0) break;
v(nlines)=vv;
nlines++;
}
fclose(fp5);
m.invert(inv);
seb = m*v;
m.invert(inv);
b=seb.sub(3,3); G4cout << "<y|y>=" << b << G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+148
View File
@@ -0,0 +1,148 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// -------------------------------------------------------------------
// $Id: SteppingAction.cc,v 1.2 2008/01/25 20:49:24 sincerti Exp $
// -------------------------------------------------------------------
#include "SteppingAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
SteppingAction::SteppingAction(RunAction* run,DetectorConstruction* det,PrimaryGeneratorAction* pri)
:Run(run),Detector(det),Primary(pri)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
SteppingAction::~SteppingAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void SteppingAction::UserSteppingAction(const G4Step* s)
{
if ( (s->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "proton")
/*
// for doublet
&& (s->GetTrack()->GetPosition().z()>-3230.2)
&& (s->GetTrack()->GetPosition().z()<-3229.8)
*/
// for triplet and whole line
&& (s->GetTrack()->GetPosition().z()>249.99999)
&& (s->GetTrack()->GetPosition().z()<250.00001)
&& (s->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "Vol")
&& (s->GetPostStepPoint()->GetPhysicalVolume()->GetName() == "World")
)
{
xIn = s->GetTrack()->GetPosition().x();
yIn = s->GetTrack()->GetPosition().y();
zIn = s->GetTrack()->GetPosition().z();
E = s->GetTrack()->GetKineticEnergy();
G4ThreeVector angleIn;
angleIn = s->GetTrack()->GetMomentumDirection();
thetaIn = std::asin(angleIn[0]/std::sqrt(angleIn[0]*angleIn[0]+angleIn[1]*angleIn[1]+angleIn[2]*angleIn[2]));
phiIn = std::asin(angleIn[1]/std::sqrt(angleIn[0]*angleIn[0]+angleIn[1]*angleIn[1]+angleIn[2]*angleIn[2]));
G4cout << " =>IMAGE : X(microns)=" << xIn/micrometer <<" Y(microns)="<< yIn/micrometer << " THETA(mrad)=" << (thetaIn/mrad) << " PHI(mrad)=" << (phiIn/mrad) << G4endl;
G4cout << G4endl;
FILE *myFile1;
myFile1=fopen ("results/x.txt","a");
fprintf(myFile1,"%e \n",xIn*1000);
fclose (myFile1);
FILE *myFile2;
myFile2=fopen ("results/y.txt","a");
fprintf(myFile2,"%e \n",yIn*1000);
fclose (myFile2);
FILE *myFile3;
myFile3=fopen ("results/theta.txt","a");
fprintf(myFile3,"%e \n",thetaIn*1000);
fclose (myFile3);
FILE *myFile4;
myFile4=fopen ("results/phi.txt","a");
fprintf(myFile4,"%e \n",phiIn*1000);
fclose (myFile4);
FILE *myFile5;
myFile5=fopen ("results/image.txt","a");
fprintf(myFile5,"%e %e\n",xIn*1000, yIn*1000);
fclose (myFile5);
}
if (Detector->GetProfile()==1)
{
if (
(s->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "proton")
&& (s->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "Vol")
&& (s->GetPostStepPoint()->GetPhysicalVolume()->GetName() == "Vol") )
{
xIn = s->GetTrack()->GetPosition().x();
yIn = s->GetTrack()->GetPosition().y();
zIn = s->GetTrack()->GetPosition().z();
FILE *myFile6;
myFile6=fopen ("results/profile.txt","a");
fprintf(myFile6,"%e %e %e\n",xIn*1000, yIn*1000, zIn);
fclose (myFile6);
}
}
if (Detector->GetGrid()==1)
{
if (
(s->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "proton")
&& (s->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "ControlVol_GridShadow")
&& (s->GetPostStepPoint()->GetPhysicalVolume()->GetName() == "World") )
{
xIn = s->GetTrack()->GetPosition().x();
yIn = s->GetTrack()->GetPosition().y();
E = s->GetTrack()->GetKineticEnergy();
FILE *myFile7;
myFile7=fopen ("results/grid.txt","a");
fprintf(myFile7,"%e %e %e\n",xIn*1000, yIn*1000, E);
fclose (myFile7);
}
}
// end
}
+171
View File
@@ -0,0 +1,171 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// -------------------------------------------------------------------
// $Id: SteppingVerbose.cc,v 1.2 2008/01/25 20:49:24 sincerti Exp $
// -------------------------------------------------------------------
#include "SteppingVerbose.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
SteppingVerbose::SteppingVerbose()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
SteppingVerbose::~SteppingVerbose()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void SteppingVerbose::StepInfo()
{
CopyState();
G4int prec = G4cout.precision(3);
if( verboseLevel >= 1 ){
if( verboseLevel >= 4 ) VerboseTrack();
if( verboseLevel >= 3 ){
G4cout << G4endl;
G4cout << std::setw( 5) << "#Step#" << " "
<< std::setw( 6) << "X" << " "
<< std::setw( 6) << "Y" << " "
<< std::setw( 6) << "Z" << " "
<< std::setw( 9) << "KineE" << " "
<< std::setw( 9) << "dEStep" << " "
<< std::setw(10) << "StepLeng"
<< std::setw(10) << "TrakLeng"
<< std::setw(10) << "NextVolu"
<< std::setw(10) << "Process" << G4endl;
}
G4cout << std::setw( 5) << fTrack->GetCurrentStepNumber() << " "
<< std::setw( 6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
<< std::setw( 6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
<< std::setw( 6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
<< std::setw( 6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
<< std::setw( 6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
<< std::setw( 6) << G4BestUnit(fStep->GetStepLength(),"Length")
<< std::setw( 6) << G4BestUnit(fTrack->GetTrackLength(),"Length");
// if( fStepStatus != fWorldBoundary){
if( fTrack->GetNextVolume() != 0 ) {
G4cout << std::setw(10) << fTrack->GetNextVolume()->GetName();
} else {
G4cout << std::setw(10) << "OutOfWorld";
}
if(fStep->GetPostStepPoint()->GetProcessDefinedStep() != NULL){
G4cout << std::setw(10) << fStep->GetPostStepPoint()->GetProcessDefinedStep()
->GetProcessName();
} else {
G4cout << "User Limit";
}
G4cout << G4endl;
if( verboseLevel == 2 ){
G4int tN2ndariesTot = fN2ndariesAtRestDoIt +
fN2ndariesAlongStepDoIt +
fN2ndariesPostStepDoIt;
if(tN2ndariesTot>0){
G4cout << " :----- List of 2ndaries - "
<< "#SpawnInStep=" << std::setw(3) << tN2ndariesTot
<< "(Rest=" << std::setw(2) << fN2ndariesAtRestDoIt
<< ",Along=" << std::setw(2) << fN2ndariesAlongStepDoIt
<< ",Post=" << std::setw(2) << fN2ndariesPostStepDoIt
<< "), "
<< "#SpawnTotal=" << std::setw(3) << (*fSecondary).size()
<< " ---------------"
<< G4endl;
for(size_t lp1=(*fSecondary).size()-tN2ndariesTot;
lp1<(*fSecondary).size(); lp1++){
G4cout << " : "
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetPosition().x(),"Length")
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetPosition().y(),"Length")
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetPosition().z(),"Length")
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(),"Energy")
<< std::setw(10)
<< (*fSecondary)[lp1]->GetDefinition()->GetParticleName();
G4cout << G4endl;
}
G4cout << " :-----------------------------"
<< "----------------------------------"
<< "-- EndOf2ndaries Info ---------------"
<< G4endl;
}
}
}
G4cout.precision(prec);
//G4cout<< "exit SteppingVerbose::StepInfo " <<G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void SteppingVerbose::TrackingStarted()
{
CopyState();
G4int prec = G4cout.precision(3);
if( verboseLevel > 0 ){
G4cout << std::setw( 5) << "Step#" << " "
<< std::setw( 6) << "X" << " "
<< std::setw( 6) << "Y" << " "
<< std::setw( 6) << "Z" << " "
<< std::setw( 9) << "KineE" << " "
<< std::setw( 9) << "dEStep" << " "
<< std::setw(10) << "StepLeng"
<< std::setw(10) << "TrakLeng"
<< std::setw(10) << "NextVolu"
<< std::setw(10) << "Process" << G4endl;
G4cout << std::setw( 5) << fTrack->GetCurrentStepNumber() << " "
<< std::setw( 6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
<< std::setw( 6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
<< std::setw( 6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
<< std::setw( 6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
<< std::setw( 6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
<< std::setw( 6) << G4BestUnit(fStep->GetStepLength(),"Length")
<< std::setw( 6) << G4BestUnit(fTrack->GetTrackLength(),"Length");
if(fTrack->GetNextVolume()){
G4cout << std::setw(10) << fTrack->GetNextVolume()->GetName() << " ";
} else {
G4cout << std::setw(10) << "OutOfWorld" << " ";
}
G4cout << std::setw(10) << "initStep" << G4endl;
}
G4cout.precision(prec);
G4cout<< "exit SteppingVerbose::TrackingStarted() " <<G4endl;
}
+532
View File
@@ -0,0 +1,532 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// -------------------------------------------------------------------
// $Id: TabulatedField3D.cc,v 1.2 2008/01/25 20:49:24 sincerti Exp $
// -------------------------------------------------------------------
#include "TabulatedField3D.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
TabulatedField3D::TabulatedField3D(G4float gr1, G4float gr2, G4float gr3, G4float gr4, G4int choiceModel)
{
G4cout << " ********************** " << G4endl;
G4cout << " **** CONFIGURATION *** " << G4endl;
G4cout << " ********************** " << G4endl;
G4cout<< G4endl;
G4cout << "=====> You have selected :" << G4endl;
if (choiceModel==1) G4cout<< "-> Square quadrupole field"<<G4endl;
if (choiceModel==2) G4cout<< "-> 3D quadrupole field"<<G4endl;
if (choiceModel==3) G4cout<< "-> Enge quadrupole field"<<G4endl;
G4cout << " G1 (T/m) = "<< gr1 << G4endl;
G4cout << " G2 (T/m) = "<< gr2 << G4endl;
G4cout << " G3 (T/m) = "<< gr3 << G4endl;
G4cout << " G4 (T/m) = "<< gr4 << G4endl;
gradient1 = gr1;
gradient2 = gr2;
gradient3 = gr3;
gradient4 = gr4;
model = choiceModel;
if (model==2)
{
const char * filename ="OM50.grid";
double lenUnit= mm;
G4cout << "\n-----------------------------------------------------------"
<< "\n 3D Magnetic field from OPERA software "
<< "\n-----------------------------------------------------------";
G4cout << "\n ---> " "Reading the field grid from " << filename << " ... " << endl;
ifstream file( filename ); // Open the file for reading.
// Read table dimensions
file >> nx >> ny >> nz; // Note dodgy order
G4cout << " [ Number of values x,y,z: "
<< nx << " " << ny << " " << nz << " ] "
<< endl;
// Set up storage space for table
xField.resize( nx );
yField.resize( nx );
zField.resize( nx );
int ix, iy, iz;
for (ix=0; ix<nx; ix++) {
xField[ix].resize(ny);
yField[ix].resize(ny);
zField[ix].resize(ny);
for (iy=0; iy<ny; iy++) {
xField[ix][iy].resize(nz);
yField[ix][iy].resize(nz);
zField[ix][iy].resize(nz);
}
}
// Read in the data
double xval,yval,zval,bx,by,bz;
double permeability; // Not used in this example.
for (ix=0; ix<nx; ix++) {
for (iy=0; iy<ny; iy++) {
for (iz=0; iz<nz; iz++) {
file >> xval >> yval >> zval >> bx >> by >> bz >> permeability;
if ( ix==0 && iy==0 && iz==0 ) {
minx = xval * lenUnit;
miny = yval * lenUnit;
minz = zval * lenUnit;
}
xField[ix][iy][iz] = bx ;
yField[ix][iy][iz] = by ;
zField[ix][iy][iz] = bz ;
}
}
}
file.close();
maxx = xval * lenUnit;
maxy = yval * lenUnit;
maxz = zval * lenUnit;
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: "
<< minx/cm << " " << miny/cm << " " << minz/cm << " cm "
<< "\n ---> Max values x,y,z: "
<< maxx/cm << " " << maxy/cm << " " << maxz/cm << " cm " << endl;
dx = maxx - minx;
dy = maxy - miny;
dz = maxz - minz;
G4cout << "\n ---> Dif values x,y,z (range): "
<< dx/cm << " " << dy/cm << " " << dz/cm << " cm in z "
<< "\n-----------------------------------------------------------" << endl;
// Table normalization
for (ix=0; ix<nx; ix++)
{
for (iy=0; iy<ny; iy++)
{
for (iz=0; iz<nz; iz++)
{
xField[ix][iy][iz] = (xField[ix][iy][iz]/197.736);
yField[ix][iy][iz] = (yField[ix][iy][iz]/197.736);
zField[ix][iy][iz] = (zField[ix][iy][iz]/197.736);
}
}
}
} // model==2
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void TabulatedField3D::GetFieldValue(const double point[4],
double *Bfield ) const
{
G4double coef, G0;
G0 = 0;
coef=1; //protons
//coef=2; // alphas
//******************************************************************
// MAP
if (model==2)
{
Bfield[0] = 0.0;
Bfield[1] = 0.0;
Bfield[2] = 0.0;
Bfield[3] = 0.0;
Bfield[4] = 0.0;
Bfield[5] = 0.0;
double x = point[0];
double y = point[1];
double z = point[2];
G4int quad;
G4double gradient[5];
gradient[0]=gradient1*(tesla/m)/coef;
gradient[1]=gradient2*(tesla/m)/coef;
gradient[2]=gradient3*(tesla/m)/coef;
gradient[3]=gradient4*(tesla/m)/coef;
gradient[4]=-gradient3*(tesla/m)/coef;
for (quad=0; quad<=4; quad++)
{
if ((quad+1)==1) {z = point[2] + 3720 * mm;}
if ((quad+1)==2) {z = point[2] + 3580 * mm;}
if ((quad+1)==3) {z = point[2] + 330 * mm;}
if ((quad+1)==4) {z = point[2] + 190 * mm;}
if ((quad+1)==5) {z = point[2] + 50 * mm;}
// Check that the point is within the defined region
if
(
x>=minx && x<=maxx &&
y>=miny && y<=maxy &&
z>=minz && z<=maxz
)
{
// Position of given point within region, normalized to the range
// [0,1]
double xfraction = (x - minx) / dx;
double yfraction = (y - miny) / dy;
double zfraction = (z - minz) / dz;
// Need addresses of these to pass to modf below.
// modf uses its second argument as an OUTPUT argument.
double xdindex, ydindex, zdindex;
// Position of the point within the cuboid defined by the
// nearest surrounding tabulated points
double xlocal = ( std::modf(xfraction*(nx-1), &xdindex));
double ylocal = ( std::modf(yfraction*(ny-1), &ydindex));
double zlocal = ( std::modf(zfraction*(nz-1), &zdindex));
// 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);
// Interpolated field
Bfield[0] =
(xField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
xField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
xField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
xField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
xField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
xField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
xField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
xField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal)*gradient[quad]
+ Bfield[0];
Bfield[1] =
(yField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
yField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
yField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
yField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
yField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
yField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
yField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
yField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal)*gradient[quad]
+ Bfield[1];
Bfield[2] =
(zField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
zField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
zField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
zField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
zField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
zField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
zField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
zField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal)*gradient[quad]
+ Bfield[2];
}
} // loop on quads
} //end MAP
//******************************************************************
// SQUARE
if (model==1)
{
Bfield[0] = 0.0;
Bfield[1] = 0.0;
Bfield[2] = 0.0;
Bfield[3] = 0.0;
Bfield[4] = 0.0;
Bfield[5] = 0.0;
// Field components
G4double Bx = 0;
G4double By = 0;
G4double Bz = 0;
G4double x = point[0];
G4double y = point[1];
G4double z = point[2];
if (z>=-3770*mm & z<=-3670*mm) G0 = (gradient1/coef)* tesla/m;
if (z>=-3630*mm & z<=-3530*mm) G0 = (gradient2/coef)* tesla/m;
if (z>=-380*mm & z<=-280*mm) G0 = (gradient3/coef)* tesla/m;
if (z>=-240*mm & z<=-140*mm) G0 = (gradient4/coef)* tesla/m;
if (z>=-100*mm & z<=0*mm) G0 = (-gradient3/coef)* tesla/m;
Bx = y*G0;
By = x*G0;
Bz = 0;
Bfield[0] = Bx;
Bfield[1] = By;
Bfield[2] = Bz;
}
// end SQUARE
//******************************************************************
// ENGE
if (model==3)
{
// X POSITION OF FIRST QUADRUPOLE
//G4double lineX = 0*mm;
// Z POSITION OF FIRST QUADRUPOLE
G4double lineZ = -3720*mm;
// QUADRUPOLE HALF LENGTH
//G4double quadHalfLength = 50*mm;
// QUADRUPOLE CENTER COORDINATES
G4double zoprime;
G4double Grad1, Grad2, Grad3, Grad4, Grad5;
Grad1=gradient1;
Grad2=gradient2;
Grad3=gradient3;
Grad4=gradient4;
Grad5=-Grad3;
Bfield[0] = 0.0;
Bfield[1] = 0.0;
Bfield[2] = 0.0;
Bfield[3] = 0.0;
Bfield[4] = 0.0;
Bfield[5] = 0.0;
double x = point[0];
double y = point[1];
double z = point[2];
if ( z>=-3900*mm & z<-3470*mm || z>=-490*mm & z<100*mm )
{
G4double Bx=0;
G4double By=0;
G4double Bz=0;
// FRINGING FILED CONSTANTS
G4double c0[5], c1[5], c2[5], z1[5], z2[5], a0[5], gradient[5];
// DOUBLET***************
// QUADRUPOLE 1
c0[0] = -10.; // Ci are constants in the; Pn(z)=C0+C1*s+C2*s^2
c1[0] = 3.08874;
c2[0] = -0.00618654;
z1[0] = 28.6834*mm; //Fringing field lower limit
z2[0] = z1[0]+50*mm; //Fringing field upper limit
a0[0] = 7.5*mm; //Bore Radius
gradient[0] =Grad1*(tesla/m)/coef;
// QUADRUPOLE 2
c0[1] = -10.; // Ci are constants in the; Pn(z)=C0+C1*s+C2*s^2
c1[1] = 3.08874;
c2[1] = -0.00618654;
z1[1] = 28.6834*mm; //Fringing field lower limit
z2[1] = z1[1]+50*mm; //Fringing field upper limit
a0[1] = 7.5*mm; //Bore Radius
gradient[1] =Grad2*(tesla/m)/coef;
// TRIPLET**********
// QUADRUPOLE 3
c0[2] = -10.; // Ci are constants in the; Pn(z)=C0+C1*s+C2*s^2
c1[2] = 3.08874;
c2[2] = -0.00618654;
z1[2] = 28.6834*mm; //Fringing field lower limit
z2[2] = z1[2]+50*mm; //Fringing field upper limit
a0[2] = 7.5*mm; //Bore Radius
gradient[2] = Grad3*(tesla/m)/coef;
// QUADRUPOLE 4
c0[3] = -10.; // Ci are constants in the; Pn(z)=C0+C1*s+C2*s^2
c1[3] = 3.08874;
c2[3] = -0.00618654;
z1[3] = 28.6834*mm; //Fringing field lower limit
z2[3] = z1[3]+50*mm; //Fringing field upper limit
a0[3] = 7.5*mm; //Bore Radius
gradient[3] = Grad4*(tesla/m)/coef;
// QUADRUPOLE 5
c0[4] = -10.; // Ci are constants in the; Pn(z)=C0+C1*s+C2*s^2
c1[4] = 3.08874;
c2[4] = -0.00618654;
z1[4] = 28.6834*mm; //Fringing field lower limit
z2[4] = z1[4]+50*mm; //Fringing field upper limit
a0[4] = 7.5*mm; //Bore Radius
gradient[4] = Grad5*(tesla/m)/coef;
// FIELD CREATED BY A QUADRUPOLE IN ITS LOCAL FRAME
G4double Bx_local,By_local,Bz_local;
Bx_local = 0; By_local = 0; Bz_local = 0;
// FIELD CREATED BY A QUADRUPOOLE IN WORLD FRAME
G4double Bx_quad,By_quad,Bz_quad;
Bx_quad = 0; By_quad=0; Bz_quad=0;
// QUADRUPOLE FRAME
G4double x_local,y_local,z_local;
x_local= 0; y_local=0; z_local=0;
G4double s = 0; // For Enges formula
G4double G0, G1, G2, G3; // For Enges formula
G4double K0, K1, K2, K3; // For Enges formula
G4double P0, P1, P2, P3, cte; // For Enges formula
K0=0;
K1=0;
K2=0;
K3=0;
P0=0;
P1=0;
P2=0;
P3=0;
G0=0;
G1=0;
G2=0;
G3=0;
cte=0;
for (G4int i=0;i<5; i++) // LOOP ON MAGNETS
{
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
{
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
{
G0=0;
G1=0;
G2=0;
G3=0;
}
if ( (z_local>=-z1[i]) & (z_local<=z1[i]) ) // inside the quadrupole but outside the fringefield
{
G0=gradient[i];
G1=0;
G2=0;
G3=0;
}
if ( ((z_local>=-z2[i]) & (z_local<-z1[i])) || ((z_local>z1[i]) & (z_local<=z2[i])) ) // Inside the fringefield
{
s = ( z_local - z1[i]) / a0[i]; // se (8)
if (z_local<-z1[i]) s = ( - z_local - z1[i]) / a0[i]; // se (9) p1397 Incerti et.al.
P0 = c0[i]+c1[i]*s+c2[i]*s*s;
P1 = c1[i]/a0[i]+2*c2[i]*(z_local-z1[i])/a0[i]/a0[i]; //dP/dz
if (z_local<-z1[i]) P1 = -c1[i]/a0[i]+2*c2[i]*(z_local+z1[i])/a0[i]/a0[i]; // --"--
P2 = 2*c2[i]/a0[i]/a0[i]; // d2P/dz2
P3 = 0; // d3P/dw3 ??
cte = 1 + std::exp(c0[i]); // (1+e^c0)
K1 = -cte*P1*std::exp(P0)/( (1+std::exp(P0))*(1+std::exp(P0)) ); // se (11) p1397 Incerti et.al.
K2 = -cte*std::exp(P0)*( // se (12) p1397 Incerti et.al.
P2/( (1+std::exp(P0))*(1+std::exp(P0)) )
+2*P1*K1/(1+std::exp(P0))/cte
+P1*P1/(1+std::exp(P0))/(1+std::exp(P0))
);
K3 = -cte*std::exp(P0)*( // se (13) p1397 Incerti et.al
(3*P2*P1+P1*P1*P1)/(1+std::exp(P0))/(1+std::exp(P0))
+4*K1*(P1*P1+P2)/(1+std::exp(P0))/cte
+2*P1*(K1*K1/cte/cte+K2/(1+std::exp(P0))/cte)
);
G0 = gradient[i]*cte/(1+std::exp(P0)); // G = G0*K(z) , se (7) p1397 Incerti et.al
G1 = gradient[i]*K1; // dG/dz
G2 = gradient[i]*K2; // d2G/dz2
G3 = gradient[i]*K3; // d3G/dz3
}
Bx_local = y_local*(G0-(1./12)*(3*x_local*x_local+y_local*y_local)*G2); // se (4) p1396 Incerti et.al
By_local = x_local*(G0-(1./12)*(3*y_local*y_local+x_local*x_local)*G2); // se (5) p1396 Incerti et.al
Bz_local = x_local*y_local*(G1-(1./12)*(x_local*x_local+y_local*y_local)*G3); // se (6) p1396 Incerti et.al
// TOTAL MAGNETIC FIELD
Bx = Bx + Bx_local ;
By = By + By_local ;
Bz = Bz + Bz_local ;
} // LOOP ON QUADRUPOLES
Bfield[0] = Bx;
Bfield[1] = By;
Bfield[2] = Bz;
}
} // end ENGE
}
+57
View File
@@ -0,0 +1,57 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// -------------------------------------------------------------------
// $Id: TrackingAction.cc,v 1.2 2008/01/25 20:49:24 sincerti Exp $
// -------------------------------------------------------------------
#include "G4TrackingManager.hh"
#include "G4Track.hh"
#include "TrackingAction.hh"
#include "RunAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
TrackingAction::TrackingAction(RunAction* run)
:Run(run)
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void TrackingAction::PostUserTrackingAction(const G4Track*)
{
}