Moved Tao's code to TaoLEMuSR.

This commit is contained in:
shiroka
2008-03-20 09:23:20 +00:00
parent 58c48f9e21
commit 1ca5ef0575
423 changed files with 0 additions and 0 deletions

View File

@ -1,272 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID : AsymCheck.cc , v 1.3
// AUTHOR: Taofiq PARAISO
// DATE : 2006-01-19 15:17
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// 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();
WriteRoot();
}
AsymCheck* AsymCheck::pointer=0;
AsymCheck* AsymCheck::GetInstance()
{
return pointer;
}
void AsymCheck::UserSteppingAction(const G4Step* aStep)
{
SetParticleVolumeNames(aStep);
if(CheckCondition(aStep))
{
SetPositionMomentum(aStep);
SetTimeEnergy(aStep);
SetAngles(aStep);
SetSpinDirection(aStep);
Update();
FillRoot();
// PrintDatas(aStep);
PrintAsym();
}
}
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)
{
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)
{
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);
asym.asym=A;
asym.L=L;
asym.R=R;
asym.S=L+R;
G4cout <<"\n Left/Right Asymmetry: L vs R = " << L <<" vs " << R <<" => A = " << A <<" for "<< L+R <<" particles.\n"<<G4endl;
}
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();
}

View File

@ -1,361 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID :FieldCheck.cc , v 1.2
// AUTHOR: Taofiq PARAISO
// DATE : 2006-01-19 15:17
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// 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);
PrintField(aStep);
Update();
FillRoot();
#if defined G4UI_USE_ROOT
myFile->Write();
#endif
}
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)
{
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);
if(position.z()<-34.7*cm)
{
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();
}

View File

@ -1,266 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID :FocalLengthTest.cc , v 1.2
// AUTHOR: Taofiq PARAISO
// DATE : 2006-01-19 15:17
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// 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();
}

View File

@ -1,282 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID : LEMuSRAtRestSpinRotation.cc , v 1.3
// AUTHOR: Taofiq PARAISO
// DATE : 2006-01-19 16:15
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// 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;
}
//$$$$$$$$$$$$$$$$$$$$$$$$$$ AT REST DO IT $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
/*!
* This method contains the list of modifications to do when the particle come to rest state. It is the implementation of a virtual method of G4VProcess. Therefore, it's name should not be changed.
*
* The procedure is the following:
* -# Initialize the particle change object according to the particle's properties taken from the track object.
* -# Propose a status for the track, a position, momentum, energy, and time change.
* -# Check is the volume where the particle is at rest contains a magnetic field
* -# If there is a magnetic field, get the B vector and call the RotateSpin method to rotate the spin.
* -# Propose a spin change
* -# Return the particle change object.
* .
* Then the AtRestUpdateStep method is called cf LEMuSRParticleChangeForSR.
*/
G4VParticleChange* LEMuSRAtRestSpinRotation::AtRestDoIt(const G4Track& theTrack, const G4Step& aStep)
{
theParticleChange.Initialize(theTrack);
theParticleChange.ProposeTrackStatus(fStopButAlive);
theParticleChange.ProposePosition(theTrack.GetPosition());
theParticleChange.ProposeMomentumDirection(theTrack.GetMomentumDirection());
theParticleChange.ProposeEnergy(theTrack.GetKineticEnergy());
// 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;
#endif
// Get B Field vector
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]);
if(magField!=G4ThreeVector(0.0,0.0,0.0))
{
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;
}
}
//$$$$$$$$$$$$$$$$$$$$$$$$$$ ROTATE SPIN $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
/*!
* This method rotates the spin of the particle according to the field value.It also takes the gyromagnetic parameters from the particle definition. It will make the spin precess until the particle decays. The gyromagnetic factor is taken from the particle definition.
*/
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
//! Gyromagnetic Ratio
G4double gamma = GetGyromagneticRatio();
//! Compute precession frequency
G4double 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;
}
// Return the gyromagnetic ratio
/*!
* This method call the event manager to get the tracking manager and then the current track in order to get the particle name. According to the name of the particle it returns the gyromagnetic ratio.
*/
G4double LEMuSRAtRestSpinRotation::GetGyromagneticRatio()
{
//! Get the event manager
G4EventManager* evtMgr = G4EventManager::GetEventManager();
//! Get the track from the tracking manager
G4Track* theTrack = evtMgr->GetTrackingManager()->GetTrack();
//! Get the particle name
G4String particle = theTrack->GetDefinition()->GetParticleName();
/*! Arbitrary initialisation of \f$ \gamma \f$ as muons plus
* gyromagnetic ratio
*/
G4double gamma = 8.5062e+7*rad/(s*kilogauss);
//! Set gamma according to the particle. One can add other particles at will.
if(particle== "Mu")
{
gamma= gamma = 0.5*((1.*eplus)/(0.1056584*GeV/(c_light*c_light))-(1.*eplus)/(0.51099906*MeV/(c_light*c_light)));
}
else if (particle == "mu+")
{
gamma= 8.5062e+7*rad/(s*kilogauss);
}
else
{
gamma= 8.5062e+7*rad/(s*kilogauss);
}
return gamma;
}

View File

@ -1,86 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID :LEMuSRCryoField.cc , v 1.2
// AUTHOR: Taofiq PARAISO
// DATE : 2006-01-19 15:17
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// CRYOFIELD
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#include"LEMuSRCryoField.hh"
LEMuSRCryoField::LEMuSRCryoField(G4ThreeVector FieldVector)
{
EField=FieldVector;
uniform=true;
}
LEMuSRCryoField::~LEMuSRCryoField()
{;}
LEMuSRCryoField:: LEMuSRCryoField(G4ThreeVector FieldVector,G4double radius,G4double zmin, G4double zmax)
{
// 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;
}
}

View File

@ -1,99 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID :LEMuSRCryoHit.cc , v 1.2
// AUTHOR: Taofiq PARAISO
// DATE : 2006-01-19 15:17
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// CRYOHIT
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#include "LEMuSRCryoHit.hh"
#include "G4VVisManager.hh"
#include "G4Circle.hh"
#include "G4Colour.hh"
#include "G4VisAttributes.hh"
#include "G4ios.hh"
#include <fstream>
#include <iomanip>
#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)
{
using namespace std;
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;
}

View File

@ -1,235 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID :LEMuSRCryoSD.cc , v 1.2
// AUTHOR: Taofiq PARAISO
// DATE : 2006-01-19 15:17
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// CRYOSD
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#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();
}
/* Obsolete: to be removed
// 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")
{
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();
theParticle.muon = mu;
theParticle.positron = e;
theParticle.gamma = g;
theParticle.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");
tree->Branch("particle",&theParticle.muon,"muon/I:muonium/I:gamma/I:runID/I");
}
void LEMuSRCryoSD::FillRoot()
{
tree->Fill();
}
void LEMuSRCryoSD::WriteRoot()
{
myFile->Write();
myFile->Close();
}

View File

@ -1,220 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID :LEMuSRDecay.cc , v 1.2
// AUTHOR: Taofiq PARAISO
// DATE : 2006-01-19 15:17
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// LEMUSRDECAY
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#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();
#ifdef G4VERBOSE
if (GetVerboseLevel()>1) {
G4cerr << "LEMuSRDecay::DoIt : selected decay channel addr:" << decaychannel <<G4endl;
decaychannel->SetVerboseLevel(GetVerboseLevel());
decaychannel->DumpInfo();
}
#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 Channel LEMuSR "<<testa<<" Decay Channel Geant "<<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 ;
}

View File

@ -1,196 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID :LEMuSRDepolarize.cc , v 1.2
// AUTHOR: Taofiq PARAISO
// DATE : 2006-01-19 15:17
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// LEMUSRDEPOLARIZE
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#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());
}

File diff suppressed because it is too large Load Diff

View File

@ -1,461 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// 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/HolderMaterial",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/ThirdLens",this);
SetThirdLensPotential->SetGuidance("\n Third Lens 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 lens chamber and sample chamber [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;
newDetector = theDetector->Construct();
G4RunManager::GetRunManager()->DefineWorldVolume(newDetector);
G4cout<<"THIS COMMAND ONLY ENABLES THE TRIGGER FIELD.\n"
<<"TO SET THE ELECTROSTATIC LENSES PLEASE USE THE /Detector/Voltage COMMANDS."<<G4endl;
}
else if(newvalue=="off")
{
theDetector->elfield=0;
theDetector->anode_elfield=0;
theDetector->trigger_field=0;
newDetector = theDetector->Construct();
G4RunManager::GetRunManager()->DefineWorldVolume(newDetector);
G4cout<<"ALL ELECTRIC FIELDS ARE NOW DISABLED."<<G4endl;
}
else
{
G4cout<<"UNRECOGNIZED COMMAND PLEASE ENTER on OR off."<<G4endl;
}
}
// 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;
newDetector = theDetector->Construct();
G4RunManager::GetRunManager()->DefineWorldVolume(newDetector);
G4cout << " \n TOTAL GEOMETRY IS LOADED. \n" ;
}
else if(newvalue=="half")
{
theDetector->dSPhi=90.*deg;
theDetector->dEPhi=180.*deg;
theDetector->halfview=1;
newDetector = theDetector->Construct();
G4RunManager::GetRunManager()->DefineWorldVolume(newDetector);
G4cout << " \n !!! BEFORE '/run/beamOn' :: PLEASE ENSURE TOTAL GEOMETRY IS LOADED !!! \n" ;
}
else if(newvalue=="quarter")
{
theDetector->dSPhi=0.*deg;
theDetector->dEPhi=270.*deg;
theDetector->halfview=1;
newDetector = theDetector->Construct();
G4RunManager::GetRunManager()->DefineWorldVolume(newDetector);
G4cout << " \n !!! BEFORE '/run/beamOn' :: PLEASE ENSURE TOTAL GEOMETRY IS LOADED !!! \n" ;
}
else
{
G4cout << "Unknown command: please check value is total/quarter/half ."<<G4endl;
}
// Update visualization
//UI ->ApplyCommand("/vis/viewer/refresh") ;
//UI ->ApplyCommand("/vis/viewer/update");
}
else
{
G4cout << "Unknown command: please check value."<<G4endl;
}
}

View File

@ -1,95 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// 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;
}

View File

@ -1,81 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID :LEMuSRElMagField.cc , v 1.3
// AUTHOR: Taofiq PARAISO
// DATE : 2004-09-17 10:20
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// ElectroMagnetic Field
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#include"LEMuSRElMagField.hh"
#include"G4UnitsTable.hh"
#include "G4ios.hh"
#include <iomanip>
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;
*/
}

