MyElementField Class Reference

#include <MyElementField.hh>

Inheritance diagram for MyElementField:
MyFieldMap

List of all members.

Public Member Functions

 MyElementField (const G4ThreeVector, G4LogicalVolume *)
 Constructor.
void construct ()
 the actual implementation constructs the MyElementField
virtual ~MyElementField ()
 Destructor.
G4ThreeVector getCenter ()
void setCenter (G4ThreeVector)
G4double const * getBoundingBox ()
void setMaxStep (G4double s)
 setMaxStep(G4double) sets the max. step size
G4double getMaxStep ()
 getMaxStep() returns the max. step size
void setColor (G4String c)
 setColor(G4String) sets the color
G4String getColor ()
 getColor() returns the color
void setGlobalPoint (const G4double point[4])
bool isInBoundingBox (const G4double point[4]) const
virtual void addFieldValue (const G4double point[4], G4double field[6]) const =0
virtual G4double getMaxLength ()=0
virtual G4double getMaxWidth ()=0
virtual G4double getMaxHeight ()=0

Static Public Member Functions

static G4VisAttributes * getVisAttribute (G4String color)
 getVisAttribute() returns the appropriate G4VisAttributes.

Protected Attributes

G4LogicalVolume * lvolume
G4AffineTransform global2local

Private Member Functions

MyElementFieldoperator= (const MyElementField &)

Private Attributes

G4String color
G4ThreeVector center
G4double minX
G4double minY
G4double minZ
G4double maxX
G4double maxY
G4double maxZ
G4double maxStep
G4UserLimits * userLimits
G4double * boundingBox

Static Private Attributes

static G4Navigator * aNavigator

Detailed Description

Definition at line 54 of file MyElementField.hh.


Constructor & Destructor Documentation

MyElementField::MyElementField ( const  G4ThreeVector,
G4LogicalVolume *  lv 
)

Constructor.

Definition at line 38 of file MyElementField.cc.

References MyGlobalField::addElementField(), boundingBox, center, color, MyGlobalField::getObject(), lvolume, maxStep, maxX, maxY, maxZ, minX, minY, minZ, and userLimits.

00038                                                                    {
00039     center = c;
00040 
00041     // AK20100812 Add access to bounding box points
00042     boundingBox=NULL;
00043 
00044     //G4cout << "-AK- MyElementField::MyElementField, center is " << c << G4endl;
00045     //G4cout << "-AK- MyElementField::MyElementField, volume name is "
00046     //<< lv->GetName() << G4endl;
00047 
00048     minX = minY = minZ = -DBL_MAX;
00049     maxX = maxY = maxZ =  DBL_MAX;
00050 
00051     MyGlobalField::getObject()->addElementField(this);
00052     //F04GlobalField::getObject()->addElementField(this);
00053 
00054     color = "1,1,1";
00055 
00056     userLimits = new G4UserLimits();
00057 
00058     lvolume = lv;
00059     //lvolume->SetVisAttributes(getVisAttribute(color));
00060 
00061     maxStep = 1*mm;
00062 
00063     userLimits->SetMaxAllowedStep(maxStep);
00064 
00065     userLimits->SetUserMaxTrackLength(500.*m);
00066     userLimits->SetUserMaxTime(10*ms);
00067     userLimits->SetUserMinEkine(0.1*MeV);
00068     //  userLimits->SetUserMinRange(1*mm);
00069 
00070     lvolume->SetUserLimits(userLimits);
00071 }

virtual MyElementField::~MyElementField (  )  [inline, virtual]

Destructor.

Definition at line 69 of file MyElementField.hh.

References aNavigator, and boundingBox.

00069                                   {
00070             if (aNavigator) delete aNavigator;
00071             if (boundingBox) delete boundingBox;
00072         }


Member Function Documentation

virtual void MyElementField::addFieldValue ( const G4double  point[4],
G4double  field[6] 
) const [pure virtual]

