2 added + 9 modified, total 11 files
lcdd/include
diff -N MagneticFieldOverlay.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MagneticFieldOverlay.hh 21 Apr 2006 23:51:26 -0000 1.1
@@ -0,0 +1,32 @@
+// $Header: /cvs/lcd/lcdd/include/MagneticFieldOverlay.hh,v 1.1 2006/04/21 23:51:26 jeremy Exp $
+#ifndef MagneticFieldOverlay_hh
+#define MagneticFieldOverlay_hh 1
+
+#include "G4MagneticField.hh"
+
+#include <vector>
+
+/**
+ * @class MagneticFieldOverlay
+ * @brief Overlay multiple G4MagneticField objects by calling all their GetFieldValue functions.
+ */
+class MagneticFieldOverlay : public G4MagneticField
+{
+public:
+
+ MagneticFieldOverlay();
+ virtual ~MagneticFieldOverlay();
+
+public:
+
+ /** Add a G4MagneticField to the fields vector. */
+ void addMagneticField(G4MagneticField* field);
+
+ /** Call GetFieldValue of each field in fields. */
+ void GetFieldValue( const double Point[3], double *Bfield ) const;
+
+private:
+ std::vector<G4MagneticField*> m_fields;
+};
+
+#endif
lcdd/include
diff -u -r1.18 -r1.19
--- LCDDProcessor.hh 9 Dec 2005 01:56:42 -0000 1.18
+++ LCDDProcessor.hh 21 Apr 2006 23:51:26 -0000 1.19
@@ -41,23 +41,11 @@
public:
// header
- const LCDDHeaderRecord* getHeader()
- {
- return m_header;
- }
-
- void setHeader(LCDDHeaderRecord* h)
- {
- assert( h );
- m_header = h;
- }
-
- std::string getDetectorName()
- {
- assert( m_header );
- std::string detTag = m_header->getDetectorName();
- return detTag;
- }
+ const LCDDHeaderRecord* getHeader() const;
+ void setHeader(LCDDHeaderRecord* h);
+
+ // detector name
+ std::string getDetectorName() const;
// Sensitive Detectors
void addSensitiveDetector(std::string& name, G4SensitiveDetector* sd);
@@ -77,10 +65,18 @@
LCDDProcessor::MagneticFields::const_iterator getMagneticFieldsBegin();
LCDDProcessor::MagneticFields::const_iterator getMagneticFieldsEnd();
+ // DEPRECATED
void setGlobalMagneticField(G4MagneticField *mag);
+
+ // DEPRECATED
void setGlobalMagneticField( const std::string& name);
+
+ // DEPRECATED
void setGlobalMagneticField( const char* name);
+ // Setup the global overlay field.
+ void setupGlobalMagneticField();
+
// Regions
void addRegion(std::string& name, G4Region* reg);
@@ -106,30 +102,11 @@
LCDDProcessor::VisAttributes::const_iterator getVisAttributesBegin();
LCDDProcessor::VisAttributes::const_iterator getVisAttributesEnd();
- const LCDDProcessor::VisAttributes* getVisAttributesStore() const
- {
- return &m_visAttributes;
- }
-
- const LCDDProcessor::SensitiveDetectors* getSensitiveDetectorStore() const
- {
- return &m_sensitiveDetectors;
- }
-
- const LCDDProcessor::MagneticFields* getMagneticFieldStore() const
- {
- return &m_magneticFields;
- }
-
- const LCDDProcessor::Regions* getRegionStore() const
- {
- return &m_regions;
- }
-
- const LCDDProcessor::LimitSets* getLimitSetStore() const
- {
- return &m_limitSets;
- }
+ const LCDDProcessor::VisAttributes* getVisAttributesStore() const;
+ const LCDDProcessor::SensitiveDetectors* getSensitiveDetectorStore() const;
+ const LCDDProcessor::MagneticFields* getMagneticFieldStore() const;
+ const LCDDProcessor::Regions* getRegionStore() const;
+ const LCDDProcessor::LimitSets* getLimitSetStore() const;
private:
lcdd/include
diff -u -r1.1 -r1.2
--- idfieldElem.hh 4 Mar 2005 22:51:04 -0000 1.1
+++ idfieldElem.hh 21 Apr 2006 23:51:26 -0000 1.2
@@ -1,6 +1,6 @@
-// $Header: /cvs/lcd/lcdd/include/idfieldElem.hh,v 1.1 2005/03/04 22:51:04 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/idfieldElem.hh,v 1.2 2006/04/21 23:51:26 jeremy Exp $
#ifndef idfieldElem_hh
-#define idfieldElem_hh
+#define idfieldElem_hh 1
#include "Saxana/SAXObject.h"
lcdd/schemas/lcdd/1.0
diff -u -r1.6 -r1.7
--- lcdd_fields.xsd 31 Aug 2005 20:33:43 -0000 1.6
+++ lcdd_fields.xsd 21 Apr 2006 23:51:27 -0000 1.7
@@ -15,10 +15,12 @@
<xs:sequence>
<!-- <xs:element name="field" minOccurs="0" maxOccurs="unbounded" type="FieldType" /> -->
<xs:element minOccurs="0" maxOccurs="1" ref="field" />
- <xs:element name="global_field" minOccurs="0" maxOccurs="1" type="GlobalFieldType" />
+ <!--<xs:element name="global_field" minOccurs="0" maxOccurs="1" type="GlobalFieldType" /> -->
</xs:sequence>
</xs:complexType>
+ <!--
+ DEPRECATED
<xs:complexType name="GlobalFieldType">
<xs:annotation>
<xs:documentation>
@@ -27,7 +29,8 @@
<xs:sequence>
<xs:element name="fieldref" minOccurs="1" maxOccurs="1" type="ReferenceType" />
</xs:sequence>
- </xs:complexType>
+ </xs:complexType>
+ -->
<xs:element name="fields" type="FieldsType">
</xs:element>
@@ -41,6 +44,30 @@
<xs:element name="field" type="FieldType">
</xs:element>
+ <xs:complexType name="DipoleType">
+ <xs:complexContent>
+ <xs:extension base="FieldType">
+ <xs:sequence>
+ <xs:element name="dipole_coeff" minOccurs="1" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="value" type="xs:double" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="zmin" type="xs:double" />
+ <xs:attribute name="zmax" type="xs:double" />
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <xs:element name="dipole" substitutionGroup="field" type="DipoleType">
+ <xs:annotation>
+ <xs:documentation>
+ Dipole field element.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+
<xs:complexType name="SolenoidType">
<xs:annotation>
<xs:documentation>
lcdd/src
diff -N MagneticFieldOverlay.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MagneticFieldOverlay.cc 21 Apr 2006 23:51:27 -0000 1.1
@@ -0,0 +1,33 @@
+// $Header: /cvs/lcd/lcdd/src/MagneticFieldOverlay.cc,v 1.1 2006/04/21 23:51:27 jeremy Exp $
+#include "MagneticFieldOverlay.hh"
+
+//#include <iostream>
+
+MagneticFieldOverlay::MagneticFieldOverlay()
+{}
+
+MagneticFieldOverlay::~MagneticFieldOverlay()
+{}
+
+void MagneticFieldOverlay::addMagneticField(G4MagneticField* field)
+{
+ if (field != 0) {
+ m_fields.push_back(field);
+ }
+}
+
+/**
+ * Call GetFieldValue of all G4MagneticField objects registered with this MagneticFieldOverlay.
+ */
+void MagneticFieldOverlay::GetFieldValue( const double Point[3], double *Bfield ) const
+{
+ Bfield[0] = Bfield[1] = Bfield[2] = 0.;
+ for(std::vector<G4MagneticField*>::const_iterator iter = m_fields.begin();
+ iter != m_fields.end();
+ iter++) {
+ (*iter)->GetFieldValue(Point, Bfield);
+ }
+
+ //std::cout << "x y z: " << Point[0] << " " << Point[1] << " " << Point[2] << std::endl;
+ //std::cout << "bx, by, bz: " << Bfield[0] << " " << Bfield[1] << " " << Bfield[2] << std::endl;
+}
lcdd/src
diff -u -r1.8 -r1.9
--- G4RZFieldMap.cc 1 Sep 2005 18:55:15 -0000 1.8
+++ G4RZFieldMap.cc 21 Apr 2006 23:51:27 -0000 1.9
@@ -1,10 +1,11 @@
-// $Header: /cvs/lcd/lcdd/src/G4RZFieldMap.cc,v 1.8 2005/09/01 18:55:15 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4RZFieldMap.cc,v 1.9 2006/04/21 23:51:27 jeremy Exp $
#include "G4RZFieldMap.hh"
#include "globals.hh"
#include <cmath>
+// Set this preprocessor symbol for lots of debugging output.
//#define FIELD_MAP_DEBUG 1
#ifdef FIELD_MAP_DEBUG
@@ -211,9 +212,9 @@
double hx = hr * cos(theta);
double hy = hr * sin(theta);
- Bfield[0] = hx;
- Bfield[1] = hy;
- Bfield[2] = hz;
+ Bfield[0] += hx;
+ Bfield[1] += hy;
+ Bfield[2] += hz;
#ifdef FIELD_MAP_DEBUG
cout << "Bfield XYZ = " << Bfield[0] << " " << Bfield[1] << " " << Bfield[2] << endl;
lcdd/src
diff -u -r1.4 -r1.5
--- G4Solenoid.cc 15 Feb 2005 17:59:17 -0000 1.4
+++ G4Solenoid.cc 21 Apr 2006 23:51:27 -0000 1.5
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4Solenoid.cc,v 1.4 2005/02/15 17:59:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4Solenoid.cc,v 1.5 2006/04/21 23:51:27 jeremy Exp $
#include "G4Solenoid.hh"
@@ -13,43 +13,25 @@
_outerR(0),
_innerZ(0),
_outerZ(0)
-{
- //G4cout << "tesla unit: " << tesla << G4endl;
-}
+{}
G4Solenoid::~G4Solenoid()
{}
-// BUG: inner/outer Z unused
+/**
+ * Apply simple solenoid magnetic field to the given Point.
+ */
+// TODO: use inner/outer Z
void G4Solenoid::GetFieldValue( const double Point[3], double* Bfield ) const
{
- // DEBUG
- //G4cout << "G4Solenoid::GetFieldValue()" << G4endl;
- //
-
- Bfield[0] = 0.;
- Bfield[1] = 0.;
-
double this_radius = sqrt( Point[0] * Point[0] + Point[1] * Point[1] );
- //G4cout << "this_radius: " << this_radius << G4endl;
if ( this_radius < _innerR ) {
- //G4cout << "this_radius < innerR" << G4endl;
- Bfield[2] = _innerField;
+ Bfield[2] += _innerField;
}
else if ( this_radius < _outerR ) {
- //G4cout << "this_radius < outerR" << G4endl;
- Bfield[2] = _outerField;
- }
- else {
- //G4cout << "no bfield" << G4endl;
- Bfield[2] = 0.;
+ Bfield[2] += _outerField;
}
-
- // DEBUG
- //G4cout << "bfield: " << Bfield[2] << G4endl;
- //
-
return;
}
lcdd/src
diff -u -r1.9 -r1.10
--- LCDDDetectorConstruction.cc 17 Nov 2005 19:59:44 -0000 1.9
+++ LCDDDetectorConstruction.cc 21 Apr 2006 23:51:27 -0000 1.10
@@ -1,7 +1,8 @@
-// $Header: /cvs/lcd/lcdd/src/LCDDDetectorConstruction.cc,v 1.9 2005/11/17 19:59:44 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/LCDDDetectorConstruction.cc,v 1.10 2006/04/21 23:51:27 jeremy Exp $
// LCDD
#include "LCDDDetectorConstruction.hh"
+#include "LCDDProcessor.hh"
#include "LCDDMessenger.hh"
#include "GDMLWriterMessenger.hh"
#include "LCDDParser.hh"
@@ -22,7 +23,7 @@
m_messenger = new LCDDMessenger();
// writer messenger
- m_writerMessenger = new GDMLWriterMessenger();
+ m_writerMessenger = new GDMLWriterMessenger();
// setup geo manager
GeometryManager::instance();
@@ -45,15 +46,20 @@
G4cout << "Started geometry construction timer." << G4endl;
- // get geometry from the global parser instance, which will die on failure
+ // get geometry from the global parser instance, which will die on failure
G4VPhysicalVolume* pv = LCDDParser::instance()->construct();
// set world ptr
setWorldVolume(pv);
+ // Setup the global magnetic field.
+ // TODO: Probably this call belongs someplace else. It is the only
+ // direct coupling to LCDDProcessor.
+ LCDDProcessor::instance()->setupGlobalMagneticField();
+
// stop build timer and print
geoTimer.Stop();
- G4cout << "Geometry construction time: " << geoTimer << G4endl;
+ G4cout << "Geometry construction time: " << geoTimer << G4endl;
return pv;
}
lcdd/src
diff -u -r1.20 -r1.21
--- LCDDLibLoad.cc 29 Aug 2005 23:23:48 -0000 1.20
+++ LCDDLibLoad.cc 21 Apr 2006 23:51:27 -0000 1.21
@@ -40,6 +40,8 @@
LOAD_COMPONENT(rz_field_mapProcess);
LOAD_COMPONENT(rzbProcess);
LOAD_COMPONENT(global_fieldProcess);
+ LOAD_COMPONENT(dipoleProcess);
+ LOAD_COMPONENT(dipole_coeffProcess);
// region
LOAD_COMPONENT(regionProcess);
@@ -75,7 +77,9 @@
// field
LOAD_COMPONENT(solenoidSubscriber);
LOAD_COMPONENT(rz_field_mapSubscriber);
- LOAD_COMPONENT(global_fieldSubscriber);
+ // DEPRECATED: global_field is no longer used
+ //LOAD_COMPONENT(global_fieldSubscriber);
+ LOAD_COMPONENT(dipoleSubscriber);
// region
LOAD_COMPONENT(regionSubscriber);
lcdd/src
diff -u -r1.12 -r1.13
--- LCDDProcessor.cc 18 Nov 2005 22:31:24 -0000 1.12
+++ LCDDProcessor.cc 21 Apr 2006 23:51:27 -0000 1.13
@@ -7,6 +7,8 @@
#include "G4SDManager.hh"
#include "G4HCtable.hh"
+#include "MagneticFieldOverlay.hh"
+
LCDDProcessor* LCDDProcessor::sInstance = 0;
LCDDProcessor::LCDDProcessor()
@@ -84,6 +86,26 @@
return m_magneticFields.end();
}
+void LCDDProcessor::setupGlobalMagneticField()
+{
+ // Add all the magnetic fields declared in the LCDD file to an overlay field.
+ MagneticFieldOverlay* overlay = new MagneticFieldOverlay();
+ for (MagneticFields::const_iterator iter = m_magneticFields.begin();
+ iter != m_magneticFields.end();
+ iter++) {
+ overlay->addMagneticField(iter->second);
+ }
+
+ // Setup Geant4 to use the overlay field.
+ G4FieldManager* fieldMgr =
+ G4TransportationManager::GetTransportationManager()->GetFieldManager();
+ fieldMgr->SetDetectorField(overlay);
+ fieldMgr->CreateChordFinder(overlay);
+
+ m_globalMagneticFieldIsInitialized = true;
+}
+
+// DEPRECATED
void LCDDProcessor::setGlobalMagneticField(G4MagneticField *mag)
{
if( m_globalMagneticFieldIsInitialized == false ) {
@@ -98,6 +120,7 @@
}
}
+// DEPRECATED
void LCDDProcessor::setGlobalMagneticField( const std::string& name)
{
G4MagneticField* m = getMagneticField( name );
@@ -193,3 +216,46 @@
{
return m_limitSets.end();
}
+
+const LCDDHeaderRecord* LCDDProcessor::getHeader() const
+{
+ return m_header;
+}
+
+void LCDDProcessor::setHeader(LCDDHeaderRecord* h)
+{
+ assert( h );
+ m_header = h;
+}
+
+std::string LCDDProcessor::getDetectorName() const
+{
+ assert( m_header );
+ std::string detTag = m_header->getDetectorName();
+ return detTag;
+}
+
+const LCDDProcessor::VisAttributes* LCDDProcessor::getVisAttributesStore() const
+{
+ return &m_visAttributes;
+}
+
+const LCDDProcessor::SensitiveDetectors* LCDDProcessor::getSensitiveDetectorStore() const
+{
+ return &m_sensitiveDetectors;
+}
+
+const LCDDProcessor::MagneticFields* LCDDProcessor::getMagneticFieldStore() const
+{
+ return &m_magneticFields;
+}
+
+const LCDDProcessor::Regions* LCDDProcessor::getRegionStore() const
+{
+ return &m_regions;
+}
+
+const LCDDProcessor::LimitSets* LCDDProcessor::getLimitSetStore() const
+{
+ return &m_limitSets;
+}
lcdd/src
diff -u -r1.6 -r1.7
--- global_fieldSubscriber.cc 30 Mar 2006 19:43:58 -0000 1.6
+++ global_fieldSubscriber.cc 21 Apr 2006 23:51:27 -0000 1.7
@@ -13,10 +13,10 @@
#include "G4MagneticField.hh"
/**
- @class global_fieldSubscriber
- @brief SAX subscriber for global_field element.
- @note Resolves fieldref and sets global field in LCDDProcessor.
-*/
+ * @class global_fieldSubscriber
+ * @brief SAX subscriber for global_field element.
+ * @note Resolves fieldref and sets global field in LCDDProcessor.
+ */
class global_fieldSubscriber : virtual public SAXSubscriber
{
public:
@@ -69,7 +69,6 @@
}
}
}
-
}
else {
std::cerr << "Failed cast to global_field!" << std::endl;
CVSspam 0.2.8