View File

@ -1,182 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID :LEMuSRElMag_SpinEqRhs.cc , v 1.3
// AUTHOR: Taofiq PARAISO
// DATE : 2004-09-17 10:20
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// ElectroMagnetic Spin Equation
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#include "LEMuSRElMag_SpinEqRhs.hh"
#include "G4MagneticField.hh"
#include "G4ThreeVector.hh"
#include "G4ios.hh"
#include "G4UnitsTable.hh"
#include "globals.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);
/* theTrackingAction= LEMuSRTrackingAction::GetInstance();
G4double gratio=theTrackingAction->GyroMagRatio;
G4cout <<"g ratio [MHz]/[T]"<<gratio<<G4endl;
*/
// Get the gyromagnetic ratio via the event manager
G4double gratio= GetGyromagneticRatio();
// G4cout <<"g ratio [MHz]/[T]"<<gratio<<G4endl;
omegac =gratio;// 0.105658387*GeV/mass * 2.837374841e-3*(rad/cm/kilogauss);
#ifdef DEBUG
anomaly =1.165923e-3;
oldomegac= 0.105658387*GeV/mass * 2.837374841e-3*(rad/cm/kilogauss);
//G4cout<< "Old FrequencyG: " << G4BestUnit(oldomegac*gauss/(2*M_PI*rad)*cm,"Frequency") <<G4endl;
#endif
//G4cout<< "FrequencyG: " << G4BestUnit(gratio*gauss,"Frequency") <<G4endl;
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]);
// 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;
#ifdef DEBUG
G4double udb = anomaly*beta*gamma/(1.+gamma) * (BField * u);
G4double ucb = (anomaly+1./gamma)/beta;
dSpin = ParticleCharge*oldomegac*(ucb*(Spin.cross(BField))-udb*(Spin.cross(u)));
G4cout<<"Old dSpin" << dSpin<<G4endl;
#endif
// Calculation of dSpin according to theory for ex. Cohen-Tannoudji I p449
// dSpin/dt=gyromag_ratio*S^B
// dVar/ds=dVar/dt*mass/|mom|
//
dSpin =(Spin.cross(BField))*1./velocity*omegac;//multiply by gyromag ratio
#ifdef DEBUG
G4cout<<"New dSpin" << dSpin<<G4endl;
#endif
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 ;
}
G4double LEMuSRElMag_SpinEqRhs::GetGyromagneticRatio()
{
//! Get the event manager
G4EventManager* evtMgr = G4EventManager::GetEventManager();
//! Get the track from the tracking manager
G4Track* theTrack = evtMgr->GetTrackingManager()->GetTrack();
//! Get the particle name
G4String particle = theTrack->GetDefinition()->GetParticleName();
/*! Arbitrary initialisation of \f$ \gamma \f$ as muons plus
* gyromagnetic ratio
*/
G4double gamma = 8.5062e+7*rad/(s*kilogauss);
//! Set gamma according to the particle. One can add other particles at will.
if(particle== "Mu")
{
gamma= gamma = 0.5*((1.*eplus)/(0.1056584*GeV/(c_light*c_light))-(1.*eplus)/(0.51099906*MeV/(c_light*c_light)));
}
else if (particle == "mu+")
{
gamma= 8.5062e+7*rad/(s*kilogauss);
}
else
{
gamma= 8.5062e+7*rad/(s*kilogauss);
}
return gamma;
}

View File

@ -1,364 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// 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,G4String Xfile,
G4String Yfile,
G4String 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,G4String 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";
}
//! Scaling the distances acording to the unit.
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;
}
Bfield[0] = Bfield[0]*FieldVal*field_factor;
Bfield[1] = Bfield[1]*FieldVal*field_factor;
Bfield[2] = Bfield[2]*FieldVal*field_factor;
#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;
G4cout<<"FieldVal " <<FieldVal <<" coef " << field_factor<<" \n";
#endif
}

View File

@ -1,91 +0,0 @@
//
// ********************************************************************
// * 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 ;
}

View File

@ -1,234 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// 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;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,161 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID : LEMuSRMUONIUM.cc , v 1.3
// AUTHOR: Taofiq PARAISO
// DATE : 2006-01-19 16:15
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// MUONIUM
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#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()) ;
}
// G4cout<<"MU Formation"<<G4endl;getchar();
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());
}
}

View File