addFieldValue() will add the field value for this element to field[]. Implementations must be sure to verify that point[] is within the field region, and do nothing if not. point[] is in global coordinates and geant4 units; x,y,z,t. field[] is in geant4 units; Bx,By,Bz,Ex,Ey,Ez. For efficiency, the caller may (but need not) call isInBoundingBox(point), and only call this function if that returns true.

Implemented in MyFieldMap.

Referenced by MyGlobalField::GetFieldValue().

void MyElementField::construct (  ) 

the actual implementation constructs the MyElementField

Definition at line 74 of file MyElementField.cc.

References aNavigator, center, getMaxHeight(), getMaxLength(), getMaxWidth(), global2local, lvolume, and setGlobalPoint().

00074                                {
00075     G4Navigator* theNavigator =
00076         G4TransportationManager::GetTransportationManager()->
00077         GetNavigatorForTracking();
00078 
00079 //    G4cout << "-AK- In MyElementField::construct, lvolume is "
00080 //        << lvolume->GetName() << G4endl;
00081 
00082     if (!aNavigator) {
00083         aNavigator = new G4Navigator();
00084         if ( theNavigator->GetWorldVolume() )
00085             aNavigator->SetWorldVolume(theNavigator->GetWorldVolume());
00086     }
00087 
00088     G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
00089 
00090     if (!geomManager->IsGeometryClosed()) {
00091         geomManager->OpenGeometry();
00092         geomManager->CloseGeometry(true);
00093     }
00094 
00095     aNavigator->LocateGlobalPointAndSetup(center,0,false);
00096 //    G4cout << "-AK- MyElementField::construct, center is " << center << G4endl;
00097 
00098     G4TouchableHistoryHandle fTouchable = aNavigator->
00099         CreateTouchableHistoryHandle();
00100 
00101     G4int depth = fTouchable->GetHistoryDepth();
00102 //    G4cout << "-AK- fTouchable->GetHistoryDepth is " << depth << G4endl;
00103 
00104     for (G4int i = 0; i<depth; ++i) {
00105 //        G4cout << "-AK- In MyElementField::construct, volume is "
00106  //           << fTouchable->GetVolume()->GetLogicalVolume()->GetName() << G4endl;
00107         if(fTouchable->GetVolume()->GetLogicalVolume() == lvolume) {
00108 //            G4cout << "-AK- In MyElementField::construct, found lvolume "
00109 //                << lvolume->GetName() << G4endl;
00110             break;
00111         }
00112 
00113         fTouchable->MoveUpHistory();
00114     }
00115 
00116     // set global2local transform
00117     global2local = fTouchable->GetHistory()->GetTopTransform();
00118 
00119     // set global bounding box
00120     G4double local[4], global[4];
00121 
00122     G4ThreeVector globalPosition;
00123     local[3] = 0.0;
00124     for (int i=0; i<2; ++i) {
00125         local[0] = (i==0 ? -1.0 : 1.0) * getMaxWidth()/2.;
00126         for (int j=0; j<2; ++j) {
00127             local[1] = (j==0 ? -1.0 : 1.0) * getMaxHeight()/2.;
00128             for (int k=0; k<2; ++k) {
00129                 local[2] = (k==0 ? -1.0 : 1.0) * getMaxLength()/2.;
00130                 G4ThreeVector localPosition(local[0],local[1],local[2]);
00131                 globalPosition =
00132                     global2local.Inverse().TransformPoint(localPosition);
00133                 global[0] = globalPosition.x();
00134                 global[1] = globalPosition.y();
00135                 global[2] = globalPosition.z();
00136                 setGlobalPoint(global);
00137                 //G4cout << "-AK- MyElementField::construct, bounding box global pos is"
00138                 //     << globalPosition << G4endl;
00139             }
00140         }
00141     }
00142 }

G4double const * MyElementField::getBoundingBox (  ) 

