CMS 3D CMS Logo

FieldBuilder.cc
Go to the documentation of this file.
3 
5 
11 
12 #include <CLHEP/Units/SystemOfUnits.h>
13 #include "G4ChordFinder.hh"
14 #include "G4ClassicalRK4.hh"
15 #include "G4FieldManager.hh"
16 #include "G4LogicalVolumeStore.hh"
17 #include "G4Mag_UsualEqRhs.hh"
18 #include "G4TMagFieldEquation.hh"
19 #include "CMSTMagFieldEquation.h"
20 #include "G4PropagatorInField.hh"
21 
22 using namespace sim;
23 
24 FieldBuilder::FieldBuilder(const MagneticField *f, const edm::ParameterSet &p) : theTopVolume(nullptr), thePSet(p) {
25  theDelta = p.getParameter<double>("delta") * CLHEP::mm;
26  theField = new Field(f, theDelta);
27  theFieldEquation = nullptr;
28 }
29 
31 
32 void FieldBuilder::build(CMSFieldManager *fM, G4PropagatorInField *fP) {
33  edm::ParameterSet thePSetForGMFM = thePSet.getParameter<edm::ParameterSet>("ConfGlobalMFM");
34  std::string volName = thePSetForGMFM.getParameter<std::string>("Volume");
35  edm::ParameterSet volPSet = thePSetForGMFM.getParameter<edm::ParameterSet>(volName);
36 
37  configureForVolume(volName, volPSet, fM, fP);
38 
39  edm::LogVerbatim("SimG4CoreMagneticField") << " FieldBuilder::build: Global magnetic field is used";
40 }
41 
43  edm::ParameterSet &volPSet,
44  CMSFieldManager *fM,
45  G4PropagatorInField *fP) {
46  G4LogicalVolumeStore *theStore = G4LogicalVolumeStore::GetInstance();
47  for (auto vol : *theStore) {
48  if ((std::string)vol->GetName() == volName) {
49  theTopVolume = vol;
50  break;
51  }
52  }
53 
54  std::string fieldType = volPSet.getParameter<std::string>("Type");
55  std::string stepper = volPSet.getParameter<std::string>("Stepper");
56 
57  edm::ParameterSet stpPSet = volPSet.getParameter<edm::ParameterSet>("StepperParam");
58  double minStep = stpPSet.getParameter<double>("MinStep") * CLHEP::mm;
59 
60  if (stepper == "CMSTDormandPrince45") {
62  } else if (stepper == "G4TDormandPrince45") {
63  theFieldEquation = new G4TMagFieldEquation<sim::Field>(theField);
64  } else {
65  theFieldEquation = new G4Mag_UsualEqRhs(theField);
66  }
67 
68  FieldStepper *dStepper = new FieldStepper(theFieldEquation, theDelta, stepper);
69  G4ChordFinder *cf = new G4ChordFinder(theField, minStep, dStepper);
70 
71  MonopoleEquation *monopoleEquation = new MonopoleEquation(theField);
72  G4MagIntegratorStepper *mStepper = new G4ClassicalRK4(monopoleEquation, 8);
73  G4ChordFinder *cfmon = new G4ChordFinder(theField, minStep, mStepper);
74 
75  fM->InitialiseForVolume(stpPSet, theField, cf, cfmon, volName, fieldType, stepper, theDelta, fP);
76 }
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
G4LogicalVolume * theTopVolume
Definition: FieldBuilder.h:31
double f[11][100]
FieldBuilder(const MagneticField *, const edm::ParameterSet &)
Definition: FieldBuilder.cc:24
void build(CMSFieldManager *fM, G4PropagatorInField *fP)
Definition: FieldBuilder.cc:32
G4Mag_UsualEqRhs * theFieldEquation
Definition: FieldBuilder.h:30
void InitialiseForVolume(const edm::ParameterSet &, sim::Field *, G4ChordFinder *cfDefault, G4ChordFinder *cfMonopole, const std::string &vol, const std::string &fieldType, const std::string &stepperName, double delta, G4PropagatorInField *)
edm::ParameterSet thePSet
Definition: FieldBuilder.h:32
void configureForVolume(const std::string &volName, edm::ParameterSet &volPSet, CMSFieldManager *fM, G4PropagatorInField *fP)
Definition: FieldBuilder.cc:42