@ -1,291 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID : LEMuSRMUONIUMScatt.cc , v 1.3
// AUTHOR: Taofiq PARAISO
// DATE : 2006-01-19 16:15
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// MUONIUMScatt
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#include "LEMuSRMUONIUMScatt.hh"
#include "G4StepStatus.hh"
#include "G4Navigator.hh"
#include "G4TransportationManager.hh"
#include "Randomize.hh"
#include "G4ProductionCutsTable.hh"
#include "G4FieldManager.hh"
#include "G4Field.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
using namespace std;
LEMuSRMUONIUMScatt:: LEMuSRMUONIUMScatt(const G4String& name ,
G4ProcessType aType )
: G4VDiscreteProcess(name, aType)
{}
LEMuSRMUONIUMScatt:: ~LEMuSRMUONIUMScatt()
{}
/*!
* At the end of the step, the current volume is checked and if the muonium is in a solid material (except the carbon foil where it is generated) it is stopped immediately.
*
* The RotateSpinIfMag method is also called here, in order to perform the spin precession of a muonium flying in a magnetic field. Indeed the momentum and spin propagation of neutral particles is not taken into account in \gf.
*/
G4VParticleChange* LEMuSRMUONIUMScatt::PostStepDoIt(
const G4Track& trackData,
const G4Step& aStep )
{
fParticleChange.Initialize(trackData);
// tao :: /*! *- Get Time information */
itime = trackData.GetProperTime();
gtime = trackData.GetGlobalTime();
ftime = trackData.GetDynamicParticle()->GetPreAssignedDecayProperTime();
deltatime = ftime - itime;
fParticleChange.ProposeGlobalTime(deltatime + itime -gtime);
/*! - Set position, momentum, energy and time of the particle change. */
fParticleChange.ProposePosition(trackData.GetPosition());
fParticleChange.ProposeMomentumDirection(trackData.GetMomentumDirection());
fParticleChange.ProposeEnergy(trackData.GetKineticEnergy());
fParticleChange.ProposeGlobalTime(gtime);
fParticleChange.ProposeProperTime(itime);
fParticleChange.ProposeTrackStatus(trackData.GetTrackStatus()) ;
/*! * - Verify the condition of applying the process: if the Mu is in a material different than vacuum and carbon foil, then stop it directly.*/
if( CheckCondition(aStep))
{
fParticleChange.ProposePosition(trackData.GetStep()->GetPreStepPoint()->GetPosition());
fParticleChange.ProposeTrackStatus(fStopButAlive) ;
}
else
{;}
/*! *- If the Mu is in flight, then rotate the spin if there is a magnetic field.*/
polar = RotateSpinIfMag(trackData, aStep);
fParticleChange.ProposePolarization(polar);
// fParticleChange.DumpInfo();
/*! * - Return the particle change object. */
return &fParticleChange;
}
/*!
* The muonium will be stopped as soon as it enters a material different as the carbon foil and vacuum.
*/
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......
/*!
* Not used.
*/
void LEMuSRMUONIUMScatt::GetDatas( const G4Step* )
{;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void LEMuSRMUONIUMScatt::PrepareSecondary(const G4Track& track)
{
aSecondary = new G4Track(DP,track.GetDynamicParticle()->GetPreAssignedDecayProperTime(),track.GetPosition());
;}
/*!
* If a magnetic field is present in the volume the muonium is going through the spin precession is performed.
*/
G4ThreeVector LEMuSRMUONIUMScatt::RotateSpinIfMag( const G4Track& theTrack, const G4Step& aStep)
{
G4ThreeVector theSpin = theTrack.GetPolarization() ;
if(theTrack.GetKineticEnergy()!=0&&aStep.GetTrack()->GetVolume()->GetLogicalVolume()->GetFieldManager())
{
G4FieldManager *fMgr = theTrack.GetVolume()->GetLogicalVolume()->GetFieldManager();
// if(!fMgr->DoesFieldChangeEnergy())//then we have a magnetic field
if(fMgr->FieldHasMagComponent()==true)//then we have a magnetic field
{
#ifdef G4SRVERBOSE
G4cout<<"IN FLIGHT::: MAGNETIC FIELD HERE" <<G4endl;// getchar();
#endif
// tao :: Get Field
point[0]=theTrack.GetPosition().x()/mm;
point[1]=theTrack.GetPosition().y()/mm;
point[2]=theTrack.GetPosition().z()/mm;
const G4Field* mfield;
mfield = fMgr->GetDetectorField();
mfield->GetFieldValue(point,B);
#ifdef G4SRVERBOSE
G4cout <<"IN FLIGHT::: POSITION ="<< point[0]/mm <<" mm, " << point[1]/mm <<" mm, " << point[2]/mm<<" mm" <<G4endl;
#endif
#ifdef G4SRVERBOSE
G4cout <<"IN FLIGHT::: MAGNETIC FIELD B="<< B[0]/gauss <<" G, " << B[1]/gauss <<" G, " << B[2]/gauss<<" G" <<G4endl;
#endif
#ifdef G4SRVERBOSE
G4cout <<"IN FLIGHT::: TIME= proper: "<< itime <<" ; global: " << gtime <<" decay: " << ftime <<G4endl;
#endif
G4ThreeVector magField(B[0],B[1],B[2]);
if(sqr(B[0]) + sqr(B[1]) +sqr(B[2]) !=0)
{
theSpin= RotateSpin(aStep,magField,deltatime);
}
#ifdef G4SRVERBOSE
G4cout<<"IN FLIGHT::: spin rotated";
#endif
}
}
return theSpin;
}
G4ThreeVector LEMuSRMUONIUMScatt::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<< "IN FLIGHT::: 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;
// Muon's value.. not used. just for comparison in debugging.
fqz = 8.5062e+7*rad/(s*kilogauss);
gamma = 0.5*((1.*eplus)/(0.1056584*GeV/(c_light*c_light))-(1.*eplus)/(0.51099906*MeV/(c_light*c_light)));
// G4cout<< fqz*(s*tesla)<<G4endl;
// G4cout<< gamma*(s*tesla)<<G4endl;
#ifdef G4SRVERBOSE
G4cout<< "IN FLIGHT::: PARAMETERS\n"
<< "Charge : " << q <<"\n";
#endif
// omega= - (fqz)*(1.+a) * Bnorm;
omega= - (gamma) * Bnorm;
#ifdef G4SRVERBOSE
G4cout<< "IN FLIGHT::: PARAMETERS\n"
<< "Frequency: " << G4BestUnit(fqz*gauss/(2*M_PI*rad),"Frequency") <<"\n";
G4cout<< "IN FLIGHT::: PARAMETERS\n"
<< "FrequencyG: " << G4BestUnit(gamma*gauss/(2*M_PI*rad),"Frequency") <<"\n";
#endif
G4double 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<< "IN FLIGHT::: 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
return newspin;
}

View File

@ -1,188 +0,0 @@
//
// ********************************************************************
// * 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"
#include "G4ParticleDefinition.hh" // Include from 'tracking'
#include "G4Track.hh"
#include "G4ios.hh"
#include "G4UnitsTable.hh"
#include "globals.hh"
LEMuSRMag_SpinEqRhs::LEMuSRMag_SpinEqRhs( G4MagneticField* MagField )
: G4Mag_EqRhs( MagField )
{
anomaly = 1.165923e-3;
}
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);
G4double gratio=GetGyromagneticRatio();
//G4cout <<"g ratio [MHz]/[T]"<<gratio<<G4endl;
omegac =gratio;
#ifdef DEBUG
anomaly = 1.165923e-3;
oldomegac= 0.105658387*GeV/mass * 2.837374841e-3*(rad/cm/kilogauss);
//G4cout<< "Old FrequencyG: " << G4BestUnit(oldomegac*gauss/(2*M_PI*rad)*cm,"Frequency") <<G4endl;
#endif
//G4cout<< "FrequencyG: " << G4BestUnit(gratio*gauss,"Frequency") <<G4endl;
ParticleCharge = particleCharge;
E = sqrt(sqr(MomentumXc)+sqr(mass));
beta = MomentumXc/E;
gamma = E/mass;
m_mass=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]);
if (momentum_mag_square==0)
{
G4cout<<"LEMuSRMag_SpinEqRhs says: SEVERE ERROR:: MOMENTUM SQUARE ==0 !!!"<<G4endl;
return ;
}
G4double inv_momentum_magnitude = 1.0 / std::sqrt( momentum_mag_square );
G4double cof = FCof()*inv_momentum_magnitude;
// G4cout << "\n------------ LEMuSRMAg_SpinEqRhs :: mommagnitude : "<< sqrt(momentum_mag_square) <<"\n";
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 velocity=(sqrt(momentum_mag_square)/m_mass)*c_light;
// 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 =Spin.cross(BField)*omegac*1/velocity;
//G4cout<<"New dSpin" << dSpin<<G4endl;
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 ;
}
G4double LEMuSRMag_SpinEqRhs::GetGyromagneticRatio()
{
//! Get the event manager
G4EventManager* evtMgr = G4EventManager::GetEventManager();
//! Get the track from the tracking manager
G4Track* theTrack = evtMgr->GetTrackingManager()->GetTrack();
//! Get the particle name
G4String particle = theTrack->GetDefinition()->GetParticleName();
/*! Arbitrary initialisation of \f$ \gamma \f$ as muons plus
* gyromagnetic ratio
*/
G4double gamma = 8.5062e+7*rad/(s*kilogauss);
//! Set gamma according to the particle. One can add other particles at will.
if(particle== "Mu")
{
gamma= gamma = 0.5*((1.*eplus)/(0.1056584*GeV/(c_light*c_light))-(1.*eplus)/(0.51099906*MeV/(c_light*c_light)));
}
else if (particle == "mu+")
{
gamma= 8.5062e+7*rad/(s*kilogauss);
}
else
{
gamma= 8.5062e+7*rad/(s*kilogauss);
}
return gamma;
}

View File

@ -1,65 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID :LEMuSRMagneticField.cc , v 1.3
// AUTHOR: Taofiq PARAISO
// DATE : 2004-09-17 10:20
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// Magnetic Field
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#include "LEMuSRMagneticField.hh"
#include "G4ios.hh"
#include <iomanip>
LEMuSRMagneticField::LEMuSRMagneticField(const G4ThreeVector FieldVector)
{
BField=FieldVector;
// G4cout<<"MAGNETIC FIELD DEFINED AS "<<BField.x()/gauss<<"gauss"<<BField.y()/gauss<< "gauss"<<BField.z()/gauss<< "gauss"<<G4endl;
// getchar();
}
LEMuSRMagneticField::~LEMuSRMagneticField()
{;}
void LEMuSRMagneticField::GetFieldValue (const G4double pos[4],
G4double *field ) const
{
field[0]= 0.0*gauss;
field[1]= 0.0*gauss;
field[2]= 0.0*gauss;
G4double X,Y,Z,factor;
X= pos[0]*mm;Y=pos[1]*mm;Z=pos[2]*mm;
// G4cout<<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*0 ;//TAO
field[1]= BField.y()*factor*0 ;
field[2]= BField.z()*factor*0 ;
// G4cout<<"true: "<<field[0]/gauss<<" gauss, "<<field[1]/gauss<< " gauss, "<<field[2]/gauss<< " gauss."<<G4endl;// getchar();
// getchar();
/*
}
*/
}

View File

