Import Geant4 7.0.0 source tree
This commit is contained in:
@@ -86,13 +86,13 @@ XrayFluoDetectorConstruction::XrayFluoDetectorConstruction()
|
||||
NbOfPixelRows = 1; // should be 1
|
||||
NbOfPixelColumns = 1; // should be 1
|
||||
NbOfPixels = NbOfPixelRows*NbOfPixelColumns;
|
||||
PixelSizeXY = sqrt(40) * mm; // should be sqrt(40) * mm
|
||||
PixelSizeXY = std::sqrt(40.) * mm; // should be std::sqrt(40) * mm
|
||||
PixelThickness = 3.5 * mm; //should be 3.5 mm
|
||||
|
||||
G4cout << "PixelThickness(mm): "<< PixelThickness/mm << G4endl;
|
||||
G4cout << "PixelSizeXY(cm): "<< PixelSizeXY/cm << G4endl;
|
||||
|
||||
ContactSizeXY = sqrt(40) * mm; //should be the same as PixelSizeXY
|
||||
ContactSizeXY = std::sqrt(40.) * mm; //should be the same as PixelSizeXY
|
||||
SampleThickness = 4 * mm;
|
||||
SampleSizeXY = 3. * cm;
|
||||
Dia1Thickness = 1. *mm;
|
||||
@@ -255,8 +255,8 @@ G4VPhysicalVolume* XrayFluoDetectorConstruction::ConstructApparate()
|
||||
|
||||
zRotPhiHPGe.rotateX(PhiHPGe);
|
||||
G4double x,y,z;
|
||||
z = DistDe * cos(ThetaHPGe);
|
||||
y =DistDe * sin(ThetaHPGe);
|
||||
z = DistDe * std::cos(ThetaHPGe);
|
||||
y =DistDe * std::sin(ThetaHPGe);
|
||||
x = 0.*cm;
|
||||
physiHPGe = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)),
|
||||
"HPGeDetector", //its name
|
||||
@@ -285,8 +285,8 @@ G4VPhysicalVolume* XrayFluoDetectorConstruction::ConstructApparate()
|
||||
/*
|
||||
zRotPhiHPGe.rotateX(PhiHPGe);
|
||||
G4double x,y,z;
|
||||
z = DistDe * cos(ThetaHPGe);
|
||||
y =DistDe * sin(ThetaHPGe);
|
||||
z = DistDe * std::cos(ThetaHPGe);
|
||||
y =DistDe * std::sin(ThetaHPGe);
|
||||
x = 0.*cm;*/
|
||||
physiPixel = new G4PVPlacement(0,
|
||||
G4ThreeVector(0,
|
||||
@@ -387,17 +387,17 @@ G4VPhysicalVolume* XrayFluoDetectorConstruction::ConstructApparate()
|
||||
|
||||
G4int nbOfGrainsX = ((G4int)(SampleSizeXY/grainDia)) -1 ;
|
||||
|
||||
// y dim of a max density plane is 2rn-(n-1)ar, wehere a = (1-(sqrt(3)/2)), n is
|
||||
// y dim of a max density plane is 2rn-(n-1)ar, wehere a = (1-(std::sqrt(3)/2)), n is
|
||||
// number of rows and r the radius of the grain. so the Y-dim of the sample must
|
||||
// be greater or equal to this. It results that nmust be <= (SampleY-a)/(1-a).
|
||||
// Max Y shift of the planes superimposing along Z axis is minor (2/sqrt(3)r)
|
||||
// Max Y shift of the planes superimposing along Z axis is minor (2/std::sqrt(3)r)
|
||||
|
||||
G4double a = (1.-(sqrt(3.)/2.));
|
||||
G4double a = (1.-(std::sqrt(3.)/2.));
|
||||
G4int nbOfGrainsY = (G4int) ( ((SampleSizeXY/(grainDia/2.)) -a)/(2.-a) ) -1;
|
||||
|
||||
// same for the z axis, but a = 2 * (sqrt(3) - sqrt(2))/sqrt(3)
|
||||
// same for the z axis, but a = 2 * (std::sqrt(3) - std::sqrt(2))/std::sqrt(3)
|
||||
|
||||
G4double b = 2. * (sqrt(3.) - sqrt(2.))/sqrt(3.);
|
||||
G4double b = 2. * (std::sqrt(3.) - std::sqrt(2.))/std::sqrt(3.);
|
||||
G4int nbOfGrainsZ = (G4int) ( ((SampleThickness/(grainDia/2.)) -b)/(2.-b) )-1;
|
||||
|
||||
if (SampleThickness > 0.){
|
||||
@@ -410,12 +410,12 @@ G4VPhysicalVolume* XrayFluoDetectorConstruction::ConstructApparate()
|
||||
sampleMaterial, //its material
|
||||
"Grain"); //its name
|
||||
G4ThreeVector grainPosition;
|
||||
G4double grainInitPositionX;
|
||||
G4double grainInitPositionY;
|
||||
G4double grainInitPositionX = 0.;
|
||||
G4double grainInitPositionY = 0.;
|
||||
G4double grainInitPositionZ = (-1.*SampleThickness/2.+grainDia/2.);
|
||||
G4double grainStepX = grainDia;
|
||||
G4double grainStepY = grainDia*(1.-(0.5-(sqrt(3.)/4.)));
|
||||
G4double grainStepZ = grainDia*sqrt(2./3.);
|
||||
G4double grainStepY = grainDia*(1.-(0.5-(std::sqrt(3.)/4.)));
|
||||
G4double grainStepZ = grainDia*std::sqrt(2./3.);
|
||||
|
||||
for ( G4int k=0; k < nbOfGrainsZ ; k++ ) {
|
||||
for ( G4int j=0; j < nbOfGrainsY ; j++ ) {
|
||||
@@ -438,7 +438,7 @@ G4VPhysicalVolume* XrayFluoDetectorConstruction::ConstructApparate()
|
||||
}
|
||||
else if ( ((k+2) % 3) == 0 ) { // B-layer
|
||||
|
||||
grainInitPositionY = ( (-1.*SampleSizeXY/2.) + (grainDia/2.)*(1. + (1./sqrt(3.)) ) );
|
||||
grainInitPositionY = ( (-1.*SampleSizeXY/2.) + (grainDia/2.)*(1. + (1./std::sqrt(3.)) ) );
|
||||
|
||||
if (j%2 ==0) { //first or (3-multiple)th row
|
||||
grainInitPositionX = (-1.*SampleSizeXY/2.+grainDia);
|
||||
@@ -452,7 +452,7 @@ G4VPhysicalVolume* XrayFluoDetectorConstruction::ConstructApparate()
|
||||
|
||||
else if ( (k+1)%3 == 0 ) { // B-layer
|
||||
|
||||
grainInitPositionY = (-1.*SampleSizeXY/2.+(grainDia/2.)*(1.+2./sqrt(3.)) );
|
||||
grainInitPositionY = (-1.*SampleSizeXY/2.+(grainDia/2.)*(1.+2./std::sqrt(3.)) );
|
||||
|
||||
if (j%2 ==0) { //first or (3-multiple)th row
|
||||
grainInitPositionX = (-1.*SampleSizeXY/2.+grainDia/2.);
|
||||
@@ -523,8 +523,8 @@ G4VPhysicalVolume* XrayFluoDetectorConstruction::ConstructApparate()
|
||||
|
||||
zRotPhiDia1.rotateX(AlphaDia1);
|
||||
G4double x,y,z;
|
||||
z = DistDia * cos(ThetaDia1);
|
||||
y =DistDia * sin(ThetaDia1);
|
||||
z = DistDia * std::cos(ThetaDia1);
|
||||
y =DistDia * std::sin(ThetaDia1);
|
||||
x = 0.*cm;
|
||||
physiDia1 = new G4PVPlacement(G4Transform3D(zRotPhiDia1,G4ThreeVector(x,y,z)),
|
||||
"Diaphragm1", //its name
|
||||
@@ -554,8 +554,8 @@ G4VPhysicalVolume* XrayFluoDetectorConstruction::ConstructApparate()
|
||||
|
||||
zRotPhiDia3.rotateX(AlphaDia3);
|
||||
G4double x,y,z;
|
||||
z = Dia3Dist * cos(ThetaDia3);
|
||||
y =Dia3Dist * sin(ThetaDia3);
|
||||
z = Dia3Dist * std::cos(ThetaDia3);
|
||||
y =Dia3Dist * std::sin(ThetaDia3);
|
||||
x = 0.*cm;
|
||||
physiDia3 = new G4PVPlacement(G4Transform3D(zRotPhiDia3,G4ThreeVector(x,y,z)), "Diaphragm3", //its name
|
||||
logicDia3, //its logical volume
|
||||
|
||||
@@ -132,9 +132,10 @@ void XrayFluoEventAction::BeginOfEventAction(const G4Event* evt)
|
||||
if ( eventNumber % (G4int)5e6 != 0 ) G4cout << "#" << std::flush;
|
||||
else G4cout << "#"<< G4endl;
|
||||
// if ( eventNumber % 5e6 == 0 ) G4cout << "#"<< G4endl;
|
||||
|
||||
// #ifdef G4ANALYSIS_USE
|
||||
// XrayFluoAnalysisManager* analysis = XrayFluoAnalysisManager::getInstance();
|
||||
// analysis->PlotCurrentResults();
|
||||
// #endif
|
||||
}
|
||||
|
||||
if (HPGeCollID==-1)
|
||||
@@ -167,7 +168,7 @@ void XrayFluoEventAction::EndOfEventAction(const G4Event* evt)
|
||||
{
|
||||
n_hit = HPGeHC->entries();
|
||||
|
||||
// if (n_hit) {G4cout << "Ecco quante hit ho nel detector "<< n_hit << G4endl;}
|
||||
// if (n_hit) {G4cout << "Number of Hits in the detector "<< n_hit << G4endl;}
|
||||
|
||||
for (G4int i=0;i<n_hit;i++)
|
||||
{
|
||||
@@ -179,10 +180,10 @@ void XrayFluoEventAction::EndOfEventAction(const G4Event* evt)
|
||||
energyD = detectorType->ResponseFunction(totEnergy);
|
||||
// energyD = totEnergy;
|
||||
// G4cout << "energy deposit: "<< totEnergy << G4endl;
|
||||
|
||||
#ifdef G4ANALYSIS_USE
|
||||
XrayFluoAnalysisManager* analysis = XrayFluoAnalysisManager::getInstance();
|
||||
analysis->analyseEnergyDep(energyD);
|
||||
|
||||
#endif
|
||||
totEnergyDetect += energyD;
|
||||
|
||||
|
||||
@@ -231,7 +232,7 @@ G4double XrayFluoEventAction::RandomCut(G4double energy)
|
||||
|
||||
if ( Random<efficiency )
|
||||
{
|
||||
G4double sigma = sqrt(F*epsilon*energy+pow(deltaE/2355,2));
|
||||
G4double sigma = std::sqrt(F*epsilon*energy+std::pow(deltaE/2355,2));
|
||||
|
||||
EdepDetect = G4RandGauss::shoot(energy, sigma );
|
||||
|
||||
|
||||
@@ -0,0 +1,342 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: XrayFluoHPGeDetectorType.cc
|
||||
// GEANT4 tag $Name:
|
||||
//
|
||||
// Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it)
|
||||
//
|
||||
// History:
|
||||
// -----------
|
||||
// 16 Jul 2003 Alfonso Mantero Created
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#include "XrayFluoHPGeDetectorType.hh"
|
||||
#include "XrayFluoDataSet.hh"
|
||||
#include "G4DataVector.hh"
|
||||
#include "G4LogLogInterpolation.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <fstream>
|
||||
#include <strstream>
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
|
||||
XrayFluoHPGeDetectorType::XrayFluoHPGeDetectorType():
|
||||
detectorMaterial("HPGe"),efficiencySet(0)
|
||||
{
|
||||
LoadResponseData("response");
|
||||
|
||||
LoadEfficiencyData("efficienza");
|
||||
|
||||
|
||||
}
|
||||
XrayFluoHPGeDetectorType::~XrayFluoHPGeDetectorType()
|
||||
{
|
||||
std::map<G4int,G4DataVector*,std::less<G4int> >::iterator pos;
|
||||
|
||||
for (pos = energyMap.begin(); pos != energyMap.end(); pos++)
|
||||
{
|
||||
G4DataVector* dataSet = (*pos).second;
|
||||
delete dataSet;
|
||||
dataSet = 0;
|
||||
}
|
||||
for (pos = dataMap.begin(); pos != dataMap.end(); pos++)
|
||||
{
|
||||
G4DataVector* dataSet = (*pos).second;
|
||||
delete dataSet;
|
||||
dataSet = 0;
|
||||
}
|
||||
|
||||
delete interpolation4;
|
||||
|
||||
}
|
||||
G4String XrayFluoHPGeDetectorType::GetDetectorMaterial()
|
||||
{
|
||||
return detectorMaterial;
|
||||
}
|
||||
|
||||
XrayFluoHPGeDetectorType* XrayFluoHPGeDetectorType::instance = 0;
|
||||
|
||||
XrayFluoHPGeDetectorType* XrayFluoHPGeDetectorType::GetInstance()
|
||||
|
||||
{
|
||||
if (instance == 0)
|
||||
{
|
||||
instance = new XrayFluoHPGeDetectorType;
|
||||
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
G4double XrayFluoHPGeDetectorType::ResponseFunction(G4double energy)
|
||||
{
|
||||
|
||||
|
||||
G4double eMin = 1* keV;
|
||||
G4double eMax = 10*keV;
|
||||
G4double value = 0.;
|
||||
G4double efficiency = 1.;
|
||||
|
||||
const XrayFluoDataSet* dataSet = efficiencySet;
|
||||
G4int id = 0;
|
||||
|
||||
G4double random = G4UniformRand();
|
||||
|
||||
if (energy>=eMin && energy <=eMax)
|
||||
{
|
||||
G4double infEnergy = (G4int)(energy/keV)* keV;
|
||||
|
||||
G4double supEnergy = ((G4int)(energy/keV) + 1)*keV;
|
||||
|
||||
G4double infData = GetInfData(energy, random, 0);// 0 is not used
|
||||
|
||||
G4double supData = GetSupData(energy,random, 0); // 0 is not used
|
||||
|
||||
value = (std::log10(infData)*std::log10(supEnergy/energy) +
|
||||
std::log10(supData)*std::log10(energy/infEnergy)) /
|
||||
std::log10(supEnergy/infEnergy);
|
||||
value = std::pow(10,value);
|
||||
}
|
||||
else if (energy<eMin)
|
||||
{
|
||||
G4double infEnergy = eMin;
|
||||
G4double supEnergy = eMin/keV +1*keV;
|
||||
|
||||
G4double infData = GetInfData(eMin, random, 0);
|
||||
G4double supData = GetSupData(eMin,random, 0);
|
||||
value = (std::log10(infData)*std::log10(supEnergy/eMin) +
|
||||
std::log10(supData)*std::log10(eMin/infEnergy)) /
|
||||
std::log10(supEnergy/infEnergy);
|
||||
value = std::pow(10,value);
|
||||
value = value-eMin+ energy;
|
||||
|
||||
|
||||
}
|
||||
else if (energy>eMax)
|
||||
{
|
||||
G4double infEnergy = eMax/keV - 1. *keV;
|
||||
G4double supEnergy = eMax;
|
||||
|
||||
G4double infData = GetInfData(eMax, random, 0);
|
||||
G4double supData = GetSupData(eMax,random, 0);
|
||||
value = (std::log10(infData)*std::log10(supEnergy/eMax) +
|
||||
std::log10(supData)*std::log10(eMax/infEnergy)) /
|
||||
std::log10(supEnergy/infEnergy);
|
||||
value = std::pow(10,value);
|
||||
value = value+energy- eMax;
|
||||
}
|
||||
G4double RandomNum = G4UniformRand();
|
||||
|
||||
efficiency = dataSet->FindValue(value,id);
|
||||
if ( RandomNum>efficiency )
|
||||
{
|
||||
value = 0.;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
G4double XrayFluoHPGeDetectorType::GetInfData(G4double energy, G4double random, G4int)
|
||||
{
|
||||
G4double value = 0.;
|
||||
G4int zMin = 1;
|
||||
G4int zMax = 10;
|
||||
|
||||
G4int Z = ((G4int)(energy/keV));
|
||||
|
||||
if (Z<zMin) {Z=zMin;}
|
||||
if (Z>zMax) {Z=zMax;}
|
||||
|
||||
if (Z >= zMin && Z <= zMax)
|
||||
{
|
||||
std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
|
||||
pos = energyMap.find(Z);
|
||||
std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator posData;
|
||||
posData = dataMap.find(Z);
|
||||
if (pos!= energyMap.end())
|
||||
{
|
||||
G4DataVector energySet = *((*pos).second);
|
||||
G4DataVector dataSet = *((*posData).second);
|
||||
G4int nData = energySet.size();
|
||||
|
||||
G4double partSum = 0;
|
||||
G4int index = 0;
|
||||
|
||||
while (random> partSum)
|
||||
{
|
||||
partSum += dataSet[index];
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
if (index >= 0 && index < nData)
|
||||
{
|
||||
value = energySet[index];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return value;
|
||||
|
||||
}
|
||||
G4double XrayFluoHPGeDetectorType::GetSupData(G4double energy, G4double random, G4int)
|
||||
{
|
||||
G4double value = 0.;
|
||||
G4int zMin = 1;
|
||||
G4int zMax = 10;
|
||||
G4int Z = ((G4int)(energy/keV)+1);
|
||||
|
||||
if (Z<zMin) {Z=zMin;}
|
||||
if (Z>zMax) {Z=zMax;}
|
||||
if (Z >= zMin && Z <= zMax)
|
||||
{
|
||||
std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
|
||||
pos = energyMap.find(Z);
|
||||
std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator posData;
|
||||
posData = dataMap.find(Z);
|
||||
if (pos!= energyMap.end())
|
||||
{
|
||||
G4DataVector energySet = *((*pos).second);
|
||||
G4DataVector dataSet = *((*posData).second);
|
||||
G4int nData = energySet.size();
|
||||
G4double partSum = 0;
|
||||
G4int index = 0;
|
||||
|
||||
while (random> partSum)
|
||||
{
|
||||
partSum += dataSet[index];
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
if (index >= 0 && index < nData)
|
||||
{
|
||||
value = energySet[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
|
||||
}
|
||||
void XrayFluoHPGeDetectorType::LoadResponseData(G4String fileName)
|
||||
{
|
||||
char nameChar[100] = {""};
|
||||
std::ostrstream ost(nameChar, 100, std::ios::out);
|
||||
|
||||
|
||||
ost << fileName<<".dat";
|
||||
|
||||
G4String name(nameChar);
|
||||
|
||||
char* path = getenv("XRAYDATA");
|
||||
|
||||
G4String pathString(path);
|
||||
G4String dirFile = pathString + "/" + name;
|
||||
std::ifstream file(dirFile);
|
||||
std::filebuf* lsdp = file.rdbuf();
|
||||
|
||||
if (! (lsdp->is_open()) )
|
||||
{
|
||||
G4String excep = "XrayFluoHPGeDetectorType - data file: " + dirFile + " not found";
|
||||
G4Exception(excep);
|
||||
}
|
||||
G4double a = 0;
|
||||
G4int k = 1;
|
||||
G4int s = 0;
|
||||
|
||||
G4int Z = 1;
|
||||
G4DataVector* energies = new G4DataVector;
|
||||
G4DataVector* data = new G4DataVector;
|
||||
|
||||
do
|
||||
{
|
||||
file >> a;
|
||||
G4int nColumns = 2;
|
||||
if (a == -1)
|
||||
{
|
||||
if (s == 0)
|
||||
{
|
||||
// End of a data set
|
||||
energyMap[Z] = energies;
|
||||
dataMap[Z] = data;
|
||||
// Start of new shell data set
|
||||
energies = new G4DataVector;
|
||||
data = new G4DataVector;
|
||||
Z++;
|
||||
}
|
||||
s++;
|
||||
if (s == nColumns)
|
||||
{
|
||||
s = 0;
|
||||
}
|
||||
}
|
||||
else if (a == -2)
|
||||
{
|
||||
// End of file; delete the empty vectors
|
||||
//created when encountering the last -1 -1 row
|
||||
delete energies;
|
||||
delete data;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// 1st column is energy
|
||||
if(k%nColumns != 0)
|
||||
{
|
||||
G4double e = a * keV;
|
||||
energies->push_back(e);
|
||||
k++;
|
||||
}
|
||||
else if (k%nColumns == 0)
|
||||
{
|
||||
// 2nd column is data
|
||||
|
||||
data->push_back(a);
|
||||
k = 1;
|
||||
}
|
||||
}
|
||||
} while (a != -2); // end of file
|
||||
file.close();
|
||||
}
|
||||
|
||||
void XrayFluoHPGeDetectorType::LoadEfficiencyData(G4String fileName)
|
||||
{
|
||||
|
||||
char* path = getenv("XRAYDATA");
|
||||
G4String dirFile;
|
||||
if (path) {
|
||||
G4String pathString(path);
|
||||
dirFile = pathString + "/" + fileName;
|
||||
}
|
||||
else{
|
||||
path = getenv("PWD");
|
||||
G4String pathString(path);
|
||||
dirFile = pathString + "/" + fileName;
|
||||
}
|
||||
|
||||
interpolation4 = new G4LogLogInterpolation();
|
||||
efficiencySet = new XrayFluoDataSet(1,dirFile,interpolation4,keV,1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,496 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: XrayFluoDetectorConstruction.hh
|
||||
// GEANT4 tag $Name: xray_fluo-V03-02-00
|
||||
//
|
||||
// Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it)
|
||||
//
|
||||
// History:
|
||||
// -----------
|
||||
// 20 Aug 2001 Alfonso Mantero Created
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#include "XrayFluoMaterials.hh"
|
||||
|
||||
XrayFluoMaterials::XrayFluoMaterials()
|
||||
{ CreateMaterials();}
|
||||
|
||||
XrayFluoMaterials* XrayFluoMaterials::instance = 0;
|
||||
|
||||
XrayFluoMaterials* XrayFluoMaterials::GetInstance()
|
||||
{
|
||||
if (instance == 0)
|
||||
{
|
||||
instance = new XrayFluoMaterials;
|
||||
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
G4Material* XrayFluoMaterials::GetMaterial(G4String material)
|
||||
{
|
||||
G4Material* pttoMaterial = G4Material::GetMaterial(material);
|
||||
return pttoMaterial;
|
||||
}
|
||||
|
||||
|
||||
void XrayFluoMaterials::CreateMaterials()
|
||||
{
|
||||
|
||||
//define elements
|
||||
G4String name, symbol; //a=mass of a mole;
|
||||
G4double a, z, density; //z=mean number of protons;
|
||||
G4int natoms,ncomponents;
|
||||
G4double temperature, pressure;
|
||||
G4double fractionmass;
|
||||
|
||||
// Elements Definitions
|
||||
|
||||
//define Niobium
|
||||
|
||||
a = 92.906*g/mole;
|
||||
G4Element* Nb = new G4Element(name="Niobium" ,symbol="Nb" , z= 41., a);
|
||||
|
||||
//define Zirconium
|
||||
|
||||
a = 91.22*g/mole;
|
||||
G4Element* Zr = new G4Element(name="Zirconium" ,symbol="Zr" , z= 40., a);
|
||||
|
||||
//define Yttrium
|
||||
|
||||
a = 88.905*g/mole;
|
||||
G4Element* Y = new G4Element(name="Yttrium" ,symbol="Y" , z= 39., a);
|
||||
|
||||
//define Stronzium
|
||||
|
||||
a = 87.62*g/mole;
|
||||
G4Element* Sr = new G4Element(name="Stronzium" ,symbol="Sr" , z= 38., a);
|
||||
|
||||
//define Rubidium
|
||||
|
||||
a = 85.47*g/mole;
|
||||
G4Element* Rb = new G4Element(name="Rubidium" ,symbol="Rb" , z= 37., a);
|
||||
|
||||
//define Zinc
|
||||
|
||||
a = 65.37*g/mole;
|
||||
G4Element* Zn = new G4Element(name="Zinc" ,symbol="Zn" , z= 30., a);
|
||||
|
||||
//define Nichel
|
||||
|
||||
a = 58.71*g/mole;
|
||||
G4Element* Ni = new G4Element(name="Nichel" ,symbol="Ni" , z= 28., a);
|
||||
|
||||
//define Scandio
|
||||
|
||||
a = 44.956*g/mole;
|
||||
G4Element* Sc = new G4Element(name="Scandium" ,symbol="Sc" , z= 21., a);
|
||||
|
||||
//define Vanadium
|
||||
|
||||
a = 50.942*g/mole;
|
||||
G4Element* V = new G4Element(name="Vanadium" ,symbol="V" , z= 39., a);
|
||||
|
||||
//define Cromium
|
||||
|
||||
a = 51.996*g/mole;
|
||||
G4Element* Cr = new G4Element(name="Cromium" ,symbol="Cr" , z= 24., a);
|
||||
|
||||
//define Cobalt
|
||||
|
||||
a = 58.933*g/mole;
|
||||
G4Element* Co = new G4Element(name="Cobalt" ,symbol="Co" , z= 27., a);
|
||||
|
||||
//define Copper
|
||||
|
||||
a = 63.54*g/mole;
|
||||
G4Element* elCu = new G4Element(name="Copper" ,symbol="Cu" , z= 29., a);
|
||||
|
||||
//define Barium
|
||||
|
||||
a = 137.34*g/mole;
|
||||
G4Element* Ba = new G4Element(name="Barium" ,symbol="Ba" , z= 56., a);
|
||||
|
||||
//define Cerium
|
||||
|
||||
a = 140.12*g/mole;
|
||||
G4Element* Ce = new G4Element(name="Cerium" ,symbol="Ce" , z= 58., a);
|
||||
|
||||
//define Neodimuim
|
||||
|
||||
a = 144.24*g/mole;
|
||||
G4Element* Nd = new G4Element(name="Neodimuim" ,symbol="Nd" , z= 60., a);
|
||||
|
||||
|
||||
//Define Zolfo
|
||||
|
||||
a = 32.064*g/mole;
|
||||
G4Element* elS = new G4Element(name="Zolfo" ,symbol="S" , z= 16., a);
|
||||
|
||||
|
||||
//define carbon
|
||||
|
||||
a = 12.0107*g/mole;
|
||||
G4Element* C = new G4Element(name="Carbon" ,symbol="C" , z= 6., a);
|
||||
|
||||
//define Nitrogen
|
||||
|
||||
a = 14.01*g/mole;
|
||||
G4Element* N = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
|
||||
|
||||
// define Oxigen
|
||||
a = 15.9994*g/mole;
|
||||
G4Element* O = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
|
||||
|
||||
//define Arsenic
|
||||
a = 74.9216 * g/mole;
|
||||
G4Element * As = new G4Element( name="arsenic",symbol="As",z= 33.,a);
|
||||
|
||||
//Define Gallium
|
||||
a = 69.72* g/mole;
|
||||
G4Element * Ga = new G4Element(name="gallium",symbol="Ga",z= 31.,a);
|
||||
|
||||
//define Iron
|
||||
a = 55.847*g/mole;
|
||||
G4Element* Fe = new G4Element(name="Iron" ,symbol="Fe", z=26., a);
|
||||
//define hydrogen
|
||||
|
||||
a = 1.01*g/mole;
|
||||
G4Element* H = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
|
||||
|
||||
//define germanium
|
||||
a = 72.61*g/mole;
|
||||
G4Element* Ge = new G4Element(name="Germanium",symbol="Ge", z= 32.,a);
|
||||
//define phosporus
|
||||
|
||||
a = 30.97*g/mole;
|
||||
G4Element* P = new G4Element(name="Phosporus",symbol="P", z= 15., a);
|
||||
|
||||
// define Titanium
|
||||
a = 47.88*g/mole;
|
||||
G4Element* elTi = new G4Element(name="Titanium",symbol="Ti" , z= 22., a);
|
||||
|
||||
// define Calcium
|
||||
a = 40.078*g/mole;
|
||||
G4Element* Ca = new G4Element(name="Calcium",symbol="Ca" , z= 20., a);
|
||||
|
||||
// define silicon
|
||||
a = 28.0855*g/mole;
|
||||
G4Element* elSi = new G4Element(name="Silicon",symbol="Si" , z= 14., a);
|
||||
|
||||
// define Aluminium
|
||||
a = 26.98154*g/mole;
|
||||
G4Element* elAl = new G4Element(name="Aluminium",symbol="Al" , z= 13., a);
|
||||
|
||||
// Define Magnesium
|
||||
a = 24.305*g/mole;
|
||||
G4Element* Mg = new G4Element(name="Magnesium",symbol="Mg" , z= 12., a);
|
||||
|
||||
// Define Manganese
|
||||
a = 54.938*g/mole;
|
||||
G4Element* Mn = new G4Element(name="Manganese",symbol="Mn" , z= 25., a);
|
||||
|
||||
// Define Sodium
|
||||
a = 22.989*g/mole;
|
||||
G4Element* Na = new G4Element(name="Sodium",symbol="Na" , z= 11., a);
|
||||
|
||||
// Define Potassium
|
||||
a = 39.10*g/mole;
|
||||
G4Element* K = new G4Element(name="Potassium",symbol="K" , z= 19., a);
|
||||
// Define lead
|
||||
|
||||
a=207.19*g/mole;
|
||||
G4Element* elPb = new G4Element(name="Lead",symbol="pb", z=82.,a);
|
||||
|
||||
//define Uranium
|
||||
|
||||
a = 238.02891*g/mole;
|
||||
G4Element* elU = new G4Element(name="Uranium",symbol="U", z=92.,a);
|
||||
|
||||
|
||||
// define Palladium
|
||||
a= 106.4*g/mole;
|
||||
G4Element* Pd = new G4Element(name="Palladium",symbol="Pd",z=46.,a);
|
||||
|
||||
// define cadmium
|
||||
a = 112.4 *g/mole;
|
||||
G4Element* Cd = new G4Element(name="Cadmium",symbol="Cd",z=48.,a);
|
||||
|
||||
// define Silver
|
||||
a = 107.87 *g/mole;
|
||||
G4Element* Ag = new G4Element(name="Silver",symbol="Ag",z=47.,a);
|
||||
|
||||
// define Clorine
|
||||
a = 35.453 * g/mole;
|
||||
G4Element * Cl = new G4Element( name="Chlorine",symbol="Cl",z= 17.,a);
|
||||
|
||||
|
||||
G4cout << "Elements created" << G4endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Materials Definitions
|
||||
|
||||
// Define dolorite main components
|
||||
|
||||
density = 3*g/cm3;
|
||||
G4Material* diorite = new G4Material(name="Diorite", density, ncomponents=11);
|
||||
diorite->AddElement(Fe, fractionmass=0.1750);
|
||||
diorite->AddElement(elTi, fractionmass=0.0082);
|
||||
diorite->AddElement(Ca, fractionmass=0.0753);
|
||||
diorite->AddElement(elSi, fractionmass=0.2188);
|
||||
diorite->AddElement(elAl, fractionmass=0.0676);
|
||||
diorite->AddElement(Mg, fractionmass=0.0008);
|
||||
diorite->AddElement(O , fractionmass=0.4377);
|
||||
diorite->AddElement(Mn , fractionmass=0.0015);
|
||||
diorite->AddElement(Na , fractionmass=0.0134);
|
||||
diorite->AddElement(K , fractionmass=0.0011);
|
||||
diorite->AddElement(P , fractionmass=0.0006);
|
||||
|
||||
// define traces in dolorite
|
||||
|
||||
density = 3*g/cm3;
|
||||
G4Material* tracesOfDolorite = new G4Material(name="TracesOfDolorite", density, ncomponents=16);
|
||||
tracesOfDolorite->AddElement(Nb, natoms=5);
|
||||
tracesOfDolorite->AddElement(Zr, natoms=91);
|
||||
tracesOfDolorite->AddElement(Y, natoms=29);
|
||||
tracesOfDolorite->AddElement(Sr, natoms=140);
|
||||
tracesOfDolorite->AddElement(Rb, natoms=3);
|
||||
tracesOfDolorite->AddElement(Ga, natoms=20);
|
||||
tracesOfDolorite->AddElement(Zn, natoms=99);
|
||||
tracesOfDolorite->AddElement(Ni, natoms=77);
|
||||
tracesOfDolorite->AddElement(Sc, natoms=32);
|
||||
tracesOfDolorite->AddElement(V, natoms=314);
|
||||
tracesOfDolorite->AddElement(Cr, natoms=130);
|
||||
tracesOfDolorite->AddElement(Co, natoms=56);
|
||||
tracesOfDolorite->AddElement(elCu, natoms=119);
|
||||
tracesOfDolorite->AddElement(Ba, natoms=38);
|
||||
tracesOfDolorite->AddElement(Ce, natoms=15);
|
||||
tracesOfDolorite->AddElement(Nd, natoms=9);
|
||||
|
||||
// define dolorite (full)
|
||||
|
||||
density = 3*g/cm3;
|
||||
dolorite = new G4Material(name="Dolorite", density, ncomponents=2);
|
||||
dolorite->AddMaterial(tracesOfDolorite, fractionmass=0.0027842352);
|
||||
dolorite->AddMaterial(diorite, fractionmass=0.9972157648);
|
||||
|
||||
// define mars1
|
||||
|
||||
density = 3*g/cm3;
|
||||
G4Material* mars1Main = new G4Material(name="Mars1 Main components", density, ncomponents=11);
|
||||
mars1Main->AddElement(Fe, fractionmass=0.100916);
|
||||
mars1Main->AddElement(elTi, fractionmass=0.0186804);
|
||||
mars1Main->AddElement(Ca, fractionmass=0.0404091);
|
||||
mars1Main->AddElement(elSi, fractionmass=0.196378);
|
||||
mars1Main->AddElement(elAl, fractionmass=0.103282);
|
||||
mars1Main->AddElement(Mg, fractionmass=0.0241622);
|
||||
mars1Main->AddElement(Mn , fractionmass=0.00184331);
|
||||
mars1Main->AddElement(Na , fractionmass=0.0177908);
|
||||
mars1Main->AddElement(K , fractionmass=0.00574498);
|
||||
mars1Main->AddElement(P , fractionmass=0.00280169);
|
||||
mars1Main->AddElement(O , fractionmass=0.48799152);
|
||||
|
||||
density = 3*g/cm3;
|
||||
G4Material* tracesOfMars1 = new G4Material(name="TracesOfMars1", density, ncomponents=17);
|
||||
tracesOfMars1->AddElement(Nb, natoms=55);
|
||||
tracesOfMars1->AddElement(Zr, natoms=433);
|
||||
tracesOfMars1->AddElement(Y, natoms=58);
|
||||
tracesOfMars1->AddElement(Sr, natoms=968);
|
||||
tracesOfMars1->AddElement(Rb, natoms=16);
|
||||
tracesOfMars1->AddElement(Ga, natoms=24);
|
||||
tracesOfMars1->AddElement(Zn, natoms=109);
|
||||
tracesOfMars1->AddElement(Ni, natoms=70);
|
||||
tracesOfMars1->AddElement(Sc, natoms=21);
|
||||
tracesOfMars1->AddElement(V, natoms=134);
|
||||
tracesOfMars1->AddElement(Cr, natoms=141);
|
||||
tracesOfMars1->AddElement(Co, natoms=30);
|
||||
tracesOfMars1->AddElement(elCu, natoms=19);
|
||||
tracesOfMars1->AddElement(Ba, natoms=580);
|
||||
tracesOfMars1->AddElement(elPb, natoms=4);
|
||||
tracesOfMars1->AddElement(elS, natoms=444);
|
||||
tracesOfMars1->AddElement(elU, natoms=2);
|
||||
|
||||
|
||||
density = 3*g/cm3;
|
||||
mars1 = new G4Material(name="Mars1", density, ncomponents=2);
|
||||
mars1->AddMaterial(tracesOfMars1, fractionmass=0.0044963163);
|
||||
mars1->AddMaterial(mars1Main, fractionmass=0.9955036837);
|
||||
|
||||
// define anorthosite
|
||||
|
||||
density = 2.8*g/cm3;
|
||||
anorthosite = new G4Material(name="Anorthosite", density, ncomponents=21);
|
||||
anorthosite->AddElement(Fe, fractionmass=0.095283);
|
||||
anorthosite->AddElement(Mn, fractionmass=0.00137086);
|
||||
anorthosite->AddElement(Ni, fractionmass=5e-5);
|
||||
anorthosite->AddElement(elCu, fractionmass=5.2e-4);
|
||||
anorthosite->AddElement(Na, fractionmass=0.017635);
|
||||
anorthosite->AddElement(Mg, fractionmass=0.0245361);
|
||||
anorthosite->AddElement(elAl, fractionmass=0.0800355);
|
||||
anorthosite->AddElement(elSi, fractionmass=0.232204);
|
||||
anorthosite->AddElement(Ca, fractionmass=0.0635368);
|
||||
anorthosite->AddElement(K, fractionmass=0.00464912);
|
||||
anorthosite->AddElement(C, fractionmass=0.000837803);
|
||||
anorthosite->AddElement(P, fractionmass=0.00176742);
|
||||
anorthosite->AddElement(elTi, fractionmass=0.0240879);
|
||||
anorthosite->AddElement(Cl, fractionmass=0.00014);
|
||||
anorthosite->AddElement(Pd, fractionmass=0.00001);
|
||||
anorthosite->AddElement(Cd, fractionmass=0.00018);
|
||||
anorthosite->AddElement(Ag, fractionmass=0.00048);
|
||||
anorthosite->AddElement(elS, fractionmass=0.00144);
|
||||
anorthosite->AddElement(V, fractionmass=0.00228);
|
||||
anorthosite->AddElement(Ba, fractionmass=0.00151);
|
||||
anorthosite->AddElement(O, fractionmass=0.447026);
|
||||
|
||||
|
||||
|
||||
//define Neodimuim
|
||||
|
||||
density = 6800*kg/m3;
|
||||
materialNd = new G4Material(name="Neodimuim" ,density , ncomponents=1);
|
||||
materialNd ->AddElement(Nd,natoms=1);
|
||||
|
||||
// Define Magnesium
|
||||
density = 1738*kg/m3;
|
||||
materialMg = new G4Material(name="Magnesium",density , ncomponents=1);
|
||||
materialMg->AddElement(Mg,natoms=1);
|
||||
|
||||
//define iron
|
||||
|
||||
density = 7.86 * g/cm3;
|
||||
FeMaterial = new G4Material(name="Iron",density,ncomponents=1);
|
||||
FeMaterial->AddElement(Fe,natoms=1);
|
||||
|
||||
|
||||
|
||||
//define gallium arsenide
|
||||
|
||||
density = 5.32 * g/cm3;
|
||||
G4Material * GaAs = new G4Material(name ="gallium arsenide",density,ncomponents=2);
|
||||
GaAs->AddElement(Ga,natoms=1);
|
||||
GaAs->AddElement(As,natoms=1);
|
||||
|
||||
|
||||
// define germanium
|
||||
|
||||
density = 5.32 * g/cm3;
|
||||
HPGe = new G4Material(name="HPGe",density,ncomponents=1);
|
||||
HPGe ->AddElement(Ge,natoms=1);
|
||||
|
||||
//define silicon
|
||||
|
||||
density = 2.333*g/cm3;
|
||||
a = 28.0855*g/mole;
|
||||
Si = new G4Material(name="Silicon",z=14., a,density);
|
||||
|
||||
//define copper
|
||||
|
||||
density = 8.960*g/cm3;
|
||||
a = 63.55*g/mole;
|
||||
Cu = new G4Material(name="Copper" , z=29., a, density);
|
||||
|
||||
|
||||
|
||||
////define Oxigen
|
||||
//density = 1*g/cm3;
|
||||
//a=16*g/mole;
|
||||
//G4Material* matOx = new G4Material(name="Oxigen", z=8., a, density);
|
||||
|
||||
//define aluminium
|
||||
|
||||
density = 2.700*g/cm3;
|
||||
a = 26.98*g/mole;
|
||||
Al = new G4Material(name="Aluminium", z=13., a, density);
|
||||
|
||||
//define titanium
|
||||
density = 4.54 *g/cm3;
|
||||
a = 47.867*g/mole;
|
||||
Ti = new G4Material(name="Titanium",z=22.,a,density);
|
||||
|
||||
|
||||
//define Uranium
|
||||
// density = 19050*kg/m3;
|
||||
// a = 238.02891*g/mole;
|
||||
// G4Material* U = new G4Material(name="Uranium",z=92.,a,density);
|
||||
|
||||
//define Tin
|
||||
density = 7310*kg/m3;
|
||||
a = 118.710*g/mole;
|
||||
Sn = new G4Material(name="Tin",z=50.,a,density);
|
||||
|
||||
//define lead
|
||||
|
||||
density = 11.35*g/cm3;
|
||||
a=207.19*g/mole;
|
||||
Pb = new G4Material(name="Lead",z=82.,a,density);
|
||||
|
||||
//define scintillator
|
||||
|
||||
density = 1.032*g/cm3;
|
||||
Sci = new G4Material(name="Scintillator", density, ncomponents=2);
|
||||
Sci->AddElement(C, natoms=9);
|
||||
Sci->AddElement(H, natoms=10);
|
||||
|
||||
|
||||
//define air
|
||||
|
||||
|
||||
density = 1.290*mg/cm3;
|
||||
Air = new G4Material(name="Air" , density, ncomponents=2);
|
||||
Air->AddElement(N, fractionmass=0.7);
|
||||
Air->AddElement(O, fractionmass=0.3);
|
||||
|
||||
//define vacuum
|
||||
|
||||
density = universe_mean_density; //from PhysicalConstants.h
|
||||
pressure = 3.e-18*pascal;
|
||||
temperature = 2.73*kelvin;
|
||||
Vacuum = new G4Material(name="Galactic", z=1., a=1.01*g/mole, density,
|
||||
kStateGas,temperature,pressure);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//define basalt
|
||||
density = 3.*g/cm3;
|
||||
basalt = new G4Material(name="Basalt", density, ncomponents=7);
|
||||
basalt->AddElement(Fe, fractionmass=0.1200);
|
||||
basalt->AddElement(elTi, fractionmass=0.0160);
|
||||
basalt->AddElement(Ca, fractionmass=0.0750);
|
||||
basalt->AddElement(elSi, fractionmass=0.2160);
|
||||
basalt->AddElement(elAl, fractionmass=0.0710);
|
||||
basalt->AddElement(Mg, fractionmass=0.0590);
|
||||
basalt->AddElement(O , fractionmass=0.4430);
|
||||
|
||||
// end basalt
|
||||
|
||||
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,551 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: XrayFluoMercuryDetectorConstruction.cc
|
||||
// GEANT4 tag $Name: XrayFluo-V05-02-06
|
||||
//
|
||||
// Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it)
|
||||
//
|
||||
// History:
|
||||
// -----------
|
||||
// 08 Sep 2003 Alfonso Mantero Created
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#include "XrayFluoMercuryDetectorConstruction.hh"
|
||||
#include "XrayFluoMercuryDetectorMessenger.hh"
|
||||
#include "XrayFluoSD.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Sphere.hh"
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4UserLimits.hh"
|
||||
#include "XrayFluoMaterials.hh"
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
|
||||
XrayFluoMercuryDetectorConstruction::XrayFluoMercuryDetectorConstruction()
|
||||
: detectorType(0),mercuryGranularity(false), DeviceSizeX(0),
|
||||
DeviceSizeY(0),DeviceThickness(0),
|
||||
solidWorld(0),logicWorld(0),physiWorld(0),
|
||||
solidHPGe(0),logicHPGe(0),physiHPGe(0),
|
||||
solidScreen(0),logicScreen(0),physiScreen(0),
|
||||
solidMercury (0),logicMercury(0),physiMercury (0),
|
||||
solidOhmicPos(0),logicOhmicPos(0), physiOhmicPos(0),
|
||||
solidOhmicNeg(0),logicOhmicNeg(0), physiOhmicNeg(0),
|
||||
solidPixel(0),logicPixel(0), physiPixel(0),
|
||||
screenMaterial(0),OhmicPosMaterial(0), OhmicNegMaterial(0),
|
||||
pixelMaterial(0),mercuryMaterial(0),
|
||||
defaultMaterial(0),HPGeSD(0)
|
||||
|
||||
{
|
||||
materials = XrayFluoMaterials::GetInstance();
|
||||
|
||||
DefineDefaultMaterials();
|
||||
|
||||
NbOfPixelRows = 1; // should be 1
|
||||
NbOfPixelColumns = 1; // should be 1
|
||||
NbOfPixels = NbOfPixelRows*NbOfPixelColumns;
|
||||
PixelSizeXY = std::sqrt(40.) * mm ; // should be std::sqrt(40) * mm
|
||||
PixelThickness = 3.5 * mm ; //should be 3.5 mm
|
||||
|
||||
G4cout << "PixelThickness(mm): "<< PixelThickness/mm << G4endl;
|
||||
G4cout << "PixelSizeXY(cm): "<< PixelSizeXY/cm << G4endl;
|
||||
|
||||
ContactSizeXY = std::sqrt(40.) * mm ; //should be the same as PixelSize or lower
|
||||
|
||||
mercuryDia = 2 * 4880 * km ;
|
||||
sunDia = 1390000 * km ;
|
||||
mercurySunDistance = 57910000 * km ;
|
||||
|
||||
|
||||
OhmicNegThickness = 0.005*mm ;
|
||||
OhmicPosThickness = 0.005*mm ;
|
||||
|
||||
screenThickness = 5 * mm ;
|
||||
|
||||
ThetaHPGe = 135. * deg ;
|
||||
PhiHPGe = 225. * deg ;
|
||||
|
||||
|
||||
distDe = (mercuryDia/2 + 400 * km);
|
||||
|
||||
distScreen = distDe + (screenThickness+PixelThickness)/2+OhmicPosThickness ;
|
||||
|
||||
distOptic = distDe - 1.*m;
|
||||
|
||||
opticThickness = 1.* cm ;
|
||||
opticDia = 21. * cm ;
|
||||
opticAperture = 1. * deg;
|
||||
|
||||
PixelCopyNb=0;
|
||||
grainCopyNb=0;
|
||||
G4String defaultDetectorType = "sili";
|
||||
ComputeApparateParameters();
|
||||
SetDetectorType(defaultDetectorType);
|
||||
|
||||
// create commands for interactive definition of the apparate
|
||||
|
||||
detectorMessenger = new XrayFluoMercuryDetectorMessenger(this);
|
||||
G4cout << "XrayFluoMercuryDetectorConstruction created" << G4endl;
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
|
||||
XrayFluoMercuryDetectorConstruction* XrayFluoMercuryDetectorConstruction::instance = 0;
|
||||
|
||||
XrayFluoMercuryDetectorConstruction* XrayFluoMercuryDetectorConstruction::GetInstance()
|
||||
{
|
||||
if (instance == 0)
|
||||
{
|
||||
instance = new XrayFluoMercuryDetectorConstruction;
|
||||
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
void XrayFluoMercuryDetectorConstruction::SetDetectorType(G4String type)
|
||||
{
|
||||
|
||||
if (type=="sili")
|
||||
{
|
||||
detectorType = XrayFluoSiLiDetectorType::GetInstance();
|
||||
}
|
||||
else if (type=="hpge")
|
||||
{
|
||||
detectorType = XrayFluoHPGeDetectorType::GetInstance();
|
||||
}
|
||||
else
|
||||
{
|
||||
G4String excep = type + "detector type unknown";
|
||||
G4Exception(excep);
|
||||
}
|
||||
}
|
||||
|
||||
XrayFluoVDetectorType* XrayFluoMercuryDetectorConstruction::GetDetectorType()
|
||||
{
|
||||
return detectorType;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoMercuryDetectorConstruction::~XrayFluoMercuryDetectorConstruction()
|
||||
|
||||
{
|
||||
delete detectorMessenger;
|
||||
delete detectorType;
|
||||
G4cout << "XrayFluoMercuryDetectorConstruction deleted" << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
G4VPhysicalVolume* XrayFluoMercuryDetectorConstruction::Construct()
|
||||
{
|
||||
return ConstructApparate();
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoMercuryDetectorConstruction::DefineDefaultMaterials()
|
||||
{
|
||||
|
||||
|
||||
//define materials of the apparate
|
||||
|
||||
mercuryMaterial = materials->GetMaterial("Anorthosite");
|
||||
screenMaterial = materials->GetMaterial("Lead");
|
||||
pixelMaterial = materials->GetMaterial("Silicon");
|
||||
OhmicPosMaterial = materials->GetMaterial("Copper");
|
||||
OhmicNegMaterial = materials->GetMaterial("Lead");
|
||||
defaultMaterial = materials->GetMaterial("Galactic");
|
||||
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
G4VPhysicalVolume* XrayFluoMercuryDetectorConstruction::ConstructApparate()
|
||||
{
|
||||
// complete the apparate parameters definition
|
||||
|
||||
ComputeApparateParameters();
|
||||
|
||||
//world
|
||||
|
||||
solidWorld = new G4Box("World", //its name
|
||||
WorldSizeXY/2,WorldSizeXY/2,WorldSizeZ/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
|
||||
0, //its mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
|
||||
//detector
|
||||
|
||||
solidHPGe = 0; physiHPGe = 0; logicHPGe=0;
|
||||
solidPixel=0; logicPixel=0; physiPixel=0;
|
||||
|
||||
if (DeviceThickness > 0.)
|
||||
{
|
||||
solidHPGe = new G4Box("HPGeDetector", //its name
|
||||
DeviceSizeX/2,DeviceSizeY/2,DeviceThickness/2);//size
|
||||
|
||||
|
||||
logicHPGe = new G4LogicalVolume(solidHPGe, //its solid
|
||||
defaultMaterial, //its material
|
||||
"HPGeDetector"); //its name
|
||||
|
||||
zRotPhiHPGe.rotateX(PhiHPGe);
|
||||
G4double x,y,z;
|
||||
|
||||
z = distDe * std::cos(ThetaHPGe);
|
||||
y = distScreen * std::sin(ThetaHPGe);
|
||||
x = 0.*cm;
|
||||
|
||||
physiHPGe = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)),
|
||||
"HPGeDetector", //its name
|
||||
logicHPGe, //its logical volume
|
||||
physiWorld, //its mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
}
|
||||
// Pixel
|
||||
|
||||
|
||||
|
||||
|
||||
for ( G4int j=0; j < NbOfPixelColumns ; j++ )
|
||||
{ for ( G4int i=0; i < NbOfPixelRows ; i++ )
|
||||
{
|
||||
solidPixel=0; logicPixel=0; physiPixel=0;
|
||||
if (PixelThickness > 0.)
|
||||
solidPixel = new G4Box("Pixel",
|
||||
PixelSizeXY/2,PixelSizeXY/2, PixelThickness/2);
|
||||
|
||||
logicPixel = new G4LogicalVolume(solidPixel,
|
||||
pixelMaterial, //its material
|
||||
"Pixel"); //its name
|
||||
|
||||
/*
|
||||
zRotPhiHPGe.rotateX(PhiHPGe);
|
||||
G4double x,y,z;
|
||||
z = distDe * std::cos(ThetaHPGe);
|
||||
y =distDe * std::sin(ThetaHPGe);
|
||||
x = 0.*cm;*/
|
||||
physiPixel = new G4PVPlacement(0,
|
||||
G4ThreeVector(0,
|
||||
i*PixelSizeXY,
|
||||
j*PixelSizeXY ),
|
||||
"Pixel",
|
||||
logicPixel, //its logical volume
|
||||
physiHPGe, //its mother volume
|
||||
false, //no boolean operation
|
||||
PixelCopyNb);//copy number
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// OhmicNeg
|
||||
|
||||
solidOhmicNeg=0; logicOhmicNeg=0; physiOhmicNeg=0;
|
||||
|
||||
if (OhmicNegThickness > 0.)
|
||||
{ solidOhmicNeg = new G4Box("OhmicNeg", //its name
|
||||
PixelSizeXY/2,PixelSizeXY/2,OhmicNegThickness/2);
|
||||
|
||||
logicOhmicNeg = new G4LogicalVolume(solidOhmicNeg, //its solid
|
||||
OhmicNegMaterial, //its material
|
||||
"OhmicNeg"); //its name
|
||||
|
||||
physiOhmicNeg = new G4PVPlacement(0,
|
||||
G4ThreeVector
|
||||
(0.,
|
||||
0.,
|
||||
(PixelThickness+OhmicNegThickness)/2),
|
||||
"OhmicNeg", //its name
|
||||
logicOhmicNeg, //its logical volume
|
||||
physiHPGe, //its mother
|
||||
false, //no boulean operat
|
||||
PixelCopyNb); //copy number
|
||||
|
||||
}
|
||||
// OhmicPos
|
||||
solidOhmicPos=0; logicOhmicPos=0; physiOhmicPos=0;
|
||||
|
||||
if (OhmicPosThickness > 0.)
|
||||
{ solidOhmicPos = new G4Box("OhmicPos", //its name
|
||||
PixelSizeXY/2,PixelSizeXY/2,OhmicPosThickness/2);
|
||||
|
||||
logicOhmicPos = new G4LogicalVolume(solidOhmicPos, //its solid
|
||||
OhmicPosMaterial, //its material
|
||||
"OhmicPos"); //its name
|
||||
|
||||
physiOhmicPos = new G4PVPlacement(0,
|
||||
G4ThreeVector(0.,
|
||||
0.,
|
||||
(-PixelThickness-OhmicPosThickness)/2),
|
||||
"OhmicPos",
|
||||
logicOhmicPos,
|
||||
physiHPGe,
|
||||
false,
|
||||
PixelCopyNb);
|
||||
|
||||
}
|
||||
|
||||
PixelCopyNb += PixelCopyNb;
|
||||
G4cout << "PixelCopyNb: " << PixelCopyNb << G4endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Optics
|
||||
|
||||
if (DeviceThickness > 0.)
|
||||
{
|
||||
solidOptic = new G4Tubs("DetectorOptic", //its name
|
||||
0.,opticDia/2, opticThickness, 0.,2.*pi);//size
|
||||
|
||||
|
||||
logicOptic = new G4LogicalVolume(solidOptic, //its solid
|
||||
defaultMaterial, //its material
|
||||
"DetectorOptic"); //its name
|
||||
|
||||
//zRotPhiHPGe.rotateX(PhiHPGe);
|
||||
G4double x,y,z;
|
||||
z = distOptic * std::cos(ThetaHPGe);
|
||||
y = distOptic * std::sin(ThetaHPGe);
|
||||
x = 0.*cm;
|
||||
physiOptic = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)),
|
||||
"DetectorOptic", //its name
|
||||
logicOptic, //its logical volume
|
||||
physiWorld, //its mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
}
|
||||
|
||||
|
||||
// Screen
|
||||
|
||||
if (DeviceThickness > 0.)
|
||||
{
|
||||
solidScreen = new G4Box("DetectorScreen", //its name
|
||||
screenSizeXY/2,screenSizeXY/2,screenThickness/2);//size
|
||||
|
||||
|
||||
logicScreen = new G4LogicalVolume(solidScreen, //its solid
|
||||
defaultMaterial, //its material
|
||||
"DetectorScreen"); //its name
|
||||
|
||||
//zRotPhiHPGe.rotateX(PhiHPGe);
|
||||
G4double x,y,z;
|
||||
G4cout << "distScreen: "<< distScreen/m <<G4endl;
|
||||
z = distScreen * std::cos(ThetaHPGe);
|
||||
y = distScreen * std::sin(ThetaHPGe);
|
||||
x = 0.*cm;
|
||||
physiScreen = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)),
|
||||
"DetectorScreen", //its name
|
||||
logicScreen, //its logical volume
|
||||
physiWorld, //its mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
}
|
||||
|
||||
//Mercury
|
||||
|
||||
|
||||
solidMercury=0; logicMercury=0; physiMercury=0;
|
||||
if (mercuryDia > 0.)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
solidMercury = new G4Sphere("Mercury",0.,mercuryDia/2., 0., twopi, 0., pi);
|
||||
|
||||
logicMercury= new G4LogicalVolume(solidMercury, //its solid
|
||||
mercuryMaterial, //its material
|
||||
"Mercury"); //its name
|
||||
|
||||
physiMercury = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(), //at (0,0,0)
|
||||
"Mercury", //its name
|
||||
logicMercury, //its logical volume
|
||||
physiWorld, //its mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
|
||||
}
|
||||
|
||||
|
||||
G4SDManager* SDman = G4SDManager::GetSDMpointer();
|
||||
|
||||
if(!HPGeSD)
|
||||
{
|
||||
HPGeSD = new XrayFluoSD ("HPGeSD",this);
|
||||
SDman->AddNewDetector(HPGeSD);
|
||||
}
|
||||
|
||||
|
||||
if (logicPixel)
|
||||
{
|
||||
logicPixel->SetSensitiveDetector(HPGeSD);
|
||||
}
|
||||
|
||||
// Visualization attributes
|
||||
|
||||
|
||||
logicWorld->SetVisAttributes (G4VisAttributes::Invisible);
|
||||
G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
|
||||
G4VisAttributes * yellow= new G4VisAttributes( G4Colour(255/255. ,255/255. ,51/255. ));
|
||||
G4VisAttributes * red= new G4VisAttributes( G4Colour(255/255. , 0/255. , 0/255. ));
|
||||
G4VisAttributes * blue= new G4VisAttributes( G4Colour(0/255. , 0/255. , 255/255. ));
|
||||
G4VisAttributes * gray= new G4VisAttributes( G4Colour(128/255. , 128/255. , 128/255. ));
|
||||
//G4VisAttributes * green= new G4VisAttributes( G4Colour(25/255. , 255/255. , 25/255. ));
|
||||
yellow->SetVisibility(true);
|
||||
yellow->SetForceSolid(true);
|
||||
red->SetVisibility(true);
|
||||
red->SetForceSolid(true);
|
||||
blue->SetVisibility(true);
|
||||
gray->SetVisibility(true);
|
||||
gray->SetForceSolid(true);
|
||||
simpleBoxVisAtt->SetVisibility(true);
|
||||
|
||||
//logicWorld->SetVisAttributes (simpleBoxVisAtt);
|
||||
|
||||
logicPixel->SetVisAttributes(blue);
|
||||
logicHPGe->SetVisAttributes(G4VisAttributes::Invisible);
|
||||
|
||||
logicMercury->SetVisAttributes(gray);
|
||||
|
||||
|
||||
logicScreen->SetVisAttributes(red);
|
||||
logicOhmicNeg->SetVisAttributes(yellow);
|
||||
logicOhmicPos->SetVisAttributes(yellow);
|
||||
logicOptic->SetVisAttributes(gray);
|
||||
|
||||
|
||||
if (mercuryGranularity) logicGrain->SetVisAttributes(gray);
|
||||
|
||||
//always return the physical World
|
||||
|
||||
PrintApparateParameters();
|
||||
|
||||
return physiWorld;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoMercuryDetectorConstruction::PrintApparateParameters()
|
||||
{
|
||||
G4cout << "-----------------------------------------------------------------------"
|
||||
<< G4endl
|
||||
<< "The mercury is a sphere whose diamter is: "
|
||||
<< G4endl
|
||||
<< mercuryDia/km
|
||||
<< " Km "
|
||||
<< G4endl
|
||||
<<" Material: " << logicMercury->GetMaterial()->GetName()
|
||||
<<G4endl
|
||||
<<"The Detector is a slice " << DeviceThickness/(1.e-6*m)
|
||||
<< " micron thick of " << pixelMaterial->GetName()<<G4endl
|
||||
<<"-------------------------------------------------------------------------"
|
||||
<< G4endl;
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoMercuryDetectorConstruction::UpdateGeometry()
|
||||
{
|
||||
|
||||
|
||||
delete solidHPGe;
|
||||
delete logicHPGe;
|
||||
delete physiHPGe;
|
||||
delete solidPixel;
|
||||
delete logicPixel;
|
||||
delete physiPixel;
|
||||
delete solidOhmicNeg;
|
||||
delete logicOhmicNeg;
|
||||
delete physiOhmicNeg;
|
||||
delete solidOhmicPos;
|
||||
delete logicOhmicPos;
|
||||
delete physiOhmicPos;
|
||||
delete solidOptic;
|
||||
delete logicOptic;
|
||||
delete physiOptic;
|
||||
delete solidMercury;
|
||||
delete logicMercury;
|
||||
delete physiMercury;
|
||||
delete solidScreen;
|
||||
delete logicScreen;
|
||||
delete physiScreen;
|
||||
delete solidWorld;
|
||||
delete logicWorld;
|
||||
delete physiWorld;
|
||||
|
||||
zRotPhiHPGe.rotateX(-1.*PhiHPGe);
|
||||
ComputeApparateParameters();
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(ConstructApparate());
|
||||
}
|
||||
|
||||
void XrayFluoMercuryDetectorConstruction::SetMercuryMaterial(G4String newMaterial)
|
||||
{
|
||||
|
||||
|
||||
G4cout << "New Mercury Material: " << newMaterial << G4endl;
|
||||
logicMercury->SetMaterial(materials->GetMaterial(newMaterial));
|
||||
PrintApparateParameters();
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: XrayFluoMercuryDetectorMessenger.cc
|
||||
// GEANT4 tag $Name:
|
||||
//
|
||||
// Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it)
|
||||
//
|
||||
// History:
|
||||
// -----------
|
||||
//
|
||||
// 18 Sep 2003 Alfonso Mantero created
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
|
||||
#include "XrayFluoMercuryDetectorMessenger.hh"
|
||||
#include "XrayFluoMercuryDetectorConstruction.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoMercuryDetectorMessenger::XrayFluoMercuryDetectorMessenger(XrayFluoMercuryDetectorConstruction * Det)
|
||||
:Detector(Det)
|
||||
{
|
||||
detDir = new G4UIdirectory("/apparate/");
|
||||
detDir->SetGuidance("detector control.");
|
||||
|
||||
UpdateCmd = new G4UIcmdWithoutParameter("/apparate/update",this);
|
||||
UpdateCmd->SetGuidance("Update apparate geometry.");
|
||||
UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
|
||||
UpdateCmd->SetGuidance("if you changed geometrical value(s): /apparate/GrainDiameter and /apparate/sampleGranularity");
|
||||
|
||||
UpdateCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
sampleCmd = new G4UIcmdWithAString("/apparate/mercuryMaterial",this);
|
||||
sampleCmd->SetGuidance("select a diferent material for the mercury");
|
||||
sampleCmd->SetParameterName("material",true);
|
||||
sampleCmd->SetDefaultValue("mars1");
|
||||
sampleCmd->SetCandidates("Dolorite Anorthosite Mars1");
|
||||
sampleCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
detectorCmd = new G4UIcmdWithAString("/apparate/detector",this);
|
||||
detectorCmd->SetGuidance("select a diferent detectorType");
|
||||
detectorCmd->SetParameterName("detector",true);
|
||||
detectorCmd->SetDefaultValue("sili");
|
||||
detectorCmd->SetCandidates("sili hpge");
|
||||
detectorCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
latitudeAngleCmd = new G4UIcmdWithADoubleAndUnit( "/apparate/latitude",this );
|
||||
latitudeAngleCmd->SetGuidance( "Set latitude angle of the spacecraft" );
|
||||
latitudeAngleCmd->SetGuidance( "After this, /apparate/update must be executed before BeamOn" );
|
||||
latitudeAngleCmd->SetGuidance( "Default: 45 deg " );
|
||||
latitudeAngleCmd->SetParameterName( "Latitude Angle", true, true );
|
||||
latitudeAngleCmd->SetDefaultUnit( "deg" );
|
||||
latitudeAngleCmd->SetUnitCategory( "Angle" );
|
||||
latitudeAngleCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
orbitHeightCmd = new G4UIcmdWithADoubleAndUnit( "/apparate/orbitHeight",this );
|
||||
orbitHeightCmd->SetGuidance( "Set height of the spacecraft above Mercuey Surface" );
|
||||
orbitHeightCmd->SetGuidance( "After this, /apparate/update must be executed before BeamOn" );
|
||||
orbitHeightCmd->SetGuidance( "Default: 400 km " );
|
||||
orbitHeightCmd->SetParameterName( "Spacecraft Altitude", true, true );
|
||||
orbitHeightCmd->SetDefaultUnit( "km" );
|
||||
orbitHeightCmd->SetUnitCategory( "Length" );
|
||||
orbitHeightCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
|
||||
|
||||
// granularityFlagCmd= new G4UIcmdWithABool("/apparate/sampleGranularity",this);
|
||||
// granularityFlagCmd->SetGuidance("Set if sample granularity is present");
|
||||
// granularityFlagCmd->SetGuidance( "After this, /apparate/update must be executed before BeamOn" );
|
||||
// granularityFlagCmd->SetParameterName("Granularity Flag",true);
|
||||
// granularityFlagCmd->SetDefaultValue(false);
|
||||
// granularityFlagCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoMercuryDetectorMessenger::~XrayFluoMercuryDetectorMessenger()
|
||||
{
|
||||
delete UpdateCmd;
|
||||
delete detDir;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoMercuryDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
|
||||
{
|
||||
if( command == UpdateCmd )
|
||||
{ Detector->UpdateGeometry(); }
|
||||
|
||||
else if ( command == sampleCmd )
|
||||
{ Detector->SetMercuryMaterial(newValue);}
|
||||
|
||||
else if ( command == detectorCmd )
|
||||
{ Detector->SetDetectorType(newValue);}
|
||||
|
||||
else if ( command == latitudeAngleCmd )
|
||||
{
|
||||
G4double newAngle = latitudeAngleCmd->GetNewDoubleValue(newValue);
|
||||
Detector->SetLatitude(newAngle);
|
||||
}
|
||||
|
||||
else if ( command == orbitHeightCmd )
|
||||
{
|
||||
G4double newAngle = orbitHeightCmd->GetNewDoubleValue(newValue);
|
||||
Detector->SetOribitHeight(newAngle);
|
||||
}
|
||||
|
||||
|
||||
// else if ( command == granularityFlagCmd )
|
||||
// {
|
||||
// Detector->DeleteGrainObjects();
|
||||
// G4bool newGranFlag = granularityFlagCmd->GetNewBoolValue(newValue);
|
||||
// Detector->SetMercuryGranularity(newGranFlag);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: XrayFluoPlanePrimaryGeneratorAction.cc
|
||||
// GEANT4 tag $Name:
|
||||
//
|
||||
// Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it)
|
||||
//
|
||||
// History:
|
||||
// -----------
|
||||
// 02 Sep 2003 Alfonso Mantero created
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#include "XrayFluoMercuryPrimaryGeneratorAction.hh"
|
||||
#include "G4DataVector.hh"
|
||||
#include "XrayFluoMercuryDetectorConstruction.hh"
|
||||
#include "XrayFluoMercuryPrimaryGeneratorMessenger.hh"
|
||||
#include "XrayFluoRunAction.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "XrayFluoAnalysisManager.hh"
|
||||
#include "XrayFluoDataSet.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoMercuryPrimaryGeneratorAction::XrayFluoMercuryPrimaryGeneratorAction(XrayFluoMercuryDetectorConstruction* XrayFluoDC)
|
||||
:globalFlag(false),spectrum("off")
|
||||
{
|
||||
|
||||
XrayFluoDetector = XrayFluoDC;
|
||||
|
||||
G4int n_particle = 1;
|
||||
particleGun = new G4ParticleGun(n_particle);
|
||||
|
||||
//create a messenger for this class
|
||||
gunMessenger = new XrayFluoMercuryPrimaryGeneratorMessenger(this);
|
||||
runManager = new XrayFluoRunAction();
|
||||
|
||||
// default particle kinematic
|
||||
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
G4String particleName;
|
||||
G4ParticleDefinition* particle
|
||||
= particleTable->FindParticle(particleName="gamma");
|
||||
particleGun->SetParticleDefinition(particle);
|
||||
particleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,-1.));
|
||||
|
||||
|
||||
particleGun->SetParticleEnergy(10.*keV);
|
||||
G4double position = -0.5*(XrayFluoDetector->GetWorldSizeZ());
|
||||
particleGun->SetParticlePosition(G4ThreeVector(0.*cm,0.*cm,position));
|
||||
|
||||
G4cout << "XrayFluoMercuryPrimaryGeneratorAction created" << G4endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoMercuryPrimaryGeneratorAction::~XrayFluoMercuryPrimaryGeneratorAction()
|
||||
{
|
||||
delete particleGun;
|
||||
delete gunMessenger;
|
||||
delete runManager;
|
||||
|
||||
G4cout << "XrayFluoMercuryPrimaryGeneratorAction deleted" << G4endl;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoMercuryPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
//this function is called at the begining of event
|
||||
//
|
||||
|
||||
// Conidering the sunas a Poin-like source.
|
||||
|
||||
G4double z0 = -0.5*(XrayFluoDetector->GetWorldSizeZ());
|
||||
G4double y0 = 0.*m, x0 = 0.*m;
|
||||
|
||||
|
||||
// Let's try to illuminate only the prtion of Mercury surface that can be seen by the detector.
|
||||
|
||||
G4double spacecraftLatitude = XrayFluoDetector->GetOrbitInclination();
|
||||
G4double mercuryDia = XrayFluoDetector->GetMercuryDia();
|
||||
G4double sunDia = XrayFluoDetector->GetSunDia();
|
||||
G4double opticField = XrayFluoDetector->GetOpticAperture();
|
||||
|
||||
|
||||
G4double a = 2*std::tan(opticField/2);
|
||||
|
||||
// if (!pointLikeFlag) {
|
||||
|
||||
// let's decide from wich point of the sun surface the particle is coming:
|
||||
|
||||
G4double theta = pi/2. * G4UniformRand();
|
||||
G4double phi = 2. * pi * G4UniformRand();
|
||||
G4double rho = sunDia/2;
|
||||
|
||||
G4double sunPosX = x0 + rho * std::sin(theta) * std::cos(phi);
|
||||
G4double sunPosY = y0 + rho * std::sin(theta) * std::sin(phi);
|
||||
G4double sunPosZ = z0 + rho * std::cos(theta);
|
||||
|
||||
particleGun->SetParticlePosition(G4ThreeVector(sunPosX,sunPosY,sunPosZ));
|
||||
|
||||
// the angle at the center of Mercury subtending the area seen by the optics:
|
||||
G4double alpha = 2 * a/mercuryDia;
|
||||
|
||||
if(!globalFlag){
|
||||
theta = alpha * G4UniformRand() + (180.*deg - spacecraftLatitude)-alpha/2.;
|
||||
phi = alpha * G4UniformRand() + 90. * deg - alpha/2.;
|
||||
}
|
||||
|
||||
else if(globalFlag){
|
||||
theta = pi/2. * rad * G4UniformRand() + 90.*deg ; //was 900., probably an error
|
||||
phi = 2*pi*rad * G4UniformRand() ;
|
||||
}
|
||||
|
||||
rho = mercuryDia/2.;
|
||||
|
||||
G4double mercuryPosX = rho * std::sin(theta) * std::cos(phi);
|
||||
G4double mercuryPosY = rho * std::sin(theta) * std::sin(phi);
|
||||
G4double mercuryPosZ = rho * std::cos(theta);
|
||||
|
||||
particleGun->SetParticleMomentumDirection(
|
||||
G4ThreeVector(mercuryPosX-sunPosX ,mercuryPosY-sunPosY,mercuryPosZ-sunPosZ));
|
||||
|
||||
// }
|
||||
// if (pointLikeFlag) {
|
||||
|
||||
// // theta is the angle that the mean direction of the incident light (on the desired
|
||||
// // point of the surface of Mercury) makes with the Z-axis
|
||||
// G4double theta = std::asin( mercuryDia/2. * std::sin(spacecraftLatitude) /
|
||||
// std::sqrt(std::pow(z0,2)+std::pow(mercuryDia/2.,2)-2*mercuryDia/2.*z0*std::cos(spacecraftLatitude)) );
|
||||
|
||||
// // on the y axis, the light emitted from the Sun must be in [theta-phi;theta+phi]
|
||||
// G4double phi = std::asin( mercuryDia/2.*std::sin(spacecraftLatitude) + a*std::cos(spacecraftLatitude) /
|
||||
// std::sqrt( std::pow(mercuryDia/2.*std::sin(spacecraftLatitude) + a*std::cos(spacecraftLatitude) , 2) +
|
||||
// std::pow(z0 - mercuryDia/2.*std::cos(spacecraftLatitude) - a*std::sin(spacecraftLatitude) , 2)) )
|
||||
// - theta;
|
||||
|
||||
// // on the x axis, the light emitted from the Sun must be in [-zeta;zeta]
|
||||
// G4double zeta = std::atan( a/std::sqrt(std::pow(z0,2)+std::pow(mercuryDia,2)-2*mercuryDia*z0*std::cos(spacecraftLatitude)) );
|
||||
|
||||
|
||||
|
||||
// //alpha in [-zeta;zeta]
|
||||
// G4double alpha = (2*zeta)*G4UniformRand() - zeta;
|
||||
// //beta in [theta-phi;theta+phi]
|
||||
// G4double beta = (G4UniformRand()*2*phi) - phi + theta;
|
||||
|
||||
// G4double dirY = std::sin(beta);
|
||||
// G4double dirX = std::sin(alpha);
|
||||
|
||||
// particleGun->SetParticleMomentumDirection(G4ThreeVector(dirX.,dirY,1.));
|
||||
|
||||
// particleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
//shoot particles according to a certain spectrum
|
||||
if (spectrum =="on")
|
||||
{
|
||||
G4String particle = particleGun->GetParticleDefinition()
|
||||
->GetParticleName();
|
||||
if(particle == "proton"|| particle == "alpha")
|
||||
{
|
||||
G4DataVector* energies = runManager->GetEnergies();
|
||||
G4DataVector* data = runManager->GetData();
|
||||
|
||||
G4double sum = runManager->GetDataSum();
|
||||
G4double partSum = 0;
|
||||
G4int j = 0;
|
||||
G4double random= sum*G4UniformRand();
|
||||
while (partSum<random)
|
||||
{
|
||||
partSum += (*data)[j];
|
||||
j++;
|
||||
}
|
||||
|
||||
particleGun->SetParticleEnergy((*energies)[j]);
|
||||
|
||||
}
|
||||
else if (particle == "gamma")
|
||||
{
|
||||
const XrayFluoDataSet* dataSet = runManager->GetGammaSet();
|
||||
|
||||
G4int i = 0;
|
||||
G4int id = 0;
|
||||
G4double minEnergy = 0. * keV;
|
||||
G4double particleEnergy= 0.;
|
||||
G4double maxEnergy = 10. * keV;
|
||||
G4double energyRange = maxEnergy - minEnergy;
|
||||
|
||||
while ( i == 0)
|
||||
{
|
||||
G4double random = G4UniformRand();
|
||||
|
||||
G4double randomNum = G4UniformRand(); //*5.0E6;
|
||||
|
||||
particleEnergy = (random*energyRange) + minEnergy;
|
||||
|
||||
if ((dataSet->FindValue(particleEnergy,id)) > randomNum)
|
||||
{
|
||||
i = 1;
|
||||
|
||||
}
|
||||
}
|
||||
particleGun->SetParticleEnergy(particleEnergy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef G4ANALYSIS_USE
|
||||
|
||||
G4double partEnergy = particleGun->GetParticleEnergy();
|
||||
XrayFluoAnalysisManager* analysis = XrayFluoAnalysisManager::getInstance();
|
||||
analysis->analysePrimaryGenerator(partEnergy/keV);
|
||||
|
||||
#endif
|
||||
|
||||
particleGun->GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: XrayFluoMercuryPrimarygeneratorMessenger.cc
|
||||
// GEANT4 tag $Name:
|
||||
//
|
||||
// Author: Alfonso Mantero (Alfonso.mantero@ge.infn.it)
|
||||
//
|
||||
// History:
|
||||
// -----------
|
||||
// 19 Sep 2003 Alfonso Mantero created
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#include "XrayFluoMercuryPrimaryGeneratorMessenger.hh"
|
||||
#include "XrayFluoMercuryPrimaryGeneratorAction.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoMercuryPrimaryGeneratorMessenger::XrayFluoMercuryPrimaryGeneratorMessenger(XrayFluoMercuryPrimaryGeneratorAction* XrayFluoGun)
|
||||
:XrayFluoAction(XrayFluoGun)
|
||||
{
|
||||
spectrum = new G4UIcmdWithAString("/gun/spectrum",this);
|
||||
spectrum->SetGuidance("Shoot the incident particle with a certain energy spectrum.");
|
||||
spectrum->SetGuidance(" Choice : on(default), off");
|
||||
spectrum->SetParameterName("choice",true);
|
||||
spectrum->SetDefaultValue("on");
|
||||
spectrum->SetCandidates("on off");
|
||||
spectrum->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
globalCmd = new G4UIcmdWithABool("/gun/globalIllumunation",this);
|
||||
globalCmd->SetGuidance("Illuminate the entire Mercury globe, not only the area seen by the optics");
|
||||
globalCmd->SetGuidance("Choice : true, 1, false, 0");
|
||||
globalCmd->SetParameterName("illuminaton",true);
|
||||
globalCmd->SetDefaultValue("false");
|
||||
globalCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
G4cout << "XrayFluoMercuryPrimaryGeneratorMessenger created" << G4endl;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoMercuryPrimaryGeneratorMessenger::~XrayFluoMercuryPrimaryGeneratorMessenger()
|
||||
{
|
||||
delete spectrum;
|
||||
delete globalCmd;
|
||||
|
||||
G4cout << "XrayFluoMercuryPrimaryGeneratorMessenger deleted" << G4endl;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoMercuryPrimaryGeneratorMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
{
|
||||
|
||||
if( command == spectrum )
|
||||
{ XrayFluoAction->SetSpectrum(newValue);}
|
||||
|
||||
if( command == globalCmd )
|
||||
{
|
||||
G4bool newGlobalFlag = globalCmd->GetNewBoolValue(newValue);
|
||||
XrayFluoAction->SetGlobalFlag(newGlobalFlag);
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
@@ -353,7 +353,7 @@ void XrayFluoPhysicsList::SetCutsByEnergy(G4double val)
|
||||
{
|
||||
G4ParticleTable* theXrayFluoParticleTable = G4ParticleTable::GetParticleTable();
|
||||
|
||||
G4Material* currMat;
|
||||
G4Material* currMat=0;
|
||||
|
||||
if(pDet){
|
||||
currMat = pDet->XrayFluoDetectorConstruction::GetSampleMaterial();
|
||||
|
||||
@@ -0,0 +1,644 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: XrayFluoPlaneDetectorConstruction.cc
|
||||
// GEANT4 tag $Name: xray_fluo-V03-02-00
|
||||
//
|
||||
// Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it)
|
||||
//
|
||||
// History:
|
||||
// -----------
|
||||
// 29 aug 2003 Alfonso Mantero Created
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#include "XrayFluoPlaneDetectorConstruction.hh"
|
||||
#include "XrayFluoPlaneDetectorMessenger.hh"
|
||||
#include "XrayFluoSD.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Sphere.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4UserLimits.hh"
|
||||
#include "XrayFluoMaterials.hh"
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
|
||||
XrayFluoPlaneDetectorConstruction::XrayFluoPlaneDetectorConstruction()
|
||||
: detectorType(0),planeGranularity(false), DeviceSizeX(0),
|
||||
DeviceSizeY(0),DeviceThickness(0),
|
||||
solidWorld(0),logicWorld(0),physiWorld(0),
|
||||
solidHPGe(0),logicHPGe(0),physiHPGe(0),
|
||||
solidScreen(0),logicScreen(0),physiScreen(0),
|
||||
solidPlane (0),logicPlane(0),physiPlane (0),
|
||||
solidOhmicPos(0),logicOhmicPos(0), physiOhmicPos(0),
|
||||
solidOhmicNeg(0),logicOhmicNeg(0), physiOhmicNeg(0),
|
||||
solidPixel(0),logicPixel(0), physiPixel(0),
|
||||
screenMaterial(0),OhmicPosMaterial(0), OhmicNegMaterial(0),
|
||||
pixelMaterial(0),planeMaterial(0),
|
||||
defaultMaterial(0),HPGeSD(0)
|
||||
|
||||
{
|
||||
materials = XrayFluoMaterials::GetInstance();
|
||||
|
||||
DefineDefaultMaterials();
|
||||
|
||||
NbOfPixelRows = 1; // should be 1
|
||||
NbOfPixelColumns = 1; // should be 1
|
||||
NbOfPixels = NbOfPixelRows*NbOfPixelColumns;
|
||||
PixelSizeXY = 5 * cm; // should be 5
|
||||
PixelThickness = 3.5 * mm; //changed should be 3.5 mm
|
||||
|
||||
G4cout << "PixelThickness(mm): "<< PixelThickness/mm << G4endl;
|
||||
G4cout << "PixelSizeXY(cm): "<< PixelSizeXY/cm << G4endl;
|
||||
|
||||
ContactSizeXY = 5 * cm; //should be the same as pixelSizeXY
|
||||
planeThickness = 5 * cm;
|
||||
planeSizeXY = 5. * m;
|
||||
|
||||
OhmicNegThickness = 0.005*mm;
|
||||
OhmicPosThickness = 0.005*mm;
|
||||
|
||||
screenThickness = 5 * mm;
|
||||
|
||||
ThetaHPGe = 0. * deg;
|
||||
PhiHPGe = 0. * deg;
|
||||
|
||||
|
||||
DistDe = 0.5 * m;
|
||||
|
||||
distScreen = DistDe + (screenThickness+PixelThickness)/2+OhmicPosThickness ;
|
||||
|
||||
grainDia = 1 * mm;
|
||||
|
||||
|
||||
PixelCopyNb=0;
|
||||
grainCopyNb=0;
|
||||
G4String defaultDetectorType = "sili";
|
||||
ComputeApparateParameters();
|
||||
SetDetectorType(defaultDetectorType);
|
||||
|
||||
// create commands for interactive definition of the apparate
|
||||
|
||||
detectorMessenger = new XrayFluoPlaneDetectorMessenger(this);
|
||||
G4cout << "XrayFluoPlaneDetectorConstruction created" << G4endl;
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
|
||||
XrayFluoPlaneDetectorConstruction* XrayFluoPlaneDetectorConstruction::instance = 0;
|
||||
|
||||
XrayFluoPlaneDetectorConstruction* XrayFluoPlaneDetectorConstruction::GetInstance()
|
||||
{
|
||||
if (instance == 0)
|
||||
{
|
||||
instance = new XrayFluoPlaneDetectorConstruction;
|
||||
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
void XrayFluoPlaneDetectorConstruction::SetDetectorType(G4String type)
|
||||
{
|
||||
|
||||
if (type=="sili")
|
||||
{
|
||||
detectorType = XrayFluoSiLiDetectorType::GetInstance();
|
||||
}
|
||||
else if (type=="hpge")
|
||||
{
|
||||
detectorType = XrayFluoHPGeDetectorType::GetInstance();
|
||||
}
|
||||
else
|
||||
{
|
||||
G4String excep = type + "detector type unknown";
|
||||
G4Exception(excep);
|
||||
}
|
||||
}
|
||||
|
||||
XrayFluoVDetectorType* XrayFluoPlaneDetectorConstruction::GetDetectorType()
|
||||
{
|
||||
return detectorType;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoPlaneDetectorConstruction::~XrayFluoPlaneDetectorConstruction()
|
||||
|
||||
{
|
||||
delete detectorMessenger;
|
||||
delete detectorType;
|
||||
G4cout << "XrayFluoPlaneDetectorConstruction deleted" << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
G4VPhysicalVolume* XrayFluoPlaneDetectorConstruction::Construct()
|
||||
{
|
||||
return ConstructApparate();
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoPlaneDetectorConstruction::DefineDefaultMaterials()
|
||||
{
|
||||
|
||||
|
||||
//define materials of the apparate
|
||||
|
||||
planeMaterial = materials->GetMaterial("Anorthosite");
|
||||
screenMaterial = materials->GetMaterial("Lead");
|
||||
pixelMaterial = materials->GetMaterial("Silicon");
|
||||
OhmicPosMaterial = materials->GetMaterial("Copper");
|
||||
OhmicNegMaterial = materials->GetMaterial("Lead");
|
||||
defaultMaterial = materials->GetMaterial("Galactic");
|
||||
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
G4VPhysicalVolume* XrayFluoPlaneDetectorConstruction::ConstructApparate()
|
||||
{
|
||||
// complete the apparate parameters definition
|
||||
|
||||
//ComputeApparateParameters();
|
||||
|
||||
//world
|
||||
|
||||
solidWorld = new G4Box("World", //its name
|
||||
WorldSizeXY/2,WorldSizeXY/2,WorldSizeZ/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
|
||||
0, //its mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
|
||||
//detector
|
||||
|
||||
solidHPGe = 0; physiHPGe = 0; logicHPGe=0;
|
||||
solidPixel=0; logicPixel=0; physiPixel=0;
|
||||
|
||||
if (DeviceThickness > 0.)
|
||||
{
|
||||
solidHPGe = new G4Box("HPGeDetector", //its name
|
||||
DeviceSizeX/2,DeviceSizeY/2,DeviceThickness/2);//size
|
||||
|
||||
|
||||
logicHPGe = new G4LogicalVolume(solidHPGe, //its solid
|
||||
defaultMaterial, //its material
|
||||
"HPGeDetector"); //its name
|
||||
|
||||
zRotPhiHPGe.rotateX(PhiHPGe);
|
||||
G4double x,y,z;
|
||||
|
||||
z = -1. * DistDe; //* std::cos(ThetaHPGe);
|
||||
y = 0.*cm; //distScreen * std::sin(ThetaHPGe);
|
||||
x = 0.*cm;
|
||||
|
||||
physiHPGe = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)),
|
||||
"HPGeDetector", //its name
|
||||
logicHPGe, //its logical volume
|
||||
physiWorld, //its mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
}
|
||||
// Pixel
|
||||
|
||||
|
||||
|
||||
|
||||
for ( G4int j=0; j < NbOfPixelColumns ; j++ )
|
||||
{ for ( G4int i=0; i < NbOfPixelRows ; i++ )
|
||||
{
|
||||
solidPixel=0; logicPixel=0; physiPixel=0;
|
||||
if (PixelThickness > 0.)
|
||||
solidPixel = new G4Box("Pixel",
|
||||
PixelSizeXY/2,PixelSizeXY/2, PixelThickness/2);
|
||||
|
||||
logicPixel = new G4LogicalVolume(solidPixel,
|
||||
pixelMaterial, //its material
|
||||
"Pixel"); //its name
|
||||
|
||||
/*
|
||||
zRotPhiHPGe.rotateX(PhiHPGe);
|
||||
G4double x,y,z;
|
||||
z = DistDe * std::cos(ThetaHPGe);
|
||||
y =DistDe * std::sin(ThetaHPGe);
|
||||
x = 0.*cm;*/
|
||||
physiPixel = new G4PVPlacement(0,
|
||||
G4ThreeVector(0,
|
||||
i*PixelSizeXY,
|
||||
j*PixelSizeXY ),
|
||||
"Pixel",
|
||||
logicPixel, //its logical volume
|
||||
physiHPGe, //its mother volume
|
||||
false, //no boolean operation
|
||||
PixelCopyNb);//copy number
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// OhmicNeg
|
||||
|
||||
solidOhmicNeg=0; logicOhmicNeg=0; physiOhmicNeg=0;
|
||||
|
||||
if (OhmicNegThickness > 0.)
|
||||
{ solidOhmicNeg = new G4Box("OhmicNeg", //its name
|
||||
PixelSizeXY/2,PixelSizeXY/2,OhmicNegThickness/2);
|
||||
|
||||
logicOhmicNeg = new G4LogicalVolume(solidOhmicNeg, //its solid
|
||||
OhmicNegMaterial, //its material
|
||||
"OhmicNeg"); //its name
|
||||
|
||||
physiOhmicNeg = new G4PVPlacement(0,
|
||||
G4ThreeVector
|
||||
(0.,
|
||||
0.,
|
||||
(PixelThickness+OhmicNegThickness)/2),
|
||||
"OhmicNeg", //its name
|
||||
logicOhmicNeg, //its logical volume
|
||||
physiHPGe, //its mother
|
||||
false, //no boulean operat
|
||||
PixelCopyNb); //copy number
|
||||
|
||||
}
|
||||
// OhmicPos
|
||||
solidOhmicPos=0; logicOhmicPos=0; physiOhmicPos=0;
|
||||
|
||||
if (OhmicPosThickness > 0.)
|
||||
{ solidOhmicPos = new G4Box("OhmicPos", //its name
|
||||
PixelSizeXY/2,PixelSizeXY/2,OhmicPosThickness/2);
|
||||
|
||||
logicOhmicPos = new G4LogicalVolume(solidOhmicPos, //its solid
|
||||
OhmicPosMaterial, //its material
|
||||
"OhmicPos"); //its name
|
||||
|
||||
physiOhmicPos = new G4PVPlacement(0,
|
||||
G4ThreeVector(0.,
|
||||
0.,
|
||||
(-PixelThickness-OhmicPosThickness)/2),
|
||||
"OhmicPos",
|
||||
logicOhmicPos,
|
||||
physiHPGe,
|
||||
false,
|
||||
PixelCopyNb);
|
||||
|
||||
}
|
||||
|
||||
PixelCopyNb += PixelCopyNb;
|
||||
G4cout << "PixelCopyNb: " << PixelCopyNb << G4endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Screen
|
||||
|
||||
if (DeviceThickness > 0.)
|
||||
{
|
||||
solidScreen = new G4Box("DetectorScreen", //its name
|
||||
screenSizeXY/2,screenSizeXY/2,screenThickness/2);//size
|
||||
|
||||
|
||||
logicScreen = new G4LogicalVolume(solidScreen, //its solid
|
||||
defaultMaterial, //its material
|
||||
"DetectorScreen"); //its name
|
||||
|
||||
//zRotPhiHPGe.rotateX(PhiHPGe);
|
||||
G4double x,y,z;
|
||||
G4cout << "distScreen: "<< distScreen/m <<G4endl;
|
||||
z = -1 * distScreen; //* std::cos(ThetaHPGe);
|
||||
y = 0.*cm; //distScreen * std::sin(ThetaHPGe);
|
||||
x = 0.*cm;
|
||||
physiScreen = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)),
|
||||
"DetectorScreen", //its name
|
||||
logicScreen, //its logical volume
|
||||
physiWorld, //its mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
}
|
||||
|
||||
//Plane
|
||||
|
||||
if (planeGranularity) {
|
||||
|
||||
solidPlane=0; logicPlane=0; physiPlane=0;
|
||||
if (planeThickness > 0.)
|
||||
{
|
||||
solidPlane = new G4Box("Plane", //its name
|
||||
planeSizeXY/2,planeSizeXY/2,planeThickness/2);//size
|
||||
|
||||
logicPlane= new G4LogicalVolume(solidPlane, //its solid
|
||||
defaultMaterial, //its material
|
||||
"Plane"); //its name
|
||||
|
||||
physiPlane = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(), //at (0,0,0)
|
||||
"Plane", //its name
|
||||
logicPlane, //its logical volume
|
||||
physiWorld, //its mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
G4int nbOfGrainsX = ((G4int)(planeSizeXY/grainDia)) -1 ;
|
||||
|
||||
// y dim of a max density plane is 2rn-(n-1)ar, wehere a = (1-(std::sqrt(3)/2)), n is
|
||||
// number of rows and r the radius of the grain. so the Y-dim of the plane must
|
||||
// be greater or equal to this. It results that nmust be <= (PlaneY-a)/(1-a).
|
||||
// Max Y shift of the planes superimposing along Z axis is minor (2/std::sqrt(3)r)
|
||||
|
||||
G4double a = (1.-(std::sqrt(3.)/2.));
|
||||
G4int nbOfGrainsY = (G4int) ( ((planeSizeXY/(grainDia/2.)) -a)/(2.-a) ) -1;
|
||||
|
||||
// same for the z axis, but a = 2 * (std::sqrt(3) - std::sqrt(2))/std::sqrt(3)
|
||||
|
||||
G4double b = 2. * (std::sqrt(3.) - std::sqrt(2.))/std::sqrt(3.);
|
||||
G4int nbOfGrainsZ = (G4int) ( ((planeThickness/(grainDia/2.)) -b)/(2.-b) )-1;
|
||||
|
||||
if (planeThickness > 0.){
|
||||
|
||||
solidGrain=0; logicGrain=0; physiGrain=0;
|
||||
solidGrain = new G4Sphere("Grain",0.,
|
||||
grainDia/2,0., twopi, 0., pi);
|
||||
|
||||
logicGrain = new G4LogicalVolume(solidGrain,
|
||||
planeMaterial, //its material
|
||||
"Grain"); //its name
|
||||
G4ThreeVector grainPosition;
|
||||
G4double grainInitPositionX = 0.;
|
||||
G4double grainInitPositionY = 0.;
|
||||
G4double grainInitPositionZ = (-1.*planeThickness/2.+grainDia/2.);
|
||||
G4double grainStepX = grainDia;
|
||||
G4double grainStepY = grainDia*(1.-(0.5-(std::sqrt(3.)/4.)));
|
||||
G4double grainStepZ = grainDia*std::sqrt(2./3.);
|
||||
|
||||
for ( G4int k=0; k < nbOfGrainsZ ; k++ ) {
|
||||
for ( G4int j=0; j < nbOfGrainsY ; j++ ) {
|
||||
for ( G4int i=0; i < nbOfGrainsX ; i++ ) {
|
||||
|
||||
// Now we identify the layer and the row where the grain is , to place it in the right position
|
||||
|
||||
|
||||
|
||||
if (k%3 == 0) { // first or (4-multiple)th layer: structure is ABCABC
|
||||
grainInitPositionY = (-1.*planeSizeXY/2.+grainDia/2.);
|
||||
if (j%2 ==0) { //first or (3-multiple)th row
|
||||
grainInitPositionX = (-1.*planeSizeXY/2.+grainDia/2.);
|
||||
}
|
||||
|
||||
else if ( ((j+1) % 2) == 0 ) {
|
||||
grainInitPositionX = (-1.*planeSizeXY/2.+ grainDia);
|
||||
}
|
||||
|
||||
}
|
||||
else if ( ((k+2) % 3) == 0 ) { // B-layer
|
||||
|
||||
grainInitPositionY = ( (-1.*planeSizeXY/2.) + (grainDia/2.)*(1. + (1./std::sqrt(3.)) ) );
|
||||
|
||||
if (j%2 ==0) { //first or (3-multiple)th row
|
||||
grainInitPositionX = (-1.*planeSizeXY/2.+grainDia);
|
||||
}
|
||||
|
||||
else if ( (j+1)%2 == 0 ) {
|
||||
grainInitPositionX = (-1.*planeSizeXY/2.+grainDia/2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else if ( (k+1)%3 == 0 ) { // B-layer
|
||||
|
||||
grainInitPositionY = (-1.*planeSizeXY/2.+(grainDia/2.)*(1.+2./std::sqrt(3.)) );
|
||||
|
||||
if (j%2 ==0) { //first or (3-multiple)th row
|
||||
grainInitPositionX = (-1.*planeSizeXY/2.+grainDia/2.);
|
||||
}
|
||||
|
||||
else if ( (j+1)%2 == 0 ) {
|
||||
grainInitPositionX = (-1.*planeSizeXY/2.+grainDia);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
physiGrain = new G4PVPlacement(0,
|
||||
G4ThreeVector( grainInitPositionX + i*grainStepX,
|
||||
grainInitPositionY + j*grainStepY,
|
||||
grainInitPositionZ + k*grainStepZ),
|
||||
"Grain",
|
||||
logicGrain, //its logical volume
|
||||
physiPlane, //its mother volume
|
||||
false, //no boolean operation
|
||||
grainCopyNb);//copy number
|
||||
|
||||
grainCopyNb = grainCopyNb +1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
solidPlane=0; logicPlane=0; physiPlane=0;
|
||||
if (planeThickness > 0.)
|
||||
{
|
||||
solidPlane = new G4Box("Plane", //its name
|
||||
planeSizeXY/2,planeSizeXY/2,planeThickness/2);//size
|
||||
|
||||
logicPlane= new G4LogicalVolume(solidPlane, //its solid
|
||||
planeMaterial, //its material
|
||||
"Plane"); //its name
|
||||
|
||||
physiPlane = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(), //at (0,0,0)
|
||||
"Plane", //its name
|
||||
logicPlane, //its logical volume
|
||||
physiWorld, //its mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
G4SDManager* SDman = G4SDManager::GetSDMpointer();
|
||||
|
||||
if(!HPGeSD)
|
||||
{
|
||||
HPGeSD = new XrayFluoSD ("HPGeSD",this);
|
||||
SDman->AddNewDetector(HPGeSD);
|
||||
}
|
||||
|
||||
|
||||
if (logicPixel)
|
||||
{
|
||||
logicPixel->SetSensitiveDetector(HPGeSD);
|
||||
}
|
||||
|
||||
// Visualization attributes
|
||||
|
||||
logicWorld->SetVisAttributes (G4VisAttributes::Invisible);
|
||||
G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
|
||||
G4VisAttributes * yellow= new G4VisAttributes( G4Colour(255/255. ,255/255. ,51/255. ));
|
||||
G4VisAttributes * red= new G4VisAttributes( G4Colour(255/255. , 0/255. , 0/255. ));
|
||||
G4VisAttributes * blue= new G4VisAttributes( G4Colour(0/255. , 0/255. , 255/255. ));
|
||||
G4VisAttributes * gray= new G4VisAttributes( G4Colour(128/255. , 128/255. , 128/255. ));
|
||||
G4VisAttributes * lightGray= new G4VisAttributes( G4Colour(178/255. , 178/255. , 178/255. ));
|
||||
yellow->SetVisibility(true);
|
||||
yellow->SetForceSolid(true);
|
||||
red->SetVisibility(true);
|
||||
red->SetForceSolid(true);
|
||||
blue->SetVisibility(true);
|
||||
gray->SetVisibility(true);
|
||||
gray->SetForceSolid(true);
|
||||
lightGray->SetVisibility(true);
|
||||
lightGray->SetForceSolid(true);
|
||||
simpleBoxVisAtt->SetVisibility(true);
|
||||
|
||||
logicPixel->SetVisAttributes(red); //modified!!!
|
||||
logicHPGe->SetVisAttributes(blue);
|
||||
|
||||
logicPlane->SetVisAttributes(lightGray);
|
||||
|
||||
|
||||
logicScreen->SetVisAttributes(gray);
|
||||
logicOhmicNeg->SetVisAttributes(yellow);
|
||||
logicOhmicPos->SetVisAttributes(yellow);
|
||||
|
||||
|
||||
|
||||
if (planeGranularity) logicGrain->SetVisAttributes(gray);
|
||||
|
||||
//always return the physical World
|
||||
|
||||
PrintApparateParameters();
|
||||
|
||||
return physiWorld;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoPlaneDetectorConstruction::PrintApparateParameters()
|
||||
{
|
||||
G4cout << "-----------------------------------------------------------------------"
|
||||
<< G4endl
|
||||
<< "The plane is a box whose size is: "
|
||||
<< G4endl
|
||||
<< planeThickness/cm
|
||||
<< " cm * "
|
||||
<< planeSizeXY/cm
|
||||
<< " cm * "
|
||||
<< planeSizeXY/cm
|
||||
<< " cm"
|
||||
<< G4endl
|
||||
<<" Material: " << logicPlane->GetMaterial()->GetName()
|
||||
<<G4endl
|
||||
<<"The Detector is a slice " << DeviceThickness/(1.e-6*m) << " micron thick of " << pixelMaterial->GetName()
|
||||
<<G4endl
|
||||
|
||||
|
||||
<<"-------------------------------------------------------------------------"
|
||||
<< G4endl;
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoPlaneDetectorConstruction::UpdateGeometry()
|
||||
{
|
||||
|
||||
delete solidWorld;
|
||||
delete logicWorld;
|
||||
delete physiWorld;
|
||||
delete solidHPGe;
|
||||
delete logicHPGe;
|
||||
delete physiHPGe;
|
||||
delete solidPixel;
|
||||
delete logicPixel;
|
||||
delete physiPixel;
|
||||
delete solidOhmicNeg;
|
||||
delete logicOhmicNeg;
|
||||
delete physiOhmicNeg;
|
||||
delete solidOhmicPos;
|
||||
delete logicOhmicPos;
|
||||
delete physiOhmicPos;
|
||||
delete solidPlane;
|
||||
delete logicPlane;
|
||||
delete physiPlane;
|
||||
delete solidScreen;
|
||||
delete logicScreen;
|
||||
delete physiScreen;
|
||||
|
||||
zRotPhiHPGe.rotateX(-1.*PhiHPGe);
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(ConstructApparate());
|
||||
}
|
||||
|
||||
|
||||
void XrayFluoPlaneDetectorConstruction::DeleteGrainObjects()
|
||||
{
|
||||
if (planeGranularity) {
|
||||
delete solidGrain;
|
||||
delete logicGrain;
|
||||
delete physiGrain;
|
||||
}
|
||||
|
||||
}
|
||||
void XrayFluoPlaneDetectorConstruction::SetPlaneMaterial(G4String newMaterial)
|
||||
{
|
||||
|
||||
|
||||
G4cout << "Material!!!!" << newMaterial << G4cout;
|
||||
logicPlane->SetMaterial(materials->GetMaterial(newMaterial));
|
||||
PrintApparateParameters();
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: XrayFluoPlaneDetectorMessenger.cc
|
||||
// GEANT4 tag $Name:
|
||||
//
|
||||
// Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it)
|
||||
//
|
||||
// History:
|
||||
// -----------
|
||||
//
|
||||
// 29 Aug 2003 Alfonso Mantero created
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
|
||||
#include "XrayFluoPlaneDetectorMessenger.hh"
|
||||
#include "XrayFluoPlaneDetectorConstruction.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoPlaneDetectorMessenger::XrayFluoPlaneDetectorMessenger(XrayFluoPlaneDetectorConstruction * Det)
|
||||
:Detector(Det)
|
||||
{
|
||||
detDir = new G4UIdirectory("/apparate/");
|
||||
detDir->SetGuidance("detector control.");
|
||||
|
||||
UpdateCmd = new G4UIcmdWithoutParameter("/apparate/update",this);
|
||||
UpdateCmd->SetGuidance("Update apparate geometry.");
|
||||
UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
|
||||
UpdateCmd->SetGuidance("if you changed geometrical value(s): /apparate/GrainDiameter and /apparate/sampleGranularity");
|
||||
|
||||
UpdateCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
sampleCmd = new G4UIcmdWithAString("/apparate/planeMaterial",this);
|
||||
sampleCmd->SetGuidance("select a diferent material for the plane");
|
||||
sampleCmd->SetParameterName("material",true);
|
||||
sampleCmd->SetDefaultValue("mars1");
|
||||
sampleCmd->SetCandidates("Dolorite Anorthosite Mars1");
|
||||
sampleCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
detectorCmd = new G4UIcmdWithAString("/apparate/detector",this);
|
||||
detectorCmd->SetGuidance("select a diferent detectorType");
|
||||
detectorCmd->SetParameterName("detector",true);
|
||||
detectorCmd->SetDefaultValue("sili");
|
||||
detectorCmd->SetCandidates("sili hpge");
|
||||
detectorCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
grainDiaCmd = new G4UIcmdWithADoubleAndUnit( "/apparate/GrainDiameter",this );
|
||||
grainDiaCmd->SetGuidance( "Set diameter of grains" );
|
||||
grainDiaCmd->SetGuidance( "After this, /apparate/update must be executed before BeamOn" );
|
||||
grainDiaCmd->SetGuidance( "Default: 0.5 mm " );
|
||||
grainDiaCmd->SetParameterName( "Grain Diameter", true, true );
|
||||
grainDiaCmd->SetDefaultUnit( "mm" );
|
||||
grainDiaCmd->SetUnitCategory( "Length" );
|
||||
grainDiaCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
granularityFlagCmd= new G4UIcmdWithABool("/apparate/sampleGranularity",this);
|
||||
granularityFlagCmd->SetGuidance("Set if sample granularity is present");
|
||||
granularityFlagCmd->SetGuidance( "After this, /apparate/update must be executed before BeamOn" );
|
||||
granularityFlagCmd->SetParameterName("Granularity Flag",true);
|
||||
granularityFlagCmd->SetDefaultValue(false);
|
||||
granularityFlagCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoPlaneDetectorMessenger::~XrayFluoPlaneDetectorMessenger()
|
||||
{
|
||||
delete UpdateCmd;
|
||||
delete detDir;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoPlaneDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
|
||||
{
|
||||
if( command == UpdateCmd )
|
||||
{ Detector->UpdateGeometry(); }
|
||||
|
||||
else if ( command == sampleCmd )
|
||||
{ Detector->SetPlaneMaterial(newValue);}
|
||||
|
||||
else if ( command == detectorCmd )
|
||||
{ Detector->SetDetectorType(newValue);}
|
||||
|
||||
else if ( command == grainDiaCmd )
|
||||
{
|
||||
G4double newSize = grainDiaCmd->GetNewDoubleValue(newValue);
|
||||
Detector->SetGrainDia(newSize);
|
||||
}
|
||||
|
||||
else if ( command == granularityFlagCmd )
|
||||
{
|
||||
Detector->DeleteGrainObjects();
|
||||
G4bool newGranFlag = granularityFlagCmd->GetNewBoolValue(newValue);
|
||||
Detector->SetPlaneGranularity(newGranFlag);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: XrayFluoPlanePrimaryGeneratorAction.cc
|
||||
// GEANT4 tag $Name:
|
||||
//
|
||||
// Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it)
|
||||
//
|
||||
// History:
|
||||
// -----------
|
||||
// 02 Sep 2003 Alfonso Mantero created
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#include "XrayFluoPlanePrimaryGeneratorAction.hh"
|
||||
#include "G4DataVector.hh"
|
||||
#include "XrayFluoPlaneDetectorConstruction.hh"
|
||||
#include "XrayFluoPlanePrimaryGeneratorMessenger.hh"
|
||||
#include "XrayFluoRunAction.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "XrayFluoAnalysisManager.hh"
|
||||
#include "XrayFluoDataSet.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoPlanePrimaryGeneratorAction::XrayFluoPlanePrimaryGeneratorAction(XrayFluoPlaneDetectorConstruction* XrayFluoDC)
|
||||
:rndmFlag("on"),beam("off"),spectrum("off"),isoVert("off")
|
||||
{
|
||||
|
||||
XrayFluoDetector = XrayFluoDC;
|
||||
|
||||
G4int n_particle = 1;
|
||||
particleGun = new G4ParticleGun(n_particle);
|
||||
|
||||
//create a messenger for this class
|
||||
gunMessenger = new XrayFluoPlanePrimaryGeneratorMessenger(this);
|
||||
runManager = new XrayFluoRunAction();
|
||||
|
||||
// default particle kinematic
|
||||
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
G4String particleName;
|
||||
G4ParticleDefinition* particle
|
||||
= particleTable->FindParticle(particleName="gamma");
|
||||
particleGun->SetParticleDefinition(particle);
|
||||
particleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
|
||||
|
||||
|
||||
particleGun->SetParticleEnergy(10.*keV);
|
||||
G4double position = -0.5*(XrayFluoDetector->GetWorldSizeZ());
|
||||
particleGun->SetParticlePosition(G4ThreeVector(0.*cm,0.*cm,position));
|
||||
|
||||
G4cout << "XrayFluoPlanePrimaryGeneratorAction created UUUUUUUUUUAAAAAAAAAAAAAAAAAAAAAAAaa" << G4endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoPlanePrimaryGeneratorAction::~XrayFluoPlanePrimaryGeneratorAction()
|
||||
{
|
||||
delete particleGun;
|
||||
delete gunMessenger;
|
||||
delete runManager;
|
||||
|
||||
G4cout << "XrayFluoPlanePrimaryGeneratorAction deleted" << G4endl;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoPlanePrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
//this function is called at the begining of event
|
||||
//
|
||||
G4double z0 = -0.5*(XrayFluoDetector->GetWorldSizeZ());
|
||||
G4double y0 = 0.*m, x0 = 0.*m;
|
||||
G4double dX = 0.5*(XrayFluoDetector->GetWorldSizeXY())-(XrayFluoDetector->GetPlaneSizeXY());
|
||||
if (rndmFlag == "on")
|
||||
|
||||
{y0 = (XrayFluoDetector->GetPlaneSizeXY())*(G4UniformRand()-0.5);
|
||||
x0 = (XrayFluoDetector->GetPlaneSizeXY())*(G4UniformRand()-0.5) + dX;
|
||||
}
|
||||
|
||||
z0 = -1 * dX;
|
||||
|
||||
particleGun->SetParticleMomentumDirection(G4ThreeVector(-1.,0.,1.));
|
||||
|
||||
particleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
|
||||
|
||||
//randomize starting point
|
||||
if (beam == "on")
|
||||
{
|
||||
G4double radius = 0.5 * mm;
|
||||
G4double rho = radius*std::sqrt(G4UniformRand());
|
||||
G4double theta = 2*pi*G4UniformRand()*rad;
|
||||
G4double position = -0.5*(XrayFluoDetector->GetWorldSizeZ());
|
||||
|
||||
G4double y = rho * std::sin(theta);
|
||||
G4double x = rho * std::cos(theta);
|
||||
|
||||
particleGun->SetParticlePosition(G4ThreeVector(x,y,position));
|
||||
}
|
||||
//shoot particles according to a certain spectrum
|
||||
if (spectrum =="on")
|
||||
{
|
||||
G4String particle = particleGun->GetParticleDefinition()
|
||||
->GetParticleName();
|
||||
if(particle == "proton"|| particle == "alpha")
|
||||
{
|
||||
G4DataVector* energies = runManager->GetEnergies();
|
||||
G4DataVector* data = runManager->GetData();
|
||||
|
||||
G4double sum = runManager->GetDataSum();
|
||||
G4double partSum = 0;
|
||||
G4int j = 0;
|
||||
G4double random= sum*G4UniformRand();
|
||||
while (partSum<random)
|
||||
{
|
||||
partSum += (*data)[j];
|
||||
j++;
|
||||
}
|
||||
|
||||
particleGun->SetParticleEnergy((*energies)[j]);
|
||||
|
||||
}
|
||||
else if (particle == "gamma")
|
||||
{
|
||||
const XrayFluoDataSet* dataSet = runManager->GetGammaSet();
|
||||
|
||||
G4int i = 0;
|
||||
G4int id = 0;
|
||||
G4double minEnergy = 0. * keV;
|
||||
G4double particleEnergy= 0.;
|
||||
G4double maxEnergy = 10. * keV;
|
||||
G4double energyRange = maxEnergy - minEnergy;
|
||||
|
||||
while ( i == 0)
|
||||
{
|
||||
G4double random = G4UniformRand();
|
||||
|
||||
G4double randomNum = G4UniformRand(); //*5.0E6;
|
||||
|
||||
particleEnergy = (random*energyRange) + minEnergy;
|
||||
|
||||
if ((dataSet->FindValue(particleEnergy,id)) > randomNum)
|
||||
{
|
||||
i = 1;
|
||||
|
||||
}
|
||||
}
|
||||
particleGun->SetParticleEnergy(particleEnergy);
|
||||
}
|
||||
}
|
||||
|
||||
if (isoVert == "on")
|
||||
{
|
||||
G4double rho = 1. *m;
|
||||
//theta in [0;pi/2]
|
||||
G4double theta = (pi/2)*G4UniformRand();
|
||||
//phi in [-pi;pi]
|
||||
G4double phi = (G4UniformRand()*2*pi)- pi;
|
||||
G4double x = rho*std::sin(theta)*std::sin(phi);
|
||||
G4double y = rho*std::sin(theta)*std::cos(phi);
|
||||
G4double z = -(rho*std::cos(theta));
|
||||
particleGun->SetParticlePosition(G4ThreeVector(x,y,z));
|
||||
|
||||
G4double Xdim = XrayFluoDetector->GetPlaneSizeXY();
|
||||
G4double Ydim = XrayFluoDetector->GetPlaneSizeXY();
|
||||
|
||||
G4double Dx = Xdim*(G4UniformRand()-0.5);
|
||||
|
||||
G4double Dy = Ydim*(G4UniformRand()-0.5);
|
||||
|
||||
particleGun->SetParticleMomentumDirection(G4ThreeVector(-x+Dx,-y+Dy,-z));
|
||||
|
||||
}
|
||||
#ifdef G4ANALYSIS_USE
|
||||
|
||||
G4double partEnergy = particleGun->GetParticleEnergy();
|
||||
XrayFluoAnalysisManager* analysis = XrayFluoAnalysisManager::getInstance();
|
||||
analysis->analysePrimaryGenerator(partEnergy/keV);
|
||||
|
||||
#endif
|
||||
|
||||
particleGun->GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: XrayFluoPlanePrimarygeneratorMessenger.cc
|
||||
// GEANT4 tag $Name:
|
||||
//
|
||||
// Author: Alfonso Mantero (Alfonso.mantero@ge.infn.it)
|
||||
//
|
||||
// History:
|
||||
// -----------
|
||||
// 02 Sep 2003 Alfonso Mantero created
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#include "XrayFluoPlanePrimaryGeneratorMessenger.hh"
|
||||
#include "XrayFluoPlanePrimaryGeneratorAction.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoPlanePrimaryGeneratorMessenger::XrayFluoPlanePrimaryGeneratorMessenger(XrayFluoPlanePrimaryGeneratorAction* XrayFluoGun)
|
||||
:XrayFluoAction(XrayFluoGun)
|
||||
{
|
||||
RndmCmd = new G4UIcmdWithAString("/gun/random",this);
|
||||
RndmCmd->SetGuidance("Shoot particles from a point-like source at infinity, witth an incidence angle with the plane of 45 deg");
|
||||
RndmCmd->SetGuidance(" Choice : on(default), off");
|
||||
RndmCmd->SetParameterName("choice",true);
|
||||
RndmCmd->SetDefaultValue("on");
|
||||
RndmCmd->SetCandidates("on off");
|
||||
RndmCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
RndmVert = new G4UIcmdWithAString("/gun/beam",this);
|
||||
RndmVert->SetGuidance("Creates a round beam of particles of 0.5mm in diameter.");
|
||||
RndmVert->SetGuidance(" Choice : on(default), off");
|
||||
RndmVert->SetParameterName("choice",true);
|
||||
RndmVert->SetDefaultValue("on");
|
||||
RndmVert->SetCandidates("on off");
|
||||
RndmVert->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
spectrum = new G4UIcmdWithAString("/gun/spectrum",this);
|
||||
spectrum->SetGuidance("Shoot the incident particle with a certain energy spectrum.");
|
||||
spectrum->SetGuidance(" Choice : on(default), off");
|
||||
spectrum->SetParameterName("choice",true);
|
||||
spectrum->SetDefaultValue("on");
|
||||
spectrum->SetCandidates("on off");
|
||||
spectrum->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
isoVert = new G4UIcmdWithAString("/gun/isoVert",this);
|
||||
isoVert->SetGuidance("Shoot the incident particle from an isotropic direction.");
|
||||
isoVert->SetGuidance(" Choice : on(default), off");
|
||||
isoVert->SetParameterName("choice",true);
|
||||
isoVert->SetDefaultValue("on");
|
||||
isoVert->SetCandidates("on off");
|
||||
isoVert->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
G4cout << "XrayFluoPlanePrimaryGeneratorMessenger created" << G4endl;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoPlanePrimaryGeneratorMessenger::~XrayFluoPlanePrimaryGeneratorMessenger()
|
||||
{
|
||||
delete RndmCmd;
|
||||
delete RndmVert;
|
||||
delete spectrum;
|
||||
delete isoVert;
|
||||
|
||||
G4cout << "XrayFluoPlanePrimaryGeneratorMessenger deleted" << G4endl;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoPlanePrimaryGeneratorMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
{
|
||||
if( command == RndmCmd )
|
||||
{
|
||||
XrayFluoAction->SetRndmFlag(newValue);
|
||||
XrayFluoAction->SetRndmVert("off");
|
||||
XrayFluoAction->SetIsoVert("off");
|
||||
}
|
||||
|
||||
if( command == RndmVert )
|
||||
{
|
||||
XrayFluoAction->SetRndmVert(newValue);
|
||||
XrayFluoAction->SetIsoVert("off");
|
||||
XrayFluoAction->SetRndmFlag("off");
|
||||
}
|
||||
if( command == spectrum )
|
||||
{ XrayFluoAction->SetSpectrum(newValue);}
|
||||
|
||||
if( command == isoVert )
|
||||
{
|
||||
XrayFluoAction->SetIsoVert(newValue);
|
||||
XrayFluoAction->SetRndmFlag("off");
|
||||
XrayFluoAction->SetRndmVert("off");
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
@@ -100,8 +100,8 @@ void XrayFluoPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
G4double z0 = -0.5*(XrayFluoDetector->GetWorldSizeZ());
|
||||
G4double y0 = 0.*cm, x0 = 0.*cm;
|
||||
if (rndmFlag == "on")
|
||||
{y0 = (XrayFluoDetector->GetDia3SizeXY())/sqrt(2.)*(G4UniformRand()-0.5); // it was GetSampleSizeXY(),
|
||||
x0 = (XrayFluoDetector->GetDia3SizeXY())/sqrt(2.)*(G4UniformRand()-0.5); // not divided by sqrt(2.)
|
||||
{y0 = (XrayFluoDetector->GetDia3SizeXY())/std::sqrt(2.)*(G4UniformRand()-0.5); // it was GetSampleSizeXY(),
|
||||
x0 = (XrayFluoDetector->GetDia3SizeXY())/std::sqrt(2.)*(G4UniformRand()-0.5); // not divided by std::sqrt(2.)
|
||||
}
|
||||
particleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
|
||||
|
||||
@@ -109,12 +109,12 @@ void XrayFluoPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
if (beam == "on")
|
||||
{
|
||||
G4double radius = 0.5 * mm;
|
||||
G4double rho = radius*sqrt(G4UniformRand());
|
||||
G4double rho = radius*std::sqrt(G4UniformRand());
|
||||
G4double theta = 2*pi*G4UniformRand()*rad;
|
||||
G4double position = -0.5*(XrayFluoDetector->GetWorldSizeZ());
|
||||
|
||||
G4double y = rho * sin(theta);
|
||||
G4double x = rho * cos(theta);
|
||||
G4double y = rho * std::sin(theta);
|
||||
G4double x = rho * std::cos(theta);
|
||||
|
||||
particleGun->SetParticlePosition(G4ThreeVector(x,y,position));
|
||||
}
|
||||
@@ -177,9 +177,9 @@ void XrayFluoPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
G4double theta = (pi/2)*G4UniformRand();
|
||||
//phi in [-pi;pi]
|
||||
G4double phi = (G4UniformRand()*2*pi)- pi;
|
||||
G4double x = rho*sin(theta)*sin(phi);
|
||||
G4double y = rho*sin(theta)*cos(phi);
|
||||
G4double z = -(rho*cos(theta));
|
||||
G4double x = rho*std::sin(theta)*std::sin(phi);
|
||||
G4double y = rho*std::sin(theta)*std::cos(phi);
|
||||
G4double z = -(rho*std::cos(theta));
|
||||
particleGun->SetParticlePosition(G4ThreeVector(x,y,z));
|
||||
|
||||
G4double Xdim = XrayFluoDetector->GetSampleSizeXY();
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: XrayFluoSD.cc
|
||||
// GEANT4 tag $Name: xray_fluo-V04-01-03
|
||||
//
|
||||
// Author: Elena Guardincerri (Elena.Guardincerri@ge.infn.it)
|
||||
//
|
||||
// History:
|
||||
// -----------
|
||||
// 28 Nov 2001 Elena Guardincerri Created
|
||||
// 29 Nov 2002 Energy deposition bug fixed (Alfonso.mantero@ge.infn.it)
|
||||
// 17 Jul 2003 Name changed to XrayFluoSD
|
||||
// 01 Sep 2003 Constructor overload for different geometries handling
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#include "XrayFluoSD.hh"
|
||||
#include "XrayFluoSensorHit.hh"
|
||||
#include "XrayFluoDetectorConstruction.hh"
|
||||
#include "XrayFluoPlaneDetectorConstruction.hh"
|
||||
#include "XrayFluoMercuryDetectorConstruction.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4VTouchable.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4VProcess.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoSD::XrayFluoSD(G4String name,
|
||||
XrayFluoDetectorConstruction* det)
|
||||
:G4VSensitiveDetector(name),Detector(0),planeDetector(0),mercuryDetector(0)
|
||||
{
|
||||
|
||||
Detector = det;
|
||||
collectionName.insert("HPGeCollection");
|
||||
HitHPGeID = new G4int[500];
|
||||
G4cout << "XrayFluoSD created" << G4endl;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoSD::XrayFluoSD(G4String name,
|
||||
XrayFluoPlaneDetectorConstruction* det)
|
||||
:G4VSensitiveDetector(name),Detector(0),planeDetector(0),mercuryDetector(0)
|
||||
{
|
||||
planeDetector = det;
|
||||
collectionName.insert("HPGeCollection");
|
||||
HitHPGeID = new G4int[500];
|
||||
G4cout << "XrayFluoSD created" << G4endl;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
XrayFluoSD::XrayFluoSD(G4String name,
|
||||
XrayFluoMercuryDetectorConstruction* det)
|
||||
:G4VSensitiveDetector(name),Detector(0),planeDetector(0),mercuryDetector(0)
|
||||
{
|
||||
mercuryDetector = det;
|
||||
collectionName.insert("HPGeCollection");
|
||||
HitHPGeID = new G4int[500];
|
||||
G4cout << "XrayFluoSD created" << G4endl;
|
||||
}
|
||||
|
||||
// //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
|
||||
|
||||
|
||||
XrayFluoSD::~XrayFluoSD()
|
||||
{
|
||||
|
||||
delete [] HitHPGeID;
|
||||
|
||||
// delete HPGeCollection;
|
||||
|
||||
G4cout << "XrayFluoSD deleted" << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoSD::Initialize(G4HCofThisEvent*)
|
||||
|
||||
//initializes HCE with the hits collection(s) created by this
|
||||
//sensitive detector
|
||||
{
|
||||
HPGeCollection = new XrayFluoSensorHitsCollection
|
||||
(SensitiveDetectorName,collectionName[0]);
|
||||
|
||||
G4int nPixel = 0;
|
||||
|
||||
if (Detector) {nPixel = Detector->GetNbOfPixels();}
|
||||
else if (planeDetector) {nPixel = planeDetector->GetNbOfPixels();}
|
||||
else if (mercuryDetector) {nPixel = mercuryDetector->GetNbOfPixels();}
|
||||
|
||||
for (G4int j=0;j<nPixel;j++)
|
||||
{HitHPGeID [j]= -1;};
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
G4bool XrayFluoSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
|
||||
{
|
||||
|
||||
|
||||
|
||||
G4double edep = aStep->GetTotalEnergyDeposit();
|
||||
|
||||
/*
|
||||
G4String particleName = aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->GetParticleName();
|
||||
|
||||
G4Track* track = aStep->GetTrack();
|
||||
G4int trackId = track->GetTrackID();
|
||||
//G4String processName = aStep->GetTrack()->GetCreatorProcess()->GetProcessName();
|
||||
|
||||
G4double partEnergy = aStep->GetPreStepPoint()->GetKineticEnergy();
|
||||
G4double secondEnergy = aStep->GetPostStepPoint()->GetKineticEnergy();
|
||||
G4cout << " la particella che deposita e': " << particleName << " ha una energia di keV "
|
||||
<< partEnergy << " e deposita "<< edep << G4endl;
|
||||
G4cout << " la particella creata ha energia cinetica: " << secondEnergy << G4endl;
|
||||
*/
|
||||
|
||||
if ((edep==0.)) return false;
|
||||
|
||||
//G4cout << " edep = " << edep << G4endl;
|
||||
|
||||
G4TouchableHistory* theTouchable
|
||||
= (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
|
||||
|
||||
|
||||
|
||||
G4VPhysicalVolume* physVol = theTouchable->GetVolume();
|
||||
G4int PixelNumber = 0;
|
||||
|
||||
if (Detector && Detector->GetNbOfPixels()>1) {PixelNumber= physVol->GetCopyNo();}
|
||||
else if (planeDetector && planeDetector->GetNbOfPixels()>1) {PixelNumber= physVol->GetCopyNo();}
|
||||
else if (mercuryDetector && mercuryDetector->GetNbOfPixels()>1) {PixelNumber= physVol->GetCopyNo();}
|
||||
|
||||
|
||||
|
||||
if ( HitHPGeID[PixelNumber]==-1)
|
||||
{
|
||||
XrayFluoSensorHit* HPGeHit = new XrayFluoSensorHit();
|
||||
HPGeHit->AddEnergy(edep);
|
||||
HitHPGeID[PixelNumber] = HPGeCollection->insert(HPGeHit) - 1;
|
||||
if (verboseLevel>0){
|
||||
G4cout << " New Hit on pixel: " << PixelNumber << G4endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(*HPGeCollection)[HitHPGeID[PixelNumber]]->AddEnergy(edep);
|
||||
//G4double ED =(*HPGeCollection)[HitHPGeID[PixelNumber]]->GetEdepTot();
|
||||
if (verboseLevel>0)
|
||||
G4cout << " Energy added to Pixel: " << PixelNumber << G4endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoSD::EndOfEvent(G4HCofThisEvent* HCE)
|
||||
{
|
||||
static G4int HCID = -1;
|
||||
if(HCID<0)
|
||||
{ HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); }
|
||||
HCE->AddHitsCollection(HCID,HPGeCollection);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoSD::clear()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoSD::DrawAll()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void XrayFluoSD::PrintAll()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,410 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: XrayFluoVdetectorType.cc
|
||||
// GEANT4 tag $Name:
|
||||
//
|
||||
// Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it)
|
||||
//
|
||||
// History:
|
||||
// -----------
|
||||
// 19 Jun 2003 Alfonso Mantero Created
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#include "XrayFluoSiLiDetectorType.hh"
|
||||
#include "XrayFluoDataSet.hh"
|
||||
#include "G4DataVector.hh"
|
||||
#include "G4LogLogInterpolation.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <fstream>
|
||||
#include <strstream>
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
|
||||
XrayFluoSiLiDetectorType::XrayFluoSiLiDetectorType():
|
||||
detectorMaterial("Silicon"),efficiencySet(0)
|
||||
{
|
||||
LoadResponseData("SILIresponse");
|
||||
|
||||
LoadEfficiencyData("SILIefficiency");
|
||||
|
||||
|
||||
}
|
||||
XrayFluoSiLiDetectorType::~XrayFluoSiLiDetectorType()
|
||||
{
|
||||
std::map<G4int,G4DataVector*,std::less<G4int> >::iterator pos;
|
||||
|
||||
for (pos = energyMap.begin(); pos != energyMap.end(); pos++)
|
||||
{
|
||||
G4DataVector* dataSet = (*pos).second;
|
||||
delete dataSet;
|
||||
dataSet = 0;
|
||||
}
|
||||
for (pos = dataMap.begin(); pos != dataMap.end(); pos++)
|
||||
{
|
||||
G4DataVector* dataSet = (*pos).second;
|
||||
delete dataSet;
|
||||
dataSet = 0;
|
||||
}
|
||||
|
||||
delete interpolation4;
|
||||
|
||||
}
|
||||
G4String XrayFluoSiLiDetectorType::GetDetectorMaterial()
|
||||
{
|
||||
return detectorMaterial;
|
||||
}
|
||||
|
||||
XrayFluoSiLiDetectorType* XrayFluoSiLiDetectorType::instance = 0;
|
||||
|
||||
XrayFluoSiLiDetectorType* XrayFluoSiLiDetectorType::GetInstance()
|
||||
|
||||
{
|
||||
if (instance == 0)
|
||||
{
|
||||
instance = new XrayFluoSiLiDetectorType;
|
||||
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
G4double XrayFluoSiLiDetectorType::ResponseFunction(G4double energy)
|
||||
{
|
||||
|
||||
G4double eMin = 1.500 *keV;
|
||||
G4double eMax = 6.403 *keV;
|
||||
G4double value = 0.;
|
||||
G4double efficiency = 1.;
|
||||
|
||||
const XrayFluoDataSet* dataSet = efficiencySet;
|
||||
G4int id = 0;
|
||||
G4DataVector energyVector;
|
||||
energyVector.push_back(1.486* keV);
|
||||
energyVector.push_back(1.740* keV);
|
||||
energyVector.push_back(3.688* keV);
|
||||
energyVector.push_back(4.510* keV);
|
||||
energyVector.push_back(5.414* keV);
|
||||
energyVector.push_back(6.404* keV);
|
||||
|
||||
G4double infEnergy = 0 *keV;
|
||||
G4double supEnergy = 10* keV;
|
||||
G4int energyNumber = 0;
|
||||
G4double random = G4UniformRand();
|
||||
|
||||
if (energy>=eMin && energy <=eMax)
|
||||
{
|
||||
|
||||
for (G4int i=0; i<(G4int)energyVector.size(); i++){
|
||||
if (energyVector[i]/keV < energy/keV){
|
||||
|
||||
infEnergy = energyVector[i];
|
||||
supEnergy = energyVector[i+1];
|
||||
|
||||
energyNumber = i+1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
G4double infData = GetInfData(energy, random, energyNumber);
|
||||
|
||||
G4double supData = GetSupData(energy,random, energyNumber);
|
||||
|
||||
value = (std::log10(infData)*std::log10(supEnergy/energy) +
|
||||
std::log10(supData)*std::log10(energy/infEnergy)) /
|
||||
std::log10(supEnergy/infEnergy);
|
||||
value = std::pow(10,value);
|
||||
|
||||
|
||||
}
|
||||
// else if (energy<eMin || energy>eMax)
|
||||
// {
|
||||
// G4double infEnergy = eMin;
|
||||
// G4double supEnergy = eMin/keV +1*keV;
|
||||
|
||||
// G4double infData = GetInfData(eMin, random);
|
||||
// G4double supData = GetSupData(eMin,random);
|
||||
// value = (std::log10(infData)*std::log10(supEnergy/eMin) +
|
||||
// std::log10(supData)*std::log10(eMin/infEnergy)) /
|
||||
// std::log10(supEnergy/infEnergy);
|
||||
// value = std::pow(10,value);
|
||||
// value = value-eMin+ energy;
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
else if (energy > eMax)
|
||||
{
|
||||
|
||||
energyNumber = 5;
|
||||
|
||||
value = (GetSupData(energy, random, energyNumber))+(energy - 6.404* keV);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
G4double mean = -14.03 * eV + 1.0047*energy/eV;
|
||||
G4double stdDev = 35.38 * eV + 0.004385*energy/eV;
|
||||
|
||||
|
||||
value = (G4RandGauss::shoot(mean,stdDev))*eV;
|
||||
|
||||
// G4double infEnergy = eMax/keV - 1. *keV;
|
||||
// G4double supEnergy = eMax;
|
||||
|
||||
// G4double infData = Manager->GetInfData(eMax, random);
|
||||
// G4double supData = Manager->GetSupData(eMax,random);
|
||||
// value = (std::log10(infData)*std::log10(supEnergy/eMax) +
|
||||
// std::log10(supData)*std::log10(eMax/infEnergy)) /
|
||||
// std::log10(supEnergy/infEnergy);
|
||||
// value = std::pow(10,value);
|
||||
// value = value+energy- eMax;
|
||||
}
|
||||
G4double RandomNum = G4UniformRand();
|
||||
|
||||
efficiency = dataSet->FindValue(value,id);
|
||||
if ( RandomNum>efficiency )
|
||||
{
|
||||
value = 0.;
|
||||
}
|
||||
|
||||
// G4cout << value << G4endl;
|
||||
return value;
|
||||
|
||||
}
|
||||
G4double XrayFluoSiLiDetectorType::GetInfData(G4double, G4double random, G4int posIndex)
|
||||
{
|
||||
G4double value = 0.;
|
||||
G4int zMin = 1;
|
||||
G4int zMax = 6;
|
||||
|
||||
G4int Z = posIndex;
|
||||
|
||||
if (Z<zMin) {Z=zMin;}
|
||||
if (Z>zMax) {Z=zMax;}
|
||||
|
||||
if (Z >= zMin && Z <= zMax)
|
||||
{
|
||||
std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
|
||||
pos = energyMap.find(Z);
|
||||
std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator posData;
|
||||
posData = dataMap.find(Z);
|
||||
|
||||
|
||||
if (pos!= energyMap.end())
|
||||
{
|
||||
G4DataVector energySet = *((*pos).second);
|
||||
G4DataVector dataSet = *((*posData).second);
|
||||
G4int nData = energySet.size();
|
||||
|
||||
|
||||
G4double dataSum = 0;
|
||||
G4double partSum = 0;
|
||||
G4int index = 0;
|
||||
|
||||
// if data is not perfectly normalized (it may happen)
|
||||
// rnadom number is renormalized, in case it is higer
|
||||
//than the sum of all energies => segmentation fault.
|
||||
|
||||
for (G4int i = 0; i<nData; i++){
|
||||
dataSum += dataSet[i];
|
||||
}
|
||||
|
||||
G4double normRandom = random*dataSum;
|
||||
|
||||
|
||||
while (normRandom> partSum)
|
||||
{
|
||||
|
||||
partSum += dataSet[index];
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
if (index >= 0 && index < nData)
|
||||
{
|
||||
value = energySet[index];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
G4double XrayFluoSiLiDetectorType::GetSupData(G4double, G4double random, G4int posIndex)
|
||||
{
|
||||
G4double value = 0.;
|
||||
G4int zMin = 1;
|
||||
G4int zMax = 6;
|
||||
G4int Z = (posIndex+1);
|
||||
|
||||
if (Z<zMin) {Z=zMin;}
|
||||
if (Z>zMax) {Z=zMax;}
|
||||
if (Z >= zMin && Z <= zMax)
|
||||
{
|
||||
std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
|
||||
pos = energyMap.find(Z);
|
||||
std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator posData;
|
||||
posData = dataMap.find(Z);
|
||||
if (pos!= energyMap.end())
|
||||
{
|
||||
G4DataVector energySet = *((*pos).second);
|
||||
G4DataVector dataSet = *((*posData).second);
|
||||
G4int nData = energySet.size();
|
||||
G4double dataSum = 0;
|
||||
G4double partSum = 0;
|
||||
G4int index = 0;
|
||||
|
||||
// if data is not perfectly normalized (it may happen)
|
||||
// rnadom number is renormalized, in case it is higer
|
||||
//than the sum of all energies => segmentation fault.
|
||||
|
||||
for (G4int i = 0; i<nData; i++){
|
||||
dataSum += dataSet[i];
|
||||
}
|
||||
|
||||
G4double normRandom = random*dataSum;
|
||||
|
||||
|
||||
while (normRandom> partSum)
|
||||
{
|
||||
partSum += dataSet[index];
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
if (index >= 0 && index < nData)
|
||||
{
|
||||
value = energySet[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
void XrayFluoSiLiDetectorType::LoadResponseData(G4String fileName)
|
||||
{
|
||||
char nameChar[100] = {""};
|
||||
std::ostrstream ost(nameChar, 100, std::ios::out);
|
||||
|
||||
|
||||
ost << fileName<<".dat";
|
||||
|
||||
G4String name(nameChar);
|
||||
|
||||
char* path = getenv("XRAYDATA");
|
||||
|
||||
G4String pathString(path);
|
||||
G4String dirFile = pathString + "/" + name;
|
||||
std::ifstream file(dirFile);
|
||||
std::filebuf* lsdp = file.rdbuf();
|
||||
|
||||
if (! (lsdp->is_open()) )
|
||||
{
|
||||
G4String excep = "XrayFluoSiLiDetectorType - data file: " + dirFile + " not found";
|
||||
G4Exception(excep);
|
||||
}
|
||||
G4double a = 0;
|
||||
G4int k = 1;
|
||||
G4int s = 0;
|
||||
|
||||
G4int Z = 1;
|
||||
G4DataVector* energies = new G4DataVector;
|
||||
G4DataVector* data = new G4DataVector;
|
||||
|
||||
do
|
||||
{
|
||||
file >> a;
|
||||
G4int nColumns = 2;
|
||||
if (a == -1)
|
||||
{
|
||||
if (s == 0)
|
||||
{
|
||||
// End of a data set
|
||||
energyMap[Z] = energies;
|
||||
dataMap[Z] = data;
|
||||
// Start of new shell data set
|
||||
energies = new G4DataVector;
|
||||
data = new G4DataVector;
|
||||
Z++;
|
||||
}
|
||||
s++;
|
||||
if (s == nColumns)
|
||||
{
|
||||
s = 0;
|
||||
}
|
||||
}
|
||||
else if (a == -2)
|
||||
{
|
||||
// End of file; delete the empty vectors
|
||||
//created when encountering the last -1 -1 row
|
||||
delete energies;
|
||||
delete data;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// 1st column is energy
|
||||
if(k%nColumns != 0)
|
||||
{
|
||||
G4double e = a * keV;
|
||||
energies->push_back(e);
|
||||
k++;
|
||||
}
|
||||
else if (k%nColumns == 0)
|
||||
{
|
||||
// 2nd column is data
|
||||
|
||||
data->push_back(a);
|
||||
k = 1;
|
||||
}
|
||||
}
|
||||
} while (a != -2); // end of file
|
||||
file.close();
|
||||
}
|
||||
|
||||
void XrayFluoSiLiDetectorType::LoadEfficiencyData(G4String fileName)
|
||||
{
|
||||
char* path = getenv("XRAYDATA");
|
||||
G4String dirFile;
|
||||
if (path) {
|
||||
G4String pathString(path);
|
||||
dirFile = pathString + "/" + fileName;
|
||||
}
|
||||
else{
|
||||
path = getenv("PWD");
|
||||
G4String pathString(path);
|
||||
dirFile = pathString + "/" + fileName;
|
||||
}
|
||||
|
||||
interpolation4 = new G4LogLogInterpolation();
|
||||
efficiencySet = new XrayFluoDataSet(1,fileName,interpolation4,keV,1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: XrayFluoSimulation.cc
|
||||
//
|
||||
// Author: Elena Guardincerri
|
||||
//
|
||||
// History:
|
||||
// -----------
|
||||
// 28 Nov 2001 Elena Guardincerri Created
|
||||
// 24 Ago 2002 Splitted in a separet class Alfonso Mantero
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UIterminal.hh"
|
||||
#include "G4UItcsh.hh"
|
||||
#ifdef G4UI_USE_XM
|
||||
#include "G4UIXm.hh"
|
||||
#endif
|
||||
#include "Randomize.hh"
|
||||
#ifdef G4VIS_USE
|
||||
#include "XrayFluoVisManager.hh"
|
||||
#endif
|
||||
#include "XrayFluoDetectorConstruction.hh"
|
||||
#include "XrayFluoPlaneDetectorConstruction.hh"
|
||||
#include "XrayFluoMercuryDetectorConstruction.hh"
|
||||
#include "XrayFluoPhysicsList.hh"
|
||||
#include "XrayFluoPrimaryGeneratorAction.hh"
|
||||
#include "XrayFluoPlanePrimaryGeneratorAction.hh"
|
||||
#include "XrayFluoMercuryPrimaryGeneratorAction.hh"
|
||||
#include "XrayFluoRunAction.hh"
|
||||
#include "XrayFluoEventAction.hh"
|
||||
#include "XrayFluoSteppingAction.hh"
|
||||
#include "XrayFluoSteppingVerbose.hh"
|
||||
#include "XrayFluoSimulation.hh"
|
||||
|
||||
#ifdef G4ANALYSIS_USE
|
||||
#include "XrayFluoAnalysisManager.hh"
|
||||
#endif
|
||||
|
||||
XrayFluoSimulation::XrayFluoSimulation(G4int seed):dir(seed)
|
||||
|
||||
{ }
|
||||
|
||||
XrayFluoSimulation::~XrayFluoSimulation()
|
||||
|
||||
{ }
|
||||
|
||||
void XrayFluoSimulation::RunSimulation(int argc,char* argv[])
|
||||
{
|
||||
|
||||
// choose the Random engine
|
||||
HepRandom::setTheEngine(new RanecuEngine);
|
||||
HepRandom::setTheSeed(dir);
|
||||
|
||||
//XrayFluo Verbose output class
|
||||
G4VSteppingVerbose::SetInstance(new XrayFluoSteppingVerbose);
|
||||
|
||||
// Construct the default run manager
|
||||
G4RunManager * runManager = new G4RunManager;
|
||||
|
||||
// set mandatory initialization
|
||||
|
||||
XrayFluoPhysicsList* xrayList = 0;
|
||||
|
||||
// chosing Geometry setup
|
||||
|
||||
G4int GeometryNumber;
|
||||
|
||||
|
||||
if (argc == 3){
|
||||
GeometryNumber = atoi(argv[2]);
|
||||
}
|
||||
while ( (GeometryNumber != 1) && (GeometryNumber !=2) && (GeometryNumber !=3) ) {
|
||||
G4cout << "Please Select Simulation Geometrical Set-Up: "<< G4endl;
|
||||
G4cout << "1 - Test Beam" << G4endl;
|
||||
G4cout << "2 - Infinite Plane" << G4endl;
|
||||
G4cout << "3 - Planet and Sun (beta)"<< G4endl;
|
||||
G4cin >> GeometryNumber;
|
||||
}
|
||||
|
||||
XrayFluoDetectorConstruction* testBeamDetector = 0;
|
||||
XrayFluoPlaneDetectorConstruction* planeDetector = 0;
|
||||
XrayFluoMercuryDetectorConstruction* mercuryDetector = 0;
|
||||
|
||||
if (GeometryNumber == 1) {
|
||||
testBeamDetector = XrayFluoDetectorConstruction::GetInstance();
|
||||
runManager->SetUserInitialization(testBeamDetector);
|
||||
xrayList = new XrayFluoPhysicsList(testBeamDetector);
|
||||
}
|
||||
else if (GeometryNumber == 2) {
|
||||
planeDetector = XrayFluoPlaneDetectorConstruction::GetInstance();
|
||||
runManager->SetUserInitialization(planeDetector);
|
||||
xrayList = new XrayFluoPhysicsList(planeDetector);
|
||||
}
|
||||
else if (GeometryNumber == 3) {
|
||||
mercuryDetector = XrayFluoMercuryDetectorConstruction::GetInstance();
|
||||
runManager->SetUserInitialization(mercuryDetector);
|
||||
xrayList = new XrayFluoPhysicsList(mercuryDetector);
|
||||
}
|
||||
|
||||
runManager->SetUserInitialization(xrayList);
|
||||
|
||||
G4UIsession* session=0;
|
||||
|
||||
if (argc==1) // Define UI session for interactive mode.
|
||||
{
|
||||
// G4UIterminal is a (dumb) terminal.
|
||||
#ifdef G4UI_USE_XM
|
||||
session = new G4UIXm(argc,argv);
|
||||
#else
|
||||
#ifdef G4UI_USE_TCSH
|
||||
session = new G4UIterminal(new G4UItcsh);
|
||||
#else
|
||||
session = new G4UIterminal();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef G4VIS_USE
|
||||
//visualization manager
|
||||
G4VisManager* visManager = new XrayFluoVisManager;
|
||||
visManager->Initialize();
|
||||
#endif
|
||||
|
||||
// set analysis to have the messenger running...
|
||||
// XrayFluoAnalysisManager* analysis =
|
||||
|
||||
#ifdef G4ANALYSIS_USE
|
||||
XrayFluoAnalysisManager::getInstance();
|
||||
#endif
|
||||
|
||||
XrayFluoEventAction* eventAction = 0;
|
||||
XrayFluoRunAction* runAction = new XrayFluoRunAction();
|
||||
XrayFluoSteppingAction* stepAction = new XrayFluoSteppingAction();
|
||||
|
||||
|
||||
//Selecting the PrimaryGenerator depending upon Geometry setup selected
|
||||
|
||||
if (GeometryNumber == 1) {
|
||||
eventAction = new XrayFluoEventAction(testBeamDetector);
|
||||
runManager->SetUserAction(new XrayFluoPrimaryGeneratorAction(testBeamDetector));
|
||||
|
||||
}
|
||||
else if (GeometryNumber == 2) {
|
||||
eventAction = new XrayFluoEventAction(planeDetector);
|
||||
runManager->SetUserAction(new XrayFluoPlanePrimaryGeneratorAction(planeDetector));
|
||||
}
|
||||
else if (GeometryNumber == 3) {
|
||||
stepAction->SetMercuryFlag(true);
|
||||
eventAction = new XrayFluoEventAction(mercuryDetector);
|
||||
runManager->SetUserAction(new XrayFluoMercuryPrimaryGeneratorAction(mercuryDetector));
|
||||
}
|
||||
|
||||
runManager->SetUserAction(eventAction);
|
||||
runManager->SetUserAction(runAction);
|
||||
runManager->SetUserAction(stepAction);
|
||||
|
||||
//Initialize G4 kernel
|
||||
runManager->Initialize();
|
||||
|
||||
// get the pointer to the User Interface manager
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
|
||||
if (session) // Define UI session for interactive mode.
|
||||
{
|
||||
// G4UIterminal is a (dumb) terminal.
|
||||
UI->ApplyCommand("/control/execute initInter.mac");
|
||||
#ifdef G4UI_USE_XM
|
||||
// Customize the G4UIXm menubar with a macro file :
|
||||
UI->ApplyCommand("/control/execute gui.mac");
|
||||
#endif
|
||||
session->SessionStart();
|
||||
delete session;
|
||||
}
|
||||
else // Batch mode
|
||||
{
|
||||
G4String command = "/control/execute ";
|
||||
G4String fileName = argv[1];
|
||||
UI->ApplyCommand(command+fileName);
|
||||
}
|
||||
|
||||
// job termination
|
||||
|
||||
#ifdef G4VIS_USE
|
||||
delete visManager;
|
||||
G4cout << "visManager deleted"<< G4endl;
|
||||
#endif
|
||||
|
||||
delete runManager;
|
||||
|
||||
if (testBeamDetector) delete testBeamDetector;
|
||||
if (planeDetector) delete planeDetector;
|
||||
if (mercuryDetector) delete mercuryDetector;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: XrayFluoVdetectorType.cc
|
||||
// GEANT4 tag $Name:
|
||||
//
|
||||
// Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it)
|
||||
//
|
||||
// History:
|
||||
// -----------
|
||||
// 19 Jun 2003 Alfonso Mantero Created
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#include "XrayFluoVDetectorType.hh"
|
||||
|
||||
XrayFluoVDetectorType::XrayFluoVDetectorType()
|
||||
{;}
|
||||
XrayFluoVDetectorType::~XrayFluoVDetectorType()
|
||||
{;}
|
||||
// G4String XrayFluoVDetectorType::GetDetectorMaterial()
|
||||
// {;}
|
||||
// G4double XrayFluoVDetectorType::ResponseFunction(G4double)
|
||||
// {;}
|
||||
// G4double XrayFluoVDetectorType::GetInfData(G4double,G4double,G4int=0)
|
||||
// {;}
|
||||
// G4double XrayFluoVDetectorType::GetSupData(G4double,G4double,G4int=0)
|
||||
// {;}
|
||||
// void XrayFluoVDetectorType::LoadResponseData(G4String)
|
||||
// {;}
|
||||
// void XrayFluoVDetectorType::LoadEfficiencyData(G4String)
|
||||
// {;}
|
||||
|
||||
Reference in New Issue
Block a user