// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // // // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... #ifndef IElementField_h #define IElementField_h 1 #include #include #include #include // IElementFieldDescription #include // IElementFieldDescription namespace COMET { // class IElementField - interface for the EM field of one element // This is the interface class used by IFieldManager to compute the field // value at a given point[]. // An element that represents an element with an EM field will // derive a class from this one and implement the computation for the // element. The constructor will add the derived object into // IFieldManager's IElementField list. // Define DBL_MAX and DBL_MIN. Taken from Geant4 templates.hh #ifndef DBL_MAX /* Max decimal value of a double */ #define DBL_MAX std::numeric_limits::max() // 1.7976931348623157e+308 #endif #ifndef DBL_MIN /* Min decimal value of a double */ #define DBL_MIN std::numeric_limits::min() // 2.2250738585072014e-308 #endif class BoundingBox_t{ public: Double_t MinX; Double_t MinY; Double_t MinZ; Double_t MaxX; Double_t MaxY; Double_t MaxZ; BoundingBox_t(){ MinX=-DBL_MAX; MinY=-DBL_MAX; MinZ=-DBL_MAX; MaxX=DBL_MAX; MaxY=DBL_MAX; MaxZ=DBL_MAX; } void operator=(const BoundingBox_t other){ MinX=other.MinX; MinY=other.MinY; MinZ=other.MinZ; MaxX=other.MaxX; MaxY=other.MaxY; MaxZ=other.MaxZ; } }; class IElementField { private: IElementField& operator=(const IElementField&); public: /// Constructor. IElementField(TVector3 translation, TRotation rot); /// Destructor. virtual ~IElementField() { } /// Make a persistable IDatum with all the details to describe this element of the field virtual COMET::IHandle MakeDescription()=0; // Get translation of field element TVector3 GetTranslation(){return fTranslation;} // Set center of field element void SetTranslation(TVector3 t){ fTranslation=t; } // Get rotation of field element TRotation GetRotation(){return fGlobalToLocalRotation;} // Set the rotation of the field element void SetRotation(TRotation rot){ fGlobalToLocalRotation=rot.Inverse(); fLocalToGlobalRotation=rot; } // Transform global point to local coords void GlobalToLocal(const Double_t GlobalPoint[4], Double_t LocalPoint[4]) const; void GlobalToLocal(TVector3& Point) const{ Point-=fTranslation; Point = Point.Transform(fGlobalToLocalRotation); } // Get Bounding Box BoundingBox_t GetBoundingBox(){return fBoundingBox;} // Set Bounding Box // Bounding box must be defined in local coords of the element void SetBoundingBox(BoundingBox_t aBox){fBoundingBox=aBox;} /// isInBoundingBox() returns true if the point (in local coords) /// is within the bounding box bool isInBoundingBox(const Double_t LocalPoint[4]) const { if(LocalPoint[2] < fBoundingBox.MinZ || LocalPoint[2] > fBoundingBox.MaxZ) return false; if(LocalPoint[0] < fBoundingBox.MinX || LocalPoint[0] > fBoundingBox.MaxX) return false; if(LocalPoint[1] < fBoundingBox.MinY || LocalPoint[1] > fBoundingBox.MaxY) return false; return true; } /// addFieldValue() will add the field value for this element to field[]. /// First checks to see if the point (in global coords) is in the /// bounding box by calling isInBoundingBox(point) /// if true, transform point to local coords of the element and /// then get the field void addFieldValue(const Double_t GlobalPoint[4], Double_t field[6]) const; // Get dimensions for the bounding box in the local coords Double_t getMaxLength()const{return fBoundingBox.MaxZ;}; Double_t getMaxWidth() const{return fBoundingBox.MaxX;}; Double_t getMaxHeight()const{return fBoundingBox.MaxY;}; /// Implementations must be sure to verify that point[] is within /// the field region, and do nothing if not. /// point[] is in local coordinates and geant4 units; x,y,z,t. /// field[] is in geant4 units; Bx,By,Bz,Ex,Ey,Ez. virtual void getFieldValue(const Double_t LocalPoint[4], Double_t field[6]) const = 0; protected: // Bounding box in the local coords BoundingBox_t fBoundingBox; private: // Translation from local coords to global coords of the field element TVector3 fTranslation; // Rotation matrix from local coords to global coords of the field element TRotation fGlobalToLocalRotation, fLocalToGlobalRotation; }; } #endif