20 using namespace DD4hep::Geometry;
29 void calculate_combined_field(vector<CartesianField>&
v,
const double* pos,
double* field) {
30 for (vector<CartesianField>::iterator i = v.begin(); i != v.end(); ++i)
31 (*i).value(pos, field);
36 CartesianField::Object::Object()
48 return m_element->GetTitle();
63 value(pos,(
double*)&field);
68 value((
double*)&pos,val);
73 data<Object>()->fieldComponents(pos, val);
78 :
type(0), electric(), magnetic() {
90 assign(
new Object(), nam,
"overlay_field");
100 int field = data<Object>()->
type;
106 if (field.isValid()) {
107 Object* o = data<Object>();
126 throw runtime_error(
"OverlayedField::add: Attempt to add an unknown field type.");
128 throw runtime_error(
"OverlayedField::add: Attempt to add to an invalid object.");
130 throw runtime_error(
"OverlayedField::add: Attempt to add an invalid field.");
135 field[0] = field[1] = field[2] = 0.;
136 calculate_combined_field(data<Object>()->electric_components, pos, field);
141 field[0] = field[1] = field[2] = 0.;
142 calculate_combined_field(data<Object>()->magnetic_components, pos, field);
147 Object* o = data<Object>();
148 field[0] = field[1] = field[2] = 0.;
DD4hep::Geometry::CartesianField electric
Properties & properties() const
Access to properties container.
Internal data class shared by all handles of a given type.
bool changesEnergy() const
Does the field change the energy of charged particles?
void combinedMagnetic(const Position &pos, double *field) const
Returns the 3 magnetic field components (x, y, z) if many components are present. ...
Object()
Default constructor.
int fieldType() const
Access the field type.
Internal data class shared by all handles.
void add(CartesianField field)
Add a new field component.
std::map< std::string, PropertyValues > Properties
static void decrement(T *)
Decrement count according to type information.
std::map< std::string, PropertyValues > Properties
std::vector< DD4hep::Geometry::CartesianField > electric_components
const char * type() const
Access the field type (string)
Implementation of a named object.
OverlayedField::Object OverlayedFieldObject
bool changesEnergy() const
Does the field change the energy of charged particles?
std::vector< DD4hep::Geometry::CartesianField > magnetic_components
void electromagneticField(const Position &pos, double *val) const
Returns the 3 electric (val[0]-val[2]) and magnetic field components (val[3]-val[5]).
OverlayedField()=default
Default constructor.
int type() const
Access the field type.
ROOT::Math::XYZVector Position
Handle< NamedObject > Ref_t
Default Ref_t definition describing named objects.
static void increment(T *)
Increment count according to type information.
virtual ~Object()
Default destructor.
Properties & properties() const
Access to properties container.
virtual ~Object()
Default destructor.
Handle class describing any field with 3D cartesian vectors for the field strength.
void combinedElectric(const Position &pos, double *field) const
Returns the 3 electric field components (x, y, z) if many components are present. ...
CartesianField::Object CartesianFieldObject
DD4hep::Geometry::CartesianField magnetic
DD4HEP_INSTANTIATE_HANDLE(CartesianFieldObject)
void value(const Position &pos, Direction &field) const
Returns the 3 field components (x, y, z).