From cd724f2691ef3a6aa87e215b83bfff50d3d9aadd Mon Sep 17 00:00:00 2001 From: paraiso Date: Fri, 24 Feb 2006 14:34:55 +0000 Subject: [PATCH] Remove G4ParticleDefinition dependance. --- geant4/LEMuSR/G4Modified/update.sh | 20 +++--- .../include/LEMuSRAtRestSpinRotation.hh | 26 +++++--- geant4/LEMuSR/include/LEMuSRCryoHit.hh | 24 +++---- geant4/LEMuSR/include/LEMuSRCryoSD.hh | 34 +++++----- .../include/LEMuSRDetectorConstruction.hh | 38 +++++------ .../LEMuSR/include/LEMuSRDetectorMessenger.hh | 31 ++++----- geant4/LEMuSR/include/LEMuSRElFieldMix.hh | 34 +++++----- geant4/LEMuSR/include/LEMuSRElMagField.hh | 38 ++++++----- .../LEMuSR/include/LEMuSRElMag_SpinEqRhs.hh | 20 ++++-- geant4/LEMuSR/include/LEMuSRElectricField.hh | 36 +++++----- geant4/LEMuSR/include/LEMuSREventAction.hh | 12 ++-- geant4/LEMuSR/include/LEMuSRMag_SpinEqRhs.hh | 17 +++-- geant4/LEMuSR/src/LEMuSRAtRestSpinRotation.cc | 66 +++++++++++++------ .../LEMuSR/src/LEMuSRDetectorConstruction.cc | 15 ++--- geant4/LEMuSR/src/LEMuSRElMag_SpinEqRhs.cc | 40 ++++++++++- geant4/LEMuSR/src/LEMuSRMag_SpinEqRhs.cc | 41 +++++++++++- geant4/LEMuSR/src/LEMuSRRunAction.cc | 24 ++++--- 17 files changed, 324 insertions(+), 192 deletions(-) diff --git a/geant4/LEMuSR/G4Modified/update.sh b/geant4/LEMuSR/G4Modified/update.sh index 347ffc3..68393ec 100644 --- a/geant4/LEMuSR/G4Modified/update.sh +++ b/geant4/LEMuSR/G4Modified/update.sh @@ -4,18 +4,19 @@ cp G4ChordFinder.cc $G4INSTALL/source/geometry/magneticfield/src/ cp G4ChordFinder.hh $G4INSTALL/source/geometry/magneticfield/include/ -cp G4El_EqRhs.cc $G4INSTALL/source/geometry/magneticfield/src/ -cp G4El_EqRhs.hh $G4INSTALL/source/geometry/magneticfield/include/ - -cp G4El_MagEqRhs.cc $G4INSTALL/source/geometry/magneticfield/src/ -cp G4El_MagEqRhs.hh $G4INSTALL/source/geometry/magneticfield/include/ - -cp G4El_UsualEqRhs.cc $G4INSTALL/source/geometry/magneticfield/src/ -cp G4El_UsualEqRhs.hh $G4INSTALL/source/geometry/magneticfield/include/ cp G4FieldManager.cc $G4INSTALL/source/geometry/magneticfield/src/ cp G4FieldManager.hh $G4INSTALL/source/geometry/magneticfield/include/ cp G4FieldManager.icc $G4INSTALL/source/geometry/magneticfield/include/ + +cp G4El_EqRhs.cc $G4INSTALL/source/geometry/magneticfield/src/ +cp G4El_EqRhs.hh $G4INSTALL/source/geometry/magneticfield/include/ + +cp G4El_UsualEqRhs.cc $G4INSTALL/source/geometry/magneticfield/src/ +cp G4El_UsualEqRhs.hh $G4INSTALL/source/geometry/magneticfield/include/ + + + cp G4MultipleScattering52.cc $G4INSTALL/source/processes/electromagnetic/standard/src/ cp G4VDecayChannel.cc $G4INSTALL/source/particles/management/src/ @@ -27,9 +28,6 @@ cp G4MuonDecayChannelWithSpin.hh $G4INSTALL/source/particles/management/inclu cp G4Muonium.cc $G4INSTALL/source/particles/leptons/src/ cp G4Muonium.hh $G4INSTALL/source/particles/leptons/include/ -cp G4ParticleDefinition.cc $G4INSTALL/source/particles/management/src/ -cp G4ParticleDefinition.hh $G4INSTALL/source/particles/management/include/ -cp G4ParticleDefinition.icc $G4INSTALL/source/particles/management/include/ cd $G4INSTALL/source/geometry/magneticfield/ diff --git a/geant4/LEMuSR/include/LEMuSRAtRestSpinRotation.hh b/geant4/LEMuSR/include/LEMuSRAtRestSpinRotation.hh index c1f0162..1f6ef40 100644 --- a/geant4/LEMuSR/include/LEMuSRAtRestSpinRotation.hh +++ b/geant4/LEMuSR/include/LEMuSRAtRestSpinRotation.hh @@ -69,7 +69,7 @@ #include "G4ForceCondition.hh" #include "G4ParticleChangeForTransport.hh" #include "LEMuSRParticleChangeForSR.hh" - +#include "G4EventManager.hh" /*! * This class is a public class of the G4VRestProcess class, @@ -114,15 +114,20 @@ public: G4double //! The magnetic field vector at the point[4] position. B[3], - //! The spin rotation angle computed in the RotateSpin method - rotation_angle; + //! The rotation frequency + fqz, + //! The spin rotation angle computed in the RotateSpin method + rotation_angle; + G4double //! The initial time. itime, - //! The final time. - ftime, - //! The time variation. - deltatime; + //! The final time. + ftime, + //! The time variation. + deltatime; + + G4ThreeVector SpinDirection; //! The particle change object which stores all the proposed modification of the particle's state. @@ -134,7 +139,12 @@ public: void RotateSpin(const G4Step&, G4ThreeVector, G4double); - + //! Returns the precession frequency according to the particle: + /*! + *- For muons and all other particles \f$ \gamma= 8.5062e+7*rad/(s*kGauss)\f$ + *- For muonium \f$ \gamma=*rad/(s*kGauss) \f$ + */ + G4double GetGyromagneticRatio(); inline G4double GetMeanLifeTime(const G4Track&, G4ForceCondition* condition) { diff --git a/geant4/LEMuSR/include/LEMuSRCryoHit.hh b/geant4/LEMuSR/include/LEMuSRCryoHit.hh index 4112b41..ce508df 100644 --- a/geant4/LEMuSR/include/LEMuSRCryoHit.hh +++ b/geant4/LEMuSR/include/LEMuSRCryoHit.hh @@ -22,18 +22,6 @@ -/** - *The LEMuSRCryoHit class defines the Hit object for the Sample Plate. A hit is an elementary - *component for the sensitive detection. As soon as particle enters in the specified - *volume, a hit object is created and will store any parameter the user wants to - *consider. - *The hit can then be plotted, printed or registered in a hit collection for further histogramming. - * - *However, it is not necessary to use hits objects since histograms can be filled - *directly from the sensitive detector classes (cf. LEMuSRCryoSD.cc). - * -*/ - #ifndef LEMuSRCryoHit_h #define LEMuSRCryoHit_h 1 @@ -45,6 +33,18 @@ #include "G4LogicalVolume.hh" #include "G4VPhysicalVolume.hh" + +/** + *The LEMuSRCryoHit class defines the Hit object for the Sample Plate. A hit is an elementary + *component for the sensitive detection. As soon as particle enters in the specified + *volume, a hit object is created and will store any parameter the user wants to + *consider. + *The hit can then be plotted, printed or registered in a hit collection for further histogramming. + * + *However, it is not necessary to use hits objects since histograms can be filled + *directly from the sensitive detector classes (cf. LEMuSRCryoSD.cc). + * +*/ class LEMuSRCryoHit : public G4VHit { public: diff --git a/geant4/LEMuSR/include/LEMuSRCryoSD.hh b/geant4/LEMuSR/include/LEMuSRCryoSD.hh index 22a49cf..2ac6647 100644 --- a/geant4/LEMuSR/include/LEMuSRCryoSD.hh +++ b/geant4/LEMuSR/include/LEMuSRCryoSD.hh @@ -23,23 +23,6 @@ -/** - *The sensitive detector classes are the most important to simulate the data acquisition. - *The sensitive detector object is attached to the detector in LEMuSRDetectorConstruction. - * - *During the particle transportation, geant4 will check if the volume where the particle - *travels is a sensitive detector (cf. G4Transportation). If this is the case, the method - *ProcessHits will be executed. - * - *In the geant4 standard, the ProcessHit method would create a hit object, fill it with - *desired parameters and send it to the corresponding hits collection for histogramming. - * - *This implementationof the \lemu simulation uses Root for histogramming, and therefore the hit object are not used. - *Instead of filling a collection, we directly fill a Root tree with all the data we want. - *A new hit structutre has been implemented according to Root format. -*/ - - #ifndef LEMuSRCryoSD_h #define LEMuSRCryoSD_h 1 @@ -67,6 +50,23 @@ class G4Step; class G4HCofThisEvent; class G4TouchableHistory; + +/** + *The sensitive detector classes are the most important to simulate the data acquisition. + *The sensitive detector object is attached to the detector in LEMuSRDetectorConstruction. + * + *During the particle transportation, geant4 will check if the volume where the particle + *travels is a sensitive detector (cf. G4Transportation). If this is the case, the method + *ProcessHits will be executed. + * + *In the geant4 standard, the ProcessHit method would create a hit object, fill it with + *desired parameters and send it to the corresponding hits collection for histogramming. + * + *This implementationof the \lemu simulation uses Root for histogramming, and therefore the hit object are not used. + *Instead of filling a collection, we directly fill a Root tree with all the data we want. + *A new hit structutre has been implemented according to Root format. +*/ + class LEMuSRCryoSD : public G4VSensitiveDetector { public: diff --git a/geant4/LEMuSR/include/LEMuSRDetectorConstruction.hh b/geant4/LEMuSR/include/LEMuSRDetectorConstruction.hh index 6cde1c2..866ac4b 100644 --- a/geant4/LEMuSR/include/LEMuSRDetectorConstruction.hh +++ b/geant4/LEMuSR/include/LEMuSRDetectorConstruction.hh @@ -20,25 +20,6 @@ // DETECTOR CONSTRUCTION.HH //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$// -/*! In this class the detector geometry is defined according to the following hierarchy: - * - Solid Volume - * -# The solid shape of the detector element. For example tube, sphere, box etc. - * -# It can be defined as a boolean combination of solids. - * - Logical Volume - * -# The solid volume plus a material, a color, and all other specific parameters. - * -# One can define different kind of attributes: visualization attributes, step size limitation, minimal kinetic enery to pursue the tracking of a particle etc. They are called UserAttributes or UserLimits. For more precision please refer to the G4UserLimits class. - * -# The sensitive detection is also set in the logical volume: the user should first define a sensitive detector, and then assign it to the logical volume (cf. source code of LEMuSRDetectorConstruction.cc) - * - Physical Volume - * -# The logical volume and its position inside a mother logical volume. - * -# One can also define space transformations (rotation, translation etc.) to position the physical volume in the mother volume. - * -# Only the World volume does not need to be given a mother volume. - * . - * The main method is the virtual method Construct. - * For clarity and compilation reasons the implementation code has been shared in the following files: - * -# LEMuSRDetectorConstruction.cc - * -# LEMuSRMaterials.cc where the materials table is built as well as the different attribute - * -# LEMuSRdummydets.cc, which build the dummy detectors. This file should be removed in the future since we notice that the introduction of dummy detectors could influence the results. -*/ #ifndef LEMuSRDetectorConstruction_H #define LEMuSRDetectorConstruction_H 1 @@ -88,6 +69,25 @@ class G4VPhysicalVolume; class G4Material; +/*! In this class the detector geometry is defined according to the following hierarchy: + * - Solid Volume + * -# The solid shape of the detector element. For example tube, sphere, box etc. + * -# It can be defined as a boolean combination of solids. + * - Logical Volume + * -# The solid volume plus a material, a color, and all other specific parameters. + * -# One can define different kind of attributes: visualization attributes, step size limitation, minimal kinetic enery to pursue the tracking of a particle etc. They are called UserAttributes or UserLimits. For more precision please refer to the G4UserLimits class. + * -# The sensitive detection is also set in the logical volume: the user should first define a sensitive detector, and then assign it to the logical volume (cf. source code of LEMuSRDetectorConstruction.cc) + * - Physical Volume + * -# The logical volume and its position inside a mother logical volume. + * -# One can also define space transformations (rotation, translation etc.) to position the physical volume in the mother volume. + * -# Only the World volume does not need to be given a mother volume. + * . + * The main method is the virtual method Construct. + * For clarity and compilation reasons the implementation code has been shared in the following files: + * -# LEMuSRDetectorConstruction.cc + * -# LEMuSRMaterials.cc where the materials table is built as well as the different attribute + * -# LEMuSRdummydets.cc, which build the dummy detectors. This file should be removed in the future since we notice that the introduction of dummy detectors could influence the results. +*/ class LEMuSRDetectorConstruction : public G4VUserDetectorConstruction { diff --git a/geant4/LEMuSR/include/LEMuSRDetectorMessenger.hh b/geant4/LEMuSR/include/LEMuSRDetectorMessenger.hh index c91b8d5..75cd0a8 100644 --- a/geant4/LEMuSR/include/LEMuSRDetectorMessenger.hh +++ b/geant4/LEMuSR/include/LEMuSRDetectorMessenger.hh @@ -21,21 +21,7 @@ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$// -/** - * The LEMuSRDetectorMessenger class defines the terminal's commands to operate changes in the detector geometry. The following settings can be personalized: - * -# MCP/Sample cryostat geometry - * -# Electric Fields on/off - * -# Magnetic Fields on/off - * -# Sample cryostat grid - * -# Sample cryostat guards - * -# Electric potentials - * -# Carbon foil thickness - * -# Maximal step size in field regions - * -# Sample holder material - * -# Views of the detector - * . - * Many more can be implemented at will by the user. - */ + #ifndef LEMuSRDetectorMessenger_h #define LEMuSRDetectorMessenger_h 1 @@ -72,6 +58,21 @@ class G4UIcmdWithAString; class G4UIcmdWithoutParameter; class LEMuSRDetectorConstruction; //modif +/** + * The LEMuSRDetectorMessenger class defines the terminal's commands to operate changes in the detector geometry. The following settings can be personalized: + * -# MCP/Sample cryostat geometry + * -# Electric Fields on/off + * -# Magnetic Fields on/off + * -# Sample cryostat grid + * -# Sample cryostat guards + * -# Electric potentials + * -# Carbon foil thickness + * -# Maximal step size in field regions + * -# Sample holder material + * -# Views of the detector + * . + * Many more can be implemented at will by the user. + */ class LEMuSRDetectorMessenger : public G4UImessenger { public: //! Constructor. diff --git a/geant4/LEMuSR/include/LEMuSRElFieldMix.hh b/geant4/LEMuSR/include/LEMuSRElFieldMix.hh index 23847b8..2c966ef 100644 --- a/geant4/LEMuSR/include/LEMuSRElFieldMix.hh +++ b/geant4/LEMuSR/include/LEMuSRElFieldMix.hh @@ -19,22 +19,7 @@ // & // Electric Field MIX //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$// -/** - * In order to build complex electric fields, the following class has been built. - * It allows the superposition of many electric fields recurrently. - * - * The main reason for this is that the field manager attached to a given volume do not handle such a - * superposition. In the case of the sample chamber, this is a big problem because we have to handle - * the fields of the ring anode and of the sample cryostat. - * - * The electric field in the sample region (gate valve chamber + mcp2 chamber) is then the - * superposition of the following electric fields: - * -# left side of the ring anode - * -# right side of the ring anode - * -# sample cryostat - * . - * On the same principle was built the class LEMuSRElMagField. - */ + #ifndef LEMUSRELECTRICFIELDMIX_H #define LEMUSRELECTRICFIELDMIX_H 1 @@ -54,6 +39,23 @@ #include "LEMuSRElectricField.hh" + +/** + * In order to build complex electric fields, the following class has been built. + * It allows the superposition of many electric fields recurrently. + * + * The main reason for this is that the field manager attached to a given volume do not handle such a + * superposition. In the case of the sample chamber, this is a big problem because we have to handle + * the fields of the ring anode and of the sample cryostat. + * + * The electric field in the sample region (gate valve chamber + mcp2 chamber) is then the + * superposition of the following electric fields: + * -# left side of the ring anode + * -# right side of the ring anode + * -# sample cryostat + * . + * On the same principle was built the class LEMuSRElMagField. + */ class LEMuSRElFieldMix : public G4ElectricField { public: diff --git a/geant4/LEMuSR/include/LEMuSRElMagField.hh b/geant4/LEMuSR/include/LEMuSRElMagField.hh index 817694c..d0f678d 100644 --- a/geant4/LEMuSR/include/LEMuSRElMagField.hh +++ b/geant4/LEMuSR/include/LEMuSRElMagField.hh @@ -20,24 +20,6 @@ // ElectroMagnetic Field //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$// -/** - * In order to build complex electromagnetic fields, the following class has been built. - * It allows the superposition of an electric field and a magnetic field. - * - * The main reason for this is that the field manager attached to a given volume do not handle such a - * superposition. In the case of the sample chamber, this is a big problem because we have to handle - * the electric fields of the ring anode and of the sample cryostat as well as the magnetic field over the sample. - * - * The electromagnetic field in the sample region (gate valve chamber + mcp2 chamber) is then the - * superposition of the following fields: - * -# electric field for left side of the ring anode - * -# electric field for right side of the ring anode - * -# electric field for sample cryostat - * -# magnetic field for sample region - * . - * On the same principle was built the class LEMuSRElFieldMix - */ - #ifndef LEMUSRELECTRICMAGFIELD_H #define LEMUSRELECTRICMAGFIELD_H 1 @@ -58,6 +40,26 @@ #include "LEMuSRElectricField.hh" + + +/** + * In order to build complex electromagnetic fields, the following class has been built. + * It allows the superposition of an electric field and a magnetic field. + * + * The main reason for this is that the field manager attached to a given volume do not handle such a + * superposition. In the case of the sample chamber, this is a big problem because we have to handle + * the electric fields of the ring anode and of the sample cryostat as well as the magnetic field over the sample. + * + * The electromagnetic field in the sample region (gate valve chamber + mcp2 chamber) is then the + * superposition of the following fields: + * -# electric field for left side of the ring anode + * -# electric field for right side of the ring anode + * -# electric field for sample cryostat + * -# magnetic field for sample region + * . + * On the same principle was built the class LEMuSRElFieldMix + */ + class LEMuSRElMagField : public G4MagneticField { public: diff --git a/geant4/LEMuSR/include/LEMuSRElMag_SpinEqRhs.hh b/geant4/LEMuSR/include/LEMuSRElMag_SpinEqRhs.hh index 793c532..b4f9e8a 100644 --- a/geant4/LEMuSR/include/LEMuSRElMag_SpinEqRhs.hh +++ b/geant4/LEMuSR/include/LEMuSRElMag_SpinEqRhs.hh @@ -20,12 +20,6 @@ // ElectroMagnetic Spin Equation //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$// -/** - * This class defines the motion equation to use to calculate the evolution of a - * particle in an electromagnetic field. The derivatives vector is calculated for - * the electric field, and for the magnetic field, taking into account the spin precession - * and the time evolution. - */ #ifndef LEMuSRELMAG_SPIN_EQRHS #define LEMuSRELMAG_SPIN_EQRHS 1 @@ -46,6 +40,12 @@ class G4MagneticField; +/** + * This class defines the motion equation to use to calculate the evolution of a + * particle in an electromagnetic field. The derivatives vector is calculated for + * the electric field, and for the magnetic field, taking into account the spin precession + * and the time evolution. + */ class LEMuSRElMag_SpinEqRhs : public G4Mag_EqRhs { public: // with description @@ -65,6 +65,14 @@ class LEMuSRElMag_SpinEqRhs : public G4Mag_EqRhs G4double dydx[] ) const; // Given the value of the electromagnetic field B, this function // calculates the value of the derivative dydx. + + + //! 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 GetGyromagneticRatio(); private: diff --git a/geant4/LEMuSR/include/LEMuSRElectricField.hh b/geant4/LEMuSR/include/LEMuSRElectricField.hh index 158dc7a..73460d7 100644 --- a/geant4/LEMuSR/include/LEMuSRElectricField.hh +++ b/geant4/LEMuSR/include/LEMuSRElectricField.hh @@ -20,6 +20,24 @@ // Electric Field //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$// + +#ifndef LEMUSRELECTRICFIELD_H +#define LEMUSRELECTRICFIELD_H 1 + +#include"G4ElectricField.hh" +#include"G4ElectroMagneticField.hh" +#include "globals.hh" +#include "G4ios.hh" + +#include +#include +#include +#include +#include +#include "CLHEP/Matrix/Vector.h" +#include "CLHEP/Matrix/Matrix.h" + + /** * The goal of the LEMuSRElectricField class is to read field maps generated by * COMSOL Multiphysics. @@ -51,24 +69,6 @@ * lens, the anode and the sample. */ -#ifndef LEMUSRELECTRICFIELD_H -#define LEMUSRELECTRICFIELD_H 1 - -#include"G4ElectricField.hh" -#include"G4ElectroMagneticField.hh" -#include "globals.hh" -#include "G4ios.hh" - -#include -#include -#include -#include -#include -#include "CLHEP/Matrix/Vector.h" -#include "CLHEP/Matrix/Matrix.h" - - - class LEMuSRElectricField : public G4ElectricField { public: diff --git a/geant4/LEMuSR/include/LEMuSREventAction.hh b/geant4/LEMuSR/include/LEMuSREventAction.hh index b99a67f..0b076ff 100644 --- a/geant4/LEMuSR/include/LEMuSREventAction.hh +++ b/geant4/LEMuSR/include/LEMuSREventAction.hh @@ -19,11 +19,7 @@ // & // EVENT ACTION.HH //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$// -/*! - * The role of the event action is to take special actions at the beginning or at the end of each event. It can be used for histogramming, plotting trajectories, or any other useful actions. - * - * It can be used to initialized the hits collections for the sensitive detection. In \lemu simulation, we finally did not really use the event action. -*/ + #ifndef LEMuSREventAction_h #define LEMuSREventAction_h 1 @@ -46,7 +42,11 @@ class G4EventManager; class G4Event; - +/*! + * The role of the event action is to take special actions at the beginning or at the end of each event. It can be used for histogramming, plotting trajectories, or any other useful actions. + * + * It can be used to initialized the hits collections for the sensitive detection. In \lemu simulation, we finally did not really use the event action. +*/ class LEMuSREventAction : public G4UserEventAction { public: diff --git a/geant4/LEMuSR/include/LEMuSRMag_SpinEqRhs.hh b/geant4/LEMuSR/include/LEMuSRMag_SpinEqRhs.hh index 7688211..cb69f45 100644 --- a/geant4/LEMuSR/include/LEMuSRMag_SpinEqRhs.hh +++ b/geant4/LEMuSR/include/LEMuSRMag_SpinEqRhs.hh @@ -43,12 +43,17 @@ #include "G4Types.hh" #include "G4Mag_EqRhs.hh" #include "G4SteppingManager.hh" // Include from 'tracking' +#include "G4EventManager.hh" #include "G4TrackingManager.hh" // Include from 'tracking' -#include "LEMuSRTrackingAction.hh" -#include "LEMuSRSteppingAction.hh" class G4MagneticField; +/** + * This class defines the motion equation to use to calculate the evolution of a + * particle in a magnetic field. The derivatives vector is calculated for + * the magnetic field, taking into account the spin precession + * and the time evolution. + */ class LEMuSRMag_SpinEqRhs : public G4Mag_EqRhs { public: // with description @@ -69,6 +74,11 @@ class LEMuSRMag_SpinEqRhs : public G4Mag_EqRhs const G4double B[3], G4double dydx[] ) const; + //! 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 GetGyromagneticRatio(); private: G4double omegac; @@ -80,8 +90,7 @@ class LEMuSRMag_SpinEqRhs : public G4Mag_EqRhs G4double beta; G4double m_mass; - LEMuSRTrackingAction* theTrackingAction; - G4double oldomegac; //to remove + G4double oldomegac; //to remove }; #endif /* LEMuSRMAG_SPIN_EQRHS */ diff --git a/geant4/LEMuSR/src/LEMuSRAtRestSpinRotation.cc b/geant4/LEMuSR/src/LEMuSRAtRestSpinRotation.cc index 6d56eb8..e9ed93a 100644 --- a/geant4/LEMuSR/src/LEMuSRAtRestSpinRotation.cc +++ b/geant4/LEMuSR/src/LEMuSRAtRestSpinRotation.cc @@ -193,27 +193,11 @@ void LEMuSRAtRestSpinRotation::RotateSpin( const G4Step& aStep, G4ThreeVector B, G4cout<< "AT REST::: PARAMETERS\n" << "Magnetic Field Norm : " << G4BestUnit(Bnorm,"Magnetic flux density") <<"\n"; #endif - - G4double omega,q,a,fqz; - G4double gamma; - q= aStep.GetTrack()->GetDefinition()->GetPDGCharge(); - a= 1.165922e-3; - fqz = 8.5062e+7*rad/(s*kilogauss); - - gamma = aStep.GetTrack()->GetDefinition()->GetGyromagneticRatio()*rad; - // G4cout<< fqz*(s*tesla)<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; +} diff --git a/geant4/LEMuSR/src/LEMuSRDetectorConstruction.cc b/geant4/LEMuSR/src/LEMuSRDetectorConstruction.cc index 6e59d96..05c49d6 100644 --- a/geant4/LEMuSR/src/LEMuSRDetectorConstruction.cc +++ b/geant4/LEMuSR/src/LEMuSRDetectorConstruction.cc @@ -76,7 +76,6 @@ #include "G4ElectricField.hh" #include "G4ElectroMagneticField.hh" #include "G4EqMagElectricField.hh" -#include "G4El_MagEqRhs.hh" #include "LEMuSRCryoField.hh" #include "LEMuSRMag_SpinEqRhs.hh" #include "LEMuSRElMag_SpinEqRhs.hh" @@ -541,9 +540,9 @@ void LEMuSRDetectorConstruction:: lemuCRYO() // sample MAGNETIC field sampleField = new LEMuSRRNDMAGField(G4ThreeVector(0.,0.,100*gauss),1.); - G4Mag_SpinEqRhs *Mag_SpinEqRhs; + LEMuSRMag_SpinEqRhs *Mag_SpinEqRhs; G4MagIntegratorStepper *pStepper; - Mag_SpinEqRhs = new G4Mag_SpinEqRhs(sampleField); + Mag_SpinEqRhs = new LEMuSRMag_SpinEqRhs(sampleField); pStepper = new G4ClassicalRK4( Mag_SpinEqRhs,12 ); G4ChordFinder* pChordFinder = new G4ChordFinder(sampleField,1.e-5* mm, pStepper ); @@ -1173,11 +1172,11 @@ void LEMuSRDetectorConstruction::buildAnodeField() #ifdef LEMU_TRANSVERSE_FIELD mcField = new LEMuSRMagneticField(G4ThreeVector(0.,B*gauss,0.)); G4cout<<"Transverse Field Applied: (0 G, " <GetTrackingManager()->GetTrack(); - G4double gratio= theTrack->GetDefinition()->GetGyromagneticRatio(); + G4double gratio= GetGyromagneticRatio(); // G4cout <<"g ratio [MHz]/[T]"<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; +} diff --git a/geant4/LEMuSR/src/LEMuSRMag_SpinEqRhs.cc b/geant4/LEMuSR/src/LEMuSRMag_SpinEqRhs.cc index 195a02d..99d3176 100644 --- a/geant4/LEMuSR/src/LEMuSRMag_SpinEqRhs.cc +++ b/geant4/LEMuSR/src/LEMuSRMag_SpinEqRhs.cc @@ -60,9 +60,7 @@ LEMuSRMag_SpinEqRhs::SetChargeMomentumMass(G4double particleCharge, // in e+ uni // To set fCof_val G4Mag_EqRhs::SetChargeMomentumMass(particleCharge, MomentumXc, mass); - theTrackingAction= LEMuSRTrackingAction::GetInstance(); - - G4double gratio=theTrackingAction->GyroMagRatio; + G4double gratio=GetGyromagneticRatio(); //G4cout <<"g ratio [MHz]/[T]"<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; +} diff --git a/geant4/LEMuSR/src/LEMuSRRunAction.cc b/geant4/LEMuSR/src/LEMuSRRunAction.cc index 9fd107b..4547b3f 100644 --- a/geant4/LEMuSR/src/LEMuSRRunAction.cc +++ b/geant4/LEMuSR/src/LEMuSRRunAction.cc @@ -29,6 +29,9 @@ #include "G4ios.hh" +#include "G4VPhysicalVolume.hh" +#include "LEMuSRDetectorConstruction.hh" + // ROOT #include "TROOT.h" #include "TApplication.h" @@ -51,10 +54,22 @@ LEMuSRRunAction::~LEMuSRRunAction() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -/*! Initializes the user interface manager.*/ + +//! 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"<ApplyCommand("/Detector/View total"); + G4VPhysicalVolume* newDetector = LEMuSRDetectorConstruction::GetInstance()->Construct(); + + */ + + G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl; G4RunManager::GetRunManager()->SetRandomNumberStore(true); @@ -64,13 +79,6 @@ void LEMuSRRunAction::BeginOfRunAction(const G4Run* aRun) UI->ApplyCommand("/vis/scene/notifyHandlers"); } - //! BUILD THE DETECTOR IN TOTAL GEOMETRY -// G4cout<<"WILL REBUILD THE DETECTOR"<ApplyCommand("/Detector/View total"); - -// G4VPhysicalVolume* newDetector = LEMuSRDetectorConstruction::GetInstance()->Construct(); -// G4RunManager::GetRunManager()->DefineWorldVolume(newDetector); -// G4cout<<"DETECTOR BUILT."<