@ -1,451 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID : LEMuSRDetectorConstruction.cc , v 1.0
// AUTHOR: Taofiq PARAISO
// DATE : 2004-06-24 16:33
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// DETECTOR CONSTRUCTION: MATERIALS
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
// 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>
// 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
//G4VisAttributes InBlack = new G4VisAttributes(G4Colour(0.,0.,0.));// for special projection plot.
Blue_style = new G4VisAttributes(G4Colour(0.80,0.83,1.));// InBlack
Blue_style->SetForceSolid(true);
//Blue_style->SetForceWireframe(false);
fBlue_style = new G4VisAttributes(G4Colour(0.85,.88,0.92));//InBlack
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);
/***MATERIALS***/
// 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 material 'tantale'
density = 16.650*g/cm3;
G4Material* tantale = new G4Material(name="tantale", density, 1);
tantale->AddElement (Ta, nbelements=1);
//definition material 'or'
density = 19.300*g/cm3;
G4Material* gold = new G4Material(name="gold", density, 1);
gold->AddElement (Au, nbelements=1);
// definition material 'iron'
density = 7.874*g/cm3;
G4Material* iron = new G4Material("iron",density,1);
iron->AddElement (Fe,1);
// definition material '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);
/***MATERIALS***/
// 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 material 'copper'
density = 8.920*g/cm3;
G4Material* copper = new G4Material(name="copper", density, 1);
copper->AddElement (Cu, nbelements=1);
// definition material '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;
}

View File

@ -1,99 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID :LEMuSRMcpHit.cc , v 1.3
// AUTHOR: Taofiq PARAISO
// DATE : 2004-09-17 10:20
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// MCP HITS
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#include "LEMuSRMcpHit.hh"
#include "G4VVisManager.hh"
#include "G4Circle.hh"
#include "G4Colour.hh"
#include "G4VisAttributes.hh"
#include "G4ios.hh"
#include <fstream>
#include <iomanip>
#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)
{
using namespace std;
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;
}

View File

@ -1,248 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID :LEMuSRMcpSD.cc , v 1.3
// AUTHOR: Taofiq PARAISO
// DATE : 2004-09-17 10:20
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// MCP SD
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#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();
}

View File

@ -1,285 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// 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;
}

View File

@ -1,94 +0,0 @@
//
// ********************************************************************
// * 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: LEMuSRMuoniumParticle.cc,v 1.10 2005/01/14 03:49:17 asaim Exp $
// GEANT4 tag $Name: geant4-08-00-patch-01 $
//
//
// ----------------------------------------------------------------------
// GEANT 4 class implementation file
//
// History: first implementation, based on object model of
// 4th April 1996, G.Cosmo
// **********************************************************************
// New impelemenataion as an utility class M.Asai, 26 July 2004
// ----------------------------------------------------------------------
#include "LEMuSRMuoniumParticle.hh"
#include "G4ParticleTable.hh"
#include "G4MuonDecayChannel.hh"
#include "G4DecayTable.hh"
// ######################################################################
// ### MUONIUM ###
// ######################################################################
LEMuSRMuoniumParticle* LEMuSRMuoniumParticle::theInstance = 0;
LEMuSRMuoniumParticle* LEMuSRMuoniumParticle::Definition()
{
if (theInstance !=0) return theInstance;
const G4String name = "Mu";
// search in particle table]
G4ParticleTable* pTable = G4ParticleTable::GetParticleTable();
G4ParticleDefinition* anInstance = pTable->FindParticle(name);
if (anInstance ==0)
{
// create particle
//
// Arguments for constructor are as follows
// name mass width charge
// 2*spin parity C-conjugation
// 2*Isospin 2*Isospin3 G-parity
// type lepton number baryon number PDG encoding
// stable lifetime decay table
// shortlived subType anti_encoding
anInstance = new G4ParticleDefinition(
name, 0.1056584*GeV, 2.99591e-16*MeV, 0.*eplus,
1, 0, 0,
0, 0, 0,
"lepton", -1, 0, -1313,
false, 2197.03*ns, NULL,
false, "mu"
);
//create Decay Table
G4DecayTable* table = new G4DecayTable();
// create a decay channel
G4VDecayChannel* mode = new G4MuonDecayChannel("Mu",1.00);
table->Insert(mode);
anInstance->SetDecayTable(table);
}
theInstance = reinterpret_cast<LEMuSRMuoniumParticle*>(anInstance);
return theInstance;
}
LEMuSRMuoniumParticle* LEMuSRMuoniumParticle::MuoniumDefinition()
{
return Definition();
}
LEMuSRMuoniumParticle* LEMuSRMuoniumParticle::Muonium()
{
return Definition();
}

View File

@ -1,99 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID :LEMuSROScintHit.cc , v 1.3
// AUTHOR: Taofiq PARAISO
// DATE : 2004-09-17 10:20
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// Outer SCINT HITS
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#include "LEMuSROScintHit.hh"
#include "G4VVisManager.hh"
#include "G4Circle.hh"
#include "G4Colour.hh"
#include "G4VisAttributes.hh"
#include "G4ios.hh"
#include <fstream>
#include <iomanip>
#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)
{
using namespace std;
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;
}

View File

@ -1,238 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID :LEMuSROScintSD.cc , v 1.3
// AUTHOR: Taofiq PARAISO
// DATE : 2004-09-17 10:20
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// Outer SCINT SD
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#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();
}

View File

@ -1,238 +0,0 @@
//
// ********************************************************************
// * 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: LEMuSRParticleChangeForMSC.cc,v 1.12 2004/12/02 06:38:05 kurasige Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// --------------------------------------------------------------
// GEANT 4 class implementation file
//
//
//
// ------------------------------------------------------------
// Implemented for the new scheme 23 Mar. 1998 H.Kurahige
// Update for model variant of msc 16 Jan 2004 V.Ivanchenko
// --------------------------------------------------------------
#include "LEMuSRParticleChangeForMSC.hh"
#include "G4Track.hh"
#include "G4Step.hh"
#include "G4DynamicParticle.hh"
#include "G4ExceptionSeverity.hh"
LEMuSRParticleChangeForMSC::LEMuSRParticleChangeForMSC():G4VParticleChange()
{
Post_Update=false;
#ifdef G4VERBOSE
if (verboseLevel>2) {
G4cout << "LEMuSRParticleChangeForMSC::LEMuSRParticleChangeForMSC() " << G4endl;
}
#endif
}
LEMuSRParticleChangeForMSC::~LEMuSRParticleChangeForMSC()
{
#ifdef G4VERBOSE
if (verboseLevel>2) {
G4cout << "LEMuSRParticleChangeForMSC::~LEMuSRParticleChangeForMSC() " << G4endl;
}
#endif
}
LEMuSRParticleChangeForMSC::LEMuSRParticleChangeForMSC(
const LEMuSRParticleChangeForMSC &right): G4VParticleChange(right)
{
if (verboseLevel>1) {
G4cout << "LEMuSRParticleChangeForMSC:: copy constructor is called " << G4endl;
}
theMomentumDirection = right.theMomentumDirection;
thePosition = right.thePosition;
}
// assignment operator
LEMuSRParticleChangeForMSC & LEMuSRParticleChangeForMSC::operator=(
const LEMuSRParticleChangeForMSC &right)
{
if (verboseLevel>1) {
G4cout << "LEMuSRParticleChangeForMSC:: assignment operator is called " << G4endl;
}
if (this != &right)
{
theListOfSecondaries = right.theListOfSecondaries;
theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries;
theNumberOfSecondaries = right.theNumberOfSecondaries;
theStatusChange = right.theStatusChange;
theLocalEnergyDeposit = right.theLocalEnergyDeposit;
theSteppingControlFlag = right.theSteppingControlFlag;
theTrueStepLength = right.theTrueStepLength;
theMomentumDirection = right.theMomentumDirection;
thePosition = right.thePosition;
}
return *this;
}
//----------------------------------------------------------------
// methods for updating G4Step
//
G4Step* LEMuSRParticleChangeForMSC::UpdateStepForAlongStep(G4Step* pStep)
{
// Update the G4Step specific attributes
pStep->SetStepLength(theTrueStepLength);
theStatusChange = pStep->GetTrack()->GetTrackStatus();
// DumpInfo();
return pStep;
}
G4Step* LEMuSRParticleChangeForMSC::UpdateStepForPostStep(G4Step* pStep)
{
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
/* G4cout << "POST STEP UPDATE DATA: " ;
G4cout.precision(6);
G4cout << " Energy [MeV] : "
<< std::setw(20) <<
G4cout << " Position - x (mm) : "
<< std::setw(20) << thePosition.x()/mm
<< G4endl;
G4cout << " Position - y (mm) : "
<< std::setw(20) << thePosition.y()/mm
<< G4endl;
G4cout << " Position - z (mm) : "
<< std::setw(20) << thePosition.z()/mm
<< G4endl;
G4cout << " Momentum Direct - x : "
<< std::setw(20) << theMomentumDirection.x()
<< G4endl;
G4cout << " Momentum Direct - y : "
<< std::setw(20) << theMomentumDirection.y()
<< G4endl;
G4cout << " Momentum Direct - z : "
<< std::setw(20) << theMomentumDirection.z()
<< G4endl;
*/
// theStatusChange = pStep->GetTrack()->GetTrackStatus();
// A physics process always calculates the final state of the particle
// update position
pPostStepPoint->SetPosition( thePosition );
// update momentum direction
// G4cout<<"Momentum to set: "<<theMomentumDirection<<G4endl;
pPostStepPoint->SetMomentumDirection(theMomentumDirection);
return pStep;
}
//----------------------------------------------------------------
// methods for printing messages
//
void LEMuSRParticleChangeForMSC::DumpInfo() const
{
// use base-class DumpInfo
G4VParticleChange::DumpInfo();
G4cout.precision(6);
G4cout << " Energy [MeV] : "
<< std::setw(20) <<
G4cout << " Position - x (mm) : "
<< std::setw(20) << thePosition.x()/mm
<< G4endl;
G4cout << " Position - y (mm) : "
<< std::setw(20) << thePosition.y()/mm
<< G4endl;
G4cout << " Position - z (mm) : "
<< std::setw(20) << thePosition.z()/mm
<< G4endl;
G4cout << " Momentum Direct - x : "
<< std::setw(20) << theMomentumDirection.x()
<< G4endl;
G4cout << " Momentum Direct - y : "
<< std::setw(20) << theMomentumDirection.y()
<< G4endl;
G4cout << " Momentum Direct - z : "
<< std::setw(20) << theMomentumDirection.z()
<< G4endl;
}
G4bool LEMuSRParticleChangeForMSC::CheckIt(const G4Track& aTrack)
{
G4bool itsOK = true;
G4bool exitWithError = false;
G4double accuracy;
// check
// MomentumDirection should be unit vector
accuracy = std::abs(theMomentumDirection.mag2()-1.0);
if (accuracy > accuracyForWarning) {
#ifdef G4VERBOSE
G4cout << " LEMuSRParticleChangeForMSC::CheckIt : ";
G4cout << "the Momentum Change is not unit vector !!" << G4endl;
G4cout << " Difference: " << accuracy << G4endl;
#endif
itsOK = false;
if (accuracy > accuracyForException) exitWithError = true;
}
// dump out information of this particle change
#ifdef G4VERBOSE
if (!itsOK) {
G4cout << " LEMuSRParticleChangeForMSC::CheckIt " <<G4endl;
DumpInfo();
}
#endif
// Exit with error
if (exitWithError) {
G4Exception("LEMuSRParticleChangeForMSC::CheckIt",
"300",
EventMustBeAborted,
"momentum direction was illegal");
}
//correction
if (!itsOK) {
G4double vmag = theMomentumDirection.mag();
theMomentumDirection = (1./vmag)*theMomentumDirection;
}
itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
return itsOK;
}