Definition at line 165 of file MyElementField.cc.

References boundingBox, maxX, maxY, maxZ, minX, minY, and minZ.

00165                                                 {
00166     if(boundingBox==NULL) {
00167         boundingBox= new G4double[6];
00168     }
00169     boundingBox[0] = minX;
00170     boundingBox[1] = maxX;
00171     boundingBox[2] = minY;
00172     boundingBox[3] = maxY;
00173     boundingBox[4] = minZ;
00174     boundingBox[5] = maxZ;
00175     return boundingBox;
00176 }

G4ThreeVector MyElementField::getCenter (  )  [inline]

Definition at line 75 of file MyElementField.hh.

References center.

00075 {return center;}

G4String MyElementField::getColor (  )  [inline]

getColor() returns the color

Definition at line 100 of file MyElementField.hh.

References color.

00100 { return color; }

virtual G4double MyElementField::getMaxHeight (  )  [pure virtual]

Implemented in MyFieldMap.

Referenced by construct().

virtual G4double MyElementField::getMaxLength (  )  [pure virtual]

Implemented in MyFieldMap.

Referenced by construct().

G4double MyElementField::getMaxStep (  )  [inline]

getMaxStep() returns the max. step size

Definition at line 91 of file MyElementField.hh.

References maxStep.

00091 { return maxStep; }

virtual G4double MyElementField::getMaxWidth (  )  [pure virtual]

Implemented in MyFieldMap.

Referenced by construct().

G4VisAttributes * MyElementField::getVisAttribute ( G4String  color  )  [static]

getVisAttribute() returns the appropriate G4VisAttributes.

Definition at line 145 of file MyElementField.cc.

Referenced by setColor().

00145                                                                {
00146     G4VisAttributes* p = NULL;
00147     if(color.size() > 0 &&
00148     (isdigit(color.c_str()[0]) || color.c_str()[0] == '.')) {
00149         G4double red=0.0, green=0.0, blue=0.0;
00150         if (sscanf(color.c_str(),"%lf,%lf,%lf",&red,&green,&blue) == 3) {
00151             p = new G4VisAttributes(true,G4Color(red,green,blue));
00152         }
00153         else {
00154             G4cout << " Invalid color " << color << G4endl;
00155         }
00156     }
00157 
00158     if (!p) p = new G4VisAttributes(G4VisAttributes::Invisible);
00159     p->SetDaughtersInvisible(false);
00160 
00161     return p;
00162 }

bool MyElementField::isInBoundingBox ( const G4double  point[4]  )  const [inline]

isInBoundingBox() returns true if the point is within the global bounding box - global coordinates.

Definition at line 122 of file MyElementField.hh.

References maxX, maxY, maxZ, minX, minY, and minZ.

Referenced by MyGlobalField::GetFieldValue().

00122                                                             {
00123             if(point[2] < minZ || point[2] > maxZ) return false;
00124             if(point[0] < minX || point[0] > maxX) return false;
00125             if(point[1] < minY || point[1] > maxY) return false;
00126             return true;
00127         }

MyElementField& MyElementField::operator= ( const MyElementField  )  [private]
void MyElementField::setCenter ( G4ThreeVector  c  ) 

Definition at line 179 of file MyElementField.cc.

References center.

00179                                               {
00180     center = c;
00181 }

void MyElementField::setColor ( G4String  c  )  [inline]

setColor(G4String) sets the color

Definition at line 94 of file MyElementField.hh.

References color, getVisAttribute(), and lvolume.

00094                                   {
00095             color = c;
00096             lvolume->SetVisAttributes(getVisAttribute(color));
00097         }

void MyElementField::setGlobalPoint ( const G4double  point[4]  )  [inline]

setGlobalPoint() ensures that the point is within the global bounding box of this ElementField's global coordinates. Normally called 8 times for the corners of the local bounding box, after a local->global coordinate transform. If never called, the global bounding box is infinite. BEWARE: if called only once, the bounding box is just a point.

