Added to repository
This commit is contained in:
277
geant4/LEMuSR/src/AsymCheck.cc
Normal file
277
geant4/LEMuSR/src/AsymCheck.cc
Normal file
@ -0,0 +1,277 @@
|
||||
///§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID : AsymCheck.cc , v 1.2
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-08-20 10:20
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// ASYMCHECK
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
#include "AsymCheck.hh"
|
||||
|
||||
#include "G4SteppingManager.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4DynamicParticle.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "LEMuSRMuonDecayChannel.hh"
|
||||
#include "G4MuonDecayChannelWithSpin.hh"
|
||||
|
||||
AsymCheck::AsymCheck()
|
||||
{
|
||||
|
||||
A=0;L=0;R=0;
|
||||
BR1=BR2=dm1=dm2=0;
|
||||
BookRoot();
|
||||
|
||||
pointer=this ;
|
||||
}
|
||||
|
||||
|
||||
AsymCheck::~AsymCheck()
|
||||
{
|
||||
PrintAsym();
|
||||
G4cout <<"\n Left/Right Asymmetry: L vs R = " << L <<" vs " << R <<" => A = " << A <<" for "<< L+R <<" particles.\n"<<G4endl;
|
||||
WriteRoot();
|
||||
}
|
||||
|
||||
AsymCheck* AsymCheck::pointer=0;
|
||||
AsymCheck* AsymCheck::GetInstance()
|
||||
{
|
||||
return pointer;
|
||||
}
|
||||
|
||||
|
||||
void AsymCheck::UserSteppingAction(const G4Step* aStep)
|
||||
|
||||
{
|
||||
|
||||
SetParticleVolumeNames(aStep);
|
||||
|
||||
if(CheckCondition(aStep))
|
||||
{
|
||||
|
||||
// Get datas
|
||||
SetPositionMomentum(aStep);
|
||||
SetTimeEnergy(aStep);
|
||||
SetAngles(aStep);
|
||||
|
||||
SetSpinDirection(aStep);
|
||||
// Print datas to screen
|
||||
// PrintDatas(aStep);
|
||||
Update();
|
||||
FillRoot();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
G4bool AsymCheck::CheckCondition(const G4Step* aStep)
|
||||
{
|
||||
G4bool condition=false;
|
||||
|
||||
if (v_name == "lv_AsymL" ||v_name == "lv_AsymR")
|
||||
{
|
||||
if(p_name == "e+")
|
||||
{
|
||||
if( aStep->GetTrack()->GetCreatorProcess())
|
||||
{
|
||||
if( aStep->GetTrack()->GetCreatorProcess()->GetProcessName()=="Decay"|| aStep->GetTrack()->GetCreatorProcess()->GetProcessName()=="DecayWithSpin")
|
||||
|
||||
{
|
||||
condition=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return condition;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void AsymCheck::SetAngles(const G4Step* aStep)
|
||||
{
|
||||
//lemu
|
||||
// theta = LEMuSRMuonDecayChannel::GetInstance()->theta;
|
||||
// phi = LEMuSRMuonDecayChannel::GetInstance()->phi;
|
||||
|
||||
// triumf
|
||||
m=aStep->GetPreStepPoint()->GetMomentumDirection();
|
||||
p= aStep->GetTrack()->GetDynamicParticle()->GetPolarization();
|
||||
|
||||
m.rotateUz(G4ThreeVector(-1.,0.,0.));
|
||||
p.rotateUz(G4ThreeVector(-1.,0.,0.));
|
||||
|
||||
theta = m.theta(p);
|
||||
if (m.x()<0)phi = acos(m.x()/sin(theta))*(-1.);
|
||||
else if (m.x()>=0)phi = acos(m.x()/sin(theta))*(+1.);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void AsymCheck::SetParticleVolumeNames(const G4Step* aStep)
|
||||
{
|
||||
// NAMES
|
||||
p_name = aStep->GetTrack()->GetDefinition()->GetParticleName(); // particle name
|
||||
v_name = aStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetName(); //lv_name
|
||||
pv_name = aStep->GetTrack()->GetVolume()->GetName(); //lv_name
|
||||
|
||||
}
|
||||
|
||||
|
||||
void AsymCheck::SetPositionMomentum(const G4Step* aStep)
|
||||
{
|
||||
|
||||
// POSITION, MOMENTUM
|
||||
position = aStep->GetPreStepPoint()->GetPosition(); // position
|
||||
momentum = aStep->GetPreStepPoint()->GetMomentum(); // momentum
|
||||
momentum_direction = aStep->GetPreStepPoint()->GetMomentumDirection(); // momentum
|
||||
|
||||
if(position.x()>0) L++;
|
||||
else if(position.x()<0) R++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void AsymCheck::SetTimeEnergy(const G4Step* aStep)
|
||||
{
|
||||
|
||||
// ENERGY
|
||||
kenergy= aStep->GetTrack()->GetDynamicParticle()->GetKineticEnergy(); // position
|
||||
|
||||
tenergy= aStep->GetTrack()->GetDynamicParticle()->GetTotalEnergy(); // position
|
||||
|
||||
// TIME
|
||||
localtime = aStep->GetTrack()->GetLocalTime(); // time since track creation
|
||||
globaltime = aStep->GetPreStepPoint()->GetGlobalTime();// time since event creation
|
||||
proptime = aStep->GetTrack()->GetProperTime(); // proper time of the particle
|
||||
time = proptime;
|
||||
|
||||
positron.kenergy =kenergy ;
|
||||
}
|
||||
|
||||
|
||||
void AsymCheck::SetSpinDirection(const G4Step* aStep)
|
||||
{
|
||||
polarization = aStep->GetTrack()->GetDynamicParticle()->GetPolarization();
|
||||
// G4cout <<"Polarization " << polarization <<G4endl;
|
||||
spin.omegat = acos(polarization.x());
|
||||
spin.time = aStep->GetPreStepPoint()->GetGlobalTime();
|
||||
}
|
||||
|
||||
|
||||
void AsymCheck::Update()
|
||||
{
|
||||
positron.kenergy =kenergy/MeV ;
|
||||
positron.tenergy =tenergy;
|
||||
positron.localtime =localtime ;
|
||||
positron.globaltime =globaltime/ns ;
|
||||
positron.proptime = proptime ;
|
||||
|
||||
positron.theta = theta/rad ;
|
||||
positron.phi = phi/rad;
|
||||
|
||||
positron.positionx = position.x()/mm;
|
||||
positron.positiony = position.y()/mm;
|
||||
positron.positionz = position.z()/mm;
|
||||
|
||||
positron.momdirx= momentum_direction.x()/mm;
|
||||
positron.momdiry= momentum_direction.y()/mm;
|
||||
positron.momdirz= momentum_direction.z()/mm;
|
||||
|
||||
positron.ID=G4RunManager::GetRunManager()->GetCurrentRun()->GetRunID();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// PRINT VALUES
|
||||
|
||||
void AsymCheck::PrintAsym()
|
||||
{
|
||||
A = (L-R)/(L+R);
|
||||
// G4cout <<"\n Left/Right Asymmetry: L vs R = " << L <<" vs " << R <<" => A = " << A <<" for "<< L+R <<" particles.\n"<<G4endl;
|
||||
asym.asym=A;
|
||||
asym.L=L;
|
||||
asym.R=R;
|
||||
asym.S=L+R;
|
||||
}
|
||||
|
||||
|
||||
void AsymCheck::PrintDatas(const G4Step* aStep)
|
||||
{
|
||||
|
||||
if( aStep->GetTrack()->GetCreatorProcess())
|
||||
{
|
||||
G4cout << "NOT PRIMARY PARTICLE : created by : " << aStep->GetTrack()->GetCreatorProcess()->GetProcessName() <<" ;\n ";
|
||||
}
|
||||
|
||||
G4cout << "particle name : " << p_name <<" ;\n "
|
||||
<< "volume name : " << v_name <<" ;\n "
|
||||
<< "kinetic energy : " << G4BestUnit(kenergy,"Energy") <<" ;\n "
|
||||
<< "total energy : " << G4BestUnit(tenergy,"Energy") <<" ;\n "
|
||||
<< "current energy : " << G4BestUnit(aStep->GetPreStepPoint()->GetTotalEnergy(),"Energy") <<" ;\n "
|
||||
<< "Time (l,g,p) : " << G4BestUnit(localtime,"Time") <<" ; "
|
||||
<< G4BestUnit(globaltime,"Time")<<" ; "
|
||||
<< G4BestUnit(proptime,"Time") <<" ;\n "
|
||||
<< "position : " << position <<" ;\n "
|
||||
<< "momentum : " << momentum <<" ;\n "
|
||||
<< "momentum direction: " << momentum_direction<<" ;\n "
|
||||
<< "theta angle : " << theta <<" ;\n "
|
||||
<< "phi angle : " << phi <<" ;\n "
|
||||
|
||||
<<G4endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------//
|
||||
// ROOT
|
||||
|
||||
void AsymCheck::BookRoot()
|
||||
{
|
||||
myFile = new TFile("Test.root", "RECREATE");
|
||||
|
||||
tree = new TTree ("tree","Positrons parameters");
|
||||
|
||||
tree->Branch("positron",&positron.kenergy,"kenergy/F:tenergy/F:localtime/F:globaltime:propertime/F:theta:phi:positionx/F:positiony:positionz:momdirx:momdiry:momdirz/F:runID/I");
|
||||
|
||||
tree->Branch("Asymetry",&asym.asym,"Asym/F:L:R:S");
|
||||
|
||||
tree->Branch("spin",&spin.omegat,"omegat/F:time");
|
||||
|
||||
}
|
||||
|
||||
|
||||
void AsymCheck::FillRoot()
|
||||
{
|
||||
tree->Fill();
|
||||
// tree->Scan();
|
||||
|
||||
}
|
||||
|
||||
void AsymCheck::WriteRoot()
|
||||
{
|
||||
myFile->Write();
|
||||
myFile->Close();
|
||||
|
||||
}
|
376
geant4/LEMuSR/src/FieldCheck.cc
Normal file
376
geant4/LEMuSR/src/FieldCheck.cc
Normal file
@ -0,0 +1,376 @@
|
||||
///§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID :FieldCheck.cc , v 1.2
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-09-17 10:20
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// FIELDCHECK
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
#include "FieldCheck.hh"
|
||||
|
||||
#include "G4SteppingManager.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4DynamicParticle.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "LEMuSRDetectorConstruction.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4Polyline.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
|
||||
|
||||
|
||||
FieldCheck::FieldCheck()
|
||||
{
|
||||
|
||||
BookRoot();
|
||||
muon.index= 0;
|
||||
|
||||
|
||||
loop=0;
|
||||
pointer=this ;
|
||||
}
|
||||
|
||||
|
||||
FieldCheck::~FieldCheck()
|
||||
{
|
||||
WriteRoot();
|
||||
}
|
||||
|
||||
FieldCheck* FieldCheck::pointer=0;
|
||||
FieldCheck* FieldCheck::GetInstance()
|
||||
{
|
||||
return pointer;
|
||||
}
|
||||
|
||||
|
||||
void FieldCheck::UserSteppingAction(const G4Step* aStep)
|
||||
|
||||
{
|
||||
if( aStep->GetPreStepPoint()&& aStep->GetPostStepPoint()->GetPhysicalVolume() )
|
||||
{
|
||||
SetParticleVolumeNames(aStep);
|
||||
kenergy= aStep->GetTrack()->GetDynamicParticle()->GetKineticEnergy(); // position
|
||||
|
||||
if(CheckCondition(aStep))
|
||||
{
|
||||
|
||||
SetPositionMomentum(aStep);
|
||||
SetTimeEnergy(aStep);
|
||||
// SetSpinDirection(aStep);
|
||||
|
||||
// Print datas to screen
|
||||
// PrintDatas(aStep);
|
||||
PrintField(aStep);
|
||||
|
||||
Update();
|
||||
FillRoot();
|
||||
#if defined G4UI_USE_ROOT
|
||||
myFile->Write();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
// kill useless particles
|
||||
// kill useless particles
|
||||
/* if(aStep->GetTrack()->GetDefinition()->GetParticleName()=="e-"
|
||||
||aStep->GetTrack()->GetDefinition()->GetParticleName()=="gamma")
|
||||
{
|
||||
aStep->GetTrack()->SetTrackStatus(fStopAndKill);
|
||||
}*/
|
||||
|
||||
if(p_name!="mu+" &&p_name!="Mu" &&p_name!="e+" &&p_name!="geantino")
|
||||
{
|
||||
aStep->GetTrack()->SetTrackStatus(fStopAndKill);
|
||||
}
|
||||
|
||||
|
||||
// loop killa
|
||||
if(aStep->GetStepLength()<0.01*mm)
|
||||
{
|
||||
loop++;
|
||||
if(loop>20)
|
||||
{
|
||||
aStep->GetTrack()->SetTrackStatus(fStopAndKill);
|
||||
loop=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
|
||||
|
||||
if (pVVisManager) {
|
||||
//----- Define a line segment
|
||||
G4Polyline polyline;
|
||||
G4Colour colour;
|
||||
if (p_name == "mu+") colour = G4Colour(1., 0., 0.);
|
||||
else if (p_name == "Mu" ) colour = G4Colour(0., 0., 1.);
|
||||
else if (p_name == "e+" ) colour = G4Colour(1., 1., 0.);
|
||||
else colour = G4Colour(1., 0., 1.);
|
||||
G4VisAttributes attribs(colour);
|
||||
polyline.SetVisAttributes(attribs);
|
||||
polyline.push_back(aStep->GetPreStepPoint()->GetPosition());
|
||||
polyline.push_back(aStep->GetPostStepPoint()->GetPosition());
|
||||
|
||||
//----- Call a drawing method for G4Polyline
|
||||
pVVisManager -> Draw(polyline);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4bool FieldCheck::CheckCondition(const G4Step* aStep)
|
||||
{
|
||||
G4bool condition=false;
|
||||
|
||||
if((p_name == "mu+"||p_name=="Mu"||p_name=="geantino")/*&&v_name=="lv_MCPV"*/&&aStep->GetPreStepPoint()->GetPosition().z()<16*cm)
|
||||
|
||||
// if(aStep->GetPostStepPoint()->GetProcessDefinedStep() != NULL)
|
||||
// {
|
||||
// if( aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="Decay")
|
||||
// {
|
||||
{
|
||||
condition=true;
|
||||
}
|
||||
return condition;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FieldCheck::SetParticleVolumeNames(const G4Step* aStep)
|
||||
{
|
||||
// NAMES
|
||||
p_name = aStep->GetTrack()->GetDefinition()->GetParticleName(); // particle name
|
||||
v_name = aStep->GetPostStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName(); //lv_name
|
||||
pv_name = aStep->GetTrack()->GetVolume()->GetName(); //lv_name
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FieldCheck::SetPositionMomentum(const G4Step* aStep)
|
||||
{
|
||||
|
||||
// POSITION, MOMENTUM
|
||||
position = aStep->GetTrack()->GetPosition(); // position
|
||||
momentum = aStep->GetTrack()->GetMomentum(); // momentum
|
||||
momentum_direction = aStep->GetTrack()->GetMomentumDirection(); // momentum
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FieldCheck::SetTimeEnergy(const G4Step* aStep)
|
||||
{
|
||||
|
||||
// ENERGY
|
||||
kenergy= aStep->GetTrack()->GetDynamicParticle()->GetKineticEnergy(); // position
|
||||
|
||||
tenergy= aStep->GetTrack()->GetDynamicParticle()->GetTotalEnergy(); // position
|
||||
|
||||
// TIME
|
||||
localtime = aStep->GetPostStepPoint()->GetLocalTime(); // time since track creation
|
||||
globaltime = aStep->GetPostStepPoint()->GetGlobalTime();// time since event creation
|
||||
proptime = aStep->GetPostStepPoint()->GetProperTime(); // proper time of the particle
|
||||
time = proptime;
|
||||
|
||||
charge=aStep->GetTrack()->GetDynamicParticle()->GetCharge();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FieldCheck::SetSpinDirection(const G4Step* aStep)
|
||||
{
|
||||
polarization = aStep->GetTrack()->GetDynamicParticle()->GetPolarization();
|
||||
// G4cout<<polarization.y()<<G4endl;
|
||||
}
|
||||
|
||||
|
||||
void FieldCheck::Update()
|
||||
{
|
||||
muon.tenergy = kenergy/keV;
|
||||
muon.localtime = localtime ;
|
||||
muon.globaltime= globaltime/ns ;
|
||||
muon.proptime = proptime ;
|
||||
|
||||
muon.positionx = position.x()/mm;
|
||||
muon.positiony = position.y()/mm;
|
||||
muon.positionz = position.z()/mm;
|
||||
|
||||
muon.momdirx= momentum_direction.x();
|
||||
muon.momdiry= momentum_direction.y();
|
||||
muon.momdirz= momentum_direction.z();
|
||||
|
||||
muon.Ex=fx;
|
||||
muon.Ey=fy;
|
||||
muon.Ez=fz;
|
||||
|
||||
muon.Bx=bx;
|
||||
muon.By=by;
|
||||
muon.Bz=bz;
|
||||
|
||||
muon.id = G4RunManager::GetRunManager()->GetCurrentRun()->GetRunID();
|
||||
evt=G4RunManager::GetRunManager()->GetCurrentEvent()->GetEventID();
|
||||
muon.event = evt;
|
||||
|
||||
muon.charge= charge;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// PRINT VALUES
|
||||
|
||||
void FieldCheck::PrintField(const G4Step* aStep)
|
||||
{
|
||||
// G4cout<< position.z()<<G4endl;
|
||||
if(aStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetFieldManager())
|
||||
{
|
||||
G4double point[4];
|
||||
G4double Bfield[6];
|
||||
|
||||
point[0]=position.x();
|
||||
point[1]=position.y();
|
||||
point[2]=position.z();
|
||||
|
||||
aStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetFieldManager()->GetDetectorField()->GetFieldValue(point, Bfield);
|
||||
// G4cout<< position.z()<<G4endl;
|
||||
|
||||
if(position.z()<-34.7*cm)
|
||||
{
|
||||
// G4cout<< position.z() <<" Case TL "<<G4endl;
|
||||
fx=Bfield[0]/kilovolt*meter;
|
||||
fy=Bfield[1]/kilovolt*meter;
|
||||
fz=Bfield[2]/kilovolt*meter;
|
||||
}
|
||||
|
||||
if(position.z()>-34.7*cm
|
||||
&&LEMuSRDetectorConstruction::GetInstance()->magfield==1
|
||||
&&LEMuSRDetectorConstruction::GetInstance()->anode_elfield==1)
|
||||
{
|
||||
// G4cout<<"Case EM "<<G4endl;
|
||||
bx=Bfield[0]/gauss;
|
||||
by=Bfield[1]/gauss; //kilovolt*meter;
|
||||
bz=Bfield[2]/gauss;
|
||||
fx=Bfield[3]/kilovolt*meter;
|
||||
fy=Bfield[4]/kilovolt*meter;
|
||||
fz=Bfield[5]/kilovolt*meter;
|
||||
}
|
||||
|
||||
if(position.z()>-34.7*cm
|
||||
&&LEMuSRDetectorConstruction::GetInstance()->magfield==1
|
||||
&&LEMuSRDetectorConstruction::GetInstance()->anode_elfield==0)
|
||||
{
|
||||
// G4cout<<"Case Mag "<<G4endl;
|
||||
bx=Bfield[0]/gauss;
|
||||
by=Bfield[1]/gauss; //kilovolt*meter;
|
||||
bz=Bfield[2]/gauss;
|
||||
fx=0*Bfield[3]/kilovolt*meter;
|
||||
fy=0*Bfield[4]/kilovolt*meter;
|
||||
fz=0*Bfield[5]/kilovolt*meter;
|
||||
}
|
||||
|
||||
if(position.z()>-34.7*cm
|
||||
&&LEMuSRDetectorConstruction::GetInstance()->magfield==0
|
||||
&&LEMuSRDetectorConstruction::GetInstance()->anode_elfield==1)
|
||||
{
|
||||
// G4cout<<"Case Elec "<<G4endl;
|
||||
fx=Bfield[0]/kilovolt*meter;
|
||||
fy=Bfield[1]/kilovolt*meter;
|
||||
fz=Bfield[2]/kilovolt*meter;
|
||||
bx=0.;
|
||||
by=0.; //kilovolt*meter;
|
||||
bz=0.;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG_FIELD
|
||||
G4cout<<"Field Value " << G4BestUnit(Bfield[0]*meter,"Electric potential") <<" /m " <<Bfield[1] /volt*meter <<" V/m "<< Bfield[2]/volt*meter <<" V/m " <<G4endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fx=0;
|
||||
fy=0;
|
||||
fz=0;
|
||||
bx=0;
|
||||
by=0;
|
||||
bz=0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FieldCheck::PrintDatas(const G4Step* aStep)
|
||||
{
|
||||
|
||||
if( aStep->GetTrack()->GetCreatorProcess())
|
||||
{
|
||||
G4cout << "NOT PRIMARY PARTICLE : created by : " << aStep->GetTrack()->GetCreatorProcess()->GetProcessName() <<" ;\n ";
|
||||
}
|
||||
|
||||
G4cout << "particle name : " << p_name <<" ;\n "
|
||||
<< "volume name : " << v_name <<" ;\n "
|
||||
<< "kinetic energy : " << G4BestUnit(kenergy,"Energy") <<" ;\n "
|
||||
<< "Time (l,g,p) : " << G4BestUnit(localtime,"Time") <<" ; "
|
||||
<< G4BestUnit(globaltime,"Time")<<" ; "
|
||||
<< G4BestUnit(proptime,"Time") <<" ;\n "
|
||||
<< "position : " << G4BestUnit(position,"Length")<<" ;\n "
|
||||
<< "momentum : " << momentum <<" ;\n "
|
||||
<< "momentum direction: " << momentum_direction<<" ;\n "
|
||||
<<G4endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------//
|
||||
// ROOT
|
||||
|
||||
void FieldCheck::BookRoot()
|
||||
{
|
||||
myFile = new TFile("field2.root", "RECREATE");
|
||||
|
||||
tree = new TTree ("tree","Muons parameters");
|
||||
|
||||
tree->Branch("muon",&muon.tenergy,"kenergy/F:localtime/F:globaltime:propertime/F:positionx/F:positiony:positionz:momdirx:momdiry:momdirz:Bx:By:Bz:Ex:Ey:Ez:charge/F:index/I:event/I:runID/I");
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FieldCheck::FillRoot()
|
||||
{
|
||||
tree->Fill();
|
||||
// tree->Scan();
|
||||
|
||||
}
|
||||
|
||||
void FieldCheck::WriteRoot()
|
||||
{
|
||||
myFile->Write();
|
||||
myFile->Close();
|
||||
|
||||
}
|
264
geant4/LEMuSR/src/FocalLengthTest.cc
Normal file
264
geant4/LEMuSR/src/FocalLengthTest.cc
Normal file
@ -0,0 +1,264 @@
|
||||
///§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID :FocalLengthTest.cc , v 1.2
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2005-03-02 09:37
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// FOCALLENGTHTEST
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
#include "FocalLengthTest.hh"
|
||||
|
||||
#include "G4SteppingManager.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4DynamicParticle.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#include "LEMuSRPrimaryGeneratorAction.hh"
|
||||
|
||||
|
||||
FocalLengthTest::FocalLengthTest()
|
||||
{
|
||||
|
||||
BookRoot();
|
||||
muon.event=0;
|
||||
loop=0;
|
||||
pointer=this ;
|
||||
}
|
||||
|
||||
|
||||
FocalLengthTest::~FocalLengthTest()
|
||||
{
|
||||
WriteRoot();
|
||||
}
|
||||
|
||||
FocalLengthTest* FocalLengthTest::pointer=0;
|
||||
FocalLengthTest* FocalLengthTest::GetInstance()
|
||||
{
|
||||
return pointer;
|
||||
}
|
||||
|
||||
|
||||
void FocalLengthTest::UserSteppingAction(const G4Step* aStep)
|
||||
|
||||
{
|
||||
if( aStep->GetPreStepPoint()&& aStep->GetPreStepPoint()->GetPhysicalVolume() )
|
||||
{
|
||||
|
||||
LoopKiller(aStep);
|
||||
SetParticleVolumeNames(aStep);
|
||||
|
||||
if(CheckCondition(aStep))
|
||||
{
|
||||
|
||||
// Get datas
|
||||
SetPositionMomentum(aStep);
|
||||
SetTimeEnergy(aStep);
|
||||
|
||||
Update();
|
||||
FillRoot();
|
||||
#if defined G4UI_USE_ROOT
|
||||
myFile->Write();
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void FocalLengthTest::LoopKiller(const G4Step *aStep)
|
||||
{
|
||||
// loop killa
|
||||
if(aStep->GetStepLength()<0.001*mm)
|
||||
{
|
||||
loop++;
|
||||
if(loop>20)
|
||||
{
|
||||
aStep->GetTrack()->SetTrackStatus(fStopAndKill);
|
||||
loop=0;
|
||||
}
|
||||
}
|
||||
|
||||
// kill useless particles
|
||||
if(aStep->GetTrack()->GetDefinition()->GetParticleName()=="e-"
|
||||
||aStep->GetTrack()->GetDefinition()->GetParticleName()=="gamma")
|
||||
{
|
||||
if(aStep->GetTrack()->GetKineticEnergy()<10.*eV)
|
||||
{
|
||||
aStep->GetTrack()->SetTrackStatus(fStopAndKill);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
G4bool FocalLengthTest::CheckCondition(const G4Step* )
|
||||
{
|
||||
G4bool condition=false;
|
||||
|
||||
// if(p_name == "geantino" && v_name=="lv_fchk") // change also in pga
|
||||
if(p_name == "mu+" && v_name=="lv_fchk")
|
||||
{
|
||||
if(pv_name=="pv_f1"||pv_name=="pv_f44")// THE FIRST DUMMY PLANE
|
||||
{
|
||||
condition=true;
|
||||
}
|
||||
}
|
||||
|
||||
return condition;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FocalLengthTest::SetParticleVolumeNames(const G4Step* aStep)
|
||||
{
|
||||
// NAMES
|
||||
p_name = aStep->GetTrack()->GetDefinition()->GetParticleName(); // particle name
|
||||
v_name = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName(); //lv_name
|
||||
pv_name = aStep->GetTrack()->GetVolume()->GetName(); //lv_name
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FocalLengthTest::SetPositionMomentum(const G4Step* aStep)
|
||||
{
|
||||
|
||||
// POSITION, MOMENTUM
|
||||
position = aStep->GetPreStepPoint()->GetPosition(); // position
|
||||
momentum = aStep->GetPreStepPoint()->GetMomentum(); // momentum
|
||||
momentum_direction = aStep->GetPreStepPoint()->GetMomentumDirection(); // momentum
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FocalLengthTest::SetTimeEnergy(const G4Step* aStep)
|
||||
{
|
||||
|
||||
// ENERGY
|
||||
kenergy= aStep->GetTrack()->GetDynamicParticle()->GetKineticEnergy(); // position
|
||||
|
||||
tenergy= aStep->GetTrack()->GetDynamicParticle()->GetTotalEnergy(); // position
|
||||
|
||||
// TIME
|
||||
localtime = aStep->GetPreStepPoint()->GetLocalTime(); // time since track creation
|
||||
globaltime = aStep->GetPreStepPoint()->GetGlobalTime();// time since event creation
|
||||
proptime = aStep->GetPreStepPoint()->GetProperTime(); // proper time of the particle
|
||||
time = proptime;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FocalLengthTest::SetSpinDirection(const G4Step* aStep)
|
||||
{
|
||||
polarization = aStep->GetTrack()->GetDynamicParticle()->GetPolarization();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FocalLengthTest::Update()
|
||||
{
|
||||
muon.index++;
|
||||
|
||||
|
||||
if(pv_name=="pv_f1")// THE FIRST DUMMY PLANE
|
||||
{
|
||||
muon.index=0;
|
||||
muon.event++;
|
||||
init_kenergy=LEMuSRPrimaryGeneratorAction::GetPGA()->energy;
|
||||
}
|
||||
|
||||
if(pv_name=="pv_f44")
|
||||
{
|
||||
G4double FL, h, l, d;
|
||||
h=sqrt(position.x()*position.x()+position.y()*position.y());
|
||||
d=sqrt(momentum_direction.x()*momentum_direction.x()+momentum_direction.y()*momentum_direction.y());
|
||||
l=momentum_direction.z();
|
||||
|
||||
FL= h*l/d+22.*cm;// 22 cm from the last plane pv_f44 to the center of the lense
|
||||
//G4cout <<"Focal length for this particle : " << FL/meter <<"meter" <<G4endl;
|
||||
muon.focal = FL/centimeter;
|
||||
muon.kenergy = LEMuSRPrimaryGeneratorAction::GetPGA()->energy/keV;
|
||||
// G4cout <<"Kinectic energy for this particle : " << init_kenergy/keV <<"keV" <<G4endl;
|
||||
if(init_kenergy/keV<10)
|
||||
{
|
||||
muon.ratio=(-10*keV-init_kenergy)/(-init_kenergy);
|
||||
}
|
||||
else{
|
||||
muon.ratio=(10*keV-init_kenergy)/(-init_kenergy);
|
||||
}
|
||||
// G4cout <<"Ratio for this particle : " << (15*keV-init_kenergy)/init_kenergy <<"." <<G4endl;
|
||||
}
|
||||
|
||||
|
||||
muon.positionx = position.x()/mm;
|
||||
muon.positiony = position.y()/mm;
|
||||
muon.positionz = position.z()/mm;
|
||||
|
||||
muon.momdirx= momentum_direction.x();
|
||||
muon.momdiry= momentum_direction.y();
|
||||
muon.momdirz= momentum_direction.z();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// PRINT VALUES
|
||||
|
||||
void FocalLengthTest::PrintField(const G4Step* )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FocalLengthTest::PrintDatas(const G4Step* )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------//
|
||||
// ROOT
|
||||
|
||||
void FocalLengthTest::BookRoot()
|
||||
{
|
||||
myFile = new TFile("focal_length.root", "RECREATE");
|
||||
|
||||
tree = new TTree ("tree","Muons parameters");
|
||||
|
||||
tree->Branch("muon",&muon.kenergy,"kenergy/F:focal/F:ratio/F:positionx/F:positiony/F:positionz/F:momdirx/F:momdiry/F:momdirz");
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FocalLengthTest::FillRoot()
|
||||
{
|
||||
tree->Fill();
|
||||
// tree->Scan();
|
||||
|
||||
}
|
||||
|
||||
void FocalLengthTest::WriteRoot()
|
||||
{
|
||||
myFile->Write();
|
||||
myFile->Close();
|
||||
|
||||
}
|
229
geant4/LEMuSR/src/LEMuSRAtRestSpinRotation.cc
Normal file
229
geant4/LEMuSR/src/LEMuSRAtRestSpinRotation.cc
Normal file
@ -0,0 +1,229 @@
|
||||
///§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID : LEMuSRAtRestSpinRotation.cc , v 1.2
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-08-20 10:20
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// AT REST SPIN ROTATION
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
#include "LEMuSRAtRestSpinRotation.hh"
|
||||
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4MagneticField.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4FieldManager.hh"
|
||||
#include <iomanip>
|
||||
#include "globals.hh"
|
||||
#include "G4ParticleChange.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
|
||||
#include "G4ProcessVector.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
|
||||
|
||||
LEMuSRAtRestSpinRotation::LEMuSRAtRestSpinRotation(const G4String& processName)
|
||||
: G4VRestProcess (processName)
|
||||
{
|
||||
G4cout << GetProcessName() << " is created "<< G4endl;
|
||||
pointer = this;
|
||||
}
|
||||
|
||||
|
||||
LEMuSRAtRestSpinRotation::~LEMuSRAtRestSpinRotation()
|
||||
{;}
|
||||
|
||||
|
||||
LEMuSRAtRestSpinRotation* LEMuSRAtRestSpinRotation::pointer=0;
|
||||
LEMuSRAtRestSpinRotation* LEMuSRAtRestSpinRotation::GetInstance()
|
||||
{
|
||||
return pointer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
G4VParticleChange* LEMuSRAtRestSpinRotation::AtRestDoIt(const G4Track& theTrack, const G4Step& aStep)
|
||||
{
|
||||
|
||||
theParticleChange.Initialize(theTrack);
|
||||
theParticleChange.ProposeTrackStatus(fAlive);
|
||||
// G4cout<<"AT REST::: globaltime "<< theTrack.GetGlobalTime()/ns <<G4endl;// getchar();
|
||||
theParticleChange.ProposePosition(theTrack.GetPosition());
|
||||
theParticleChange.ProposeMomentumDirection(theTrack.GetMomentumDirection());
|
||||
theParticleChange.ProposeEnergy(theTrack.GetKineticEnergy());
|
||||
|
||||
// tao :: Get Time
|
||||
itime = theTrack.GetProperTime();
|
||||
G4double gtime = theTrack.GetGlobalTime();
|
||||
ftime = theTrack.GetDynamicParticle()->GetPreAssignedDecayProperTime();
|
||||
|
||||
|
||||
|
||||
deltatime = ftime - itime;
|
||||
theParticleChange.ProposeGlobalTime(deltatime + itime -gtime);
|
||||
theParticleChange.ProposeProperTime(deltatime);
|
||||
|
||||
polar = aStep.GetTrack()->GetPolarization();
|
||||
|
||||
|
||||
if(aStep.GetTrack()->GetVolume()->GetLogicalVolume()->GetFieldManager())
|
||||
{
|
||||
|
||||
|
||||
G4FieldManager *fMgr = theTrack.GetVolume()->GetLogicalVolume()->GetFieldManager();
|
||||
|
||||
|
||||
// if(!fMgr->DoesFieldChangeEnergy())//then we have a magnetic field
|
||||
if(fMgr->FieldHasMagComponent())//then we have a magnetic field
|
||||
{
|
||||
|
||||
#ifdef G4SRVERBOSE
|
||||
G4cout<<"AT REST::: MAGNETIC FIELD HERE" <<G4endl;// getchar();
|
||||
#endif
|
||||
|
||||
// tao :: Get Field
|
||||
point[0]=theTrack.GetPosition().x();
|
||||
point[1]=theTrack.GetPosition().y();
|
||||
point[2]=theTrack.GetPosition().z();
|
||||
|
||||
mfield = fMgr->GetDetectorField();
|
||||
|
||||
mfield->GetFieldValue(point,B);
|
||||
|
||||
#ifdef G4SRVERBOSE
|
||||
G4cout <<"AT REST::: MAGNETIC FIELD B="<< B[0] <<" " << B[1] <<" " << B[2] <<G4endl;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef G4SRVERBOSE
|
||||
G4cout <<"AT REST::: TIME= proper: "<< itime <<" ; global: " << gtime <<" decay: " << ftime <<G4endl;
|
||||
#endif
|
||||
|
||||
|
||||
G4ThreeVector magField(B[0],B[1],B[2]);
|
||||
RotateSpin(aStep,magField,deltatime);
|
||||
|
||||
|
||||
#ifdef G4SRVERBOSE
|
||||
G4cout<<"AT REST::: spin rotated";
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
theParticleChange.ProposePolarization(polar);
|
||||
|
||||
|
||||
|
||||
#ifdef G4SRVERBOSE
|
||||
theParticleChange.DumpInfo();
|
||||
#endif
|
||||
|
||||
|
||||
return &theParticleChange;
|
||||
|
||||
// then the AtRestUpdateStep method is called cf LEMuSRParticleChangeForSpinRotation (SR)
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// G4cout <<"No MAGNETIC FIELD do not call AtRestPrecession :: RotateSpin!!! ";
|
||||
return &theParticleChange;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LEMuSRAtRestSpinRotation::RotateSpin( const G4Step& aStep, G4ThreeVector B, G4double deltatime )
|
||||
{
|
||||
|
||||
|
||||
G4Transform3D Spin_rotation;
|
||||
|
||||
G4double Bnorm = sqrt(sqr(B[0]) + sqr(B[1]) +sqr(B[2]) );
|
||||
|
||||
#ifdef G4SRVERBOSE
|
||||
G4cout<< "AT REST::: PARAMETERS\n"
|
||||
<< "Magnetic Field Norm : " << G4BestUnit(Bnorm,"Magnetic flux density") <<"\n";
|
||||
#endif
|
||||
|
||||
G4double omega,q,a,fqz;
|
||||
G4double gamma;
|
||||
q= aStep.GetTrack()->GetDefinition()->GetPDGCharge();
|
||||
a= 1.165922e-3;
|
||||
fqz = 8.5062e+7*rad/(s*kilogauss);
|
||||
|
||||
gamma = aStep.GetTrack()->GetDefinition()->GetGammaFactor()*rad;
|
||||
|
||||
// G4cout<< fqz*(s*tesla)<<G4endl;
|
||||
// G4cout<< gamma*(s*tesla)<<G4endl;
|
||||
|
||||
|
||||
|
||||
#ifdef G4SRVERBOSE
|
||||
G4cout<< "AT REST::: PARAMETERS\n"
|
||||
<< "Charge : " << q <<"\n";
|
||||
#endif
|
||||
|
||||
// omega= - (fqz)*(1.+a) * Bnorm;
|
||||
omega= - (gamma) * Bnorm;
|
||||
|
||||
#ifdef G4SRVERBOSE
|
||||
G4cout<< "AT REST::: PARAMETERS\n"
|
||||
<< "Frequency: " << G4BestUnit(fqz*gauss/(2*M_PI*rad),"Frequency") <<"\n";
|
||||
G4cout<< "AT REST::: PARAMETERS\n"
|
||||
<< "FrequencyG: " << G4BestUnit(gamma*gauss/(2*M_PI*rad),"Frequency") <<"\n";
|
||||
#endif
|
||||
|
||||
|
||||
rotation_angle = deltatime*omega;
|
||||
|
||||
|
||||
Spin_rotation= G4Rotate3D(rotation_angle,B/Bnorm);
|
||||
|
||||
HepVector3D spin = aStep.GetTrack()->GetPolarization();
|
||||
HepVector3D newspin;
|
||||
newspin = Spin_rotation*spin;
|
||||
|
||||
G4double x,y,z,alpha;
|
||||
x = sqrt(spin*spin);
|
||||
y = sqrt(newspin*newspin);
|
||||
z = spin*newspin/x/y;
|
||||
alpha = acos(z);
|
||||
|
||||
#ifdef G4SRVERBOSE
|
||||
G4cout<< "AT REST::: PARAMETERS\n"
|
||||
<< "Initial spin : " << spin <<"\n"
|
||||
<< "Delta time : " << deltatime <<"\n"
|
||||
<< "Rotation angle: " << rotation_angle/(M_PI*rad) <<"\n"
|
||||
<< "New spin : " << newspin <<"\n"
|
||||
<< "Checked norms : " << x <<" " <<y <<" \n"
|
||||
<< G4endl;
|
||||
#endif
|
||||
|
||||
polar = newspin;
|
||||
|
||||
}
|
64
geant4/LEMuSR/src/LEMuSRCryoField.cc
Normal file
64
geant4/LEMuSR/src/LEMuSRCryoField.cc
Normal file
@ -0,0 +1,64 @@
|
||||
#include"LEMuSRCryoField.hh"
|
||||
|
||||
|
||||
LEMuSRCryoField::LEMuSRCryoField(G4ThreeVector FieldVector)
|
||||
{
|
||||
EField=FieldVector;
|
||||
|
||||
uniform=true;
|
||||
|
||||
}
|
||||
|
||||
LEMuSRCryoField::~LEMuSRCryoField()
|
||||
{;}
|
||||
|
||||
LEMuSRCryoField:: LEMuSRCryoField(G4ThreeVector FieldVector,G4double radius,G4double zmin, G4double zmax, G4double mcpv_z)
|
||||
{
|
||||
|
||||
// initialize
|
||||
EField=FieldVector;
|
||||
|
||||
fradius = radius;
|
||||
fzmin = zmin;
|
||||
fzmax = zmax;
|
||||
G4cout<<"zmin= "<<fzmin/cm<<"[cm] zmax= "<<fzmax/cm<<"[cm] "<<G4endl;
|
||||
|
||||
uniform=false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LEMuSRCryoField::GetFieldValue (const G4double pos[4],
|
||||
G4double *field ) const
|
||||
{
|
||||
|
||||
|
||||
|
||||
field[0]= 0.0;
|
||||
field[1]= 0.0;
|
||||
field[2]= 0.0;
|
||||
|
||||
G4double X,Y,Z;
|
||||
G4bool it=false;
|
||||
|
||||
X= pos[0];Y=pos[1];Z=pos[2];
|
||||
if(Z<fzmax&&Z>fzmin)
|
||||
{
|
||||
G4double R=sqrt(X*X+Y*Y);
|
||||
if(R<fradius)
|
||||
{
|
||||
it= true;
|
||||
}
|
||||
}
|
||||
|
||||
if(it||uniform)
|
||||
{
|
||||
// G4cout<<"true!"<<G4endl;getchar;
|
||||
field[0]= EField.x() ;//TAO
|
||||
field[1]= EField.y() ;
|
||||
field[2]= EField.z() ;
|
||||
// G4cout<<"CRYO FIELD: Z "<<Z/mm<<"[mm], FIELD "<<field[0]/volt*meter<<"V/m "<<field[1]/volt*meter<< "V/m "<<field[2]/volt*meter<< "V/m "<<G4endl;
|
||||
}
|
||||
|
||||
}
|
75
geant4/LEMuSR/src/LEMuSRCryoHit.cc
Normal file
75
geant4/LEMuSR/src/LEMuSRCryoHit.cc
Normal file
@ -0,0 +1,75 @@
|
||||
#include "LEMuSRCryoHit.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4Circle.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <fstream.h>
|
||||
#include <iomanip.h>
|
||||
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
G4Allocator<LEMuSRCryoHit> LEMuSRCryoHitAllocator;
|
||||
|
||||
LEMuSRCryoHit::LEMuSRCryoHit()
|
||||
{;}
|
||||
|
||||
LEMuSRCryoHit::~LEMuSRCryoHit()
|
||||
{;}
|
||||
|
||||
LEMuSRCryoHit::LEMuSRCryoHit(const LEMuSRCryoHit &right) : G4VHit()
|
||||
{
|
||||
particle_name = right.particle_name;
|
||||
energy_deposition = right.energy_deposition;
|
||||
time_of_flight = right.time_of_flight;
|
||||
position = right.position;
|
||||
momentum = right.momentum;
|
||||
}
|
||||
|
||||
const LEMuSRCryoHit& LEMuSRCryoHit::operator=(const LEMuSRCryoHit &right)
|
||||
{
|
||||
particle_name = right.particle_name;
|
||||
energy_deposition = right.energy_deposition;
|
||||
time_of_flight = right.time_of_flight;
|
||||
position = right.position;
|
||||
momentum = right.momentum;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4int LEMuSRCryoHit::operator==(const LEMuSRCryoHit &right) const
|
||||
{
|
||||
return (this==&right) ? 1 : 0;
|
||||
}
|
||||
|
||||
void LEMuSRCryoHit::Draw()
|
||||
{
|
||||
G4VVisManager* VisManager = G4VVisManager::GetConcreteInstance();
|
||||
if(VisManager)
|
||||
{
|
||||
G4Circle circle(position);
|
||||
circle.SetScreenSize(0.1);
|
||||
circle.SetFillStyle(G4Circle::filled);
|
||||
G4Colour colour(1.,1.,1.);
|
||||
G4VisAttributes attributes(colour);
|
||||
circle.SetVisAttributes(attributes);
|
||||
VisManager->Draw(circle);
|
||||
}
|
||||
}
|
||||
|
||||
void LEMuSRCryoHit::Print()
|
||||
{}
|
||||
|
||||
void LEMuSRCryoHit::print(G4String name)
|
||||
{
|
||||
ofstream TestPrint(name,ios::app);
|
||||
if (!TestPrint.is_open()) exit(8);
|
||||
TestPrint << "particle name : " << particle_name <<" ;\n "
|
||||
<< "energy_deposition : " << G4BestUnit(energy_deposition,"Energy") <<" ;\n "
|
||||
<< "time_of_flight : " << G4BestUnit(time_of_flight,"Time") <<" ;\n "
|
||||
<< "position : " << position <<" ;\n "
|
||||
<< "momentum : " << momentum <<" ;\n "
|
||||
<<G4endl;
|
||||
|
||||
}
|
205
geant4/LEMuSR/src/LEMuSRCryoSD.cc
Normal file
205
geant4/LEMuSR/src/LEMuSRCryoSD.cc
Normal file
@ -0,0 +1,205 @@
|
||||
#include "LEMuSRCryoSD.hh"
|
||||
#include "LEMuSRDetectorConstruction.hh"
|
||||
#include "G4HCofThisEvent.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4VProcess.hh"
|
||||
|
||||
// ROOT
|
||||
#include "TROOT.h"
|
||||
#include "TApplication.h"
|
||||
#include "TSystem.h"
|
||||
#include "TH1.h"
|
||||
#include "TPad.h"
|
||||
#include "TCanvas.h"
|
||||
|
||||
|
||||
LEMuSRCryoSD::LEMuSRCryoSD(G4String name)
|
||||
:G4VSensitiveDetector(name)
|
||||
{
|
||||
|
||||
G4String HCname;
|
||||
collectionName.insert(HCname="CryoCollection");
|
||||
positionResolution = 1*mm;
|
||||
|
||||
|
||||
// ROOT
|
||||
BookRoot();
|
||||
}
|
||||
|
||||
LEMuSRCryoSD::~LEMuSRCryoSD()
|
||||
{
|
||||
// ROOT
|
||||
WriteRoot();
|
||||
}
|
||||
|
||||
void LEMuSRCryoSD::Initialize(G4HCofThisEvent* HCE)
|
||||
{
|
||||
static int HCID = -1;
|
||||
CryoCollection = new LEMuSRCryoHitsCollection
|
||||
(SensitiveDetectorName,collectionName[0]);
|
||||
if(HCID<0)
|
||||
{ HCID = GetCollectionID(0); }
|
||||
HCE->AddHitsCollection(HCID,CryoCollection);
|
||||
}
|
||||
|
||||
G4bool LEMuSRCryoSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
|
||||
{
|
||||
// G4cout << "PROCESS HIT"<<G4endl;
|
||||
mu=0;e=0;g=0;
|
||||
|
||||
LEMuSRCryoHit* aHit;
|
||||
p_name = aStep->GetTrack()->GetDefinition()->GetParticleName(); // particle name
|
||||
if(p_name=="mu+")mu=1;
|
||||
if(p_name=="Mu")e=1;
|
||||
// G4cout<<"mu+ "<< mu <<" mu "<<e;
|
||||
|
||||
|
||||
if( CheckCondition(aStep))
|
||||
{
|
||||
GetDatas(aStep);
|
||||
getHit();
|
||||
FillRoot();
|
||||
}
|
||||
|
||||
|
||||
// Define Hit
|
||||
aHit = new LEMuSRCryoHit();
|
||||
|
||||
//++++++++++++++ set hit values _______________
|
||||
aHit->SetParticleName(p_name);
|
||||
aHit->SetSpin(spin);
|
||||
|
||||
aHit->SetMomentum( hitmom );
|
||||
aHit->SetPosition( hitpos );
|
||||
|
||||
aHit->SetTimeOfFlight( tof);
|
||||
aHit->SetEnergyDeposition( edep );
|
||||
|
||||
|
||||
CryoCollection->insert( aHit );
|
||||
// aHit->Print();
|
||||
// aHit->print("Statistics/SCIS.Hits");
|
||||
aHit->Draw();
|
||||
|
||||
|
||||
PrintAll();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void LEMuSRCryoSD::EndOfEvent(G4HCofThisEvent*)
|
||||
{
|
||||
// G4int NbHits = CryoCollection->entries();
|
||||
// G4cout << "\n-------->Hits Collection: in this event they are " << NbHits
|
||||
// << " hits in the cryo: " << G4endl;
|
||||
// for (G4int i=0;i<NbHits;i++) (*CryoCollection)[i]->Print();
|
||||
|
||||
}
|
||||
|
||||
G4bool LEMuSRCryoSD::CheckCondition(const G4Step* aStep)
|
||||
{
|
||||
G4bool condition=false;
|
||||
if(p_name == "mu+"||p_name == "Mu")
|
||||
{
|
||||
if(aStep->GetTrack()->GetNextVolume()->GetLogicalVolume()->GetName()=="lv_SAH2"||aStep->GetTrack()->GetNextVolume()->GetLogicalVolume()->GetName()=="lv_SAH3"||aStep->GetTrack()->GetNextVolume()->GetLogicalVolume()->GetName()=="lv_SAH1"||aStep->GetTrack()->GetNextVolume()->GetLogicalVolume()->GetName()=="lv_CRSH2"||aStep->GetTrack()->GetNextVolume()->GetLogicalVolume()->GetName()=="lv_CRSH"||aStep->GetTrack()->GetNextVolume()->GetLogicalVolume()->GetName()=="lv_SAPH")
|
||||
{
|
||||
condition=true;
|
||||
}
|
||||
}
|
||||
return condition;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LEMuSRCryoSD::clear()
|
||||
{
|
||||
delete CryoCollection;
|
||||
}
|
||||
|
||||
void LEMuSRCryoSD::DrawAll()
|
||||
{
|
||||
}
|
||||
|
||||
void LEMuSRCryoSD::PrintAll()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LEMuSRCryoSD::GetDatas(const G4Step *aStep)
|
||||
{
|
||||
// Get datas
|
||||
//a Volume, name, spin
|
||||
vname = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName();
|
||||
spin= aStep->GetTrack()->GetDefinition()->GetPDGSpin(); // spin in units of 1
|
||||
|
||||
//b Position momentum
|
||||
hitpos = aStep->GetPreStepPoint()->GetPosition(); // position
|
||||
hitmom = aStep->GetPreStepPoint()->GetMomentum(); // momentum
|
||||
|
||||
//c Times
|
||||
tof = aStep->GetPreStepPoint()->GetLocalTime(); // time since track creation
|
||||
globaltime = aStep->GetPreStepPoint()->GetGlobalTime();// time since event creation
|
||||
proptime = aStep->GetPreStepPoint()->GetProperTime(); // particle's proper time
|
||||
|
||||
//d Energy
|
||||
edep = aStep->GetTotalEnergyDeposit();
|
||||
|
||||
toten = aStep->GetTrack()->GetTotalEnergy();
|
||||
|
||||
kinen = aStep->GetTrack()->GetKineticEnergy();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LEMuSRCryoSD::getHit()
|
||||
{
|
||||
theHit.kenergy = kinen/keV;
|
||||
theHit.tenergy = toten/keV;
|
||||
theHit.edeposit = edep/keV;
|
||||
theHit.localtime = tof/ns;
|
||||
theHit.globaltime = globaltime/ns;
|
||||
theHit.proptime = proptime/ns;
|
||||
theHit.positionx = hitpos.x()/mm;
|
||||
theHit.positiony = hitpos.y()/mm;
|
||||
theHit.positionz = hitpos.z()/mm;
|
||||
theHit.momdirx = hitmom.x();
|
||||
theHit.momdiry = hitmom.y();
|
||||
theHit.momdirz = hitmom.z();
|
||||
theHit.foil = LEMuSRDetectorConstruction::GetInstance()->cfthk;
|
||||
theHit.muon = mu;
|
||||
theHit.positron = e;
|
||||
theHit.gamma = g;
|
||||
theHit.runid = G4RunManager::GetRunManager()->GetCurrentRun()->GetRunID();
|
||||
}
|
||||
|
||||
// ROOT METHODS
|
||||
|
||||
void LEMuSRCryoSD::BookRoot()
|
||||
{
|
||||
// open root file
|
||||
myFile = new TFile("SDCryoE0.root", "RECREATE");
|
||||
// myFile->SetCompressionLevel(1);
|
||||
|
||||
tree = new TTree ("tree"," Cryo Datas");
|
||||
|
||||
tree->Branch("cryoHit",&theHit.kenergy,"kenergy/F:tenergy/F:edeposit/F:localtime/F:globaltime:propertime/F:positionx/F:positiony:positionz:momdirx:momdiry:momdirz/F:foil/F:muon/I:muonium/I:gamma/I:runID/I");
|
||||
|
||||
}
|
||||
|
||||
void LEMuSRCryoSD::FillRoot()
|
||||
{
|
||||
tree->Fill();
|
||||
}
|
||||
|
||||
void LEMuSRCryoSD::WriteRoot()
|
||||
{
|
||||
myFile->Write();
|
||||
myFile->Close();
|
||||
}
|
||||
|
196
geant4/LEMuSR/src/LEMuSRDecay.cc
Normal file
196
geant4/LEMuSR/src/LEMuSRDecay.cc
Normal file
@ -0,0 +1,196 @@
|
||||
#include"LEMuSRDecay.hh"
|
||||
|
||||
#include "G4DynamicParticle.hh"
|
||||
#include "G4DecayProducts.hh"
|
||||
#include "G4DecayTable.hh"
|
||||
#include "G4PhysicsLogVector.hh"
|
||||
#include "G4ParticleChangeForDecay.hh"
|
||||
#include "G4VExtDecayer.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "LEMuSRMuonDecayChannel.hh"
|
||||
|
||||
G4VParticleChange* LEMuSRDecay::DecayIt(const G4Track& aTrack, const G4Step& aStep)
|
||||
{
|
||||
|
||||
|
||||
// G4cerr<<"METHOD CALLED WHEN SHOULD NOT BE AT ALL!!!!\n";//enable for geant code
|
||||
// The DecayIt() method returns by pointer a particle-change object.
|
||||
// Units are expressed in GEANT4 internal units.
|
||||
// get particle
|
||||
const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
|
||||
G4ParticleDefinition* aParticleDef = aParticle->GetDefinition();
|
||||
|
||||
|
||||
// if particle is not a muon
|
||||
if(aParticle->GetDefinition()->GetParticleName()!="mu+"&&aParticle->GetDefinition()->GetParticleName()!="Mu")
|
||||
{
|
||||
G4ParticleChangeForDecay* k;
|
||||
k = (G4ParticleChangeForDecay*)G4Decay::DecayIt(aTrack,aStep);
|
||||
return k ;
|
||||
}
|
||||
// m_ExtDecayer = 0;//G4Decay::GetExtDecayer();
|
||||
m_RemainderLifeTime = G4Decay::GetRemainderLifeTime();
|
||||
|
||||
// check if the particle is stable
|
||||
if (aParticleDef->GetPDGStable()) return &pParticleChangeForDecay ;
|
||||
|
||||
|
||||
//check if thePreAssignedDecayProducts exists
|
||||
const G4DecayProducts* o_products = (aParticle->GetPreAssignedDecayProducts());
|
||||
G4bool isPreAssigned = (o_products != 0);
|
||||
G4DecayProducts* products = 0;
|
||||
|
||||
// decay table
|
||||
G4DecayTable *decaytable = aParticleDef->GetDecayTable();
|
||||
|
||||
// check if external decayer exists
|
||||
G4bool isExtDecayer = (decaytable == 0);
|
||||
|
||||
// Error due to NO Decay Table
|
||||
if ( (decaytable == 0) && !isExtDecayer &&!isPreAssigned ){
|
||||
#ifdef G4VERBOSE
|
||||
if (GetVerboseLevel()>0) {
|
||||
G4cerr << "LEMuSRDecay::DoIt : decay table not defined for ";
|
||||
G4cerr << aParticle->GetDefinition()->GetParticleName()<< G4endl;
|
||||
}
|
||||
#endif
|
||||
pParticleChangeForDecay.SetNumberOfSecondaries(0);
|
||||
// Kill the parent particle
|
||||
pParticleChangeForDecay.ProposeTrackStatus( fStopAndKill ) ;
|
||||
pParticleChangeForDecay.ProposeLocalEnergyDeposit(0.0);
|
||||
|
||||
ClearNumberOfInteractionLengthLeft();
|
||||
return &pParticleChangeForDecay ;
|
||||
}
|
||||
|
||||
if (isPreAssigned) {
|
||||
// copy decay products
|
||||
products = new G4DecayProducts(*o_products);
|
||||
} else {
|
||||
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++ACCORDING TO DECAY TABLE++++++++++++++++++++++++++
|
||||
// decay acoording to decay table
|
||||
// choose a decay channel
|
||||
G4VDecayChannel *decaychannel = decaytable->SelectADecayChannel();
|
||||
if (decaychannel == 0 ){
|
||||
// decay channel not found
|
||||
G4Exception("G4Decay::DoIt : can not determine decay channel ");
|
||||
} else {
|
||||
G4int temp = decaychannel->GetVerboseLevel();
|
||||
// execute DecayIt()
|
||||
#ifdef G4VERBOSE
|
||||
if (GetVerboseLevel()>1) {
|
||||
G4cerr << "LEMuSRDecay::DoIt : selected decay channel addr:" << decaychannel <<G4endl;
|
||||
decaychannel->SetVerboseLevel(GetVerboseLevel());
|
||||
}
|
||||
#endif
|
||||
|
||||
// CHECK FOR POLARIASATION AND ASSIGN IT TO THE DECAY METHOD
|
||||
|
||||
G4ThreeVector parent_polarization = aParticle->GetPolarization();
|
||||
|
||||
//-----------------------------INFORMATION---------------------------------
|
||||
// G4cout <<"LEMuSRDecay MESSAGE:: polarization is " << parent_polarization <<" .\n";
|
||||
if(aParticle->GetDefinition()->GetParticleName()=="mu+"||aParticle->GetDefinition()->GetParticleName()=="Mu")
|
||||
{
|
||||
decaychannel->SetParentPolarization(parent_polarization);
|
||||
if(decaychannel->GetKinematicsName()=="LEMuSR Muon Decay")
|
||||
{
|
||||
products = decaychannel->DecayIt(aParticle->GetMass());//decaychannel->DecayItPolarized(aParticle->GetMass(),parent_polarization);// has to be included in G4VDecayChannel.
|
||||
testa++;
|
||||
}
|
||||
|
||||
else if(decaychannel->GetKinematicsName()=="Muon Decay")
|
||||
{
|
||||
products = decaychannel->DecayIt(aParticle->GetMass());
|
||||
testb++;
|
||||
}
|
||||
#ifdef G4VERBOSE
|
||||
if (GetVerboseLevel()>1) {
|
||||
G4cout<<"Decay Channela "<<testa<<" Decay Channelb "<<testb<<G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
else products = decaychannel->DecayIt(aParticle->GetMass()) ;
|
||||
|
||||
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if (GetVerboseLevel()>1) {
|
||||
decaychannel->SetVerboseLevel(temp);
|
||||
}
|
||||
#endif
|
||||
#ifdef G4VERBOSE
|
||||
// for debug
|
||||
//if (! products->IsChecked() ) products->DumpInfo();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// get parent particle information ...................................
|
||||
G4double ParentEnergy = aParticle->GetTotalEnergy();
|
||||
G4ThreeVector ParentDirection(aParticle->GetMomentumDirection());
|
||||
|
||||
//boost all decay products to laboratory frame
|
||||
G4double energyDeposit = 0.0;
|
||||
G4double finalGlobalTime = aTrack.GetGlobalTime();
|
||||
if (aTrack.GetTrackStatus() == fStopButAlive ){
|
||||
// AtRest case
|
||||
finalGlobalTime += m_RemainderLifeTime;
|
||||
energyDeposit += aParticle->GetKineticEnergy();
|
||||
if (isPreAssigned) products->Boost( ParentEnergy, ParentDirection);
|
||||
} else {
|
||||
// PostStep case
|
||||
if (!isExtDecayer) products->Boost( ParentEnergy, ParentDirection);
|
||||
}
|
||||
//add products in pParticleChangeForDecay
|
||||
G4int numberOfSecondaries = products->entries();
|
||||
|
||||
pParticleChangeForDecay.SetNumberOfSecondaries(numberOfSecondaries);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if (GetVerboseLevel()>1) {
|
||||
G4cerr << "LEMuSRDecay::DoIt : Decay vertex :";
|
||||
G4cerr << " Time: " << finalGlobalTime/ns << "[ns]";
|
||||
G4cerr << " X:" << (aTrack.GetPosition()).x() /cm << "[cm]";
|
||||
G4cerr << " Y:" << (aTrack.GetPosition()).y() /cm << "[cm]";
|
||||
G4cerr << " Z:" << (aTrack.GetPosition()).z() /cm << "[cm]";
|
||||
G4cerr << G4endl;
|
||||
G4cerr << "G4Decay::DoIt : decay products in Lab. Frame" << G4endl;
|
||||
products->DumpInfo();
|
||||
}
|
||||
#endif
|
||||
G4int index;
|
||||
G4ThreeVector currentPosition;
|
||||
const G4TouchableHandle thand = aTrack.GetTouchableHandle();
|
||||
|
||||
for (index=0; index < numberOfSecondaries; index++)
|
||||
{
|
||||
// get current position of the track
|
||||
currentPosition = aTrack.GetPosition();
|
||||
// create a new track object
|
||||
G4Track* secondary = new G4Track( products->PopProducts(),
|
||||
finalGlobalTime ,
|
||||
currentPosition );
|
||||
// switch on good for tracking flag
|
||||
secondary->SetGoodForTrackingFlag();
|
||||
secondary->SetTouchableHandle(thand);
|
||||
// add the secondary track in the List
|
||||
pParticleChangeForDecay.AddSecondary(secondary);
|
||||
}
|
||||
delete products;
|
||||
|
||||
// Kill the parent particle
|
||||
pParticleChangeForDecay.ProposeTrackStatus( fStopAndKill ) ;
|
||||
|
||||
pParticleChangeForDecay.ProposeLocalEnergyDeposit(energyDeposit);
|
||||
pParticleChangeForDecay.ProposeGlobalTime( finalGlobalTime );
|
||||
// reset NumberOfInteractionLengthLeft
|
||||
ClearNumberOfInteractionLengthLeft();
|
||||
|
||||
return &pParticleChangeForDecay ;
|
||||
|
||||
}
|
175
geant4/LEMuSR/src/LEMuSRDepolarize.cc
Normal file
175
geant4/LEMuSR/src/LEMuSRDepolarize.cc
Normal file
@ -0,0 +1,175 @@
|
||||
|
||||
#include "LEMuSRDepolarize.hh"
|
||||
#include "G4StepStatus.hh"
|
||||
#include "G4Navigator.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4ProductionCutsTable.hh"
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
using namespace std;
|
||||
|
||||
LEMuSRDepolarize:: LEMuSRDepolarize(const G4String& name ,
|
||||
G4ProcessType aType )
|
||||
: G4VDiscreteProcess(name, aType)
|
||||
{}
|
||||
|
||||
|
||||
LEMuSRDepolarize:: ~LEMuSRDepolarize()
|
||||
{}
|
||||
|
||||
|
||||
G4VParticleChange* LEMuSRDepolarize::AtRestDoIt(
|
||||
const G4Track& trackData,
|
||||
const G4Step& aStep )
|
||||
{
|
||||
// Initialize ParticleChange (by setting all its members equal
|
||||
// to corresponding members in G4Track)
|
||||
fParticleChange.Initialize(trackData);
|
||||
|
||||
// tao :: Get Time
|
||||
itime = trackData.GetProperTime();
|
||||
gtime = trackData.GetGlobalTime();
|
||||
ftime = trackData.GetDynamicParticle()->GetPreAssignedDecayProperTime();
|
||||
|
||||
deltatime = ftime - itime;
|
||||
fParticleChange.ProposeGlobalTime(deltatime + itime -gtime);
|
||||
|
||||
// set position momentum energy
|
||||
fParticleChange.ProposePosition(trackData.GetPosition());
|
||||
fParticleChange.ProposeMomentumDirection(trackData.GetMomentumDirection());
|
||||
fParticleChange.ProposeEnergy(trackData.GetKineticEnergy());
|
||||
fParticleChange.ProposeGlobalTime(gtime);
|
||||
fParticleChange.ProposeProperTime(itime);
|
||||
fParticleChange.ProposeTrackStatus(trackData.GetTrackStatus()) ;
|
||||
|
||||
if( CheckCondition(aStep))
|
||||
{
|
||||
G4double costheta, sintheta, cosphi, sinphi, theta, phi;
|
||||
|
||||
phi = 2.0*M_PI*G4UniformRand()*rad;
|
||||
sinphi = sin(phi);
|
||||
cosphi = cos(phi);
|
||||
|
||||
theta = M_PI*G4UniformRand()*rad;
|
||||
sintheta = sin(theta);
|
||||
costheta = cos(theta);
|
||||
|
||||
// rotation angles
|
||||
G4double px = sintheta*sinphi;
|
||||
G4double py = sintheta*cosphi;
|
||||
G4double pz = costheta;
|
||||
|
||||
G4ThreeVector direction0(px,py,pz);
|
||||
|
||||
fParticleChange.ProposePolarization(px,py,pz);
|
||||
// G4cout<<"DEPOLARIZE at rest"<<G4endl;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
fParticleChange.ProposePolarization(trackData.GetPolarization());
|
||||
}
|
||||
// fParticleChange.DumpInfo();
|
||||
return &fParticleChange;
|
||||
}
|
||||
|
||||
|
||||
G4VParticleChange* LEMuSRDepolarize::PostStepDoIt(
|
||||
const G4Track& trackData,
|
||||
const G4Step& aStep )
|
||||
{
|
||||
// Initialize ParticleChange (by setting all its members equal
|
||||
// to corresponding members in G4Track)
|
||||
fParticleChange.Initialize(trackData);
|
||||
|
||||
// tao :: Get Time
|
||||
itime = trackData.GetProperTime();
|
||||
gtime = trackData.GetGlobalTime();
|
||||
ftime = trackData.GetDynamicParticle()->GetPreAssignedDecayProperTime();
|
||||
|
||||
deltatime = ftime - itime;
|
||||
fParticleChange.ProposeGlobalTime(deltatime + itime -gtime);
|
||||
|
||||
// set position momentum energy
|
||||
fParticleChange.ProposePosition(trackData.GetPosition());
|
||||
fParticleChange.ProposeMomentumDirection(trackData.GetMomentumDirection());
|
||||
fParticleChange.ProposeEnergy(trackData.GetKineticEnergy());
|
||||
fParticleChange.ProposeGlobalTime(gtime);
|
||||
fParticleChange.ProposeProperTime(itime);
|
||||
fParticleChange.ProposeTrackStatus(trackData.GetTrackStatus()) ;
|
||||
|
||||
if( CheckCondition(aStep))
|
||||
{
|
||||
G4double costheta, sintheta, cosphi, sinphi, theta, phi;
|
||||
|
||||
phi = 2.0*M_PI*G4UniformRand()*rad;
|
||||
sinphi = sin(phi);
|
||||
cosphi = cos(phi);
|
||||
|
||||
theta = M_PI*G4UniformRand()*rad;
|
||||
sintheta = sin(theta);
|
||||
costheta = cos(theta);
|
||||
|
||||
// rotation angles
|
||||
G4double px = sintheta*sinphi;
|
||||
G4double py = sintheta*cosphi;
|
||||
G4double pz = costheta;
|
||||
|
||||
G4ThreeVector direction0(px,py,pz);
|
||||
fParticleChange.ProposePolarization(px,py,pz);
|
||||
// G4cout<<"DEPOLARIZE post step"<<G4endl;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
fParticleChange.ProposePolarization(trackData.GetPolarization());
|
||||
}
|
||||
// fParticleChange.DumpInfo();
|
||||
return &fParticleChange;
|
||||
|
||||
}
|
||||
|
||||
|
||||
G4bool LEMuSRDepolarize::CheckCondition( const G4Step& aStep)
|
||||
{
|
||||
G4bool condition=false;
|
||||
p_name = aStep.GetTrack()->GetDefinition()->GetParticleName(); // particle name
|
||||
if((p_name == "mu+"||p_name=="Mu"))
|
||||
{
|
||||
if(aStep.GetTrack()->GetVolume()->GetLogicalVolume()->GetName()=="lv_SAH1"
|
||||
||aStep.GetTrack()->GetVolume()->GetLogicalVolume()->GetName()=="lv_SAH2"
|
||||
||aStep.GetTrack()->GetVolume()->GetLogicalVolume()->GetName()=="lv_SAH3"
|
||||
||aStep.GetTrack()->GetVolume()->GetLogicalVolume()->GetName()=="lv_SAPH")
|
||||
{
|
||||
condition=true;// ACTIVATE PROCESS IN VOLUME ONLY:: LOOK IN G4 DOCUMENTATION
|
||||
}
|
||||
}
|
||||
return condition;
|
||||
|
||||
}
|
||||
|
||||
|
||||
G4double LEMuSRDepolarize:: GetMeanFreePath(const G4Track& ,
|
||||
G4double ,
|
||||
G4ForceCondition* condition
|
||||
)
|
||||
{
|
||||
|
||||
*condition = Forced;
|
||||
return DBL_MAX;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void LEMuSRDepolarize::GetDatas( const G4Step* )
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
|
||||
void LEMuSRDepolarize::PrepareSecondary(const G4Track& track)
|
||||
{
|
||||
aSecondary = new G4Track(DP,track.GetGlobalTime(),track.GetPosition());
|
||||
}
|
1383
geant4/LEMuSR/src/LEMuSRDetectorConstruction.cc
Normal file
1383
geant4/LEMuSR/src/LEMuSRDetectorConstruction.cc
Normal file
File diff suppressed because it is too large
Load Diff
448
geant4/LEMuSR/src/LEMuSRDetectorMessenger.cc
Normal file
448
geant4/LEMuSR/src/LEMuSRDetectorMessenger.cc
Normal file
@ -0,0 +1,448 @@
|
||||
///§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID : LEMuSRDetectorMessenger.cc , v 1.2
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-08-20 10:20
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// DETECTOR MESSENGER
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
#include "LEMuSRDetectorMessenger.hh"
|
||||
#include "LEMuSRDetectorConstruction.hh"
|
||||
|
||||
|
||||
|
||||
//
|
||||
// process remove
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleChange.hh"
|
||||
#include "G4ProcessVector.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4VProcess.hh"
|
||||
|
||||
|
||||
|
||||
LEMuSRDetectorMessenger::LEMuSRDetectorMessenger(LEMuSRDetectorConstruction *lemuDetector)
|
||||
{
|
||||
theDetector=lemuDetector;
|
||||
DetMode = new G4UIdirectory("/Detector/");
|
||||
DetMode->SetGuidance("Set detector parameters");
|
||||
|
||||
// commands
|
||||
SetDetMode = new G4UIcmdWithAString("/Detector/Mode",this);
|
||||
SetDetMode->SetGuidance("\n mcp: multiple channel mode \n cryo: cryostat mode ");
|
||||
SetDetMode->SetParameterName("mode",false);
|
||||
SetDetMode->SetDefaultValue("mcp");
|
||||
SetDetMode->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
|
||||
// commands
|
||||
|
||||
// El field on/off
|
||||
SetElField = new G4UIcmdWithAString("/Detector/ElectricField",this);
|
||||
SetElField->SetGuidance("\n on: electric field on \n off: electric field off ");
|
||||
SetElField->SetParameterName("field",false);
|
||||
SetElField->SetDefaultValue("on");
|
||||
SetElField->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
|
||||
// Grid on/off
|
||||
SetGrid = new G4UIcmdWithAString("/Detector/Sample/Grid",this);
|
||||
SetGrid->SetGuidance("\n on: Sample Grid on \n off: Sample Grid off ");
|
||||
SetGrid->SetParameterName("grid",false);
|
||||
SetGrid->SetDefaultValue("on");
|
||||
SetGrid->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
|
||||
// Guards on/off
|
||||
SetGuards = new G4UIcmdWithAString("/Detector/Sample/Guards",this);
|
||||
SetGuards->SetGuidance("\n on: Sample Guards Rings on \n off: Sample Guards off ");
|
||||
SetGuards->SetParameterName("guards",false);
|
||||
SetGuards->SetDefaultValue("on");
|
||||
SetGuards->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
|
||||
// ASYM
|
||||
SetAsymCheck = new G4UIcmdWithAString("/Detector/AsymCheck",this);
|
||||
SetAsymCheck->SetGuidance("\n on: asym on \n off:asym off ");
|
||||
SetAsymCheck->SetParameterName("asym",false);
|
||||
SetAsymCheck->SetDefaultValue("on");
|
||||
SetAsymCheck->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
|
||||
// SAH MATERIAL
|
||||
SetSAHmaterial = new G4UIcmdWithAString("/Detector/Sample/Material",this);
|
||||
SetSAHmaterial->SetGuidance("\n Sample material");
|
||||
SetSAHmaterial->SetParameterName("material",false);
|
||||
SetSAHmaterial->SetDefaultValue("copper");
|
||||
SetSAHmaterial->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
|
||||
|
||||
// ELECTRIC POTENTIALS
|
||||
SetThirdLensPotential = new G4UIcmdWithADouble("/Detector/Voltage/ThirdLense",this);
|
||||
SetThirdLensPotential->SetGuidance("\n Third Lense Middle Cylinder Voltage Value >> IN KILOVOLT ");
|
||||
SetThirdLensPotential->SetParameterName("f",false);
|
||||
SetThirdLensPotential->SetDefaultValue(1);
|
||||
SetThirdLensPotential->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
SetMagField = new G4UIcmdWithADouble("/Detector/MagneticField",this);
|
||||
SetMagField->SetGuidance("\n Magnetic Field Max Value >>> in GAUSS ");
|
||||
SetMagField->SetParameterName("f",false);
|
||||
SetMagField->SetDefaultValue(100);
|
||||
SetMagField->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
|
||||
|
||||
|
||||
SetRAPotential = new G4UIcmdWith3Vector("/Detector/Voltage/ConicalAnode",this);
|
||||
SetRAPotential->SetGuidance("\n Conical anode left and right side Voltage Values >> IN KILOVOLT; set build to !=0 to build the detector ");
|
||||
SetRAPotential->SetParameterName("RA-Left Voltage [kV]","RA-Right Voltage [kV]","Build",false,true);
|
||||
SetRAPotential->SetDefaultValue(Hep3Vector(8.1,8.1,1.0));
|
||||
SetRAPotential->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
SetCryoPotential = new G4UIcmdWithADouble("/Detector/Voltage/Cryo",this);
|
||||
SetCryoPotential->SetGuidance("\n Cryo voltage in kV ");
|
||||
SetCryoPotential->SetParameterName("Voltage [kV]",true,true);
|
||||
SetCryoPotential->SetDefaultValue(7.2);
|
||||
SetCryoPotential->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
|
||||
|
||||
SetDetVisualization = new G4UIcmdWithAString("/Detector/View",this);
|
||||
SetDetVisualization->SetGuidance("\n quarter: quarter cut view of the detector \n half: half cut view of the detector \n total: view of the total detector ");
|
||||
SetDetVisualization->SetParameterName("view",false);
|
||||
SetDetVisualization->SetDefaultValue("total");
|
||||
SetDetVisualization->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
SetFieldStepLim = new G4UIcmdWithADouble("/Detector/MaxStepInField",this);
|
||||
SetFieldStepLim->SetGuidance("\n The user step limitation in third lense and conical anode [mm] ");
|
||||
SetFieldStepLim->SetParameterName("usl",false);
|
||||
SetFieldStepLim->SetDefaultValue(10.);
|
||||
SetFieldStepLim->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
|
||||
// Carbon Foil
|
||||
SetCFthk = new G4UIcmdWithADouble("/Detector/CfoilThickness",this);
|
||||
SetCFthk->SetGuidance("\n Carbon foil thickness; unit is mug/cm2 ");
|
||||
SetCFthk->SetParameterName("f",false);
|
||||
SetCFthk->SetDefaultValue(1.0);
|
||||
SetCFthk->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
|
||||
}
|
||||
|
||||
LEMuSRDetectorMessenger::~LEMuSRDetectorMessenger()
|
||||
{
|
||||
delete theDetector;
|
||||
delete DetMode;
|
||||
delete SetMagField;
|
||||
delete SetThirdLensPotential;
|
||||
delete SetCFthk;
|
||||
delete SetCryoPotential;
|
||||
delete SetRAPotential;
|
||||
delete SetElField;
|
||||
delete SetGrid;
|
||||
delete SetGuards;
|
||||
delete SetFieldCheck;
|
||||
delete SetAsymCheck;
|
||||
delete SetDetMode;
|
||||
delete SetDetVisualization;
|
||||
delete SetFieldStepLim;
|
||||
delete SetSAHmaterial;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LEMuSRDetectorMessenger::SetNewValue(G4UIcommand* command, G4String newvalue)//MUST have the name SetNewValue:: inherited method from messenger class.
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
|
||||
|
||||
if(command == SetDetMode)
|
||||
{
|
||||
if(newvalue=="mcp")
|
||||
{
|
||||
theDetector->mcdetector=1;
|
||||
}
|
||||
else if(newvalue=="cryo")
|
||||
{
|
||||
theDetector->mcdetector=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout << "Unknown command: please check value."<<G4endl;
|
||||
}
|
||||
|
||||
G4cout << "About to build new detector."<<G4endl;
|
||||
newDetector = theDetector->Construct();
|
||||
G4cout << "New detector built."<<G4endl;
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(newDetector);
|
||||
|
||||
G4cout << " runmanager updated\n" ;
|
||||
|
||||
// Actualisation du visualiseur
|
||||
//UI ->ApplyCommand("/vis/viewer/refresh") ;
|
||||
//UI ->ApplyCommand("/vis/viewer/update");
|
||||
|
||||
}
|
||||
|
||||
|
||||
else if(command == SetThirdLensPotential)
|
||||
{
|
||||
if(SetThirdLensPotential->GetNewDoubleValue(newvalue)!=0.)
|
||||
{
|
||||
theDetector->elfield=1;
|
||||
theDetector->L3FieldVal=SetThirdLensPotential->GetNewDoubleValue(newvalue);
|
||||
}
|
||||
|
||||
else if(SetThirdLensPotential->GetNewDoubleValue(newvalue)==0.)
|
||||
{
|
||||
theDetector->elfield=0;
|
||||
|
||||
}
|
||||
newDetector = theDetector->Construct();
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(newDetector);
|
||||
|
||||
}
|
||||
|
||||
else if(command == SetMagField)
|
||||
{
|
||||
if(SetMagField->GetNewDoubleValue(newvalue)!=0.)
|
||||
{
|
||||
theDetector->magfield=1;
|
||||
theDetector->B=SetMagField->GetNewDoubleValue(newvalue);
|
||||
}
|
||||
else if(SetMagField->GetNewDoubleValue(newvalue)==0.)
|
||||
{
|
||||
theDetector->magfield=0;
|
||||
}
|
||||
newDetector = theDetector->Construct();
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(newDetector);
|
||||
}
|
||||
|
||||
|
||||
|
||||
else if(command == SetSAHmaterial)
|
||||
{
|
||||
if(G4Material::GetMaterial(newvalue))
|
||||
{
|
||||
theDetector->Material_SAH=newvalue;
|
||||
newDetector = theDetector->Construct();
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(newDetector);
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout<<":-? Material "<<newvalue<<" not found!!!"<<G4endl;
|
||||
G4cout<<"Sample holder material is still "
|
||||
<<theDetector->Material_SAH<<"."<<G4endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
else if(command == SetCFthk)
|
||||
{
|
||||
theDetector->cfthk=SetCFthk->GetNewDoubleValue(newvalue);
|
||||
newDetector = theDetector->Construct();
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(newDetector);
|
||||
G4cout<<"Thickness: " << LEMuSRDetectorConstruction::GetInstance()->cfthk<<G4endl;
|
||||
}
|
||||
|
||||
else if(command == SetRAPotential)
|
||||
{
|
||||
G4double ral, rar, build;
|
||||
ral = SetRAPotential->GetNew3VectorValue(newvalue).x();
|
||||
rar = SetRAPotential->GetNew3VectorValue(newvalue).y();
|
||||
build = SetRAPotential->GetNew3VectorValue(newvalue).z();
|
||||
|
||||
theDetector->RALval=ral;
|
||||
theDetector->RARval=rar;
|
||||
G4cout<<"Conical anode Voltage:\n RA-L: "<< ral <<"[kV] RA-R: "<<rar <<" [kV]"<<G4endl;
|
||||
theDetector->anode_elfield=1;
|
||||
if(build!=0.0)
|
||||
{
|
||||
newDetector = theDetector->Construct();
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(newDetector);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
G4cout<<"\n ~~~~~~~~~~~~~ATTENTION:: DETECTOR NOT BUILT~~~~~~~~~~~~"<<G4endl;
|
||||
}
|
||||
|
||||
}
|
||||
else if(command == SetCryoPotential)
|
||||
{
|
||||
G4double V;
|
||||
V = SetCryoPotential->GetNewDoubleValue(newvalue);
|
||||
|
||||
theDetector->cryoVoltage=V;
|
||||
G4cout<<"Cryo Voltage:\n V: "<< V <<"[kV]"<<G4endl;
|
||||
theDetector->anode_elfield=1;
|
||||
newDetector = theDetector->Construct();
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(newDetector);
|
||||
}
|
||||
|
||||
|
||||
|
||||
else if(command == SetElField)
|
||||
{
|
||||
if(newvalue=="on")
|
||||
{
|
||||
// theDetector->elfield=1;
|
||||
// theDetector->anode_elfield=1;
|
||||
theDetector->trigger_field=1;
|
||||
G4cout<<"THIS COMMAND ONLY ENABLES THE TRIGGER FIELD.\n"
|
||||
<<" TO SET THE ELECTROSTATIC LENSES USE /Detector/Voltage COMMAND."<<G4endl;
|
||||
}
|
||||
else if(newvalue=="off")
|
||||
{
|
||||
theDetector->elfield=0;
|
||||
theDetector->anode_elfield=0;
|
||||
theDetector->trigger_field=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout<<"UNRECOGNIZED COMMAND ENTER on OR off."<<G4endl;
|
||||
}
|
||||
newDetector = theDetector->Construct();
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(newDetector);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// SAMPLE GRID
|
||||
else if(command == SetGrid)
|
||||
{
|
||||
if(newvalue=="on")
|
||||
{
|
||||
theDetector->Grid=1;
|
||||
|
||||
}
|
||||
|
||||
else if(newvalue=="off")
|
||||
{
|
||||
|
||||
theDetector->Grid=0;
|
||||
|
||||
}
|
||||
G4cout<<"SAMPLE CRYOSTAT:: GRID ON ==>> DON'T FORGET TO REBUILD DETECTOR"<<G4endl;
|
||||
}
|
||||
|
||||
|
||||
// SAMPLE GUARDS
|
||||
else if(command == SetGuards)
|
||||
{
|
||||
if(newvalue=="on")
|
||||
{
|
||||
theDetector->Guards=1;
|
||||
|
||||
}
|
||||
|
||||
else if(newvalue=="off")
|
||||
{
|
||||
|
||||
theDetector->Guards=0;
|
||||
|
||||
}
|
||||
G4cout<<"SAMPLE CRYOSTAT:: GUARDS ON ==>> DON'T FORGET TO REBUILD DETECTOR"<<G4endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
else if(command == SetFieldStepLim)
|
||||
{
|
||||
theDetector->FieldStepLim=SetFieldStepLim->GetNewDoubleValue(newvalue)*mm;
|
||||
newDetector = theDetector->Construct();
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(newDetector);
|
||||
}
|
||||
|
||||
|
||||
|
||||
else if(command == SetAsymCheck)
|
||||
{
|
||||
if(newvalue=="on")
|
||||
{
|
||||
theDetector->AsymCheck=1;
|
||||
|
||||
}
|
||||
|
||||
else if(newvalue=="off")
|
||||
{
|
||||
theDetector->AsymCheck=0;
|
||||
|
||||
}
|
||||
newDetector = theDetector->Construct();
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(newDetector);
|
||||
|
||||
}
|
||||
|
||||
|
||||
else if(command == SetDetVisualization)
|
||||
{
|
||||
if(newvalue=="total")
|
||||
{
|
||||
theDetector->dSPhi=0*deg;
|
||||
theDetector->dEPhi=360*deg;
|
||||
theDetector->halfview=0;
|
||||
}
|
||||
else if(newvalue=="half")
|
||||
{
|
||||
theDetector->dSPhi=+90*deg;
|
||||
theDetector->dEPhi=180*deg;
|
||||
theDetector->halfview=1;
|
||||
}
|
||||
else if(newvalue=="quarter")
|
||||
{
|
||||
theDetector->dSPhi=0*deg;
|
||||
theDetector->dEPhi=270*deg;
|
||||
theDetector->halfview=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout << "Unknown command: please check value."<<G4endl;
|
||||
}
|
||||
|
||||
newDetector = theDetector->Construct();
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(newDetector);
|
||||
|
||||
G4cout << " \n !!! BEFORE '/run/beamOn' :: PLEASE ENSURE TOTAL GEOMETRY IS LOADED !!! \n" ;
|
||||
// Update visualization
|
||||
//UI ->ApplyCommand("/vis/viewer/refresh") ;
|
||||
//UI ->ApplyCommand("/vis/viewer/update");
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
G4cout << "Unknown command: please check value."<<G4endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
75
geant4/LEMuSR/src/LEMuSREMPhysics.cc
Normal file
75
geant4/LEMuSR/src/LEMuSREMPhysics.cc
Normal file
@ -0,0 +1,75 @@
|
||||
//
|
||||
|
||||
#include "LEMuSREMPhysics.hh"
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
LEMuSREMPhysics::LEMuSREMPhysics(const G4String& name)
|
||||
: G4VPhysicsConstructor(name)
|
||||
{
|
||||
}
|
||||
|
||||
LEMuSREMPhysics::~LEMuSREMPhysics()
|
||||
{
|
||||
}
|
||||
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
|
||||
#include "G4Gamma.hh"
|
||||
|
||||
#include "G4Electron.hh"
|
||||
#include "G4Positron.hh"
|
||||
|
||||
#include "G4NeutrinoE.hh"
|
||||
#include "G4AntiNeutrinoE.hh"
|
||||
#include "G4UserSpecialCuts.hh"
|
||||
void LEMuSREMPhysics::ConstructParticle()
|
||||
{
|
||||
// gamma
|
||||
G4Gamma::GammaDefinition();
|
||||
|
||||
// electron
|
||||
G4Electron::ElectronDefinition();
|
||||
G4Positron::PositronDefinition();
|
||||
G4NeutrinoE::NeutrinoEDefinition();
|
||||
G4AntiNeutrinoE::AntiNeutrinoEDefinition();
|
||||
}
|
||||
|
||||
|
||||
#include "G4ProcessManager.hh"
|
||||
|
||||
|
||||
void LEMuSREMPhysics::ConstructProcess()
|
||||
{
|
||||
G4ProcessManager * pManager = 0;
|
||||
|
||||
// Gamma Physics
|
||||
pManager = G4Gamma::Gamma()->GetProcessManager();
|
||||
pManager->AddDiscreteProcess(&thePhotoEffect);
|
||||
pManager->AddDiscreteProcess(&theComptonEffect);
|
||||
pManager->AddDiscreteProcess(&thePairProduction);
|
||||
pManager->AddProcess(new G4UserSpecialCuts(),-1,-1,1);
|
||||
// Electron Physics
|
||||
pManager = G4Electron::Electron()->GetProcessManager();
|
||||
|
||||
pManager->AddProcess(&theElectronMultipleScattering, -1, 1, 1);
|
||||
pManager->AddProcess(&theElectronIonisation, -1, 2, 2);
|
||||
pManager->AddProcess(&theElectronBremsStrahlung, -1, 3, 3);
|
||||
pManager->AddProcess(new G4UserSpecialCuts(),-1,-1,4);
|
||||
|
||||
//Positron Physics
|
||||
pManager = G4Positron::Positron()->GetProcessManager();
|
||||
|
||||
pManager->AddProcess(&thePositronMultipleScattering, -1, 1, 1);
|
||||
pManager->AddProcess(&thePositronIonisation, -1, 2, 2);
|
||||
pManager->AddProcess(&thePositronBremsStrahlung, -1, 3, 3);
|
||||
pManager->AddProcess(&theAnnihilation, 0,-1, 4);
|
||||
pManager->AddProcess(new G4UserSpecialCuts(),-1,-1,5);
|
||||
}
|
||||
|
||||
|
||||
|
95
geant4/LEMuSR/src/LEMuSRElFieldMix.cc
Normal file
95
geant4/LEMuSR/src/LEMuSRElFieldMix.cc
Normal file
@ -0,0 +1,95 @@
|
||||
///§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID :LEMuSRElFieldMix.cc , v 1.3
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-09-17 10:20
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// Electric Field
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
#include"LEMuSRElFieldMix.hh"
|
||||
#include"G4UnitsTable.hh"
|
||||
|
||||
|
||||
LEMuSRElFieldMix::LEMuSRElFieldMix( LEMuSRElectricField *E1, LEMuSRElectricField *E2, G4double field1_val, G4double field2_val)
|
||||
{
|
||||
coef1 = field1_val;
|
||||
coef2 = field2_val;
|
||||
field1 = E1;
|
||||
field2 = E2;
|
||||
G4cout<<"FIELDMIX COEFS "<< coef1 <<"AND "<< coef2<<G4endl;
|
||||
}
|
||||
|
||||
LEMuSRElFieldMix::LEMuSRElFieldMix( G4ElectricField *E1, G4ElectricField *E2, G4double field1_val, G4double field2_val)
|
||||
{
|
||||
coef1 = field1_val;
|
||||
coef2 = field2_val;
|
||||
field1 = E1;
|
||||
field2 = E2;
|
||||
G4cout<<"FIELDMIX COEFS "<< coef1 <<"AND "<< coef2<<G4endl;
|
||||
}
|
||||
|
||||
|
||||
LEMuSRElFieldMix::~LEMuSRElFieldMix()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LEMuSRElFieldMix::GetFieldValue(const G4double point[4], G4double *Bfield ) const
|
||||
{
|
||||
G4double Bfield1[3], Bfield2[3];
|
||||
|
||||
/* Bfield1[0] = 0;
|
||||
Bfield1[1] = 0;
|
||||
Bfield1[2] = 0;
|
||||
|
||||
Bfield2[0] = 0;
|
||||
Bfield2[1] = 0;
|
||||
Bfield2[2] = 0;
|
||||
*/
|
||||
|
||||
G4double position[4],position2[4];
|
||||
position[0]=point[0];
|
||||
position[1]=point[1];
|
||||
position[2]=point[2];
|
||||
position[3]=point[3];
|
||||
position2[0]=point[0];
|
||||
position2[1]=point[1];
|
||||
position2[2]=point[2];
|
||||
position2[3]=point[3];
|
||||
/// G4cout<<"Field zb" <<field1->minz <<std::endl;
|
||||
// G4cout<<"Field zb" <<field2->maxz <<std::endl;
|
||||
|
||||
field1->GetFieldValue(position, Bfield1);
|
||||
// G4cout<<"Field 1 Value " << G4BestUnit(Bfield1[0]*coef1*meter,"Electric potential") <<"/m " <<Bfield1[1]*coef1/volt*meter <<" V/m "<< Bfield1[2]*coef1/volt*meter <<" V/m " <<G4endl;
|
||||
|
||||
field2->GetFieldValue(position2, Bfield2);
|
||||
// G4cout<<"Field 2 Value " << G4BestUnit(Bfield2[0]*coef2*meter,"Electric potential") <<"/m " <<Bfield2[1]*coef2/volt*meter <<" V/m "<< Bfield2[2]*coef2/volt*meter <<" V/m " <<G4endl;
|
||||
|
||||
// Bfield1=Bfield1*coef1;
|
||||
// Bfield2=Bfield2*coef2;
|
||||
|
||||
Bfield[0] = Bfield1[0]*coef1+ Bfield2[0]*coef2;
|
||||
Bfield[1] = Bfield1[1]*coef1+ Bfield2[1]*coef2;
|
||||
Bfield[2] = Bfield1[2]*coef1+ Bfield2[2]*coef2;
|
||||
|
||||
// G4cout<<"Field M Value " << G4BestUnit(Bfield[0]*meter,"Electric potential") <<"/m " <<Bfield[1]/volt*meter <<" V/m "<< Bfield[2]/volt*meter <<" V/m " <<G4endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
81
geant4/LEMuSR/src/LEMuSRElMagField.cc
Normal file
81
geant4/LEMuSR/src/LEMuSRElMagField.cc
Normal file
@ -0,0 +1,81 @@
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID :LEMuSRElMagField.cc , v 1.3
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-09-17 10:20
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// Electric Field
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
#include"LEMuSRElMagField.hh"
|
||||
#include"G4UnitsTable.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <iomanip.h>
|
||||
|
||||
LEMuSRElMagField::LEMuSRElMagField( G4ElectricField *E, G4MagneticField *B, G4double field1_val, G4double field2_val)
|
||||
{
|
||||
coef1 = field1_val;
|
||||
coef2 = field2_val;
|
||||
field1 = E;
|
||||
field2 = B;
|
||||
G4cout<<"ELMAGFIELD COEFS "<< coef1 <<"AND "<< coef2<<G4endl;
|
||||
G4cout<<"nb: coefs disabled in code"<<G4endl;
|
||||
}
|
||||
|
||||
|
||||
LEMuSRElMagField::~LEMuSRElMagField()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LEMuSRElMagField::GetFieldValue(const G4double point[4], G4double *EMfield ) const
|
||||
{
|
||||
G4double Efield[3], Bfield[3];
|
||||
|
||||
G4double position[4],position2[4];
|
||||
position[0]=point[0];
|
||||
position[1]=point[1];
|
||||
position[2]=point[2];
|
||||
position[3]=point[3];
|
||||
position2[0]=point[0];
|
||||
position2[1]=point[1];
|
||||
position2[2]=point[2];
|
||||
position2[3]=point[3];
|
||||
/// G4cout<<"Field zb" <<field1->minz <<std::endl;
|
||||
// G4cout<<"Field zb" <<field2->maxz <<std::endl;
|
||||
|
||||
field1->GetFieldValue(position, Efield);
|
||||
|
||||
field2->GetFieldValue(position2, Bfield);
|
||||
/*
|
||||
G4cout<<"Field E Value " << G4BestUnit(Efield[0]*coef1*meter,"Electric potential") <<"/m " <<Efield[1]*coef1/volt*meter <<" V/m "<< Efield[2]*coef1/volt*meter <<" V/m " <<G4endl;
|
||||
G4cout<<"Field B Value " << Bfield[0]/gauss <<"gauss " <<Bfield[1]/gauss <<"gauss "<< Bfield[2]/gauss <<"gauss " <<G4endl;
|
||||
*/
|
||||
|
||||
EMfield[0] = Bfield[0];//* coef1
|
||||
EMfield[1] = Bfield[1];
|
||||
EMfield[2] = Bfield[2];
|
||||
EMfield[3] = Efield[0];// *coef2
|
||||
EMfield[4] = Efield[1];
|
||||
EMfield[5] = Efield[2];
|
||||
|
||||
/* G4cout<<"Field EM Field Value " << EMfield[0]/gauss <<"gauss " <<EMfield[1]/gauss <<"gauss "<< EMfield[2]/gauss <<"gauss \n"
|
||||
<< EMfield[3]/volt*meter <<"V/m " <<EMfield[3]/volt*meter <<"V/m "<< EMfield[5]/volt*meter <<"V/m " <<G4endl;
|
||||
*/
|
||||
}
|
||||
|
||||
|
89
geant4/LEMuSR/src/LEMuSRElMag_SpinEqRhs.cc
Normal file
89
geant4/LEMuSR/src/LEMuSRElMag_SpinEqRhs.cc
Normal file
@ -0,0 +1,89 @@
|
||||
|
||||
#include "LEMuSRElMag_SpinEqRhs.hh"
|
||||
#include "G4MagneticField.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
|
||||
LEMuSRElMag_SpinEqRhs::LEMuSRElMag_SpinEqRhs( G4MagneticField* MagField )
|
||||
: G4Mag_EqRhs( MagField ) {}
|
||||
|
||||
LEMuSRElMag_SpinEqRhs::~LEMuSRElMag_SpinEqRhs() {}
|
||||
|
||||
void
|
||||
LEMuSRElMag_SpinEqRhs::SetChargeMomentumMass(G4double particleCharge, // in e+ units
|
||||
G4double MomentumXc,
|
||||
G4double mass)
|
||||
{
|
||||
// To set fCof_val
|
||||
G4Mag_EqRhs::SetChargeMomentumMass(particleCharge, MomentumXc, mass);
|
||||
|
||||
omegac = 0.105658387*GeV/mass * 2.837374841e-3*(rad/cm/kilogauss);
|
||||
anomaly = 1.165923e-3*0;
|
||||
ParticleCharge = particleCharge;
|
||||
|
||||
E = sqrt(sqr(MomentumXc)+sqr(mass));
|
||||
beta = MomentumXc/E;
|
||||
gamma = E/mass;
|
||||
m_mass=mass;
|
||||
|
||||
cst = particleCharge*eplus*m_mass;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
LEMuSRElMag_SpinEqRhs::EvaluateRhsGivenB( const G4double y[],
|
||||
const G4double B[6],
|
||||
G4double dydx[] ) const
|
||||
{
|
||||
G4double momentum_square = y[3]*y[3] + y[4]*y[4] + y[5]*y[5];
|
||||
G4double inv_momentum_magnitude = 1.0 / sqrt( momentum_square );
|
||||
|
||||
G4double cof = FCof()*inv_momentum_magnitude;
|
||||
G4double cofe = cst*inv_momentum_magnitude;
|
||||
|
||||
dydx[0] = y[3] * inv_momentum_magnitude; // (d/ds)x = Vx/V
|
||||
dydx[1] = y[4] * inv_momentum_magnitude; // (d/ds)y = Vy/V
|
||||
dydx[2] = y[5] * inv_momentum_magnitude; // (d/ds)z = Vz/V
|
||||
|
||||
dydx[3] = cofe*B[3] + cof*(y[4]*B[2] - y[5]*B[1]) ; // Ax = a*(Ex+Vy*Bz - Vz*By)
|
||||
dydx[4] = cofe*B[4] + cof*(y[5]*B[0] - y[3]*B[2]) ; // Ay = a*(Ey+Vz*Bx - Vx*Bz)
|
||||
dydx[5] = cofe*B[5] + cof*(y[3]*B[1] - y[4]*B[0]) ; // Az = a*(Ez+Vx*By - Vy*Bx)
|
||||
|
||||
|
||||
G4ThreeVector u(y[3], y[4], y[5]);
|
||||
u *= inv_momentum_magnitude;
|
||||
|
||||
G4ThreeVector BField(B[0],B[1],B[2]);
|
||||
|
||||
G4double udb = anomaly*beta*gamma/(1.+gamma) * (BField * u);
|
||||
G4double ucb = (anomaly+1./gamma)/beta;
|
||||
|
||||
// Initialise the values of dydx that we do not update.
|
||||
dydx[6] = dydx[8] = 0.0;
|
||||
|
||||
//unit of momentum is mev/c in this case
|
||||
G4double velocity=(sqrt(momentum_square)/m_mass)*c_light;
|
||||
|
||||
dydx[7]=1./velocity; //dt/ds
|
||||
//G4cout <<"\nmass"<<m_mass/MeV;
|
||||
|
||||
|
||||
G4ThreeVector Spin(y[9],y[10],y[11]);
|
||||
G4ThreeVector dSpin;
|
||||
|
||||
dSpin = ParticleCharge*omegac*(ucb*(Spin.cross(BField))-udb*(Spin.cross(u)));
|
||||
|
||||
dydx[ 9] = dSpin.x();
|
||||
dydx[10] = dSpin.y();
|
||||
dydx[11] = dSpin.z();
|
||||
|
||||
/* G4cout<<"LEMuSRMAg_SpinEqRhs :: dydx \n"
|
||||
<< dydx[0] <<" " << dydx[1] <<" "<< dydx[2] <<" "<<"\n"
|
||||
<< dydx[3] <<" " << dydx[4] <<" "<< dydx[5] <<" "<<"\n"
|
||||
<< dydx[6] <<" " << dydx[7] <<" "<< dydx[8] <<" "<<"\n"
|
||||
<< dydx[9] <<" " << dydx[10] <<" "<< dydx[11] <<" "<<"\n";
|
||||
*/
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
|
370
geant4/LEMuSR/src/LEMuSRElectricField.cc
Normal file
370
geant4/LEMuSR/src/LEMuSRElectricField.cc
Normal file
@ -0,0 +1,370 @@
|
||||
///§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID :LEMuSRElectricField.cc , v 1.3
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-09-17 10:20
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// Electric Field
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
#include"LEMuSRElectricField.hh"
|
||||
#include"G4UnitsTable.hh"
|
||||
|
||||
|
||||
LEMuSRElectricField::LEMuSRElectricField(G4double fieldval,const char* Xfile,
|
||||
const char* Yfile,
|
||||
const char* Zfile,
|
||||
G4String map_length_unit,
|
||||
G4double Offset, G4double nbx, G4double nby, G4double nbz)
|
||||
{
|
||||
FieldVal=fieldval;
|
||||
map_unit = map_length_unit;
|
||||
G4cout<<G4endl
|
||||
<< " ++++++ELECTRIC FIELD BEINg BUILT++++++"<<G4endl;
|
||||
G4cout<< " +++++IMPORTANT++++++"<<G4endl;
|
||||
G4cout<< "+ MAKE SURE UNITS IN FIELD MAP AND IN LEMuSRElectricField.cc ARE COHERENT +"<<G4endl<<G4endl;
|
||||
|
||||
// open files for reading
|
||||
std::ifstream fx(Xfile);
|
||||
std::ifstream fy(Yfile);
|
||||
std::ifstream fz(Zfile);
|
||||
|
||||
// Ignore first blank line
|
||||
char Xbuffer[256];
|
||||
fx.getline(Xbuffer,256);
|
||||
char Ybuffer[256];
|
||||
fy.getline(Ybuffer,256);
|
||||
char Zbuffer[256];
|
||||
fz.getline(Zbuffer,256);
|
||||
|
||||
zOffset = Offset;
|
||||
nx=nbx;
|
||||
ny=nby;
|
||||
nz=nbz;
|
||||
|
||||
|
||||
int ix, iy, iz;
|
||||
|
||||
// Read in the data
|
||||
double xval,yval,zval,bx,by,bz;
|
||||
xval=0;
|
||||
yval=0;
|
||||
zval=0;
|
||||
bx=0;
|
||||
by=0;
|
||||
bz=0;
|
||||
ix=0;
|
||||
iy=0;
|
||||
iz=0;
|
||||
G4int firstline;
|
||||
firstline=0;
|
||||
|
||||
// ATTENTION :: FIELD MAP IS ASSUMED TO BEGIN WITH XMIN YMIN ZMIN AND END WITH XMAX YMAX ZMAX
|
||||
// THIS IS A CASE FOR MAPS GENERATED BY FEMLAB
|
||||
|
||||
for (ix=0; ix<nx; ix++) {
|
||||
for (iy=0; iy<ny; iy++) {
|
||||
for (iz=0; iz<nz; iz++) {
|
||||
|
||||
fx >> xval >> yval >> zval >> bx;
|
||||
fy >> xval >> yval >> zval >> by;
|
||||
fz >> xval >> yval >> zval >> bz;
|
||||
|
||||
xField[ix][iy][iz] = bx*volt/meter;
|
||||
yField[ix][iy][iz] = by*volt/meter;
|
||||
zField[ix][iy][iz] = bz*volt/meter;
|
||||
if (firstline==0)
|
||||
{
|
||||
minx =xval;
|
||||
miny =yval;
|
||||
minz =zval;
|
||||
|
||||
firstline=1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fx.close(); fy.close(); fz.close();
|
||||
|
||||
maxx = xval;
|
||||
maxy = yval;
|
||||
maxz = zval;
|
||||
|
||||
G4cout<<G4endl
|
||||
<< " (-: ++++++ELECTRIC FIELD INITIALIZED++++++ :-)";
|
||||
G4cout<<"\n from files "<< Xfile << " etc. with following statistics : \n"
|
||||
<<"\n last line: " << xval <<" "<< yval <<" "<< zval<<" "<<bx<<" "<<by<<" "<<bz<<" with field "<<fieldval<<"\n"
|
||||
<<"\n boundaries: " << minx <<" "<< maxx <<" "<< miny<<" "<<maxy<<" "<<minz<<" "<<maxz<<" (in "<<map_unit<<")\n"
|
||||
<<G4endl
|
||||
<<G4endl;
|
||||
|
||||
|
||||
//#ifdef DEBUG_INTERPOLATING_FIELD2
|
||||
G4String output_name;
|
||||
G4cout<<"Output Field Map file name?"<<G4endl;
|
||||
G4cin>>output_name;
|
||||
std::ofstream fout (output_name); // open destination file
|
||||
fout.close ();
|
||||
|
||||
|
||||
fout.open(output_name);
|
||||
if (!fout.is_open()) exit(8);
|
||||
|
||||
for (ix=0; ix<nx; ix++) {
|
||||
for (iy=0; iy<ny; iy++) {
|
||||
for (iz=0; iz<nz; iz++) {
|
||||
fout<< xField[ix][iy][iz]/volt*meter <<" " << yField[ix][iy][iz]/volt*meter <<" " << zField[ix][iy][iz]/volt*meter <<G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fout<< maxx<<" " << maxy<<" " <<maxz <<G4endl;
|
||||
fout<< minx<<" " << miny<<" " <<minz <<G4endl;
|
||||
|
||||
fout.close();
|
||||
|
||||
G4cout<<"Field Map "<<output_name<<" genarated ___ press enter"<<G4endl;
|
||||
|
||||
//#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
LEMuSRElectricField::LEMuSRElectricField(G4double fieldval,const char* file,
|
||||
G4String map_length_unit,
|
||||
G4double Offset,
|
||||
G4double nbx,
|
||||
G4double nby,
|
||||
G4double nbz)
|
||||
{
|
||||
|
||||
FieldVal= fieldval;
|
||||
map_unit = map_length_unit;
|
||||
G4cout<<G4endl
|
||||
<< "++++++LEMUSR ELECTRIC FIELD INITIALIZATION+++++\n";
|
||||
G4cout<< " +++++IMPORTANT++++++"<<G4endl;
|
||||
G4cout<< "+ MAKE SURE UNITS IN FIELD MAP AND IN LEMuSRElectricField.cc ARE COHERENT +"<<G4endl;
|
||||
G4cout<< "++++++ELECTRIC FIELD BEINg BUILT++++++"<<G4endl<<G4endl;
|
||||
|
||||
// open files for reading
|
||||
std::ifstream fmap(file);
|
||||
|
||||
// Ignore first blank line
|
||||
// char buffer[256];
|
||||
// fmap.getline(buffer,256);
|
||||
|
||||
zOffset = Offset;
|
||||
nx=nbx;
|
||||
ny=nby;
|
||||
nz=nbz;
|
||||
|
||||
int ix, iy, iz;
|
||||
|
||||
|
||||
// Read in the data
|
||||
double bx,by,bz;
|
||||
for (ix=0; ix<nx; ix++) {
|
||||
for (iy=0; iy<ny; iy++) {
|
||||
for (iz=0; iz<nz; iz++) {
|
||||
fmap >>bx >>by >>bz;
|
||||
|
||||
xField[ix][iy][iz] = bx*volt/meter;
|
||||
yField[ix][iy][iz] = by*volt/meter;
|
||||
zField[ix][iy][iz] = bz*volt/meter;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fmap>> maxx >> maxy >> maxz ;
|
||||
fmap>> minx >> miny >> minz ;
|
||||
G4cout<< maxx<<" " << maxy<<" " <<maxz <<G4endl;
|
||||
G4cout<< minx<<" " << miny<<" " <<minz <<G4endl;
|
||||
|
||||
fmap.close();
|
||||
|
||||
G4cout<< "++++++ELECTRIC FIELD INITIALIZED++++++";
|
||||
G4cout<<"\n from file "<< file <<G4endl<<G4endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
LEMuSRElectricField::~LEMuSRElectricField()
|
||||
{
|
||||
delete [] xField ;
|
||||
delete [] yField ;
|
||||
delete [] zField ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LEMuSRElectricField::GetFieldValue(const G4double point[4],
|
||||
G4double *Bfield ) const
|
||||
{
|
||||
// Values of x y z must be scaled according to the field map unit! important
|
||||
// be carefull and use the debuging to verify it
|
||||
|
||||
G4double length_ratio, field_factor;
|
||||
length_ratio=1;
|
||||
field_factor=0;
|
||||
|
||||
if (map_unit=="m")
|
||||
{
|
||||
length_ratio=1000;
|
||||
field_factor=1;
|
||||
}
|
||||
|
||||
else if (map_unit=="dm")
|
||||
{
|
||||
length_ratio=100;
|
||||
field_factor=10;
|
||||
}
|
||||
else if (map_unit=="cm")
|
||||
{
|
||||
length_ratio=10;
|
||||
field_factor=100;
|
||||
}
|
||||
else if (map_unit=="mm")
|
||||
{
|
||||
length_ratio=1;
|
||||
field_factor=1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout<<"ERROR!!!! UNRECOGNIZED LENGTH UNIT FOR FIELD MAP ==>> zöro";
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4double x = (point[0]/mm)/length_ratio;
|
||||
G4double y = (point[1]/mm)/length_ratio;
|
||||
G4double z = ((point[2] - zOffset)/mm)/length_ratio;
|
||||
|
||||
|
||||
#ifdef DEBUG_INTERPOLATING_FIELD
|
||||
|
||||
G4cout<<"POSITION:: " <<point[0] <<" mm "<< G4BestUnit(point[1],"Length") <<" "<<G4BestUnit(point[2],"Length")<<G4endl;
|
||||
|
||||
G4cout<<"POSITION in the field map:: " <<x <<map_unit<<" "<< y <<map_unit<<" "<< z <<map_unit<< " "<<G4endl;
|
||||
#endif
|
||||
|
||||
|
||||
//check that the point is within the defined region
|
||||
if ( x>=minx && x<=maxx && y>=miny && y<=maxy && (z)>=minz && (z)<=maxz )
|
||||
{
|
||||
|
||||
// Position of given point within region, normalized to the range
|
||||
// [0,1]
|
||||
G4double xfraction = (x - minx) / (maxx-minx);
|
||||
G4double yfraction = (y - miny) / (maxy-miny);
|
||||
G4double zfraction = (z - minz) / (maxz-minz);//!!!!! PROBLEM MAY BE HERE
|
||||
|
||||
// Need addresses of these to pass to modf below.
|
||||
// modf uses its second argument as an OUTPUT argument.
|
||||
G4double xdindex, ydindex, zdindex;
|
||||
|
||||
// Position of the point within the cuboid defined by the
|
||||
// nearest surrounding tabulated points
|
||||
|
||||
G4double xlocal = ( modf(xfraction*(nx-1), &xdindex));
|
||||
G4double ylocal = ( modf(yfraction*(ny-1), &ydindex));
|
||||
G4double zlocal = ( modf(zfraction*(nz-1), &zdindex));
|
||||
|
||||
// The indices of the nearest tabulated point whose coordinates
|
||||
// are all less than those of the given point
|
||||
/* int xindex = static_cast<int>(xdindex);
|
||||
int yindex = static_cast<int>(ydindex);
|
||||
int zindex = static_cast<int>(zdindex);
|
||||
*/
|
||||
G4int xindex = (G4int)(xdindex);
|
||||
G4int yindex = (G4int)(ydindex);
|
||||
G4int zindex = (G4int)(zdindex);
|
||||
|
||||
|
||||
#ifdef DEBUG_INTERPOLATING_FIELD
|
||||
G4cout << "Local x,y,z: " << xlocal << " " << ylocal << " " << zlocal << endl;
|
||||
G4cout << "Index x,y,z: " << xindex << " " << yindex << " " << zindex << endl;
|
||||
#endif
|
||||
|
||||
//********************* FIELD INTERPOLATION***************************//
|
||||
//*********** FROM GEANT4 EXTENDED EXAMPLE PURGING MAGNET ************//
|
||||
|
||||
// Full 3-dimensional version
|
||||
|
||||
// example: if map_unit= 'dm' multiply by 10 since field map generated by femlab is in volt/decimeter! in order to get the field in V/m.
|
||||
|
||||
Bfield[0] =
|
||||
(xField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
|
||||
xField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
|
||||
xField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
|
||||
xField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
|
||||
xField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
|
||||
xField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
|
||||
xField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
|
||||
xField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal);
|
||||
Bfield[1] =
|
||||
(yField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
|
||||
yField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
|
||||
yField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
|
||||
yField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
|
||||
yField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
|
||||
yField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
|
||||
yField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
|
||||
yField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal);
|
||||
Bfield[2] =
|
||||
(zField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
|
||||
zField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
|
||||
zField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
|
||||
zField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
|
||||
zField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
|
||||
zField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
|
||||
zField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
|
||||
zField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal);
|
||||
|
||||
} else {
|
||||
// G4cout<<"RANGE ERROR=>field 0:: RANGE is " << minx <<" " << maxx <<" " << miny <<" " << maxy <<" " << minz <<" "<< maxz <<" ";
|
||||
Bfield[0] = 0.0;
|
||||
Bfield[1] = 0.0;
|
||||
Bfield[2] = 0.0;
|
||||
}
|
||||
|
||||
|
||||
//G4cout<<"Field Value " << G4BestUnit(Bfield[0]*meter,"Electric potential") <<"/m " <<Bfield[1]/volt*meter <<" V/m "<< Bfield[2]/volt*meter <<" V/m " <<G4endl;
|
||||
|
||||
|
||||
// G4cout<<"FieldVal " <<FieldVal <<" coef " << field_factor<<" \n";
|
||||
|
||||
Bfield[0] = Bfield[0]*FieldVal*field_factor;
|
||||
Bfield[1] = Bfield[1]*FieldVal*field_factor;
|
||||
Bfield[2] = Bfield[2]*FieldVal*field_factor;
|
||||
|
||||
// G4cout<< "Ex "<< xField[37][37][84]<<"\n Ey "<< yField[37][37][84]<<"\n Ez "<< zField[37][37][84] <<G4endl;
|
||||
|
||||
// G4cout<< "Ex "<< xField[37][37][884]<<"\n Ey "<< yField[37][37][884]<<"\n Ez "<< zField[37][37][884] <<G4endl;
|
||||
|
||||
#ifdef DEBUG_INTERPOLATING_FIELD
|
||||
G4cout<<"Field Value " << G4BestUnit(Bfield[0]*meter,"Electric potential") <<"/m " <<Bfield[1]/volt*meter <<" V/m "<< Bfield[2]/volt*meter <<" V/m " <<G4endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
91
geant4/LEMuSR/src/LEMuSREqMagElectricField.cc
Normal file
91
geant4/LEMuSR/src/LEMuSREqMagElectricField.cc
Normal file
@ -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$
|
||||
// GEANT4 tag $Name$
|
||||
//
|
||||
//
|
||||
// This is the standard right-hand side for equation of motion.
|
||||
//
|
||||
// The only case another is required is when using a moving reference
|
||||
// frame ... or extending the class to include additional Forces,
|
||||
// eg an electric field
|
||||
//
|
||||
// 10.11.98 V.Grichine
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
|
||||
#include "LEMuSREqMagElectricField.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
void
|
||||
LEMuSREqMagElectricField::SetChargeMomentumMass(G4double particleCharge, // e+ units
|
||||
G4double,
|
||||
G4double particleMass)
|
||||
{
|
||||
fElectroMagCof = eplus*particleCharge*c_light ;
|
||||
fMassCof = particleMass*particleMass ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
LEMuSREqMagElectricField::EvaluateRhsGivenB(const G4double y[],
|
||||
const G4double Field[],
|
||||
G4double dydx[] ) const
|
||||
{
|
||||
|
||||
// Components of y:
|
||||
// 0-2 dr/ds,
|
||||
// 3-5 dp/ds - momentum derivatives
|
||||
|
||||
G4double pSquared = y[3]*y[3] + y[4]*y[4] + y[5]*y[5] ;
|
||||
|
||||
G4double Energy = sqrt( pSquared + fMassCof );
|
||||
G4double cof2 = Energy/c_light ;
|
||||
|
||||
G4double pModuleInverse = 1.0/sqrt(pSquared) ;
|
||||
|
||||
// G4double inverse_velocity = Energy * c_light * pModuleInverse;
|
||||
G4double inverse_velocity = Energy * pModuleInverse / c_light;
|
||||
|
||||
G4double cof1 = fElectroMagCof*pModuleInverse ;
|
||||
|
||||
// G4double vDotE = y[3]*Field[3] + y[4]*Field[4] + y[5]*Field[5] ;
|
||||
|
||||
|
||||
dydx[0] = y[3]*pModuleInverse ;
|
||||
dydx[1] = y[4]*pModuleInverse ;
|
||||
dydx[2] = y[5]*pModuleInverse ;
|
||||
|
||||
dydx[3] = cof1*(cof2*Field[3] + (y[4]*Field[2] - y[5]*Field[1])) ;
|
||||
|
||||
dydx[4] = cof1*(cof2*Field[4] + (y[5]*Field[0] - y[3]*Field[2])) ;
|
||||
|
||||
dydx[5] = cof1*(cof2*Field[5] + (y[3]*Field[1] - y[4]*Field[0])) ;
|
||||
|
||||
// Lab Time of flight
|
||||
dydx[7] = inverse_velocity;
|
||||
return ;
|
||||
}
|
234
geant4/LEMuSR/src/LEMuSREventAction.cc
Normal file
234
geant4/LEMuSR/src/LEMuSREventAction.cc
Normal file
@ -0,0 +1,234 @@
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION Geant4 SIMULATION
|
||||
// ID : LEMuSREventAction.cc , v 1.0
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-07-07 11:15
|
||||
//
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// EVENT ACTION.CC
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
|
||||
#include "LEMuSREventAction.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "LEMuSRPrimaryGeneratorAction.hh"
|
||||
#include "G4TrajectoryContainer.hh"
|
||||
#include "G4Trajectory.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4DynamicParticle.hh"
|
||||
#include "G4DecayTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
|
||||
#include "G4HCofThisEvent.hh"
|
||||
#include "G4VHitsCollection.hh"
|
||||
#include "LEMuSRScintHit.hh"
|
||||
#include "LEMuSROScintHit.hh"
|
||||
#include "LEMuSRCryoHit.hh"
|
||||
#include "LEMuSRMcpHit.hh"
|
||||
|
||||
#include "LEMuSRDetectorConstruction.hh"
|
||||
|
||||
#include "TROOT.h"
|
||||
#include "TApplication.h"
|
||||
#include "TSystem.h"
|
||||
#include "TH1.h"
|
||||
#include "TPad.h"
|
||||
#include "TCanvas.h"
|
||||
|
||||
|
||||
// sensitive detectors
|
||||
#include "LEMuSRCryoSD.hh"
|
||||
|
||||
LEMuSREventAction::LEMuSREventAction()
|
||||
:drawFlag("all")
|
||||
{
|
||||
iScintCollID = -1;
|
||||
oScintCollID = -1;
|
||||
McpCollID = -1;
|
||||
CryoCollID = -1;
|
||||
|
||||
|
||||
G4cout<<"EVENT ACTION INITIALIZED";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
LEMuSREventAction::~LEMuSREventAction()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LEMuSREventAction::BeginOfEventAction(const G4Event*)
|
||||
{
|
||||
|
||||
G4SDManager * SDman = G4SDManager::GetSDMpointer();
|
||||
|
||||
if(iScintCollID<0)
|
||||
{
|
||||
iScintCollID = SDman->GetCollectionID("InnerScintCollection");
|
||||
|
||||
}
|
||||
|
||||
if(oScintCollID<0)
|
||||
{
|
||||
oScintCollID = SDman->GetCollectionID("OuterScintCollection");
|
||||
|
||||
}
|
||||
|
||||
// check detectors mode (mcp or cryo => k)
|
||||
LEMuSRDetectorConstruction* lemuDet = LEMuSRDetectorConstruction::GetInstance();
|
||||
G4double k = lemuDet->GetParamMC();
|
||||
if(k==1){
|
||||
if(McpCollID<0)
|
||||
{
|
||||
McpCollID = SDman->GetCollectionID("McpCollection");
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(CryoCollID<0)
|
||||
{
|
||||
CryoCollID = SDman->GetCollectionID("CryoCollection");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LEMuSREventAction::EndOfEventAction(const G4Event* evt)
|
||||
{
|
||||
// G4cout << ">>> Event " << evt->GetEventID() << G4endl;
|
||||
|
||||
|
||||
// extract the trajectories and draw them
|
||||
|
||||
if (G4VVisManager::GetConcreteInstance())
|
||||
{
|
||||
G4TrajectoryContainer * trajectoryContainer = evt->GetTrajectoryContainer();
|
||||
G4int n_trajectories = 0;
|
||||
if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();
|
||||
|
||||
for (G4int i=0; i<n_trajectories; i++)
|
||||
{
|
||||
G4Trajectory* trj = (G4Trajectory*)((*(evt->GetTrajectoryContainer()))[i]);
|
||||
if (drawFlag == "all") trj->DrawTrajectory(500);
|
||||
else if ((drawFlag == "charged")&&(trj->GetCharge() != 0.))
|
||||
trj->DrawTrajectory(50);
|
||||
else if ((drawFlag == "neutral")&&(trj->GetCharge() == 0.))
|
||||
trj->DrawTrajectory(50);
|
||||
}
|
||||
}
|
||||
|
||||
// SDCollManagement(evt);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LEMuSREventAction::SDCollManagement(const G4Event* evt)
|
||||
{
|
||||
|
||||
// informations about hits and draw them
|
||||
int nos_hit, nis_hit, nm_hit, nc_hit;
|
||||
|
||||
|
||||
|
||||
if(iScintCollID<0||oScintCollID<0)
|
||||
{
|
||||
G4cout<<"IDERROR";
|
||||
return;
|
||||
}
|
||||
G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
|
||||
LEMuSRScintHitsCollection* iScintHC = 0;
|
||||
LEMuSROScintHitsCollection* oScintHC = 0;
|
||||
LEMuSRMcpHitsCollection* McpHC = 0;
|
||||
LEMuSRCryoHitsCollection* CryoHC = 0;
|
||||
|
||||
|
||||
// check detectors mode (mcp or cryo => k)
|
||||
LEMuSRDetectorConstruction* lemuDet = LEMuSRDetectorConstruction::GetInstance();
|
||||
G4double k = lemuDet->GetParamMC();
|
||||
|
||||
if(HCE)
|
||||
{
|
||||
iScintHC = (LEMuSRScintHitsCollection*)(HCE->GetHC(iScintCollID));
|
||||
oScintHC = (LEMuSROScintHitsCollection*)(HCE->GetHC(oScintCollID));
|
||||
if(k==0) {CryoHC = (LEMuSRCryoHitsCollection*)(HCE->GetHC(CryoCollID));}
|
||||
else{ McpHC = (LEMuSRMcpHitsCollection*)(HCE->GetHC(McpCollID));}
|
||||
}
|
||||
|
||||
|
||||
if(iScintHC)
|
||||
{
|
||||
nis_hit = iScintHC->entries();
|
||||
// G4cout << " " << nis_hit
|
||||
// << " hits are stored in LEMuSRHitsCollection for SCIS." << G4endl;
|
||||
}
|
||||
|
||||
if(oScintHC)
|
||||
{
|
||||
nos_hit = oScintHC->entries();
|
||||
// G4cout << " " << nos_hit
|
||||
// << " hits are stored in LEMuSRHitsCollection for SCOS." << G4endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(k==0)
|
||||
{
|
||||
if (CryoCollID <0) return ;
|
||||
|
||||
if(CryoHC)
|
||||
{
|
||||
nc_hit = CryoHC->entries();
|
||||
// G4cout << " " << nc_hit
|
||||
// << " hits are stored in LEMuSRHitsCollection for CRYO." << G4endl;
|
||||
|
||||
|
||||
|
||||
for(int i=0;i<nc_hit;i++)
|
||||
{
|
||||
aHit = (*CryoHC)[i];
|
||||
|
||||
en_dep = aHit->GetEnergyDeposition()/keV;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if(k==1)
|
||||
{
|
||||
if(McpCollID <0) return ;
|
||||
if(McpHC)
|
||||
{
|
||||
nm_hit = McpHC->entries();
|
||||
// G4cout << " " << nm_hit
|
||||
// << " hits are stored in LEMuSRHitsCollection for MCP." << G4endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
105
geant4/LEMuSR/src/LEMuSRGeneralPhysics.cc
Normal file
105
geant4/LEMuSR/src/LEMuSRGeneralPhysics.cc
Normal file
@ -0,0 +1,105 @@
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID : LEMuSRGeneralPhysics.cc , v 1.1
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-08-24 16:33
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// GENERAL PHYSICS
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
#include "LEMuSRGeneralPhysics.hh"
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <iomanip>
|
||||
#include "G4StepLimiter.hh"
|
||||
|
||||
|
||||
LEMuSRGeneralPhysics::LEMuSRGeneralPhysics(const G4String& name)
|
||||
: G4VPhysicsConstructor(name)
|
||||
{
|
||||
}
|
||||
|
||||
LEMuSRGeneralPhysics::~LEMuSRGeneralPhysics()
|
||||
{
|
||||
}
|
||||
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
// Bosons
|
||||
#include "G4ChargedGeantino.hh"
|
||||
#include "G4Geantino.hh"
|
||||
|
||||
#include "G4UserSpecialCuts.hh"
|
||||
#include "G4Neutron.hh"
|
||||
|
||||
|
||||
void LEMuSRGeneralPhysics::ConstructParticle()
|
||||
{
|
||||
// pseudo-particles
|
||||
G4Neutron::Neutron();
|
||||
G4Geantino::GeantinoDefinition();
|
||||
G4ChargedGeantino::ChargedGeantinoDefinition();
|
||||
}
|
||||
|
||||
void LEMuSRGeneralPhysics::ConstructProcess()
|
||||
{
|
||||
// Add Decay Process
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() )
|
||||
{
|
||||
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
if (fDecayProcess.IsApplicable(*particle)&&particle->GetParticleName()!="mu+"&&particle->GetParticleName()!="Mu")
|
||||
{
|
||||
pmanager ->AddProcess(&fDecayProcess);
|
||||
// set ordering for PostStepDoIt and AtRestDoIt
|
||||
pmanager ->SetProcessOrdering(&fDecayProcess, idxPostStep);
|
||||
pmanager ->SetProcessOrdering(&fDecayProcess, idxAtRest);
|
||||
}
|
||||
if (particle->GetParticleName()!="mu+"&&particle->GetParticleName()!="Mu")
|
||||
{
|
||||
pmanager->AddProcess(new G4UserSpecialCuts(),-1,-1,1);
|
||||
}
|
||||
//#if defined LEMU_TEST_FIELD
|
||||
if (particle->GetParticleName()=="mu+"||particle->GetParticleName()=="Mu")
|
||||
{
|
||||
pmanager->AddProcess(&fStepLimiter,-1,-1,1); //
|
||||
pmanager->AddProcess(new G4UserSpecialCuts(),-1,-1,1);
|
||||
|
||||
}
|
||||
//#endif
|
||||
}
|
||||
|
||||
|
||||
G4ProcessManager* Gpmanager;
|
||||
Gpmanager = G4Geantino::Geantino()->GetProcessManager();
|
||||
Gpmanager->AddProcess(new G4UserSpecialCuts(),-1,-1,1); //
|
||||
Gpmanager->AddProcess(&fStepLimiter,-1,-1,1); //
|
||||
|
||||
|
||||
G4ProcessManager* Npmanager;
|
||||
Npmanager = G4Neutron::Neutron()->GetProcessManager();
|
||||
|
||||
Npmanager->AddProcess(new G4UserSpecialCuts(),-1,-1,1); //
|
||||
Npmanager->AddProcess(new G4UserSpecialCuts(),-1,-1,1); //
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
415
geant4/LEMuSR/src/LEMuSRHadronPhysics.cc
Normal file
415
geant4/LEMuSR/src/LEMuSRHadronPhysics.cc
Normal file
@ -0,0 +1,415 @@
|
||||
// $Id$
|
||||
// GEANT4 tag $Name$
|
||||
//
|
||||
|
||||
#include "LEMuSRHadronPhysics.hh"
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
LEMuSRHadronPhysics::LEMuSRHadronPhysics(const G4String& name)
|
||||
: G4VPhysicsConstructor(name)
|
||||
{
|
||||
}
|
||||
|
||||
LEMuSRHadronPhysics::~LEMuSRHadronPhysics()
|
||||
{
|
||||
delete theStringDecay;
|
||||
}
|
||||
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
|
||||
// Nuclei
|
||||
#include "G4MesonConstructor.hh"
|
||||
#include "G4BaryonConstructor.hh"
|
||||
#include "G4ShortLivedConstructor.hh"
|
||||
|
||||
void LEMuSRHadronPhysics::ConstructParticle()
|
||||
{
|
||||
// Construct all mesons
|
||||
G4MesonConstructor pMesonConstructor;
|
||||
pMesonConstructor.ConstructParticle();
|
||||
|
||||
// Construct all barions
|
||||
G4BaryonConstructor pBaryonConstructor;
|
||||
pBaryonConstructor.ConstructParticle();
|
||||
|
||||
// Construct resonaces and quarks
|
||||
G4ShortLivedConstructor pShortLivedConstructor;
|
||||
pShortLivedConstructor.ConstructParticle();
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "G4ProcessManager.hh"
|
||||
|
||||
|
||||
void LEMuSRHadronPhysics::ConstructProcess()
|
||||
{
|
||||
G4ProcessManager * pManager = 0;
|
||||
G4cout << "" << G4endl;
|
||||
G4cout << "You are using the ExoN04HadronPhysics" << G4endl;
|
||||
G4cout << " - Note that this hadronic physics list is not optimized for any particular usage" << G4endl;
|
||||
G4cout << " - If you wish to have a starting point tailored for a particular area of work," << G4endl;
|
||||
G4cout << " please use one of the available physics lists by use-case." << G4endl;
|
||||
G4cout << " More information can also be found from the Geant4 HyperNews." << G4endl;
|
||||
G4cout << "" << G4endl;
|
||||
// Elastic Process
|
||||
theElasticModel = new G4LElastic();
|
||||
theElasticProcess.RegisterMe(theElasticModel);
|
||||
|
||||
// pi+ and pi-
|
||||
|
||||
thePreEquilib = new G4PreCompoundModel(&theHandler);
|
||||
theCascade.SetDeExcitation(thePreEquilib);
|
||||
theTheoModel.SetTransport(&theCascade);
|
||||
theTheoModel.SetHighEnergyGenerator(&theStringModel);
|
||||
theStringDecay = new G4ExcitedStringDecay(&theFragmentation);
|
||||
theStringModel.SetFragmentationModel(theStringDecay);
|
||||
theTheoModel.SetMinEnergy(15*GeV);
|
||||
theTheoModel.SetMaxEnergy(100*TeV);
|
||||
|
||||
// PionPlus
|
||||
pManager = G4PionPlus::PionPlus()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEPionPlusModel = new G4LEPionPlusInelastic();
|
||||
thePionPlusInelastic.RegisterMe(theLEPionPlusModel);
|
||||
thePionPlusInelastic.RegisterMe(&theTheoModel);
|
||||
pManager->AddDiscreteProcess(&thePionPlusInelastic);
|
||||
|
||||
pManager->AddProcess(&thePionPlusIonisation, ordInActive,2, 2);
|
||||
|
||||
pManager->AddProcess(&thePionPlusMult);
|
||||
pManager->SetProcessOrdering(&thePionPlusMult, idxAlongStep, 1);
|
||||
pManager->SetProcessOrdering(&thePionPlusMult, idxPostStep, 1);
|
||||
|
||||
// PionMinus
|
||||
pManager = G4PionMinus::PionMinus()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEPionMinusModel = new G4LEPionMinusInelastic();
|
||||
thePionMinusInelastic.RegisterMe(theLEPionMinusModel);
|
||||
thePionMinusInelastic.RegisterMe(&theTheoModel);
|
||||
pManager->AddDiscreteProcess(&thePionMinusInelastic);
|
||||
|
||||
pManager->AddProcess(&thePionMinusIonisation, ordInActive,2, 2);
|
||||
|
||||
pManager->AddProcess(&thePionMinusMult);
|
||||
pManager->SetProcessOrdering(&thePionMinusMult, idxAlongStep, 1);
|
||||
pManager->SetProcessOrdering(&thePionMinusMult, idxPostStep, 1);
|
||||
|
||||
pManager->AddRestProcess(&thePionMinusAbsorption, ordDefault);
|
||||
|
||||
// KaonPlus
|
||||
pManager = G4KaonPlus::KaonPlus()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEKaonPlusModel = new G4LEKaonPlusInelastic();
|
||||
theHEKaonPlusModel = new G4HEKaonPlusInelastic();
|
||||
theKaonPlusInelastic.RegisterMe(theLEKaonPlusModel);
|
||||
theKaonPlusInelastic.RegisterMe(&theTheoModel);
|
||||
pManager->AddDiscreteProcess(&theKaonPlusInelastic);
|
||||
|
||||
pManager->AddProcess(&theKaonPlusIonisation, ordInActive,2, 2);
|
||||
|
||||
pManager->AddProcess(&theKaonPlusMult);
|
||||
pManager->SetProcessOrdering(&theKaonPlusMult, idxAlongStep, 1);
|
||||
pManager->SetProcessOrdering(&theKaonPlusMult, idxPostStep, 1);
|
||||
|
||||
// KaonMinus
|
||||
pManager = G4KaonMinus::KaonMinus()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEKaonMinusModel = new G4LEKaonMinusInelastic();
|
||||
theHEKaonMinusModel = new G4HEKaonMinusInelastic();
|
||||
theKaonMinusInelastic.RegisterMe(theLEKaonMinusModel);
|
||||
theKaonMinusInelastic.RegisterMe(theHEKaonMinusModel);
|
||||
pManager->AddDiscreteProcess(&theKaonMinusInelastic);
|
||||
|
||||
pManager->AddProcess(&theKaonMinusIonisation, ordInActive,2, 2);
|
||||
|
||||
pManager->AddProcess(&theKaonMinusMult);
|
||||
pManager->SetProcessOrdering(&theKaonMinusMult, idxAlongStep, 1);
|
||||
pManager->SetProcessOrdering(&theKaonMinusMult, idxPostStep, 1);
|
||||
|
||||
pManager->AddRestProcess(&theKaonMinusAbsorption, ordDefault);
|
||||
|
||||
// KaonZeroL
|
||||
pManager = G4KaonZeroLong::KaonZeroLong()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEKaonZeroLModel = new G4LEKaonZeroLInelastic();
|
||||
theHEKaonZeroLModel = new G4HEKaonZeroInelastic();
|
||||
theKaonZeroLInelastic.RegisterMe(theLEKaonZeroLModel);
|
||||
theKaonZeroLInelastic.RegisterMe(theHEKaonZeroLModel);
|
||||
pManager->AddDiscreteProcess(&theKaonZeroLInelastic);
|
||||
|
||||
// KaonZeroS
|
||||
pManager = G4KaonZeroShort::KaonZeroShort()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEKaonZeroSModel = new G4LEKaonZeroSInelastic();
|
||||
theHEKaonZeroSModel = new G4HEKaonZeroInelastic();
|
||||
theKaonZeroSInelastic.RegisterMe(theLEKaonZeroSModel);
|
||||
theKaonZeroSInelastic.RegisterMe(theHEKaonZeroSModel);
|
||||
pManager->AddDiscreteProcess(&theKaonZeroSInelastic);
|
||||
|
||||
// Proton
|
||||
pManager = G4Proton::Proton()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEProtonModel = new G4LEProtonInelastic();
|
||||
theHEProtonModel = new G4HEProtonInelastic();
|
||||
theProtonInelastic.RegisterMe(theLEProtonModel);
|
||||
theProtonInelastic.RegisterMe(&theTheoModel);
|
||||
pManager->AddDiscreteProcess(&theProtonInelastic);
|
||||
|
||||
pManager->AddProcess(&theProtonIonisation, ordInActive,2, 2);
|
||||
|
||||
pManager->AddProcess(&theProtonMult);
|
||||
pManager->SetProcessOrdering(&theProtonMult, idxAlongStep, 1);
|
||||
pManager->SetProcessOrdering(&theProtonMult, idxPostStep, 1);
|
||||
|
||||
// anti-Proton
|
||||
pManager = G4AntiProton::AntiProton()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEAntiProtonModel = new G4LEAntiProtonInelastic();
|
||||
theHEAntiProtonModel = new G4HEAntiProtonInelastic();
|
||||
theAntiProtonInelastic.RegisterMe(theLEAntiProtonModel);
|
||||
theAntiProtonInelastic.RegisterMe(theHEAntiProtonModel);
|
||||
pManager->AddDiscreteProcess(&theAntiProtonInelastic);
|
||||
|
||||
pManager->AddProcess(&theAntiProtonIonisation, ordInActive,2, 2);
|
||||
|
||||
pManager->AddProcess(&theAntiProtonMult);
|
||||
pManager->SetProcessOrdering(&theAntiProtonMult, idxAlongStep, 1);
|
||||
pManager->SetProcessOrdering(&theAntiProtonMult, idxPostStep, 1);
|
||||
|
||||
pManager->AddRestProcess(&theAntiProtonAnnihilation);
|
||||
|
||||
// Neutron
|
||||
pManager = G4Neutron::Neutron()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLENeutronModel = new G4LENeutronInelastic();
|
||||
theHENeutronModel = new G4HENeutronInelastic();
|
||||
theNeutronInelastic.RegisterMe(theLENeutronModel);
|
||||
theNeutronInelastic.RegisterMe(&theTheoModel);
|
||||
pManager->AddDiscreteProcess(&theNeutronInelastic);
|
||||
|
||||
theNeutronFissionModel = new G4LFission();
|
||||
theNeutronFission.RegisterMe(theNeutronFissionModel);
|
||||
pManager->AddDiscreteProcess(&theNeutronFission);
|
||||
|
||||
theNeutronCaptureModel = new G4LCapture();
|
||||
theNeutronCapture.RegisterMe(theNeutronCaptureModel);
|
||||
pManager->AddDiscreteProcess(&theNeutronCapture);
|
||||
|
||||
// AntiNeutron
|
||||
pManager = G4AntiNeutron::AntiNeutron()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEAntiNeutronModel = new G4LEAntiNeutronInelastic();
|
||||
theHEAntiNeutronModel = new G4HEAntiNeutronInelastic();
|
||||
theAntiNeutronInelastic.RegisterMe(theLEAntiNeutronModel);
|
||||
theAntiNeutronInelastic.RegisterMe(theHEAntiNeutronModel);
|
||||
pManager->AddDiscreteProcess(&theAntiNeutronInelastic);
|
||||
|
||||
pManager->AddRestProcess(&theAntiNeutronAnnihilation);
|
||||
|
||||
// Lambda
|
||||
pManager = G4Lambda::Lambda()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLELambdaModel = new G4LELambdaInelastic();
|
||||
theHELambdaModel = new G4HELambdaInelastic();
|
||||
theLambdaInelastic.RegisterMe(theLELambdaModel);
|
||||
theLambdaInelastic.RegisterMe(theHELambdaModel);
|
||||
pManager->AddDiscreteProcess(&theLambdaInelastic);
|
||||
|
||||
// AntiLambda
|
||||
pManager = G4AntiLambda::AntiLambda()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEAntiLambdaModel = new G4LEAntiLambdaInelastic();
|
||||
theHEAntiLambdaModel = new G4HEAntiLambdaInelastic();
|
||||
theAntiLambdaInelastic.RegisterMe(theLEAntiLambdaModel);
|
||||
theAntiLambdaInelastic.RegisterMe(theHEAntiLambdaModel);
|
||||
pManager->AddDiscreteProcess(&theAntiLambdaInelastic);
|
||||
|
||||
// SigmaMinus
|
||||
pManager = G4SigmaMinus::SigmaMinus()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLESigmaMinusModel = new G4LESigmaMinusInelastic();
|
||||
theHESigmaMinusModel = new G4HESigmaMinusInelastic();
|
||||
theSigmaMinusInelastic.RegisterMe(theLESigmaMinusModel);
|
||||
theSigmaMinusInelastic.RegisterMe(theHESigmaMinusModel);
|
||||
pManager->AddDiscreteProcess(&theSigmaMinusInelastic);
|
||||
|
||||
pManager->AddProcess(&theSigmaMinusIonisation, ordInActive,2, 2);
|
||||
|
||||
pManager->AddProcess(&theSigmaMinusMult);
|
||||
pManager->SetProcessOrdering(&theSigmaMinusMult, idxAlongStep, 1);
|
||||
pManager->SetProcessOrdering(&theSigmaMinusMult, idxPostStep, 1);
|
||||
|
||||
// anti-SigmaMinus
|
||||
pManager = G4AntiSigmaMinus::AntiSigmaMinus()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEAntiSigmaMinusModel = new G4LEAntiSigmaMinusInelastic();
|
||||
theHEAntiSigmaMinusModel = new G4HEAntiSigmaMinusInelastic();
|
||||
theAntiSigmaMinusInelastic.RegisterMe(theLEAntiSigmaMinusModel);
|
||||
theAntiSigmaMinusInelastic.RegisterMe(theHEAntiSigmaMinusModel);
|
||||
pManager->AddDiscreteProcess(&theAntiSigmaMinusInelastic);
|
||||
|
||||
pManager->AddProcess(&theAntiSigmaMinusIonisation, ordInActive,2, 2);
|
||||
|
||||
pManager->AddProcess(&theAntiSigmaMinusMult);
|
||||
pManager->SetProcessOrdering(&theAntiSigmaMinusMult, idxAlongStep, 1);
|
||||
pManager->SetProcessOrdering(&theAntiSigmaMinusMult, idxPostStep, 1);
|
||||
|
||||
// SigmaPlus
|
||||
pManager = G4SigmaPlus::SigmaPlus()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLESigmaPlusModel = new G4LESigmaPlusInelastic();
|
||||
theHESigmaPlusModel = new G4HESigmaPlusInelastic();
|
||||
theSigmaPlusInelastic.RegisterMe(theLESigmaPlusModel);
|
||||
theSigmaPlusInelastic.RegisterMe(theHESigmaPlusModel);
|
||||
pManager->AddDiscreteProcess(&theSigmaPlusInelastic);
|
||||
|
||||
pManager->AddProcess(&theSigmaPlusIonisation, ordInActive,2, 2);
|
||||
|
||||
pManager->AddProcess(&theSigmaPlusMult);
|
||||
pManager->SetProcessOrdering(&theSigmaPlusMult, idxAlongStep, 1);
|
||||
pManager->SetProcessOrdering(&theSigmaPlusMult, idxPostStep, 1);
|
||||
|
||||
// anti-SigmaPlus
|
||||
pManager = G4AntiSigmaPlus::AntiSigmaPlus()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEAntiSigmaPlusModel = new G4LEAntiSigmaPlusInelastic();
|
||||
theHEAntiSigmaPlusModel = new G4HEAntiSigmaPlusInelastic();
|
||||
theAntiSigmaPlusInelastic.RegisterMe(theLEAntiSigmaPlusModel);
|
||||
theAntiSigmaPlusInelastic.RegisterMe(theHEAntiSigmaPlusModel);
|
||||
pManager->AddDiscreteProcess(&theAntiSigmaPlusInelastic);
|
||||
|
||||
pManager->AddProcess(&theAntiSigmaPlusIonisation, ordInActive,2, 2);
|
||||
|
||||
pManager->AddProcess(&theAntiSigmaPlusMult);
|
||||
pManager->SetProcessOrdering(&theAntiSigmaPlusMult, idxAlongStep, 1);
|
||||
pManager->SetProcessOrdering(&theAntiSigmaPlusMult, idxPostStep, 1);
|
||||
|
||||
// XiMinus
|
||||
pManager = G4XiMinus::XiMinus()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEXiMinusModel = new G4LEXiMinusInelastic();
|
||||
theHEXiMinusModel = new G4HEXiMinusInelastic();
|
||||
theXiMinusInelastic.RegisterMe(theLEXiMinusModel);
|
||||
theXiMinusInelastic.RegisterMe(theHEXiMinusModel);
|
||||
pManager->AddDiscreteProcess(&theXiMinusInelastic);
|
||||
|
||||
pManager->AddProcess(&theXiMinusIonisation, ordInActive,2, 2);
|
||||
|
||||
pManager->AddProcess(&theXiMinusMult);
|
||||
pManager->SetProcessOrdering(&theXiMinusMult, idxAlongStep, 1);
|
||||
pManager->SetProcessOrdering(&theXiMinusMult, idxPostStep, 1);
|
||||
|
||||
// anti-XiMinus
|
||||
pManager = G4AntiXiMinus::AntiXiMinus()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEAntiXiMinusModel = new G4LEAntiXiMinusInelastic();
|
||||
theHEAntiXiMinusModel = new G4HEAntiXiMinusInelastic();
|
||||
theAntiXiMinusInelastic.RegisterMe(theLEAntiXiMinusModel);
|
||||
theAntiXiMinusInelastic.RegisterMe(theHEAntiXiMinusModel);
|
||||
pManager->AddDiscreteProcess(&theAntiXiMinusInelastic);
|
||||
|
||||
pManager->AddProcess(&theAntiXiMinusIonisation, ordInActive,2, 2);
|
||||
|
||||
pManager->AddProcess(&theAntiXiMinusMult);
|
||||
pManager->SetProcessOrdering(&theAntiXiMinusMult, idxAlongStep, 1);
|
||||
pManager->SetProcessOrdering(&theAntiXiMinusMult, idxPostStep, 1);
|
||||
|
||||
// XiZero
|
||||
pManager = G4XiZero::XiZero()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEXiZeroModel = new G4LEXiZeroInelastic();
|
||||
theHEXiZeroModel = new G4HEXiZeroInelastic();
|
||||
theXiZeroInelastic.RegisterMe(theLEXiZeroModel);
|
||||
theXiZeroInelastic.RegisterMe(theHEXiZeroModel);
|
||||
pManager->AddDiscreteProcess(&theXiZeroInelastic);
|
||||
|
||||
// anti-XiZero
|
||||
pManager = G4AntiXiZero::AntiXiZero()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEAntiXiZeroModel = new G4LEAntiXiZeroInelastic();
|
||||
theHEAntiXiZeroModel = new G4HEAntiXiZeroInelastic();
|
||||
theAntiXiZeroInelastic.RegisterMe(theLEAntiXiZeroModel);
|
||||
theAntiXiZeroInelastic.RegisterMe(theHEAntiXiZeroModel);
|
||||
pManager->AddDiscreteProcess(&theAntiXiZeroInelastic);
|
||||
|
||||
// OmegaMinus
|
||||
pManager = G4OmegaMinus::OmegaMinus()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEOmegaMinusModel = new G4LEOmegaMinusInelastic();
|
||||
theHEOmegaMinusModel = new G4HEOmegaMinusInelastic();
|
||||
theOmegaMinusInelastic.RegisterMe(theLEOmegaMinusModel);
|
||||
theOmegaMinusInelastic.RegisterMe(theHEOmegaMinusModel);
|
||||
pManager->AddDiscreteProcess(&theOmegaMinusInelastic);
|
||||
|
||||
pManager->AddProcess(&theOmegaMinusIonisation, ordInActive,2, 2);
|
||||
|
||||
pManager->AddProcess(&theOmegaMinusMult);
|
||||
pManager->SetProcessOrdering(&theOmegaMinusMult, idxAlongStep, 1);
|
||||
pManager->SetProcessOrdering(&theOmegaMinusMult, idxPostStep, 1);
|
||||
|
||||
// anti-OmegaMinus
|
||||
pManager = G4AntiOmegaMinus::AntiOmegaMinus()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
theLEAntiOmegaMinusModel = new G4LEAntiOmegaMinusInelastic();
|
||||
theHEAntiOmegaMinusModel = new G4HEAntiOmegaMinusInelastic();
|
||||
theAntiOmegaMinusInelastic.RegisterMe(theLEAntiOmegaMinusModel);
|
||||
theAntiOmegaMinusInelastic.RegisterMe(theHEAntiOmegaMinusModel);
|
||||
pManager->AddDiscreteProcess(&theAntiOmegaMinusInelastic);
|
||||
|
||||
pManager->AddProcess(&theAntiOmegaMinusIonisation, ordInActive,2, 2);
|
||||
|
||||
pManager->AddProcess(&theAntiOmegaMinusMult);
|
||||
pManager->SetProcessOrdering(&theAntiOmegaMinusMult, idxAlongStep, 1);
|
||||
pManager->SetProcessOrdering(&theAntiOmegaMinusMult, idxPostStep, 1);
|
||||
|
||||
}
|
103
geant4/LEMuSR/src/LEMuSRIonPhysics.cc
Normal file
103
geant4/LEMuSR/src/LEMuSRIonPhysics.cc
Normal file
@ -0,0 +1,103 @@
|
||||
// $Id$
|
||||
// GEANT4 tag $Name$
|
||||
//
|
||||
//
|
||||
|
||||
#include "LEMuSRIonPhysics.hh"
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
LEMuSRIonPhysics::LEMuSRIonPhysics(const G4String& name)
|
||||
: G4VPhysicsConstructor(name)
|
||||
{
|
||||
}
|
||||
|
||||
LEMuSRIonPhysics::~LEMuSRIonPhysics()
|
||||
{
|
||||
}
|
||||
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
|
||||
// Nuclei
|
||||
#include "G4IonConstructor.hh"
|
||||
|
||||
void LEMuSRIonPhysics::ConstructParticle()
|
||||
{
|
||||
// Construct light ions
|
||||
G4IonConstructor pConstructor;
|
||||
pConstructor.ConstructParticle();
|
||||
}
|
||||
|
||||
|
||||
#include "G4ProcessManager.hh"
|
||||
|
||||
|
||||
void LEMuSRIonPhysics::ConstructProcess()
|
||||
{
|
||||
G4ProcessManager * pManager = 0;
|
||||
|
||||
// Elastic Process
|
||||
theElasticModel = new G4LElastic();
|
||||
theElasticProcess.RegisterMe(theElasticModel);
|
||||
|
||||
// Generic Ion
|
||||
pManager = G4GenericIon::GenericIon()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
pManager->AddProcess(&fIonMultipleScattering, -1, 1, 1);
|
||||
pManager->AddProcess(&fIonIonisation, -1, 2, 2);
|
||||
|
||||
// Deuteron
|
||||
pManager = G4Deuteron::Deuteron()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
fDeuteronModel = new G4LEDeuteronInelastic();
|
||||
fDeuteronProcess.RegisterMe(fDeuteronModel);
|
||||
pManager->AddDiscreteProcess(&fDeuteronProcess);
|
||||
|
||||
pManager->AddProcess(&fDeuteronMultipleScattering, -1, 1, 1);
|
||||
pManager->AddProcess(&fDeuteronIonisation, -1, 2, 2);
|
||||
|
||||
// Triton
|
||||
pManager = G4Triton::Triton()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
fTritonModel = new G4LETritonInelastic();
|
||||
fTritonProcess.RegisterMe(fTritonModel);
|
||||
pManager->AddDiscreteProcess(&fTritonProcess);
|
||||
|
||||
pManager->AddProcess(&fTritonMultipleScattering, -1, 1, 1);
|
||||
pManager->AddProcess(&fTritonIonisation, -1, 2, 2);
|
||||
|
||||
// Alpha
|
||||
pManager = G4Alpha::Alpha()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
fAlphaModel = new G4LEAlphaInelastic();
|
||||
fAlphaProcess.RegisterMe(fAlphaModel);
|
||||
pManager->AddDiscreteProcess(&fAlphaProcess);
|
||||
|
||||
pManager->AddProcess(&fAlphaMultipleScattering, -1, 1, 1);
|
||||
pManager->AddProcess(&fAlphaIonisation, -1, 2, 2);
|
||||
|
||||
// He3
|
||||
pManager = G4He3::He3()->GetProcessManager();
|
||||
// add process
|
||||
pManager->AddDiscreteProcess(&theElasticProcess);
|
||||
|
||||
pManager->AddProcess(&fHe3MultipleScattering, -1, 1, 1);
|
||||
pManager->AddProcess(&fHe3Ionisation, -1, 2, 2);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
1116
geant4/LEMuSR/src/LEMuSRMSC.cc
Normal file
1116
geant4/LEMuSR/src/LEMuSRMSC.cc
Normal file
File diff suppressed because it is too large
Load Diff
140
geant4/LEMuSR/src/LEMuSRMUONIUM.cc
Normal file
140
geant4/LEMuSR/src/LEMuSRMUONIUM.cc
Normal file
@ -0,0 +1,140 @@
|
||||
|
||||
#include "LEMuSRMUONIUM.hh"
|
||||
#include "G4StepStatus.hh"
|
||||
#include "G4Navigator.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4ProductionCutsTable.hh"
|
||||
|
||||
|
||||
#include "meyer.h"
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
using namespace std;
|
||||
|
||||
LEMuSRMUONIUM:: LEMuSRMUONIUM(const G4String& name ,
|
||||
G4ProcessType aType )
|
||||
: G4VDiscreteProcess(name, aType)
|
||||
{}
|
||||
|
||||
|
||||
LEMuSRMUONIUM:: ~LEMuSRMUONIUM()
|
||||
{}
|
||||
|
||||
|
||||
G4VParticleChange* LEMuSRMUONIUM::PostStepDoIt(
|
||||
const G4Track& trackData,
|
||||
const G4Step& aStep )
|
||||
{
|
||||
// Initialize ParticleChange (by setting all its members equal
|
||||
// to corresponding members in G4Track)
|
||||
fParticleChange.Initialize(trackData);
|
||||
|
||||
|
||||
G4Track theNewTrack;
|
||||
if( CheckCondition(aStep))
|
||||
{
|
||||
GetDatas(&aStep);
|
||||
G4Step theStep;
|
||||
PrepareSecondary( trackData);
|
||||
|
||||
fParticleChange.AddSecondary(aSecondary);
|
||||
fParticleChange.ProposeTrackStatus(fStopAndKill) ;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
fParticleChange.ProposeTrackStatus(trackData.GetTrackStatus()) ;
|
||||
}
|
||||
|
||||
return &fParticleChange;
|
||||
}
|
||||
|
||||
|
||||
G4bool LEMuSRMUONIUM::CheckCondition( const G4Step& aStep)
|
||||
{
|
||||
G4bool condition=false;
|
||||
p_name = aStep.GetTrack()->GetDefinition()->GetParticleName(); // particle name
|
||||
if(p_name == "mu+"&&aStep.GetTrack()->GetVolume()->GetLogicalVolume()->GetName()=="lv_CFOIL")
|
||||
{
|
||||
condition=true;
|
||||
}
|
||||
|
||||
return condition;
|
||||
|
||||
}
|
||||
|
||||
|
||||
G4double LEMuSRMUONIUM:: GetMeanFreePath(const G4Track& ,
|
||||
G4double ,
|
||||
G4ForceCondition* condition
|
||||
)
|
||||
{
|
||||
|
||||
*condition = Forced;
|
||||
return DBL_MAX;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
|
||||
|
||||
void LEMuSRMUONIUM::GetDatas( const G4Step* aStep)
|
||||
{
|
||||
|
||||
// Particle generation according to yields
|
||||
particleTable=G4ParticleTable::GetParticleTable();
|
||||
rnd=G4UniformRand();
|
||||
// std::cout<<"rnd : "<<rnd <<std::endl;
|
||||
G4double E = aStep->GetTrack()->GetDynamicParticle()
|
||||
->GetKineticEnergy()/keV; //LEMuSRPrimaryGeneratorAction::GetPGA()->energy/keV+LEMuSRPrimaryGeneratorAction::GetPGA()->ke_offset/keV;
|
||||
Gonin.GetYields(E,105*1000,yvector);
|
||||
|
||||
|
||||
G4String p_new="Mu";
|
||||
// MUON PLUS
|
||||
|
||||
if(p_name=="mu+")
|
||||
{
|
||||
if(rnd<yvector[0])
|
||||
{
|
||||
particle = particleTable->FindParticle(p_name) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
particle = particleTable->FindParticle(p_new);
|
||||
}
|
||||
|
||||
// Set the new dynamic particle
|
||||
|
||||
|
||||
|
||||
|
||||
DP = new G4DynamicParticle(particle,
|
||||
aStep->GetTrack()->GetDynamicParticle()
|
||||
->GetMomentumDirection(),
|
||||
|
||||
aStep->GetTrack()->GetDynamicParticle()
|
||||
->GetKineticEnergy()
|
||||
);
|
||||
// IMPORTANT : COPY THOSE DATA TO GET THE SAME PARTICLE PROPERTIES!!!!
|
||||
// SHOULD BE KEPT WHEN BUILDING A PARTICLE CHANGE
|
||||
DP->SetProperTime(aStep->GetTrack()->GetDynamicParticle()->GetProperTime());
|
||||
DP->SetPolarization(aStep->GetTrack()->GetDynamicParticle()->GetPolarization().x(),aStep->GetTrack()->GetDynamicParticle()->GetPolarization().y(),aStep->GetTrack()->GetDynamicParticle()->GetPolarization().z());
|
||||
DP->SetPreAssignedDecayProperTime(aStep->GetTrack()->GetDynamicParticle()->GetPreAssignedDecayProperTime());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
|
||||
void LEMuSRMUONIUM::PrepareSecondary(const G4Track& track)
|
||||
{
|
||||
if(p_name=="mu+")
|
||||
{
|
||||
aSecondary = new G4Track(DP,track.GetGlobalTime(),track.GetPosition());
|
||||
}
|
||||
|
||||
|
||||
}
|
125
geant4/LEMuSR/src/LEMuSRMUONIUMScatt.cc
Normal file
125
geant4/LEMuSR/src/LEMuSRMUONIUMScatt.cc
Normal file
@ -0,0 +1,125 @@
|
||||
#include "LEMuSRMUONIUMScatt.hh"
|
||||
#include "G4StepStatus.hh"
|
||||
#include "G4Navigator.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4ProductionCutsTable.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
using namespace std;
|
||||
|
||||
LEMuSRMUONIUMScatt:: LEMuSRMUONIUMScatt(const G4String& name ,
|
||||
G4ProcessType aType )
|
||||
: G4VDiscreteProcess(name, aType)
|
||||
{}
|
||||
|
||||
|
||||
LEMuSRMUONIUMScatt:: ~LEMuSRMUONIUMScatt()
|
||||
{}
|
||||
|
||||
|
||||
G4VParticleChange* LEMuSRMUONIUMScatt::PostStepDoIt(
|
||||
const G4Track& trackData,
|
||||
const G4Step& aStep )
|
||||
{
|
||||
fParticleChange.Initialize(trackData);
|
||||
|
||||
// tao :: Get Time
|
||||
G4double itime = trackData.GetProperTime();
|
||||
G4double gtime = trackData.GetGlobalTime();
|
||||
G4double ftime = trackData.GetDynamicParticle()->GetPreAssignedDecayProperTime();
|
||||
|
||||
G4double deltatime = ftime - itime;
|
||||
fParticleChange.ProposeGlobalTime(deltatime + itime -gtime);
|
||||
|
||||
// set position momentum energy
|
||||
fParticleChange.ProposePosition(trackData.GetPosition());
|
||||
fParticleChange.ProposeMomentumDirection(trackData.GetMomentumDirection());
|
||||
fParticleChange.ProposeEnergy(trackData.GetKineticEnergy());
|
||||
fParticleChange.ProposeGlobalTime(gtime);
|
||||
fParticleChange.ProposeProperTime(itime);
|
||||
fParticleChange.ProposeTrackStatus(trackData.GetTrackStatus()) ;
|
||||
|
||||
if( CheckCondition(aStep))
|
||||
{
|
||||
// fParticleChange.ProposeEnergy(0);
|
||||
fParticleChange.ProposePosition(trackData.GetStep()->GetPreStepPoint()->GetPosition());
|
||||
|
||||
fParticleChange.ProposePolarization(trackData.GetPolarization());
|
||||
// G4cout<<" at rest "<< trackData.GetStep()->GetPreStepPoint()->GetPosition() <<G4endl;
|
||||
fParticleChange.ProposeTrackStatus(fStopButAlive) ;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
fParticleChange.ProposePolarization(trackData.GetPolarization());
|
||||
}
|
||||
// fParticleChange.DumpInfo();
|
||||
return &fParticleChange;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4bool LEMuSRMUONIUMScatt::CheckCondition( const G4Step& aStep)
|
||||
{
|
||||
G4bool condition=false;
|
||||
p_name = aStep.GetTrack()->GetDefinition()->GetParticleName(); // particle name
|
||||
if(p_name == "Mu"&&aStep.GetTrack()->GetVolume()->GetLogicalVolume()->GetName()!="lv_CFOIL"&&aStep.GetTrack()->GetVolume()->GetLogicalVolume()->GetMaterial()->GetName()!="vacuum")
|
||||
{
|
||||
condition=true;
|
||||
}
|
||||
|
||||
return condition;
|
||||
|
||||
}
|
||||
|
||||
|
||||
G4double LEMuSRMUONIUMScatt:: GetMeanFreePath(const G4Track& ,
|
||||
G4double ,
|
||||
G4ForceCondition* condition
|
||||
)
|
||||
{
|
||||
|
||||
*condition = Forced;
|
||||
return DBL_MAX;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void LEMuSRMUONIUMScatt::GetDatas( const G4Step* aStep)
|
||||
{
|
||||
|
||||
// Particle generation according to yields
|
||||
particleTable=G4ParticleTable::GetParticleTable();
|
||||
particle = particleTable->FindParticle("Mu");
|
||||
|
||||
// Set the new dynamic particle
|
||||
DP = new G4DynamicParticle(particle,
|
||||
aStep->GetTrack()->GetDynamicParticle()
|
||||
->GetMomentumDirection(),0.0/*the kinectic energy set to zero*/
|
||||
);
|
||||
|
||||
|
||||
DP->SetProperTime(aStep->GetTrack()->GetDynamicParticle()->GetPreAssignedDecayProperTime());
|
||||
DP->SetPolarization(aStep->GetTrack()->GetDynamicParticle()->GetPolarization().x(),aStep->GetTrack()->GetDynamicParticle()->GetPolarization().y(),aStep->GetTrack()->GetDynamicParticle()->GetPolarization().z());
|
||||
DP->SetPreAssignedDecayProperTime(aStep->GetTrack()->GetDynamicParticle()->GetPreAssignedDecayProperTime());
|
||||
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
|
||||
void LEMuSRMUONIUMScatt::PrepareSecondary(const G4Track& track)
|
||||
{
|
||||
aSecondary = new G4Track(DP,track.GetDynamicParticle()->GetPreAssignedDecayProperTime(),track.GetPosition());
|
||||
|
||||
|
||||
;}
|
121
geant4/LEMuSR/src/LEMuSRMag_SpinEqRhs.cc
Normal file
121
geant4/LEMuSR/src/LEMuSRMag_SpinEqRhs.cc
Normal file
@ -0,0 +1,121 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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$
|
||||
// GEANT4 tag $Name$
|
||||
//
|
||||
// This is the standard right-hand side for equation of motion.
|
||||
// This version of the right-hand side includes the three components
|
||||
// of the particle's spin.
|
||||
//
|
||||
// J. Apostolakis, February 8th, 1999
|
||||
// P. Gumplinger, February 8th, 1999
|
||||
// D. Cote-Ahern, P. Gumplinger, April 11th, 2001
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "LEMuSRMag_SpinEqRhs.hh"
|
||||
#include "G4MagneticField.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
|
||||
|
||||
LEMuSRMag_SpinEqRhs::LEMuSRMag_SpinEqRhs( G4MagneticField* MagField )
|
||||
: G4Mag_EqRhs( MagField ) {}
|
||||
|
||||
LEMuSRMag_SpinEqRhs::~LEMuSRMag_SpinEqRhs() {}
|
||||
|
||||
void
|
||||
LEMuSRMag_SpinEqRhs::SetChargeMomentumMass(G4double particleCharge, // in e+ units
|
||||
G4double MomentumXc,
|
||||
G4double mass)
|
||||
{
|
||||
// To set fCof_val
|
||||
G4Mag_EqRhs::SetChargeMomentumMass(particleCharge, MomentumXc, mass);
|
||||
|
||||
omegac = 0.105658387*GeV/mass * 2.837374841e-3*(rad/cm/kilogauss);
|
||||
anomaly = 1.165923e-3;
|
||||
ParticleCharge = particleCharge;
|
||||
|
||||
E = sqrt(sqr(MomentumXc)+sqr(mass));
|
||||
beta = MomentumXc/E;
|
||||
gamma = E/mass;
|
||||
|
||||
// G4cout<<"LEMuSRMAg_SpinEqRhs :: mass" << mass/g << " \n";
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
LEMuSRMag_SpinEqRhs::EvaluateRhsGivenB( const G4double y[],
|
||||
const G4double B[3],
|
||||
G4double dydx[] ) const
|
||||
{
|
||||
G4double momentum_mag_square = sqr(y[3]) + sqr(y[4]) + sqr(y[5]);
|
||||
// G4cout << "\n------------ LEMuSRMAg_SpinEqRhs :: mommagnitude : "<< sqrt(momentum_mag_square) <<"\n";
|
||||
G4double inv_momentum_magnitude = 1.0 / sqrt( momentum_mag_square );
|
||||
G4double cof = FCof()*inv_momentum_magnitude;
|
||||
|
||||
dydx[0] = y[3] * inv_momentum_magnitude; // (d/ds)x = Vx/V
|
||||
dydx[1] = y[4] * inv_momentum_magnitude; // (d/ds)y = Vy/V
|
||||
dydx[2] = y[5] * inv_momentum_magnitude; // (d/ds)z = Vz/V
|
||||
dydx[3] = cof*(y[4]*B[2] - y[5]*B[1]) ; // Ax = a*(Vy*Bz - Vz*By)
|
||||
dydx[4] = cof*(y[5]*B[0] - y[3]*B[2]) ; // Ay = a*(Vz*Bx - Vx*Bz)
|
||||
dydx[5] = cof*(y[3]*B[1] - y[4]*B[0]) ; // Az = a*(Vx*By - Vy*Bx)
|
||||
|
||||
|
||||
G4ThreeVector pos(y[0], y[1], y[2]);
|
||||
|
||||
G4ThreeVector u(y[3], y[4], y[5]);
|
||||
u *= inv_momentum_magnitude;
|
||||
|
||||
G4ThreeVector BField(B[0],B[1],B[2]);
|
||||
|
||||
G4double udb = anomaly*beta*gamma/(1.+gamma) * (BField * u);
|
||||
G4double ucb = (anomaly+1./gamma)/beta;
|
||||
|
||||
// Initialise the values of dydx that we do not update.
|
||||
dydx[6] = dydx[7] = dydx[8] = 0.0;
|
||||
|
||||
G4ThreeVector Spin(y[9],y[10],y[11]);
|
||||
G4ThreeVector dSpin;
|
||||
|
||||
dSpin = 0;//ParticleCharge*omegac*(ucb*(Spin.cross(BField))-udb*(Spin.cross(u)));
|
||||
|
||||
|
||||
dydx[ 9] = dSpin.x();
|
||||
dydx[10] = dSpin.y();
|
||||
dydx[11] = dSpin.z();
|
||||
//G4cout<<"LEMuSRMAg_SpinEqRhs :: dydx" << Spin*u << " \n";
|
||||
|
||||
// G4cout<<"LEMuSRMAg_SpinEqRhs :: dydx \n"
|
||||
// << dydx[0] <<" " << dydx[1] <<" "<< dydx[2] <<" "<<"\n"
|
||||
// << dydx[3] <<" " << dydx[4] <<" "<< dydx[5] <<" "<<"\n"
|
||||
// << dydx[6] <<" " << dydx[7] <<" "<< dydx[8] <<" "<<"\n"
|
||||
// << dydx[9] <<" " << dydx[10] <<" "<< dydx[11] <<" "<<"\n";
|
||||
|
||||
|
||||
// G4cout<<"LEMuSRMAg_SpinEqRhs ::" << pos <<"\n" << u <<"\n" << Spin <<"\n" << BField <<"\n" <<Spin*BField <<"\n" << Spin*u <<"\n"<< dSpin.x() <<" "<< dSpin.y() <<" "<< dSpin.z() <<" \n-----------------------";
|
||||
|
||||
// getchar();
|
||||
return ;
|
||||
}
|
||||
|
44
geant4/LEMuSR/src/LEMuSRMagneticField.cc
Normal file
44
geant4/LEMuSR/src/LEMuSRMagneticField.cc
Normal file
@ -0,0 +1,44 @@
|
||||
#include "LEMuSRMagneticField.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <iomanip.h>
|
||||
|
||||
|
||||
LEMuSRMagneticField::LEMuSRMagneticField(const G4ThreeVector FieldVector)
|
||||
:G4UniformMagField(FieldVector )
|
||||
{
|
||||
BField=FieldVector;
|
||||
|
||||
}
|
||||
|
||||
|
||||
LEMuSRMagneticField::~LEMuSRMagneticField()
|
||||
{;}
|
||||
|
||||
|
||||
void LEMuSRMagneticField::GetFieldValue (const G4double pos[4],
|
||||
G4double *field ) const
|
||||
{
|
||||
|
||||
|
||||
|
||||
field[0]= 0.0;
|
||||
field[1]= 0.0;
|
||||
field[2]= 0.0;
|
||||
|
||||
G4double X,Y,Z,factor;
|
||||
|
||||
X= pos[0];Y=pos[1];Z=pos[2]*mm;
|
||||
// G4cout<<"\n"<<pos[0]<<" "<<pos[1]<<" "<<pos[2]<<G4endl;
|
||||
if(Z<20*cm&&Z>-20*cm)
|
||||
{ //G4cout<<"true!";
|
||||
factor=exp((-Z*Z)/(10*cm*10*cm));
|
||||
field[0]= BField.x()*factor ;//TAO
|
||||
field[1]= BField.y()*factor ;
|
||||
field[2]= BField.z()*factor ;
|
||||
|
||||
//G4cout<<"true!"<<field[0]/gauss<<"gauss"<<field[1]/gauss<< "gauss"<<field[2]/gauss<< "gauss"<<G4endl;getchar();
|
||||
// getchar();
|
||||
|
||||
}
|
||||
|
||||
}
|
451
geant4/LEMuSR/src/LEMuSRMaterials.cc
Normal file
451
geant4/LEMuSR/src/LEMuSRMaterials.cc
Normal file
@ -0,0 +1,451 @@
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID : LEMuSRDetectorConstruction.cc , v 1.0
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-06-24 16:33
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// DETECTOR CONSTRUCTION
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
|
||||
// G4 GEOMETRIC FORMS CLASSES
|
||||
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Trap.hh"
|
||||
#include "G4Cons.hh"
|
||||
#include "G4Sphere.hh"
|
||||
#include "G4SubtractionSolid.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
// G4 VOLUME DEFINITION CLASSES
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4PropagatorInField.hh"
|
||||
#include "LEMuSRMag_SpinEqRhs.hh"
|
||||
#include "G4Mag_SpinEqRhs.hh"
|
||||
#include "G4ChordFinder.hh"
|
||||
#include "G4El_UsualEqRhs.hh"
|
||||
#include "G4ClassicalRK4.hh"
|
||||
#include "G4SimpleHeum.hh"
|
||||
#include "G4SimpleRunge.hh"
|
||||
#include "G4MagIntegratorStepper.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
//#include "G4RotationMatrix.hh"
|
||||
|
||||
// G4 CLASSES
|
||||
#include "G4ios.hh"
|
||||
#include <iomanip.h>
|
||||
|
||||
|
||||
// HEADER
|
||||
#include "LEMuSRDetectorConstruction.hh"
|
||||
#include "LEMuSRDetectorMessenger.hh"
|
||||
|
||||
|
||||
// process remove
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleChange.hh"
|
||||
#include "G4ProcessVector.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4VProcess.hh"
|
||||
|
||||
// electric fieldmap
|
||||
#include "LEMuSRElectricField.hh"
|
||||
#include "LEMuSRElFieldMix.hh"
|
||||
#include "G4ElectricField.hh"
|
||||
#include "G4ElectroMagneticField.hh"
|
||||
#include "G4EqMagElectricField.hh"
|
||||
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
|
||||
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
// DEFINE COLOR AND USER LIMIT ATTRIBUTES
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
void LEMuSRDetectorConstruction :: LoadAttributes()
|
||||
{
|
||||
|
||||
// visual attributes
|
||||
|
||||
Blue_style = new G4VisAttributes(G4Colour(0.80,0.83,1.));
|
||||
Blue_style->SetForceSolid(true);
|
||||
//Blue_style->SetForceWireframe(false);
|
||||
fBlue_style = new G4VisAttributes(G4Colour(0.85,.88,0.92));
|
||||
fBlue_style->SetForceSolid(true);
|
||||
|
||||
|
||||
Red_style = new G4VisAttributes(G4Colour(1.0,0.,.0));
|
||||
Red_style->SetForceSolid(true);
|
||||
|
||||
oxsteel = new G4VisAttributes(G4Colour(0.9,0.8,0.75));
|
||||
oxsteel->SetForceSolid(true);
|
||||
|
||||
dRed_style = new G4VisAttributes(G4Colour(0.5,0.,.0));
|
||||
dRed_style->SetForceSolid(true);
|
||||
// dRed_style->SetForceWireframe(false);
|
||||
|
||||
Green_style = new G4VisAttributes(G4Colour(0.,1.,.0));
|
||||
Green_style->SetForceSolid(true);
|
||||
// Green_style->SetForceWireframe(false);
|
||||
|
||||
White_style = new G4VisAttributes(G4Colour(1.,1.,1.0));
|
||||
White_style->SetForceSolid(true);
|
||||
// White_style->SetForceWireframe(false);
|
||||
|
||||
lBlue_style = new G4VisAttributes(G4Colour(0.,.5,1.0));
|
||||
lBlue_style->SetForceSolid(true);
|
||||
|
||||
|
||||
dBlue_style = new G4VisAttributes(G4Colour(0.,.25,.5));
|
||||
dBlue_style->SetForceSolid(true);
|
||||
|
||||
Purple_style = new G4VisAttributes(G4Colour(1.,0.,1.0));
|
||||
Purple_style->SetForceSolid(true);
|
||||
// Purple_style->SetForceWireframe(false);
|
||||
|
||||
MCP_style = new G4VisAttributes(G4Colour(0.5,0.2,.7));
|
||||
MCP_style->SetForceSolid(true);
|
||||
// MCP_style->SetForceWireframe(false);
|
||||
|
||||
MACOR_style = new G4VisAttributes(G4Colour(0.9,0.9,.1));
|
||||
MACOR_style->SetForceSolid(true);
|
||||
// MACOR_style->SetForceWireframe(false);
|
||||
|
||||
SCINT_style = new G4VisAttributes(G4Colour(0.5,0.5,.75));
|
||||
SCINT_style->SetForceSolid(true);
|
||||
|
||||
dSCINT_style = new G4VisAttributes(G4Colour(0.3,0.3,.3));
|
||||
dSCINT_style->SetForceSolid(true);
|
||||
|
||||
|
||||
|
||||
|
||||
VTBB_style = new G4VisAttributes(G4Colour(0.9,0.9,.9));
|
||||
//VTBB_style->SetForceSolid(true);
|
||||
VTBB_style->SetForceWireframe(true);
|
||||
|
||||
// user limits
|
||||
VTBB_lim = new G4UserLimits();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
// MATERIALS DEFINITION
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
void LEMuSRDetectorConstruction :: MaterialsDefinition ()
|
||||
{
|
||||
|
||||
|
||||
|
||||
G4double a; // atomic mass
|
||||
G4double z; // atomic number
|
||||
G4double density; //
|
||||
G4String name, symbol; //
|
||||
G4int nbelements; // number of elements
|
||||
G4double fractionmass; // fractionnal mass - for mixtures
|
||||
|
||||
|
||||
|
||||
/*** ELEMENTS***/
|
||||
|
||||
|
||||
|
||||
// definition hydrogene
|
||||
a=1.01*g/mole;
|
||||
G4Element* H = new G4Element(name="hydrogen", symbol="H", z=1., a);
|
||||
|
||||
// definition boron
|
||||
a=10.811*g/mole;
|
||||
G4Element* B = new G4Element(name="boron", symbol="B", z=5., a);
|
||||
|
||||
|
||||
// definition carbon
|
||||
a=12.0107*g/mole;
|
||||
G4Element* C= new G4Element(name="carbone", symbol="C", z=6., a);
|
||||
|
||||
// definition nitrogen
|
||||
a=14.01*g/mole;
|
||||
G4Element* N = new G4Element(name="nitrogen", // le nom
|
||||
symbol="N", // le symbole
|
||||
z=7., // le numero atomique
|
||||
a); // la masse atomique
|
||||
|
||||
|
||||
// definition oxygene
|
||||
a=16.00*g/mole;
|
||||
G4Element* O = new G4Element(name="oxygen",symbol="O", z=8., a);
|
||||
|
||||
// definition sodium
|
||||
a=22.989770*g/mole;
|
||||
G4Element* Na= new G4Element(name="sodium", symbol="Na", z=11, a);
|
||||
|
||||
|
||||
// definition magnesium
|
||||
a=24.305*g/mole;
|
||||
G4Element* Mg= new G4Element ("magnesium","Mg", z=12,a) ;
|
||||
|
||||
// definition aluminium
|
||||
a=26.981538*g/mole;
|
||||
G4Element* Al= new G4Element(name="aluminium", symbol="Al", z=13, a);
|
||||
|
||||
// definition silicon
|
||||
a=28.0855*g/mole;
|
||||
G4Element* Si= new G4Element(name="silicon", symbol="Si", z=14., a);
|
||||
|
||||
// definition potassium
|
||||
a=39.0983*g/mole;
|
||||
G4Element* K= new G4Element(name="potassium", symbol="K", z=19., a);
|
||||
|
||||
// definition chromium
|
||||
a=51.9961*g/mole;
|
||||
G4Element* Cr= new G4Element(name="chromium", symbol="Cr", z=24., a);
|
||||
|
||||
// definition mangenese
|
||||
// a=54.938049*g/mole;
|
||||
// G4Element* Mn= new G4Element(name="manganese", symbol="Mn", z=25., a);
|
||||
|
||||
// definition iron
|
||||
a=55.847*g/mole;
|
||||
G4Element* Fe= new G4Element(name="fer", symbol="Fe", z=26., a);
|
||||
|
||||
// definition nickel
|
||||
a=58.6934*g/mole;
|
||||
G4Element* Ni= new G4Element(name="nickel", symbol="Ni", z=28., a);
|
||||
|
||||
// definition copper
|
||||
a=63.546*g/mole;
|
||||
G4Element* Cu= new G4Element(name="copper", symbol="Cu", z=29., a);
|
||||
|
||||
// definition zinc
|
||||
a=65.409*g/mole;
|
||||
G4Element* Zn= new G4Element(name="zinc", symbol="Zn", z=30., a);
|
||||
|
||||
// definition arsenic
|
||||
a=74.92160*g/mole;
|
||||
G4Element* As = new G4Element(name="arsenic", symbol="As", z=33., a);
|
||||
|
||||
// definition rubidium
|
||||
a=85.4678*g/mole;
|
||||
G4Element* Rb= new G4Element(name="rubidium", symbol="Rb", z=37., a);
|
||||
|
||||
//definition iodine
|
||||
a=126.90447*g/mole;
|
||||
G4Element* I = new G4Element(name="iodine", symbol="I", z=53., a);
|
||||
|
||||
//definition caesium
|
||||
a=132.90545*g/mole;
|
||||
G4Element* Cs = new G4Element(name="caesium", symbol="Cs", z=55., a);
|
||||
|
||||
//definition barium
|
||||
a=137.327*g/mole;
|
||||
G4Element* Ba= new G4Element(name="barium", symbol="Ba", z=56., a);
|
||||
|
||||
// definition tantalum
|
||||
a=180.95*g/mole;
|
||||
G4Element* Ta= new G4Element(name="tantalum", symbol="Ta", z=73., a);
|
||||
|
||||
// definition tungsten
|
||||
a=183.85*g/mole;
|
||||
G4Element* W= new G4Element(name="tungsten", symbol="W", z=74., a);
|
||||
|
||||
// definition gold
|
||||
a=196.97*g/mole;
|
||||
G4Element* Au= new G4Element(name="gold", symbol="Au", z=79., a);
|
||||
|
||||
// definition lead
|
||||
a=207.2*g/mole;
|
||||
G4Element* Pb= new G4Element(name="lead", symbol="Pb", z=82., a);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/***MATERIAUX***/
|
||||
|
||||
// definition : composition de Air
|
||||
density=1.290*mg/cm3;
|
||||
G4Material* Air= new G4Material(name="Air", density,nbelements=2);
|
||||
Air->AddElement (N, fractionmass=0.7);//fractionmass=G4double
|
||||
Air->AddElement (O, fractionmass=0.3);//fractionmass=G4double
|
||||
|
||||
|
||||
density=1.e-9*g/cm3;
|
||||
G4Material* vac= new G4Material(name="vac", density,nbelements=1);
|
||||
vac->AddMaterial (Air, fractionmass=1.);//fractionmass=G4double
|
||||
|
||||
|
||||
// vacuum
|
||||
density=1.e-15*g/cm3;
|
||||
/* G4Material* vacuum = new G4Material("vacuum", z=1., a=1.01*g/mole, density, kStateGas, 3.e-10*pascal, 2.73*kelvin);
|
||||
G4Material* vacuum2;
|
||||
vacuum2= vacuum;
|
||||
*/
|
||||
density= 2.376e-15*g/cm3;
|
||||
G4double temperature= 300*kelvin;
|
||||
G4double pressure= 3.0e-9*pascal;
|
||||
G4Material* vacuum = new G4Material(name="vacuum", density, nbelements=1,
|
||||
kStateGas,temperature,pressure);
|
||||
vacuum-> AddMaterial(Air, fractionmass= 1.);
|
||||
|
||||
//definition H2O=
|
||||
density = 1.000*g/cm3;
|
||||
G4Material* H2O = new G4Material(name="H2O", density, 2);
|
||||
H2O->AddElement (H, nbelements=2);//nbelements=G4int
|
||||
H2O->AddElement (O, nbelements=1);//nbelements=G4int
|
||||
|
||||
|
||||
|
||||
//definition materiau 'tantale'
|
||||
density = 16.650*g/cm3;
|
||||
G4Material* tantale = new G4Material(name="tantale", density, 1);
|
||||
tantale->AddElement (Ta, nbelements=1);
|
||||
|
||||
//definition materiau 'or'
|
||||
density = 19.300*g/cm3;
|
||||
G4Material* gold = new G4Material(name="gold", density, 1);
|
||||
gold->AddElement (Au, nbelements=1);
|
||||
|
||||
// definition materiau 'iron'
|
||||
density = 7.874*g/cm3;
|
||||
G4Material* iron = new G4Material("iron",density,1);
|
||||
iron->AddElement (Fe,1);
|
||||
|
||||
// definition materiau 'tungsten'
|
||||
density =19.250*g/cm3;
|
||||
G4Material* tungsten = new G4Material("tungsten",density,1);
|
||||
tungsten->AddElement(W,1);
|
||||
|
||||
|
||||
// definition : composition of Graphite
|
||||
density=2.*g/cm3;
|
||||
G4Material* graphite= new G4Material(name="graphite",density,1);
|
||||
graphite->AddElement (C,1);
|
||||
|
||||
|
||||
/***MATERIAUX***/
|
||||
|
||||
// definition composition of NaI
|
||||
density = 3.67*g/cm3;
|
||||
G4Material* NaI = new G4Material(name="NaI", density, 2);
|
||||
NaI->AddElement (Na, nbelements=1);//nbelements=G4int
|
||||
NaI->AddElement (I, nbelements=1);//nbelements=G4int
|
||||
|
||||
// definition composition of MgO
|
||||
density = 3.60*g/cm3;
|
||||
G4Material* MgO = new G4Material(name="MgO", density, 2);
|
||||
MgO->AddElement (Mg, nbelements=1);//nbelements=G4int
|
||||
MgO->AddElement (O, nbelements=1);//nbelements=G4int
|
||||
|
||||
// definition composition of K2O
|
||||
density = 2.350*g/cm3;
|
||||
G4Material* K2O = new G4Material(name="K2O", density, 2);
|
||||
K2O->AddElement (O, nbelements=1);
|
||||
K2O->AddElement (K, nbelements=2);
|
||||
|
||||
// definition composition of SiO2
|
||||
density = 2.533*g/cm3;
|
||||
G4Material* SiO2 = new G4Material(name="SiO2", density, 2);
|
||||
SiO2->AddElement (O, nbelements=2);
|
||||
SiO2->AddElement (Si, nbelements=1);
|
||||
|
||||
|
||||
// definition composition of B2O3
|
||||
density = 2.550*g/cm3;
|
||||
G4Material* B2O3 = new G4Material(name="B2O3", density, 2);
|
||||
B2O3->AddElement (B, nbelements=2);
|
||||
B2O3->AddElement (O, nbelements=3);
|
||||
|
||||
|
||||
// definition : composition of saphire //Al2-O3
|
||||
density=3.985*g/cm3;
|
||||
G4Material*saphire = new G4Material(name="saphire", density,2);
|
||||
saphire->AddElement (Al, nbelements=2);
|
||||
saphire->AddElement (O, nbelements=3);
|
||||
|
||||
//definition materiau 'copper'
|
||||
density = 8.920*g/cm3;
|
||||
G4Material* copper = new G4Material(name="copper", density, 1);
|
||||
copper->AddElement (Cu, nbelements=1);
|
||||
|
||||
// definition materiau 'aluminium'
|
||||
density = 2.700*g/cm3;
|
||||
G4Material* aluminium = new G4Material("aluminium",density,1);
|
||||
aluminium->AddElement (Al,1);
|
||||
|
||||
// definition composition de Brass
|
||||
density=8.67*g/cm3;
|
||||
G4Material* brass= new G4Material(name="brass", density,4);
|
||||
brass->AddElement (Cu, fractionmass=63./100.);
|
||||
brass->AddElement (Pb, fractionmass=3./100.);
|
||||
brass->AddElement (Fe, fractionmass=0.1/100.);
|
||||
brass->AddElement (Zn, fractionmass=33.9/100.);
|
||||
|
||||
|
||||
// definition composition de mcpglass
|
||||
density = 2.*g/cm3;
|
||||
G4Material* mcpglass = new G4Material(name="mcpglass", density, 9);
|
||||
mcpglass->AddElement (Pb, fractionmass= 0.48 );
|
||||
mcpglass->AddElement (O, fractionmass= 0.258 );
|
||||
mcpglass->AddElement (Si, fractionmass= 0.182 );
|
||||
mcpglass->AddElement (K, fractionmass= 0.042 );
|
||||
mcpglass->AddElement (Rb, fractionmass= 0.018 );
|
||||
mcpglass->AddElement (Ba, fractionmass= 0.013 );
|
||||
mcpglass->AddElement (As, fractionmass= 0.004 );
|
||||
mcpglass->AddElement (Cs, fractionmass= 0.002 );
|
||||
mcpglass->AddElement (Na, fractionmass= 0.001 );
|
||||
|
||||
// definition composition de scint
|
||||
density = 1.*g/cm3;
|
||||
G4Material* scint = new G4Material(name="scint", density, 2);
|
||||
scint->AddElement (C, fractionmass= 1/2.04 );
|
||||
scint->AddElement (H, fractionmass= 1.04/2.04);
|
||||
|
||||
// definition : composition de stainless_steel
|
||||
density=7.930*g/cm3;
|
||||
G4Material* stainless_steel= new G4Material(name="stainless_steel", density,3);
|
||||
stainless_steel->AddElement (Ni, fractionmass= 0.11);
|
||||
stainless_steel->AddElement (Cr, fractionmass= 0.18);
|
||||
stainless_steel->AddElement (Fe, fractionmass= 0.71);
|
||||
|
||||
|
||||
// definition : composition de macor
|
||||
density=2.52*g/cm3;
|
||||
G4Material* macor= new G4Material(name="macor", density,5);
|
||||
macor->AddMaterial (SiO2, fractionmass=0.47);
|
||||
macor->AddMaterial (saphire, fractionmass=0.17);
|
||||
macor->AddMaterial (MgO, fractionmass=0.18);
|
||||
macor->AddMaterial (K2O, fractionmass=0.105);
|
||||
macor->AddMaterial (B2O3, fractionmass=0.075);
|
||||
|
||||
// G4cout << *(G4Material::GetMaterialTable()) << G4endl;
|
||||
|
||||
}
|
||||
|
75
geant4/LEMuSR/src/LEMuSRMcpHit.cc
Normal file
75
geant4/LEMuSR/src/LEMuSRMcpHit.cc
Normal file
@ -0,0 +1,75 @@
|
||||
#include "LEMuSRMcpHit.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4Circle.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <fstream.h>
|
||||
#include <iomanip.h>
|
||||
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
G4Allocator<LEMuSRMcpHit> LEMuSRMcpHitAllocator;
|
||||
|
||||
LEMuSRMcpHit::LEMuSRMcpHit()
|
||||
{;}
|
||||
|
||||
LEMuSRMcpHit::~LEMuSRMcpHit()
|
||||
{;}
|
||||
|
||||
LEMuSRMcpHit::LEMuSRMcpHit(const LEMuSRMcpHit &right) : G4VHit()
|
||||
{
|
||||
particle_name = right.particle_name;
|
||||
energy_deposition = right.energy_deposition;
|
||||
time_of_flight = right.time_of_flight;
|
||||
position = right.position;
|
||||
momentum = right.momentum;
|
||||
}
|
||||
|
||||
const LEMuSRMcpHit& LEMuSRMcpHit::operator=(const LEMuSRMcpHit &right)
|
||||
{
|
||||
particle_name = right.particle_name;
|
||||
energy_deposition = right.energy_deposition;
|
||||
time_of_flight = right.time_of_flight;
|
||||
position = right.position;
|
||||
momentum = right.momentum;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4int LEMuSRMcpHit::operator==(const LEMuSRMcpHit &right) const
|
||||
{
|
||||
return (this==&right) ? 1 : 0;
|
||||
}
|
||||
|
||||
void LEMuSRMcpHit::Draw()
|
||||
{
|
||||
G4VVisManager* VisManager = G4VVisManager::GetConcreteInstance();
|
||||
if(VisManager)
|
||||
{
|
||||
G4Circle circle(position);
|
||||
circle.SetScreenSize(0.1);
|
||||
circle.SetFillStyle(G4Circle::filled);
|
||||
G4Colour colour(1.,1.,1.);
|
||||
G4VisAttributes attributes(colour);
|
||||
circle.SetVisAttributes(attributes);
|
||||
VisManager->Draw(circle);
|
||||
}
|
||||
}
|
||||
|
||||
void LEMuSRMcpHit::Print()
|
||||
{}
|
||||
|
||||
void LEMuSRMcpHit::print(G4String name)
|
||||
{
|
||||
ofstream TestPrint(name,ios::app);
|
||||
if (!TestPrint.is_open()) exit(8);
|
||||
TestPrint << "particle name : " << particle_name <<" ;\n "
|
||||
<< "energy_deposition : " << G4BestUnit(energy_deposition,"Energy") <<" ;\n "
|
||||
<< "time_of_flight : " << G4BestUnit(time_of_flight,"Time") <<" ;\n "
|
||||
<< "position : " << position <<" ;\n "
|
||||
<< "momentum : " << momentum <<" ;\n "
|
||||
<<G4endl;
|
||||
|
||||
}
|
226
geant4/LEMuSR/src/LEMuSRMcpSD.cc
Normal file
226
geant4/LEMuSR/src/LEMuSRMcpSD.cc
Normal file
@ -0,0 +1,226 @@
|
||||
#include "LEMuSRMcpSD.hh"
|
||||
#include "LEMuSRDetectorConstruction.hh"
|
||||
#include "G4HCofThisEvent.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4VProcess.hh"
|
||||
|
||||
// ROOT
|
||||
#include "TROOT.h"
|
||||
#include "TApplication.h"
|
||||
#include "TSystem.h"
|
||||
#include "TH1.h"
|
||||
#include "TPad.h"
|
||||
#include "TCanvas.h"
|
||||
#include "LEMuSRPrimaryGeneratorAction.hh"
|
||||
|
||||
LEMuSRMcpSD::LEMuSRMcpSD(G4String name)
|
||||
:G4VSensitiveDetector(name)
|
||||
{
|
||||
|
||||
G4String HCname;
|
||||
collectionName.insert(HCname="McpCollection");
|
||||
positionResolution = 0.1*mm;
|
||||
|
||||
|
||||
// ROOT
|
||||
BookRoot();
|
||||
}
|
||||
|
||||
LEMuSRMcpSD::~LEMuSRMcpSD()
|
||||
{
|
||||
// ROOT
|
||||
WriteRoot();
|
||||
}
|
||||
|
||||
void LEMuSRMcpSD::Initialize(G4HCofThisEvent* HCE)
|
||||
{
|
||||
static int HCID = -1;
|
||||
McpCollection = new LEMuSRMcpHitsCollection
|
||||
(SensitiveDetectorName,collectionName[0]);
|
||||
if(HCID<0)
|
||||
{ HCID = GetCollectionID(0); }
|
||||
HCE->AddHitsCollection(HCID,McpCollection);
|
||||
}
|
||||
|
||||
G4bool LEMuSRMcpSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
|
||||
{
|
||||
|
||||
p_name = aStep->GetTrack()->GetDefinition()->GetParticleName();
|
||||
|
||||
if( CheckCondition(aStep))
|
||||
{
|
||||
GetDatas(aStep);
|
||||
getHit();
|
||||
FillRoot();
|
||||
}
|
||||
|
||||
|
||||
//PrintAll();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void LEMuSRMcpSD::EndOfEvent(G4HCofThisEvent*)
|
||||
{
|
||||
/*
|
||||
G4int NbHits = McpCollection->entries();
|
||||
G4cout << "\n-------->Hits Collection: in this event they are " << NbHits
|
||||
<< " hits in the mcp: " << G4endl;
|
||||
for (G4int i=0;i<NbHits;i++) (*McpCollection)[i]->Print();
|
||||
*/
|
||||
}
|
||||
|
||||
G4bool LEMuSRMcpSD::CheckCondition(const G4Step* aStep)
|
||||
{
|
||||
|
||||
G4bool condition=false;
|
||||
mu=e=g=0;
|
||||
|
||||
|
||||
|
||||
if(aStep->GetPreStepPoint()->GetGlobalTime()/ns<1000.)
|
||||
{
|
||||
if(p_name == "e+"&&aStep->GetTrack()->GetNextVolume()->GetLogicalVolume()->GetName()!="lv_DMCP")
|
||||
{
|
||||
if( aStep->GetTrack()->GetCreatorProcess())
|
||||
{
|
||||
if( aStep->GetTrack()->GetCreatorProcess()->GetProcessName()=="Decay")
|
||||
{
|
||||
condition=false;//true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if(p_name == "proton")
|
||||
if(p_name == "mu+"||p_name == "Mu")
|
||||
{
|
||||
condition=true;
|
||||
if(p_name=="mu+")mu=1;
|
||||
if(p_name=="Mu")e=1;
|
||||
}
|
||||
if(p_name == "gamma")
|
||||
{
|
||||
g=1;
|
||||
condition=false;//true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return condition;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LEMuSRMcpSD::clear()
|
||||
{
|
||||
delete McpCollection;
|
||||
}
|
||||
|
||||
void LEMuSRMcpSD::DrawAll()
|
||||
{
|
||||
}
|
||||
|
||||
void LEMuSRMcpSD::PrintAll()
|
||||
{
|
||||
|
||||
// Define Hit
|
||||
|
||||
LEMuSRMcpHit* aHit;
|
||||
aHit = new LEMuSRMcpHit();
|
||||
|
||||
//++++++++++++++ set hit values _______________
|
||||
aHit->SetParticleName(p_name);
|
||||
aHit->SetSpin(spin);
|
||||
|
||||
aHit->SetMomentum( hitmom );
|
||||
aHit->SetPosition( hitpos );
|
||||
|
||||
aHit->SetTimeOfFlight( tof );
|
||||
aHit->SetEnergyDeposition( edep );
|
||||
|
||||
|
||||
// McpCollection->insert( aHit );
|
||||
// aHit->Print();
|
||||
// aHit->print("Statistics/SCIS.Hits");
|
||||
// aHit->Draw();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LEMuSRMcpSD::GetDatas(const G4Step *aStep)
|
||||
{
|
||||
// Get datas
|
||||
//a Volume, name, spin
|
||||
vname = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName();
|
||||
spin= aStep->GetTrack()->GetDefinition()->GetPDGSpin(); // spin in units of 1
|
||||
|
||||
//b Position momentum
|
||||
hitpos = aStep->GetPreStepPoint()->GetPosition()/cm; // position
|
||||
hitmom = aStep->GetPreStepPoint()->GetMomentumDirection(); // momentum
|
||||
|
||||
//c Times
|
||||
tof = aStep->GetPreStepPoint()->GetLocalTime()/ns; // time since track creation
|
||||
globaltime = aStep->GetPreStepPoint()->GetGlobalTime()/ns;// time since event creation
|
||||
proptime = aStep->GetTrack()->GetDynamicParticle()->GetProperTime()/ns; // particle's proper time
|
||||
|
||||
//d Energy
|
||||
edep = aStep->GetTotalEnergyDeposit();
|
||||
|
||||
toten = LEMuSRPrimaryGeneratorAction::GetPGA()->energy/keV;//aStep->GetTrack()->GetTotalEnergy();
|
||||
|
||||
kinen = aStep->GetPreStepPoint()->GetKineticEnergy();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LEMuSRMcpSD::getHit()
|
||||
{
|
||||
theHit.kenergy = kinen;
|
||||
theHit.tenergy = toten;
|
||||
theHit.edeposit = edep;
|
||||
theHit.localtime = tof;
|
||||
theHit.globaltime = globaltime;
|
||||
theHit.proptime = proptime;
|
||||
theHit.positionx = hitpos.x();
|
||||
theHit.positiony = hitpos.y();
|
||||
theHit.positionz = hitpos.z();
|
||||
theHit.momdirx = hitmom.x();
|
||||
theHit.momdiry = hitmom.y();
|
||||
theHit.momdirz = hitmom.z();
|
||||
theHit.foil = LEMuSRDetectorConstruction::GetInstance()->cfthk;
|
||||
theHit.muon = mu;
|
||||
theHit.positron = e;
|
||||
theHit.gamma = g;
|
||||
theHit.runid = G4RunManager::GetRunManager()->GetCurrentRun()->GetRunID();
|
||||
}
|
||||
|
||||
// ROOT METHODS
|
||||
|
||||
void LEMuSRMcpSD::BookRoot()
|
||||
{
|
||||
// open root file
|
||||
myFile = new TFile("SDMcp.root", "RECREATE");
|
||||
// myFile->SetCompressionLevel(1);
|
||||
|
||||
tree = new TTree ("tree"," Mcp Datas");
|
||||
|
||||
tree->Branch("mcpHit",&theHit.kenergy,"kenergy/F:init_energy/F:edeposit/F:localtime/F:globaltime:propertime/F:positionx/F:positiony:positionz:momentumx:momentumy:momentumz/F:foil/F:muon/I:muonium/I:gamma/I:ID/I");
|
||||
|
||||
}
|
||||
|
||||
void LEMuSRMcpSD::FillRoot()
|
||||
{
|
||||
tree->Fill();
|
||||
}
|
||||
|
||||
void LEMuSRMcpSD::WriteRoot()
|
||||
{
|
||||
myFile->Write();
|
||||
myFile->Close();
|
||||
}
|
||||
|
285
geant4/LEMuSR/src/LEMuSRMuonDecayChannel.cc
Normal file
285
geant4/LEMuSR/src/LEMuSRMuonDecayChannel.cc
Normal file
@ -0,0 +1,285 @@
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION Geant4 SIMULATION
|
||||
// ID : LEMuSRMuonDecayChannel.cc , v 1.2
|
||||
// AUTHOR: Taofiq PARAISO based on G4MuonDecayChannel $Id$
|
||||
// DATE : 2004-07-13 11:15
|
||||
//
|
||||
// add muonium decay, PARAISO 07/04/2005
|
||||
//
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// MUON DECAY CHANNEL.CC
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§////
|
||||
|
||||
|
||||
|
||||
#include "Randomize.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4DecayProducts.hh"
|
||||
#include "G4VDecayChannel.hh"
|
||||
#include "LEMuSRMuonDecayChannel.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4LorentzVector.hh"
|
||||
#include "G4LorentzRotation.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#include "LEMuSRAtRestSpinRotation.hh"
|
||||
|
||||
|
||||
LEMuSRMuonDecayChannel::LEMuSRMuonDecayChannel(const G4String& theParentName,
|
||||
G4double theBR)
|
||||
:G4VDecayChannel("LEMuSR Muon Decay",1)
|
||||
{
|
||||
|
||||
// set names for daughter particles
|
||||
if (theParentName == "mu+") {
|
||||
SetBR(theBR);
|
||||
SetParent("mu+");
|
||||
SetNumberOfDaughters(3);
|
||||
SetDaughter(0, "e+");
|
||||
SetDaughter(1, "nu_e");
|
||||
SetDaughter(2, "anti_nu_mu");
|
||||
|
||||
} else if (theParentName == "mu-") {
|
||||
SetBR(theBR);
|
||||
SetParent("mu-");
|
||||
SetNumberOfDaughters(3);
|
||||
SetDaughter(0, "e-");
|
||||
SetDaughter(1, "anti_nu_e");
|
||||
SetDaughter(2, "nu_mu");
|
||||
}
|
||||
else if (theParentName == "Mu") {
|
||||
SetBR(theBR);
|
||||
SetParent("Mu");
|
||||
SetNumberOfDaughters(3);
|
||||
SetDaughter(0, "e+");
|
||||
SetDaughter(1, "nu_e");
|
||||
SetDaughter(2, "anti_nu_mu");
|
||||
}
|
||||
else {
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if (GetVerboseLevel()>0) {
|
||||
G4cout << "LEMuSRMuonDecayChannel:: constructor :";
|
||||
G4cout << " parent particle is not muon but ";
|
||||
G4cout << theParentName << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// get the random number engine
|
||||
theEngine = HepRandom::getTheEngine();
|
||||
|
||||
|
||||
theParentPolarization=G4ThreeVector(0,0,0);
|
||||
pointer = this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
LEMuSRMuonDecayChannel* LEMuSRMuonDecayChannel::pointer=0;
|
||||
LEMuSRMuonDecayChannel* LEMuSRMuonDecayChannel::GetInstance()
|
||||
{
|
||||
return pointer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
LEMuSRMuonDecayChannel::~LEMuSRMuonDecayChannel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
G4DecayProducts *LEMuSRMuonDecayChannel::DecayItPolarized(G4double mass,G4ThreeVector polar)
|
||||
{
|
||||
SetParentPolarization(polar);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if (GetVerboseLevel()>2) {
|
||||
G4cout << "LEMuSRMuonDecayChannel:: theParentPolarization is" <<theParentPolarization <<G4endl;
|
||||
}
|
||||
#endif
|
||||
return DecayIt(mass);
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4DecayProducts *LEMuSRMuonDecayChannel::DecayIt(G4double)
|
||||
{
|
||||
|
||||
if(theParentPolarization == G4ThreeVector(0,0,0))
|
||||
{
|
||||
// Generate random theParentPolarization direction
|
||||
|
||||
G4double cost = 1. - 2.*G4UniformRand();
|
||||
G4double sint = std::sqrt((1.-cost)*(1.+cost));
|
||||
|
||||
G4double phi = twopi*G4UniformRand();
|
||||
G4double sinp = std::sin(phi);
|
||||
G4double cosp = std::cos(phi);
|
||||
|
||||
G4double px = sint*cosp;
|
||||
G4double py = sint*sinp;
|
||||
G4double pz = cost;
|
||||
|
||||
theParentPolarization.setX(px);
|
||||
theParentPolarization.setY(py);
|
||||
theParentPolarization.setZ(pz);
|
||||
|
||||
}
|
||||
// assumes the pure V-A coupling
|
||||
// gives incorrect energy spectrum for neutrinos
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if (GetVerboseLevel()>2) {
|
||||
G4cout << "LEMuSRMuonDecayChannel::DecayIt ";
|
||||
}
|
||||
#endif
|
||||
|
||||
if (parent == 0) FillParent();
|
||||
if (daughters == 0) FillDaughters();
|
||||
|
||||
// parent mass
|
||||
G4double parentmass = parent->GetPDGMass();
|
||||
|
||||
//daughters'mass
|
||||
G4double daughtermass[3];
|
||||
G4double sumofdaughtermass = 0.0;
|
||||
for (G4int index=0; index<3; index++){
|
||||
daughtermass[index] = daughters[index]->GetPDGMass();
|
||||
sumofdaughtermass += daughtermass[index];
|
||||
}
|
||||
|
||||
//create parent G4DynamicParticle at rest
|
||||
G4ThreeVector dummy;
|
||||
G4DynamicParticle * parentparticle = new G4DynamicParticle( parent, dummy, 0.0);
|
||||
//create G4Decayproducts
|
||||
G4DecayProducts *products = new G4DecayProducts(*parentparticle);
|
||||
delete parentparticle;
|
||||
|
||||
|
||||
// Calculate Positron energy
|
||||
|
||||
G4double daughtermomentum[3];
|
||||
G4double energy;
|
||||
G4double x; // maximal positron energy is 52.831MeV
|
||||
G4double r;
|
||||
|
||||
do {
|
||||
do {
|
||||
r = G4UniformRand();
|
||||
x = G4UniformRand();
|
||||
} while (r > (3.0 - 2.0*x)*x*x);
|
||||
|
||||
|
||||
energy = x*52.831*MeV;
|
||||
} while (energy <0.0|| energy > 52.831);
|
||||
|
||||
|
||||
|
||||
// Anglular Distribution
|
||||
|
||||
G4double energymax=52.831*MeV;
|
||||
G4double E=energy/energymax;
|
||||
|
||||
G4double D = (2*E-1)/(3-2*E);
|
||||
|
||||
// theta
|
||||
G4double K = G4UniformRand();
|
||||
costheta = 1/D*(-1.+ sqrt(1.-2*D*(2*K-1)+D*D));
|
||||
theta = acos(costheta);
|
||||
sintheta=sin(theta);
|
||||
|
||||
// phi
|
||||
phi = 2.0*M_PI*G4UniformRand()*rad;
|
||||
sinphi = sin(phi);
|
||||
cosphi = cos(phi);
|
||||
|
||||
// rotation angles
|
||||
G4double px = sintheta*sinphi;
|
||||
G4double py = sintheta*cosphi;
|
||||
G4double pz = costheta;
|
||||
|
||||
G4ThreeVector direction0(px,py,pz);
|
||||
|
||||
direction0.rotateUz(theParentPolarization);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if (GetVerboseLevel()>2) {
|
||||
G4cout << "LEMuSRMuonDecayChanel::DecayIt \n";
|
||||
G4cout <<"e+ momentum direction: " << direction0 <<G4endl;
|
||||
G4cout <<"energy: " <<energy <<G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
daughtermomentum[0] = sqrt(energy*energy + 2.0*energy* daughtermass[0]);
|
||||
|
||||
G4DynamicParticle * daughterparticle
|
||||
= new G4DynamicParticle( daughters[0], direction0*daughtermomentum[0]);
|
||||
daughterparticle->SetPolarization(theParentPolarization.x(),theParentPolarization.y(),theParentPolarization.z());
|
||||
products->PushProducts(daughterparticle);
|
||||
|
||||
|
||||
|
||||
// daughter 1 ,2 (neutrinos)
|
||||
// create neutrinos in the C.M frame of two neutrinos
|
||||
G4double energy2 = parentmass*(1.0 - x/2.0);
|
||||
G4double vmass = sqrt((energy2-daughtermomentum[0])*(energy2+daughtermomentum[0]));
|
||||
G4double beta = -1.0*daughtermomentum[0]/energy2;
|
||||
G4double costhetan = 2.*G4UniformRand()-1.0;
|
||||
G4double sinthetan = sqrt((1.0-costhetan)*(1.0+costhetan));
|
||||
G4double phin = 2.0*M_PI*G4UniformRand()*rad;
|
||||
G4double sinphin = sin(phin);
|
||||
G4double cosphin = cos(phin);
|
||||
|
||||
G4ThreeVector direction1(sinthetan*cosphin,sinthetan*sinphin,costhetan);
|
||||
G4DynamicParticle * daughterparticle1
|
||||
= new G4DynamicParticle( daughters[1], direction1*(vmass/2.));
|
||||
G4DynamicParticle * daughterparticle2
|
||||
= new G4DynamicParticle( daughters[2], direction1*(-1.0*vmass/2.));
|
||||
|
||||
// boost to the muon rest frame
|
||||
G4LorentzVector p4;
|
||||
p4 = daughterparticle1->Get4Momentum();
|
||||
p4.boost( direction0.x()*beta, direction0.y()*beta, direction0.z()*beta);
|
||||
daughterparticle1->Set4Momentum(p4);
|
||||
p4 = daughterparticle2->Get4Momentum();
|
||||
p4.boost( direction0.x()*beta, direction0.y()*beta, direction0.z()*beta);
|
||||
daughterparticle2->Set4Momentum(p4);
|
||||
products->PushProducts(daughterparticle1);
|
||||
products->PushProducts(daughterparticle2);
|
||||
daughtermomentum[1] = daughterparticle1->GetTotalMomentum();
|
||||
daughtermomentum[2] = daughterparticle2->GetTotalMomentum();
|
||||
|
||||
// output message
|
||||
#ifdef G4VERBOSE
|
||||
if (GetVerboseLevel()>2) {
|
||||
G4cout << "LEMuSRMuonDecayChanel::DecayIt ";
|
||||
G4cout << " THETA aNGLE ::" <<theta <<G4endl;
|
||||
G4cout << " PHI aNGLE ::" <<phi <<G4endl;
|
||||
|
||||
G4cout << " create decay products in rest frame: " <<G4endl;
|
||||
products->DumpInfo();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
return products;
|
||||
}
|
154
geant4/LEMuSR/src/LEMuSRMuonPhysics.cc
Normal file
154
geant4/LEMuSR/src/LEMuSRMuonPhysics.cc
Normal file
@ -0,0 +1,154 @@
|
||||
#include "LEMuSRMuonPhysics.hh"
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
LEMuSRMuonPhysics::LEMuSRMuonPhysics(const G4String& name)
|
||||
: G4VPhysicsConstructor(name)
|
||||
{
|
||||
}
|
||||
|
||||
LEMuSRMuonPhysics::~LEMuSRMuonPhysics()
|
||||
{
|
||||
}
|
||||
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
|
||||
#include "G4MuonPlus.hh"
|
||||
#include "G4Muonium.hh"
|
||||
#include "G4MuonMinus.hh"
|
||||
#include "G4TauMinus.hh"
|
||||
#include "G4TauPlus.hh"
|
||||
#include "G4NeutrinoTau.hh"
|
||||
#include "G4AntiNeutrinoTau.hh"
|
||||
#include "G4NeutrinoMu.hh"
|
||||
#include "G4AntiNeutrinoMu.hh"
|
||||
#include "LEMuSRMuonDecayChannel.hh"
|
||||
#include "G4UserSpecialCuts.hh"
|
||||
#include "G4DecayTable.hh"
|
||||
#include "G4MuonDecayChannelWithSpin.hh"
|
||||
|
||||
|
||||
|
||||
|
||||
void LEMuSRMuonPhysics::ConstructParticle()
|
||||
{
|
||||
// Mu
|
||||
G4MuonPlus::MuonPlusDefinition();
|
||||
G4Muonium::MuoniumDefinition();
|
||||
G4MuonMinus::MuonMinusDefinition();
|
||||
G4NeutrinoMu::NeutrinoMuDefinition();
|
||||
G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
|
||||
|
||||
// Tau
|
||||
G4TauMinus::TauMinusDefinition();
|
||||
G4TauPlus::TauPlusDefinition();
|
||||
G4NeutrinoTau::NeutrinoTauDefinition();
|
||||
G4AntiNeutrinoTau::AntiNeutrinoTauDefinition();
|
||||
|
||||
|
||||
#ifdef ASYM_USE_LEMU
|
||||
G4DecayTable* MuonPlusDecayTable = new G4DecayTable();
|
||||
MuonPlusDecayTable -> Insert(new LEMuSRMuonDecayChannel("mu+",1.00));
|
||||
G4MuonPlus::MuonPlusDefinition() -> SetDecayTable(MuonPlusDecayTable);
|
||||
|
||||
G4DecayTable* MuoniumDecayTable = new G4DecayTable();
|
||||
MuoniumDecayTable -> Insert(new LEMuSRMuonDecayChannel("Mu",0.5));
|
||||
MuoniumDecayTable -> Insert(new G4MuonDecayChannel("Mu",0.5));
|
||||
G4Muonium::MuoniumDefinition() -> SetDecayTable(MuoniumDecayTable);
|
||||
|
||||
G4DecayTable* MuonMinusDecayTable = new G4DecayTable();
|
||||
MuonMinusDecayTable -> Insert(new LEMuSRMuonDecayChannel("mu-",1.00));
|
||||
G4MuonMinus::MuonMinusDefinition() -> SetDecayTable(MuonMinusDecayTable);
|
||||
G4cout<<"ASYM_USE_LEMU\n";
|
||||
#else
|
||||
G4DecayTable* MuonPlusDecayTable = new G4DecayTable();
|
||||
MuonPlusDecayTable -> Insert(new G4MuonDecayChannel("mu+",1.00));
|
||||
G4MuonPlus::MuonPlusDefinition() -> SetDecayTable(MuonPlusDecayTable);
|
||||
|
||||
G4DecayTable* MuoniumDecayTable = new G4DecayTable();
|
||||
MuoniumDecayTable -> Insert(new G4MuonDecayChannel("Mu",1.));
|
||||
G4Muonium::MuoniumDefinition() -> SetDecayTable(MuoniumDecayTable);
|
||||
|
||||
G4DecayTable* MuonMinusDecayTable = new G4DecayTable();
|
||||
MuonMinusDecayTable -> Insert(new G4MuonDecayChannelWithSpin("mu-",1.00));
|
||||
G4MuonMinus::MuonMinusDefinition() -> SetDecayTable(MuonMinusDecayTable);
|
||||
G4cout<<"ASYM_USE_G4\n";
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "G4ProcessManager.hh"
|
||||
|
||||
void LEMuSRMuonPhysics::ConstructProcess()
|
||||
{
|
||||
G4ProcessManager * pManager = 0;
|
||||
|
||||
// Muon Plus Physics
|
||||
pManager = G4MuonPlus::MuonPlus()->GetProcessManager();
|
||||
|
||||
pManager->AddProcess(&fMuAtRestSpinRotation, 1, -1, -1); //(&fprocess, atrest, prestep, poststep)
|
||||
pManager->AddProcess(&fMuFormation,-1, -1, 1);
|
||||
pManager->AddProcess(&fMuPlusMultipleScattering,-1, 1, -1);// may crash when enabled as post step process
|
||||
pManager->AddProcess(&fMuPlusIonisation, -1, 2, 2);
|
||||
pManager->AddProcess(&fMuPlusBremsstrahlung, -1, 3, 3);
|
||||
pManager->AddProcess(&fMuPlusPairProduction, -1, 4, 4);
|
||||
|
||||
pManager->AddProcess(new G4UserSpecialCuts(),-1,-1,6);
|
||||
// pManager ->SetProcessOrderingToLast(&fDepolarization, idxAtRest);
|
||||
// pManager ->SetProcessOrdering(&fDepolarization, idxPostStep);
|
||||
|
||||
// the last process: decay
|
||||
pManager->AddProcess(&fDecayProcess);
|
||||
pManager ->SetProcessOrderingToLast(&fDecayProcess, idxAtRest);
|
||||
pManager ->SetProcessOrdering(&fDecayProcess, idxPostStep);
|
||||
|
||||
|
||||
// Muonium Physics is the same as muon plus physics
|
||||
pManager = G4Muonium::Muonium()->GetProcessManager();
|
||||
|
||||
pManager->AddProcess(&fMuAtRestSpinRotation, 1, -1, -1);
|
||||
pManager->AddProcess(&fMuPlusIonisation, -1, 2, 2);
|
||||
pManager->AddProcess(&fMuoniumScatt, -1, -1, 3);
|
||||
pManager->AddProcess(&fMuPlusBremsstrahlung, -1, 4, 4);
|
||||
pManager->AddProcess(&fMuPlusPairProduction, -1, 5, 5);
|
||||
|
||||
pManager->AddProcess(new G4UserSpecialCuts(),-1,-1,6);
|
||||
|
||||
// the last process: decay
|
||||
pManager->AddProcess(&fDecayProcess);
|
||||
pManager->SetProcessOrderingToLast(&fDecayProcess, idxAtRest);
|
||||
pManager->SetProcessOrdering(&fDecayProcess, idxPostStep);
|
||||
|
||||
// Muon Minus Physics
|
||||
pManager = G4MuonMinus::MuonMinus()->GetProcessManager();
|
||||
|
||||
pManager->AddProcess(&fMuMinusMultipleScattering,-1, 1, 1);
|
||||
pManager->AddProcess(&fMuMinusIonisation, -1, 2, 2);
|
||||
pManager->AddProcess(&fMuMinusBremsstrahlung, -1, 3, 3);
|
||||
pManager->AddProcess(&fMuMinusPairProduction, -1, 4, 4);
|
||||
|
||||
pManager->AddRestProcess(&fMuMinusCaptureAtRest);
|
||||
pManager->AddProcess(&fDecayProcess);
|
||||
pManager->SetProcessOrderingToLast(&fDecayProcess, idxAtRest);
|
||||
pManager->SetProcessOrdering(&fDecayProcess, idxPostStep);
|
||||
|
||||
// Tau Plus Physics
|
||||
pManager = G4TauPlus::TauPlus()->GetProcessManager();
|
||||
|
||||
pManager->AddProcess(&fTauPlusMultipleScattering, -1, 1, 1);
|
||||
pManager->AddProcess(&fTauPlusIonisation, -1, 2, 2);
|
||||
|
||||
// Tau Minus Physics
|
||||
pManager = G4TauMinus::TauMinus()->GetProcessManager();
|
||||
|
||||
pManager->AddProcess(&fTauMinusMultipleScattering, -1, 1, 1);
|
||||
pManager->AddProcess(&fTauMinusIonisation, -1, 2, 2);
|
||||
|
||||
}
|
||||
|
75
geant4/LEMuSR/src/LEMuSROScintHit.cc
Normal file
75
geant4/LEMuSR/src/LEMuSROScintHit.cc
Normal file
@ -0,0 +1,75 @@
|
||||
#include "LEMuSROScintHit.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4Circle.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <fstream.h>
|
||||
#include <iomanip.h>
|
||||
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
G4Allocator<LEMuSROScintHit> LEMuSROScintHitAllocator;
|
||||
|
||||
LEMuSROScintHit::LEMuSROScintHit()
|
||||
{;}
|
||||
|
||||
LEMuSROScintHit::~LEMuSROScintHit()
|
||||
{;}
|
||||
|
||||
LEMuSROScintHit::LEMuSROScintHit(const LEMuSROScintHit &right) : G4VHit()
|
||||
{
|
||||
particle_name = right.particle_name;
|
||||
energy_deposition = right.energy_deposition;
|
||||
time_of_flight = right.time_of_flight;
|
||||
position = right.position;
|
||||
momentum = right.momentum;
|
||||
}
|
||||
|
||||
const LEMuSROScintHit& LEMuSROScintHit::operator=(const LEMuSROScintHit &right)
|
||||
{
|
||||
particle_name = right.particle_name;
|
||||
energy_deposition = right.energy_deposition;
|
||||
time_of_flight = right.time_of_flight;
|
||||
position = right.position;
|
||||
momentum = right.momentum;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4int LEMuSROScintHit::operator==(const LEMuSROScintHit &right) const
|
||||
{
|
||||
return (this==&right) ? 1 : 0;
|
||||
}
|
||||
|
||||
void LEMuSROScintHit::Draw()
|
||||
{
|
||||
G4VVisManager* VisManager = G4VVisManager::GetConcreteInstance();
|
||||
if(VisManager)
|
||||
{
|
||||
G4Circle circle(position);
|
||||
circle.SetScreenSize(0.1);
|
||||
circle.SetFillStyle(G4Circle::filled);
|
||||
G4Colour colour(1.,1.,1.);
|
||||
G4VisAttributes attributes(colour);
|
||||
circle.SetVisAttributes(attributes);
|
||||
VisManager->Draw(circle);
|
||||
}
|
||||
}
|
||||
|
||||
void LEMuSROScintHit::Print()
|
||||
{}
|
||||
|
||||
void LEMuSROScintHit::print(G4String name)
|
||||
{
|
||||
ofstream TestPrint(name,ios::app);
|
||||
if (!TestPrint.is_open()) exit(8);
|
||||
TestPrint << "particle name : " << particle_name <<" ;\n "
|
||||
<< "energy_deposition : " << G4BestUnit(energy_deposition,"Energy") <<" ;\n "
|
||||
<< "time_of_flight : " << G4BestUnit(time_of_flight,"Time") <<" ;\n "
|
||||
<< "position : " << position <<" ;\n "
|
||||
<< "momentum : " << momentum <<" ;\n "
|
||||
<<G4endl;
|
||||
|
||||
}
|
216
geant4/LEMuSR/src/LEMuSROScintSD.cc
Normal file
216
geant4/LEMuSR/src/LEMuSROScintSD.cc
Normal file
@ -0,0 +1,216 @@
|
||||
#include "LEMuSROScintSD.hh"
|
||||
#include "G4HCofThisEvent.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4VProcess.hh"
|
||||
|
||||
// ROOT
|
||||
#include "TROOT.h"
|
||||
#include "TApplication.h"
|
||||
#include "TSystem.h"
|
||||
#include "TH1.h"
|
||||
#include "TPad.h"
|
||||
#include "TCanvas.h"
|
||||
|
||||
|
||||
LEMuSROScintSD::LEMuSROScintSD(G4String name)
|
||||
:G4VSensitiveDetector(name)
|
||||
{
|
||||
|
||||
G4String HCname;
|
||||
collectionName.insert(HCname="OuterScintCollection");
|
||||
positionResolution = 5*mm;
|
||||
|
||||
|
||||
// ROOT
|
||||
BookRoot();
|
||||
}
|
||||
|
||||
LEMuSROScintSD::~LEMuSROScintSD()
|
||||
{
|
||||
// ROOT
|
||||
WriteRoot();
|
||||
}
|
||||
|
||||
void LEMuSROScintSD::Initialize(G4HCofThisEvent* HCE)
|
||||
{
|
||||
static int HCID = -1;
|
||||
ScintCollection = new LEMuSROScintHitsCollection
|
||||
(SensitiveDetectorName,collectionName[0]);
|
||||
if(HCID<0)
|
||||
{ HCID = GetCollectionID(0); }
|
||||
HCE->AddHitsCollection(HCID,ScintCollection);
|
||||
}
|
||||
|
||||
G4bool LEMuSROScintSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
|
||||
{
|
||||
// G4cout << "PROCESS HIT"<<G4endl;
|
||||
|
||||
LEMuSROScintHit* aHit;
|
||||
p_name = aStep->GetTrack()->GetDefinition()->GetParticleName(); // particle name
|
||||
|
||||
|
||||
if( CheckCondition(aStep))
|
||||
{
|
||||
GetDatas(aStep);
|
||||
getHit();
|
||||
FillRoot();
|
||||
}
|
||||
|
||||
|
||||
// Define Hit
|
||||
aHit = new LEMuSROScintHit();
|
||||
|
||||
//++++++++++++++ set hit values _______________
|
||||
aHit->SetParticleName(p_name);
|
||||
aHit->SetSpin(spin);
|
||||
|
||||
aHit->SetMomentum( hitmom );
|
||||
aHit->SetPosition( hitpos );
|
||||
|
||||
aHit->SetTimeOfFlight( tof);
|
||||
aHit->SetEnergyDeposition( edep );
|
||||
|
||||
|
||||
ScintCollection->insert( aHit );
|
||||
// aHit->Print();
|
||||
// aHit->print("Statistics/SCIS.Hits");
|
||||
aHit->Draw();
|
||||
|
||||
|
||||
PrintAll();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void LEMuSROScintSD::EndOfEvent(G4HCofThisEvent*)
|
||||
{
|
||||
// G4int NbHits = ScintCollection->entries();
|
||||
// G4cout << "\n-------->Hits Collection: in this event they are " << NbHits
|
||||
// << " hits in the inner scintillator: " << G4endl;
|
||||
// for (G4int i=0;i<NbHits;i++) (*ScintCollection)[i]->Print();
|
||||
|
||||
}
|
||||
|
||||
G4bool LEMuSROScintSD::CheckCondition(const G4Step* aStep)
|
||||
{
|
||||
G4bool condition=false;
|
||||
|
||||
if(p_name == "e+"&&aStep->GetTrack()->GetNextVolume()->GetLogicalVolume()->GetName()!="lv_SCOS")
|
||||
{
|
||||
if( aStep->GetTrack()->GetCreatorProcess())
|
||||
{
|
||||
if( aStep->GetTrack()->GetCreatorProcess()->GetProcessName()=="Decay")
|
||||
{
|
||||
condition=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return condition;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LEMuSROScintSD::clear()
|
||||
{
|
||||
delete ScintCollection;
|
||||
}
|
||||
|
||||
void LEMuSROScintSD::DrawAll()
|
||||
{
|
||||
}
|
||||
|
||||
void LEMuSROScintSD::PrintAll()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LEMuSROScintSD::GetDatas(const G4Step *aStep)
|
||||
{
|
||||
// Get datas
|
||||
//a Volume, name, spin
|
||||
vname = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName();
|
||||
spin= aStep->GetTrack()->GetDefinition()->GetPDGSpin(); // spin in units of 1
|
||||
|
||||
//b Position momentum
|
||||
hitpos = aStep->GetPreStepPoint()->GetPosition(); // position
|
||||
hitmom = aStep->GetPreStepPoint()->GetMomentum(); // momentum
|
||||
|
||||
//c Times
|
||||
tof = aStep->GetPreStepPoint()->GetLocalTime(); // time since track creation
|
||||
globaltime = aStep->GetPreStepPoint()->GetGlobalTime();// time since event creation
|
||||
proptime = aStep->GetPreStepPoint()->GetProperTime(); // particle's proper time
|
||||
|
||||
//d Energy
|
||||
edep = aStep->GetTotalEnergyDeposit();
|
||||
|
||||
toten = aStep->GetTrack()->GetTotalEnergy();
|
||||
|
||||
kinen = aStep->GetTrack()->GetKineticEnergy();
|
||||
|
||||
//e OScint ID
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LEMuSROScintSD::getHit()
|
||||
{
|
||||
theHit.kenergy = kinen;
|
||||
theHit.tenergy = toten;
|
||||
theHit.edeposit = edep;
|
||||
theHit.localtime = tof;
|
||||
theHit.globaltime = globaltime;
|
||||
theHit.proptime = proptime;
|
||||
theHit.positionx = hitpos.x();
|
||||
theHit.positiony = hitpos.y();
|
||||
theHit.positionz = hitpos.z();
|
||||
theHit.momdirx = hitmom.x();
|
||||
theHit.momdiry = hitmom.y();
|
||||
theHit.momdirz = hitmom.z();
|
||||
if (vname=="pv_SCISl")
|
||||
{
|
||||
theHit.scLeft = globaltime;//+=1;//
|
||||
}
|
||||
else if (vname=="pv_SCISb")
|
||||
{
|
||||
theHit.scBottom =globaltime ;//+=1;
|
||||
}
|
||||
else if (vname=="pv_SCISr")
|
||||
{
|
||||
theHit.scRight =globaltime;//+=1;
|
||||
}
|
||||
else if (vname=="pv_SCISt")
|
||||
{
|
||||
theHit.scTop = globaltime;//+=1;
|
||||
}
|
||||
}
|
||||
|
||||
// ROOT METHODS
|
||||
|
||||
void LEMuSROScintSD::BookRoot()
|
||||
{
|
||||
// open root file
|
||||
myFile = new TFile("SDOuterScintE0.root", "RECREATE");
|
||||
// myFile->SetCompressionLevel(1);
|
||||
|
||||
tree = new TTree ("tree","Outer Scintillator Datas");
|
||||
|
||||
tree->Branch("scintHit",&theHit.kenergy,"kenergy/F:tenergy/F:edeposit/F:localtime/F:globaltime:propertime/F:positionx/F:positiony:positionz:momdirx:momdiry:momdirz/F:Left/F:Right/F:Bottom/F:Top/F:runID");
|
||||
|
||||
}
|
||||
|
||||
void LEMuSROScintSD::FillRoot()
|
||||
{
|
||||
tree->Fill();
|
||||
}
|
||||
|
||||
void LEMuSROScintSD::WriteRoot()
|
||||
{
|
||||
myFile->Write();
|
||||
myFile->Close();
|
||||
}
|
64
geant4/LEMuSR/src/LEMuSRParticleChangeForSR.cc
Normal file
64
geant4/LEMuSR/src/LEMuSRParticleChangeForSR.cc
Normal file
@ -0,0 +1,64 @@
|
||||
///§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID : LEMuSRParticleChangeForSR.cc , v 1.2b
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-08-20 10:36
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// PARTICLE CHANGE FOR SPIN ROTATION
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
#include "LEMuSRParticleChangeForSR.hh"
|
||||
|
||||
|
||||
|
||||
G4Step* LEMuSRParticleChangeForSR::UpdateStepForAtRest(G4Step* pStep)
|
||||
{
|
||||
G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint();
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
G4Track* aTrack = pStep->GetTrack();
|
||||
|
||||
// update polarization
|
||||
|
||||
pPostStepPoint->SetMomentumDirection(theMomentumDirectionChange);
|
||||
pPostStepPoint->SetKineticEnergy(theEnergyChange);
|
||||
pPostStepPoint->AddPolarization( thePolarizationChange
|
||||
- pPreStepPoint->GetPolarization());
|
||||
|
||||
// update position and time
|
||||
pPostStepPoint->AddPosition( thePositionChange
|
||||
- pPreStepPoint->GetPosition() );
|
||||
|
||||
|
||||
pStep->SetControlFlag( theSteppingControlFlag );
|
||||
|
||||
// Update track
|
||||
pStep->UpdateTrack();
|
||||
|
||||
|
||||
#ifdef G4SRVERBOSE
|
||||
G4cout<<"STEP UPDATED "
|
||||
<< aTrack->GetDynamicParticle()->GetPreAssignedDecayProperTime()
|
||||
<<" "
|
||||
<< aTrack->GetDynamicParticle()->GetProperTime()
|
||||
<<G4endl;
|
||||
CheckIt(*aTrack);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
return pStep;
|
||||
}
|
||||
|
95
geant4/LEMuSR/src/LEMuSRParticleGun.cc
Normal file
95
geant4/LEMuSR/src/LEMuSRParticleGun.cc
Normal file
@ -0,0 +1,95 @@
|
||||
///§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID : LEMuSRParticleGun.cc , v 1.2
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-08-20 10:48
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// PARTICLE GUN
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
#include "LEMuSRParticleGun.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "LEMuSRParticleGunMessenger.hh"
|
||||
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4VProcess.hh"
|
||||
|
||||
#include "G4ProcessVector.hh"
|
||||
|
||||
LEMuSRParticleGun::LEMuSRParticleGun()
|
||||
{
|
||||
SetInitialValues();
|
||||
Messenger = new G4ParticleGunMessenger(this);
|
||||
}
|
||||
|
||||
LEMuSRParticleGun::~LEMuSRParticleGun()
|
||||
{
|
||||
delete Messenger;
|
||||
}
|
||||
|
||||
void LEMuSRParticleGun::SetInitialValues()
|
||||
{
|
||||
NumberOfParticlesToBeGenerated = 1;
|
||||
particle_definition = 0;
|
||||
G4ThreeVector zero;
|
||||
particle_momentum_direction = (G4ParticleMomentum)zero;
|
||||
particle_energy = 0.0;
|
||||
particle_position = zero;
|
||||
particle_time = 0.0;
|
||||
particle_polarization = zero;
|
||||
particle_charge = 0.0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LEMuSRParticleGun::GeneratePrimaryVertex(G4Event* evt)
|
||||
{
|
||||
if(particle_definition==0) return;
|
||||
|
||||
// create a new vertex
|
||||
G4PrimaryVertex* vertex =
|
||||
new G4PrimaryVertex(particle_position,particle_time);
|
||||
|
||||
|
||||
// create new primaries and set them to the vertex
|
||||
G4double mass = particle_definition->GetPDGMass();
|
||||
G4double energy = particle_energy + mass;
|
||||
G4double pmom = sqrt(energy*energy-mass*mass);
|
||||
G4double px = pmom*particle_momentum_direction.x();
|
||||
G4double py = pmom*particle_momentum_direction.y();
|
||||
G4double pz = pmom*particle_momentum_direction.z();
|
||||
for( G4int i=0; i<NumberOfParticlesToBeGenerated; i++ )
|
||||
{
|
||||
|
||||
G4PrimaryParticle* particle =
|
||||
new G4PrimaryParticle(particle_definition,px,py,pz);
|
||||
particle->SetMass( mass );
|
||||
// particle->SetCharge( particle_charge );
|
||||
// G4cout<<"Charge (from gun) = " << particle->GetCharge() <<" \n" <<G4endl;
|
||||
particle->SetPolarization(particle_polarization.x(),
|
||||
particle_polarization.y(),
|
||||
particle_polarization.z());
|
||||
particle->SetProperTime(decaytime);
|
||||
// G4cout<<"Muon decay time = " << decaytime/ns <<"ns. \n" <<G4endl;
|
||||
|
||||
vertex->SetPrimary( particle );
|
||||
|
||||
|
||||
}
|
||||
|
||||
evt->AddPrimaryVertex( vertex );
|
||||
}
|
231
geant4/LEMuSR/src/LEMuSRParticleGunMessenger.cc
Normal file
231
geant4/LEMuSR/src/LEMuSRParticleGunMessenger.cc
Normal file
@ -0,0 +1,231 @@
|
||||
#include "LEMuSRParticleGunMessenger.hh"
|
||||
#include "LEMuSRParticleGun.hh"
|
||||
#include "G4Geantino.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4IonTable.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWith3Vector.hh"
|
||||
#include "G4UIcmdWith3VectorAndUnit.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4Tokenizer.hh"
|
||||
|
||||
#include <iomanip>
|
||||
#include <strstream>
|
||||
|
||||
|
||||
LEMuSRParticleGunMessenger::LEMuSRParticleGunMessenger(LEMuSRParticleGun* fPtclGun)
|
||||
:fParticleGun(fPtclGun),fShootIon(false)
|
||||
{
|
||||
particleTable = G4ParticleTable::GetParticleTable();
|
||||
|
||||
gunDirectory = new G4UIdirectory("/lemuGun/");
|
||||
gunDirectory->SetGuidance("Particle Gun control commands.");
|
||||
|
||||
listCmd = new G4UIcmdWithoutParameter("/lemuGun/List",this);
|
||||
listCmd->SetGuidance("List available particles.");
|
||||
listCmd->SetGuidance(" Invoke G4ParticleTable.");
|
||||
|
||||
particleCmd = new G4UIcmdWithAString("/lemuGun/particle",this);
|
||||
particleCmd->SetGuidance("Set particle to be generated.");
|
||||
particleCmd->SetGuidance(" (geantino is default)");
|
||||
particleCmd->SetGuidance(" (ion can be specified for shooting ions)");
|
||||
particleCmd->SetParameterName("particleName",true);
|
||||
particleCmd->SetDefaultValue("geantino");
|
||||
G4String candidateList;
|
||||
G4int nPtcl = particleTable->entries();
|
||||
for(G4int i=0;i<nPtcl;i++)
|
||||
{
|
||||
if(!(particleTable->GetParticle(i)->IsShortLived()))
|
||||
{
|
||||
candidateList += particleTable->GetParticleName(i);
|
||||
candidateList += " ";
|
||||
}
|
||||
}
|
||||
candidateList += "ion ";
|
||||
particleCmd->SetCandidates(candidateList);
|
||||
|
||||
directionCmd = new G4UIcmdWith3Vector("/lemuGun/direction",this);
|
||||
directionCmd->SetGuidance("Set momentum direction.");
|
||||
directionCmd->SetGuidance("Direction needs not to be a unit vector.");
|
||||
directionCmd->SetParameterName("Px","Py","Pz",true,true);
|
||||
directionCmd->SetRange("Px != 0 || Py != 0 || Pz != 0");
|
||||
|
||||
energyCmd = new G4UIcmdWithADoubleAndUnit("/lemuGun/energy",this);
|
||||
energyCmd->SetGuidance("Set kinetic energy.");
|
||||
energyCmd->SetParameterName("Energy",true,true);
|
||||
energyCmd->SetDefaultUnit("GeV");
|
||||
//energyCmd->SetUnitCategory("Energy");
|
||||
//energyCmd->SetUnitCandidates("eV keV MeV GeV TeV");
|
||||
|
||||
positionCmd = new G4UIcmdWith3VectorAndUnit("/lemuGun/position",this);
|
||||
positionCmd->SetGuidance("Set starting position of the particle.");
|
||||
positionCmd->SetParameterName("X","Y","Z",true,true);
|
||||
positionCmd->SetDefaultUnit("cm");
|
||||
//positionCmd->SetUnitCategory("Length");
|
||||
//positionCmd->SetUnitCandidates("microm mm cm m km");
|
||||
|
||||
timeCmd = new G4UIcmdWithADoubleAndUnit("/lemuGun/time",this);
|
||||
timeCmd->SetGuidance("Set initial time of the particle.");
|
||||
timeCmd->SetParameterName("t0",true,true);
|
||||
timeCmd->SetDefaultUnit("ns");
|
||||
//timeCmd->SetUnitCategory("Time");
|
||||
//timeCmd->SetUnitCandidates("ns ms s");
|
||||
|
||||
polCmd = new G4UIcmdWith3Vector("/lemuGun/polarization",this);
|
||||
polCmd->SetGuidance("Set polarization.");
|
||||
polCmd->SetParameterName("Px","Py","Pz",true,true);
|
||||
polCmd->SetRange("Px>=-1.&&Px<=1.&&Py>=-1.&&Py<=1.&&Pz>=-1.&&Pz<=1.");
|
||||
|
||||
numberCmd = new G4UIcmdWithAnInteger("/lemuGun/number",this);
|
||||
numberCmd->SetGuidance("Set number of particles to be generated.");
|
||||
numberCmd->SetParameterName("N",true,true);
|
||||
numberCmd->SetRange("N>0");
|
||||
|
||||
ionCmd = new G4UIcommand("/lemuGun/ion",this);
|
||||
ionCmd->SetGuidance("Set properties of ion to be generated.");
|
||||
ionCmd->SetGuidance("[usage] /lemuGun/ion Z A Q");
|
||||
ionCmd->SetGuidance(" Z:(int) AtomicNumber");
|
||||
ionCmd->SetGuidance(" A:(int) AtomicMass");
|
||||
ionCmd->SetGuidance(" Q:(int) Charge of Ion (in unit of e)");
|
||||
ionCmd->SetGuidance(" E:(double) Excitation energy (in keV)");
|
||||
|
||||
G4UIparameter* param;
|
||||
param = new G4UIparameter("Z",'i',false);
|
||||
param->SetDefaultValue("1");
|
||||
ionCmd->SetParameter(param);
|
||||
param = new G4UIparameter("A",'i',false);
|
||||
param->SetDefaultValue("1");
|
||||
ionCmd->SetParameter(param);
|
||||
param = new G4UIparameter("Q",'i',true);
|
||||
param->SetDefaultValue("0");
|
||||
ionCmd->SetParameter(param);
|
||||
param = new G4UIparameter("E",'d',true);
|
||||
param->SetDefaultValue("0.0");
|
||||
ionCmd->SetParameter(param);
|
||||
|
||||
// set initial value to G4ParticleGun
|
||||
fParticleGun->SetParticleDefinition( G4Geantino::Geantino() );
|
||||
fParticleGun->SetParticleMomentumDirection( G4ThreeVector(1.0,0.0,0.0) );
|
||||
fParticleGun->SetParticleEnergy( 1.0*GeV );
|
||||
fParticleGun->SetParticlePosition(G4ThreeVector(0.0*cm, 0.0*cm, 0.0*cm));
|
||||
fParticleGun->SetParticleTime( 0.0*ns );
|
||||
}
|
||||
|
||||
|
||||
|
||||
LEMuSRParticleGunMessenger::~LEMuSRParticleGunMessenger()
|
||||
{
|
||||
delete listCmd;
|
||||
delete particleCmd;
|
||||
delete directionCmd;
|
||||
delete energyCmd;
|
||||
delete positionCmd;
|
||||
delete timeCmd;
|
||||
delete polCmd;
|
||||
delete numberCmd;
|
||||
delete ionCmd;
|
||||
delete gunDirectory;
|
||||
}
|
||||
|
||||
|
||||
void LEMuSRParticleGunMessenger::SetNewValue(G4UIcommand * command,G4String newValues)
|
||||
{
|
||||
if( command==listCmd )
|
||||
{ particleTable->DumpTable(); }
|
||||
else if( command==particleCmd )
|
||||
{
|
||||
if (newValues =="ion") {
|
||||
fShootIon = true;
|
||||
} else {
|
||||
fShootIon = false;
|
||||
G4ParticleDefinition* pd = particleTable->FindParticle(newValues);
|
||||
if(pd != 0)
|
||||
{ fParticleGun->SetParticleDefinition( pd ); }
|
||||
}
|
||||
}
|
||||
else if( command==directionCmd )
|
||||
{ fParticleGun->SetParticleMomentumDirection(directionCmd->GetNew3VectorValue(newValues)); }
|
||||
else if( command==energyCmd )
|
||||
{ fParticleGun->SetParticleEnergy(energyCmd->GetNewDoubleValue(newValues)); }
|
||||
else if( command==positionCmd )
|
||||
{ fParticleGun->SetParticlePosition(positionCmd->GetNew3VectorValue(newValues)); }
|
||||
else if( command==timeCmd )
|
||||
{ fParticleGun->SetParticleTime(timeCmd->GetNewDoubleValue(newValues)); }
|
||||
else if( command==polCmd )
|
||||
{ fParticleGun->SetParticlePolarization(polCmd->GetNew3VectorValue(newValues)); }
|
||||
else if( command==numberCmd )
|
||||
{ fParticleGun->SetNumberOfParticles(numberCmd->GetNewIntValue(newValues)); }
|
||||
else if( command==ionCmd )
|
||||
{ IonCommand(newValues); }
|
||||
}
|
||||
|
||||
G4String LEMuSRParticleGunMessenger::GetCurrentValue(G4UIcommand * command)
|
||||
{
|
||||
G4String cv;
|
||||
|
||||
if( command==directionCmd )
|
||||
{ cv = directionCmd->ConvertToString(fParticleGun->GetParticleMomentumDirection()); }
|
||||
else if( command==particleCmd )
|
||||
{ cv = fParticleGun->GetParticleDefinition()->GetParticleName(); }
|
||||
else if( command==energyCmd )
|
||||
{ cv = energyCmd->ConvertToString(fParticleGun->GetParticleEnergy(),"GeV"); }
|
||||
else if( command==positionCmd )
|
||||
{ cv = positionCmd->ConvertToString(fParticleGun->GetParticlePosition(),"cm"); }
|
||||
else if( command==timeCmd )
|
||||
{ cv = timeCmd->ConvertToString(fParticleGun->GetParticleTime(),"ns"); }
|
||||
else if( command==polCmd )
|
||||
{ cv = polCmd->ConvertToString(fParticleGun->GetParticlePolarization()); }
|
||||
else if( command==numberCmd )
|
||||
{ cv = numberCmd->ConvertToString(fParticleGun->GetNumberOfParticles()); }
|
||||
else if( command==ionCmd )
|
||||
{
|
||||
if (fShootIon) {
|
||||
cv = ItoS(fAtomicNumber) + " " + ItoS(fAtomicMass) + " ";
|
||||
cv += ItoS(fIonCharge);
|
||||
} else {
|
||||
cv = "";
|
||||
}
|
||||
}
|
||||
return cv;
|
||||
}
|
||||
|
||||
void LEMuSRParticleGunMessenger::IonCommand(G4String newValues)
|
||||
{
|
||||
if (fShootIon) {
|
||||
G4Tokenizer next( newValues );
|
||||
// check argument
|
||||
fAtomicNumber = StoI(next());
|
||||
fAtomicMass = StoI(next());
|
||||
G4String sQ = next();
|
||||
if (sQ.isNull()) {
|
||||
fIonCharge = fAtomicNumber;
|
||||
} else {
|
||||
fIonCharge = StoI(sQ);
|
||||
sQ = next();
|
||||
if (sQ.isNull()) {
|
||||
fIonExciteEnergy = 0.0;
|
||||
} else {
|
||||
fIonExciteEnergy = StoD(sQ) * keV;
|
||||
}
|
||||
}
|
||||
|
||||
G4ParticleDefinition* ion;
|
||||
ion = particleTable->GetIon( fAtomicNumber, fAtomicMass, fIonExciteEnergy);
|
||||
if (ion==0) {
|
||||
G4cout << "Ion with Z=" << fAtomicNumber;
|
||||
G4cout << " A=" << fAtomicMass << "is not be defined" << G4endl;
|
||||
} else {
|
||||
fParticleGun->SetParticleDefinition(ion);
|
||||
fParticleGun->SetParticleCharge(fIonCharge*eplus);
|
||||
}
|
||||
} else {
|
||||
G4cout << "Set /lemuGun/particle to ion before using /lemuGun/ion command";
|
||||
G4cout << G4endl;
|
||||
}
|
||||
}
|
||||
|
239
geant4/LEMuSR/src/LEMuSRPgaMessenger.cc
Normal file
239
geant4/LEMuSR/src/LEMuSRPgaMessenger.cc
Normal file
@ -0,0 +1,239 @@
|
||||
///§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID : LEMuSRPgaMessenger.cc , v 1.1
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-06-30 09:12
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// PRIMARY GENERATOR ACTION MEESENGER
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
|
||||
#include "LEMuSRPgaMessenger.hh"
|
||||
|
||||
|
||||
#include "LEMuSRPrimaryGeneratorAction.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithADouble.hh"
|
||||
#include "G4UIcmdWith3Vector.hh"
|
||||
#include "G4UIcmdWith3VectorAndUnit.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
LEMuSRPgaMessenger::LEMuSRPgaMessenger(LEMuSRPrimaryGeneratorAction *thePGA)
|
||||
:lemuPGA(thePGA)
|
||||
{
|
||||
pgaDirectory = new G4UIdirectory("/lemuGun/");
|
||||
pgaDirectory->SetGuidance("LEMuSR particle shooting control commands.");
|
||||
|
||||
// commands
|
||||
|
||||
posCmd = new G4UIcmdWith3Vector("/lemuGun/gunPosition",this);
|
||||
posCmd->SetGuidance("Set Gun Position >> IN CENTIMETERS.");
|
||||
posCmd->SetParameterName("X [cm]","Y [cm]","Z [cm]",true,true);
|
||||
posCmd->SetDefaultValue(Hep3Vector(0., 0., -114));
|
||||
|
||||
posCmd = new G4UIcmdWith3Vector("/lemuGun/MomentumDirection",this);
|
||||
posCmd->SetGuidance("Set momentum direction >> sum must equal one.");
|
||||
posCmd->SetParameterName("momX ","momY ","momZ ",true,true);
|
||||
posCmd->SetDefaultValue(Hep3Vector(0., 0., 1.));
|
||||
|
||||
|
||||
scaCmd = new G4UIcmdWith3Vector("/lemuGun/scan/square",this);
|
||||
scaCmd->SetGuidance("Gun scan: xrange yrange nbins \n Shoot right number of particles to fill. \n xrange and yrange are divided in nbins.\n");
|
||||
scaCmd->SetParameterName("X range [cm]","Y range [cm]","Number of bins",true,true);
|
||||
scaCmd->SetDefaultValue(Hep3Vector(2., 2., 400));
|
||||
|
||||
scbCmd = new G4UIcmdWith3Vector("/lemuGun/scan/circular",this);
|
||||
scbCmd->SetGuidance("Gun scan: radius Rsteps ThetaSteps \n Shoot Rsteps*Thetasteps particles to fill.");
|
||||
scbCmd->SetParameterName("Radius [cm]","Number of step along radius","Number of steps along angle",true,true);
|
||||
scbCmd->SetDefaultValue(Hep3Vector(1., 36 , 360 ));
|
||||
|
||||
scgCmd = new G4UIcmdWith3Vector("/lemuGun/scan/gauss",this);
|
||||
scgCmd->SetGuidance("Gun gauss scan:.");
|
||||
scgCmd->SetParameterName("Radius [cm]","Number of step along radius","Number of steps along angle",true,true);
|
||||
scgCmd->SetDefaultValue(Hep3Vector(1., 36 , 360 ));
|
||||
|
||||
|
||||
|
||||
reset = new G4UIcmdWithoutParameter("/lemuGun/scan/reset",this);
|
||||
reset->SetGuidance("\n Reset the counters for scanning");
|
||||
|
||||
setEnergy = new G4UIcmdWithADouble("/lemuGun/energy/defined",this);
|
||||
setEnergy->SetGuidance("\n Energy Value >> IN keV \n ");
|
||||
setEnergy->SetParameterName("Energy in [keV]",false);
|
||||
setEnergy->SetDefaultValue(20);
|
||||
setEnergy->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
setKEoffset = new G4UIcmdWithADouble("/lemuGun/energy/offset",this); // not implemented yet
|
||||
setKEoffset->SetGuidance("\n KEoffset Value >> IN keV \n ");
|
||||
setKEoffset->SetParameterName("KEoffset in [keV]; default value 3.73",false);
|
||||
setKEoffset->SetDefaultValue(0);
|
||||
setKEoffset->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
|
||||
|
||||
setRndEnergy = new G4UIcmdWithAString("/lemuGun/energy/random",this);
|
||||
setRndEnergy->SetGuidance("Gaussian energy distribution with default mean 20 kev and 0.5 kev deviation");
|
||||
setRndEnergy->SetParameterName("Random Energy: on/off",true);
|
||||
setRndEnergy->SetDefaultValue("on");
|
||||
|
||||
|
||||
setMuonium = new G4UIcmdWithAString("/lemuGun/particle",this);
|
||||
setMuonium->SetGuidance("Particles to be shot");
|
||||
setMuonium->SetParameterName("Particle types: mu+/Mu",true);
|
||||
setMuonium->SetDefaultValue("mu+");
|
||||
|
||||
|
||||
setEGauss = new G4UIcmdWith3Vector("/lemuGun/energy/gauss",this);
|
||||
setEGauss->SetGuidance("Gaussian energy distribution with specified mean and standard deviation\n ENTER VALUES >> IN keV ");
|
||||
setEGauss->SetParameterName("Mean Energy","Standard Deviation","",true,true);
|
||||
setEGauss->SetDefaultValue(Hep3Vector(20., 0.5, 0.0));
|
||||
|
||||
}
|
||||
|
||||
|
||||
LEMuSRPgaMessenger::~LEMuSRPgaMessenger()
|
||||
{
|
||||
delete posCmd;
|
||||
delete momCmd;
|
||||
delete scaCmd;
|
||||
delete scgCmd;
|
||||
delete scbCmd;
|
||||
delete reset;
|
||||
delete setEnergy;
|
||||
delete setRndEnergy;
|
||||
delete setMuonium;
|
||||
delete setKEoffset;
|
||||
delete setEGauss;
|
||||
delete pgaDirectory;
|
||||
}
|
||||
|
||||
|
||||
void LEMuSRPgaMessenger::SetNewValue(G4UIcommand * command,G4String newValues)
|
||||
{
|
||||
|
||||
if( command==posCmd )
|
||||
{
|
||||
lemuPGA->scan=0;
|
||||
lemuPGA->X=posCmd->GetNew3VectorValue(newValues).x();
|
||||
lemuPGA->Y=posCmd->GetNew3VectorValue(newValues).y();
|
||||
lemuPGA->Z=posCmd->GetNew3VectorValue(newValues).z();
|
||||
}
|
||||
else if( command==momCmd )
|
||||
{
|
||||
// lemuPGA->scan=0;
|
||||
lemuPGA->momX=momCmd->GetNew3VectorValue(newValues).x();
|
||||
lemuPGA->momY=momCmd->GetNew3VectorValue(newValues).y();
|
||||
lemuPGA->momZ=momCmd->GetNew3VectorValue(newValues).z();
|
||||
}
|
||||
else if( command==scaCmd)
|
||||
{
|
||||
lemuPGA->scan=1;
|
||||
G4int xb, yb;
|
||||
lemuPGA->m_xrange=scaCmd->GetNew3VectorValue(newValues).x();
|
||||
lemuPGA->m_yrange=scaCmd->GetNew3VectorValue(newValues).y();
|
||||
|
||||
xb=(G4int)(scaCmd->GetNew3VectorValue(newValues).z()/(2*scaCmd->GetNew3VectorValue(newValues).x()));
|
||||
yb=(G4int)(scaCmd->GetNew3VectorValue(newValues).z()/(2*scaCmd->GetNew3VectorValue(newValues).y()));
|
||||
|
||||
// xb=(G4int)(scaCmd->GetNew3VectorValue(newValues).z());
|
||||
// yb=(G4int)(scaCmd->GetNew3VectorValue(newValues).z());
|
||||
lemuPGA->m_nbxsteps=xb;
|
||||
lemuPGA->m_nbysteps=yb;
|
||||
|
||||
|
||||
lemuPGA->m_counterx = 0;
|
||||
lemuPGA->m_countery = 0;
|
||||
|
||||
G4cout<<"Scan will make " << lemuPGA->m_nbxsteps << " steps along x and " <<lemuPGA->m_nbysteps <<" steps along y.\n sHooT :: " << xb*yb <<" particles to fill.\n ";
|
||||
|
||||
}
|
||||
|
||||
else if( command==scbCmd)
|
||||
{
|
||||
lemuPGA->scan=2;
|
||||
lemuPGA->m_xrange=scbCmd->GetNew3VectorValue(newValues).x();
|
||||
lemuPGA->m_nbxsteps=(G4int)scbCmd->GetNew3VectorValue(newValues).y();
|
||||
lemuPGA->m_nbysteps=(G4int)scbCmd->GetNew3VectorValue(newValues).z();
|
||||
|
||||
lemuPGA->m_counterx = 0;
|
||||
lemuPGA->m_countery = 0;
|
||||
|
||||
}
|
||||
|
||||
else if( command==scgCmd)
|
||||
{
|
||||
lemuPGA->scan=3;
|
||||
lemuPGA->m_xrange=scgCmd->GetNew3VectorValue(newValues).x();
|
||||
lemuPGA->sc_mean =scgCmd->GetNew3VectorValue(newValues).y();
|
||||
lemuPGA->sc_stddev=scgCmd->GetNew3VectorValue(newValues).z();
|
||||
|
||||
lemuPGA->m_counterx = 0;
|
||||
lemuPGA->m_countery = 0;
|
||||
G4cout<<"Scan will make 40 steps along radius and 180 steps along angle.\n sHooT :: 3600 particles to fill.\n ";
|
||||
}
|
||||
else if( command==reset)
|
||||
{
|
||||
lemuPGA->m_counterx = 0;
|
||||
lemuPGA->m_countery = 0;
|
||||
}
|
||||
|
||||
|
||||
else if( command==setMuonium)
|
||||
{
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
|
||||
if(particleTable->FindParticle(newValues))
|
||||
{
|
||||
lemuPGA->pname=newValues;
|
||||
}
|
||||
else
|
||||
{
|
||||
lemuPGA->pname="mu+";
|
||||
G4cout<<"Particle " << newValues<<" not found ==>> will shoot mu+. "<<G4endl;
|
||||
};
|
||||
|
||||
}
|
||||
else if( command==setKEoffset)
|
||||
{
|
||||
lemuPGA->ke_offset=setKEoffset->GetNewDoubleValue(newValues)*keV;
|
||||
}
|
||||
|
||||
else if(command == setEnergy)
|
||||
{
|
||||
lemuPGA->rnd=false;
|
||||
G4double k=setEnergy->GetNewDoubleValue(newValues);
|
||||
lemuPGA->energy=k*keV;
|
||||
}
|
||||
else if(command == setRndEnergy)
|
||||
{
|
||||
lemuPGA->rnd=true;
|
||||
}
|
||||
else if( command==setEGauss )
|
||||
{
|
||||
lemuPGA->gauss=1;
|
||||
lemuPGA->mean = setEGauss->GetNew3VectorValue(newValues).x();
|
||||
lemuPGA->stddev= setEGauss->GetNew3VectorValue(newValues).y();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
93
geant4/LEMuSR/src/LEMuSRPhysicsList.cc
Normal file
93
geant4/LEMuSR/src/LEMuSRPhysicsList.cc
Normal file
@ -0,0 +1,93 @@
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID : LEMuSRPhysicsList.cc , v 1.1
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-08-24 16:33
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// PHYSICS LIST
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
|
||||
#include "LEMuSRPhysicsList.hh"
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4ProcessVector.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
|
||||
#include "G4Material.hh"
|
||||
#include "G4MaterialTable.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <iomanip>
|
||||
|
||||
#include "LEMuSRGeneralPhysics.hh"
|
||||
#include "LEMuSREMPhysics.hh"
|
||||
#include "LEMuSRMuonPhysics.hh"
|
||||
#include "LEMuSRHadronPhysics.hh"
|
||||
#include "LEMuSRIonPhysics.hh"
|
||||
|
||||
LEMuSRPhysicsList::LEMuSRPhysicsList(): G4VModularPhysicsList()
|
||||
{
|
||||
// default cut value (1.0mm)
|
||||
defaultCutValue = 10.0*cm;
|
||||
// SetVerboseLevel(1);
|
||||
// SetCuts();
|
||||
SetCutsWithDefault();
|
||||
|
||||
SetCutValue(1*mm, "e+");
|
||||
SetCutValue(1*mm, "proton");
|
||||
|
||||
// SetCutValue(0.001*mm, "mu+");
|
||||
// SetCutValue(0.001*mm, "Mu");
|
||||
|
||||
// General Physics
|
||||
RegisterPhysics( new LEMuSRGeneralPhysics("general") );
|
||||
|
||||
// EM Physics
|
||||
RegisterPhysics( new LEMuSREMPhysics("standard EM"));
|
||||
|
||||
// Muon Physics
|
||||
RegisterPhysics( new LEMuSRMuonPhysics("muon"));
|
||||
|
||||
// Hadron Physics
|
||||
RegisterPhysics( new LEMuSRHadronPhysics("hadron"));
|
||||
|
||||
// Ion Physics
|
||||
RegisterPhysics( new LEMuSRIonPhysics("ion"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
LEMuSRPhysicsList::~LEMuSRPhysicsList()
|
||||
{
|
||||
}
|
||||
|
||||
void LEMuSRPhysicsList::SetCuts()
|
||||
{
|
||||
// " G4VUserPhysicsList::SetCutsWithDefault" method sets
|
||||
// the default cut value for all particle types
|
||||
SetCutsWithDefault();
|
||||
|
||||
SetCutValue(1.*mm, "e+");
|
||||
SetCutValue(1.*mm, "e-");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
354
geant4/LEMuSR/src/LEMuSRPrimaryGeneratorAction.cc
Normal file
354
geant4/LEMuSR/src/LEMuSRPrimaryGeneratorAction.cc
Normal file
@ -0,0 +1,354 @@
|
||||
///§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID : LEMuSRPrimaryGeneratorAction.cc , v 1.3
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-09-16 09:12
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// PRIMARY GENERATOR ACTION
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
|
||||
|
||||
|
||||
#include "LEMuSRPrimaryGeneratorAction.hh"
|
||||
#include "LEMuSRPgaMessenger.hh"
|
||||
#include "yields.h"
|
||||
|
||||
// G4 LIBRARIES
|
||||
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "LEMuSRParticleGun.hh"
|
||||
#include "globals.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4Gamma.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "time.h"
|
||||
#include "G4ios.hh"
|
||||
#include <iomanip.h>
|
||||
|
||||
#include "G4Muonium.hh"
|
||||
|
||||
|
||||
LEMuSRPrimaryGeneratorAction::LEMuSRPrimaryGeneratorAction()
|
||||
{
|
||||
|
||||
|
||||
// Instance pointer
|
||||
thePGA=this;
|
||||
|
||||
// Messenger
|
||||
messenger = new LEMuSRPgaMessenger(this);
|
||||
|
||||
// get the random number engine
|
||||
theEngine = HepRandom::getTheEngine();
|
||||
|
||||
m_nbxsteps = 200;
|
||||
m_nbysteps = 200;
|
||||
m_counterx = 0;
|
||||
m_countery = 0;
|
||||
m_xrange = 2.;
|
||||
m_yrange = 2.;
|
||||
|
||||
lemuParticleGun = new LEMuSRParticleGun();
|
||||
lemuParticleGun->SetNumberOfParticles(1);
|
||||
|
||||
X=0; Y=0;
|
||||
Z=0.;
|
||||
momX=0.; momY=0.; momZ=1;
|
||||
|
||||
scan=0;
|
||||
|
||||
rnd=false;
|
||||
|
||||
energy=5*keV;
|
||||
|
||||
gauss=0; mean=0; stddev=0;
|
||||
|
||||
pname="mu+";
|
||||
|
||||
ke_offset=3.73*keV;
|
||||
#if defined LEMU_TEST_ASYM
|
||||
ke_offset=0;
|
||||
#endif
|
||||
charge=+1;
|
||||
|
||||
//==================================TEST
|
||||
/* i=j=0;
|
||||
Yprint.open("test5.txt");
|
||||
if (!Yprint.is_open()) exit(8);
|
||||
while(i<1000){table[i]=0; i++;}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OO
|
||||
|
||||
|
||||
LEMuSRPrimaryGeneratorAction::~LEMuSRPrimaryGeneratorAction()
|
||||
{
|
||||
delete lemuParticleGun;
|
||||
delete messenger;
|
||||
|
||||
|
||||
//============================0000TEST
|
||||
/* i=0;
|
||||
do
|
||||
{
|
||||
// G4cout<<i*0.01<<" " <<table[i] <<std::endl;
|
||||
Yprint<<i*0.01<<" " <<table[i] <<std::endl;
|
||||
i++;
|
||||
}while(i<500);
|
||||
Yprint.close();*/
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OO
|
||||
|
||||
|
||||
void LEMuSRPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
|
||||
|
||||
//----------------------GETTING RANDOM VALUES >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
// the random engine
|
||||
G4RandGauss* iRndGauss = new G4RandGauss(theEngine, 20.0, 10.0);
|
||||
|
||||
// the random energy
|
||||
if(rnd)
|
||||
{
|
||||
rndenergy = iRndGauss->shoot(20.0, 0.50);
|
||||
energy= rndenergy*keV;//default unit is MeV
|
||||
}
|
||||
|
||||
if(gauss==1)
|
||||
{
|
||||
rndenergy = iRndGauss->shoot(mean, stddev);
|
||||
energy= rndenergy*keV;//default unit is MeV
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LEMU_PGA
|
||||
G4cout<<"Energy is "<<G4BestUnit(energy,"Energy")<<G4endl;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//----------------------GETTING POSITIVE MUONS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
|
||||
G4ParticleDefinition* particle;
|
||||
|
||||
particle = particleTable->FindParticle(pname);
|
||||
|
||||
// std::cout<<"Particle "<< particle->GetParticleName();
|
||||
|
||||
|
||||
lemuParticleGun->SetParticleDefinition(particle);
|
||||
|
||||
lemuParticleGun->SetParticleEnergy(energy+ke_offset);
|
||||
|
||||
|
||||
|
||||
if(particle->GetParticleSubType()=="mu")
|
||||
{
|
||||
// the random time of the decay for muons
|
||||
|
||||
G4double tau=0.000002197; // the muon mean lifetime
|
||||
G4double rnddecaytime = - tau*log(1-G4UniformRand());
|
||||
decaytime = rnddecaytime*s;
|
||||
lemuParticleGun->SetDecayTime(decaytime);
|
||||
// G4cout<<"Decay Time is "<<decaytime/ns <<" nanoseconds."<<G4endl;
|
||||
}
|
||||
|
||||
|
||||
GetScanningMode(scan);
|
||||
// G4cout<<"Zposition "<<Z/mm<<" [mm]"<<G4endl;
|
||||
//-------------------MOMENTUM DIRECTION AND POLARIZATION>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
lemuParticleGun->SetParticleMomentumDirection(G4ThreeVector(momX,momY,momZ));
|
||||
lemuParticleGun->SetParticlePolarization(G4ThreeVector(1.,0.,0.));
|
||||
#if defined LEMU_TEST_ASYM
|
||||
lemuParticleGun->SetParticlePosition(G4ThreeVector(0.,0.,0.));
|
||||
lemuParticleGun->SetParticlePolarization(G4ThreeVector(-1.,0.,0.));
|
||||
lemuParticleGun->SetParticleEnergy(0);
|
||||
#endif
|
||||
|
||||
|
||||
lemuParticleGun->GeneratePrimaryVertex(anEvent);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OO
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OO
|
||||
|
||||
|
||||
|
||||
|
||||
void LEMuSRPrimaryGeneratorAction::GetScanningMode(G4int scan)
|
||||
{
|
||||
|
||||
//----------------------SINGLE SHOOTING POSITION >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
if(scan==0)
|
||||
{
|
||||
lemuParticleGun->SetParticlePosition(G4ThreeVector(X*cm,Y*cm,Z*cm));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------SQUARE SCAN >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
if(scan==1)
|
||||
{
|
||||
//scan: position of the gun
|
||||
if(m_countery<=m_nbysteps)
|
||||
{
|
||||
if(m_counterx<=m_nbxsteps)
|
||||
{
|
||||
// total scan
|
||||
X = -m_xrange+m_counterx*(2*m_xrange)/m_nbxsteps;
|
||||
Y = -m_yrange+m_countery*(2*m_yrange)/m_nbysteps;
|
||||
m_counterx++;
|
||||
}
|
||||
|
||||
if(m_counterx>m_nbxsteps)
|
||||
{
|
||||
m_countery++;
|
||||
m_counterx=1;
|
||||
}
|
||||
}
|
||||
|
||||
else if(m_countery>m_nbysteps)
|
||||
{
|
||||
m_countery=0;
|
||||
m_counterx=0;
|
||||
}
|
||||
// SET POSITION
|
||||
lemuParticleGun->SetParticlePosition(G4ThreeVector(X*cm,Y*cm,-114*cm));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------CIRCULAR SCAN>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
if(scan==2)
|
||||
{
|
||||
if(m_countery<=m_nbysteps)
|
||||
{
|
||||
if(m_counterx<=m_nbxsteps)
|
||||
{
|
||||
radius= m_xrange*(m_counterx/m_nbxsteps)*cm;
|
||||
angle=2*M_PI*m_countery/(m_nbysteps)*rad;
|
||||
X = radius*cos(angle);
|
||||
Y = radius*sin(angle);
|
||||
m_counterx++;
|
||||
|
||||
}
|
||||
|
||||
if(m_counterx>m_nbxsteps)
|
||||
{
|
||||
m_countery++;
|
||||
m_counterx=1;
|
||||
}
|
||||
}
|
||||
|
||||
else if (m_countery>m_nbysteps)
|
||||
{
|
||||
// X=0;
|
||||
// Y=0;
|
||||
m_countery=0;
|
||||
m_counterx=0;
|
||||
}
|
||||
// SET POSITION
|
||||
lemuParticleGun->SetParticlePosition(G4ThreeVector(X,Y,-114*cm));
|
||||
}
|
||||
|
||||
|
||||
//----------------------CIRCULAR SCAN Gauss >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
|
||||
if(scan==3)
|
||||
{
|
||||
G4RandGauss* iRndGauss = new G4RandGauss(theEngine);
|
||||
|
||||
|
||||
// G4cout <<"radius "<< radius/cm<<G4endl;
|
||||
do
|
||||
{
|
||||
X = iRndGauss->shoot(sc_mean, sc_stddev)*cm;
|
||||
Y = iRndGauss->shoot(sc_mean, sc_stddev)*cm;
|
||||
|
||||
radius= sqrt(X*X+Y*Y);
|
||||
}while(radius>2.5*cm);
|
||||
// SET POSITION
|
||||
lemuParticleGun->SetParticlePosition(G4ThreeVector(X,Y,-114*cm));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OO
|
||||
|
||||
LEMuSRPrimaryGeneratorAction* LEMuSRPrimaryGeneratorAction::thePGA=0;
|
||||
LEMuSRPrimaryGeneratorAction* LEMuSRPrimaryGeneratorAction::GetPGA()
|
||||
{
|
||||
return thePGA;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
//----------------------------------------------------------------
|
||||
//----------------------------------------------------------------
|
||||
//----------------------------------------------------------------
|
||||
|
||||
|
||||
/*
|
||||
G4double k=G4UniformRand();
|
||||
if(k>0.5)
|
||||
{
|
||||
G4double gamma;
|
||||
gamma = 0.5*((1.*eplus)/(0.1056584*GeV/(c_light*c_light))+(1.*eplus)/(0.51099906*MeV/(c_light*c_light)));
|
||||
G4cout<< "PGA "<< k<< " " <<gamma<<"\n"
|
||||
<< "FrequencyG: " << gamma/(2*M_PI*rad)<<"Hz/T" <<"\n";
|
||||
particle->SetGammaFactor(gamma);
|
||||
}
|
||||
else if(k<0.5)
|
||||
{
|
||||
G4double gamma;
|
||||
gamma = 0.5*((1.*eplus)/(0.1056584*GeV/(c_light*c_light))-(1.*eplus)/(0.51099906*MeV/(c_light*c_light)));
|
||||
G4cout<< "PGA "<< k<< " " <<gamma<<"\n"
|
||||
<< "FrequencyG: " << gamma/(2*M_PI*rad)<<"Hertz/T" <<"\n";
|
||||
particle->SetGammaFactor(gamma);
|
||||
}
|
||||
*/
|
68
geant4/LEMuSR/src/LEMuSRRNDMAGField.cc
Normal file
68
geant4/LEMuSR/src/LEMuSRRNDMAGField.cc
Normal file
@ -0,0 +1,68 @@
|
||||
#include "LEMuSRRNDMAGField.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <iomanip.h>
|
||||
#include "Randomize.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
|
||||
LEMuSRRNDMAGField::LEMuSRRNDMAGField(const G4ThreeVector FieldVector, G4double rndness )
|
||||
:G4UniformMagField(FieldVector )
|
||||
{
|
||||
BField=FieldVector;
|
||||
|
||||
randomness=1;
|
||||
|
||||
if(rndness<=1.&&rndness>=0)
|
||||
{
|
||||
randomness=rndness;
|
||||
G4cout <<"Mag field randomness = "<<randomness <<G4endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
LEMuSRRNDMAGField::~LEMuSRRNDMAGField()
|
||||
{;}
|
||||
|
||||
|
||||
void LEMuSRRNDMAGField::GetFieldValue (const G4double pos[4],
|
||||
G4double *field ) const
|
||||
{
|
||||
|
||||
|
||||
field[0]= 0.0;
|
||||
field[1]= 0.0;
|
||||
field[2]= 0.0;
|
||||
|
||||
|
||||
G4double costheta, sintheta, cosphi, sinphi, theta, phi;
|
||||
|
||||
phi = 2.0*M_PI*G4UniformRand()*rad;
|
||||
sinphi = sin(phi);
|
||||
cosphi = cos(phi);
|
||||
|
||||
theta = M_PI*G4UniformRand()*rad;
|
||||
sintheta = sin(theta);
|
||||
costheta = cos(theta);
|
||||
|
||||
// rotation angles
|
||||
G4double px = sintheta*sinphi*sqrt(BField*BField);
|
||||
G4double py = sintheta*cosphi*sqrt(BField*BField);
|
||||
G4double pz = costheta*sqrt(BField*BField);
|
||||
|
||||
G4ThreeVector direction0(px,py,pz);
|
||||
|
||||
|
||||
|
||||
field[0]= BField.x()*(1-randomness) + direction0.x()*(randomness) ;//TAO
|
||||
field[1]= BField.y()*(1-randomness) + direction0.y()*(randomness) ;
|
||||
field[2]= BField.z()*(1-randomness) + direction0.z()*(randomness) ;
|
||||
|
||||
|
||||
|
||||
// G4cout<<"Field EM Field Value " << field[0]/gauss <<"gauss " <<field[1]/gauss <<"gauss "<< field[2]/gauss <<"gauss \n" <<G4endl;
|
||||
|
||||
|
||||
}
|
81
geant4/LEMuSR/src/LEMuSRRunAction.cc
Normal file
81
geant4/LEMuSR/src/LEMuSRRunAction.cc
Normal file
@ -0,0 +1,81 @@
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION Geant4 SIMULATION
|
||||
// ID : LEMuSRRunAction.cc , v 1.0
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-07-12 16:15
|
||||
//
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// RUN ACTION.CC
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
#include "LEMuSRRunAction.hh"
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
|
||||
// ROOT
|
||||
#include "TROOT.h"
|
||||
#include "TApplication.h"
|
||||
#include "TSystem.h"
|
||||
#include "TH1.h"
|
||||
#include "TPad.h"
|
||||
#include "TCanvas.h"
|
||||
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
LEMuSRRunAction::LEMuSRRunAction()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
LEMuSRRunAction::~LEMuSRRunAction()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void LEMuSRRunAction::BeginOfRunAction(const G4Run* aRun)
|
||||
{
|
||||
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
|
||||
|
||||
G4RunManager::GetRunManager()->SetRandomNumberStore(true);
|
||||
|
||||
if (G4VVisManager::GetConcreteInstance())
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
UI->ApplyCommand("/vis/scene/notifyHandlers");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void LEMuSRRunAction::EndOfRunAction(const G4Run*)
|
||||
{
|
||||
if (G4VVisManager::GetConcreteInstance())
|
||||
{
|
||||
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
75
geant4/LEMuSR/src/LEMuSRScintHit.cc
Normal file
75
geant4/LEMuSR/src/LEMuSRScintHit.cc
Normal file
@ -0,0 +1,75 @@
|
||||
#include "LEMuSRScintHit.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4Circle.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <fstream.h>
|
||||
#include <iomanip.h>
|
||||
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
G4Allocator<LEMuSRScintHit> LEMuSRScintHitAllocator;
|
||||
|
||||
LEMuSRScintHit::LEMuSRScintHit()
|
||||
{;}
|
||||
|
||||
LEMuSRScintHit::~LEMuSRScintHit()
|
||||
{;}
|
||||
|
||||
LEMuSRScintHit::LEMuSRScintHit(const LEMuSRScintHit &right) : G4VHit()
|
||||
{
|
||||
particle_name = right.particle_name;
|
||||
energy_deposition = right.energy_deposition;
|
||||
time_of_flight = right.time_of_flight;
|
||||
position = right.position;
|
||||
momentum = right.momentum;
|
||||
}
|
||||
|
||||
const LEMuSRScintHit& LEMuSRScintHit::operator=(const LEMuSRScintHit &right)
|
||||
{
|
||||
particle_name = right.particle_name;
|
||||
energy_deposition = right.energy_deposition;
|
||||
time_of_flight = right.time_of_flight;
|
||||
position = right.position;
|
||||
momentum = right.momentum;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4int LEMuSRScintHit::operator==(const LEMuSRScintHit &right) const
|
||||
{
|
||||
return (this==&right) ? 1 : 0;
|
||||
}
|
||||
|
||||
void LEMuSRScintHit::Draw()
|
||||
{
|
||||
G4VVisManager* VisManager = G4VVisManager::GetConcreteInstance();
|
||||
if(VisManager)
|
||||
{
|
||||
G4Circle circle(position);
|
||||
circle.SetScreenSize(0.1);
|
||||
circle.SetFillStyle(G4Circle::filled);
|
||||
G4Colour colour(1.,1.,1.);
|
||||
G4VisAttributes attributes(colour);
|
||||
circle.SetVisAttributes(attributes);
|
||||
VisManager->Draw(circle);
|
||||
}
|
||||
}
|
||||
|
||||
void LEMuSRScintHit::Print()
|
||||
{}
|
||||
|
||||
void LEMuSRScintHit::print(G4String name)
|
||||
{
|
||||
ofstream TestPrint(name,ios::app);
|
||||
if (!TestPrint.is_open()) exit(8);
|
||||
TestPrint << "particle_name : " << particle_name <<" ;\n"
|
||||
<< "energy_deposition : " << G4BestUnit(energy_deposition,"Energy") <<" ;\n "
|
||||
<< "time_of_flight : " << G4BestUnit(time_of_flight,"Time") <<" ;\n "
|
||||
<< "position : " << position <<" ;\n "
|
||||
<< "momentum : " << momentum <<" ;\n "
|
||||
<<G4endl;
|
||||
|
||||
}
|
238
geant4/LEMuSR/src/LEMuSRScintSD.cc
Normal file
238
geant4/LEMuSR/src/LEMuSRScintSD.cc
Normal file
@ -0,0 +1,238 @@
|
||||
#include "LEMuSRScintSD.hh"
|
||||
#include "G4HCofThisEvent.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4VProcess.hh"
|
||||
|
||||
// ROOT
|
||||
#include "TROOT.h"
|
||||
#include "TApplication.h"
|
||||
#include "TSystem.h"
|
||||
#include "TH1.h"
|
||||
#include "TPad.h"
|
||||
#include "TCanvas.h"
|
||||
|
||||
|
||||
LEMuSRScintSD::LEMuSRScintSD(G4String name)
|
||||
:G4VSensitiveDetector(name)
|
||||
{
|
||||
|
||||
G4String HCname;
|
||||
collectionName.insert(HCname="InnerScintCollection");
|
||||
positionResolution = 1*mm;
|
||||
|
||||
|
||||
// ROOT
|
||||
BookRoot();
|
||||
}
|
||||
|
||||
LEMuSRScintSD::~LEMuSRScintSD()
|
||||
{
|
||||
// ROOT
|
||||
WriteRoot();
|
||||
}
|
||||
|
||||
void LEMuSRScintSD::Initialize(G4HCofThisEvent* HCE)
|
||||
{
|
||||
static int HCID = -1;
|
||||
ScintCollection = new LEMuSRScintHitsCollection
|
||||
(SensitiveDetectorName,collectionName[0]);
|
||||
if(HCID<0)
|
||||
{ HCID = GetCollectionID(0); }
|
||||
HCE->AddHitsCollection(HCID,ScintCollection);
|
||||
}
|
||||
|
||||
G4bool LEMuSRScintSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
|
||||
{
|
||||
p_name = aStep->GetTrack()->GetDefinition()->GetParticleName(); // particle name
|
||||
|
||||
|
||||
if( CheckCondition(aStep))
|
||||
{
|
||||
GetDatas(aStep);
|
||||
getHit();
|
||||
FillRoot();
|
||||
|
||||
}
|
||||
aStep->GetTrack()->SetTrackStatus(fStopAndKill);
|
||||
|
||||
// PrintAll();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void LEMuSRScintSD::EndOfEvent(G4HCofThisEvent*)
|
||||
{
|
||||
// G4int NbHits = ScintCollection->entries();
|
||||
// G4cout << "\n-------->Hits Collection: in this event they are " << NbHits
|
||||
// << " hits in the inner scintillator: " << G4endl;
|
||||
// for (G4int i=0;i<NbHits;i++) (*ScintCollection)[i]->Print();
|
||||
|
||||
}
|
||||
|
||||
G4bool LEMuSRScintSD::CheckCondition(const G4Step* aStep)
|
||||
{
|
||||
G4bool condition=false;
|
||||
|
||||
if(p_name == "e+")//&&aStep->GetTrack()->GetNextVolume()->GetLogicalVolume()->GetName()!="lv_SCIS")
|
||||
{
|
||||
condition=true;
|
||||
if( aStep->GetTrack()->GetCreatorProcess())
|
||||
{
|
||||
if( aStep->GetTrack()->GetCreatorProcess()->GetProcessName()=="Decay"|| aStep->GetTrack()->GetCreatorProcess()->GetProcessName()=="DecayWithSpin")
|
||||
{
|
||||
condition=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return condition;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LEMuSRScintSD::clear()
|
||||
{
|
||||
delete ScintCollection;
|
||||
}
|
||||
|
||||
void LEMuSRScintSD::DrawAll()
|
||||
{
|
||||
}
|
||||
|
||||
void LEMuSRScintSD::PrintAll()
|
||||
{
|
||||
// Define Hit
|
||||
|
||||
// G4cout << "PROCESS HIT"<<G4endl;
|
||||
|
||||
LEMuSRScintHit* aHit;
|
||||
aHit = new LEMuSRScintHit();
|
||||
|
||||
//++++++++++++++ set hit values _______________
|
||||
aHit->SetParticleName(p_name);
|
||||
aHit->SetSpin(spin);
|
||||
|
||||
aHit->SetMomentum( hitmom );
|
||||
aHit->SetPosition( hitpos );
|
||||
|
||||
aHit->SetTimeOfFlight( tof);
|
||||
aHit->SetEnergyDeposition( edep );
|
||||
|
||||
|
||||
// ScintCollection->insert( aHit );
|
||||
// aHit->Print();
|
||||
// aHit->print("Statistics/SCIS.Hits");
|
||||
// aHit->Draw();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LEMuSRScintSD::GetDatas(const G4Step *aStep)
|
||||
{
|
||||
// Get datas
|
||||
//a Volume, name, spin
|
||||
vname = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName();
|
||||
spin= aStep->GetTrack()->GetDefinition()->GetPDGSpin(); // spin in units of 1
|
||||
|
||||
//b Position momentum
|
||||
hitpos = aStep->GetTrack()->GetPosition(); // position
|
||||
hitmom = aStep->GetTrack()->GetMomentumDirection(); // momentum
|
||||
hitvertex = aStep->GetTrack()->GetVertexPosition();// creation position
|
||||
//c Times
|
||||
tof = aStep->GetTrack()->GetLocalTime(); // time since track creation
|
||||
globaltime = aStep->GetTrack()->GetGlobalTime();// time since event creation
|
||||
proptime = aStep->GetTrack()->GetProperTime(); // particle's proper time
|
||||
|
||||
//d Energy
|
||||
edep = aStep->GetTotalEnergyDeposit();
|
||||
|
||||
toten = aStep->GetTrack()->GetTotalEnergy();
|
||||
|
||||
kinen = aStep->GetTrack()->GetKineticEnergy();
|
||||
|
||||
//e Scint scintID
|
||||
|
||||
|
||||
//f runID
|
||||
runID=G4RunManager::GetRunManager()->GetCurrentRun()->GetRunID();
|
||||
|
||||
//g parent charge: 0 for muonium and 1 for muon
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LEMuSRScintSD::getHit()
|
||||
{
|
||||
theHit.kenergy = kinen;
|
||||
theHit.tenergy = toten;
|
||||
theHit.edeposit = edep;
|
||||
theHit.localtime = tof;
|
||||
theHit.globaltime = globaltime;
|
||||
theHit.proptime = proptime;
|
||||
theHit.positionx = hitpos.x();
|
||||
theHit.positiony = hitpos.y();
|
||||
theHit.positionz = hitpos.z();
|
||||
theHit.momdirx = hitmom.x();
|
||||
theHit.momdiry = hitmom.y();
|
||||
theHit.momdirz = hitmom.z();
|
||||
theHit.ipositionx = hitvertex.x();
|
||||
theHit.ipositiony = hitvertex.y();
|
||||
theHit.ipositionz = hitvertex.z();
|
||||
theHit.runID = runID;
|
||||
theHit.motherCharge = runID;
|
||||
|
||||
theHit.scLeft = 0;
|
||||
theHit.scBottom =0 ;
|
||||
theHit.scRight =0;
|
||||
theHit.scTop = 0;
|
||||
|
||||
if (vname=="pv_SCISl")
|
||||
{
|
||||
theHit.scLeft = 1;
|
||||
}
|
||||
else if (vname=="pv_SCISb")
|
||||
{
|
||||
theHit.scBottom =1 ;
|
||||
}
|
||||
else if (vname=="pv_SCISr")
|
||||
{
|
||||
theHit.scRight =1;
|
||||
}
|
||||
else if (vname=="pv_SCISt")
|
||||
{
|
||||
theHit.scTop = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// ROOT METHODS
|
||||
|
||||
void LEMuSRScintSD::BookRoot()
|
||||
{
|
||||
// open root file
|
||||
myFile = new TFile("SDInnerScint.root", "RECREATE");
|
||||
// myFile->SetCompressionLevel(1);
|
||||
|
||||
tree = new TTree ("tree","Inner Scintillator Datas");
|
||||
|
||||
tree->Branch("positron",&theHit.kenergy,"kenergy/F:tenergy/F:edeposit/F:localtime/F:globaltime:propertime/F:positionx/F:positiony:positionz:momentumx:momentumy:momentumz/F:initx/F:inity/F:initz/F:Left/F:Right/F:Bottom/F:Top/F:runID/I:parentCharge/F");
|
||||
|
||||
}
|
||||
|
||||
void LEMuSRScintSD::FillRoot()
|
||||
{
|
||||
tree->Fill();
|
||||
}
|
||||
|
||||
void LEMuSRScintSD::WriteRoot()
|
||||
{
|
||||
myFile->Write();
|
||||
myFile->Close();
|
||||
}
|
94
geant4/LEMuSR/src/LEMuSRStackingAction.cc
Normal file
94
geant4/LEMuSR/src/LEMuSRStackingAction.cc
Normal file
@ -0,0 +1,94 @@
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION Geant4 SIMULATION
|
||||
// ID : LEMuSRStackingAction.cc , v 1.0
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-07-07 11:15
|
||||
//
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// STACKING ACTION.CC
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "LEMuSRStackingAction.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4HCofThisEvent.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4TrackStatus.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "LEMuSRStackingActionMessenger.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
LEMuSRStackingAction::LEMuSRStackingAction()
|
||||
:ScintHits(0), stage(0)
|
||||
{
|
||||
theMessenger = new LEMuSRStackingActionMessenger(this);
|
||||
}
|
||||
|
||||
LEMuSRStackingAction::~LEMuSRStackingAction()
|
||||
{
|
||||
delete theMessenger;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4ClassificationOfNewTrack
|
||||
LEMuSRStackingAction::ClassifyNewTrack(const G4Track *)
|
||||
{
|
||||
G4ClassificationOfNewTrack classification;
|
||||
classification = fUrgent;
|
||||
return classification;
|
||||
}
|
||||
|
||||
|
||||
G4VHitsCollection* LEMuSRStackingAction::GetCollection(G4String colName)
|
||||
{
|
||||
G4SDManager* SDMan = G4SDManager::GetSDMpointer();
|
||||
G4RunManager* runMan = G4RunManager::GetRunManager();
|
||||
int colID = SDMan->GetCollectionID(colName);
|
||||
if(colID>=0)
|
||||
{
|
||||
const G4Event* currentEvent = runMan->GetCurrentEvent();
|
||||
G4HCofThisEvent* HCE = currentEvent->GetHCofThisEvent();
|
||||
return HCE->GetHC(colID);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LEMuSRStackingAction::NewStage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LEMuSRStackingAction::PrepareNewEvent()
|
||||
{
|
||||
stage = 0;
|
||||
ScintHits = 0;
|
||||
}
|
||||
|
||||
|
27
geant4/LEMuSR/src/LEMuSRStackingActionMessenger.cc
Normal file
27
geant4/LEMuSR/src/LEMuSRStackingActionMessenger.cc
Normal file
@ -0,0 +1,27 @@
|
||||
#include "LEMuSRStackingActionMessenger.hh"
|
||||
#include "LEMuSRStackingAction.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
LEMuSRStackingActionMessenger::LEMuSRStackingActionMessenger(LEMuSRStackingAction * msa)
|
||||
:myAction(msa)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
LEMuSRStackingActionMessenger::~LEMuSRStackingActionMessenger()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
void LEMuSRStackingActionMessenger::SetNewValue(G4UIcommand *,G4String)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
G4String LEMuSRStackingActionMessenger::GetCurrentValue(G4UIcommand *)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
268
geant4/LEMuSR/src/LEMuSRSteppingAction.cc
Normal file
268
geant4/LEMuSR/src/LEMuSRSteppingAction.cc
Normal file
@ -0,0 +1,268 @@
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION Geant4 SIMULATION
|
||||
// ID : LEMuSRSteppingAction.cc , v 1.0
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-07-07 11:15
|
||||
//
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// STEPPING ACTION.CC
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
|
||||
|
||||
|
||||
#include "LEMuSRSteppingAction.hh"
|
||||
#include "G4SteppingManager.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4DynamicParticle.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "LEMuSRDecay.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4Polyline.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
|
||||
|
||||
LEMuSRSteppingAction::LEMuSRSteppingAction()
|
||||
{
|
||||
pointer=this ;
|
||||
loop=0;
|
||||
}
|
||||
|
||||
|
||||
LEMuSRSteppingAction::~LEMuSRSteppingAction()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
LEMuSRSteppingAction* LEMuSRSteppingAction::pointer=0;
|
||||
LEMuSRSteppingAction* LEMuSRSteppingAction::GetInstance()
|
||||
{
|
||||
return pointer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LEMuSRSteppingAction::UserSteppingAction(const G4Step* aStep)
|
||||
|
||||
{
|
||||
LoopKiller(aStep);
|
||||
|
||||
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
|
||||
G4String p_name;
|
||||
p_name = aStep->GetTrack()->GetDefinition()->GetParticleName(); // particle name
|
||||
if (pVVisManager) {
|
||||
//----- Define a line segment
|
||||
G4Polyline polyline;
|
||||
G4Colour colour;
|
||||
if (p_name == "mu+") colour = G4Colour(1., 0., 0.);
|
||||
else if (p_name == "Mu" ) colour = G4Colour(0., 0., 1.);
|
||||
else if (p_name == "e+" ) colour = G4Colour(1., 1., 0.);
|
||||
else colour = G4Colour(1., 0., 1.);
|
||||
G4VisAttributes attribs(colour);
|
||||
polyline.SetVisAttributes(attribs);
|
||||
polyline.push_back(aStep->GetPreStepPoint()->GetPosition());
|
||||
polyline.push_back(aStep->GetPostStepPoint()->GetPosition());
|
||||
|
||||
//----- Call a drawing method for G4Polyline
|
||||
pVVisManager -> Draw(polyline);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LEMuSRSteppingAction::LoopKiller(const G4Step *aStep)
|
||||
{
|
||||
// loop killa
|
||||
if(aStep->GetTrack()->GetCurrentStepNumber()>2500)
|
||||
{
|
||||
aStep->GetTrack()->SetTrackStatus(fStopAndKill);
|
||||
G4cout<<"killed "<<G4endl;
|
||||
}
|
||||
|
||||
if(aStep->GetTrack()->GetDefinition()->GetParticleName()=="e-"
|
||||
||aStep->GetTrack()->GetDefinition()->GetParticleName()=="gamma"
|
||||
||aStep->GetTrack()->GetDefinition()->GetParticleName()=="nu_e"
|
||||
||aStep->GetTrack()->GetDefinition()->GetParticleName()=="anti_nu_e"
|
||||
||aStep->GetTrack()->GetDefinition()->GetParticleName()=="nu_mu"
|
||||
||aStep->GetTrack()->GetDefinition()->GetParticleName()=="anti_nu_mu")
|
||||
{
|
||||
aStep->GetTrack()->SetTrackStatus(fStopAndKill);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void LEMuSRSteppingAction:: FieldInfo(const G4Step *aStep)
|
||||
{
|
||||
|
||||
G4String p_name;
|
||||
p_name = aStep->GetTrack()->GetDefinition()->GetParticleName(); // particle name
|
||||
G4String v_name = aStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetName();
|
||||
|
||||
if( aStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetFieldManager())
|
||||
{
|
||||
|
||||
G4cout << "Field Manager...OK: \n"
|
||||
<< "particle name : " << p_name <<" ;\n "
|
||||
<< "volume name : " << v_name <<" ;\n "
|
||||
<< "position : " << aStep->GetPostStepPoint()->GetPosition() <<" ;\n "
|
||||
<< "kenergy : " << aStep->GetTrack()->GetKineticEnergy()<<" ;\n "
|
||||
<< "momentum direction: " << aStep->GetPostStepPoint()->GetMomentumDirection() <<" ;\n "
|
||||
<< "polarization : " << aStep->GetPostStepPoint()->GetPolarization() <<" ;\n "
|
||||
<< "time : " << aStep->GetPostStepPoint()->GetGlobalTime() <<" ;\n " ;
|
||||
// field datas
|
||||
// G4cout << "Field Step : " << aStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetFieldManager()->GetDeltaOneStep() <<" ;\n " ;
|
||||
double point[4];
|
||||
point[0]= aStep->GetPostStepPoint()->GetPosition().x()/mm/100;
|
||||
point[1]= aStep->GetPostStepPoint()->GetPosition().y()/mm/100;
|
||||
point[2]= aStep->GetPostStepPoint()->GetPosition().z()/mm/100 + 5.67;
|
||||
double field[6];
|
||||
aStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetFieldManager()->GetDetectorField()->GetFieldValue(point,field);
|
||||
G4cout <<"pOSITION : "<< point[0] <<" "<<point[1]<<" "<<point[2] <<" ;\n "
|
||||
<< "Field direction : " << field[0] <<" "<<field[1]<<" "<<field[2] <<" ;\n " ;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LEMuSRSteppingAction:: ParticleInfo(const G4Step *aStep)
|
||||
{
|
||||
G4String p_name;
|
||||
p_name = aStep->GetTrack()->GetDefinition()->GetParticleName(); // particle name
|
||||
G4String v_name = aStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetName();
|
||||
|
||||
// Get datas
|
||||
//a
|
||||
if(aStep->GetTrack()->GetDefinition())
|
||||
{
|
||||
p_name = aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->GetParticleName(); // particle name
|
||||
|
||||
// if(p_name == "mu+")
|
||||
// {
|
||||
G4String nv_name;
|
||||
G4String v_name = aStep->GetTrack()->GetVolume()->GetName(); // particle name
|
||||
if(v_name!="pv_World")
|
||||
{
|
||||
nv_name = aStep->GetTrack()->GetNextVolume()->GetName(); // particle name
|
||||
}
|
||||
else if(v_name=="pv_World")
|
||||
{
|
||||
nv_name=v_name;
|
||||
}
|
||||
|
||||
G4double spin= aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->GetPDGSpin(); // spin in units of 1
|
||||
//b
|
||||
G4ThreeVector position = aStep->GetPostStepPoint()->GetPosition(); // position
|
||||
G4ThreeVector momentum = aStep->GetPostStepPoint()->GetMomentum(); // momentum
|
||||
//c
|
||||
G4double tof = aStep->GetTrack()->GetLocalTime(); // time since track creation
|
||||
G4double globaltime = aStep->GetTrack()->GetGlobalTime();// time since the event in which the track belongs is created.
|
||||
G4double proptime = aStep->GetTrack()->GetProperTime(); // proper time of the particle
|
||||
//d
|
||||
G4double edep = aStep->GetTotalEnergyDeposit();
|
||||
|
||||
// Print Datas
|
||||
|
||||
if( aStep->GetTrack()->GetCreatorProcess())
|
||||
{
|
||||
G4cout << "NOT PRIMARY PARTICLE : created by : " << aStep->GetTrack()->GetCreatorProcess()->GetProcessName() <<" ;\n ";
|
||||
// G4cout << "Parent particles are : " << aStep->GetTrack()->GetCreatorProcess()->GetProcessName() <<" ;\n ";
|
||||
|
||||
}
|
||||
|
||||
G4cout << "particle name : " << p_name <<" ;\n "
|
||||
<< "volume name : " << v_name <<" ;\n "
|
||||
<< "next volume name : " << nv_name <<" ;\n "
|
||||
<< "spin : " << spin <<" ;\n "
|
||||
<< "current energy : " << aStep->GetTrack()->GetDynamicParticle()->GetKineticEnergy()/keV <<" keV;\n "
|
||||
<< "energy_deposition : " << G4BestUnit(edep,"Energy") <<" ;\n "
|
||||
<< "time_of_flight : " << G4BestUnit(tof,"Time") <<" ; " << G4BestUnit(globaltime,"Time")<<" ; " << G4BestUnit(proptime,"Time") <<" ;\n "
|
||||
<< "position : " << position <<" ;\n "
|
||||
<< "momentum : " << momentum <<" ;\n "
|
||||
<< "polarization : " << aStep->GetTrack()->GetDynamicParticle()->GetPolarization() <<" ;\n " ;
|
||||
if(aStep->GetPostStepPoint()->GetProcessDefinedStep()){
|
||||
G4cout << "process : " << aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() <<"\n"
|
||||
<<G4endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// }
|
||||
}
|
9
geant4/LEMuSR/src/LEMuSRTrack.cc
Normal file
9
geant4/LEMuSR/src/LEMuSRTrack.cc
Normal file
@ -0,0 +1,9 @@
|
||||
#include "LEMuSRTrack.hh"
|
||||
|
||||
|
||||
void LEMuSRTrack::SetDynamicParticle(G4DynamicParticle particle)
|
||||
{
|
||||
G4DynamicParticle *theParticle;
|
||||
// theParticle = this->GetDynamicParticle();
|
||||
*theParticle = particle;
|
||||
}
|
42
geant4/LEMuSR/src/LEMuSRTrackingAction.cc
Normal file
42
geant4/LEMuSR/src/LEMuSRTrackingAction.cc
Normal file
@ -0,0 +1,42 @@
|
||||
#include"LEMuSRTrackingAction.hh"
|
||||
#include"G4VProcess.hh"
|
||||
#include"G4PrimaryParticle.hh"
|
||||
#include"G4UnitsTable.hh"
|
||||
#include"LEMuSRMuonDecayChannel.hh"
|
||||
|
||||
|
||||
LEMuSRTrackingAction ::LEMuSRTrackingAction()
|
||||
{
|
||||
|
||||
|
||||
|
||||
;}
|
||||
|
||||
LEMuSRTrackingAction:: ~LEMuSRTrackingAction()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LEMuSRTrackingAction::PreUserTrackingAction(const G4Track* theTrack)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LEMuSRTrackingAction::Collect_datas(const G4Track* theTrack)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void LEMuSRTrackingAction::PostUserTrackingAction(const G4Track*)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
113
geant4/LEMuSR/src/LEMuSRVisManager.cc
Normal file
113
geant4/LEMuSR/src/LEMuSRVisManager.cc
Normal file
@ -0,0 +1,113 @@
|
||||
|
||||
#ifdef G4VIS_USE
|
||||
|
||||
#include "LEMuSRVisManager.hh"
|
||||
|
||||
// Supported drivers...
|
||||
|
||||
// Not needing external packages or libraries...
|
||||
#include "G4ASCIITree.hh"
|
||||
#include "G4DAWNFILE.hh"
|
||||
#include "G4GAGTree.hh"
|
||||
#include "G4HepRepFile.hh"
|
||||
#include "G4HepRep.hh"
|
||||
#include "G4RayTracer.hh"
|
||||
#include "G4VRML1File.hh"
|
||||
#include "G4VRML2File.hh"
|
||||
|
||||
// Needing external packages or libraries...
|
||||
|
||||
#ifdef G4VIS_USE_DAWN
|
||||
#include "G4FukuiRenderer.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OPENGLX
|
||||
#include "G4OpenGLImmediateX.hh"
|
||||
#include "G4OpenGLStoredX.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OPENGLWIN32
|
||||
#include "G4OpenGLImmediateWin32.hh"
|
||||
#include "G4OpenGLStoredWin32.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OPENGLXM
|
||||
#include "G4OpenGLImmediateXm.hh"
|
||||
#include "G4OpenGLStoredXm.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OIX
|
||||
#include "G4OpenInventorX.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OIWIN32
|
||||
#include "G4OpenInventorWin32.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_VRML
|
||||
#include "G4VRML1.hh"
|
||||
#include "G4VRML2.hh"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
LEMuSRVisManager::LEMuSRVisManager () {;}
|
||||
|
||||
LEMuSRVisManager::~LEMuSRVisManager () {;}
|
||||
|
||||
void LEMuSRVisManager::RegisterGraphicsSystems () {
|
||||
|
||||
// Graphics Systems not needing external packages or libraries...
|
||||
RegisterGraphicsSystem (new G4ASCIITree);
|
||||
RegisterGraphicsSystem (new G4DAWNFILE);
|
||||
RegisterGraphicsSystem (new G4GAGTree);
|
||||
RegisterGraphicsSystem (new G4HepRepFile);
|
||||
RegisterGraphicsSystem (new G4HepRep);
|
||||
RegisterGraphicsSystem (new G4RayTracer);
|
||||
RegisterGraphicsSystem (new G4VRML1File);
|
||||
RegisterGraphicsSystem (new G4VRML2File);
|
||||
|
||||
// Graphics systems needing external packages or libraries...
|
||||
|
||||
#ifdef G4VIS_USE_DAWN
|
||||
RegisterGraphicsSystem (new G4FukuiRenderer);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OPENGLX
|
||||
RegisterGraphicsSystem (new G4OpenGLImmediateX);
|
||||
RegisterGraphicsSystem (new G4OpenGLStoredX);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OPENGLWIN32
|
||||
RegisterGraphicsSystem (new G4OpenGLImmediateWin32);
|
||||
RegisterGraphicsSystem (new G4OpenGLStoredWin32);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OPENGLXM
|
||||
RegisterGraphicsSystem (new G4OpenGLImmediateXm);
|
||||
RegisterGraphicsSystem (new G4OpenGLStoredXm);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OIX
|
||||
RegisterGraphicsSystem (new G4OpenInventorX);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OIWIN32
|
||||
RegisterGraphicsSystem (new G4OpenInventorWin32);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_VRML
|
||||
RegisterGraphicsSystem (new G4VRML1);
|
||||
RegisterGraphicsSystem (new G4VRML2);
|
||||
#endif
|
||||
|
||||
if (fVerbose > 0) {
|
||||
G4cout <<
|
||||
"\nYou have successfully chosen to use the following graphics systems."
|
||||
<< G4endl;
|
||||
PrintAvailableGraphicsSystems ();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
225
geant4/LEMuSR/src/LEMuSRdummydets.cc
Normal file
225
geant4/LEMuSR/src/LEMuSRdummydets.cc
Normal file
@ -0,0 +1,225 @@
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID : LEMuSRDetectorConstruction.cc , v 1.0
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2004-06-24 16:33
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// DETECTOR CONSTRUCTION
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
|
||||
// G4 GEOMETRIC FORMS CLASSES
|
||||
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Trap.hh"
|
||||
#include "G4Cons.hh"
|
||||
#include "G4Sphere.hh"
|
||||
#include "G4SubtractionSolid.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
// G4 VOLUME DEFINITION CLASSES
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4PropagatorInField.hh"
|
||||
#include "LEMuSRMag_SpinEqRhs.hh"
|
||||
#include "G4Mag_SpinEqRhs.hh"
|
||||
#include "G4ChordFinder.hh"
|
||||
#include "G4El_UsualEqRhs.hh"
|
||||
#include "G4ClassicalRK4.hh"
|
||||
#include "G4SimpleHeum.hh"
|
||||
#include "G4SimpleRunge.hh"
|
||||
#include "G4MagIntegratorStepper.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
//#include "G4RotationMatrix.hh"
|
||||
|
||||
// G4 CLASSES
|
||||
#include "G4ios.hh"
|
||||
#include <iomanip.h>
|
||||
|
||||
|
||||
// HEADER
|
||||
#include "LEMuSRDetectorConstruction.hh"
|
||||
#include "LEMuSRDetectorMessenger.hh"
|
||||
|
||||
|
||||
// process remove
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleChange.hh"
|
||||
#include "G4ProcessVector.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4VProcess.hh"
|
||||
|
||||
// electric fieldmap
|
||||
#include "LEMuSRElectricField.hh"
|
||||
#include "LEMuSRElFieldMix.hh"
|
||||
#include "G4ElectricField.hh"
|
||||
#include "G4ElectroMagneticField.hh"
|
||||
#include "G4EqMagElectricField.hh"
|
||||
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
|
||||
|
||||
///§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
// DEFINE THE ASYMETRY DUMMY DETECTORS
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
|
||||
void LEMuSRDetectorConstruction::lemuAsym()
|
||||
{
|
||||
|
||||
|
||||
// solids
|
||||
Asym_tube = new G4Tubs("sAsym",0.*cm,1*cm,0.0000001*cm, dSPhi, dEPhi);
|
||||
|
||||
G4Sphere *Asym_sphl = new G4Sphere("sphAsymL",25*cm,25.001*cm,0.*deg,360*deg,90*deg,90*deg);
|
||||
G4Sphere *Asym_sphr = new G4Sphere("sphAsymR",25*cm,25.001*cm,0.*deg,360*deg,0*deg,90*deg);
|
||||
|
||||
// logical volumes
|
||||
lv_Asym = new G4LogicalVolume(Asym_tube,G4Material::GetMaterial("vacuum"),"lv_Asym",0,0,0);
|
||||
|
||||
lv_AsymL = new G4LogicalVolume(Asym_sphl,G4Material::GetMaterial("vacuum"),"lv_AsymL",0,0,0);
|
||||
lv_AsymR = new G4LogicalVolume(Asym_sphr,G4Material::GetMaterial("vacuum"),"lv_AsymR",0,0,0);
|
||||
|
||||
// G4Translate3D trl =G4ThreeVector(+50.*cm,0.*cm,0.*cm); //uncomment
|
||||
Asym_rotation = G4RotateY3D(90*deg);
|
||||
|
||||
// G4Transform3D asymt3d= trl;//*Asym_rotation;//uncomment
|
||||
// pv_Asym = new G4PVPlacement( asymt3d,lv_Asym,"pv_Asym1",lv_LABO, false, 0 );//uncomment
|
||||
|
||||
// G4Translate3D trl2 =G4ThreeVector(-50.*cm,0.*cm,0.*cm);//uncomment
|
||||
|
||||
// G4Transform3D asymt3d2= trl2*Asym_rotation;//uncomment
|
||||
//pv_Asym2 = new G4PVPlacement( asymt3d2,lv_Asym,"pv_Asym2",lv_LABO, false, 0 );//uncomment
|
||||
|
||||
pv_AsymL = new G4PVPlacement(Asym_rotation ,lv_AsymL,"pv_AsymL",lv_LABO, false, 0 );
|
||||
pv_AsymR = new G4PVPlacement(Asym_rotation ,lv_AsymR,"pv_AsymR",lv_LABO, false, 0 );
|
||||
|
||||
//visual attibutes
|
||||
// lv_Asym->SetVisAttributes(VTBB_style);
|
||||
|
||||
lv_AsymL->SetVisAttributes(Green_style);
|
||||
lv_AsymR->SetVisAttributes(dRed_style);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
// DEFINE THE ELECTRIC FIELD DUMMY DETECTORS
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
void LEMuSRDetectorConstruction::lemuFieldCheck()
|
||||
{
|
||||
|
||||
// solids
|
||||
fchk_tube = new G4Tubs("tube_fchk", 0., 6*cm, 0.001*mm, dSPhi, dEPhi);
|
||||
|
||||
lv_fchk = new G4LogicalVolume(fchk_tube,G4Material::GetMaterial("vacuum"),"lv_fchk",0 ,0 ,0 );
|
||||
lv_fchk2 = new G4LogicalVolume(fchk_tube,G4Material::GetMaterial("vacuum"),"lv_fchk",0 ,0 ,0 );
|
||||
lv_fchk3 = new G4LogicalVolume(fchk_tube,G4Material::GetMaterial("vacuum"),"lv_fchk",0 ,0 ,0 );
|
||||
|
||||
|
||||
pv_fchk = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,0*cm),lv_fchk,"pv_f0",lv_L3VA, false, 0 );
|
||||
pv_fchk1 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,-22*cm),lv_fchk,"pv_f1",lv_L3VA, false, 0 );
|
||||
/* pv_fchk2 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -21*cm),lv_fchk,"pv_f2",lv_L3VA, false, 0 );
|
||||
pv_fchk3 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -20*cm),lv_fchk,"pv_f3",lv_L3VA, false, 0 );
|
||||
pv_fchk4 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -19*cm),lv_fchk,"pv_f4",lv_L3VA, false, 0 );
|
||||
pv_fchk5 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -18*cm),lv_fchk,"pv_f5",lv_L3VA, false, 0 );
|
||||
pv_fchk6 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -17*cm),lv_fchk,"pv_f6",lv_L3VA, false, 0 );
|
||||
pv_fchk7 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -16*cm),lv_fchk,"pv_f7",lv_L3VA, false, 0 );
|
||||
pv_fchk8 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -15*cm),lv_fchk,"pv_f8",lv_L3VA, false, 0 );
|
||||
pv_fchk9 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -14*cm),lv_fchk,"pv_f9",lv_L3VA, false, 0 );
|
||||
pv_fchk10 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -13*cm),lv_fchk,"pv_f10",lv_L3VA, false, 0 );
|
||||
pv_fchk11 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -12*cm),lv_fchk,"pv_f11",lv_L3VA, false, 0 );
|
||||
pv_fchk12 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -11*cm),lv_fchk,"pv_f12",lv_L3VA, false, 0 );
|
||||
pv_fchk13 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -10*cm),lv_fchk,"pv_f13",lv_L3VA, false, 0 );
|
||||
pv_fchk14 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -9*cm),lv_fchk,"pv_f14",lv_L3VA, false, 0 );
|
||||
pv_fchk15 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -8*cm),lv_fchk,"pv_f15",lv_L3VA, false, 0 );
|
||||
pv_fchk16 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -7*cm),lv_fchk,"pv_f16",lv_L3VA, false, 0 );
|
||||
pv_fchk17 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -6*cm),lv_fchk,"pv_f17",lv_L3VA, false, 0 );
|
||||
pv_fchk18 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -5*cm),lv_fchk,"pv_f18",lv_L3VA, false, 0 );
|
||||
pv_fchk19 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -4*cm),lv_fchk,"pv_f19",lv_L3VA, false, 0 );
|
||||
pv_fchk20 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -3*cm),lv_fchk,"pv_f20",lv_L3VA, false, 0 );
|
||||
pv_fchk21 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -2*cm),lv_fchk,"pv_f21",lv_L3VA, false, 0 );
|
||||
pv_fchk22 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -1*cm),lv_fchk,"pv_f22",lv_L3VA, false, 0 );
|
||||
pv_fchk23 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +1*cm),lv_fchk,"pv_f23",lv_L3VA, false, 0 );
|
||||
pv_fchk24 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +2*cm),lv_fchk,"pv_f24",lv_L3VA, false, 0 );
|
||||
pv_fchk25 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +3*cm),lv_fchk,"pv_f25",lv_L3VA, false, 0 );
|
||||
pv_fchk26 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +4*cm),lv_fchk,"pv_f26",lv_L3VA, false, 0 );
|
||||
pv_fchk27 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +5*cm),lv_fchk,"pv_f27",lv_L3VA, false, 0 );
|
||||
pv_fchk28 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +6*cm),lv_fchk,"pv_f28",lv_L3VA, false, 0 );
|
||||
pv_fchk29 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +7*cm),lv_fchk,"pv_f29",lv_L3VA, false, 0 );
|
||||
pv_fchk30 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +8*cm),lv_fchk,"pv_f30",lv_L3VA, false, 0 );
|
||||
pv_fchk31 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +9*cm),lv_fchk,"pv_f31",lv_L3VA, false, 0 );
|
||||
pv_fchk32 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +10*cm),lv_fchk,"pv_f32",lv_L3VA, false, 0 );
|
||||
pv_fchk33 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +11*cm),lv_fchk,"pv_f33",lv_L3VA, false, 0 );
|
||||
pv_fchk34 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +12*cm),lv_fchk,"pv_f34",lv_L3VA, false, 0 );
|
||||
pv_fchk35 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +13*cm),lv_fchk,"pv_f35",lv_L3VA, false, 0 );
|
||||
pv_fchk36 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +14*cm),lv_fchk,"pv_f36",lv_L3VA, false, 0 );
|
||||
pv_fchk37 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +15*cm),lv_fchk,"pv_f37",lv_L3VA, false, 0 );
|
||||
pv_fchk38 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +16*cm),lv_fchk,"pv_f38",lv_L3VA, false, 0 );
|
||||
pv_fchk39 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +17*cm),lv_fchk,"pv_f39",lv_L3VA, false, 0 );
|
||||
pv_fchk40 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +18*cm),lv_fchk,"pv_f40",lv_L3VA, false, 0 );
|
||||
pv_fchk41 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +19*cm),lv_fchk,"pv_f41",lv_L3VA, false, 0 );
|
||||
pv_fchk42 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +20*cm),lv_fchk,"pv_f42",lv_L3VA, false, 0 );
|
||||
pv_fchk43 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +21*cm),lv_fchk,"pv_f43",lv_L3VA, false, 0 ); */
|
||||
pv_fchk44 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, +21.5*cm),lv_fchk,"pv_f44",lv_L3VA, false, 0 );
|
||||
|
||||
#ifndef LEMU_TEST_FOCAL_LENGTH
|
||||
// use another lv_fchk because belong to another mother volume
|
||||
pv_fchk45 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,(-8-25.45)*cm),lv_fchk2,"pv_f45",lv_RAV, false, 0 );
|
||||
pv_fchk46 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,(-7-25.45)*cm),lv_fchk2,"pv_f46",lv_RAV, false, 0 );
|
||||
pv_fchk47 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,(-5-25.45)*cm),lv_fchk2,"pv_f47",lv_RAV, false, 0 );
|
||||
pv_fchk48 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,(-2.5-25.45)*cm),lv_fchk2,"pv_f48",lv_RAV, false, 0 );
|
||||
pv_fchk49 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,(0-25.45)*cm),lv_fchk2,"pv_f49",lv_RAV, false, 0 );
|
||||
pv_fchk50 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,(2.5-25.45)*cm),lv_fchk2,"pv_f50",lv_RAV, false, 0 );
|
||||
pv_fchk51 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,(5-25.45)*cm),lv_fchk2,"pv_f51",lv_RAV, false, 0 );
|
||||
pv_fchk52 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,(7-25.45)*cm),lv_fchk2,"pv_f52",lv_RAV, false, 0 );
|
||||
pv_fchk53 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,(9-25.45)*cm),lv_fchk2,"pv_f53",lv_RAV, false, 0 );
|
||||
|
||||
|
||||
|
||||
|
||||
// use another lv_fchk because belong to another mother volume
|
||||
pv_fchk54 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,-16*cm),lv_fchk3,"pv_f54",lv_MCPV, false, 0 );
|
||||
pv_fchk55 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,-15*cm),lv_fchk3,"pv_f55",lv_MCPV, false, 0 );
|
||||
pv_fchk56 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,-14*cm),lv_fchk3,"pv_f56",lv_MCPV, false, 0 );
|
||||
pv_fchk57 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,-13*cm),lv_fchk3,"pv_f57",lv_MCPV, false, 0 );
|
||||
pv_fchk58 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,-12*cm),lv_fchk3,"pv_f58",lv_MCPV, false, 0 );
|
||||
pv_fchk59 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,-11*cm),lv_fchk3,"pv_f59",lv_MCPV, false, 0 );
|
||||
pv_fchk60 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,-10*cm),lv_fchk3,"pv_f60",lv_MCPV, false, 0 );
|
||||
pv_fchk61 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,-9*cm),lv_fchk3,"pv_f61",lv_MCPV, false, 0 );
|
||||
pv_fchk62 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm, -8*cm),lv_fchk3,"pv_f62",lv_MCPV, false, 0 );
|
||||
|
||||
pv_fchk64 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,-7*cm),lv_fchk3,"pv_f64",lv_MCPV, false, 0 );
|
||||
pv_fchk65 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,-6*cm),lv_fchk3,"pv_f65",lv_MCPV, false, 0 );
|
||||
pv_fchk66 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,-5*cm),lv_fchk3,"pv_f66",lv_MCPV, false, 0 );
|
||||
pv_fchk67 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,-4*cm),lv_fchk3,"pv_f67",lv_MCPV, false, 0 );
|
||||
pv_fchk68 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,-3*cm),lv_fchk3,"pv_f68",lv_MCPV, false, 0 );
|
||||
pv_fchk69 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,-2*cm),lv_fchk3,"pv_f69",lv_MCPV, false, 0 );
|
||||
pv_fchk70 = new G4PVPlacement( 0,G4ThreeVector(0.*cm,0.*cm,+1.75*cm),lv_fchk3,"pv_f70",lv_MCPV, false, 0 );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}
|
103
geant4/LEMuSR/src/PhysicsList.cc
Normal file
103
geant4/LEMuSR/src/PhysicsList.cc
Normal file
@ -0,0 +1,103 @@
|
||||
#include "PhysicsList.hh"
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
|
||||
#include "G4Material.hh"
|
||||
#include "G4MaterialTable.hh"
|
||||
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4ProcessVector.hh"
|
||||
|
||||
#include "G4DecayTable.hh"
|
||||
|
||||
#include "G4MuonDecayChannelWithSpin.hh"
|
||||
|
||||
PhysicsList::PhysicsList()
|
||||
{}
|
||||
|
||||
PhysicsList::~PhysicsList()
|
||||
{}
|
||||
|
||||
void PhysicsList::ConstructParticle()
|
||||
{
|
||||
G4Electron::ElectronDefinition();
|
||||
G4Positron::PositronDefinition();
|
||||
G4NeutrinoE::NeutrinoEDefinition();
|
||||
G4AntiNeutrinoE::AntiNeutrinoEDefinition();
|
||||
G4MuonPlus::MuonPlusDefinition();
|
||||
G4MuonMinus::MuonMinusDefinition();
|
||||
G4NeutrinoMu::NeutrinoMuDefinition();
|
||||
G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
|
||||
|
||||
G4DecayTable* MuonPlusDecayTable = new G4DecayTable();
|
||||
MuonPlusDecayTable -> Insert(new G4MuonDecayChannelWithSpin("mu+",1.00));
|
||||
G4MuonPlus::MuonPlusDefinition() -> SetDecayTable(MuonPlusDecayTable);
|
||||
|
||||
G4DecayTable* MuonMinusDecayTable = new G4DecayTable();
|
||||
MuonMinusDecayTable -> Insert(new G4MuonDecayChannelWithSpin("mu-",1.00));
|
||||
G4MuonMinus::MuonMinusDefinition() -> SetDecayTable(MuonMinusDecayTable);
|
||||
|
||||
}
|
||||
|
||||
void PhysicsList::ConstructProcess()
|
||||
{
|
||||
// Define transportation process
|
||||
|
||||
AddTransportation();
|
||||
|
||||
theDecayProcess = new G4DecayWithSpin();
|
||||
|
||||
G4ProcessManager* pManager;
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
pManager = particle->GetProcessManager();
|
||||
|
||||
if (theDecayProcess->IsApplicable(*particle)) {
|
||||
pManager->AddProcess(theDecayProcess);
|
||||
pManager ->SetProcessOrderingToLast(theDecayProcess, idxAtRest);
|
||||
}
|
||||
}
|
||||
|
||||
theMuPlusIonisation = new G4MuIonisation();
|
||||
theMuPlusMultipleScattering = new G4MultipleScattering();
|
||||
theMuPlusBremsstrahlung=new G4MuBremsstrahlung();
|
||||
theMuPlusPairProduction= new G4MuPairProduction();
|
||||
|
||||
theMuMinusIonisation = new G4MuIonisation();
|
||||
theMuMinusMultipleScattering = new G4MultipleScattering;
|
||||
theMuMinusBremsstrahlung = new G4MuBremsstrahlung();
|
||||
theMuMinusPairProduction = new G4MuPairProduction();
|
||||
|
||||
// Muon Plus Physics
|
||||
pManager = G4MuonPlus::MuonPlus()->GetProcessManager();
|
||||
pManager->AddProcess(theMuPlusMultipleScattering,-1, 1, 1);
|
||||
pManager->AddProcess(theMuPlusIonisation, -1, 2, 2);
|
||||
pManager->AddProcess(theMuPlusBremsstrahlung, -1, 3, 3);
|
||||
pManager->AddProcess(theMuPlusPairProduction, -1, 4, 4);
|
||||
|
||||
// Muon Minus Physics
|
||||
pManager = G4MuonMinus::MuonMinus()->GetProcessManager();
|
||||
pManager->AddProcess(theMuMinusMultipleScattering,-1, 1, 1);
|
||||
pManager->AddProcess(theMuMinusIonisation, -1, 2, 2);
|
||||
pManager->AddProcess(theMuMinusBremsstrahlung, -1, 3, 3);
|
||||
pManager->AddProcess(theMuMinusPairProduction, -1, 4, 4);
|
||||
|
||||
}
|
||||
|
||||
void PhysicsList::SetCuts()
|
||||
{
|
||||
// suppress error messages even in case e/gamma/proton do not exist
|
||||
G4int temp = GetVerboseLevel();
|
||||
SetVerboseLevel(0);
|
||||
|
||||
// " G4VUserPhysicsList::SetCutsWithDefault" method sets
|
||||
// the default cut value for all particle types
|
||||
SetCutsWithDefault();
|
||||
|
||||
// Retrieve verbose level
|
||||
SetVerboseLevel(temp);
|
||||
}
|
256
geant4/LEMuSR/src/TDCheck.cc
Normal file
256
geant4/LEMuSR/src/TDCheck.cc
Normal file
@ -0,0 +1,256 @@
|
||||
///§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
|
||||
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
|
||||
//
|
||||
// ID :TDCheck.cc , v 1.2
|
||||
// AUTHOR: Taofiq PARAISO
|
||||
// DATE : 2005-03-01 10:07
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
//
|
||||
// & &&&&&&&&&& &&&&&&& &&&&&&&&
|
||||
// & & && && & &&
|
||||
// & & & & & & &&
|
||||
// & &&&&&&& & & &&&&&& &&&&&&&&
|
||||
// & & & && & & &&
|
||||
// & & && & & && && & &
|
||||
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// &
|
||||
// TDCHECK
|
||||
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
|
||||
#include "TDCheck.hh"
|
||||
|
||||
#include "G4SteppingManager.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4DynamicParticle.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
|
||||
#include "LEMuSRDetectorConstruction.hh"
|
||||
#include "LEMuSRPrimaryGeneratorAction.hh"
|
||||
|
||||
|
||||
TDCheck::TDCheck()
|
||||
{
|
||||
|
||||
BookRoot();
|
||||
muon.thickness=0;
|
||||
pointer=this ;
|
||||
loop=0;
|
||||
oldz=0;
|
||||
thk_old=0;
|
||||
id=0;
|
||||
old_id=0;
|
||||
loop=0;
|
||||
}
|
||||
|
||||
|
||||
TDCheck::~TDCheck()
|
||||
{
|
||||
WriteRoot();
|
||||
}
|
||||
|
||||
TDCheck* TDCheck::pointer=0;
|
||||
TDCheck* TDCheck::GetInstance()
|
||||
{
|
||||
return pointer;
|
||||
}
|
||||
|
||||
|
||||
void TDCheck::UserSteppingAction(const G4Step* aStep)
|
||||
|
||||
{
|
||||
|
||||
if( aStep->GetPreStepPoint()&& aStep->GetPreStepPoint()->GetPhysicalVolume() )
|
||||
{
|
||||
SetParticleVolumeNames(aStep);
|
||||
|
||||
if(CheckCondition(aStep))
|
||||
{
|
||||
// Get datas
|
||||
SetPositionMomentum(aStep);
|
||||
SetTimeEnergy(aStep);
|
||||
Update();
|
||||
FillRoot();
|
||||
#if defined G4UI_USE_ROOT
|
||||
myFile->Write();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
LoopKiller(aStep);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
G4bool TDCheck::CheckCondition(const G4Step* )
|
||||
{
|
||||
G4bool condition=false;
|
||||
|
||||
if(v_name=="lv_CFOIL" )
|
||||
{
|
||||
if(p_name=="Mu" || p_name == "mu+")
|
||||
{
|
||||
condition=true;
|
||||
}
|
||||
}
|
||||
|
||||
if(v_name=="lv_SAH2" )
|
||||
{
|
||||
if(p_name=="Mu" || p_name == "mu+")
|
||||
{
|
||||
condition=true;
|
||||
}
|
||||
}
|
||||
|
||||
return condition;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TDCheck::LoopKiller(const G4Step *aStep)
|
||||
{
|
||||
// loop killa
|
||||
if(aStep->GetStepLength()<0.1*mm)
|
||||
{
|
||||
loop++;
|
||||
if(loop>20)
|
||||
{
|
||||
aStep->GetTrack()->SetTrackStatus(fStopAndKill);
|
||||
loop=0;
|
||||
}
|
||||
}
|
||||
|
||||
// kill useless particles
|
||||
if(aStep->GetTrack()->GetDefinition()->GetParticleName()=="e-"
|
||||
||aStep->GetTrack()->GetDefinition()->GetParticleName()=="gamma")
|
||||
{
|
||||
// if(aStep->GetTrack()->GetKineticEnergy()<10.*eV)
|
||||
// {
|
||||
aStep->GetTrack()->SetTrackStatus(fStopAndKill);
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void TDCheck::SetParticleVolumeNames(const G4Step* aStep)
|
||||
{
|
||||
// NAMES
|
||||
p_name = aStep->GetTrack()->GetDefinition()->GetParticleName(); // particle name
|
||||
v_name = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName();
|
||||
pv_name = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName();
|
||||
}
|
||||
|
||||
|
||||
void TDCheck::SetPositionMomentum(const G4Step* aStep)
|
||||
{
|
||||
// POSITION, MOMENTUM
|
||||
position = aStep->GetPreStepPoint()->GetPosition(); // position
|
||||
momentum = aStep->GetPostStepPoint()->GetMomentumDirection(); // momentum
|
||||
momentum_direction = aStep->GetPreStepPoint()->GetMomentumDirection(); // momentum
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TDCheck::SetTimeEnergy(const G4Step* aStep)
|
||||
{
|
||||
|
||||
// ENERGY
|
||||
kenergy= aStep->GetTrack()->GetDynamicParticle()->GetKineticEnergy(); // position
|
||||
|
||||
tenergy= aStep->GetTrack()->GetDynamicParticle()->GetTotalEnergy(); // position
|
||||
|
||||
// TIME
|
||||
localtime = (aStep->GetPreStepPoint()->GetLocalTime()+ aStep->GetPreStepPoint()->GetLocalTime())/2.; // time since track creation
|
||||
globaltime = aStep->GetPreStepPoint()->GetGlobalTime();// time since event creation
|
||||
proptime = aStep->GetPreStepPoint()->GetProperTime(); // proper time of the particle
|
||||
time = proptime;
|
||||
|
||||
}
|
||||
|
||||
void TDCheck::Update()
|
||||
{
|
||||
muon.localtime = localtime/ns ;
|
||||
muon.globaltime= globaltime/ns ;
|
||||
muon.proptime = proptime/ns ;
|
||||
|
||||
muon.positionx = LEMuSRPrimaryGeneratorAction::GetPGA()->X/cm; // position.x()/cm;
|
||||
muon.positiony = LEMuSRPrimaryGeneratorAction::GetPGA()->Y/cm; //position.y()/cm;
|
||||
muon.positionz = position.z()/cm;
|
||||
|
||||
muon.momdirx= LEMuSRPrimaryGeneratorAction::GetPGA()->angle/rad;//momentum_direction.x();
|
||||
muon.momdiry= LEMuSRPrimaryGeneratorAction::GetPGA()->radius/cm; //momentum_direction.y();
|
||||
muon.momdirz= momentum_direction.z();
|
||||
|
||||
muon.tenergy = kenergy/keV;
|
||||
muon.thickness = LEMuSRDetectorConstruction::GetInstance()->cfthk;
|
||||
|
||||
muon.angle=0;
|
||||
|
||||
|
||||
muon.index=0;
|
||||
muon.ienergy= LEMuSRPrimaryGeneratorAction::GetPGA()->energy/keV;
|
||||
|
||||
muon.angle=acos(momentum.z())*180/M_PI;
|
||||
|
||||
/////////////////
|
||||
/*
|
||||
G4cout << "particle name : " << p_name <<" ;\n "
|
||||
<< "position : " << position <<" ;\n "
|
||||
<< "momentum direction: " <<momentum_direction <<" ;\n "
|
||||
<< "time : " << globaltime/ns <<" ;\n "
|
||||
<<std::endl;
|
||||
*/
|
||||
//////////////////
|
||||
|
||||
if( G4RunManager::GetRunManager()->GetCurrentRun()->GetRunID()!=old_id)
|
||||
{
|
||||
id=id+1;
|
||||
old_id= G4RunManager::GetRunManager()->GetCurrentRun()->GetRunID();
|
||||
}
|
||||
|
||||
if( LEMuSRDetectorConstruction::GetInstance()->cfthk!=thk_old)
|
||||
{
|
||||
id=0;
|
||||
thk_old=LEMuSRDetectorConstruction::GetInstance()->cfthk;
|
||||
}
|
||||
muon.id = G4RunManager::GetRunManager()->GetCurrentRun()->GetRunID();
|
||||
|
||||
if(p_name=="Mu") muon.charge=0;
|
||||
else if(p_name=="mu+") muon.charge=1;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------//
|
||||
// ROOT
|
||||
|
||||
void TDCheck::BookRoot()
|
||||
{
|
||||
myFile = new TFile("gfoil.root", "RECREATE");
|
||||
|
||||
tree = new TTree ("tree","Muons parameters");
|
||||
|
||||
tree->Branch("muon",&muon.ienergy,"Init_Energy/F:kenergy/F:localtime/F:globaltime:propertime/F:positionx/F:positiony:positionz:init_angle:init_radius:momdirz:Angle/F:Plane/I:foil_thickness/F:runID/I:Charge/I");
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TDCheck::FillRoot()
|
||||
{
|
||||
tree->Fill();
|
||||
}
|
||||
|
||||
void TDCheck::WriteRoot()
|
||||
{
|
||||
myFile->Write();
|
||||
myFile->Close();
|
||||
|
||||
}
|
1013
geant4/LEMuSR/src/meyer.cc
Normal file
1013
geant4/LEMuSR/src/meyer.cc
Normal file
File diff suppressed because it is too large
Load Diff
105
geant4/LEMuSR/src/yields.cc
Normal file
105
geant4/LEMuSR/src/yields.cc
Normal file
@ -0,0 +1,105 @@
|
||||
#include "yields.h"
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Die Funktion sowie die Parameter sind uebernommen aus:
|
||||
|
||||
M.Gonin, R.Kallenbach, P.Bochsler: 'Charge exchange of hydrogen atoms
|
||||
in carbon foils at 0.4 - 120 keV', Rev.Sci.Instrum. 65 (3), March 1994
|
||||
|
||||
|
||||
fIRST IMPLEMENTATION BY ANLSEM,H. IN FORTRAN
|
||||
C++ CONVERSION T.K.PARAISO 04-2005
|
||||
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
Yields::Yields(){;}
|
||||
Yields::~Yields(){;}
|
||||
|
||||
void Yields::GetYields(
|
||||
double E, // kinetische Energie in keV
|
||||
double masse,// in keV / c**2
|
||||
double yvector[3])// pointer to yields table
|
||||
{
|
||||
|
||||
// YIELDS FUNCTIONS PRAMETERS
|
||||
double a_zero,a_minus;
|
||||
double k_Fermi,k_zero,k_minus;
|
||||
double zwo_k_Fermi;
|
||||
double k_Fermi_Quad,k_zero_Quad,k_minus_Quad;
|
||||
double vc_minus,vc_plus,v_Bohr,v_rel;
|
||||
|
||||
|
||||
// YIELDS FUNCTIONS PARAMETERs VALUES
|
||||
a_zero = 0.953 ;
|
||||
a_minus = 0.029 ;
|
||||
k_Fermi = 1.178 ;// ! [v_Bohr]
|
||||
k_Fermi_Quad = k_Fermi * k_Fermi ;
|
||||
zwo_k_Fermi = 2. * k_Fermi ;
|
||||
k_zero = 0.991*k_Fermi ; //! [v_Bohr]
|
||||
k_zero_Quad = k_zero * k_zero ;
|
||||
k_minus = 0.989*k_Fermi ; // [v_Bohr]
|
||||
k_minus_Quad = k_minus * k_minus ;
|
||||
vc_minus = 0.284 ;
|
||||
vc_plus = 0.193 ; // [v_Bohr]
|
||||
v_Bohr = 7.2974E-3 ; // [c]
|
||||
|
||||
|
||||
|
||||
// std::cout<< "E = "<< E <<std::endl;
|
||||
|
||||
// ABORT IF ENERGY NEGaTIVE-------------------------------------
|
||||
if (E < 0)
|
||||
{
|
||||
std::cout<< "Error in method ''Yields'':"<<std::endl;
|
||||
std::cout<< "E = "<< E <<" < 0!"<<std::endl;
|
||||
std::cout<< "-> ABORT!"<<std::endl;
|
||||
return;
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// VARIABLES DEFINITION
|
||||
|
||||
//Energie in Geschwindigkeit umrechnen (in Einheiten von v_Bohr):
|
||||
|
||||
// - klassisch:
|
||||
|
||||
v_rel = sqrt(2.*E/masse)/ v_Bohr;
|
||||
|
||||
help1 = v_rel*v_rel;
|
||||
help2 = zwo_k_Fermi*v_rel;
|
||||
Q_zero = 1. + (k_zero_Quad - k_Fermi_Quad - help1) / help2;
|
||||
Q_minus = 1. + (k_minus_Quad - k_Fermi_Quad - help1) / help2;
|
||||
|
||||
|
||||
help1 = a_zero * Q_zero;
|
||||
help2 = a_minus * Q_minus;
|
||||
help3 = (1.-Q_zero)*(1.-Q_minus);
|
||||
D = help1*(help2 + (1.-Q_minus)) + help3;
|
||||
|
||||
Yield_minus = help1*help2 / D;
|
||||
Yield_plus = help3 / D;
|
||||
|
||||
Yield_minus = Yield_minus* exp(-vc_minus/v_rel);
|
||||
Yield_plus = Yield_plus * exp(-vc_plus /v_rel);
|
||||
|
||||
if(Yield_minus > exp(-vc_minus/v_rel)) Yield_minus=exp(-vc_minus/v_rel);
|
||||
if(Yield_plus > exp(-vc_plus/v_rel)) Yield_plus=exp(-vc_plus/v_rel);
|
||||
|
||||
Yield_zero = 1. - (Yield_minus + Yield_plus);
|
||||
|
||||
yvector[0]=Yield_plus;
|
||||
yvector[1]=Yield_zero;
|
||||
yvector[2]=Yield_minus;
|
||||
|
||||
// std::cout<<"Y+ : " << Yield_plus << std::endl;
|
||||
// std::cout<<"Y0 : " << Yield_zero << std::endl;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user