View File

@ -1,64 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// 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;
}

View File

@ -1,106 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// 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();
theMessenger = new LEMuSRParticleGunMessenger(this);
}
LEMuSRParticleGun::~LEMuSRParticleGun()
{
delete theMessenger;
}
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;
//! \b 1. Creates a new vertex.
/*!
* The initial vertex of the particle is defined with a position-time
* and receives the information of the particle to simulate.
*/
G4PrimaryVertex* vertex =
new G4PrimaryVertex(particle_position,particle_time);
//! \b 2. Creates new primary particle.
/*!
* The primary particle is used in the initial vertex to
* produce the dynamic particles which will actually be tracked.
*/
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->SetPolarization(particle_polarization.x(),
particle_polarization.y(),
particle_polarization.z());
particle->SetProperTime(decaytime);
// G4cout<<"Muon decay time = " << decaytime/ns <<"ns. \n" <<G4endl;
//! \b 3. Set the primary particle to the vertex.
vertex->SetPrimary( particle );
}
//! \b 4. Sets the vertex to the event.
evt->AddPrimaryVertex( vertex );
}

View File

@ -1,253 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID : LEMuSRParticleGunMessenger.cc , v 1.2
// AUTHOR: Taofiq PARAISO
// DATE : 2004-08-20 10:48
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// PARTICLE GUN MESSENGER
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#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 <sstream>
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;
}
}

View File

@ -1,254 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// 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"
/*!
* The commands are instanciated and a new pointer is created for each of them.
* A directory and name for the commands is also defined, as well as some guidance to the user about how to use the command.
* Finally if possible some default values are defined.
*/
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));
momCmd = new G4UIcmdWith3Vector("/lemuGun/MomentumDirection",this);
momCmd->SetGuidance("Set momentum direction >> sum must equal one.");
momCmd->SetParameterName("momX ","momY ","momZ ",true,true);
momCmd->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 or other.",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));
}
/*!
* Kills the implemented pointers.
*/
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;
}
/*!
* This method registers all the operation to take when a command is
* entered in the terminal. Typically, the command is read and according to its name, is identified to a command defined in the constructor.
* Then the user value is read by the GetNewValue type methods. It can be a string, a double, a vector etc.
*
* What to do with this new value(s) is then implemented.
*/
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();
}
}

View File

