LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
G4EzVolume.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // ====================================================================
27 // G4EzVolume.hh
28 //
29 // Utility class for supporting creating user geometry
30 //
31 // * wrapper of logical volume
32 //
33 // 2005 Q
34 // ====================================================================
35 #ifndef G4_EZ_VOLUME_H
36 #define G4_EZ_VOLUME_H
37 
38 #include "G4LogicalVolume.hh"
39 #include "G4VisAttributes.hh"
40 #include "G4Transform3D.hh"
41 
42 // ====================================================================
43 //
44 // class definition
45 //
46 // ====================================================================
47 class G4Material;
48 class G4VSolid;
49 class G4VPhysicalVolume;
50 
51 class G4EzVolume {
52 protected:
53  // volume information
55  G4VSolid* solid;
56  G4LogicalVolume* lv;
57  G4LogicalVolume* lvsub; // logical volume for voxels
58  G4VisAttributes* va;
59  G4int nplacement; // # of placements
60 
61 public:
62  G4EzVolume();
63  G4EzVolume(const G4String& aname);
64  ~G4EzVolume();
65 
66  // createing volume
67  void CreateBoxVolume(G4Material* amaterial,
68  G4double dx, G4double dy, G4double dz);
69 
70  void CreateTubeVolume(G4Material* amaterial,
71  G4double rmin, G4double rmax,
72  G4double dz,
73  G4double phi0=0., G4double dphi=360*deg);
74 
75  void CreateConeVolume(G4Material* amaterial,
76  G4double rmin1, G4double rmax1,
77  G4double rmin2, G4double rmax2,
78  G4double dz,
79  G4double phi0=0., G4double dphi=360.*deg);
80 
81  void CreateSphereVolume(G4Material* amaterial,
82  G4double rmin, G4double rmax,
83  G4double phi0=0., G4double dphi=360.*deg,
84  G4double theta0=0., G4double dtheta=180.*deg);
85 
86  void CreateOrbVolume(G4Material* amaterial, G4double rmax);
87 
88 
89  // placement
90  G4VPhysicalVolume* PlaceIt(const G4ThreeVector& pos, G4int ncopy=0,
91  G4EzVolume* parent=0);
92 
93  G4VPhysicalVolume* PlaceIt(const G4Transform3D& transform, G4int ncopy=0,
94  G4EzVolume* parent=0);
95  // replica
96  // parent volume should be exactly filled with replicated volumes.
97  G4VPhysicalVolume* ReplicateIt(G4EzVolume* parent,
98  EAxis pAxis, G4int nReplicas,
99  G4double width, G4double offset=0);
100  // voxelize
101  // volume should be "BOX". otherwise, error.
102  // returning voxel size in each dimension
103  G4ThreeVector VoxelizeIt(G4int nx, G4int ny, G4int nz);
104 
105  // sensitivity
106  // in the case of voxelized, SD will be set to a voxel.
107  void SetSensitiveDetector(G4VSensitiveDetector* asd);
108 
109  // direct access to properties
110  const G4String& GetName() const;
111 
112  void SetSolid(G4VSolid* asolid);
113  const G4VSolid* GetSolid() const;
114 
115  void SetMaterial(G4Material* amaterial);
116  G4Material* GetMaterial() const;
117 
118  G4int GetNofPlacements() const;
119 
120  void SetVisibility(G4bool qvisible);
121  void SetColor(const G4Color& color);
122  void SetColor(G4double red, G4double green, G4double blue);
123 
124 };
125 
126 // ====================================================================
127 // inline functions
128 // ====================================================================
129 
130 inline const G4String& G4EzVolume::GetName() const { return name; }
131 
132 inline void G4EzVolume::SetSolid(G4VSolid* asolid) { solid= asolid; }
133 
134 inline const G4VSolid* G4EzVolume::GetSolid() const { return solid; }
135 
136 inline void G4EzVolume::SetMaterial(G4Material* amaterial)
137 {
138  if(lv!= 0) lv-> SetMaterial(amaterial);
139  if(lvsub!= 0) lvsub-> SetMaterial(amaterial);
140 }
141 
142 inline G4Material* G4EzVolume::GetMaterial() const
143 {
144  if(lv!=0) return lv-> GetMaterial();
145  else return 0;
146 }
147 
148 inline G4int G4EzVolume::GetNofPlacements() const { return nplacement; }
149 
150 inline void G4EzVolume::SetVisibility(G4bool qvisible)
151 {
152  if(va!=0) va-> SetVisibility(qvisible);
153 }
154 
155 inline void G4EzVolume::SetColor(const G4Color& color)
156 {
157  if(va!=0) va-> SetColor(color);
158 }
159 
160 inline void G4EzVolume::SetColor(G4double red, G4double green, G4double blue)
161 {
162  if(va!=0) va-> SetColor(red, green, blue);
163 }
164 
165 #endif
G4int GetNofPlacements() const
Definition: G4EzVolume.hh:148
G4String name
Definition: G4EzVolume.hh:54
G4LogicalVolume * lv
Definition: G4EzVolume.hh:56
Definition: test07.cc:35
G4ThreeVector VoxelizeIt(G4int nx, G4int ny, G4int nz)
Definition: G4EzVolume.cc:256
void SetSensitiveDetector(G4VSensitiveDetector *asd)
Definition: G4EzVolume.cc:300
G4VSolid * solid
Definition: G4EzVolume.hh:55
void CreateTubeVolume(G4Material *amaterial, G4double rmin, G4double rmax, G4double dz, G4double phi0=0., G4double dphi=360 *deg)
Definition: G4EzVolume.cc:100
void CreateConeVolume(G4Material *amaterial, G4double rmin1, G4double rmax1, G4double rmin2, G4double rmax2, G4double dz, G4double phi0=0., G4double dphi=360.*deg)
Definition: G4EzVolume.cc:121
Definition: test07.cc:35
void CreateOrbVolume(G4Material *amaterial, G4double rmax)
Definition: G4EzVolume.cc:167
G4Material * GetMaterial() const
Definition: G4EzVolume.hh:142
void SetSolid(G4VSolid *asolid)
Definition: G4EzVolume.hh:132
void SetVisibility(G4bool qvisible)
Definition: G4EzVolume.hh:150
const G4VSolid * GetSolid() const
Definition: G4EzVolume.hh:134
G4int nplacement
Definition: G4EzVolume.hh:59
const G4String & GetName() const
Definition: G4EzVolume.hh:130
void CreateBoxVolume(G4Material *amaterial, G4double dx, G4double dy, G4double dz)
Definition: G4EzVolume.cc:80
void CreateSphereVolume(G4Material *amaterial, G4double rmin, G4double rmax, G4double phi0=0., G4double dphi=360.*deg, G4double theta0=0., G4double dtheta=180.*deg)
Definition: G4EzVolume.cc:145
G4VisAttributes * va
Definition: G4EzVolume.hh:58
void SetMaterial(G4Material *amaterial)
Definition: G4EzVolume.hh:136
std::size_t color(std::string const &procname)
G4LogicalVolume * lvsub
Definition: G4EzVolume.hh:57
void SetColor(const G4Color &color)
Definition: G4EzVolume.hh:155
G4VPhysicalVolume * ReplicateIt(G4EzVolume *parent, EAxis pAxis, G4int nReplicas, G4double width, G4double offset=0)
Definition: G4EzVolume.cc:236
G4VPhysicalVolume * PlaceIt(const G4ThreeVector &pos, G4int ncopy=0, G4EzVolume *parent=0)
Definition: G4EzVolume.cc:186