| 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | //
|
|---|
| 27 | // $Id: G4FieldManager.cc,v 1.15 2007/12/07 15:34:10 japost Exp $
|
|---|
| 28 | // GEANT4 tag $Name: $
|
|---|
| 29 | //
|
|---|
| 30 | // -------------------------------------------------------------------
|
|---|
| 31 |
|
|---|
| 32 | #include "G4FieldManager.hh"
|
|---|
| 33 | #include "G4Field.hh"
|
|---|
| 34 | #include "G4MagneticField.hh"
|
|---|
| 35 | #include "G4ChordFinder.hh"
|
|---|
| 36 | #include "G4FieldManagerStore.hh"
|
|---|
| 37 |
|
|---|
| 38 | G4FieldManager::G4FieldManager(G4Field *detectorField,
|
|---|
| 39 | G4ChordFinder *pChordFinder,
|
|---|
| 40 | G4bool fieldChangesEnergy
|
|---|
| 41 | )
|
|---|
| 42 | : fDetectorField(detectorField),
|
|---|
| 43 | fChordFinder(pChordFinder),
|
|---|
| 44 | fAllocatedChordFinder(false),
|
|---|
| 45 | fDefault_Delta_One_Step_Value(0.01*mm),
|
|---|
| 46 | fDefault_Delta_Intersection_Val(0.001*mm),
|
|---|
| 47 | fEpsilonMinDefault(5.0e-5),
|
|---|
| 48 | fEpsilonMaxDefault(0.001),
|
|---|
| 49 | fEpsilonMin( fEpsilonMinDefault ),
|
|---|
| 50 | fEpsilonMax( fEpsilonMaxDefault)
|
|---|
| 51 | {
|
|---|
| 52 | fDelta_One_Step_Value= fDefault_Delta_One_Step_Value;
|
|---|
| 53 | fDelta_Intersection_Val= fDefault_Delta_Intersection_Val;
|
|---|
| 54 | if ( detectorField )
|
|---|
| 55 | fFieldChangesEnergy= detectorField->DoesFieldChangeEnergy();
|
|---|
| 56 | else
|
|---|
| 57 | fFieldChangesEnergy= fieldChangesEnergy;
|
|---|
| 58 |
|
|---|
| 59 | // Add to store
|
|---|
| 60 | G4FieldManagerStore::Register(this);
|
|---|
| 61 |
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | G4FieldManager::G4FieldManager(G4MagneticField *detectorField)
|
|---|
| 65 | : fDetectorField(detectorField), fAllocatedChordFinder(true),
|
|---|
| 66 | fFieldChangesEnergy(false),
|
|---|
| 67 | fDefault_Delta_One_Step_Value(0.01*mm),
|
|---|
| 68 | fDefault_Delta_Intersection_Val(0.001*mm),
|
|---|
| 69 | fEpsilonMinDefault(5.0e-5),
|
|---|
| 70 | fEpsilonMaxDefault(0.001),
|
|---|
| 71 | fEpsilonMin( fEpsilonMinDefault ),
|
|---|
| 72 | fEpsilonMax( fEpsilonMaxDefault)
|
|---|
| 73 | {
|
|---|
| 74 | fChordFinder= new G4ChordFinder( detectorField );
|
|---|
| 75 | fDelta_One_Step_Value= fDefault_Delta_One_Step_Value;
|
|---|
| 76 | fDelta_Intersection_Val= fDefault_Delta_Intersection_Val;
|
|---|
| 77 | // Add to store
|
|---|
| 78 | G4FieldManagerStore::Register(this);
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | void G4FieldManager::ConfigureForTrack( const G4Track * )
|
|---|
| 82 | {
|
|---|
| 83 | // Default is to do nothing!
|
|---|
| 84 | ;
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | G4FieldManager::~G4FieldManager()
|
|---|
| 88 | {
|
|---|
| 89 | if( fAllocatedChordFinder ){
|
|---|
| 90 | delete fChordFinder;
|
|---|
| 91 | }
|
|---|
| 92 | G4FieldManagerStore::DeRegister(this);
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | void
|
|---|
| 96 | G4FieldManager::CreateChordFinder(G4MagneticField *detectorMagField)
|
|---|
| 97 | {
|
|---|
| 98 | if ( fAllocatedChordFinder )
|
|---|
| 99 | delete fChordFinder;
|
|---|
| 100 | fChordFinder= new G4ChordFinder( detectorMagField );
|
|---|
| 101 | fAllocatedChordFinder= true;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | G4bool G4FieldManager::SetDetectorField(G4Field *pDetectorField)
|
|---|
| 105 | {
|
|---|
| 106 | fDetectorField= pDetectorField;
|
|---|
| 107 |
|
|---|
| 108 | if ( pDetectorField )
|
|---|
| 109 | fFieldChangesEnergy= pDetectorField->DoesFieldChangeEnergy();
|
|---|
| 110 | else
|
|---|
| 111 | fFieldChangesEnergy= false; // No field
|
|---|
| 112 |
|
|---|
| 113 | return false;
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|