@ -1,587 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID : LEMuSRMuonPhysics.cc , v 1.5
// AUTHOR: Taofiq PARAISO
// DATE : 2006-02-25 14:47
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// MuonPhysics
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// AFTER $Id$
// GEANT4 tag $Name: geant4-08-00-patch-01 $ exampleN07.cc
//
#include "LEMuSRPhysicsList.hh"
#include "G4ParticleDefinition.hh"
#include "G4ProcessManager.hh"
#include "G4ProcessVector.hh"
#include "G4ParticleTypes.hh"
#include "G4ParticleTable.hh"
#include "G4ios.hh"
// LEMuSR Muonium Particle
#include "LEMuSRMuoniumParticle.hh"
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// //
// CONSTRUCTOR AND DESTRUCTOR //
// //
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
LEMuSRPhysicsList::LEMuSRPhysicsList(): G4VUserPhysicsList()
{
defaultCutValue = 5.0*mm;
SetVerboseLevel(2);
}
LEMuSRPhysicsList::~LEMuSRPhysicsList()
{}
/*! \anchor constructparticles*/
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// //
// CONSTRUCTION OF THE DIFFERENT PARTICLES //
// CALLS THE DIFFERENT CONSTRUCTION METHODS //
// //
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
void LEMuSRPhysicsList::ConstructParticle()
{
// In this method, static member functions should be called
// for all particles which you want to use.
// This ensures that objects of these particle types will be
// created in the program.
SetCuts();
ConstructBosons();
ConstructLeptons();
ConstructBaryons();
// ConstructMesons();
}
/*! \anchor constructparticlesmethods*/
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// //
// CONSTRUCTION METHODS FOR THE DIFFERENT PARTICLES //
// //
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
void LEMuSRPhysicsList::ConstructBosons()
{
// pseudo-particles
G4Geantino::GeantinoDefinition();
G4ChargedGeantino::ChargedGeantinoDefinition();
// gamma
G4Gamma::GammaDefinition();
}
void LEMuSRPhysicsList::ConstructLeptons()
{
// leptons
G4Electron::ElectronDefinition();
G4Positron::PositronDefinition();
G4MuonPlus::MuonPlusDefinition();
LEMuSRMuoniumParticle::MuoniumDefinition();
G4MuonMinus::MuonMinusDefinition();
G4NeutrinoE::NeutrinoEDefinition();
G4AntiNeutrinoE::AntiNeutrinoEDefinition();
G4NeutrinoMu::NeutrinoMuDefinition();
G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
}
void LEMuSRPhysicsList::ConstructMesons()
{
// mesons
G4PionPlus::PionPlusDefinition();
G4PionMinus::PionMinusDefinition();
G4PionZero::PionZeroDefinition();
G4Eta::EtaDefinition();
G4EtaPrime::EtaPrimeDefinition();
G4KaonPlus::KaonPlusDefinition();
G4KaonMinus::KaonMinusDefinition();
G4KaonZero::KaonZeroDefinition();
G4AntiKaonZero::AntiKaonZeroDefinition();
G4KaonZeroLong::KaonZeroLongDefinition();
G4KaonZeroShort::KaonZeroShortDefinition();
}
void LEMuSRPhysicsList::ConstructBaryons()
{
// barions
G4Proton::ProtonDefinition();
G4AntiProton::AntiProtonDefinition();
G4Neutron::NeutronDefinition();
G4AntiNeutron::AntiNeutronDefinition();
}
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// //
// DECLARE PROCESSES //
// //
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4MultipleScattering.hh"
#include "G4MultipleScattering52.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
#include "G4MuIonisation.hh"
#include "G4MuIonisation52.hh"
#include "G4MuBremsstrahlung.hh"
#include "G4MuPairProduction.hh"
#include "G4hIonisation.hh"
// LEMuSR Processes
#include "LEMuSRAtRestSpinRotation.hh"
#include "LEMuSRDepolarize.hh"
#include "LEMuSRMSC.hh"
#include "LEMuSRMUONIUM.hh"
#include "LEMuSRMUONIUMScatt.hh"
/*! \anchor constructprocesses*/
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// //
// CONSTRUCTION OF THE DIFFERENT PROCESSES //
// CALLS THE DIFFERENT CONSTRUCTION METHODS //
// //
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
void LEMuSRPhysicsList::ConstructProcess()
{
/*! The transportation process is added to all particle. cf.
* <a href="">G4VPhysicsList</a>
*/
AddTransportation();
/*! Construction of Electromagnetic processes:
* those are the processes for the leptons and the bosons
*/
ConstructEM();
/*! Construction of the Decay process when applicable.
*
* Construction of User Cuts and Step Limitation. */
ConstructGeneral();
}
/*! \anchor constructprocessesmetods*/
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// //
// THE DIFFERENT PROCESSES CONSTRUCTION METHODS //
// //
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
void LEMuSRPhysicsList::ConstructEM()
{
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
G4String particleName = particle->GetParticleName();
if (particleName == "gamma") {
// gamma
pmanager->AddDiscreteProcess(new G4GammaConversion());
pmanager->AddDiscreteProcess(new G4ComptonScattering());
pmanager->AddDiscreteProcess(new G4PhotoElectricEffect());
} else if (particleName == "e-") {
//electron
G4VProcess* theeminusMultipleScattering = new G4MultipleScattering();
G4VProcess* theeminusIonisation = new G4eIonisation();
G4VProcess* theeminusBremsstrahlung = new G4eBremsstrahlung();
//
// add processes
pmanager->AddProcess(theeminusMultipleScattering);
pmanager->AddProcess(theeminusIonisation);
pmanager->AddProcess(theeminusBremsstrahlung);
//
// set ordering for AlongStepDoIt
pmanager->SetProcessOrdering(theeminusMultipleScattering, idxAlongStep,1);
pmanager->SetProcessOrdering(theeminusIonisation, idxAlongStep,2);
pmanager->SetProcessOrdering(theeminusBremsstrahlung, idxAlongStep,3);
//
// set ordering for PostStepDoIt
pmanager->SetProcessOrdering(theeminusMultipleScattering, idxPostStep,1);
pmanager->SetProcessOrdering(theeminusIonisation, idxPostStep,2);
pmanager->SetProcessOrdering(theeminusBremsstrahlung, idxPostStep,3);
} else if (particleName == "e+") {
//positron
G4VProcess* theeplusMultipleScattering = new G4MultipleScattering();
G4VProcess* theeplusIonisation = new G4eIonisation();
G4VProcess* theeplusBremsstrahlung = new G4eBremsstrahlung();
G4VProcess* theeplusAnnihilation = new G4eplusAnnihilation();
//
// add processes
pmanager->AddProcess(theeplusMultipleScattering);
pmanager->AddProcess(theeplusIonisation);
pmanager->AddProcess(theeplusBremsstrahlung);
pmanager->AddProcess(theeplusAnnihilation);
//
// set ordering for AtRestDoIt
pmanager->SetProcessOrderingToFirst(theeplusAnnihilation, idxAtRest);
//
// set ordering for AlongStepDoIt
pmanager->SetProcessOrdering(theeplusMultipleScattering, idxAlongStep,1);
pmanager->SetProcessOrdering(theeplusIonisation, idxAlongStep,2);
pmanager->SetProcessOrdering(theeplusBremsstrahlung, idxAlongStep,3);
//
// set ordering for PostStepDoIt
pmanager->SetProcessOrdering(theeplusMultipleScattering, idxPostStep,1);
pmanager->SetProcessOrdering(theeplusIonisation, idxPostStep,2);
pmanager->SetProcessOrdering(theeplusBremsstrahlung, idxPostStep,3);
pmanager->SetProcessOrdering(theeplusAnnihilation, idxPostStep,4);
}
/*! \anchor muplusphysics*/
//! Muon Plus Physics is implemented here.
else if( particleName == "mu+" ) {
// PROCESSES FOR MUON PLUS
//! Multiple Scattering including Meyer'Algorithm: LEMuSRMSC
G4VProcess* aMultipleScattering = new LEMuSRMSC();//new G4MultipleScattering52();
//! Muonium formation: LEMuSRMUONIUM
G4VProcess* aMuoniumFormation = new LEMuSRMUONIUM();
//! Spin Precession Process At Rest: LEMuSRAtRestSpinRotation
G4VProcess* aRestSpinRotation = new LEMuSRAtRestSpinRotation();
//! Unchanged \gf processes
G4VProcess* aBremsstrahlung = new G4MuBremsstrahlung();
G4VProcess* aPairProduction = new G4MuPairProduction();
G4VProcess* anIonisation = new G4MuIonisation();
// ADD WANTED PROCESSES TO PROCESS MANAGER
// add lemu processes
pmanager->AddProcess(aMultipleScattering);
pmanager->AddProcess(aMuoniumFormation);
pmanager->AddProcess(aRestSpinRotation);
// add \gf processes
pmanager->AddProcess(aBremsstrahlung);
pmanager->AddProcess(anIonisation);
pmanager->AddProcess(aPairProduction);
// SET PROCESSES ORDERING (ALONG STEP. POST STEP. AT REST).
// set ordering for AlongStepDoIt
pmanager->SetProcessOrdering(aMultipleScattering, idxAlongStep,1);
pmanager->SetProcessOrdering(anIonisation, idxAlongStep,3);
pmanager->SetProcessOrdering(aBremsstrahlung, idxAlongStep,4);
pmanager->SetProcessOrdering(aPairProduction, idxAlongStep,5);
// set ordering for PostStepDoIt
pmanager->SetProcessOrdering(aMultipleScattering, idxPostStep,1);
pmanager->SetProcessOrdering(aMuoniumFormation, idxPostStep,2);
pmanager->SetProcessOrdering(anIonisation, idxPostStep,3);
pmanager->SetProcessOrdering(aBremsstrahlung, idxPostStep,4);
pmanager->SetProcessOrdering(aPairProduction, idxPostStep,5);
// set ordering for AtRestDoIt
pmanager->SetProcessOrderingToFirst(aRestSpinRotation, idxAtRest);
}
/*! \anchor muoniumphysics*/
//! Muonium Physics is implemented here.
else if( particleName == "Mu" ) {
// PROCESSES FOR MUONIUM
//! Spin Precession Process At Rest: LEMuSRAtRestSpinRotation
G4VProcess* aRestSpinRotation = new LEMuSRAtRestSpinRotation();
G4VProcess* aMuScatt = new LEMuSRMUONIUMScatt();
// ADD WANTED PROCESSES TO PROCESS MANAGER
// add lemu processes
pmanager->AddProcess(aMuScatt);
pmanager->AddProcess(aRestSpinRotation);
// set ordering for PostStepDoIt
pmanager->SetProcessOrdering(aMuScatt, idxPostStep,1);
// set ordering for AtRestDoIt
pmanager->SetProcessOrderingToFirst(aRestSpinRotation, idxAtRest);
}
/*! \anchor muonminusphysics*/
//! Muon Minus Physics is implemented here.
else if( particleName == "mu-" ) {
//muon minus
G4VProcess* aMultipleScattering = new G4MultipleScattering52();
G4VProcess* aBremsstrahlung = new G4MuBremsstrahlung();
G4VProcess* aPairProduction = new G4MuPairProduction();
G4VProcess* anIonisation = new G4MuIonisation();
//
// add processes
pmanager->AddProcess(anIonisation);
pmanager->AddProcess(aMultipleScattering);
pmanager->AddProcess(aBremsstrahlung);
pmanager->AddProcess(aPairProduction);
//
// set ordering for AlongStepDoIt
pmanager->SetProcessOrdering(aMultipleScattering, idxAlongStep,1);
pmanager->SetProcessOrdering(anIonisation, idxAlongStep,2);
pmanager->SetProcessOrdering(aBremsstrahlung, idxAlongStep,3);
pmanager->SetProcessOrdering(aPairProduction, idxAlongStep,4);
//
// set ordering for PostStepDoIt
pmanager->SetProcessOrdering(aMultipleScattering, idxPostStep,1);
pmanager->SetProcessOrdering(anIonisation, idxPostStep,2);
pmanager->SetProcessOrdering(aBremsstrahlung, idxPostStep,3);
pmanager->SetProcessOrdering(aPairProduction, idxPostStep,4);
} else if ((!particle->IsShortLived()) &&
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
// all others charged particles except geantino
G4VProcess* aMultipleScattering = new G4MultipleScattering();
G4VProcess* anIonisation = new G4hIonisation();
//
// add processes
pmanager->AddProcess(anIonisation);
pmanager->AddProcess(aMultipleScattering);
//
// set ordering for AlongStepDoIt
pmanager->SetProcessOrdering(aMultipleScattering, idxAlongStep,1);
pmanager->SetProcessOrdering(anIonisation, idxAlongStep,2);
//
// set ordering for PostStepDoIt
pmanager->SetProcessOrdering(aMultipleScattering, idxPostStep,1);
pmanager->SetProcessOrdering(anIonisation, idxPostStep,2);
}
}
}
// LEMuSR decay process
#include "LEMuSRMuonDecayChannel.hh"
#include "LEMuSRDecay.hh"
// Geant decay processes
#include "G4MuonDecayChannel.hh"
#include "G4MuonDecayChannelWithSpin.hh"
#include "G4DecayWithSpin.hh"
#include "G4Decay.hh"
#include "G4UserSpecialCuts.hh"
#include "G4DecayTable.hh"
// Step Limiter Process
#include "G4StepLimiter.hh"
/*! \anchor constructdecayprocess*/
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// //
// CONSTRUCTION METHOD FOR DECAY PROCESS //
// //
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//! This method constructs the decay process for all the particles.
void LEMuSRPhysicsList::ConstructGeneral()
{
/*! Declare Decay Processes (from \lemu and \gf).*/
// G4Decay* theDecayProcess = new G4Decay();
LEMuSRDecay* theLEMuSRDecayProcess = new LEMuSRDecay();
/*! Declare User Cut.*/
G4StepLimiter* aStepLimiter = new G4StepLimiter();
G4UserSpecialCuts* aUserCut = new G4UserSpecialCuts();
/*! Initialization of the particle iterator.*/
theParticleIterator->reset();
while( (*theParticleIterator)() )
{
G4ParticleDefinition* particle = theParticleIterator->value();
/*! If the particle is a muon plus or a muonium,
* add the decay process from \lemu.
*/
if (particle->GetParticleName()=="mu+")
{
/*! Initialize the decay table.*/
/*!
* Although the asymmetric decay process is a feature of
*new Geant4 versions,
* it is recommended to use the original \lemu implementation.
*/
G4DecayTable* MuonPlusDecayTable = new G4DecayTable();
MuonPlusDecayTable -> Insert(new LEMuSRMuonDecayChannel("mu+",1.00));
MuonPlusDecayTable ->DumpInfo();
G4MuonPlus::MuonPlusDefinition() -> SetDecayTable(MuonPlusDecayTable);
G4ProcessManager* pmanager = particle->GetProcessManager();
if (theLEMuSRDecayProcess->IsApplicable(*particle))
{
pmanager ->AddProcess(theLEMuSRDecayProcess);
pmanager ->AddProcess(aStepLimiter);
// set ordering
pmanager ->SetProcessOrderingToLast(aStepLimiter, idxPostStep);
pmanager ->SetProcessOrderingToLast(theLEMuSRDecayProcess, idxPostStep);
pmanager ->SetProcessOrderingToLast(theLEMuSRDecayProcess, idxAtRest);
}
pmanager->DumpInfo();
}
else if (particle->GetParticleName()=="Mu")
{
/*! Initialize the decay table.*/
/*!
Half of the muonium have a completely isotropic decay.
*/
G4DecayTable* MuoniumDecayTable = new G4DecayTable();
MuoniumDecayTable -> Insert(new LEMuSRMuonDecayChannel("Mu",0.5));
MuoniumDecayTable -> Insert(new G4MuonDecayChannel("Mu",0.5));
MuoniumDecayTable ->DumpInfo();
LEMuSRMuoniumParticle::MuoniumDefinition() -> SetDecayTable(MuoniumDecayTable);
G4ProcessManager* pmanager = particle->GetProcessManager();
if (theLEMuSRDecayProcess->IsApplicable(*particle))
{
pmanager ->AddProcess(theLEMuSRDecayProcess);
pmanager ->AddProcess(aStepLimiter);
// set ordering
// pmanager ->SetProcessOrdering(aStepLimiter, idxPostStep, 1); // not needed for the muonium
pmanager ->SetProcessOrderingToLast(theLEMuSRDecayProcess, idxPostStep);
pmanager ->SetProcessOrderingToLast(theLEMuSRDecayProcess, idxAtRest);
}
pmanager->DumpInfo();
}
/*! For all other particles,
* add the decay process from \lemu also, it checks if particle is muon or not.
*/
else
{
G4ProcessManager* pmanager = particle->GetProcessManager();
pmanager ->AddProcess(aUserCut);
pmanager ->SetProcessOrdering(aUserCut, idxPostStep);
if (theLEMuSRDecayProcess->IsApplicable(*particle))
{
pmanager ->AddProcess(theLEMuSRDecayProcess);
// set ordering for PostStepDoIt and AtRestDoIt
pmanager ->SetProcessOrdering(theLEMuSRDecayProcess, idxPostStep);
pmanager ->SetProcessOrdering(theLEMuSRDecayProcess, idxAtRest);
}
}
}
}
#include "G4Region.hh"
#include "G4RegionStore.hh"
#include "G4ProductionCuts.hh"
void LEMuSRPhysicsList::SetCuts()
{
if (verboseLevel >0){
G4cout << "LEMuSRPhysicsList::SetCuts: default cut length : "
<< G4BestUnit(defaultCutValue,"Length") << G4endl;
}
// These values are used as the default production thresholds
// for the world volume.
SetCutsWithDefault();
SetCutValue(1.*mm, "e+");
SetCutValue(1.*mm, "e-");
// SetCutValue(1*mm, "proton");
}

