Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:27

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 //
0028 
0029 #ifndef G4VScoringMesh_h
0030 #define G4VScoringMesh_h 1
0031 
0032 #include "globals.hh"
0033 #include "G4THitsMap.hh"
0034 #include "G4RotationMatrix.hh"
0035 #include "G4StatDouble.hh"
0036 
0037 class G4VPhysicalVolume;
0038 class G4LogicalVolume;
0039 class G4MultiFunctionalDetector;
0040 class G4VPrimitiveScorer;
0041 class G4VSDFilter;
0042 class G4VScoreColorMap;
0043 class G4ParallelWorldProcess;
0044 
0045 #include <map>
0046 
0047 // class description:
0048 //
0049 //  This class represents a multi-functional detector to be used by
0050 //  command-based scorer For parallel world scorer, this class creates a
0051 //  parallel world mesh geometry
0052 //
0053 
0054 class G4VScoringMesh
0055 {
0056  public:
0057   enum class MeshShape
0058   {
0059     box,
0060     cylinder,
0061     sphere,
0062     realWorldLogVol,
0063     probe,
0064     undefined = -1
0065   };
0066   using EventScore   = G4THitsMap<G4double>;
0067   using RunScore     = G4THitsMap<G4StatDouble>;
0068   using MeshScoreMap = std::map<G4String, RunScore*>;
0069 
0070  public:
0071   G4VScoringMesh(const G4String& wName);
0072   virtual ~G4VScoringMesh() = default;
0073 
0074  public:  // with description
0075   virtual void Construct(G4VPhysicalVolume* fWorldPhys);
0076   virtual void WorkerConstruct(G4VPhysicalVolume* fWorldPhys);
0077 
0078   // list infomration of this mesh
0079   virtual void List() const;
0080 
0081   // get the world name
0082   // If this ScoringMesh is for parallel world, it returns the name of the
0083   // parallel world If this ScoringMesh is for real world logical volume, it
0084   // returns name of logical volume
0085   inline const G4String& GetWorldName() const { return fWorldName; }
0086   // get whether this mesh is active or not
0087   inline G4bool IsActive() const { return fActive; }
0088   // set an activity of this mesh
0089   inline void Activate(G4bool vl = true) { fActive = vl; }
0090   // get the shape of this mesh
0091   inline MeshShape GetShape() const { return fShape; }
0092   // accumulate hits in a registered primitive scorer
0093   void Accumulate(G4THitsMap<G4double>* map);
0094   void Accumulate(G4THitsMap<G4StatDouble>* map);
0095   // merge same kind of meshes
0096   void Merge(const G4VScoringMesh* scMesh);
0097   // dump information of primitive socrers registered in this mesh
0098   void Dump();
0099   // draw a projected quantity on a current viewer
0100   void DrawMesh(const G4String& psName, G4VScoreColorMap* colorMap,
0101                 G4int axflg = 111);
0102   // draw a column of a quantity on a current viewer
0103   void DrawMesh(const G4String& psName, G4int idxPlane, G4int iColumn,
0104                 G4VScoreColorMap* colorMap);
0105   // draw a projected quantity on a current viewer
0106   virtual void Draw(RunScore* map, G4VScoreColorMap* colorMap,
0107                     G4int axflg = 111) = 0;
0108   // draw a column of a quantity on a current viewer
0109   virtual void DrawColumn(RunScore* map, G4VScoreColorMap* colorMap,
0110                           G4int idxProj, G4int idxColumn) = 0;
0111   // reset registered primitive scorers
0112   void ResetScore();
0113 
0114   // Following set/get methods make sense only for parallel world scoring mesh
0115   // set size of this mesh
0116   void SetSize(G4double size[3]);
0117   // get size of this mesh
0118   G4ThreeVector GetSize() const;
0119   // set starting and span angles (used only for tube segment)
0120   void SetAngles(G4double, G4double);
0121   // get angles (used only for tube segment)
0122   inline G4double GetStartAngle() const { return fAngle[0]; }
0123   inline G4double GetAngleSpan() const { return fAngle[1]; }
0124   // set position of center of this mesh
0125   void SetCenterPosition(G4double centerPosition[3]);
0126   // get position of center of this mesh
0127   G4ThreeVector GetTranslation() const { return fCenterPosition; }
0128   // set a rotation angle around the x axis
0129   void RotateX(G4double delta);
0130   // set a rotation angle around the y axis
0131   void RotateY(G4double delta);
0132   // set a rotation angle around the z axis
0133   void RotateZ(G4double delta);
0134   // get a rotation matrix
0135   G4RotationMatrix GetRotationMatrix() const
0136   {
0137     if(fRotationMatrix != nullptr)
0138       return *fRotationMatrix;
0139     return G4RotationMatrix::IDENTITY;
0140   }
0141 
0142   // set number of segments of this mesh
0143   void SetNumberOfSegments(G4int nSegment[3]);
0144   // get number of segments of this mesh
0145   void GetNumberOfSegments(G4int nSegment[3]);
0146 
0147   // register a primitive scorer to the MFD & set it to the current primitive
0148   // scorer
0149   void SetPrimitiveScorer(G4VPrimitiveScorer* ps);
0150   // register a filter to a current primtive scorer
0151   void SetFilter(G4VSDFilter* filter);
0152   // set a primitive scorer to the current one by the name
0153   void SetCurrentPrimitiveScorer(const G4String& name);
0154   // find registered primitive scorer by the name
0155   G4bool FindPrimitiveScorer(const G4String& psname);
0156   // get whether current primitive scorer is set or not
0157   G4bool IsCurrentPrimitiveScorerNull()
0158   {
0159     return fCurrentPS == nullptr;
0160   }
0161   // get unit of primitive scorer by the name
0162   G4String GetPSUnit(const G4String& psname);
0163   // get unit of current primitive scorer
0164   G4String GetCurrentPSUnit();
0165   // set unit of current primitive scorer
0166   void SetCurrentPSUnit(const G4String& unit);
0167   // get unit value of primitive scorer by the name
0168   G4double GetPSUnitValue(const G4String& psname);
0169   // set PS name to be drawn
0170   void SetDrawPSName(const G4String& psname) { fDrawPSName = psname; }
0171 
0172   // get axis names of the hierarchical division in the divided order
0173   void GetDivisionAxisNames(G4String divisionAxisNames[3]);
0174 
0175   // set current  primitive scorer to NULL
0176   void SetNullToCurrentPrimitiveScorer() { fCurrentPS = nullptr; }
0177   // set verbose level
0178   inline void SetVerboseLevel(G4int vl) { verboseLevel = vl; }
0179   // get the primitive scorer map
0180   inline MeshScoreMap GetScoreMap() const { return fMap; }
0181   // get whether this mesh setup has been ready
0182   inline G4bool ReadyForQuantity() const { return (sizeIsSet && nMeshIsSet); }
0183 
0184   // protected:
0185   // get registered primitive socrer by the name
0186   G4VPrimitiveScorer* GetPrimitiveScorer(const G4String& name);
0187 
0188   inline void SetMeshElementLogical(G4LogicalVolume* val)
0189   {
0190     fMeshElementLogical = val;
0191   }
0192   inline G4LogicalVolume* GetMeshElementLogical() const
0193   {
0194     return fMeshElementLogical;
0195   }
0196 
0197   inline void SetParallelWorldProcess(G4ParallelWorldProcess* proc)
0198   {
0199     fParallelWorldProcess = proc;
0200   }
0201   inline G4ParallelWorldProcess* GetParallelWorldProcess() const
0202   {
0203     return fParallelWorldProcess;
0204   }
0205   inline void GeometryHasBeenDestroyed()
0206   {
0207     fGeometryHasBeenDestroyed = true;
0208     fMeshElementLogical       = nullptr;
0209   }
0210 
0211   // Geometry hirarchy level (bottom = 0) to be used as the copy number
0212   // This is used only for real-world scorer
0213   inline void SetCopyNumberLevel(G4int val) { copyNumberLevel = val; }
0214   inline G4int GetCopyNumberLevel() const { return copyNumberLevel; }
0215 
0216   G4bool LayeredMassFlg() { return layeredMassFlg; }
0217 
0218  protected:
0219   // a pure virtual function to construct this mesh geometry
0220   virtual void SetupGeometry(G4VPhysicalVolume* fWorldPhys) = 0;
0221 
0222  protected:
0223   G4String fWorldName;
0224   G4VPrimitiveScorer* fCurrentPS;
0225   G4bool fConstructed;
0226   G4bool fActive;
0227   MeshShape fShape;
0228 
0229   G4double fSize[3];
0230   G4double fAngle[2];
0231   G4ThreeVector fCenterPosition;
0232   G4RotationMatrix* fRotationMatrix;
0233   G4int fNSegment[3];
0234 
0235   MeshScoreMap fMap;
0236   G4MultiFunctionalDetector* fMFD;
0237 
0238   G4int verboseLevel;
0239 
0240   G4bool sizeIsSet;
0241   G4bool nMeshIsSet;
0242 
0243   G4String fDrawUnit;
0244   G4double fDrawUnitValue;
0245   G4String fDrawPSName;
0246 
0247   G4String fDivisionAxisNames[3];
0248 
0249   G4LogicalVolume* fMeshElementLogical;
0250 
0251   G4ParallelWorldProcess* fParallelWorldProcess;
0252   G4bool fGeometryHasBeenDestroyed;
0253  
0254   G4int copyNumberLevel;
0255 
0256   // This flag may be set to true for Probe scoring mesh.
0257   // There is no public set method for this boolean flag, but it should be set
0258   // to true through SetMaterial() method of Probe scoring mesh.
0259   G4bool layeredMassFlg;
0260 };
0261 
0262 #endif