Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-19 09:21:38

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 // G4LogicalCrystalVolume
0027 //
0028 // Class description:
0029 //
0030 // Specialised logical volume for the description of crystals.
0031 // The object can be created only with an extended material
0032 // with a crystal extension. The class handles the orientation
0033 // of the crystal axes wrt the solid to which the crystal is attached.
0034 
0035 // Author: Enrico Bagli (Ferrara Univ.), 21.04.2016
0036 // ---------------------------------------------------------------------------
0037 #ifndef G4LOGICALCRYSTALVOLUME_HH
0038 #define G4LOGICALCRYSTALVOLUME_HH
0039 
0040 #include <vector>
0041 #include "G4LogicalVolume.hh"
0042 
0043 class G4CrystalExtension;
0044 class G4ExtendedMaterial;
0045 
0046 /**
0047  * @brief G4LogicalCrystalVolume is a specialised logical volume for the
0048  * description of crystals. The object can be created only with an extended
0049  * material with a crystal extension. The class handles the orientation
0050  * of the crystal axes wrt the solid to which the crystal is attached.
0051  */
0052 
0053 class G4LogicalCrystalVolume : public G4LogicalVolume
0054 {
0055   public:
0056 
0057     /**
0058      * Constructor for G4LogicalCrystalVolume.
0059      *  @param[in] pSolid Pointer to the associated solid primitive.
0060      *  @param[in] pMaterial Pointer to the associated extended crystal material.
0061      *  @param[in] name The volume name.
0062      *  @param[in] pFieldMgr Pointer to optional magnetic field manager.
0063      *  @param[in] pSDetector Pointer to optional associated sensitive detector.
0064      *  @param[in] pULimits Pointer to optional user limits.
0065      *  @param[in] optimise Flag to enable/disable optimisation structure.
0066      *  @param[in] h Miller orientation parameter h.
0067      *  @param[in] k Miller orientation parameter k.
0068      *  @param[in] l Miller orientation parameter l.
0069      *  @param[in] rot Miller rotation parameter.
0070      */
0071     G4LogicalCrystalVolume(G4VSolid* pSolid,
0072                            G4ExtendedMaterial* pMaterial,
0073                            const G4String& name,
0074                            G4FieldManager* pFieldMgr = nullptr,
0075                            G4VSensitiveDetector* pSDetector = nullptr,
0076                            G4UserLimits* pULimits = nullptr,
0077                            G4bool optimise = true,
0078                            G4int h = 0,
0079                            G4int k = 0,
0080                            G4int l = 0,
0081                            G4double rot = 0.0);
0082 
0083     /**
0084      * Destructor.
0085      */
0086     ~G4LogicalCrystalVolume() override;
0087     
0088     /**
0089      * Returns true as it is not a base-class object.
0090      */
0091     inline G4bool IsExtended() const override { return true; }
0092 
0093     /**
0094      * Sets the physical lattice orientation, relative to G4VSolid coordinates.
0095      * Miller orientation aligns lattice normal (hkl) with geometry +Z.
0096      */
0097     void SetMillerOrientation(G4int h, G4int k, G4int l, G4double rot = 0.0);
0098     
0099     /**
0100      * Methods to rotate input vector between lattice and solid orientations.
0101      *  @returns The new vector value for convenience.
0102      */
0103     const G4ThreeVector& RotateToLattice(G4ThreeVector& dir) const;
0104     const G4ThreeVector& RotateToSolid(G4ThreeVector& dir) const;
0105 
0106     /**
0107      * Returns a pointer to the crystal extension object.
0108      */
0109     const G4CrystalExtension* GetCrystal() const;
0110 
0111     /**
0112      * Calls through to get crystal basis vectors.
0113      */
0114     const G4ThreeVector& GetBasis(G4int i) const;
0115     
0116     /**
0117      * Setter for verbosity level.
0118      */
0119     inline void SetVerbose(G4int aInt) { verboseLevel = aInt; }
0120 
0121     /**
0122      * Returns true if the logical volume 'aLV' is a lattice.
0123      */
0124     static G4bool IsLattice(G4LogicalVolume* aLV);
0125 
0126   private:
0127 
0128     /** Rotates geometry into lattice frame. */
0129     G4RotationMatrix fOrient;
0130     G4RotationMatrix fInverse;
0131 
0132     /** Cached Miller indices for dump. */
0133     G4int hMiller = 1, kMiller = 1, lMiller = 0;
0134     G4double fRot = 0.0;
0135     
0136     /** Verbosity level. */
0137     G4int verboseLevel = 0;
0138 
0139     static std::vector<G4LogicalVolume*> fLCVvec;
0140 };
0141 
0142 #endif