View File

@ -1,356 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// 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>
#include "LEMuSRMuoniumParticle.hh"
/*!
* In the constructor the PGA messenger is initialized
* the particle gun is created and the default
* values are given to the variables for the particle definition
* or the scanning parameters
*/
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=-114.;
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
/*!
* The particle gun and the messenger pointers are deleted inthe destructor.
*/
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
/*!
* This method defines all the parameters for the particle gun and
* calls the GeneratePrimaryVertex from the LEMuSRParticleGun class.
* An important submethod is the GetScanningMode. which is called to
* get different distribution of the initial gun position.
*
* The decay time is preliminary assigned for muons and muonium particles.
*/
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();
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;
}
lemuParticleGun->SetParticleDefinition(particle);
lemuParticleGun->SetParticleEnergy(energy+ke_offset);
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
/*!
* The different scanning modes are distributions of the initial position of the gun.
* Few of them were implemented and one can modify them as he likes.
* The user can switch the scanning mode before each run via the user interface
* terminal thanks to the commands implemented in LEMuSRPGAMessenger.
*
* So far, one can choose between the following distributions:
* - Single position of the gun
* - Square sweeping: the gun position will be uniformely distributed in a square. The dimensions and steps along x and y directions are defined by the user.
* - Circular scan: the radius is scaned linearly and for all radius a circle is described according to the specified steps number. This distribution <I> is not</I> homogeneous.
* - Gaussian scan: x and y are randomly determined according to a gaussian distribution. The mean value and the standard deviation are user parameters.
*.
* The following picture shows different beam profiles generated by modifying the parameters of the gaussian circular scan. The maximal radius is limited to 2.5cm around the mean value.
*/
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));
}
//---------------------- GAUSSIAN SCAN >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
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-sc_mean)*(X-sc_mean)+(Y-sc_mean)*(Y-sc_mean));
}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;
}

View File

@ -1,88 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID : LEMuSRRNDMAGField.cc , v 1.2
// AUTHOR: Taofiq PARAISO
// DATE : 2004-08-20 10:48
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// RND MAG FIELD
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#include "LEMuSRRNDMAGField.hh"
#include "G4ios.hh"
#include <iomanip>
#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
{
G4double x = pos[0]; // dummy usage to avoid compiler warning
field[0]= 0.0 * x;
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;
}

View File

@ -1,90 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// 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"
#include "G4VPhysicalVolume.hh"
#include "LEMuSRDetectorConstruction.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......
//! Actions to take before the run.
/*!
* -# Initializes the user interface manager.
* -# Initialize the visualization
*/
void LEMuSRRunAction::BeginOfRunAction(const G4Run* aRun)
{
// G4UImanager* UI = G4UImanager::GetUIpointer();
/* G4cout<<"WILL REBUILD THE DETECTOR"<<G4endl;
UI->ApplyCommand("/Detector/View total");
G4VPhysicalVolume* newDetector = LEMuSRDetectorConstruction::GetInstance()->Construct();
*/
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
G4RunManager::GetRunManager()->SetRandomNumberStore(true);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
/*! Updates the user interface manager.*/
void LEMuSRRunAction::EndOfRunAction(const G4Run*)
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

View File

@ -1,99 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION Geant4 SIMULATION
// ID : LEMuSRScintHit.cc , v 1.0
// AUTHOR: Taofiq PARAISO
// DATE : 2004-07-12 16:15
//
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// INNER SCINT HIT
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#include "LEMuSRScintHit.hh"
#include "G4VVisManager.hh"
#include "G4Circle.hh"
#include "G4Colour.hh"
#include "G4VisAttributes.hh"
#include "G4ios.hh"
#include <fstream>
#include <iomanip>
#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)
{
using namespace std;
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;
}

View File

@ -1,261 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION Geant4 SIMULATION
// ID : LEMuSRScintSD.cc , v 1.0
// AUTHOR: Taofiq PARAISO
// DATE : 2004-07-12 16:15
//
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// INNER SCINT SD
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#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();
}

