12.07.2015 Views

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Detector Definition and ResponsefieldMgr->GetChordFinder()->SetDeltaChord( G4double newValue);4.3.2.2. Creating a Field <strong>for</strong> a Part of the Volume HierarchyIt is possible to create a field <strong>for</strong> a part of the detector. In particular it can describe the field (with pointerfEmField, <strong>for</strong> example) inside a logical volume and all its daughters. This can be done by simply creating aG4FieldManager and attaching it to a logical volume (with pointer, logicVolumeWithField, <strong>for</strong> example) orset of logical volumes.G4bool allLocal = true;logicVolumeWithField->SetFieldManager(localFieldManager, allLocal);Using the second parameter to SetFieldManager you choose whether daughter volumes of this logical volumewill also be given this new field. If it has the value true, the field will be assigned also to its daughters, andall their sub-volumes. Else, if it is false, it will be copied only to those daughter volumes which do not havea field manager already.4.3.2.3. Creating an Electric or Electromagnetic FieldThe design and implementation of the Field category allows and enables the use of an electric or combined electromagneticfield. These fields can also vary with time, as can magnetic fields.Source listing Example 4.12 shows how to define a uni<strong>for</strong>m electric field <strong>for</strong> the whole of a detector.Example 4.12. How to define a uni<strong>for</strong>m electric field <strong>for</strong> the whole of a detector, extractedfrom example in examples/extended/field/field02 .// in the header file (or first)#include "G4EqMagElectricField.hh"#include "G4Uni<strong>for</strong>mElectricField.hh"...G4ElectricField* fEMfield;G4EqMagElectricField* fEquation;G4MagIntegratorStepper* fStepper;G4FieldManager*fFieldMgr;G4double fMinStep ;G4ChordFinder* fChordFinder ;// in the source file{fEMfield = new G4Uni<strong>for</strong>mElectricField(G4ThreeVector(0.0,100000.0*kilovolt/cm,0.0));// Create an equation of motion <strong>for</strong> this fieldfEquation = new G4EqMagElectricField(fEMfield);G4int nvar = 8;fStepper = new G4ClassicalRK4( fEquation, nvar );// Get the global field managerfFieldManager= G4TransportationManager::GetTransportationManager()->GetFieldManager();// Set this field to the global field managerfFieldManager->SetDetectorField(fEMfield );fMinStep= 0.010*mm ; // minimal step of 10 micronsfIntgrDriver = new G4MagInt_Driver(fMinStep,fStepper,fStepper->GetNumberOfVariables() );fChordFinder = new G4ChordFinder(fIntgrDriver);fFieldManager->SetChordFinder( fChordFinder );}120

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!