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 | // FredHit.cc |
---|
28 | // |
---|
29 | // Implementation of FredHit: intersection of track with a test volume |
---|
30 | // |
---|
31 | // For more comments, you should really take a look at FredHit.hh |
---|
32 | // |
---|
33 | |
---|
34 | #include "FredHit.hh" |
---|
35 | #include "G4Track.hh" |
---|
36 | #include "G4VVisManager.hh" |
---|
37 | #include "G4Circle.hh" |
---|
38 | #include "G4Color.hh" |
---|
39 | #include "G4VisAttributes.hh" |
---|
40 | |
---|
41 | // |
---|
42 | // Implement FredHit's allocator, via template |
---|
43 | G4Allocator<FredHit> FredHitAllocator; |
---|
44 | |
---|
45 | |
---|
46 | // |
---|
47 | // Constructor (position and enters specified) |
---|
48 | // |
---|
49 | FredHit::FredHit( const G4ThreeVector aPos, G4bool aEnters, const G4Track *aTrack ) |
---|
50 | { |
---|
51 | pos = aPos; |
---|
52 | enters = aEnters; |
---|
53 | track = aTrack; |
---|
54 | } |
---|
55 | |
---|
56 | |
---|
57 | // |
---|
58 | // Copy (initialization) |
---|
59 | // |
---|
60 | FredHit::FredHit( const FredHit &right ) |
---|
61 | : G4VHit(right) |
---|
62 | { |
---|
63 | // Assign position |
---|
64 | pos = right.pos; |
---|
65 | enters = right.enters; |
---|
66 | track = right.track; |
---|
67 | } |
---|
68 | |
---|
69 | // |
---|
70 | // Copy (assignment operator) |
---|
71 | // |
---|
72 | const FredHit& FredHit::operator=( const FredHit &right ) |
---|
73 | { |
---|
74 | pos = right.pos; |
---|
75 | enters = right.enters; |
---|
76 | track = right.track; |
---|
77 | return *this; |
---|
78 | } |
---|
79 | |
---|
80 | // |
---|
81 | // Draw |
---|
82 | // Our standard drawing |
---|
83 | // |
---|
84 | void FredHit::Draw() |
---|
85 | { |
---|
86 | DrawPrim(0); |
---|
87 | } |
---|
88 | |
---|
89 | // |
---|
90 | // DrawShadowHit |
---|
91 | // |
---|
92 | // Special draw mode for drawing tracks that miss the test volume |
---|
93 | // |
---|
94 | void FredHit::DrawShadowHit() |
---|
95 | { |
---|
96 | DrawPrim(1); |
---|
97 | } |
---|
98 | |
---|
99 | // |
---|
100 | // DrawShadowHit |
---|
101 | // |
---|
102 | // Special draw mode for drawing tracks that hit the test volume |
---|
103 | // |
---|
104 | void FredHit::DrawMaskHit() |
---|
105 | { |
---|
106 | DrawPrim(3); |
---|
107 | } |
---|
108 | |
---|
109 | // |
---|
110 | // DrawErrorHit |
---|
111 | // |
---|
112 | // Special draw mode for drawing tracks with tracking errors (bugs) |
---|
113 | // |
---|
114 | void FredHit::DrawErrorHit() |
---|
115 | { |
---|
116 | DrawPrim(2); |
---|
117 | } |
---|
118 | |
---|
119 | // |
---|
120 | // DrawPrim |
---|
121 | // With all this wonderful c++ technology, why is drawing still |
---|
122 | // such a pain?? |
---|
123 | // |
---|
124 | |
---|
125 | void FredHit::DrawPrim(G4int imode) |
---|
126 | { |
---|
127 | // |
---|
128 | // Make sure there is something to draw first |
---|
129 | // |
---|
130 | G4VVisManager *visManager = G4VVisManager::GetConcreteInstance(); |
---|
131 | |
---|
132 | if (visManager) { |
---|
133 | // |
---|
134 | // Heh. Sometimes something bad happens, and we get |
---|
135 | // a point at infinity. Don't draw such a beasty, as it |
---|
136 | // messes up VRML viewing. |
---|
137 | // |
---|
138 | if (pos.mag() > 200.0*m) return; |
---|
139 | |
---|
140 | |
---|
141 | // How about a little circle? |
---|
142 | // |
---|
143 | // I took this from example N04. Note the temporary |
---|
144 | // nature of the "G4VisAttribute". We can do this |
---|
145 | // because circle.SetVisAttributes copies it. |
---|
146 | |
---|
147 | G4Circle circle( pos ); |
---|
148 | if (imode==0) { |
---|
149 | //circle.SetScreenSize( 3.0 ); |
---|
150 | circle.SetWorldSize( 5*cm ); |
---|
151 | G4Color color( enters ? 0:1, enters ? 0:1, 1 ); |
---|
152 | G4VisAttributes attribs( color ); |
---|
153 | circle.SetVisAttributes( attribs ); |
---|
154 | } |
---|
155 | else if (imode==1) { |
---|
156 | circle.SetScreenSize( 2.0 ); |
---|
157 | G4Color color( 0.25, 0.25, 1.0 ); |
---|
158 | G4VisAttributes attribs( color ); |
---|
159 | circle.SetVisAttributes( attribs ); |
---|
160 | } |
---|
161 | else if (imode==2) { |
---|
162 | circle.SetScreenSize( 3.0 ); |
---|
163 | G4Color color( 1.0, 1.0, 1.0 ); |
---|
164 | G4VisAttributes attribs( color ); |
---|
165 | circle.SetVisAttributes( attribs ); |
---|
166 | } |
---|
167 | else if (imode==3) { |
---|
168 | circle.SetScreenSize( 3.0 ); |
---|
169 | G4Color color( 1.0, 0.25, 0.25 ); |
---|
170 | G4VisAttributes attribs( color ); |
---|
171 | circle.SetVisAttributes( attribs ); |
---|
172 | } |
---|
173 | |
---|
174 | circle.SetFillStyle( G4Circle::filled ); |
---|
175 | visManager->Draw( circle ); |
---|
176 | } |
---|
177 | } |
---|
178 | |
---|
179 | // |
---|
180 | // Print |
---|
181 | // |
---|
182 | void FredHit::Print() |
---|
183 | { |
---|
184 | |
---|
185 | // Print the position |
---|
186 | ; |
---|
187 | } |
---|