View File

@ -1,130 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// 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);
kill_e = true; kill_gamma = true; kill_nu_e = kill_nu_mu = true;
}
LEMuSRStackingAction::~LEMuSRStackingAction()
{
delete theMessenger;
}
G4ClassificationOfNewTrack
LEMuSRStackingAction::ClassifyNewTrack(const G4Track *track)
{
G4ClassificationOfNewTrack classification;
classification = fUrgent;
G4String p_name;
p_name = track->GetDefinition()->GetParticleName(); // particle name
if (p_name=="e-")
{
if (kill_e) classification=fKill;
}
else if (p_name=="gamma")
{
if (kill_gamma) classification=fKill;
}
else if (p_name=="nu_e")
{
if (kill_nu_e) classification=fKill;
}
else if (p_name=="anti_nu_e")
{
if (kill_nu_e) classification=fKill;
}
else if (p_name=="nu_mu")
{
if (kill_nu_mu) classification=fKill;
}
else if (p_name=="anti_nu_mu")
{
if (kill_nu_mu) classification=fKill;
}
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;
}

View File

@ -1,52 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION Geant4 SIMULATION
// ID : LEMuSRStackingActionMessenger.cc , v 1.0
// AUTHOR: Taofiq PARAISO
// DATE : 2004-07-07 11:15
//
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// STACKING ACTION MESSENGER
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#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 *)
{
//to make the compiler satisfied with function declaration
return "LEMuSRStackingActionMessenger::GetCurrentValue undefined";
}

View File

@ -1,280 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// 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"
//! \ct
LEMuSRSteppingAction::LEMuSRSteppingAction()
{
pointer=this ;
loop=0;
}
//! \dt
LEMuSRSteppingAction::~LEMuSRSteppingAction()
{
;
}
LEMuSRSteppingAction* LEMuSRSteppingAction::pointer=0;
LEMuSRSteppingAction* LEMuSRSteppingAction::GetInstance()
{
return pointer;
}
//! \mm
/*!
* The main role of the stepping action in \lemu simulation is to kill particles that are looping in electromagnetic fields.
*
* Is also illustrated here the possiblity of personalizing the color of the trajectories for visualisation.
*/
void LEMuSRSteppingAction::UserSteppingAction(const G4Step* aStep)
{
LoopKiller(aStep);
// G4cout<<"LEMuSR STEPPING ACTION INVOKED!"<<G4endl ;
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);
}
// ParticleInfo(aStep);
}
//! Method to kill the looping partiles
/*!
* A looping particle can increase the CPU time, and in the worst case even paralize the simulation. To kill the loops, we just limit the steps number of one track to 2500. The loop killer method check the step number and kills the particle when it gets too big. Note that a usual track does not contain more that few hundred steps and experience showed that above 1000 steps, the particles were actually trapped in a loop and rarely recovered a normal trajectory.
*
* In order to verify that this method is not abusive, the word "killed" is printed to the screen each time a particle is killed. Usually, this is the case of few particles over hundred thousands.
*
* The neutrinos, gammas and electrons tracks are killed directly because they have no influence on the simulation but increasing the calculation time.
* In particular, electrons are important sources of looping tracks in electromagntic field.
*
* Of course, one can select the particles to kill or not.
*/
void LEMuSRSteppingAction::LoopKiller(const G4Step *aStep)
{
// loop killa
if(aStep->GetTrack()->GetCurrentStepNumber()>1500)
{
aStep->GetTrack()->SetTrackStatus(fStopAndKill);
G4cout<<"killed:: step number > 1500 "<<G4endl;
ParticleInfo(aStep);
// getchar();
}
}
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
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->GetTrack()->GetPosition(); // position
G4ThreeVector momentum = aStep->GetTrack()->GetMomentumDirection(); // 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.precision(6);
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;
}
}
// }
}

View File

@ -1,85 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION Geant4 SIMULATION
// ID : LEMuSRTrackingAction.cc , v 1.2
// AUTHOR: Taofiq PARAISO
// DATE : 2004-07-07 11:15
//
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// TRACKING ACTION.CC
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#include"LEMuSRTrackingAction.hh"
#include"G4VProcess.hh"
#include"G4PrimaryParticle.hh"
#include"G4UnitsTable.hh"
#include"LEMuSRMuonDecayChannel.hh"
//! \ct
/*
* The tracking manager can be accessed by calling
the event manager GetTrackingManager() method.
One should not create here a pointer to the tracking manager, which is created
by the event manager and must be a singleton.
http://www-geant4.kek.jp/lxr/source/event/src/G4EventManager.cc
The event mnager is accessed by G4EventManager::GetEventManager().
*
* BUG REPORT:
* A previous version created here a new pointer of type G4TrackingManager:
* the BUG due to this operation was the disparition of the tracking verbose
* which is enabled during the simulation by the command <tt> /tracking/verbose x</tt>.
*/
LEMuSRTrackingAction ::LEMuSRTrackingAction()
{
pointer=this ;
}
LEMuSRTrackingAction* LEMuSRTrackingAction::pointer=0;
//! Returns pointer to the tracking action.
LEMuSRTrackingAction* LEMuSRTrackingAction::GetInstance()
{
return pointer;
}
//! \dt
LEMuSRTrackingAction:: ~LEMuSRTrackingAction()
{
;
}
//! Actions to take at the beginning of a track.
void LEMuSRTrackingAction::PreUserTrackingAction(const G4Track* theTrack)
{
;
}
void LEMuSRTrackingAction::Collect_datas(const G4Track* theTrack)
{
;
}
//! Actions to take at the end of a track.
void LEMuSRTrackingAction::PostUserTrackingAction(const G4Track*)
{
;
}

View File

@ -1,141 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION Geant4 SIMULATION
// ID : LEMuSRVisManager.cc , v 1.0
// AUTHOR: Taofiq PARAISO
// DATE : 2004-07-07 11:15
//
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// VIS MANAGER
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#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
//!\ct
LEMuSRVisManager::LEMuSRVisManager () {;}
//!\dt
LEMuSRVisManager::~LEMuSRVisManager () {;}
//!\mm
/*!
* This method registers the different graphic systems for the simulation.
* The user must prealably check that the libraries for the enabled systems
* are installed ( cf. @ref ssg4setup ).
*
* The corresponding environment variables have to be set before the compilation.
*/
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

View File

@ -1,227 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION
//
// ID : LEMuSRDetectorConstruction.cc , v 1.0
// AUTHOR: Taofiq PARAISO
// DATE : 2004-06-24 16:33
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// DETECTOR CONSTRUCTION: DUMMY DETECTORS
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
// 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>
// 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.000001*cm,0.*deg,360*deg,90*deg,90*deg);
G4Sphere *Asym_sphr = new G4Sphere("sphAsymR",25*cm,25.000001*cm,0.*deg,360*deg,0*deg,90*deg);
// logical volumes
G4String mat = "vacuum";
lv_Asym = new G4LogicalVolume(Asym_tube,G4Material::GetMaterial(mat),"lv_Asym",0,0,0);
lv_AsymL = new G4LogicalVolume(Asym_sphl,G4Material::GetMaterial(mat),"lv_AsymL",0,0,0);
lv_AsymR = new G4LogicalVolume(Asym_sphr,G4Material::GetMaterial(mat),"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
}

View File

@ -1,103 +0,0 @@
#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);
}

View File

@ -1,256 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// 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();
}

File diff suppressed because it is too large Load Diff

View File

@ -1,132 +0,0 @@
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//*
// LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION Geant4 SIMULATION
// ID : YIELDS.cc , v 1.0
// AUTHOR: Taofiq PARAISO
// DATE : 2005-04
//
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
//
// & &&&&&&&&&& &&&&&&& &&&&&&&&
// & & && && & &&
// & & & & & & &&
// & &&&&&&& & & &&&&&& &&&&&&&&
// & & & && & & &&
// & & && & & && && & &
// &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & &&
// &
// &
// &
// &
// YIELDS
/*
fIRST IMPLEMENTATION BY ANLSEM,H. IN FORTRAN
C++ CONVERSION T.K.PARAISO 04-2005
*/
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//
#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;
}