CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
sim::FieldBuilder Class Reference

#include <FieldBuilder.h>

Public Member Functions

void build (G4FieldManager *fM=nullptr, G4PropagatorInField *fP=nullptr, ChordFinderSetter *setter=nullptr)
 
void configureForVolume (const std::string &volName, edm::ParameterSet &volPSet, G4FieldManager *fM=nullptr, G4PropagatorInField *fP=nullptr, ChordFinderSetter *setter=nullptr)
 
 FieldBuilder (const MagneticField *, const edm::ParameterSet &)
 
G4LogicalVolume * fieldTopVolume ()
 

Private Member Functions

void configureFieldManager (G4FieldManager *fM, ChordFinderSetter *setter)
 
void configurePropagatorInField (G4PropagatorInField *fP)
 

Private Attributes

double dChord
 
double delta
 
double dIntersection
 
double dIntersectionAndOneStep
 
double dOneStep
 
std::string fieldType
 
double fieldValue
 
std::string keywordField
 
double maxEpsilonStep
 
double maxLoopCount
 
double minEpsilonStep
 
double minStep
 
std::string stepper
 
std::auto_ptr< FieldtheField
 
G4Mag_UsualEqRhs * theFieldEquation
 
edm::ParameterSet thePSet
 
G4LogicalVolume * theTopVolume
 

Detailed Description

Definition at line 19 of file FieldBuilder.h.

Constructor & Destructor Documentation

FieldBuilder::FieldBuilder ( const MagneticField f,
const edm::ParameterSet p 
)

Definition at line 34 of file FieldBuilder.cc.

References delta, edm::ParameterSet::getParameter(), theField, and theFieldEquation.

36  : theField(new Field(f, p.getParameter<double>("delta"))),
37  theFieldEquation(new G4Mag_UsualEqRhs(theField.get())),
38  theTopVolume(0),
39  fieldValue(0.), minStep(0.), dChord(0.), dOneStep(0.),
42  thePSet(p)
43 {
44  delta = p.getParameter<double>("delta");
45  theField->fieldEquation(theFieldEquation);
46 }
T getParameter(std::string const &) const
G4LogicalVolume * theTopVolume
Definition: FieldBuilder.h:50
double dIntersectionAndOneStep
Definition: FieldBuilder.h:60
std::auto_ptr< Field > theField
Definition: FieldBuilder.h:48
G4Mag_UsualEqRhs * theFieldEquation
Definition: FieldBuilder.h:49
edm::ParameterSet thePSet
Definition: FieldBuilder.h:65

Member Function Documentation

void FieldBuilder::build ( G4FieldManager *  fM = nullptr,
G4PropagatorInField *  fP = nullptr,
ChordFinderSetter setter = nullptr 
)

Definition at line 48 of file FieldBuilder.cc.

References configureForVolume(), gather_cfg::cout, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), i, reco::return(), sim::LocalFieldManager::SetVerbosity(), AlCaHLTBitMon_QueryRunRegistry::string, theField, thePSet, and theTopVolume.

Referenced by RunManager::initG4(), and RunManagerMT::initG4().

