source: trunk/documents/UserDoc/DocBookUsersGuides/ForApplicationDeveloper/xml/UserActions/userInformationClasses.xml @ 1208

Last change on this file since 1208 was 904, checked in by garnier, 16 years ago

ajout de la doc

File size: 7.6 KB
Line 
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>
13User Information Classes
14</title>
15
16<para>
17Additional user information can be associated with various Geant4
18classes. 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>
44G4VUserEventInformation
45</title>
46
47<para>
48<emphasis>G4VUserEventInformation</emphasis> is an abstract class from
49which the user can derive his/her own concrete class for storing user
50information associated with a G4Event class object. It is the
51user's responsibility to construct a concrete class object and set
52the pointer to a proper G4Event object.
53</para>
54
55<para>
56Within a concrete implementation of G4UserEventAction, the
57SetUserEventInformation() method of G4EventManager may be used to
58set a pointer of a concrete class object to G4Event, given that the
59G4Event object is available only by "pointer to const".
60Alternatively, the user may modify the GenerateEvent() method of
61his/her own RunManager to instantiate a G4VUserEventInformation
62object and set it to G4Event.
63</para>
64
65<para>
66The concrete class object is deleted by the Geant4 kernel when
67the associated G4Event object is deleted.
68</para>
69
70</sect2>
71
72
73<!-- ******************* Section (Level#2) ****************** -->
74<sect2 id="sect.UInfoCls.UTkInfo">
75<title>
76G4VUserTrackInformation
77</title>
78
79<para>
80This is an abstract class from which the user can derive his/her
81own concrete class for storing user information associated with a
82G4Track class object. It is the user's responsibility to construct
83a concrete class object and set the pointer to the proper G4Track
84object.
85</para>
86
87<para>
88Within a concrete implementation of G4UserTrackingAction, the
89SetUserTrackInformation() method of G4TrackingManager may be used
90to set a pointer of a concrete class object to G4Track, given that
91the G4Track object is available only by "pointer to const".
92</para>
93
94<para>
95The ideal place to copy a G4VUserTrackInformation object from a
96mother track to its daughter tracks is
97<emphasis>G4UserTrackingAction::PostUserTrackingAction()</emphasis>.
98
99<example id="programlist_UInfoCls_1">
100<title>
101Copying <literal>G4VUserTrackInformation</literal> from mother to daughter tracks
102</title>
103
104<programlisting>
105void RE01TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
106{
107  G4TrackVector* secondaries = fpTrackingManager-&gt;GimmeSecondaries();
108  if(secondaries)
109  {
110    RE01TrackInformation* info = (RE01TrackInformation*)(aTrack-&gt;GetUserInformation());
111    size_t nSeco = secondaries-&gt;size();
112    if(nSeco&gt;0)
113    {
114      for(size_t i=0; i &lt; nSeco; i++)
115      {
116        RE01TrackInformation* infoNew = new RE01TrackInformation(info);
117        (*secondaries)[i]-&gt;SetUserInformation(infoNew);
118      }
119    }
120  }
121}
122</programlisting>
123</example>
124</para>
125
126<para>
127The concrete class object is deleted by the Geant4 kernel when
128the associated G4Track object is deleted. In case the user wants to
129keep the information, it should be copied to a trajectory
130corresponding to the track.
131</para>
132
133</sect2>
134
135
136<!-- ******************* Section (Level#2) ****************** -->
137<sect2 id="sect.UInfoCls.UPrimVxTk">
138<title>
139G4VUserPrimaryVertexInformation and G4VUserPrimaryTrackInformation
140</title>
141
142<para>
143These abstract classes allow the user to attach information
144regarding the generated primary vertex and primary particle.
145Concrete class objects derived from these classes should be
146attached to <emphasis>G4PrimaryVertex</emphasis> and
147<emphasis>G4PrimaryParticle</emphasis> class objects, respectively.
148</para>
149
150<para>
151The concrete class objects are deleted by the Geant4 Kernel when
152the associated G4PrimaryVertex or G4PrimaryParticle class objects
153are 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>
162G4VUserRegionInformation
163</title>
164
165<para>
166This abstract base class allows the user to attach information
167associated with a region. For example, it would be quite beneficial
168to add some methods returning a boolean flag to indicate the
169characteristics of the region (e.g. tracker, calorimeter, etc.).
170With this example, the user can easily and quickly identify the
171detector component.
172
173<example id="programlist_UInfoCls_2">
174<title>
175A sample region information class
176</title>
177
178<programlisting>
179class 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>
204The following code is an example of a stepping action. Here, a
205track is suspended when it enters the "calorimeter region" from the
206"tracker region".
207
208<example id="programlist_UInfoCls_3">
209<title>
210Sample use of a region information class
211</title>
212
213<programlisting>
214void 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-&gt;GetTrack();
220  if(theTrack-&gt;GetTrackStatus()!=fAlive) { return; }
221
222  // get region information
223  G4StepPoint * thePrePoint = theStep-&gt;GetPreStepPoint();
224  G4LogicalVolume * thePreLV = thePrePoint-&gt;GetPhysicalVolume()-&gt;GetLogicalVolume();
225  RE01RegionInformation* thePreRInfo
226   = (RE01RegionInformation*)(thePreLV-&gt;GetRegion()-&gt;GetUserInformation());
227  G4StepPoint * thePostPoint = theStep-&gt;GetPostStepPoint();
228  G4LogicalVolume * thePostLV = thePostPoint-&gt;GetPhysicalVolume()-&gt;GetLogicalVolume();
229  RE01RegionInformation* thePostRInfo
230   = (RE01RegionInformation*)(thePostLV-&gt;GetRegion()-&gt;GetUserInformation());
231
232  // check if it is entering to the calorimeter volume
233  if(!(thePreRInfo-&gt;IsCalorimeter()) &amp;&amp; (thePostRInfo-&gt;IsCalorimeter()))
234  { theTrack-&gt;SetTrackStatus(fSuspend); }
235}
236</programlisting>
237</example>
238</para>
239
240
241</sect2>
242</sect1>
Note: See TracBrowser for help on using the repository browser.