Belle II Software  release-08-01-10
G4MonopoleFieldSetup.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 // modified from GEANT4 exoticphysics/monopole/*
10 
11 #include <simulation/monopoles/G4MonopoleFieldSetup.h>
12 #include <simulation/monopoles/G4MonopoleEquation.h>
13 
14 #include <G4MagneticField.hh>
15 #include <G4FieldManager.hh>
16 #include <G4TransportationManager.hh>
17 #include <G4MagIntegratorStepper.hh>
18 #include <G4ChordFinder.hh>
19 
20 #include <G4ClassicalRK4.hh>
21 
22 #include <CLHEP/Units/SystemOfUnits.h>
23 
24 using namespace std;
25 using namespace Belle2;
26 using namespace Belle2::Monopoles;
27 using namespace CLHEP;
28 
29 G4MonopoleFieldSetup* G4MonopoleFieldSetup::fMonopoleFieldSetup = 0;
30 
31 G4MonopoleFieldSetup::G4MonopoleFieldSetup()
32 {
33  //Take existing setup from basf2
34  fFieldManager = G4TransportationManager::GetTransportationManager()->GetFieldManager();
35  fbasf2ChordFinder = fFieldManager->GetChordFinder();
36  fMagneticField = (G4MagneticField*)fFieldManager->GetDetectorField();
37  fMonopoleEquation = new G4MonopoleEquation(fMagneticField);
38  fMinStep = 0.01 * mm ; // minimal step of 1 mm is default
39  fMonopoleStepper = new G4ClassicalRK4(fMonopoleEquation, 8); // for time information..
40  fMonopoleChordFinder = new G4ChordFinder(fMagneticField, fMinStep, fMonopoleStepper);
41 }
42 
43 G4MonopoleFieldSetup* G4MonopoleFieldSetup::GetMonopoleFieldSetup()
44 {
45  if (0 == fMonopoleFieldSetup) {
46  static G4MonopoleFieldSetup theInstance;
47  fMonopoleFieldSetup = &theInstance;
48  }
49 
50  return fMonopoleFieldSetup;
51 }
52 
53 G4MonopoleFieldSetup::~G4MonopoleFieldSetup()
54 {
55  if (fMonopoleChordFinder) delete fMonopoleChordFinder;
56  if (fMonopoleEquation) delete fMonopoleEquation;
57  if (fMonopoleStepper) delete fMonopoleStepper;
58 }
59 
60 void G4MonopoleFieldSetup::SwitchChordFinder(G4int val)
61 {
62  switch (val) {
63  case 0:
64  fFieldManager->SetChordFinder(fbasf2ChordFinder);
65  break;
66  case 1:
67  fFieldManager->SetChordFinder(fMonopoleChordFinder);
68  break;
69  }
70 }
Monopole equation of motion class.
Monopole field setup singleton class, that takes care of switching between conventional particle tran...
Abstract base class for different kinds of events.