From e09fc2f0574da8481cc697b81ec40f328de0068c Mon Sep 17 00:00:00 2001 From: shiroka Date: Mon, 16 Jun 2008 14:05:29 +0000 Subject: [PATCH] --- geant4/LEMuSR/include/F04ElementField.hh | 181 +++++++++++ geant4/LEMuSR/include/F04FieldMessenger.hh | 73 +++++ geant4/LEMuSR/include/F04GlobalField.hh | 193 ++++++++++++ geant4/LEMuSR/include/MuDecayChannel.hh | 66 ++++ .../LEMuSR/include/MuDecayChannelWithSpin.hh | 125 ++++++++ geant4/LEMuSR/include/lem4Axial2DElField.hh | 72 +++++ .../include/lem4DetectorConstruction.hh | 81 +++++ .../LEMuSR/include/lem4DetectorMessenger.hh | 57 ++++ geant4/LEMuSR/include/lem4ErrorMessage.hh | 31 ++ geant4/LEMuSR/include/lem4EventAction.hh | 67 +++++ geant4/LEMuSR/include/lem4GaussianField.hh | 16 + geant4/LEMuSR/include/lem4MagneticField.hh | 38 +++ geant4/LEMuSR/include/lem4MuFormation.hh | 75 +++++ geant4/LEMuSR/include/lem4MuScatter.hh | 52 ++++ geant4/LEMuSR/include/lem4Muonium.hh | 72 +++++ geant4/LEMuSR/include/lem4Parameters.hh | 47 +++ geant4/LEMuSR/include/lem4PhysicsList.hh | 48 +++ .../include/lem4PrimaryGeneratorAction.hh | 69 +++++ .../include/lem4PrimaryGeneratorMessenger.hh | 41 +++ geant4/LEMuSR/include/lem4RootOutput.hh | 283 ++++++++++++++++++ geant4/LEMuSR/include/lem4RunAction.hh | 36 +++ geant4/LEMuSR/include/lem4ScintHit.hh | 128 ++++++++ geant4/LEMuSR/include/lem4ScintSD.hh | 42 +++ geant4/LEMuSR/include/lem4ShieldHit.hh | 92 ++++++ geant4/LEMuSR/include/lem4ShieldSD.hh | 32 ++ geant4/LEMuSR/include/lem4SteppingAction.hh | 47 +++ geant4/LEMuSR/include/lem4SteppingVerbose.hh | 26 ++ .../include/lem4TabulatedElementField2D.hh | 73 +++++ .../include/lem4TabulatedElementField2Df.hh | 73 +++++ .../include/lem4TabulatedElementField3D.hh | 76 +++++ geant4/LEMuSR/include/lem4TabulatedField2D.hh | 52 ++++ geant4/LEMuSR/include/lem4TabulatedField3D.hh | 46 +++ geant4/LEMuSR/include/lem4UniformField.hh | 43 +++ geant4/LEMuSR/include/lem4VisManager.hh | 26 ++ .../include/musrTabulatedElementField2D.hh | 57 ++++ .../include/musrTabulatedElementField3D.hh | 57 ++++ geant4/LEMuSR/include/musrTabulatedField2D.hh | 52 ++++ geant4/LEMuSR/include/musrTabulatedField3D.hh | 46 +++ 38 files changed, 2691 insertions(+) create mode 100644 geant4/LEMuSR/include/F04ElementField.hh create mode 100644 geant4/LEMuSR/include/F04FieldMessenger.hh create mode 100644 geant4/LEMuSR/include/F04GlobalField.hh create mode 100644 geant4/LEMuSR/include/MuDecayChannel.hh create mode 100644 geant4/LEMuSR/include/MuDecayChannelWithSpin.hh create mode 100644 geant4/LEMuSR/include/lem4Axial2DElField.hh create mode 100644 geant4/LEMuSR/include/lem4DetectorConstruction.hh create mode 100644 geant4/LEMuSR/include/lem4DetectorMessenger.hh create mode 100644 geant4/LEMuSR/include/lem4ErrorMessage.hh create mode 100644 geant4/LEMuSR/include/lem4EventAction.hh create mode 100644 geant4/LEMuSR/include/lem4GaussianField.hh create mode 100644 geant4/LEMuSR/include/lem4MagneticField.hh create mode 100644 geant4/LEMuSR/include/lem4MuFormation.hh create mode 100644 geant4/LEMuSR/include/lem4MuScatter.hh create mode 100644 geant4/LEMuSR/include/lem4Muonium.hh create mode 100644 geant4/LEMuSR/include/lem4Parameters.hh create mode 100644 geant4/LEMuSR/include/lem4PhysicsList.hh create mode 100644 geant4/LEMuSR/include/lem4PrimaryGeneratorAction.hh create mode 100644 geant4/LEMuSR/include/lem4PrimaryGeneratorMessenger.hh create mode 100644 geant4/LEMuSR/include/lem4RootOutput.hh create mode 100644 geant4/LEMuSR/include/lem4RunAction.hh create mode 100644 geant4/LEMuSR/include/lem4ScintHit.hh create mode 100644 geant4/LEMuSR/include/lem4ScintSD.hh create mode 100644 geant4/LEMuSR/include/lem4ShieldHit.hh create mode 100644 geant4/LEMuSR/include/lem4ShieldSD.hh create mode 100644 geant4/LEMuSR/include/lem4SteppingAction.hh create mode 100644 geant4/LEMuSR/include/lem4SteppingVerbose.hh create mode 100644 geant4/LEMuSR/include/lem4TabulatedElementField2D.hh create mode 100644 geant4/LEMuSR/include/lem4TabulatedElementField2Df.hh create mode 100644 geant4/LEMuSR/include/lem4TabulatedElementField3D.hh create mode 100644 geant4/LEMuSR/include/lem4TabulatedField2D.hh create mode 100644 geant4/LEMuSR/include/lem4TabulatedField3D.hh create mode 100644 geant4/LEMuSR/include/lem4UniformField.hh create mode 100644 geant4/LEMuSR/include/lem4VisManager.hh create mode 100644 geant4/LEMuSR/include/musrTabulatedElementField2D.hh create mode 100644 geant4/LEMuSR/include/musrTabulatedElementField3D.hh create mode 100644 geant4/LEMuSR/include/musrTabulatedField2D.hh create mode 100644 geant4/LEMuSR/include/musrTabulatedField3D.hh diff --git a/geant4/LEMuSR/include/F04ElementField.hh b/geant4/LEMuSR/include/F04ElementField.hh new file mode 100644 index 0000000..ae19eaf --- /dev/null +++ b/geant4/LEMuSR/include/F04ElementField.hh @@ -0,0 +1,181 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +// +// +// + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... + +#ifndef F04ElementField_h +#define F04ElementField_h 1 + +#include "globals.hh" + +#include "G4Navigator.hh" +#include "G4TransportationManager.hh" + +#include "G4UserLimits.hh" +#include "G4VisAttributes.hh" + +// class F04ElementField - interface for the EM field of one element + +// This is the interface class used by GlobalField to compute the field +// value at a given point[]. + +// An element that represents an element with an EM field will +// derive a class from this one and implement the computation for the +// element. The construct() function will add the derived object into +// GlobalField. + +class F04ElementField +{ + + private: + + F04ElementField& operator=(const F04ElementField&); + + public: + + /// Constructor. + F04ElementField(const G4ThreeVector, G4LogicalVolume*); + + /// the actual implementation constructs the F04ElementField + void construct(); + + /// Destructor. + virtual ~F04ElementField() { if (aNavigator) delete aNavigator; } + + /// setMaxStep(G4double) sets the max. step size + void setMaxStep(G4double s) + { + maxStep = s; + userLimits->SetMaxAllowedStep(maxStep); + lvolume->SetUserLimits(userLimits); + } + + /// getMaxStep() returns the max. step size + G4double getMaxStep() { return maxStep; } + + /// setColor(G4String) sets the color + void setColor(G4String c) + { + color = c; + lvolume->SetVisAttributes(getVisAttribute(color)); + } + + /// getColor() returns the color + G4String getColor() { return color; } + + /// getVisAttribute() returns the appropriate G4VisAttributes. + static G4VisAttributes* getVisAttribute(G4String color); + + /// setGlobalPoint() ensures that the point is within the global + /// bounding box of this ElementField's global coordinates. + /// Normally called 8 times for the corners of the local bounding + /// box, after a local->global coordinate transform. + /// If never called, the global bounding box is infinite. + /// BEWARE: if called only once, the bounding box is just a point. + void setGlobalPoint(const G4double point[4]) + { + if(minX == -DBL_MAX || minX > point[0]) minX = point[0]; + if(minY == -DBL_MAX || minY > point[1]) minY = point[1]; + if(minZ == -DBL_MAX || minZ > point[2]) minZ = point[2]; + if(maxX == DBL_MAX || maxX < point[0]) maxX = point[0]; + if(maxY == DBL_MAX || maxY < point[1]) maxY = point[1]; + if(maxZ == DBL_MAX || maxZ < point[2]) maxZ = point[2]; + } + + /// isInBoundingBox() returns true if the point is within the + /// global bounding box - global coordinates. + bool isInBoundingBox(const G4double point[4]) const + { + if(point[2] < minZ || point[2] > maxZ) return false; + if(point[0] < minX || point[0] > maxX) return false; + if(point[1] < minY || point[1] > maxY) return false; + return true; + } + + /// addFieldValue() will add the field value for this element to field[]. + /// Implementations must be sure to verify that point[] is within + /// the field region, and do nothing if not. + /// point[] is in global coordinates and geant4 units; x,y,z,t. + /// field[] is in geant4 units; Bx,By,Bz,Ex,Ey,Ez. + /// For efficiency, the caller may (but need not) call + /// isInBoundingBox(point), and only call this function if that + /// returns true. + virtual void + addFieldValue(const G4double point[4], G4double field[6]) const = 0; + + virtual G4double getLength() = 0; + virtual G4double getWidth() = 0; + virtual G4double getHeight() = 0; + + + ///ADDED BY KAMIL. TS!! + void SetElementFieldName(G4String name) {elementFieldName=name;} + G4String GetElementFieldName() {return elementFieldName;} + void SetEventNrDependentField(G4double initialField, G4double finalField, G4int nrOfSteps); + std::map GetEventNrDependentField() const {return changeFieldInStepsMap;} + // void SetElementFieldValueIfNeeded(G4int eventNr) const { + // std::map::iterator itr; + // if ( (itr = changeFieldInStepsMap.find(eventNr)) != changeFieldInStepsMap.end() ) { + // G4double newNominalFieldValue = itr->second ; + // + // G4cout<<"Nominal Field changed for "< changeFieldInStepsMap; +}; + +#endif diff --git a/geant4/LEMuSR/include/F04FieldMessenger.hh b/geant4/LEMuSR/include/F04FieldMessenger.hh new file mode 100644 index 0000000..7e09d06 --- /dev/null +++ b/geant4/LEMuSR/include/F04FieldMessenger.hh @@ -0,0 +1,73 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +// +// +// + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... + +#ifndef F04FieldMessenger_h +#define F04FieldMessenger_h 1 + +#include "globals.hh" +#include "G4UImessenger.hh" + +class F04GlobalField; +class G4UIdirectory; +class G4UIcmdWithAString; +class G4UIcmdWithAnInteger; +class G4UIcmdWithADoubleAndUnit; +class G4UIcmdWithoutParameter; + +class F04FieldMessenger: public G4UImessenger +{ + public: + F04FieldMessenger(F04GlobalField* ); + ~F04FieldMessenger(); + + void SetNewValue(G4UIcommand*, G4String); + void SetNewValue(G4UIcommand*, G4int); + + private: + + F04GlobalField* fGlobalField; + + G4UIdirectory* detDir; + + G4UIcmdWithAnInteger* fStepperCMD; + G4UIcmdWithADoubleAndUnit* fMinStepCMD; + G4UIcmdWithADoubleAndUnit* fDeltaChordCMD; + G4UIcmdWithADoubleAndUnit* fDeltaOneStepCMD; + G4UIcmdWithADoubleAndUnit* fDeltaIntersectionCMD; + G4UIcmdWithADoubleAndUnit* fEpsMinCMD; + G4UIcmdWithADoubleAndUnit* fEpsMaxCMD; + G4UIcmdWithoutParameter* fUpdateCMD; + +}; + +#endif + diff --git a/geant4/LEMuSR/include/F04GlobalField.hh b/geant4/LEMuSR/include/F04GlobalField.hh new file mode 100644 index 0000000..82e0917 --- /dev/null +++ b/geant4/LEMuSR/include/F04GlobalField.hh @@ -0,0 +1,193 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +// +// +// + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... + +#ifndef F04GlobalField_h +#define F04GlobalField_h 1 + +#include + +#include "G4FieldManager.hh" +#include "G4PropagatorInField.hh" +#include "G4MagIntegratorStepper.hh" +#include "G4ChordFinder.hh" + +#include "G4MagneticField.hh" +#include "G4ElectroMagneticField.hh" + +#include "G4Mag_EqRhs.hh" +#include "G4Mag_SpinEqRhs.hh" + +#include "G4EqMagElectricField.hh" +#include "G4EqEMFieldWithSpin.hh" + +#include "F04FieldMessenger.hh" +#include "F04ElementField.hh" + +// F04GlobalField - handles the global ElectroMagnetic field +// +// There is a single G04GlobalField object. +// +// The field from each individual beamline element is given by a +// ElementField object. Any number of overlapping ElementField +// objects can be added to the global field. Any element that +// represents an element with an EM field must add the appropriate +// ElementField to the global GlobalField object. + +typedef std::vector FieldList; + +class F04GlobalField : public G4ElectroMagneticField { +//class F04GlobalField : public G4MagneticField { + +private: + + F04GlobalField(); + F04GlobalField(const F04GlobalField&); + + ~F04GlobalField(); + + F04GlobalField& operator=(const F04GlobalField&); + + void setupArray(); + +public: + + /// getObject() returns the single F04GlobalField object. + /// It is constructed, if necessary. + static F04GlobalField* getObject(); + + // + static G4bool Exists() {if (object==NULL) {return false;} else {return true;}; } + + /// GetFieldValue() returns the field value at a given point[]. + /// field is really field[6]: Bx,By,Bz,Ex,Ey,Ez. + /// point[] is in global coordinates: x,y,z,t. + void GetFieldValue(const G4double* point, G4double* field) const; + + /// DoesFieldChangeEnergy() returns true. + G4bool DoesFieldChangeEnergy() const { return true; } + + /// addElementField() adds the ElementField object for a single + /// element to the global field. + void addElementField(F04ElementField* f) { if (fields) fields->push_back(f); } + + /// clear() removes all ElementField-s from the global object, + /// and destroys them. Used before the geometry is completely + /// re-created. + void clear(); + + /// updates all field tracking objects and clear() + void updateField(); + + /// Set the Stepper types + void SetStepperType( G4int i ) { fStepperType = i; } + + /// Set the Stepper + void SetStepper(); + + /// Set the minimum step length + void SetMinStep(G4double s) { minStep = s; } + + /// Set the delta chord length + void SetDeltaChord(G4double s) { deltaChord = s; } + + /// Set the delta one step length + void SetDeltaOneStep(G4double s) { deltaOneStep = s; } + + /// Set the delta intersection length + void SetDeltaIntersection(G4double s) { deltaIntersection = s; } + + /// Set the minimum eps length + void SetEpsMin(G4double s) { epsMin = s; } + + /// Set the maximum eps length + void SetEpsMax(G4double s) { epsMax = s; } + + /// Return the list of Element Fields + FieldList* getFields() { return fields; } + + // Additions by KS + // G4bool DoesAnyFieldValueNeedsToBeChanged(G4int eventNumber) {return globalChangeFieldInStepsMap[eventNumber];} + void CheckWhetherAnyNominalFieldValueNeedsToBeChanged(G4int eventNumber); + + // Add point, at which user wishes to print out the field value + void AddPointForFieldTesting(G4ThreeVector point) {pointsAtWhichUserWantsToPrintFieldValue.push_back(point);} + + // Print field value at all points user wished to be print out: + void PrintFieldAtRequestedPoints() const; + +protected: + + /// Get the global field manager + G4FieldManager* GetGlobalFieldManager(); + +private: + + static F04GlobalField* object; + + G4int nfp; + G4bool first; + + FieldList* fields; + + const F04ElementField **fp; + + std::vector pointsAtWhichUserWantsToPrintFieldValue; + +private: + + G4int fStepperType; + + G4double minStep; + G4double deltaChord; + G4double deltaOneStep; + G4double deltaIntersection; + G4double epsMin; + G4double epsMax; + +// G4Mag_EqRhs* fEquation; +// G4Mag_SpinEqRhs* fEquation; + +// G4EqMagElectricField* fEquation; + G4EqEMFieldWithSpin* fEquation; + + G4FieldManager* fFieldManager; + G4PropagatorInField* fFieldPropagator; + G4MagIntegratorStepper* fStepper; + G4ChordFinder* fChordFinder; + + F04FieldMessenger* fFieldMessenger; + + std::map globalChangeFieldInStepsMap; + +}; + +#endif diff --git a/geant4/LEMuSR/include/MuDecayChannel.hh b/geant4/LEMuSR/include/MuDecayChannel.hh new file mode 100644 index 0000000..7607fa1 --- /dev/null +++ b/geant4/LEMuSR/include/MuDecayChannel.hh @@ -0,0 +1,66 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +// +// $Id: G4MuonDecayChannel.hh,v 1.6 2006/06/29 19:23:35 gunter Exp $ +// GEANT4 tag $Name: geant4-09-00 $ +// +// +// ------------------------------------------------------------ +// GEANT 4 class header file +// +// History: first implementation, based on object model of +// 30 May 1997 H.Kurashige +// ------------------------------------------------------------ +#ifndef MuDecayChannel_h +#define MuDecayChannel_h 1 + +#include "G4ios.hh" +#include "globals.hh" +#include "G4VDecayChannel.hh" + +class MuDecayChannel :public G4VDecayChannel +{ + // Class Decription + // This class describes muon decay kinemtics. + // This version neglects muon polarization + // assumes the pure V-A coupling + // gives incorrect energy spectrum for neutrinos + // + + public: // With Description + //Constructors + MuDecayChannel(const G4String& theParentName, + G4double theBR); + // Destructor + virtual ~MuDecayChannel(); + + public: // With Description + virtual G4DecayProducts *DecayIt(G4double); + +}; + + +#endif diff --git a/geant4/LEMuSR/include/MuDecayChannelWithSpin.hh b/geant4/LEMuSR/include/MuDecayChannelWithSpin.hh new file mode 100644 index 0000000..99b28e8 --- /dev/null +++ b/geant4/LEMuSR/include/MuDecayChannelWithSpin.hh @@ -0,0 +1,125 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +// ------------------------------------------------------------ +// GEANT 4 class header file +// +// History: +// 17 August 2004 P.Gumplinger and T.MacPhail +// samples Michel spectrum including 1st order +// radiative corrections +// Reference: Florian Scheck "Muon Physics", in Physics Reports +// (Review Section of Physics Letters) 44, No. 4 (1978) +// 187-248. North-Holland Publishing Company, Amsterdam +// at page 210 cc. +// +// W.E. Fisher and F. Scheck, Nucl. Phys. B83 (1974) 25. +// +// ------------------------------------------------------------ +#ifndef MuDecayChannelWithSpin_hh +#define MuDecayChannelWithSpin_hh 1 + +#include "globals.hh" +#include "G4ThreeVector.hh" +#include "MuDecayChannel.hh" + +class MuDecayChannelWithSpin : public MuDecayChannel +{ + // Class Decription + // This class describes muon decay kinemtics. + // This version assumes V-A coupling with 1st order radiative correctons, + // the standard model Michel parameter values, but + // gives incorrect energy spectrum for neutrinos + +public: // With Description + + //Constructors + MuDecayChannelWithSpin(const G4String& theParentName, + G4double theBR); + // Destructor + virtual ~MuDecayChannelWithSpin(); + +public: // With Description + + virtual G4DecayProducts *DecayIt(G4double); + + void SetPolarization(G4ThreeVector); + const G4ThreeVector& GetPolarization() const; + +private: + + G4ThreeVector parent_polarization; + +// Radiative Correction Factors + + G4double F_c(G4double x, G4double x0); + G4double F_theta(G4double x, G4double x0); + G4double R_c(G4double x); + + G4double EMMU; + G4double EMASS; + +}; + +inline void MuDecayChannelWithSpin::SetPolarization(G4ThreeVector polar) +{ + parent_polarization = polar; +} + +inline const G4ThreeVector& MuDecayChannelWithSpin::GetPolarization() const +{ + return parent_polarization; +} + +inline G4double MuDecayChannelWithSpin::F_c(G4double x, G4double x0) +{ + G4double omega = std::log(EMMU/EMASS); + + G4double f_c; + + f_c = (5.+17.*x-34.*x*x)*(omega+std::log(x))-22.*x+34.*x*x; + f_c = (1.-x)/(3.*x*x)*f_c; + f_c = (6.-4.*x)*R_c(x)+(6.-6.*x)*std::log(x) + f_c; + f_c = (fine_structure_const/twopi) * (x*x-x0*x0) * f_c; + + return f_c; +} + +inline G4double MuDecayChannelWithSpin::F_theta(G4double x, G4double x0) +{ + G4double omega = std::log(EMMU/EMASS); + + G4double f_theta; + + f_theta = (1.+x+34*x*x)*(omega+std::log(x))+3.-7.*x-32.*x*x; + f_theta = f_theta + ((4.*(1.-x)*(1.-x))/x)*std::log(1.-x); + f_theta = (1.-x)/(3.*x*x) * f_theta; + f_theta = (2.-4.*x)*R_c(x)+(2.-6.*x)*std::log(x)-f_theta; + f_theta = (fine_structure_const/twopi) * (x*x-x0*x0) * f_theta; + + return f_theta; +} + +#endif diff --git a/geant4/LEMuSR/include/lem4Axial2DElField.hh b/geant4/LEMuSR/include/lem4Axial2DElField.hh new file mode 100644 index 0000000..9be951b --- /dev/null +++ b/geant4/LEMuSR/include/lem4Axial2DElField.hh @@ -0,0 +1,72 @@ +#ifndef LEM3AXIAL2DELFIELD_H +#define LEM3AXIAL2DELFIELD_H 1 + +#include "F04ElementField.hh" +#include "F04GlobalField.hh" /// ATTENTION: USE GENERAL EM GLOBAL AND NOT MAGN. FIELD ONLY + +///#include "G4MagneticField.hh" +///#include "G4ElectricField.hh" +#include "globals.hh" +#include "G4ios.hh" + +#include +#include +#include + +class lem4Axial2DElField : public F04ElementField ///G4ElectricField +{ + +//! Contructor from a single field map +// lem4ElectricField(G4double fieldval,G4String file,G4String map_length_unit, + //G4double Offset, G4double nx, G4double ny, G4double nz); + ///lem4Axial2DElField(const G4String filename, double fieldValue, double lenUnit, double fieldNormalisation, double offset); + +public: + // Class constructor for 2D axial field map (x, z, Er, Ez) + lem4Axial2DElField(const char* filename, G4double fieldValue, G4double lenUnit, G4double fieldNormalisation, G4LogicalVolume* logVolume, G4ThreeVector positionOfTheCenter); + // "lenUnit" is the unit in which the grid coordinates are specified in the table + // "fieldNormalisation" is the normalisation that has to be applied on the field values in the table + // such that when applying V_L3 = 1 kV the E values coincide with those in the table + // "fieldValue" is the field value (in kV) set by the user (i.e. values normalised to 1 kV will be + // multiplied by this value). + + // Virtual destructor + virtual ~lem4Axial2DElField() {}; + + // addFieldValue() adds the field for THIS particular map into field[]. + // point[] is expressed in GLOBAL coordinates. + void addFieldValue(const G4double point[4], G4double* field) const; + + // Usual Set and Get functions + G4double GetNominalFieldValue(); + void SetNominalFieldValue(G4double newFieldValue); + + // getWidth(), getHeight(), getLength(), return the dimensions of the field + // (used to define the boundary of the field) + virtual G4double getWidth() { return 2*dr; } // x coordinate + virtual G4double getHeight() { return 2*dr; } // y coordinate + virtual G4double getLength() { return 2*dz; } // z coordinate + + ///void GetFieldValue(const double Point[4], double *Efield) const; + ///void SetFieldValue(double newFieldValue); + /// G4double GetFieldSetValue(); + + +private: + // Storage space for the table + std::vector < std::vector < double > > rField; + std::vector < std::vector < double > > zField; + // The dimensions of the table + int nr, nz; + // The physical limits of the defined region and the global offset + double minr, maxr, minz, maxz; + // The physical extent of the defined region + double dr, dz; + double ffieldValue; ///, zOffset; included in log_vol offset! + ///bool invertR, invertZ; // substituted by the Invert function + // Utility function for inverting field map + void Invert(const char* indexToInvert); + +}; + +#endif diff --git a/geant4/LEMuSR/include/lem4DetectorConstruction.hh b/geant4/LEMuSR/include/lem4DetectorConstruction.hh new file mode 100644 index 0000000..aaca2c9 --- /dev/null +++ b/geant4/LEMuSR/include/lem4DetectorConstruction.hh @@ -0,0 +1,81 @@ +#ifndef lem4DetectorConstruction_h +#define lem4DetectorConstruction_h 1 + +#include "globals.hh" +#include "G4VUserDetectorConstruction.hh" +#include "G4ThreeVector.hh" +#include "G4RotationMatrix.hh" +#include "G4FieldManager.hh" +#include + +class G4Tubs; +class G4Box; +class G4Cons; +class G4Trd; +class G4LogicalVolume; +class G4VPhysicalVolume; +class G4Material; +class lem4DetectorMessenger; +//class lem4TrackerSD; +//class lem4ShieldSD; +//class lem4IForwardSD; +//class lem4IBackwardSD; +class lem4ScintSD; + + +//class lem4UniformField; // Added by TS to implement uniform box field according to Gumplinger + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class lem4DetectorConstruction : public G4VUserDetectorConstruction +{ +public: + + lem4DetectorConstruction(); + ~lem4DetectorConstruction(); + +public: + + G4VPhysicalVolume* Construct(); + + + void UpdateGeometry(); + ///ALL THESE ARE OLD FIELD SETTING METHODS. USE THAT OF GUMPLINGER INSTEAD! TS. + void SetMagField(const char* fieldTableType, const char* inputFileName, G4double fieldValue); + void SetUniformMagField(G4double); + void SetGaussianMagField(G4ThreeVector); + ///void SetUniformElField(G4double); // Uniform Electric Field. TS + + void SetInputParameterFileName(G4String fileName) {parameterFileName=fileName;}; + void ReportGeometryProblem(char myString[501]); + void ReportProblemInStearingFile(char* myString); //!Changed -added + G4Material* CharToMaterial(char myString[100]); + G4LogicalVolume* FindLogicalVolume(G4String LogicalVolumeName); + void SetColourOfLogicalVolume(G4LogicalVolume* pLogVol,char* colour); + G4bool CheckIfStringContainsSubstring(char* string, char* substring); //!Changed -added + +private: + G4String parameterFileName; // name of the file with the geometry parameters + G4bool checkOverlap; // parameter to check ovelaping volumes + G4double largestAcceptableStep; // parameter defining largest step in the magnetic field + + + //G4Material* TargetMater;// pointer to the target material + //G4Material* VacMater; // pointer to the target material + //G4Material* DetMater; // pointer to the target material + //G4Material* Al; // pointer to the target material + //G4Material* Pb; // pointer to the target material + //G4Material* AirMater; // pointer to the target material + //G4Material* Vacuum; // pointer to vacuum material + + lem4ScintSD* aScintSD; + lem4DetectorMessenger* detectorMessenger; // pointer to the Messenger + + std::map pointerToRotationMatrix; + std::map pointerToField; + +private: + void DefineMaterials(); +}; + +#endif diff --git a/geant4/LEMuSR/include/lem4DetectorMessenger.hh b/geant4/LEMuSR/include/lem4DetectorMessenger.hh new file mode 100644 index 0000000..1263e93 --- /dev/null +++ b/geant4/LEMuSR/include/lem4DetectorMessenger.hh @@ -0,0 +1,57 @@ +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef lem4DetectorMessenger_h +#define lem4DetectorMessenger_h 1 + +#include "globals.hh" +#include "G4UImessenger.hh" + +class lem4DetectorConstruction; +class G4UIdirectory; +class G4UIcmdWithAString; +class G4UIcmdWithADoubleAndUnit; +class G4UIcmdWithAnInteger; +class G4UIcmdWithoutParameter; +class G4UIcmdWith3Vector; +class G4UIcmdWith3VectorAndUnit; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class lem4DetectorMessenger: public G4UImessenger +{ + public: + lem4DetectorMessenger(lem4DetectorConstruction*); + ~lem4DetectorMessenger(); + + void SetNewValue(G4UIcommand*, G4String); + + private: + lem4DetectorConstruction* myDetector; + + G4UIdirectory* lem4Dir; + G4UIdirectory* detDir; + G4UIdirectory* runDir; + G4UIcmdWithAString* CommandCmd; + G4UIcmdWithAnInteger* RunIDSetCmd; + G4UIcmdWithAnInteger* RandomOptionCmd; + G4UIcmdWithAnInteger* HowOftenToPrintEventCmd; + // G4UIcmdWithAString* WhichProcessesCmd; + G4UIcmdWithoutParameter* UpdateCmd; + // G4UIcmdWithADoubleAndUnit* FieldCmd; + G4UIcmdWithADoubleAndUnit* UFieldCmd; +/// G4UIcmdWithADoubleAndUnit* UEFieldCmd; //Uniform Electric Field. TS + G4UIcmdWith3Vector* GFieldCmd; + + + public: + // cks: The two variables used for the random number initialisation each event (if required) + // long myEventNr; + // static G4bool setRandomNrSeedAccordingEventNr; + // void IncrementMyEventNr() {myEventNr++}; + // long GetMyEventNr() {return myEventNr}; +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif + diff --git a/geant4/LEMuSR/include/lem4ErrorMessage.hh b/geant4/LEMuSR/include/lem4ErrorMessage.hh new file mode 100644 index 0000000..798d3b3 --- /dev/null +++ b/geant4/LEMuSR/include/lem4ErrorMessage.hh @@ -0,0 +1,31 @@ +#ifndef lem4ErrorMessage_h +#define lem4ErrorMessage_h 1 + +#include +#include "globals.hh" +enum SEVERITY {INFO, WARNING, SERIOUS, FATAL}; + +typedef struct +{ + SEVERITY mesSeverity; + int nTimes; +} ErrorStruct; + +class lem4ErrorMessage { + public: + // enum SEVERITY {INFO, WARNING, SERIOUS, FATAL}; + lem4ErrorMessage(); + ~lem4ErrorMessage(); + static lem4ErrorMessage* GetInstance(); + void lem4Error(SEVERITY severity, G4String message, G4bool silent); + void PrintErrorSummary(); + + private: + static lem4ErrorMessage* pointerToErrors; + G4int nErrors; + // std::map ErrorMapping; + std::map ErrorMapping; + + std::map severityWord; +}; +#endif diff --git a/geant4/LEMuSR/include/lem4EventAction.hh b/geant4/LEMuSR/include/lem4EventAction.hh new file mode 100644 index 0000000..e27b80d --- /dev/null +++ b/geant4/LEMuSR/include/lem4EventAction.hh @@ -0,0 +1,67 @@ +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef lem4EventAction_h +#define lem4EventAction_h 1 + +#include "globals.hh" +#include "G4UserEventAction.hh" +#include +using namespace std; +class G4Timer; +class G4Event; +class lem4MagneticField; +class G4ElectricField; // Unif. el. field. TS +class lem4TabulatedField3D; +class lem4TabulatedField2D; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class lem4EventAction : public G4UserEventAction +{ + public: + lem4EventAction(); + ~lem4EventAction(); + + public: + void BeginOfEventAction(const G4Event*); + void EndOfEventAction(const G4Event*); + static lem4EventAction* GetInstance(); + + private: + // pointer to this class + static lem4EventAction* pointer; + // + G4Timer* timer; + static vector * pointerToSeedVector; + // Variables for the time-dependent magnetic field + G4bool timeDependentField; + G4double fieldValueStart, fieldValueEnd, fieldStep, lastFieldValue; + G4int fieldNrOfSteps; + G4int maxEventNr; + lem4MagneticField* pointerToMusrUniformField; + G4ElectricField* pointerToMusrUniformEField; // Pointer to uniform electric field. TS + lem4TabulatedField3D* pointerToTabulatedField3D; + lem4TabulatedField2D* pointerToTabulatedField2D; + G4int latestEventNr; + + public: + static G4bool setRandomNrSeedAccordingEventNr; + static G4bool setRandomNrSeedFromFile; + static G4int nHowOftenToPrintEvent; + static vector * GetPointerToSeedVector(); + // void setMyEventNr(long n) {myEventNr=n;}; + void SetTimeDependentField(G4bool setFieldToBeTimeDependend, G4double initialField, + G4double finalField, G4int nrOfSteps); + void SetNumberOfEventsInThisRun(G4int nrOfEventsInThisRun) {maxEventNr=nrOfEventsInThisRun;}; + void SetPointerToMusrUniformField(lem4MagneticField* pointer) {pointerToMusrUniformField=pointer;}; + void SetPointerToMusrUniformEField(G4ElectricField* pointer) {pointerToMusrUniformEField=pointer;}; // Unif. El. field. TS + void SetPointerToTabulatedField3D(lem4TabulatedField3D* pointer) {pointerToTabulatedField3D=pointer;}; + void SetPointerToTabulatedField2D(lem4TabulatedField2D* pointer) {pointerToTabulatedField2D=pointer;}; + G4int GetLatestEventNr(){return latestEventNr;}; +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif + + diff --git a/geant4/LEMuSR/include/lem4GaussianField.hh b/geant4/LEMuSR/include/lem4GaussianField.hh new file mode 100644 index 0000000..91858a8 --- /dev/null +++ b/geant4/LEMuSR/include/lem4GaussianField.hh @@ -0,0 +1,16 @@ +#include "globals.hh" +#include "G4MagneticField.hh" + +class lem4GaussianField +#ifndef STANDALONE + : public G4MagneticField +#endif +{ +private: + G4double ffieldValue; + G4double fieldMagnitude,RMS; +public: + lem4GaussianField(double fieldValue, double sigma); + void GetFieldValue( const double point[4], double *Bfield ) const; + G4double GetFieldSetValue(); +}; diff --git a/geant4/LEMuSR/include/lem4MagneticField.hh b/geant4/LEMuSR/include/lem4MagneticField.hh new file mode 100644 index 0000000..4bcb16d --- /dev/null +++ b/geant4/LEMuSR/include/lem4MagneticField.hh @@ -0,0 +1,38 @@ +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef lem4MagneticField_H +#define lem4MagneticField_H + +#include "G4UniformMagField.hh" + +class G4FieldManager; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + + +class lem4MagneticField: public G4UniformMagField +{ + public: + + lem4MagneticField(G4ThreeVector); // The value of the field + lem4MagneticField(); // A zero field + ~lem4MagneticField(); + + //Set the field (fieldValue,0,0) + void SetFieldValue(G4double fieldValue); + void SetFieldValue(G4ThreeVector fieldVector); + + G4ThreeVector GetConstantFieldValue(); + + protected: + + // Find the global Field Manager + G4FieldManager* GetGlobalFieldManager(); // static +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif + + +G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true); diff --git a/geant4/LEMuSR/include/lem4MuFormation.hh b/geant4/LEMuSR/include/lem4MuFormation.hh new file mode 100644 index 0000000..603631a --- /dev/null +++ b/geant4/LEMuSR/include/lem4MuFormation.hh @@ -0,0 +1,75 @@ +//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +// Muonium Formation according to yield.cc function (through GetYields method). +// Id : lem4MuFormation.hh, v 1.4 +// Author: Taofiq PARAISO, T. Shiroka +// Date : 2007-12 +//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + +#ifndef lem4MuFormation_h +#define lem4MuFormation_h 1 + +#include "G4VDiscreteProcess.hh" +#include "G4ParticleTable.hh" + +#include "yields.h" + +/*! lem4MuFormation class defines the muonium formation process in the Carbon foil + * according to yields from Gonin's paper Sci. Rev. Instrum. 65(3), 648-652 (1994). + * \image html yields3.gif The muonium formation yields. + * The main parameters are the foil thickness and muon energy. For a given energy, + * a corresponding proportion of the muons will be converted into Muonium. + * Concretely, the muon is eliminated and replaced by a Muonium with identical + * properties, including time, energy, momentum, position etc. + * + * The process is executed at the END of a step, i.e. the muon is converted into + * Muonium AFTER flying through the Carbon foil (see also yields.h). */ + +class lem4MuFormation : public G4VDiscreteProcess +{ + public: + + lem4MuFormation(const G4String& name = "MuFormation", // process description + G4ProcessType aType = fElectromagnetic); + + ~lem4MuFormation(); + + //! - Main method. Muonium formation process is executed at the END of a step. */ + G4VParticleChange* PostStepDoIt( + const G4Track&, + const G4Step&); + + G4double GetMeanFreePath(const G4Track& aTrack, + G4double previousStepSize, + G4ForceCondition* condition); + + + //! Condition for process application (step Object). + G4bool CheckCondition(const G4Step& aStep); + + //! Condition for process application (step Pointer). + G4bool CheckCondition(const G4Step* aStep); + + + G4String p_name; + G4bool condition; + + + void GetDatas( const G4Step* aStep); + // model parameters + G4ParticleTable* particleTable; + G4ParticleDefinition* particle; + Yields Gonin; + G4double yvector[3]; + G4double rnd; + G4DynamicParticle *DP; + + //! The particle change object. + G4VParticleChange fParticleChange; + + void PrepareSecondary(const G4Track&); + G4Track* aSecondary; + + void InitializeSecondaries(const G4Track&); +}; + +#endif diff --git a/geant4/LEMuSR/include/lem4MuScatter.hh b/geant4/LEMuSR/include/lem4MuScatter.hh new file mode 100644 index 0000000..a7af8b1 --- /dev/null +++ b/geant4/LEMuSR/include/lem4MuScatter.hh @@ -0,0 +1,52 @@ +//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +// Muonium "Scattering" +// Id : lem4MuScatter.hh, v 1.4 +// Author: Taofiq PARAISO, T. Shiroka +// Date : 2007-12 +// Notes : Simplified model for Mu scattering. Spin effects have been excluded. +//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + +/*! + * lem4MuScatter class defines the Muonium scattering process. It implements a very + * basic model which assumes Muonium looses its electron as soon as it enters any + * material (except for vacuum and CFoil). The class has only a PostStepDoIt method. + * The in-flight Muonium spin precession has been supressed. */ + +#ifndef lem4MuScatter_h +#define lem4MuScatter_h 1 + +#include "G4VDiscreteProcess.hh" + +class lem4MuScatter : public G4VDiscreteProcess +{ + public: + lem4MuScatter(const G4String& name="MuScatt", // process description + G4ProcessType aType = fGeneral); + + ~lem4MuScatter(); + + //! \mm The actions are taken at the end of the step. + G4VParticleChange* PostStepDoIt(const G4Track&, + const G4Step&); + + G4double GetMeanFreePath(const G4Track& aTrack, + G4double previousStepSize, + G4ForceCondition* condition); + + //! The condition for applying the process. + G4bool CheckCondition(const G4Step& aStep); + + + G4bool condition; + G4double itime, gtime, ftime,deltatime; + G4String p_name; + G4DynamicParticle *DP; + G4ParticleChange fParticleChange; + + void PrepareSecondary(const G4Track&); + G4Track* aSecondary; + + void InitializeSecondaries(const G4Track&); +}; + +#endif diff --git a/geant4/LEMuSR/include/lem4Muonium.hh b/geant4/LEMuSR/include/lem4Muonium.hh new file mode 100644 index 0000000..082b4cd --- /dev/null +++ b/geant4/LEMuSR/include/lem4Muonium.hh @@ -0,0 +1,72 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +// +// $Id: lem4Muonium.hh,v 1.10 2006/06/29 19:20:21 gunter Exp $ +// GEANT4 tag $Name: geant4-09-00 $ +// +// +// ------------------------------------------------------------ +// GEANT 4 class header file +// +// History: first implementation, based on object model of +// 4-th April 1996, G.Cosmo +// **************************************************************** +// New implementation as a utility class M.Asai, 26 July 2004 +// ---------------------------------------------------------------- + +#ifndef lem4Muonium_h +#define lem4Muonium_h 1 + +#include "globals.hh" +#include "G4ios.hh" +#include "G4ParticleDefinition.hh" + +// ###################################################################### +// ### MUONIUM ### +// ###################################################################### + +class lem4Muonium : public G4ParticleDefinition +{ + private: + static lem4Muonium* theInstance; + lem4Muonium(){} + ~lem4Muonium(){} + + public: + static lem4Muonium* Definition(); + static lem4Muonium* MuoniumDefinition(); + static lem4Muonium* Muonium(); +}; + +#endif + + + + + + + + diff --git a/geant4/LEMuSR/include/lem4Parameters.hh b/geant4/LEMuSR/include/lem4Parameters.hh new file mode 100644 index 0000000..7cded27 --- /dev/null +++ b/geant4/LEMuSR/include/lem4Parameters.hh @@ -0,0 +1,47 @@ +#ifndef lem4Parameters_h +#define lem4Parameters_h 1 + +#include "globals.hh" + +class lem4Parameters { + public: + ///lem4Parameters(); + lem4Parameters(G4String steeringFileName); // ADDED by TS - overloaded constructor + ~lem4Parameters(); + + static lem4Parameters* GetInstance(); + + void SetMyTypeOfProcesses(G4String string) {typeOfProcesses=string;}; + G4String GetMyTypeOfProcesses() {return typeOfProcesses;}; + + static G4bool storeOnlyEventsWithHits; // Variable specifying whether to store interesting + // or all events into the ROOT tree. (default = true) + static G4double signalSeparationTime; // Minimim time separation between two subsequent signal + static G4bool storeOnlyTheFirstTimeHit; // If true, only the hit that happened first will be + // stored, anything else will be ignored + // (useful in some special cases, not for a routine simulation) + static G4bool includeMuoniumProcesses; // If true, includes Muonium formation and all + // other Mu-related processes in the simulation + //ADDED by TS + + static G4bool boolG4GeneralParticleSource;//If true, G4GeneralParticleSource will be initialised + //instead of G4ParticleGun - for simulating radioactive sources + + static G4bool field_DecayWithSpin; // If true, then the routine for calculating the magnetic + // field will use a more precise argument. + // This variable is set to "true" by the SteppinAction + // and reset to "false" in the GetFieldValue. + // It is being changed on step by step basis. + + static G4int nrOfEventsToBeGenerated; // Nr of events to be simulated in this run (set by /run/beamOn command) + + private: + static lem4Parameters* pointerToParameters; + G4String typeOfProcesses; // Variable defining what kind of Physics processes to call: + // - Standard EM + // - LowEnergy (default) + // - Penelope + // - Coulomb +}; + +#endif diff --git a/geant4/LEMuSR/include/lem4PhysicsList.hh b/geant4/LEMuSR/include/lem4PhysicsList.hh new file mode 100644 index 0000000..488752a --- /dev/null +++ b/geant4/LEMuSR/include/lem4PhysicsList.hh @@ -0,0 +1,48 @@ +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef lem4PhysicsList_h +#define lem4PhysicsList_h 1 + +#include "G4VUserPhysicsList.hh" +#include "globals.hh" +//cks Added to have Geant default muon decay with spin +#include "G4DecayWithSpin.hh" +//#include "lem4DecayWithSpin.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class lem4PhysicsList: public G4VUserPhysicsList +{ + public: + lem4PhysicsList(); + ~lem4PhysicsList(); + + protected: + // Construct particle and physics + void ConstructParticle(); + void ConstructProcess(); + + void SetCuts(); + + + protected: + // these methods Construct particles + void ConstructBosons(); + void ConstructLeptons(); + void ConstructMesons(); + void ConstructBaryons(); + + protected: + // these methods Construct physics processes and register them + void ConstructGeneral(); + void ConstructEM(); + + // private: + // char myProcesses[100]; +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif + + diff --git a/geant4/LEMuSR/include/lem4PrimaryGeneratorAction.hh b/geant4/LEMuSR/include/lem4PrimaryGeneratorAction.hh new file mode 100644 index 0000000..6a05751 --- /dev/null +++ b/geant4/LEMuSR/include/lem4PrimaryGeneratorAction.hh @@ -0,0 +1,69 @@ +#ifndef lem4PrimaryGeneratorAction_h +#define lem4PrimaryGeneratorAction_h 1 + +#include "G4VUserPrimaryGeneratorAction.hh" +#include "globals.hh" +#include "Randomize.hh" +#include "G4ThreeVector.hh" +#include +//cksdel #include "lem4ParticleGun.hh" + +class G4ParticleGun; +class G4Event; +class lem4DetectorConstruction; +class lem4PrimaryGeneratorMessenger; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... + +class lem4PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction +{ + public: + lem4PrimaryGeneratorAction(lem4DetectorConstruction*); + ~lem4PrimaryGeneratorAction(); + + public: + void GeneratePrimaries(G4Event*); + void SetRndmFlag(G4String val) {rndmFlag = val;} + void Setvertex(G4ThreeVector v) {x0=v[0]; y0=v[1]; z0=v[2];} + void SetvertexSigma(G4ThreeVector v) {xSigma=v[0]; ySigma=v[1]; zSigma=v[2];} + void SetvertexBoundary(G4ThreeVector v) {rMaxAllowed=v[0]; zMinAllowed=v[1]; zMaxAllowed=v[2];} + void SetEnergy(G4double val) {p0=std::sqrt(val*val + 2*mu_mass*val);} // {E0=val;} + void SetMomentum(G4double val) {p0=val;} + void SetMomentumSmearing(G4double val) {pSigma=val;} + void SetMomentumBoundary(G4ThreeVector v){pMinAllowed=v[0]; pMaxAllowed=v[1];} + void SetTilt(G4ThreeVector v) {xangle0=v[0]; yangle0=v[1];} + void SetSigmaTilt(G4ThreeVector v) {xangleSigma=v[0]; yangleSigma=v[1];} + void SetPitch(G4double val) {pitch=val;} + void SetInitialMuonPolariz(G4ThreeVector vIniPol); + void SetMuonDecayTimeLimits(G4ThreeVector decayTimeLimits); + void SetTurtleInput(G4String turtleFileName); + + static G4String GetPrimaryName(); + + private: + G4ParticleGun* particleGun; // Pointer a to G4 service class + lem4DetectorConstruction* lem4Detector; // Pointer to the geometry + lem4PrimaryGeneratorMessenger* gunMessenger; // Messenger of this class + G4String rndmFlag; // Flag for a random impact point + + G4double x0, y0, z0, xSigma, ySigma, zSigma, rMaxAllowed, zMinAllowed, zMaxAllowed; + G4double E0, p0, pSigma, pMinAllowed, pMaxAllowed; + G4double xangle0, yangle0, xangleSigma, yangleSigma, pitch; + G4bool UnpolarisedMuonBeam; + G4double xPolarisIni, yPolarisIni, zPolarisIni; + G4double muonDecayTimeMin; + G4double muonDecayTimeMax; + G4double muonMeanLife; + G4double mu_mass; + + // For Turtle input + FILE* fTurtleFile; + G4bool takeMuonsFromTurtleFile; + + static G4String thePrimaryParticleName; + + public: + G4double decaytime; +}; + +#endif diff --git a/geant4/LEMuSR/include/lem4PrimaryGeneratorMessenger.hh b/geant4/LEMuSR/include/lem4PrimaryGeneratorMessenger.hh new file mode 100644 index 0000000..a1deb00 --- /dev/null +++ b/geant4/LEMuSR/include/lem4PrimaryGeneratorMessenger.hh @@ -0,0 +1,41 @@ +#ifndef lem4PrimaryGeneratorMessenger_h +#define lem4PrimaryGeneratorMessenger_h 1 + +#include "G4UImessenger.hh" +#include "globals.hh" + +class lem4PrimaryGeneratorAction; +class G4UIcmdWithAString; +class G4UIcmdWithADoubleAndUnit; +class G4UIcmdWithADouble; +class G4UIcmdWithAnInteger; +class G4UIcmdWith3VectorAndUnit; +class G4UIcmdWith3Vector; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... + +class lem4PrimaryGeneratorMessenger: public G4UImessenger +{ + public: + lem4PrimaryGeneratorMessenger(lem4PrimaryGeneratorAction* lem4Gun); + ~lem4PrimaryGeneratorMessenger(); + + void SetNewValue(G4UIcommand*, G4String newValue); + + private: + lem4PrimaryGeneratorAction* lem4Action; + G4UIcmdWith3VectorAndUnit* setvertexCmd; + G4UIcmdWith3VectorAndUnit* setvertexSigmaCmd; + G4UIcmdWith3VectorAndUnit* setvertexBoundaryCmd; + G4UIcmdWithADoubleAndUnit* setEnergyCmd; + G4UIcmdWithADoubleAndUnit* setMomentumCmd; + G4UIcmdWithADoubleAndUnit* setMomentumSmearingCmd; + G4UIcmdWith3VectorAndUnit* setMomentumBoundaryCmd; + G4UIcmdWith3VectorAndUnit* setTiltAngleCmd; + G4UIcmdWith3VectorAndUnit* setSigmaTiltAngleCmd; + G4UIcmdWithADoubleAndUnit* setPitchCmd; + G4UIcmdWith3Vector* setMuonPolarizCmd; + G4UIcmdWith3VectorAndUnit* setMuonDecayTimeCmd; + G4UIcmdWithAString* setTurtleCmd; +}; +#endif diff --git a/geant4/LEMuSR/include/lem4RootOutput.hh b/geant4/LEMuSR/include/lem4RootOutput.hh new file mode 100644 index 0000000..307679a --- /dev/null +++ b/geant4/LEMuSR/include/lem4RootOutput.hh @@ -0,0 +1,283 @@ +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef lem4RootOutput_h +#define lem4RootOutput_h 1 + +//#include "G4UserRunAction.hh" +#include "globals.hh" +#include "G4ThreeVector.hh" +// ROOT +#include "TFile.h" +#include "TTree.h" +#include "TH1.h" +#include "TH2.h" +#include "TVectorD.h" +// +#include +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class lem4RootOutput { + public: + lem4RootOutput(); + ~lem4RootOutput(); + static lem4RootOutput* GetRootInstance(); + + public: + void BeginOfRunAction(); + void EndOfRunAction(); + void FillEvent(); + void ClearAllRootVariables(); + // void SetSensitiveDetectorMapping(std::string logivol, int volumeID); + void SetVolumeIDMapping(std::string logivol, int volumeID); + G4int ConvertVolumeToID(std::string logivol); + void SetSpecialSaveVolumeDefined() {boolIsAnySpecialSaveVolumeDefined=true;}; + + + // Getting variables (just for debugging) + G4double GetDecayPositionZ() {return muDecayPosZ_t;}; + G4double GetDecayTime() {return muDecayTime_t*microsecond;}; + G4double GetTimeInTarget() {return muTargetTime_t*microsecond;}; + + // Setting variables common to the whole event: + void SetRunID (G4int id) {runID_t = id;}; + void SetEventID (G4int id) {eventID_t = id;}; + void SetDecayDetectorID (std::string detectorName) {muDecayDetID_t = SensDetectorMapping[detectorName];}; + void SetBField (G4double F[6]) {B_t[0]=F[0]/tesla; B_t[1]=F[1]/tesla; B_t[2]=F[2]/tesla; + B_t[3]=F[3]/tesla; B_t[4]=F[4]/tesla; B_t[5]=F[5]/tesla;}; + void SetDecayPolarisation (G4ThreeVector pol) {muDecayPolX_t=pol.x(); muDecayPolY_t=pol.y(); muDecayPolZ_t=pol.z();}; + void SetDecayPosition (G4ThreeVector pos) {muDecayPosX_t=pos.x()/mm; muDecayPosY_t=pos.y()/mm; + muDecayPosZ_t=pos.z()/mm;}; + void SetGlobTime (G4double gt) {globalTime_t = gt/microsecond;}; + + void SetDetectorInfo (G4int nDetectors, G4int ID, G4double edep, G4double edep_el, G4double edep_pos, + G4double edep_gam, G4double edep_mup,G4int nsteps, G4double length, G4double t1, + G4double t2, G4double x, G4double y, G4double z) { + if ((nDetectors<0)||(nDetectors>=(det_nMax-1))) { + G4cout<<"SERIOUS ERROR! lem4RootOutput.hh: nDetectors="< SensDetectorMapping; +}; + +//G4int lem4RootOutput::maxNSubTracks=30; + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif diff --git a/geant4/LEMuSR/include/lem4RunAction.hh b/geant4/LEMuSR/include/lem4RunAction.hh new file mode 100644 index 0000000..7d5086e --- /dev/null +++ b/geant4/LEMuSR/include/lem4RunAction.hh @@ -0,0 +1,36 @@ +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef lem4RunAction_h +#define lem4RunAction_h 1 + +#include "G4UserRunAction.hh" +#include "globals.hh" +#include "lem4RootOutput.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class G4Timer; +class G4Run; + +class lem4RunAction : public G4UserRunAction +{ + public: + lem4RunAction(); + ~lem4RunAction(); + + public: + void BeginOfRunAction(const G4Run*); + void EndOfRunAction(const G4Run*); + + private: + G4Timer* timer; +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif + + + + + diff --git a/geant4/LEMuSR/include/lem4ScintHit.hh b/geant4/LEMuSR/include/lem4ScintHit.hh new file mode 100644 index 0000000..31a61f4 --- /dev/null +++ b/geant4/LEMuSR/include/lem4ScintHit.hh @@ -0,0 +1,128 @@ +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef lem4ScintHit_h +#define lem4ScintHit_h 1 + +#include "G4VHit.hh" +#include "G4THitsCollection.hh" +#include "G4Allocator.hh" +#include "G4ThreeVector.hh" +#include "G4MagneticField.hh" +#include "globals.hh" +#include "G4ios.hh" +// ROOT +#include "TFile.h" +#include "TTree.h" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class lem4ScintHit : public G4VHit +{ + public: + + lem4ScintHit(); + ~lem4ScintHit(); + lem4ScintHit(const lem4ScintHit&); + const lem4ScintHit& operator=(const lem4ScintHit&); + G4int operator==(const lem4ScintHit&) const; + // bool operator() (lem4ScintHit hit1, lem4ScintHit hit2) { return (hit1.globalTime lem4ScintHitsCollection; + +extern G4Allocator lem4ScintHitAllocator; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +inline void* lem4ScintHit::operator new(size_t) +{ + void *aHit; + aHit = (void *) lem4ScintHitAllocator.MallocSingle(); + return aHit; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +inline void lem4ScintHit::operator delete(void *aHit) +{ + lem4ScintHitAllocator.FreeSingle((lem4ScintHit*) aHit); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif diff --git a/geant4/LEMuSR/include/lem4ScintSD.hh b/geant4/LEMuSR/include/lem4ScintSD.hh new file mode 100644 index 0000000..edff47e --- /dev/null +++ b/geant4/LEMuSR/include/lem4ScintSD.hh @@ -0,0 +1,42 @@ +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef lem4ScintSD_h +#define lem4ScintSD_h 1 + +#include "G4VSensitiveDetector.hh" +#include "lem4ScintHit.hh" +#include "lem4RootOutput.hh" + +//cksdel extern lem4RootOutput* myRootOutput; + +class G4Step; +class G4HCofThisEvent; +//class lem4ScintHit; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class lem4ScintSD : public G4VSensitiveDetector +{ + public: + lem4ScintSD(G4String); + ~lem4ScintSD(); + + void Initialize(G4HCofThisEvent*); + G4bool ProcessHits(G4Step*, G4TouchableHistory*); + void EndOfEvent(G4HCofThisEvent*); + // bool timeOrdering (lem4ScintHit* hit1, lem4ScintHit* hit2); + // bool myREMOVEfunction (int i,int j) { return (i lem4ShieldHitsCollection; + +extern G4Allocator lem4ShieldHitAllocator; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +inline void* lem4ShieldHit::operator new(size_t) +{ + void *aHit; + aHit = (void *) lem4ShieldHitAllocator.MallocSingle(); + return aHit; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +inline void lem4ShieldHit::operator delete(void *aHit) +{ + lem4ShieldHitAllocator.FreeSingle((lem4ShieldHit*) aHit); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif diff --git a/geant4/LEMuSR/include/lem4ShieldSD.hh b/geant4/LEMuSR/include/lem4ShieldSD.hh new file mode 100644 index 0000000..1aa9a21 --- /dev/null +++ b/geant4/LEMuSR/include/lem4ShieldSD.hh @@ -0,0 +1,32 @@ +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef lem4ShieldSD_h +#define lem4ShieldSD_h 1 + +#include "G4VSensitiveDetector.hh" +#include "lem4ShieldHit.hh" + +class G4Step; +class G4HCofThisEvent; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class lem4ShieldSD : public G4VSensitiveDetector +{ + public: + lem4ShieldSD(G4String); + ~lem4ShieldSD(); + + void Initialize(G4HCofThisEvent*); + G4bool ProcessHits(G4Step*, G4TouchableHistory*); + void EndOfEvent(G4HCofThisEvent*); + + private: + lem4ShieldHitsCollection* shieldCollection; + +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif + diff --git a/geant4/LEMuSR/include/lem4SteppingAction.hh b/geant4/LEMuSR/include/lem4SteppingAction.hh new file mode 100644 index 0000000..bc4d3f5 --- /dev/null +++ b/geant4/LEMuSR/include/lem4SteppingAction.hh @@ -0,0 +1,47 @@ +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef lem4SteppingAction_h +#define lem4SteppingAction_h 1 + +#include "G4UserSteppingAction.hh" +#include "G4ProcessManager.hh" +#include "globals.hh" +#include + +class G4Timer; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class lem4SteppingAction : public G4UserSteppingAction +{ + public: + + static lem4SteppingAction* GetInstance(); + lem4SteppingAction(); + ~lem4SteppingAction(); + + void UserSteppingAction(const G4Step *theStep); + void DoAtTheBeginningOfEvent(); + void SetLogicalVolumeAsSpecialSaveVolume(G4String logicName, G4int volumeID); + + private: + G4Timer* timer; + static lem4SteppingAction* pointer; + // G4int oldEventID; + G4ProcessManager* muPlusProcessManager; + G4bool multipleToCoulombScatteringIsPossible; + G4bool coulombScatteringIsActive; + size_t multipleScatteringIndex; + size_t coulombScatteringIndex; + G4bool muAlreadyWasInTargetInThisEvent; + G4bool radioactiveElectronAlreadySavedInThisEvent; + G4bool boolIsAnySpecialSaveVolumeDefined; + std::map saveVolumeMapping; + G4String lastActualVolume; + // G4int debugOldEventID; + // G4int nrOfSteps; +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif diff --git a/geant4/LEMuSR/include/lem4SteppingVerbose.hh b/geant4/LEMuSR/include/lem4SteppingVerbose.hh new file mode 100644 index 0000000..16ca26c --- /dev/null +++ b/geant4/LEMuSR/include/lem4SteppingVerbose.hh @@ -0,0 +1,26 @@ +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class lem4SteppingVerbose; + +#ifndef lem4SteppingVerbose_h +#define lem4SteppingVerbose_h 1 + +#include "G4SteppingVerbose.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class lem4SteppingVerbose : public G4SteppingVerbose +{ + public: + + lem4SteppingVerbose(); + ~lem4SteppingVerbose(); + + void StepInfo(); + void TrackingStarted(); + +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif diff --git a/geant4/LEMuSR/include/lem4TabulatedElementField2D.hh b/geant4/LEMuSR/include/lem4TabulatedElementField2D.hh new file mode 100644 index 0000000..3731c2a --- /dev/null +++ b/geant4/LEMuSR/include/lem4TabulatedElementField2D.hh @@ -0,0 +1,73 @@ +#ifndef lem4TabulatedElementField2D_h +#define lem4TabulatedElementField2D_h 1 + +#include "F04ElementField.hh" +#include "F04GlobalField.hh" + +#include "globals.hh" +#include "G4ios.hh" + +#include +#include +#include + + +class lem4TabulatedElementField2D : public F04ElementField +{ +public: // with description + // Class constructor for 2D axial field map (r, z, EMr, EMz) - with EM = E or B; r - radial, z - longitudinal. + lem4TabulatedElementField2D(const char* filename, const char fieldType, G4double fieldValue, G4LogicalVolume* logVolume, G4ThreeVector positionOfTheCenter); + // + // "fieldType" is the type of EM field: electric - E, or magnetic - B + // "fieldValue" is the field to be applied (in T, or in kV/mm). The normalised field + // map values are multiplied by this value. The field-map itself has no units! + // "lenUnit" is the unit in which the grid coordinates of the field-map are specified + // "fieldNormalisation" is the normalisation factor that once applied to the tabulated field values + // satisfies the condition: (max. field value)*fieldNormalisation = 1 + // To revert field direction, change its sign to negative. + + // Virtual destructor + virtual ~lem4TabulatedElementField2D() {} + + // addFieldValue() adds the field for THIS particular map into field[]. + // point[] is expressed in GLOBAL coordinates. + void addFieldValue( const G4double Point[4], G4double* field) const; + + // Usual Set and Get functions + G4double GetNominalFieldValue(); + void SetNominalFieldValue(G4double newFieldValue); + + // getWidth(), getHeight(), getLength(), return the dimensions of the field + // (used to define the boundary of the field) + virtual G4double getWidth() { return 2*dr; } // x coordinate + virtual G4double getHeight() { return 2*dr; } // y coordinate + virtual G4double getLength() { return dz; } // z coordinate + + +private: + // Storage space for the 2D table + std::vector< std::vector< double > > rField; + std::vector< std::vector< double > > zField; + // The field-map dimensions + int nr, nz; + // The field map Length unit (string and number) + G4String lUnit; + double lenUnit; + // The DEFAULT user-defined field units for E and B (kilovolt/mm and tesla) + G4String fUnit; + double fieUnit; + // The field-map Field normalisation factor + double fieldNormalisation; + // The physical limits of the defined region + double minimumr, maximumr, minimumz, maximumz; + // The physical extent of the defined region + double dr, dz; + // See the description under the class constructor + char fldType; + double ffieldValue; + + void Invert(const char* indexToInvert); + +}; + +#endif diff --git a/geant4/LEMuSR/include/lem4TabulatedElementField2Df.hh b/geant4/LEMuSR/include/lem4TabulatedElementField2Df.hh new file mode 100644 index 0000000..99a211a --- /dev/null +++ b/geant4/LEMuSR/include/lem4TabulatedElementField2Df.hh @@ -0,0 +1,73 @@ +#ifndef lem4TabulatedElementField2Df_h +#define lem4TabulatedElementField2Df_h 1 + +#include "F04ElementField.hh" +#include "F04GlobalField.hh" + +#include "globals.hh" +#include "G4ios.hh" + +#include +#include +#include + + +class lem4TabulatedElementField2Df : public F04ElementField +{ +public: // with description + // Class constructor for r-axis FOLDED 2D axial field map (r, z, EMr, EMz) - with EM = E or B; r - radial, z - longit. + lem4TabulatedElementField2Df(const char* filename, const char fieldType, G4double fieldValue, G4LogicalVolume* logVolume, G4ThreeVector positionOfTheCenter); + // + // "fieldType" is the type of EM field: electric - E, or magnetic - B + // "fieldValue" is the field to be applied (in T, or in kV/mm). The normalised field + // map values are multiplied by this value. The field-map itself has no units! + // "lenUnit" is the unit in which the grid coordinates of the field-map are specified + // "fieldNormalisation" is the normalisation factor that once applied to the tabulated field values + // satisfies the condition: (max. field value)*fieldNormalisation = 1 + // To revert field direction, change its sign to negative. + + // Virtual destructor + virtual ~lem4TabulatedElementField2Df() {} + + // addFieldValue() adds the field for THIS particular map into field[]. + // point[] is expressed in GLOBAL coordinates. + void addFieldValue( const G4double Point[4], G4double* field) const; + + // Usual Set and Get functions + G4double GetNominalFieldValue(); + void SetNominalFieldValue(G4double newFieldValue); + + // getWidth(), getHeight(), getLength(), return the dimensions of the field + // (used to define the boundary of the field) + virtual G4double getWidth() { return 2*dr; } // x coordinate + virtual G4double getHeight() { return 2*dr; } // y coordinate + virtual G4double getLength() { return 2*dz; } // z coordinate + + +private: + // Storage space for the 2D table + std::vector< std::vector< double > > rField; + std::vector< std::vector< double > > zField; + // The field-map dimensions + int nr, nz; + // The field map Length unit (string and number) + G4String lUnit; + double lenUnit; + // The DEFAULT user-defined field units for E and B (kilovolt/mm and tesla) + G4String fUnit; + double fieUnit; + // The field-map Field normalisation factor + double fieldNormalisation; + // The physical limits of the defined region + double minimumr, maximumr, minimumz, maximumz; + // The physical extent of the defined region + double dr, dz; + // See the description under the class constructor + char fldType; + double ffieldValue; + + void Invert(const char* indexToInvert); + +}; + +#endif diff --git a/geant4/LEMuSR/include/lem4TabulatedElementField3D.hh b/geant4/LEMuSR/include/lem4TabulatedElementField3D.hh new file mode 100644 index 0000000..f5fbd6d --- /dev/null +++ b/geant4/LEMuSR/include/lem4TabulatedElementField3D.hh @@ -0,0 +1,76 @@ +#ifndef lem4TabulatedElementField3D_h +#define lem4TabulatedElementField3D_h 1 + +#include "F04ElementField.hh" +#include "F04GlobalField.hh" + +#include "globals.hh" +#include "G4ios.hh" + +#include +#include +#include + +// Class for reading 3D electric and magnetic field map, either with or without coordinates. + +class lem4TabulatedElementField3D : public F04ElementField +{ +public: // with description + // Class constructor for 3D field map (x, y, z, EMx, EMy, EMz) - with EM = E or B + lem4TabulatedElementField3D(const char* filename, const char fieldType, G4double fieldValue, G4LogicalVolume* logVolume, G4ThreeVector positionOfTheCenter); + // + // "fieldType" is the type of EM field: electric - E, or magnetic - B + // "fieldValue" is the field to be applied (in T, or in kV/mm). The normalised field + // map values are multiplied by this value. The field-map itself has no units! + // "lenUnit" is the unit in which the grid coordinates of the field-map are specified + // "fieldNormalisation" is the normalisation factor that once applied to the tabulated field values + // satisfies the condition: (max. field value)*fieldNormalisation = 1 + // To revert field direction, change its sign to negative. + + // Virtual destructor + virtual ~lem4TabulatedElementField3D() {} + + // addFieldValue() adds the field for THIS particular map into field[]. + // point[] is expressed in GLOBAL coordinates. + void addFieldValue( const G4double Point[4], G4double* field) const; + + // Usual Set and Get functions + G4double GetNominalFieldValue(); + void SetNominalFieldValue(G4double newFieldValue); + + // getWidth(), getHeight(), getLength(), return the dimensions of the field + // (used to define the boundary of the field) + virtual G4double getWidth() { return dx; } // x coordinate + virtual G4double getHeight() { return dy; } // y coordinate + virtual G4double getLength() { return dz; } // z coordinate + + +private: + // Storage space for the 3D table + std::vector< std::vector< std::vector< double > > > xField; + std::vector< std::vector< std::vector< double > > > yField; + std::vector< std::vector< std::vector< double > > > zField; + // The field-map dimensions + int nx, ny, nz; + // The field map Length unit (string and number) + ///G4String lUnit; + char lUnit[50]; + double lenUnit; + // The DEFAULT user-defined field units for E and B (kilovolt/mm and tesla) + G4String fUnit; + double fieUnit; + // The field-map Field normalisation factor + double fieldNormalisation; + // The physical limits of the defined region + double minimumx, maximumx, minimumy, maximumy, minimumz, maximumz; + // The physical extent of the defined region + double dx, dy, dz; + // See the description under the class constructor + char fldType; + double ffieldValue; + + void Invert(const char* indexToInvert); + +}; + +#endif diff --git a/geant4/LEMuSR/include/lem4TabulatedField2D.hh b/geant4/LEMuSR/include/lem4TabulatedField2D.hh new file mode 100644 index 0000000..c2fb3e6 --- /dev/null +++ b/geant4/LEMuSR/include/lem4TabulatedField2D.hh @@ -0,0 +1,52 @@ +#include "globals.hh" +#include "G4MagneticField.hh" +#include "G4ios.hh" +//cks For the special case of muon decay: +//#include "G4EventManager.hh" +//#include "G4RunManagerKernel.hh" +//csk + +#include +#include +#include + + +class lem4TabulatedField2D +#ifndef STANDALONE + : public G4MagneticField +#endif +{ + + // Storage space for the table + std::vector< std::vector< double > > xField; + std::vector< std::vector< double > > zField; + // The dimensions of the table + int nx,nz; + // The physical limits of the defined region + double minx, maxx, minz, maxz; + // The physical extent of the defined region + double dx, dz; + double ffieldValue; + bool invertX, invertZ; + double positionOffset[4]; + + static lem4TabulatedField2D* pointerToTabulatedField2D; + +public: + + static lem4TabulatedField2D* GetInstance(); + + lem4TabulatedField2D(const char* filename, double fieldValue, double lenUnit, double fieldNormalisation ); + // "lenUnit" is the unit in which the grid coordinates are specified in the table + // "fieldNormalisation" is the normalisation that has to be applied on the field values in the table + // such that the values correspond do 1T nominal value + // "fieldValue" is the field value (in T) that is required (i.e. values normalised to 1T will be + // multiplied by this value). + void GetFieldValue( const double Point[4], + double *Bfield ) const; + G4double GetFieldSetValue(); + void SetFieldValue(double newFieldValue); + void SetPositionOffset(double offset[4]) { positionOffset[0]=offset[0]; positionOffset[1]=offset[1]; + positionOffset[2]=offset[2]; positionOffset[3]=offset[3];} +}; + diff --git a/geant4/LEMuSR/include/lem4TabulatedField3D.hh b/geant4/LEMuSR/include/lem4TabulatedField3D.hh new file mode 100644 index 0000000..a809576 --- /dev/null +++ b/geant4/LEMuSR/include/lem4TabulatedField3D.hh @@ -0,0 +1,46 @@ +#include "globals.hh" +#include "G4MagneticField.hh" +#include "G4ios.hh" + +#include +#include +#include + +using namespace std; + +class lem4TabulatedField3D +#ifndef STANDALONE + : public G4MagneticField +#endif +{ + + // Storage space for the table + vector< vector< vector< double > > > xField; + vector< vector< vector< double > > > yField; + vector< vector< vector< double > > > zField; + // The dimensions of the table + int nx,ny,nz; + // The physical limits of the defined region + double minx, maxx, miny, maxy, minz, maxz; + // The physical extent of the defined region + double dx, dy, dz; + double ffieldValue; + bool invertX, invertY, invertZ; + double positionOffset[4]; + + static lem4TabulatedField3D* pointerToTabulatedField3D; + +public: + + static lem4TabulatedField3D* GetInstance(); + + lem4TabulatedField3D(const char* filename, double fieldValue ); + void GetFieldValue( const double Point[4], + double *Bfield ) const; + G4double GetFieldSetValue(); + void SetFieldValue(double newFieldValue); + void SetPositionOffset(double offset[4]) { positionOffset[0]=offset[0]; positionOffset[1]=offset[1]; + positionOffset[2]=offset[2]; positionOffset[3]=offset[3];} + +}; + diff --git a/geant4/LEMuSR/include/lem4UniformField.hh b/geant4/LEMuSR/include/lem4UniformField.hh new file mode 100644 index 0000000..5299917 --- /dev/null +++ b/geant4/LEMuSR/include/lem4UniformField.hh @@ -0,0 +1,43 @@ +#ifndef UNIFORM_BFIELD_HH +#define UNIFORM_BFIELD_HH + +#include "G4LogicalVolume.hh" +#include "G4Box.hh" + +#include "F04ElementField.hh" +#include "F04GlobalField.hh" + +// UniformField implements a constant electromagnetic field in any direction. TS + +class lem4UniformField : public F04ElementField +{ + public: + + lem4UniformField(G4double EMF[6], G4LogicalVolume*, G4ThreeVector); + + virtual ~lem4UniformField() {} + + // TS: Define the two newly added VIRTUAL functions of F04ElementField + G4double GetNominalFieldValue(); + void SetNominalFieldValue(G4double newFieldValue); + + virtual G4double getLength() { return fieldLength; } + virtual G4double getWidth() { return fieldWidth; } + virtual G4double getHeight() { return fieldHeight; } + + G4bool isOutside(G4ThreeVector& local) const; + G4bool isWithin (G4ThreeVector& local) const; + + void addFieldValue(const G4double point[4], G4double field[6]) const; + + private: + + G4double EMfield[6]; + + G4double fieldLength; + G4double fieldWidth; + G4double fieldHeight; + +}; + +#endif diff --git a/geant4/LEMuSR/include/lem4VisManager.hh b/geant4/LEMuSR/include/lem4VisManager.hh new file mode 100644 index 0000000..6362ef7 --- /dev/null +++ b/geant4/LEMuSR/include/lem4VisManager.hh @@ -0,0 +1,26 @@ +#ifndef lem4VisManager_h +#define lem4VisManager_h 1 + +#ifdef G4VIS_USE + +#include "G4VisManager.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class lem4VisManager: public G4VisManager { + +public: + + lem4VisManager (); + +private: + + void RegisterGraphicsSystems (); + +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif + +#endif diff --git a/geant4/LEMuSR/include/musrTabulatedElementField2D.hh b/geant4/LEMuSR/include/musrTabulatedElementField2D.hh new file mode 100644 index 0000000..98d83e0 --- /dev/null +++ b/geant4/LEMuSR/include/musrTabulatedElementField2D.hh @@ -0,0 +1,57 @@ +#ifndef lem4TabulatedElementField2D_h +#define lem4TabulatedElementField2D_h 1 + +#include "globals.hh" +////#include "G4MagneticField.hh" +#include "F04ElementField.hh" +#include "F04GlobalField.hh" +#include "G4ios.hh" +#include +#include +#include + + +class lem4TabulatedElementField2D : public F04ElementField +{ +public: + lem4TabulatedElementField2D(const char* filename, G4double fieldValue, G4double lenUnit, G4double fieldNormalisation, G4LogicalVolume* logVolume, G4ThreeVector positionOfTheCenter); + // "lenUnit" is the unit in which the grid coordinates are specified in the table + // "fieldNormalisation" is the normalisation that has to be applied on the field values in the table + // such that the values correspond do 1T nominal value + // "fieldValue" is the field value (in T) that is required (i.e. values normalised to 1T will be + // multiplied by this value). + + /// Destructor. + virtual ~lem4TabulatedElementField2D() {} + + /// addFieldValue() adds the field for this solenoid into field[]. + /// point[] is in global coordinates. + void addFieldValue( const G4double Point[4], G4double* field) const; + + G4double GetNominalFieldValue(); + void SetNominalFieldValue(G4double newFieldValue); + + // getWidth(), getHeight(), getLength(), return the dimensions of the field + // (used to define the boundary of the field) + virtual G4double getWidth() { return 2*dx; } // x coordinate + virtual G4double getHeight() { return 2*dx; } // y coordinate + virtual G4double getLength() { return 2*dz; } // z coordinate + + +private: + // Storage space for the table + std::vector< std::vector< double > > xField; + std::vector< std::vector< double > > zField; + // The dimensions of the table + int nx,nz; + // The physical limits of the defined region + double minimumx, maximumx, minimumz, maximumz; + // The physical extent of the defined region + double dx, dz; + double ffieldValue; + + void Invert(const char* indexToInvert); + +}; + +#endif diff --git a/geant4/LEMuSR/include/musrTabulatedElementField3D.hh b/geant4/LEMuSR/include/musrTabulatedElementField3D.hh new file mode 100644 index 0000000..0abb19b --- /dev/null +++ b/geant4/LEMuSR/include/musrTabulatedElementField3D.hh @@ -0,0 +1,57 @@ +#ifndef lem4TabulatedElementField3D_h +#define lem4TabulatedElementField3D_h 1 + +#include "globals.hh" +#include "F04ElementField.hh" +#include "F04GlobalField.hh" +#include "G4ios.hh" +#include +#include +#include + + +class lem4TabulatedElementField3D : public F04ElementField +{ +public: + lem4TabulatedElementField3D(const char* filename, G4double fieldValue, G4double lenUnit, G4double fieldNormalisation, G4LogicalVolume* logVolume, G4ThreeVector positionOfTheCenter); + // "lenUnit" is the unit in which the grid coordinates are specified in the table + // "fieldNormalisation" is the normalisation that has to be applied on the field values in the table + // such that the values correspond do 1T nominal value + // "fieldValue" is the field value (in T) that is required (i.e. values normalised to 1T will be + // multiplied by this value). + + /// Destructor. + virtual ~lem4TabulatedElementField3D() {} + + /// addFieldValue() adds the field for this solenoid into field[]. + /// point[] is in global coordinates. + void addFieldValue( const G4double Point[4], G4double* field) const; + + G4double GetNominalFieldValue(); + void SetNominalFieldValue(G4double newFieldValue); + + // getWidth(), getHeight(), getLength(), return the dimensions of the field + // (used to define the boundary of the field) + virtual G4double getWidth() { return dx; } // x coordinate + virtual G4double getHeight() { return dy; } // y coordinate + virtual G4double getLength() { return dz; } // z coordinate + + +private: + // Storage space for the table + std::vector< std::vector< std::vector< double > > > xField; + std::vector< std::vector< std::vector< double > > > yField; + std::vector< std::vector< std::vector< double > > > zField; + // The dimensions of the table + int nx,ny,nz; + // The physical limits of the defined region + double minimumx, maximumx, minimumy, maximumy, minimumz, maximumz; + // The physical extent of the defined region + double dx, dy, dz; + double ffieldValue; + + void Invert(const char* indexToInvert); + +}; + +#endif diff --git a/geant4/LEMuSR/include/musrTabulatedField2D.hh b/geant4/LEMuSR/include/musrTabulatedField2D.hh new file mode 100644 index 0000000..c2fb3e6 --- /dev/null +++ b/geant4/LEMuSR/include/musrTabulatedField2D.hh @@ -0,0 +1,52 @@ +#include "globals.hh" +#include "G4MagneticField.hh" +#include "G4ios.hh" +//cks For the special case of muon decay: +//#include "G4EventManager.hh" +//#include "G4RunManagerKernel.hh" +//csk + +#include +#include +#include + + +class lem4TabulatedField2D +#ifndef STANDALONE + : public G4MagneticField +#endif +{ + + // Storage space for the table + std::vector< std::vector< double > > xField; + std::vector< std::vector< double > > zField; + // The dimensions of the table + int nx,nz; + // The physical limits of the defined region + double minx, maxx, minz, maxz; + // The physical extent of the defined region + double dx, dz; + double ffieldValue; + bool invertX, invertZ; + double positionOffset[4]; + + static lem4TabulatedField2D* pointerToTabulatedField2D; + +public: + + static lem4TabulatedField2D* GetInstance(); + + lem4TabulatedField2D(const char* filename, double fieldValue, double lenUnit, double fieldNormalisation ); + // "lenUnit" is the unit in which the grid coordinates are specified in the table + // "fieldNormalisation" is the normalisation that has to be applied on the field values in the table + // such that the values correspond do 1T nominal value + // "fieldValue" is the field value (in T) that is required (i.e. values normalised to 1T will be + // multiplied by this value). + void GetFieldValue( const double Point[4], + double *Bfield ) const; + G4double GetFieldSetValue(); + void SetFieldValue(double newFieldValue); + void SetPositionOffset(double offset[4]) { positionOffset[0]=offset[0]; positionOffset[1]=offset[1]; + positionOffset[2]=offset[2]; positionOffset[3]=offset[3];} +}; + diff --git a/geant4/LEMuSR/include/musrTabulatedField3D.hh b/geant4/LEMuSR/include/musrTabulatedField3D.hh new file mode 100644 index 0000000..a809576 --- /dev/null +++ b/geant4/LEMuSR/include/musrTabulatedField3D.hh @@ -0,0 +1,46 @@ +#include "globals.hh" +#include "G4MagneticField.hh" +#include "G4ios.hh" + +#include +#include +#include + +using namespace std; + +class lem4TabulatedField3D +#ifndef STANDALONE + : public G4MagneticField +#endif +{ + + // Storage space for the table + vector< vector< vector< double > > > xField; + vector< vector< vector< double > > > yField; + vector< vector< vector< double > > > zField; + // The dimensions of the table + int nx,ny,nz; + // The physical limits of the defined region + double minx, maxx, miny, maxy, minz, maxz; + // The physical extent of the defined region + double dx, dy, dz; + double ffieldValue; + bool invertX, invertY, invertZ; + double positionOffset[4]; + + static lem4TabulatedField3D* pointerToTabulatedField3D; + +public: + + static lem4TabulatedField3D* GetInstance(); + + lem4TabulatedField3D(const char* filename, double fieldValue ); + void GetFieldValue( const double Point[4], + double *Bfield ) const; + G4double GetFieldSetValue(); + void SetFieldValue(double newFieldValue); + void SetPositionOffset(double offset[4]) { positionOffset[0]=offset[0]; positionOffset[1]=offset[1]; + positionOffset[2]=offset[2]; positionOffset[3]=offset[3];} + +}; +