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: RadmonTDetectorVolumesWithHoleDecorator.icc |
---|
28 | // Creation date: Sep 2005 |
---|
29 | // Main author: Riccardo Capra <capra@ge.infn.it> |
---|
30 | // |
---|
31 | // Id: $Id: RadmonTDetectorVolumesWithHoleDecorator.icc,v 1.4 2006/06/29 16:12:34 gunter Exp $ |
---|
32 | // Tag: $Name: $ |
---|
33 | // |
---|
34 | |
---|
35 | #ifndef RADMONTDETECTORVOLUMESWITHHOLEDECORATOR_HH |
---|
36 | #error "RadmonTDetectorVolumesWithHoleDecorator.icc cannot be included directly. Please use RadmonTDetectorVolumesWithHoleDecorator.hh" |
---|
37 | #else /* RADMONTDETECTORVOLUMESWITHHOLEDECORATOR_HH */ |
---|
38 | // Include files |
---|
39 | #include "RadmonVDetectorLabelledEntityConstructor.hh" |
---|
40 | #include "RadmonDetectorLayerVolumesList.hh" |
---|
41 | #include "RadmonDetectorLayerVolumeItem.hh" |
---|
42 | #include "RadmonDetectorLayerVolumeItemSubtraction.hh" |
---|
43 | #include "G4Box.hh" |
---|
44 | |
---|
45 | template <class LayerVolumesComponent> |
---|
46 | RadmonTDetectorVolumesWithHoleDecorator<LayerVolumesComponent> :: RadmonTDetectorVolumesWithHoleDecorator(const RadmonVDetectorLabelledEntityConstructor * constructor) |
---|
47 | : |
---|
48 | owner(constructor), |
---|
49 | component(constructor), |
---|
50 | operation(RadmonDetectorLayerVolumeItemSubtraction::rightMinusLeft) |
---|
51 | { |
---|
52 | } |
---|
53 | |
---|
54 | |
---|
55 | |
---|
56 | template <class LayerVolumesComponent> |
---|
57 | RadmonTDetectorVolumesWithHoleDecorator<LayerVolumesComponent> :: ~RadmonTDetectorVolumesWithHoleDecorator() |
---|
58 | { |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | |
---|
64 | |
---|
65 | template <class LayerVolumesComponent> |
---|
66 | RadmonDetectorLayerVolumesList * RadmonTDetectorVolumesWithHoleDecorator<LayerVolumesComponent> :: GenerateVolumesList(void) |
---|
67 | { |
---|
68 | G4double width(owner->GetWidth()); |
---|
69 | if (width<0) |
---|
70 | return 0; |
---|
71 | |
---|
72 | G4double height(owner->GetHeight()); |
---|
73 | if (height<0) |
---|
74 | return 0; |
---|
75 | |
---|
76 | G4double thickness(owner->GetThickness()); |
---|
77 | if (thickness<0) |
---|
78 | return 0; |
---|
79 | |
---|
80 | G4double holeWidth(owner->GetAttributeAsMeasure("HoleWidth", "Length", -1.)); |
---|
81 | if (holeWidth<0) |
---|
82 | { |
---|
83 | holeWidth=owner->GetAttributeAsDouble("HoleScaleWidth", -1.); |
---|
84 | |
---|
85 | if (holeWidth<0) |
---|
86 | { |
---|
87 | G4cout << "RadmonTDetectorVolumesWithHoleDecorator::GenerateVolumesList: Neither \"HoleWidth\" nor \"HoleScaleWidth\" attributes are defined." << G4endl; |
---|
88 | return 0; |
---|
89 | } |
---|
90 | |
---|
91 | holeWidth*=width; |
---|
92 | } |
---|
93 | |
---|
94 | if (width<holeWidth) |
---|
95 | { |
---|
96 | G4cout << "RadmonTDetectorVolumesWithHoleDecorator::GenerateVolumesList: Hole width exceeds layer width." << G4endl; |
---|
97 | return 0; |
---|
98 | } |
---|
99 | |
---|
100 | G4double holeHeight(owner->GetAttributeAsMeasure("HoleHeight", "Length", -1.)); |
---|
101 | if (holeHeight<0) |
---|
102 | { |
---|
103 | holeHeight=owner->GetAttributeAsDouble("HoleScaleHeight", -1.); |
---|
104 | |
---|
105 | if (holeHeight<0) |
---|
106 | { |
---|
107 | G4cout << "RadmonTDetectorVolumesWithHoleDecorator::GenerateVolumesList: Neither \"HoleHeight\" nor \"HoleScaleHeight attributes are defined." << G4endl; |
---|
108 | return 0; |
---|
109 | } |
---|
110 | |
---|
111 | holeHeight*=height; |
---|
112 | } |
---|
113 | |
---|
114 | if (height<holeHeight) |
---|
115 | { |
---|
116 | G4cout << "RadmonTDetectorVolumesWithHoleDecorator::GenerateVolumesList: Hole height exceeds layer height." << G4endl; |
---|
117 | return 0; |
---|
118 | } |
---|
119 | |
---|
120 | RadmonDetectorLayerVolumesList * list(component.GenerateVolumesList()); |
---|
121 | |
---|
122 | if (list==0) |
---|
123 | return 0; |
---|
124 | |
---|
125 | G4int n(list->GetNItems()); |
---|
126 | |
---|
127 | if (n==0) |
---|
128 | { |
---|
129 | delete list; |
---|
130 | return 0; |
---|
131 | } |
---|
132 | |
---|
133 | RadmonDetectorLayerVolumeItem * item; |
---|
134 | G4Box * hole(new G4Box("Hole", holeWidth/2., holeHeight/2., (thickness/2.)*1.01)); |
---|
135 | operation.Initialize(hole); |
---|
136 | |
---|
137 | while (n>0) |
---|
138 | { |
---|
139 | n--; |
---|
140 | |
---|
141 | item=list->GetItem(n); |
---|
142 | operation.ApplyTo(item); |
---|
143 | } |
---|
144 | |
---|
145 | return list; |
---|
146 | } |
---|
147 | #endif /* RADMONTDETECTORVOLUMESWITHHOLEDECORATOR_HH */ |
---|
148 | |
---|