49 {
50  edm::ParameterSet thePSetForGMFM =
51  thePSet.getParameter<edm::ParameterSet>("ConfGlobalMFM");
52 
53  std::string volName = thePSetForGMFM.getParameter< std::string >("Volume");
54 
55  edm::ParameterSet volPSet =
56  thePSetForGMFM.getParameter< edm::ParameterSet >( volName );
57 
58  configureForVolume( volName, volPSet, fM, fP, setter );
59 
60  // configure( "MagneticFieldType", fM, fP ) ;
61 
62  if ( thePSet.getParameter<bool>("UseLocalMagFieldManager") ) {
63 
64  edm::LogInfo("SimG4CoreApplication")
65  << " FieldBuilder: Local magnetic field is used";
66 
67  edm::ParameterSet defpset ;
68  edm::ParameterSet thePSetForLMFM =
69  thePSet.getUntrackedParameter<edm::ParameterSet>("ConfLocalMFM", defpset);
70  //
71  // Patology !!! LocalFM requested but configuration not given !
72  // In principal, need to throw an exception
73  //
74  if ( thePSetForLMFM == defpset ) {
75  std::cout << " Patology ! Local Mag.Field Manager requested but config not given !\n";
76  return ;
77  }
78 
79  std::vector<std::string> ListOfVolumes =
80  thePSetForLMFM.getParameter< std::vector<std::string> >("ListOfVolumes");
81 
82  // creating Local Mag.Field Manager
83  for (unsigned int i = 0; i < ListOfVolumes.size(); ++ i ) {
84  volPSet = thePSetForLMFM.getParameter< edm::ParameterSet >(ListOfVolumes[i]);
85  G4FieldManager* fAltM = new G4FieldManager() ;
86  configureForVolume( ListOfVolumes[i], volPSet, fAltM, nullptr, setter ) ;
87  //configureLocalFM( ListOfVolumes[i], fAltM ) ;
88  LocalFieldManager* fLM = new LocalFieldManager( theField.get(), fM, fAltM ) ;
89  fLM->SetVerbosity(thePSet.getUntrackedParameter<bool>("Verbosity",false));
90  theTopVolume->SetFieldManager( fLM, true ) ;
91  }
92  } else {
93  edm::LogInfo("SimG4CoreApplication")
94  << " FieldBuilder: Global magnetic field is used";
95  }
96 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void configureForVolume(const std::string &volName, edm::ParameterSet &volPSet, G4FieldManager *fM=nullptr, G4PropagatorInField *fP=nullptr, ChordFinderSetter *setter=nullptr)
Definition: FieldBuilder.cc:98
G4LogicalVolume * theTopVolume
Definition: FieldBuilder.h:50
std::auto_ptr< Field > theField
Definition: FieldBuilder.h:48
return(e1-e2)*(e1-e2)+dp *dp
tuple cout
Definition: gather_cfg.py:145
edm::ParameterSet thePSet
Definition: FieldBuilder.h:65
void FieldBuilder::configureFieldManager ( G4FieldManager *  fM,
ChordFinderSetter setter 
)
private

Definition at line 139 of file FieldBuilder.cc.

References dChord, delta, dIntersection, dIntersectionAndOneStep, dOneStep, sim::ChordFinderSetter::isMonopoleSet(), minStep, sim::FieldStepper::select(), sim::ChordFinderSetter::setMonopole(), stepper, and theField.

Referenced by configureForVolume().

139  {
140 
141  if (fM!=0) {
142  fM->SetDetectorField(theField.get());
143  FieldStepper * theStepper =
144  new FieldStepper(theField->fieldEquation(), delta);
145  theStepper->select(stepper);
146  G4ChordFinder * CF = new G4ChordFinder(theField.get(),minStep,theStepper);
147  CF->SetDeltaChord(dChord);
148  fM->SetChordFinder(CF);
149  fM->SetDeltaOneStep(dOneStep);
150  fM->SetDeltaIntersection(dIntersection);
151  if (dIntersectionAndOneStep != -1.)
152  fM->SetAccuraciesWithDeltaOneStep(dIntersectionAndOneStep);
153  }
154  if(setter && !setter->isMonopoleSet()) {
155  G4MonopoleEquation* fMonopoleEquation =
156  new G4MonopoleEquation(theField.get());
157  G4MagIntegratorStepper* theStepper =
158  new G4ClassicalRK4(fMonopoleEquation,8);
159  G4ChordFinder *chordFinderMonopole =
160  new G4ChordFinder(theField.get(),minStep,theStepper);
161  chordFinderMonopole->SetDeltaChord(dChord);
162  setter->setMonopole(chordFinderMonopole);
163  }
164 }
double dIntersectionAndOneStep
Definition: FieldBuilder.h:60
std::auto_ptr< Field > theField
Definition: FieldBuilder.h:48
std::string stepper
Definition: FieldBuilder.h:55
void FieldBuilder::configureForVolume ( const std::string &  volName,
edm::ParameterSet volPSet,
G4FieldManager *  fM = nullptr,
G4PropagatorInField *  fP = nullptr,
ChordFinderSetter setter = nullptr 
)

Definition at line 98 of file FieldBuilder.cc.

References configureFieldManager(), configurePropagatorInField(), dChord, delta, dIntersection, dIntersectionAndOneStep, dOneStep, fieldType, edm::ParameterSet::getParameter(), i, maxEpsilonStep, maxLoopCount, minEpsilonStep, minStep, stepper, AlCaHLTBitMon_QueryRunRegistry::string, and theTopVolume.

Referenced by build().

103 {
104  G4LogicalVolumeStore* theStore = G4LogicalVolumeStore::GetInstance();
105  for (unsigned int i=0; i<(*theStore).size(); ++i ) {
106  std::string curVolName = ((*theStore)[i])->GetName();
107  if ( curVolName == volName ) {
108  theTopVolume = (*theStore)[i] ;
109  }
110  }
111 
112  fieldType = volPSet.getParameter<std::string>("Type") ;
113  stepper = volPSet.getParameter<std::string>("Stepper") ;
114  edm::ParameterSet stpPSet =
115  volPSet.getParameter<edm::ParameterSet>("StepperParam") ;
116  minStep = stpPSet.getParameter<double>("MinStep") ;
117  dChord = stpPSet.getParameter<double>("DeltaChord") ;
118  dOneStep = stpPSet.getParameter<double>("DeltaOneStep") ;
119  dIntersection = stpPSet.getParameter<double>("DeltaIntersection") ;
121  stpPSet.getUntrackedParameter<double>("DeltaIntersectionAndOneStep",-1.);
122  maxLoopCount =
123  stpPSet.getUntrackedParameter<double>("MaximumLoopCounts",1000);
124  minEpsilonStep =
125  stpPSet.getUntrackedParameter<double>("MinimumEpsilonStep",0.00001);
126  maxEpsilonStep =
127  stpPSet.getUntrackedParameter<double>("MaximumEpsilonStep",0.01);
128 
129  if (fM!=0) configureFieldManager(fM, setter);
130  if (fP!=0) configurePropagatorInField(fP);
131 
132  edm::LogInfo("SimG4CoreApplication")
133  << " FieldBuilder: Selected stepper: <" << stepper
134  << "> const field delta(mm)= " << delta;
135 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::string fieldType
Definition: FieldBuilder.h:53
void configureFieldManager(G4FieldManager *fM, ChordFinderSetter *setter)
G4LogicalVolume * theTopVolume
Definition: FieldBuilder.h:50
double dIntersectionAndOneStep
Definition: FieldBuilder.h:60
std::string stepper
Definition: FieldBuilder.h:55
void configurePropagatorInField(G4PropagatorInField *fP)
void FieldBuilder::configurePropagatorInField ( G4PropagatorInField *  fP)
private

Definition at line 166 of file FieldBuilder.cc.

References maxEpsilonStep, maxLoopCount, and minEpsilonStep.

Referenced by configureForVolume().

166  {
167  if(fP!=0) {
168  fP->SetMaxLoopCount(int(maxLoopCount));
169  fP->SetMinimumEpsilonStep(minEpsilonStep);
170  fP->SetMaximumEpsilonStep(maxEpsilonStep);
171  fP->SetVerboseLevel(0);
172  }
173 }
G4LogicalVolume * FieldBuilder::fieldTopVolume ( )

Definition at line 137 of file FieldBuilder.cc.

References theTopVolume.

137 { return theTopVolume; }
G4LogicalVolume * theTopVolume
Definition: FieldBuilder.h:50

Member Data Documentation

double sim::FieldBuilder::dChord
private

Definition at line 57 of file FieldBuilder.h.

Referenced by configureFieldManager(), and configureForVolume().

double sim::FieldBuilder::delta
private

Definition at line 64 of file FieldBuilder.h.

Referenced by configureFieldManager(), configureForVolume(), and FieldBuilder().

double sim::FieldBuilder::dIntersection
private

Definition at line 59 of file FieldBuilder.h.

Referenced by configureFieldManager(), and configureForVolume().

double sim::FieldBuilder::dIntersectionAndOneStep
private

Definition at line 60 of file FieldBuilder.h.

Referenced by configureFieldManager(), and configureForVolume().

double sim::FieldBuilder::dOneStep
private

Definition at line 58 of file FieldBuilder.h.

Referenced by configureFieldManager(), and configureForVolume().

std::string sim::FieldBuilder::fieldType
private

Definition at line 53 of file FieldBuilder.h.

Referenced by configureForVolume().

double sim::FieldBuilder::fieldValue
private

Definition at line 54 of file FieldBuilder.h.

std::string sim::FieldBuilder::keywordField
private

Definition at line 52 of file FieldBuilder.h.

double sim::FieldBuilder::maxEpsilonStep
private

Definition at line 63 of file FieldBuilder.h.

Referenced by configureForVolume(), and configurePropagatorInField().

double sim::FieldBuilder::maxLoopCount
private

Definition at line 61 of file FieldBuilder.h.

Referenced by configureForVolume(), and configurePropagatorInField().

double sim::FieldBuilder::minEpsilonStep
private

Definition at line 62 of file FieldBuilder.h.

Referenced by configureForVolume(), and configurePropagatorInField().

double sim::FieldBuilder::minStep
private

Definition at line 56 of file FieldBuilder.h.

Referenced by configureFieldManager(), and configureForVolume().

std::string sim::FieldBuilder::stepper
private

Definition at line 55 of file FieldBuilder.h.

Referenced by configureFieldManager(), and configureForVolume().

std::auto_ptr<Field> sim::FieldBuilder::theField
private

Definition at line 48 of file FieldBuilder.h.

Referenced by build(), configureFieldManager(), and FieldBuilder().

G4Mag_UsualEqRhs* sim::FieldBuilder::theFieldEquation
private

Definition at line 49 of file FieldBuilder.h.

Referenced by FieldBuilder().

edm::ParameterSet sim::FieldBuilder::thePSet
private

Definition at line 65 of file FieldBuilder.h.

Referenced by build().

G4LogicalVolume* sim::FieldBuilder::theTopVolume
private

Definition at line 50 of file FieldBuilder.h.

Referenced by build(), configureForVolume(), and fieldTopVolume().