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=0, G4PropagatorInField *fP=0)
 
void configureForVolume (const std::string &volName, edm::ParameterSet &volPSet, G4FieldManager *fM=0, G4PropagatorInField *fP=0)
 
 FieldBuilder (const MagneticField *, const edm::ParameterSet &)
 
G4LogicalVolume * fieldTopVolume ()
 
void setStepperAndChordFinder (G4FieldManager *fM, int val)
 

Private Member Functions

void configureFieldManager (G4FieldManager *fM)
 
void configurePropagatorInField (G4PropagatorInField *fP)
 

Private Attributes

double dChord
 
double delta
 
double dIntersection
 
double dIntersectionAndOneStep
 
double dOneStep
 
G4ChordFinder * fChordFinder
 
G4ChordFinder * fChordFinderMonopole
 
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 33 of file FieldBuilder.cc.

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

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

Member Function Documentation

void FieldBuilder::build ( G4FieldManager *  fM = 0,
G4PropagatorInField *  fP = 0 
)

Definition at line 47 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().

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

Definition at line 149 of file FieldBuilder.cc.

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

Referenced by configureForVolume().

149  {
150 
151  if (fM!=0) {
152  fM->SetDetectorField(theField.get());
153  FieldStepper * theStepper =
154  new FieldStepper(theField->fieldEquation(), delta);
155  theStepper->select(stepper);
156  G4ChordFinder * CF = new G4ChordFinder(theField.get(),minStep,theStepper);
157  CF->SetDeltaChord(dChord);
158  fM->SetChordFinder(CF);
159  fM->SetDeltaOneStep(dOneStep);
160  fM->SetDeltaIntersection(dIntersection);
161  if (dIntersectionAndOneStep != -1.)
162  fM->SetAccuraciesWithDeltaOneStep(dIntersectionAndOneStep);
163  }
164  if (fChordFinderMonopole == 0) {
165  G4MonopoleEquation* fMonopoleEquation =
166  new G4MonopoleEquation(theField.get());
167  G4MagIntegratorStepper* theStepper =
168  new G4ClassicalRK4(fMonopoleEquation,8);
170  new G4ChordFinder(theField.get(),minStep,theStepper);
171  fChordFinderMonopole->SetDeltaChord(dChord);
172  }
173 }
G4ChordFinder * fChordFinderMonopole
Definition: FieldBuilder.h:50
double dIntersectionAndOneStep
Definition: FieldBuilder.h:60
std::auto_ptr< Field > theField
Definition: FieldBuilder.h:47
std::string stepper
Definition: FieldBuilder.h:55
void FieldBuilder::configureForVolume ( const std::string &  volName,
edm::ParameterSet volPSet,
G4FieldManager *  fM = 0,
G4PropagatorInField *  fP = 0 
)

Definition at line 97 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().

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

Definition at line 175 of file FieldBuilder.cc.

References maxEpsilonStep, maxLoopCount, and minEpsilonStep.

Referenced by configureForVolume().

175  {
176  if(fP!=0) {
177  fP->SetMaxLoopCount(int(maxLoopCount));
178  fP->SetMinimumEpsilonStep(minEpsilonStep);
179  fP->SetMaximumEpsilonStep(maxEpsilonStep);
180  fP->SetVerboseLevel(0);
181  }
182 }
G4LogicalVolume * FieldBuilder::fieldTopVolume ( )

Definition at line 135 of file FieldBuilder.cc.

References theTopVolume.

135 { return theTopVolume; }
G4LogicalVolume * theTopVolume
Definition: FieldBuilder.h:49
void FieldBuilder::setStepperAndChordFinder ( G4FieldManager *  fM,
int  val 
)

Definition at line 137 of file FieldBuilder.cc.

References fChordFinder, and fChordFinderMonopole.

137  {
138 
139  if (fM != 0) {
140  if (val == 0) {
141  if (fChordFinder != 0) fM->SetChordFinder(fChordFinder);
142  } else {
143  fChordFinder = fM->GetChordFinder();
144  if (fChordFinderMonopole != 0) fM->SetChordFinder(fChordFinderMonopole);
145  }
146  }
147 }
G4ChordFinder * fChordFinder
Definition: FieldBuilder.h:50
G4ChordFinder * fChordFinderMonopole
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().

G4ChordFinder* sim::FieldBuilder::fChordFinder
private

Definition at line 50 of file FieldBuilder.h.

Referenced by setStepperAndChordFinder().

G4ChordFinder * sim::FieldBuilder::fChordFinderMonopole
private

Definition at line 50 of file FieldBuilder.h.

Referenced by configureFieldManager(), and setStepperAndChordFinder().

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 47 of file FieldBuilder.h.

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

G4Mag_UsualEqRhs* sim::FieldBuilder::theFieldEquation
private

Definition at line 48 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 49 of file FieldBuilder.h.

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