1 | <!-- ******************************************************** --> |
---|
2 | <!-- --> |
---|
3 | <!-- [History] --> |
---|
4 | <!-- Created by: Makoto Asai, 27-Nov-2004 --> |
---|
5 | <!-- Converted to DocBook: Katsuya Amako, Aug-2006 --> |
---|
6 | <!-- --> |
---|
7 | <!-- ******************************************************** --> |
---|
8 | |
---|
9 | |
---|
10 | <!-- ******************* Section (Level#1) ****************** --> |
---|
11 | <sect1 id="sect.UInfoCls"> |
---|
12 | <title> |
---|
13 | User Information Classes |
---|
14 | </title> |
---|
15 | |
---|
16 | <para> |
---|
17 | Additional user information can be associated with various Geant4 |
---|
18 | classes. There are basically two ways for the user to do this: |
---|
19 | |
---|
20 | <itemizedlist spacing="compact"> |
---|
21 | <listitem><para> |
---|
22 | derive concrete classes from base classes used in Geant4. These |
---|
23 | are classes for run, hit, digit, trajectory and trajectory point, |
---|
24 | which are discussed in |
---|
25 | <xref linkend="sect.OptUAct" /> for G4Run, |
---|
26 | <xref linkend="sect.Hits" /> for G4VHit, |
---|
27 | <xref linkend="sect.Digi" /> for G4VDigit, and |
---|
28 | <xref linkend="sect.Track.Traj" /> for G4VTrajectory and G4VTrajectoryPoint |
---|
29 | </para></listitem> |
---|
30 | <listitem><para> |
---|
31 | create concrete classes from provided abstract base classes and |
---|
32 | associate them with classes used in Geant4. Geant4 classes which |
---|
33 | can accommodate user information classes are G4Event, G4Track, |
---|
34 | G4PrimaryVertex, G4PrimaryParticle and G4Region. These classes are |
---|
35 | discussed here. |
---|
36 | </para></listitem> |
---|
37 | </itemizedlist> |
---|
38 | </para> |
---|
39 | |
---|
40 | |
---|
41 | <!-- ******************* Section (Level#2) ****************** --> |
---|
42 | <sect2 id="sect.UInfoCls.UEvtInfo"> |
---|
43 | <title> |
---|
44 | G4VUserEventInformation |
---|
45 | </title> |
---|
46 | |
---|
47 | <para> |
---|
48 | <emphasis>G4VUserEventInformation</emphasis> is an abstract class from |
---|
49 | which the user can derive his/her own concrete class for storing user |
---|
50 | information associated with a G4Event class object. It is the |
---|
51 | user's responsibility to construct a concrete class object and set |
---|
52 | the pointer to a proper G4Event object. |
---|
53 | </para> |
---|
54 | |
---|
55 | <para> |
---|
56 | Within a concrete implementation of G4UserEventAction, the |
---|
57 | SetUserEventInformation() method of G4EventManager may be used to |
---|
58 | set a pointer of a concrete class object to G4Event, given that the |
---|
59 | G4Event object is available only by "pointer to const". |
---|
60 | Alternatively, the user may modify the GenerateEvent() method of |
---|
61 | his/her own RunManager to instantiate a G4VUserEventInformation |
---|
62 | object and set it to G4Event. |
---|
63 | </para> |
---|
64 | |
---|
65 | <para> |
---|
66 | The concrete class object is deleted by the Geant4 kernel when |
---|
67 | the associated G4Event object is deleted. |
---|
68 | </para> |
---|
69 | |
---|
70 | </sect2> |
---|
71 | |
---|
72 | |
---|
73 | <!-- ******************* Section (Level#2) ****************** --> |
---|
74 | <sect2 id="sect.UInfoCls.UTkInfo"> |
---|
75 | <title> |
---|
76 | G4VUserTrackInformation |
---|
77 | </title> |
---|
78 | |
---|
79 | <para> |
---|
80 | This is an abstract class from which the user can derive his/her |
---|
81 | own concrete class for storing user information associated with a |
---|
82 | G4Track class object. It is the user's responsibility to construct |
---|
83 | a concrete class object and set the pointer to the proper G4Track |
---|
84 | object. |
---|
85 | </para> |
---|
86 | |
---|
87 | <para> |
---|
88 | Within a concrete implementation of G4UserTrackingAction, the |
---|
89 | SetUserTrackInformation() method of G4TrackingManager may be used |
---|
90 | to set a pointer of a concrete class object to G4Track, given that |
---|
91 | the G4Track object is available only by "pointer to const". |
---|
92 | </para> |
---|
93 | |
---|
94 | <para> |
---|
95 | The ideal place to copy a G4VUserTrackInformation object from a |
---|
96 | mother track to its daughter tracks is |
---|
97 | <emphasis>G4UserTrackingAction::PostUserTrackingAction()</emphasis>. |
---|
98 | |
---|
99 | <example id="programlist_UInfoCls_1"> |
---|
100 | <title> |
---|
101 | Copying <literal>G4VUserTrackInformation</literal> from mother to daughter tracks |
---|
102 | </title> |
---|
103 | |
---|
104 | <programlisting> |
---|
105 | void RE01TrackingAction::PostUserTrackingAction(const G4Track* aTrack) |
---|
106 | { |
---|
107 | G4TrackVector* secondaries = fpTrackingManager->GimmeSecondaries(); |
---|
108 | if(secondaries) |
---|
109 | { |
---|
110 | RE01TrackInformation* info = (RE01TrackInformation*)(aTrack->GetUserInformation()); |
---|
111 | size_t nSeco = secondaries->size(); |
---|
112 | if(nSeco>0) |
---|
113 | { |
---|
114 | for(size_t i=0; i < nSeco; i++) |
---|
115 | { |
---|
116 | RE01TrackInformation* infoNew = new RE01TrackInformation(info); |
---|
117 | (*secondaries)[i]->SetUserInformation(infoNew); |
---|
118 | } |
---|
119 | } |
---|
120 | } |
---|
121 | } |
---|
122 | </programlisting> |
---|
123 | </example> |
---|
124 | </para> |
---|
125 | |
---|
126 | <para> |
---|
127 | The concrete class object is deleted by the Geant4 kernel when |
---|
128 | the associated G4Track object is deleted. In case the user wants to |
---|
129 | keep the information, it should be copied to a trajectory |
---|
130 | corresponding to the track. |
---|
131 | </para> |
---|
132 | |
---|
133 | </sect2> |
---|
134 | |
---|
135 | |
---|
136 | <!-- ******************* Section (Level#2) ****************** --> |
---|
137 | <sect2 id="sect.UInfoCls.UPrimVxTk"> |
---|
138 | <title> |
---|
139 | G4VUserPrimaryVertexInformation and G4VUserPrimaryTrackInformation |
---|
140 | </title> |
---|
141 | |
---|
142 | <para> |
---|
143 | These abstract classes allow the user to attach information |
---|
144 | regarding the generated primary vertex and primary particle. |
---|
145 | Concrete class objects derived from these classes should be |
---|
146 | attached to <emphasis>G4PrimaryVertex</emphasis> and |
---|
147 | <emphasis>G4PrimaryParticle</emphasis> class objects, respectively. |
---|
148 | </para> |
---|
149 | |
---|
150 | <para> |
---|
151 | The concrete class objects are deleted by the Geant4 Kernel when |
---|
152 | the associated G4PrimaryVertex or G4PrimaryParticle class objects |
---|
153 | are deleted along with the deletion of G4Event. |
---|
154 | </para> |
---|
155 | |
---|
156 | </sect2> |
---|
157 | |
---|
158 | |
---|
159 | <!-- ******************* Section (Level#2) ****************** --> |
---|
160 | <sect2 id="sect.UInfoCls.URegInfo"> |
---|
161 | <title> |
---|
162 | G4VUserRegionInformation |
---|
163 | </title> |
---|
164 | |
---|
165 | <para> |
---|
166 | This abstract base class allows the user to attach information |
---|
167 | associated with a region. For example, it would be quite beneficial |
---|
168 | to add some methods returning a boolean flag to indicate the |
---|
169 | characteristics of the region (e.g. tracker, calorimeter, etc.). |
---|
170 | With this example, the user can easily and quickly identify the |
---|
171 | detector component. |
---|
172 | |
---|
173 | <example id="programlist_UInfoCls_2"> |
---|
174 | <title> |
---|
175 | A sample region information class |
---|
176 | </title> |
---|
177 | |
---|
178 | <programlisting> |
---|
179 | class RE01RegionInformation : public G4VUserRegionInformation |
---|
180 | { |
---|
181 | public: |
---|
182 | RE01RegionInformation(); |
---|
183 | ~RE01RegionInformation(); |
---|
184 | void Print() const; |
---|
185 | |
---|
186 | private: |
---|
187 | G4bool isWorld; |
---|
188 | G4bool isTracker; |
---|
189 | G4bool isCalorimeter; |
---|
190 | |
---|
191 | public: |
---|
192 | inline void SetWorld(G4bool v=true) {isWorld = v;} |
---|
193 | inline void SetTracker(G4bool v=true) {isTracker = v;} |
---|
194 | inline void SetCalorimeter(G4bool v=true) {isCalorimeter = v;} |
---|
195 | inline G4bool IsWorld() const {return isWorld;} |
---|
196 | inline G4bool IsTracker() const {return isTracker;} |
---|
197 | inline G4bool IsCalorimeter() const {return isCalorimeter;} |
---|
198 | }; |
---|
199 | </programlisting> |
---|
200 | </example> |
---|
201 | </para> |
---|
202 | |
---|
203 | <para> |
---|
204 | The following code is an example of a stepping action. Here, a |
---|
205 | track is suspended when it enters the "calorimeter region" from the |
---|
206 | "tracker region". |
---|
207 | |
---|
208 | <example id="programlist_UInfoCls_3"> |
---|
209 | <title> |
---|
210 | Sample use of a region information class |
---|
211 | </title> |
---|
212 | |
---|
213 | <programlisting> |
---|
214 | void RE01SteppingAction::UserSteppingAction(const G4Step * theStep) |
---|
215 | { |
---|
216 | // Suspend a track if it is entering into the calorimeter |
---|
217 | |
---|
218 | // check if it is alive |
---|
219 | G4Track * theTrack = theStep->GetTrack(); |
---|
220 | if(theTrack->GetTrackStatus()!=fAlive) { return; } |
---|
221 | |
---|
222 | // get region information |
---|
223 | G4StepPoint * thePrePoint = theStep->GetPreStepPoint(); |
---|
224 | G4LogicalVolume * thePreLV = thePrePoint->GetPhysicalVolume()->GetLogicalVolume(); |
---|
225 | RE01RegionInformation* thePreRInfo |
---|
226 | = (RE01RegionInformation*)(thePreLV->GetRegion()->GetUserInformation()); |
---|
227 | G4StepPoint * thePostPoint = theStep->GetPostStepPoint(); |
---|
228 | G4LogicalVolume * thePostLV = thePostPoint->GetPhysicalVolume()->GetLogicalVolume(); |
---|
229 | RE01RegionInformation* thePostRInfo |
---|
230 | = (RE01RegionInformation*)(thePostLV->GetRegion()->GetUserInformation()); |
---|
231 | |
---|
232 | // check if it is entering to the calorimeter volume |
---|
233 | if(!(thePreRInfo->IsCalorimeter()) && (thePostRInfo->IsCalorimeter())) |
---|
234 | { theTrack->SetTrackStatus(fSuspend); } |
---|
235 | } |
---|
236 | </programlisting> |
---|
237 | </example> |
---|
238 | </para> |
---|
239 | |
---|
240 | |
---|
241 | </sect2> |
---|
242 | </sect1> |
---|