Import Geant4 10.4.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2017-06-30 10:49:55 +02:00
parent 3a5407696b
commit 1a1316fea4
2180 changed files with 237880 additions and 59109 deletions
+397
View File
@@ -0,0 +1,397 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#include "G4Channeling.hh"
#include "Randomize.hh"
#include "G4ChannelingTrackData.hh"
#include "G4TouchableHistory.hh"
#include "G4SystemOfUnits.hh"
#include "G4LambdacPlus.hh"
G4Channeling::G4Channeling():
G4VDiscreteProcess("channeling"),
fChannelingID(-1),
fTimeStepMin(0.),
fTimeStepMax(0.),
fTransverseVariationMax(2.E-2 * CLHEP::angstrom),
k010(G4ThreeVector(0.,1.,0.)){
fChannelingID = G4PhysicsModelCatalog::GetIndex("channeling");
if(fChannelingID == -1){
fChannelingID = G4PhysicsModelCatalog::Register("channeling");
}
fSpin = G4ThreeVector(0.,0.,0.);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4Channeling::~G4Channeling(){;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ChannelingTrackData* G4Channeling::GetTrackData(const G4Track& aTrack){
G4ChannelingTrackData* trackdata =
(G4ChannelingTrackData*)(aTrack.GetAuxiliaryTrackInformation(fChannelingID));
if(trackdata == nullptr){
trackdata = new G4ChannelingTrackData();
aTrack.SetAuxiliaryTrackInformation(fChannelingID,trackdata);
}
return trackdata;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4Channeling::GetEF(const G4Track& aTrack,
G4ThreeVector& pos,
G4ThreeVector& out){
out = G4ThreeVector((GetMatData(aTrack)->GetEFX()->GetEC(pos)),
(GetMatData(aTrack)->GetEFY()->GetEC(pos)),
0.);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4Channeling::PosToLattice(G4StepPoint* step,G4ThreeVector& pos){
G4TouchableHistory* theTouchable = (G4TouchableHistory*)(step->GetTouchable());
pos -= theTouchable->GetTranslation();
pos = ((*theTouchable->GetRotation()).inverse())(pos);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4bool G4Channeling::UpdateParameters(const G4Track& aTrack){
G4LogicalCrystalVolume* aLCV = (G4LogicalCrystalVolume*)(aTrack.GetVolume()->GetLogicalVolume());
G4StepPoint* postStepPoint = aTrack.GetStep()->GetPostStepPoint();
G4StepPoint* preStepPoint = aTrack.GetStep()->GetPreStepPoint();
G4ThreeVector posPost = postStepPoint->GetPosition();
aLCV->RotateToLattice(posPost);
G4ThreeVector posPre = preStepPoint->GetPosition();
aLCV->RotateToLattice(posPre);
G4double integrationLimit = fabs(posPost.z() - posPre.z());
if(integrationLimit > 0.){
//----------------------------------------
// Check if the crystal is bent
//----------------------------------------
G4bool isBent = GetMatData(aTrack)->IsBent();
//----------------------------------------
// Get the momentum in the world reference
// frame and rotate to the solid reference frame
//----------------------------------------
G4TouchableHistory* theTouchable = (G4TouchableHistory*)(preStepPoint->GetTouchable());
G4ThreeVector momWorld = aTrack.GetStep()->GetPreStepPoint()->GetMomentum();
G4ThreeVector mom = (*theTouchable->GetRotation())(momWorld);
//----------------------------------------
// Get the momentum in the solid reference
// frame and rotate to the crystal reference frame
//----------------------------------------
aLCV->RotateToLattice(mom);
//----------------------------------------
// Get the momentum in the crystal reference
// frame and rotate to the reference frame
// solidal to the bent planes
//----------------------------------------
if(isBent){
PosToLattice(preStepPoint,posPre);
G4ThreeVector axis010 = (*theTouchable->GetRotation())(k010);
mom.rotate(axis010,-posPre.z()/GetMatData(aTrack)->GetBR(posPre).x());
}
//----------------------------------------
// Take the position stored in the track data.
// If the particle enters the crystal,
// the position in the channel is randomly
// generated using a uniform distribution
//----------------------------------------
G4ThreeVector pos;
if(GetTrackData(aTrack)->GetPosCh().x() == DBL_MAX){
G4double posX = G4UniformRand() * GetMatData(aTrack)->GetPot()->GetIntSp(0);
G4double posY = G4UniformRand() * GetMatData(aTrack)->GetPot()->GetIntSp(1);
pos = G4ThreeVector(posX,posY,0.);
}
else{
pos = GetTrackData(aTrack)->GetPosCh();
}
G4double step=0., stepTot=0.;
G4double nud =0., eld =0.;
G4double efx =0., efy =0.;
G4double nud_temp =0., eld_temp =0.;
G4double beta = aTrack.GetVelocity()/CLHEP::c_light;
G4double Z = GetParticleDefinition(aTrack)->GetPDGCharge();
const G4double oneSixth = 1./6.;
G4ThreeVector posk1,posk2,posk3,posk4,posk5,posk6;
G4ThreeVector momk1,momk2,momk3,momk4,momk5,momk6;
G4ThreeVector pos_temp, efxy;
do{
//----------------------------------------
// Limit the variable step length for the
// integration via the selected algorithm
// and update variables for the integration
//----------------------------------------
UpdateIntegrationStep(aTrack,mom,step);
if(step + stepTot > integrationLimit){
step = integrationLimit - stepTot;
}
//----------------------------------------
// Function integration algorithm
// 4th Order Runge-Kutta
//----------------------------------------
GetEF(aTrack,pos,efxy);
posk1 = step / mom.z() * mom;
momk1 = step / beta * Z * efxy;
if(isBent) momk1.setX(momk1.x() - step * mom.z() * beta / (GetMatData(aTrack)->GetBR(pos)).x());
GetEF(aTrack,pos_temp = pos + posk1 * 0.5,efxy);
posk2 = step / mom.z() * (mom + momk1 * 0.5);
momk2 = step / beta * Z * efxy;
if(isBent) momk2.setX(momk2.x() - step * mom.z() * beta / (GetMatData(aTrack)->GetBR(pos_temp)).x());
GetEF(aTrack,pos_temp = pos + posk2 * 0.5,efxy);
posk3 = step / mom.z() * (mom + momk2 * 0.5);
momk3 = step / beta * Z * efxy;
if(isBent) momk3.setX(momk3.x() - step * mom.z() * beta / (GetMatData(aTrack)->GetBR(pos_temp)).x());
GetEF(aTrack,pos_temp = pos + posk3,efxy);
posk4 = step / mom.z() * (mom + momk3);
momk4 = step / beta * Z * efxy;
if(isBent) momk4.setX(momk4.x() - step * mom.z() * beta / (GetMatData(aTrack)->GetBR(pos_temp)).x());
pos = pos + oneSixth * (posk1 + 2.*posk2 + 2.*posk3 + posk4);
mom = mom + oneSixth * (momk1 + 2.*momk2 + 2.*momk3 + momk4);
//----------------------------------------
// Function integration algorithm
// 2th Order Velocity-Verlet
//----------------------------------------
/*
GetEF(aTrack,pos,efxy);
posk1 = pos + (step * 0.5 / mom.z()) * mom;
//momk1 = mom + step * 0.5 / betaZ * efxy;
momk1 = mom;
if(isBent) momk1.setX(momk1.x() - step * 0.5 * mom.z() * beta / (GetMatData(aTrack)->GetBR(pos)).x());
GetEF(aTrack,posk1,efxy);
pos = pos + (step / momk1.z()) * momk1;
//mom = mom + step / betaZ * efxy;
mom = mom;
if(isBent) mom.setX(mom.x() - step * mom.z() * beta / (GetMatData(aTrack)->GetBR(posk1)).x());
*/
//----------------------------------------
// Update the total step and the electron
// and nuclei density experienced by
// the particle during its motion
//----------------------------------------
stepTot += step;
nud_temp = GetMatData(aTrack)->GetNuD()->GetEC(pos);
eld_temp = GetMatData(aTrack)->GetElD()->GetEC(pos);
if(nud_temp < 0.) {nud_temp = 0.;}
if(eld_temp < 0.) {eld_temp = 0.;}
nud += (step * nud_temp);
eld += (step * eld_temp);
efx += (step * GetMatData(aTrack)->GetEFX()->GetEC(pos));
efy += (step * GetMatData(aTrack)->GetEFY()->GetEC(pos));
} while(stepTot<integrationLimit);
nud /= stepTot;
eld /= stepTot;
if(nud < 1.E-10) {nud = 1.E-10;}
if(eld < 1.E-10) {eld = 1.E-10;}
GetTrackData(aTrack)->SetNuD(nud);
GetTrackData(aTrack)->SetElD(eld);
GetTrackData(aTrack)->SetEFX(efx);
GetTrackData(aTrack)->SetEFY(efy);
GetTrackData(aTrack)->SetMomCh(mom);
GetTrackData(aTrack)->SetPosCh(pos);
return true;
}
else{
return false;
}
return false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4bool G4Channeling::
UpdateIntegrationStep(const G4Track& aTrack,
G4ThreeVector& mom,
G4double& step){
if(mom.x() != 0.0 || mom.y() != 0.0){
double xy2 = mom.x() * mom.x() + mom.y()*mom.y();
if(xy2!=0.){
step = std::fabs(fTransverseVariationMax * GetPre(aTrack)->GetKineticEnergy() / std::pow(xy2,0.5));
if(step < fTimeStepMin) step = fTimeStepMin;
else{
fTimeStepMax = sqrt( fTransverseVariationMax * GetPre(aTrack)->GetKineticEnergy()
/ fabs(GetMatData(aTrack)->GetEFX()->GetMax()));
if(step > fTimeStepMax) step = fTimeStepMax;
}
}
else{
step = fTimeStepMin;
}
return true;
}
else{
step = fTimeStepMin;
}
return false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4Channeling::
GetMeanFreePath(const G4Track& aTrack,
G4double, // previousStepSize
G4ForceCondition* condition){
//----------------------------------------
// the condition is forced to check if
// the volume has a lattice at each step.
// if it hasn't, return DBL_MAX
//----------------------------------------
*condition = Forced;
G4LogicalVolume* aLV = aTrack.GetVolume()->GetLogicalVolume();
G4LogicalVolume* aNLV = aTrack.GetNextVolume()->GetLogicalVolume();
if(G4LogicalCrystalVolume::IsLattice(aLV) == true &&
G4LogicalCrystalVolume::IsLattice(aNLV) == true){
G4double osc_per = GetOscillationPeriod(aTrack);
fTimeStepMin = osc_per * 2.E-4;
return osc_per * 0.01;
}
else{
GetTrackData(aTrack)->Reset();
return DBL_MAX;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VParticleChange* G4Channeling::
PostStepDoIt(const G4Track& aTrack,
const G4Step&){
//----------------------------------------
// check if the volume has a lattice
// and if the particle is in channeling.
// If it is so, the particle is forced
// to follow the channeling plane
// direction. If the particle has
// dechanneled or exited the crystal,
// the outgoing angle is evaluated
//----------------------------------------
aParticleChange.Initialize(aTrack);
G4LogicalVolume* aLV = aTrack.GetVolume()->GetLogicalVolume();
G4LogicalVolume* aNLV = aTrack.GetNextVolume()->GetLogicalVolume();
if(G4LogicalCrystalVolume::IsLattice(aLV) == true &&
G4LogicalCrystalVolume::IsLattice(aNLV) == true){
G4bool bModifiedTraj = UpdateParameters(aTrack);
if(bModifiedTraj==true){
//----------------------------------------
// Get the momentum in the reference frame
// solidal to the bent planes and rotate
// to the reference frame
//----------------------------------------
G4LogicalCrystalVolume* aLCV = (G4LogicalCrystalVolume*)(aTrack.GetVolume()->GetLogicalVolume());
G4ThreeVector momCh = GetTrackData(aTrack)->GetMomCh();
G4StepPoint* postStepPoint = aTrack.GetStep()->GetPostStepPoint();
G4TouchableHistory* theTouchable = (G4TouchableHistory*)(postStepPoint->GetTouchable());
if(GetMatData(aTrack)->IsBent()){
G4ThreeVector posPost = postStepPoint->GetPosition();
PosToLattice(postStepPoint,posPost);
G4ThreeVector axis010 = (*theTouchable->GetRotation())(k010);
momCh.rotate(axis010,posPost.z()/GetMatData(aTrack)->GetBR(posPost).x());
}
//----------------------------------------
// Get the momentum in the crystal reference
// frame and rotate to the solid reference frame
//----------------------------------------
aLCV->RotateToSolid(momCh);
//----------------------------------------
// Get the momentum in the solid reference
// frame and rotate to the world reference frame
//----------------------------------------
G4ThreeVector mom = ((*theTouchable->GetRotation()).inverse())(momCh);
aParticleChange.ProposeMomentumDirection(mom.unit());
aParticleChange.ProposePolarization(fSpin);
}
}
else{
// if the volume has no lattice it resets the density factors
GetTrackData(aTrack)->Reset();
}
return &aParticleChange;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -0,0 +1,137 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#include "G4ChannelingECHARM.hh"
#include "G4PhysicsLinearVector.hh"
#include "G4Physics2DVector.hh"
#include "G4SystemOfUnits.hh"
G4ChannelingECHARM::G4ChannelingECHARM(const G4String& fileName,G4double vConversion):
fVectorEC(0),
fDistances{0.,0.,0.},
fPoints{0,0,0},
fMaximum(-DBL_MAX),
fMinimum(DBL_MAX){
fDistances[0] = 0;
fDistances[1] = 0;
fDistances[2] = 0;
fPoints[0] = 0;
fPoints[1] = 0;
fPoints[2] = 0;
ReadFromECHARM(fileName,vConversion);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4ChannelingECHARM::~G4ChannelingECHARM(){
delete(fVectorEC);
delete(fVectorEC2D);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4ChannelingECHARM::GetEC(G4ThreeVector& vPosition){
G4double vX = vPosition.x();
if (vX < 0.0) {
vX += ((int( - vX / fDistances[0]) + 1.0 ) * fDistances[0]);
}
else if( vX > fDistances[0] ){
vX -= ( int( vX / fDistances[0]) * fDistances[0] );
}
if(fPoints[1]==1){
return fVectorEC->Value(vX);
}
else{
G4double vY = vPosition.y();
if (vY < 0.0) {
vY += ((int( - vY / fDistances[1]) + 1.0 ) * fDistances[1]);
}
else if( vY > fDistances[1] ){
vY -= ( int( vY / fDistances[1]) * fDistances[1] );
}
return fVectorEC2D->Value((vX),(vY));
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4ChannelingECHARM::ReadFromECHARM(const G4String& filename,
G4double vConversion){
std::ifstream vFileIn;
vFileIn.open(filename);
vFileIn >> fPoints[0] >> fPoints[1] >> fPoints[2];
vFileIn >> fDistances[0] >> fDistances[1] >> fDistances[2];
fDistances[0] *= CLHEP::meter;
fDistances[1] *= CLHEP::meter;
fDistances[2] *= CLHEP::meter;
fMaximum = -DBL_MAX;
fMinimum = +DBL_MAX;
if(fPoints[1]<1){
G4ExceptionDescription ed;
ed << "No Points not found !" << G4endl;
G4Exception("G4ChannelingECHARM::ReadFromECHARM(...)",
"G4ChannelingECHARM",
FatalException,
ed);
return;
}
else if(fPoints[1]==1){
fVectorEC = new G4PhysicsLinearVector(0,fDistances[0],fPoints[0]);
}
else{
fVectorEC2D = new G4Physics2DVector(fPoints[0],fPoints[1]);
}
G4double stepX = fDistances[0]/fPoints[0];
G4double stepY = fDistances[1]/fPoints[1];
for(G4int i1=0;i1<fPoints[1]; i1++){
if(fPoints[1]>1){
fVectorEC2D->PutY(i1,i1*stepY);
}
for(G4int i0=0;i0<fPoints[0]; i0++){
double vTempX;
vFileIn >> vTempX;
vTempX *= vConversion;
if(vTempX > fMaximum) {fMaximum = vTempX;}
if(vTempX < fMinimum) {fMinimum = vTempX;}
if(fPoints[1]==1){
fVectorEC->PutValue(i0,vTempX);
}
else{
fVectorEC2D->PutValue(i0,i1,vTempX);
fVectorEC2D->PutX(i0,i0*stepX);
}
}
}
G4cout << "G4ChannelingECHARM::ReadFromECHARM() - " << vConversion << " " << fPoints[0] << " " << fDistances[0] << " " << fPoints[1] << " " << fDistances[1] << " " << fMinimum << " " << fMaximum << G4endl;
vFileIn.close();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -0,0 +1,130 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#include "G4ChannelingMaterialData.hh"
#include "G4SystemOfUnits.hh"
#include "G4PhysicalConstants.hh"
#include "G4ChannelingECHARM.hh"
#include "G4LogicalCrystalVolume.hh"
#include "G4TouchableHistory.hh"
G4ChannelingMaterialData::G4ChannelingMaterialData(const G4String& name):
G4VMaterialExtension(name),
fPotential(0),
fElectricFieldX(0),
fElectricFieldY(0),
fNucleiDensity(0),
fElectronDensity(0),
fVectorR(0),
bIsBent(false){;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4ChannelingMaterialData::SetFilename(const G4String& fileName){
G4String filePot = fileName + "_pot.txt";
G4String fileEFX = fileName + "_efx.txt";
G4String fileEFY = fileName + "_efy.txt";
G4String fileAtD = fileName + "_atd.txt";
G4String fileElD = fileName + "_eld.txt";
fPotential = new G4ChannelingECHARM(filePot,CLHEP::eV);
fElectricFieldX = new G4ChannelingECHARM(fileEFX,CLHEP::eV/CLHEP::m);
fElectricFieldY = new G4ChannelingECHARM(fileEFY,CLHEP::eV/CLHEP::m);
fNucleiDensity = new G4ChannelingECHARM(fileAtD,1.);
fElectronDensity = new G4ChannelingECHARM(fileElD,1.);
G4cout << filePot << G4endl;
G4cout << fileEFX << G4endl;
G4cout << fileEFY << G4endl;
G4cout << fileAtD << G4endl;
G4cout << fileElD << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4ChannelingMaterialData::SetFilenameElement(const G4String& fileName,std::string elementName){
G4String filePot = fileName + "_pot.txt";
G4String fileEFX = fileName + "_efx.txt";
G4String fileEFY = fileName + "_efy.txt";
G4String fileAtD = fileName + "_atd.txt";
G4String fileElD = fileName + "_eld.txt";
fPotentialElement[elementName] = new G4ChannelingECHARM(filePot,CLHEP::eV);
fElectricFieldXElement[elementName] = new G4ChannelingECHARM(fileEFX,CLHEP::eV/CLHEP::m);
fElectricFieldYElement[elementName] = new G4ChannelingECHARM(fileEFY,CLHEP::eV/CLHEP::m);
fNucleiDensityElement[elementName] = new G4ChannelingECHARM(fileAtD,1.);
fElectronDensityElement[elementName] = new G4ChannelingECHARM(fileElD,1.);
G4cout << filePot << G4endl;
G4cout << fileEFX << G4endl;
G4cout << fileEFY << G4endl;
G4cout << fileAtD << G4endl;
G4cout << fileElD << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4ChannelingMaterialData::SetBR(G4double val){
fVectorR = new G4PhysicsLinearVector(0,DBL_MAX,2);
fVectorR->PutValue(0,val);
fVectorR->PutValue(1,val);
bIsBent = true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4ChannelingMaterialData::SetBR(const G4String& filename){
std::ifstream vFileIn;
int points;
float maximum;
vFileIn.open(filename);
vFileIn >> points >> maximum;
fVectorR = new G4PhysicsLinearVector(0,maximum * CLHEP::millimeter,points);
double vTempX;
double maximumY = -DBL_MAX;
double minimumY = +DBL_MAX;
for(G4int i0=0;i0<points; i0++){
vFileIn >> vTempX;
if(vTempX>maximumY) maximumY = vTempX;
if(vTempX<minimumY) minimumY = vTempX;
fVectorR->PutValue(i0,vTempX * CLHEP::meter);
}
G4cout << "G4ChannelingMaterialData::SetBR()" << G4endl;
G4cout << "Filename: " << filename << G4endl;
G4cout << "Point: " << points << " - Length [mm]: " << maximum << G4endl;
G4cout << "Maximum Radius [m]: " << maximumY << " - Minimum Radius [m]: " << minimumY << G4endl;
bIsBent = true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4ChannelingMaterialData::~G4ChannelingMaterialData(){;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -0,0 +1,265 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#include "G4ChannelingOptrChangeCrossSection.hh"
#include "G4BiasingProcessInterface.hh"
#include "G4BOptnChangeCrossSection.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
#include "G4VProcess.hh"
#include "Randomize.hh"
#include "G4InteractionLawPhysical.hh"
#include "G4ChannelingTrackData.hh"
#include "G4EmProcessSubType.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ChannelingOptrChangeCrossSection::G4ChannelingOptrChangeCrossSection(G4String particleName,
G4String name)
:G4VBiasingOperator(name),
fChannelingID(-1),
fSetup(true){
fParticleToBias = G4ParticleTable::GetParticleTable()->FindParticle(particleName);
if ( fParticleToBias == 0 )
{
G4ExceptionDescription ed;
ed << "Particle `" << particleName << "' not found !" << G4endl;
G4Exception("G4ChannelingOptrChangeCrossSection(...)",
"G4Channeling",
JustWarning,
ed);
}
fProcessToDensity["channeling"] = fDensityRatioNone;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ChannelingOptrChangeCrossSection::~G4ChannelingOptrChangeCrossSection(){
for ( std::map< const G4BiasingProcessInterface*, G4BOptnChangeCrossSection* >::iterator
it = fChangeCrossSectionOperations.begin() ;
it != fChangeCrossSectionOperations.end() ;
it++ ) delete (*it).second;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4ChannelingOptrChangeCrossSection::StartRun(){
if ( fSetup ){
const G4ProcessManager* processManager = fParticleToBias->GetProcessManager();
const G4BiasingProcessSharedData* sharedData =
G4BiasingProcessInterface::GetSharedData( processManager );
if ( sharedData ){
for ( size_t i = 0 ; i < (sharedData->GetPhysicsBiasingProcessInterfaces()).size(); i++ ){
const G4BiasingProcessInterface* wrapperProcess =
(sharedData->GetPhysicsBiasingProcessInterfaces())[i];
G4String processName = wrapperProcess->GetWrappedProcess()->GetProcessName();
G4String operationName = "channelingChangeXS-" + processName;
fChangeCrossSectionOperations[wrapperProcess] =
new G4BOptnChangeCrossSection(operationName);
G4ProcessType type = wrapperProcess->GetWrappedProcess()->GetProcessType();
G4int subType = wrapperProcess->GetWrappedProcess()->GetProcessSubType();
switch (type) {
case fNotDefined:
fProcessToDensity[processName] = fDensityRatioNotDefined;
break;
case fTransportation:
fProcessToDensity[processName] = fDensityRatioNone;
break;
case fElectromagnetic:
if(subType == fCoulombScattering ||
subType == fMultipleScattering){
fProcessToDensity[processName] = fDensityRatioNuD;
}
if(subType == fIonisation ||
subType == fPairProdByCharged ||
subType == fAnnihilation ||
subType == fAnnihilationToMuMu ||
subType == fAnnihilationToHadrons){
fProcessToDensity[processName] = fDensityRatioElD;
}
if(subType == fBremsstrahlung ||
subType == fNuclearStopping){
fProcessToDensity[processName] = fDensityRatioNuDElD;
}
if(subType == fCerenkov ||
subType == fScintillation ||
subType == fSynchrotronRadiation ||
subType == fTransitionRadiation){
fProcessToDensity[processName] = fDensityRatioNone;
}
if(subType == fRayleigh ||
subType == fPhotoElectricEffect ||
subType == fComptonScattering ||
subType == fGammaConversion ||
subType == fGammaConversionToMuMu){
fProcessToDensity[processName] = fDensityRatioNone;
}
break;
case fOptical:
fProcessToDensity[processName] = fDensityRatioNone;
break;
case fHadronic:
fProcessToDensity[processName] = fDensityRatioNuD;
break;
case fPhotolepton_hadron:
fProcessToDensity[processName] = fDensityRatioNuD;
break;
case fGeneral:
fProcessToDensity[processName] = fDensityRatioNone;
break;
case fDecay:
fProcessToDensity[processName] = fDensityRatioNone;
break;
case fParameterisation:
fProcessToDensity[processName] = fDensityRatioNone;
break;
case fUserDefined:
fProcessToDensity[processName] = fDensityRatioNone;
break;
case fParallel:
fProcessToDensity[processName] = fDensityRatioNone;
break;
case fPhonon:
fProcessToDensity[processName] = fDensityRatioNone;
break;
case fUCN:
fProcessToDensity[processName] = fDensityRatioNone;
break;
default:
fProcessToDensity[processName] = fDensityRatioNone;
break;
}
}
}
fSetup = false;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VBiasingOperation*
G4ChannelingOptrChangeCrossSection::ProposeOccurenceBiasingOperation(const G4Track* track,
const G4BiasingProcessInterface*
callingProcess)
{
if ( track->GetDefinition() != fParticleToBias ) return 0;
G4double analogInteractionLength =
callingProcess->GetWrappedProcess()->GetCurrentInteractionLength();
if ( analogInteractionLength > DBL_MAX/10. ) return 0;
G4double analogXS = 1./analogInteractionLength;
if(fChannelingID==-1){
fChannelingID = G4PhysicsModelCatalog::GetIndex("channeling");
}
G4ChannelingTrackData* trackdata =
(G4ChannelingTrackData*)(track->GetAuxiliaryTrackInformation(fChannelingID));
if(trackdata==nullptr) return 0;
G4double XStransformation = 1.;
auto search = fProcessToDensity.find(callingProcess->GetWrappedProcess()->GetProcessName());
if(search != fProcessToDensity.end()) {
switch (search->second) {
case fDensityRatioNuDElD:
XStransformation = trackdata->GetDensity();
break;
case fDensityRatioNuD:
XStransformation = trackdata->GetNuD();
break;
case fDensityRatioElD:
XStransformation = trackdata->GetElD();
break;
case fDensityRatioNone:
return 0;
break;
case fDensityRatioNotDefined:
return 0;
break;
default:
return 0;
break;
}
}
else{
XStransformation = trackdata->GetDensity();
}
G4BOptnChangeCrossSection* operation = fChangeCrossSectionOperations[callingProcess];
G4VBiasingOperation* previousOperation = callingProcess->GetPreviousOccurenceBiasingOperation();
if ( previousOperation == 0 ){
operation->SetBiasedCrossSection( XStransformation * analogXS );
operation->Sample();
}
else{
if ( previousOperation != operation ){
G4ExceptionDescription ed;
ed << " Logic problem in operation handling !" << G4endl;
G4Exception("G4ChannelingOptrChangeCrossSection::ProposeOccurenceBiasingOperation(...)",
"G4Channeling",
JustWarning,
ed);
return 0;
}
if ( operation->GetInteractionOccured() ){
operation->SetBiasedCrossSection( XStransformation * analogXS );
operation->Sample();
}
else{
operation->UpdateForStep( callingProcess->GetPreviousStepSize() );
operation->SetBiasedCrossSection( XStransformation * analogXS );
operation->UpdateForStep( 0.0 );
}
}
return operation;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4ChannelingOptrChangeCrossSection::
OperationApplied(const G4BiasingProcessInterface* callingProcess,
G4BiasingAppliedCase,
G4VBiasingOperation* occurenceOperationApplied,
G4double,
G4VBiasingOperation*,
const G4VParticleChange* )
{
G4BOptnChangeCrossSection* operation = fChangeCrossSectionOperations[callingProcess];
if ( operation == occurenceOperationApplied ) operation->SetInteractionOccured();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -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. *
// ********************************************************************
//
#include "G4ChannelingOptrMultiParticleChangeCrossSection.hh"
#include "G4ChannelingOptrChangeCrossSection.hh"
#include "G4BiasingProcessInterface.hh"
#include "G4ProcessManager.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ChannelingOptrMultiParticleChangeCrossSection::G4ChannelingOptrMultiParticleChangeCrossSection():
G4VBiasingOperator("ChannelingChangeXS-Many"),
fCurrentOperator(0),
fnInteractions(0){
AddChargedParticles();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4ChannelingOptrMultiParticleChangeCrossSection::AddParticle(G4String particleName){
const G4ParticleDefinition* particle =
G4ParticleTable::GetParticleTable()->FindParticle( particleName );
if ( particle == 0 )
{
G4ExceptionDescription ed;
ed << "Particle `" << particleName << "' not found !" << G4endl;
G4Exception("G4ChannelingOptrMultiParticleChangeCrossSection::AddParticle(...)",
"G4Channeling",
JustWarning,
ed);
return;
}
G4ChannelingOptrChangeCrossSection* optr = new G4ChannelingOptrChangeCrossSection(particleName);
fParticlesToBias.push_back( particle );
fBOptrForParticle[ particle ] = optr;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4ChannelingOptrMultiParticleChangeCrossSection::AddChargedParticles(){
G4ParticleTable::G4PTblDicIterator* aParticleIterator =
(G4ParticleTable::GetParticleTable())->GetIterator();
aParticleIterator->reset();
while( (*aParticleIterator)() ){
G4ParticleDefinition* particle = aParticleIterator->value();
if (particle->GetPDGCharge() !=0) {
AddParticle(particle->GetParticleName());
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VBiasingOperation*
G4ChannelingOptrMultiParticleChangeCrossSection::
ProposeOccurenceBiasingOperation(const G4Track* track,
const G4BiasingProcessInterface* callingProcess){
if ( fCurrentOperator ) return fCurrentOperator->
GetProposedOccurenceBiasingOperation(track, callingProcess);
else return 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4ChannelingOptrMultiParticleChangeCrossSection::StartTracking( const G4Track* track ){
const G4ParticleDefinition* definition = track->GetParticleDefinition();
std::map < const G4ParticleDefinition*, G4ChannelingOptrChangeCrossSection* > :: iterator
it = fBOptrForParticle.find( definition );
fCurrentOperator = 0;
if ( it != fBOptrForParticle.end() ) fCurrentOperator = (*it).second;
fnInteractions = 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void
G4ChannelingOptrMultiParticleChangeCrossSection::
OperationApplied( const G4BiasingProcessInterface* callingProcess,
G4BiasingAppliedCase biasingCase,
G4VBiasingOperation* occurenceOperationApplied,
G4double weightForOccurenceInteraction,
G4VBiasingOperation* finalStateOperationApplied,
const G4VParticleChange* particleChangeProduced ){
fnInteractions++;
if ( fCurrentOperator ) fCurrentOperator->ReportOperationApplied( callingProcess,
biasingCase,
occurenceOperationApplied,
weightForOccurenceInteraction,
finalStateOperationApplied,
particleChangeProduced );
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,54 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#include "G4ChannelingTrackData.hh"
#include "G4Channeling.hh"
#include "G4SystemOfUnits.hh"
G4ChannelingTrackData::G4ChannelingTrackData()
: G4VAuxiliaryTrackInformation(),
fChannelingProcess(0),
fDBL(G4ThreeVector(DBL_MAX,DBL_MAX,DBL_MAX)),
fMomCh(fDBL),
fPosCh(fDBL),
fNuD(1.),
fElD(1.),
fEFX(0.),
fEFY(0.){;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4ChannelingTrackData::~G4ChannelingTrackData(){;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4ChannelingTrackData::Print() const {
G4cout << "Nuclei Density Ratio: " << fNuD << G4endl;
G4cout << "Electron Density Ratio: " << fElD << G4endl;
G4cout << "Channeling Momentum (GeV/c): " << fMomCh/CLHEP::GeV << G4endl;
G4cout << "Channeling Position (angstrom): " << fPosCh/CLHEP::angstrom << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....