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 | // File name: RadmonTDetectorVolumesWithGroundDecorator.icc |
---|
28 | // Creation date: Sep 2005 |
---|
29 | // Main author: Riccardo Capra <capra@ge.infn.it> |
---|
30 | // |
---|
31 | // Id: $Id: RadmonTDetectorVolumesWithGroundDecorator.icc,v 1.1.2.2 2006/06/29 16:12:30 gunter Exp $ |
---|
32 | // Tag: $Name: geant4-09-01-patch-02 $ |
---|
33 | // |
---|
34 | |
---|
35 | #ifndef RADMONTDETECTORVOLUMESWITHGROUNDDECORATOR_HH |
---|
36 | #error "RadmonTDetectorVolumesWithGroundDecorator.icc cannot be included directly. Please use RadmonTDetectorVolumesWithGroundDecorator.hh" |
---|
37 | #else /* RADMONTDETECTORVOLUMESWITHGROUNDDECORATOR_HH */ |
---|
38 | // Include files |
---|
39 | #include "RadmonVDetectorLabelledEntityConstructor.hh" |
---|
40 | #include "RadmonDetectorLayerVolumesList.hh" |
---|
41 | #include "RadmonDetectorLayerVolumeItem.hh" |
---|
42 | #include "G4Box.hh" |
---|
43 | |
---|
44 | template <class LayerVolumesComponent> |
---|
45 | RadmonTDetectorVolumesWithGroundDecorator<LayerVolumesComponent> :: RadmonTDetectorVolumesWithGroundDecorator(const RadmonVDetectorLabelledEntityConstructor * constructor) |
---|
46 | : |
---|
47 | owner(constructor), |
---|
48 | component(constructor), |
---|
49 | box(0), |
---|
50 | visAttributes(0) |
---|
51 | { |
---|
52 | } |
---|
53 | |
---|
54 | |
---|
55 | |
---|
56 | template <class LayerVolumesComponent> |
---|
57 | RadmonTDetectorVolumesWithGroundDecorator<LayerVolumesComponent> :: ~RadmonTDetectorVolumesWithGroundDecorator() |
---|
58 | { |
---|
59 | delete box; |
---|
60 | delete visAttributes; |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | |
---|
65 | |
---|
66 | |
---|
67 | template <class LayerVolumesComponent> |
---|
68 | RadmonDetectorLayerVolumesList * RadmonTDetectorVolumesWithGroundDecorator<LayerVolumesComponent> :: GenerateVolumesList(void) |
---|
69 | { |
---|
70 | G4double width(owner->GetWidth()); |
---|
71 | if (width<0) |
---|
72 | return 0; |
---|
73 | |
---|
74 | G4double height(owner->GetHeight()); |
---|
75 | if (height<0) |
---|
76 | return 0; |
---|
77 | |
---|
78 | G4double thickness(owner->GetThickness()); |
---|
79 | if (thickness<0) |
---|
80 | return 0; |
---|
81 | |
---|
82 | G4double groundWidth(owner->GetAttributeAsMeasure("GroundWidth", "Length", -1.)); |
---|
83 | if (groundWidth<0) |
---|
84 | { |
---|
85 | groundWidth=owner->GetAttributeAsDouble("GroundScaleWidth", -1.); |
---|
86 | |
---|
87 | if (groundWidth<0) |
---|
88 | { |
---|
89 | G4cout << "RadmonTDetectorVolumesWithGroundDecorator::GenerateVolumesList: Neither \"GroundWidth\" nor \"GroundScaleWidth\" attributes are defined." << G4endl; |
---|
90 | return 0; |
---|
91 | } |
---|
92 | |
---|
93 | groundWidth*=width; |
---|
94 | } |
---|
95 | |
---|
96 | if (width<groundWidth) |
---|
97 | { |
---|
98 | G4cout << "RadmonTDetectorVolumesWithGroundDecorator::GenerateVolumesList: Ground width exceeds layer width." << G4endl; |
---|
99 | return 0; |
---|
100 | } |
---|
101 | |
---|
102 | G4double groundHeight(owner->GetAttributeAsMeasure("GroundHeight", "Length", -1.)); |
---|
103 | if (groundHeight<0) |
---|
104 | { |
---|
105 | groundHeight=owner->GetAttributeAsDouble("GroundScaleHeight", -1.); |
---|
106 | |
---|
107 | if (groundHeight<0) |
---|
108 | { |
---|
109 | G4cout << "RadmonTDetectorVolumesWithGroundDecorator::GenerateVolumesList: Neither \"GroundHeight\" nor \"GroundScaleHeight attributes are defined." << G4endl; |
---|
110 | return 0; |
---|
111 | } |
---|
112 | |
---|
113 | groundHeight*=height; |
---|
114 | } |
---|
115 | |
---|
116 | if (height<groundHeight) |
---|
117 | { |
---|
118 | G4cout << "RadmonTDetectorVolumesWithGroundDecorator::GenerateVolumesList: Ground height exceeds layer height." << G4endl; |
---|
119 | return 0; |
---|
120 | } |
---|
121 | |
---|
122 | G4Material * material(owner->GetMaterial("GroundMaterial")); |
---|
123 | if (!material) |
---|
124 | return 0; |
---|
125 | |
---|
126 | visAttributes=owner->AllocateVisAttributes("GroundVisAttributes", material); |
---|
127 | |
---|
128 | RadmonDetectorLayerVolumesList * list(component.GenerateVolumesList()); |
---|
129 | |
---|
130 | if (list==0) |
---|
131 | return 0; |
---|
132 | |
---|
133 | G4int n(list->GetNItems()); |
---|
134 | |
---|
135 | if (n==0) |
---|
136 | { |
---|
137 | delete list; |
---|
138 | return 0; |
---|
139 | } |
---|
140 | |
---|
141 | RadmonDetectorLayerVolumeItem * item; |
---|
142 | RadmonDetectorLayerVolumeItem * motherItem; |
---|
143 | |
---|
144 | while (n>0) |
---|
145 | { |
---|
146 | n--; |
---|
147 | |
---|
148 | item=list->GetItem(n); |
---|
149 | if (item->GetMotherVolumeItem()==0) |
---|
150 | { |
---|
151 | motherItem=item; |
---|
152 | break; |
---|
153 | } |
---|
154 | } |
---|
155 | |
---|
156 | if (!motherItem) |
---|
157 | G4Exception("RadmonTDetectorVolumesWithGroundDecorator::GenerateVolumesList: No mother volume found."); |
---|
158 | |
---|
159 | box=new G4Box("Ground", groundWidth/2., groundHeight/2., thickness/2.); |
---|
160 | |
---|
161 | item=list->AppendItem(); |
---|
162 | item->SetSolid(box); |
---|
163 | item->SetAttributes(visAttributes); |
---|
164 | item->SetMaterial(material); |
---|
165 | item->SetName("Ground"); |
---|
166 | item->SetMotherVolumeItem(motherItem); |
---|
167 | |
---|
168 | return list; |
---|
169 | } |
---|
170 | #endif /* RADMONTDETECTORVOLUMESWITHGROUNDDECORATOR_HH */ |
---|
171 | |
---|