Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:17

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 /// \file field/field04/include/F04ElementField.hh
0028 /// \brief Definition of the F04ElementField class
0029 //
0030 
0031 #ifndef F04ElementField_h
0032 #define F04ElementField_h 1
0033 
0034 #include "CLHEP/Units/SystemOfUnits.h"
0035 
0036 #include "G4Navigator.hh"
0037 #include "G4TransportationManager.hh"
0038 #include "G4UserLimits.hh"
0039 #include "G4VisAttributes.hh"
0040 #include "globals.hh"
0041 
0042 //  class F04ElementField - interface for the EM field of one element
0043 
0044 //  This is the interface class used by GlobalField to compute the field
0045 //  value at a given point[].
0046 
0047 //  An element that represents an element with an EM field will
0048 //  derive a class from this one and implement the computation for the
0049 //  element. The Construct() function will add the derived object into
0050 //  GlobalField.
0051 
0052 class F04ElementField
0053 {
0054   public:
0055     ///  Constructor.
0056     F04ElementField(const G4ThreeVector, G4LogicalVolume*);
0057 
0058     /// the actual implementation constructs the F04ElementField
0059     void Construct();
0060 
0061     ///  Destructor.
0062     virtual ~F04ElementField() = default;
0063 
0064     /// SetMaxStep(G4double) sets the max. step size
0065     void SetMaxStep(G4double stp)
0066     {
0067       fMaxStep = stp;
0068       fUserLimits->SetMaxAllowedStep(fMaxStep);
0069       fVolume->SetUserLimits(fUserLimits);
0070     }
0071 
0072     /// GetMaxStep() returns the max. step size
0073     G4double GetMaxStep() { return fMaxStep; }
0074 
0075     /// SetColor(G4String) sets the color
0076     void SetColor(G4String c)
0077     {
0078       fColor = c;
0079       fVolume->SetVisAttributes(GetVisAttribute(fColor));
0080     }
0081 
0082     /// GetColor() returns the color
0083     G4String GetColor() { return fColor; }
0084 
0085     ///  GetVisAttribute() returns the appropriate G4VisAttributes.
0086     static G4VisAttributes* GetVisAttribute(G4String color);
0087 
0088     ///  SetGlobalPoint() ensures that the point is within the global
0089     ///  bounding box of this ElementField's global coordinates.
0090     ///  Normally called 8 times for the corners of the local bounding
0091     ///  box, after a local->global coordinate transform.
0092     ///  If never called, the global bounding box is infinite.
0093     ///  BEWARE: if called only once, the bounding box is just a point.
0094     void SetGlobalPoint(const G4double point[4])
0095     {
0096       if (fMinX == -DBL_MAX || fMinX > point[0]) fMinX = point[0];
0097       if (fMinY == -DBL_MAX || fMinY > point[1]) fMinY = point[1];
0098       if (fMinZ == -DBL_MAX || fMinZ > point[2]) fMinZ = point[2];
0099       if (fMaxX == DBL_MAX || fMaxX < point[0]) fMaxX = point[0];
0100       if (fMaxY == DBL_MAX || fMaxY < point[1]) fMaxY = point[1];
0101       if (fMaxZ == DBL_MAX || fMaxZ < point[2]) fMaxZ = point[2];
0102     }
0103 
0104     ///  IsInBoundingBox() returns true if the point is within the
0105     ///  global bounding box - global coordinates.
0106     bool IsInBoundingBox(const G4double point[4]) const
0107     {
0108       if (point[2] < fMinZ || point[2] > fMaxZ) return false;
0109       if (point[0] < fMinX || point[0] > fMaxX) return false;
0110       if (point[1] < fMinY || point[1] > fMaxY) return false;
0111       return true;
0112     }
0113 
0114     ///  AddFieldValue() will add the field value for this element to field[].
0115     ///  Implementations must be sure to verify that point[] is within
0116     ///  the field region, and do nothing if not.
0117     ///  point[] is in global coordinates and geant4 units; x,y,z,t.
0118     ///  field[] is in geant4 units; Bx,By,Bz,Ex,Ey,Ez.
0119     ///  For efficiency, the caller may (but need not) call
0120     ///  IsInBoundingBox(point), and only call this function if that
0121     ///  returns true.
0122     virtual void AddFieldValue(const G4double point[4], G4double field[6]) const = 0;
0123 
0124     virtual G4double GetLength() = 0;
0125     virtual G4double GetWidth() = 0;
0126     virtual G4double GetHeight() = 0;
0127 
0128   protected:
0129     G4LogicalVolume* fVolume = nullptr;
0130 
0131     G4AffineTransform fGlobal2local;
0132 
0133     //    F04ElementField(const F04ElementField&);
0134 
0135   private:
0136     F04ElementField& operator=(const F04ElementField&);
0137 
0138     static G4ThreadLocal G4Navigator* fNavigator;
0139 
0140     G4String fColor = "1,1,1";
0141 
0142     G4ThreeVector fCenter;
0143     G4double fMinX = -DBL_MAX;
0144     G4double fMinY = -DBL_MAX;
0145     G4double fMinZ = -DBL_MAX;
0146     G4double fMaxX = DBL_MAX;
0147     G4double fMaxY = DBL_MAX;
0148     G4double fMaxZ = DBL_MAX;
0149 
0150     G4double fMaxStep = 1. * CLHEP::mm;
0151     G4UserLimits* fUserLimits = nullptr;
0152 };
0153 
0154 #endif