CMS 3D CMS Logo

FieldBuilder.cc
Go to the documentation of this file.
3 
6 
12 
13 #include "G4Mag_UsualEqRhs.hh"
14 #include "G4ClassicalRK4.hh"
15 #include "G4PropagatorInField.hh"
16 #include "G4FieldManager.hh"
17 #include "G4TransportationManager.hh"
18 #include "G4ChordFinder.hh"
19 #include "G4UniformMagField.hh"
20 #include "G4LogicalVolumeStore.hh"
21 #include "CLHEP/Units/GlobalSystemOfUnits.h"
22 
23 using namespace sim;
24 
26  : theTopVolume(nullptr),thePSet(p)
27 {
28  delta = p.getParameter<double>("delta")*CLHEP::mm;
29  theField = new Field(f, delta);
30  theFieldEquation = new G4Mag_UsualEqRhs(theField);
31 }
32 
34 {}
35 
36 void FieldBuilder::build( CMSFieldManager* fM, G4PropagatorInField* fP)
37 {
38  edm::ParameterSet thePSetForGMFM =
39  thePSet.getParameter<edm::ParameterSet>("ConfGlobalMFM");
40 
41  std::string volName = thePSetForGMFM.getParameter< std::string >("Volume");
42 
43  edm::ParameterSet volPSet =
44  thePSetForGMFM.getParameter< edm::ParameterSet >( volName );
45 
46  configureForVolume( volName, volPSet, fM, fP);
47 
48  edm::LogVerbatim("SimG4CoreMagneticField")
49  << " FieldBuilder::build: Global magnetic field is used";
50 }
51 
53  edm::ParameterSet& volPSet,
54  CMSFieldManager * fM,
55  G4PropagatorInField * fP)
56 {
57  G4LogicalVolumeStore* theStore = G4LogicalVolumeStore::GetInstance();
58  for (auto vol : *theStore) {
59  if ( (std::string)vol->GetName() == volName ) {
60  theTopVolume = vol;
61  break;
62  }
63  }
64 
65  std::string fieldType = volPSet.getParameter<std::string>("Type");
66  std::string stepper = volPSet.getParameter<std::string>("Stepper");
67 
68  edm::ParameterSet stpPSet = volPSet.getParameter<edm::ParameterSet>("StepperParam");
69  double minStep = stpPSet.getParameter<double>("MinStep") ;
70  int maxLoopCount =
71  (int)stpPSet.getUntrackedParameter<double>("MaximumLoopCounts",1000);
72  double minEpsilonStep =
73  stpPSet.getUntrackedParameter<double>("MinimumEpsilonStep",0.00001);
74  double maxEpsilonStep =
75  stpPSet.getUntrackedParameter<double>("MaximumEpsilonStep",0.01);
76 
77  FieldStepper * theStepper = new FieldStepper(theFieldEquation, delta);
78  theStepper->select(stepper);
79  G4ChordFinder * cf = new G4ChordFinder(theField,minStep,theStepper);
80 
81  MonopoleEquation* monopoleEquation = new MonopoleEquation(theField);
82  G4MagIntegratorStepper* theStepperMon = new G4ClassicalRK4(monopoleEquation,8);
83  G4ChordFinder * cfmon = new G4ChordFinder(theField,minStep,theStepperMon);
84 
85  fM->InitialiseForVolume(stpPSet, theField, cf, cfmon, volName,
86  fieldType, stepper, delta, minStep);
87 
88  if(fP) {
89  fP->SetMaxLoopCount(maxLoopCount);
90  fP->SetMinimumEpsilonStep(minEpsilonStep);
91  fP->SetMaximumEpsilonStep(maxEpsilonStep);
92  //fP->SetVerboseLevel(0);
93  }
94 }
T getParameter(std::string const &) const
void InitialiseForVolume(const edm::ParameterSet &, sim::Field *, G4ChordFinder *, G4ChordFinder *, const std::string &vol, const std::string &type, const std::string &stepper, double delta, double minstep)
#define nullptr
G4LogicalVolume * theTopVolume
Definition: FieldBuilder.h:34
double f[11][100]
FieldBuilder(const MagneticField *, const edm::ParameterSet &)
Definition: FieldBuilder.cc:25
void build(CMSFieldManager *fM, G4PropagatorInField *fP)
Definition: FieldBuilder.cc:36
Definition: RunManager.h:28
G4MagIntegratorStepper * select(const std::string &s)
Definition: FieldStepper.cc:35
G4Mag_UsualEqRhs * theFieldEquation
Definition: FieldBuilder.h:33
edm::ParameterSet thePSet
Definition: FieldBuilder.h:35
void configureForVolume(const std::string &volName, edm::ParameterSet &volPSet, CMSFieldManager *fM, G4PropagatorInField *fP)
Definition: FieldBuilder.cc:52