Definition at line 111 of file MyElementField.hh.

References maxX, maxY, maxZ, minX, minY, and minZ.

Referenced by construct().

00111                                                      {
00112             if(minX == -DBL_MAX || minX > point[0]) minX = point[0];
00113             if(minY == -DBL_MAX || minY > point[1]) minY = point[1];
00114             if(minZ == -DBL_MAX || minZ > point[2]) minZ = point[2];
00115             if(maxX ==  DBL_MAX || maxX < point[0]) maxX = point[0];
00116             if(maxY ==  DBL_MAX || maxY < point[1]) maxY = point[1];
00117             if(maxZ ==  DBL_MAX || maxZ < point[2]) maxZ = point[2];
00118         }

void MyElementField::setMaxStep ( G4double  s  )  [inline]

setMaxStep(G4double) sets the max. step size

Definition at line 84 of file MyElementField.hh.

References lvolume, maxStep, and userLimits.

00084                                     {
00085             maxStep = s;
00086             userLimits->SetMaxAllowedStep(maxStep);
00087             lvolume->SetUserLimits(userLimits);
00088         }


Member Data Documentation

G4Navigator * MyElementField::aNavigator [static, private]

Definition at line 155 of file MyElementField.hh.

Referenced by construct(), and ~MyElementField().

G4double* MyElementField::boundingBox [private]

Definition at line 165 of file MyElementField.hh.

Referenced by getBoundingBox(), MyElementField(), and ~MyElementField().

G4ThreeVector MyElementField::center [private]

Definition at line 159 of file MyElementField.hh.

Referenced by construct(), getCenter(), MyElementField(), and setCenter().

G4String MyElementField::color [private]

Definition at line 157 of file MyElementField.hh.

Referenced by getColor(), MyElementField(), and setColor().

G4AffineTransform MyElementField::global2local [protected]

Definition at line 149 of file MyElementField.hh.

Referenced by MyFieldMap::addFieldValue(), and construct().

G4LogicalVolume* MyElementField::lvolume [protected]

Definition at line 147 of file MyElementField.hh.

Referenced by construct(), MyElementField(), setColor(), and setMaxStep().

G4double MyElementField::maxStep [private]

Definition at line 162 of file MyElementField.hh.

Referenced by getMaxStep(), MyElementField(), and setMaxStep().

G4double MyElementField::maxX [private]

Definition at line 160 of file MyElementField.hh.

Referenced by getBoundingBox(), isInBoundingBox(), MyElementField(), and setGlobalPoint().

G4double MyElementField::maxY [private]

Definition at line 160 of file MyElementField.hh.

Referenced by getBoundingBox(), isInBoundingBox(), MyElementField(), and setGlobalPoint().

G4double MyElementField::maxZ [private]

Definition at line 160 of file MyElementField.hh.

Referenced by getBoundingBox(), isInBoundingBox(), MyElementField(), and setGlobalPoint().

G4double MyElementField::minX [private]

Definition at line 160 of file MyElementField.hh.

Referenced by getBoundingBox(), isInBoundingBox(), MyElementField(), and setGlobalPoint().

G4double MyElementField::minY [private]

Definition at line 160 of file MyElementField.hh.

Referenced by getBoundingBox(), isInBoundingBox(), MyElementField(), and setGlobalPoint().

G4double MyElementField::minZ [private]

Definition at line 160 of file MyElementField.hh.

Referenced by getBoundingBox(), isInBoundingBox(), MyElementField(), and setGlobalPoint().

G4UserLimits* MyElementField::userLimits [private]

Definition at line 163 of file MyElementField.hh.

Referenced by MyElementField(), and setMaxStep().


The documentation for this class was generated from the following files:

Generated on 15 Jun 2016 for g4sim by  doxygen 1.6.1