[1208] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> |
---|
| 2 | <HTML> |
---|
| 3 | <HEAD> |
---|
| 4 | <!-- Created by: Makoto Asai, 27-Nov-2004 --> |
---|
| 5 | |
---|
| 6 | <META NAME="GENERATOR" CONTENT="Mozilla/3.0Gold (X11; I; OSF1 V4.0 alpha) [Netscape]"> |
---|
| 7 | </HEAD> |
---|
| 8 | <BODY> |
---|
| 9 | <TABLE WIDTH="100%" > |
---|
| 10 | <TR> |
---|
| 11 | <TD> |
---|
| 12 | </A> |
---|
| 13 | <A HREF="index.html"> |
---|
| 14 | <IMG SRC="../../../../resources/html/IconsGIF/Contents.gif" ALT="Contents" HEIGHT=16 WIDTH=59></A> |
---|
| 15 | <A HREF="OptionalActions.html"> |
---|
| 16 | <IMG SRC="../../../../resources/html/IconsGIF/Previous.gif" ALT="Previous" HEIGHT=16 WIDTH=59></A> |
---|
| 17 | <A> |
---|
| 18 | <IMG SRC="../../../../resources/html/IconsGIF/NextGR.gif" ALT="Next" HEIGHT=16 WIDTH=59></A> |
---|
| 19 | </TD> |
---|
| 20 | |
---|
| 21 | <TD ALIGN="Right"> |
---|
| 22 | <FONT COLOR="#238E23"><FONT SIZE=-1> |
---|
| 23 | <B>Geant4 User's Guide</B> <BR> |
---|
| 24 | <B>For Application Developers</B> <BR> |
---|
| 25 | <B>User Actions</B> </FONT></FONT> |
---|
| 26 | </TD> |
---|
| 27 | </TR> |
---|
| 28 | </TABLE> |
---|
| 29 | <P><BR> |
---|
| 30 | |
---|
| 31 | <CENTER><FONT COLOR="#238E23"><FONT SIZE=+3> |
---|
| 32 | <B>6.3 User Information Classes</B> |
---|
| 33 | </FONT></FONT> |
---|
| 34 | <BR><BR> |
---|
| 35 | </CENTER> |
---|
| 36 | |
---|
| 37 | <HR ALIGN="Center" SIZE="7%"> |
---|
| 38 | |
---|
| 39 | Additional user information can be associated with various Geant4 classes. |
---|
| 40 | There are basically two ways for the user to do this: |
---|
| 41 | <ul> |
---|
| 42 | <li>derive concrete classes from base classes used in Geant4. |
---|
| 43 | These are classes for run, hit, digit, trajectory and trajectory point, |
---|
| 44 | which are discussed in |
---|
| 45 | <a href="OptionalActions.html">6.2 for G4Run</a>, |
---|
| 46 | <a href="../Detector/hit.html">4.4 for G4VHit</a>, |
---|
| 47 | <a href="../Detector/digitization.html">4.5 for G4VDigit</a>, and |
---|
| 48 | <a href="../TrackingAndPhysics/tracking.html#5.1.6">5.1.6 for G4VTrajectory and G4VTrajectoryPoint</a> |
---|
| 49 | |
---|
| 50 | <li>create concrete classes from provided abstract base classes and |
---|
| 51 | associate them with classes used in Geant4. Geant4 classes which can |
---|
| 52 | accommodate user information classes are G4Event, G4Track, G4PrimaryVertex, |
---|
| 53 | G4PrimaryParticle and G4Region. These classes are discussed here. |
---|
| 54 | </ul> |
---|
| 55 | |
---|
| 56 | <a name="6.3.1"> |
---|
| 57 | <h2>6.3.1 G4VUserEventInformation</h2> |
---|
| 58 | |
---|
| 59 | <i>G4VUserEventInformation</i> is an abstract class from which the user can |
---|
| 60 | derive his/her own concrete class for storing user information associated |
---|
| 61 | with a G4Event class object. It is the user's responsibility to construct a |
---|
| 62 | concrete class object and set the pointer to a proper G4Event object. |
---|
| 63 | <p> |
---|
| 64 | |
---|
| 65 | Within a concrete implementation of G4UserEventAction, the |
---|
| 66 | SetUserEventInformation() method of G4EventManager may be used to set a |
---|
| 67 | pointer of a concrete class object to G4Event, given that the G4Event |
---|
| 68 | object is available only by "pointer to const". |
---|
| 69 | |
---|
| 70 | Alternatively, the user may modify the GenerateEvent() method of his/her |
---|
| 71 | own RunManager to instantiate a G4VUserEventInformation object and |
---|
| 72 | set it to G4Event. |
---|
| 73 | <p> |
---|
| 74 | The concrete class object is deleted by the Geant4 kernel when the |
---|
| 75 | associated G4Event object is deleted. |
---|
| 76 | |
---|
| 77 | <a name="6.3.2"> |
---|
| 78 | <h2>6.3.2 G4VUserTrackInformation</h2> |
---|
| 79 | |
---|
| 80 | This is an abstract class from which the user can derive his/her own |
---|
| 81 | concrete class for storing user information associated with a G4Track |
---|
| 82 | class object. It is the user's responsibility to construct a concrete |
---|
| 83 | class object and set the pointer to the proper G4Track object. |
---|
| 84 | <p> |
---|
| 85 | Within a concrete implementation of G4UserTrackingAction, the |
---|
| 86 | SetUserTrackInformation() method of G4TrackingManager may be used |
---|
| 87 | to set a pointer of a concrete class object to G4Track, |
---|
| 88 | given that the G4Track object is available only by "pointer to const". |
---|
| 89 | <p> |
---|
| 90 | The ideal place to copy a G4VUserTrackInformation object from a mother track |
---|
| 91 | to its daughter tracks is <i>G4UserTrackingAction::PostUserTrackingAction()</i>. |
---|
| 92 | <p> |
---|
| 93 | <center> |
---|
| 94 | <table border=1 cellpadding=10> |
---|
| 95 | <tr> |
---|
| 96 | <td> |
---|
| 97 | <pre> |
---|
| 98 | void RE01TrackingAction::PostUserTrackingAction(const G4Track* aTrack) |
---|
| 99 | { |
---|
| 100 | G4TrackVector* secondaries = fpTrackingManager->GimmeSecondaries(); |
---|
| 101 | if(secondaries) |
---|
| 102 | { |
---|
| 103 | RE01TrackInformation* info = (RE01TrackInformation*)(aTrack->GetUserInformation()); |
---|
| 104 | size_t nSeco = secondaries->size(); |
---|
| 105 | if(nSeco>0) |
---|
| 106 | { |
---|
| 107 | for(size_t i=0; i < nSeco; i++) |
---|
| 108 | { |
---|
| 109 | RE01TrackInformation* infoNew = new RE01TrackInformation(info); |
---|
| 110 | (*secondaries)[i]->SetUserInformation(infoNew); |
---|
| 111 | } |
---|
| 112 | } |
---|
| 113 | } |
---|
| 114 | } |
---|
| 115 | </pre> |
---|
| 116 | </td> |
---|
| 117 | </tr> |
---|
| 118 | <tr> |
---|
| 119 | <td align=center> |
---|
| 120 | Source listing 6.3.1<BR> |
---|
| 121 | <tt>Copying G4VUserTrackInformation from mother to daughter tracks</tt> |
---|
| 122 | </td> |
---|
| 123 | </tr> |
---|
| 124 | </table></center><p> |
---|
| 125 | The concrete class object is deleted by the Geant4 kernel when the |
---|
| 126 | associated G4Track object is deleted. In case the user wants to keep |
---|
| 127 | the information, it should be copied to a trajectory corresponding to |
---|
| 128 | the track. |
---|
| 129 | |
---|
| 130 | <a name="6.3.3"> |
---|
| 131 | <h2>6.3.3 G4VUserPrimaryVertexInformation and G4VUserPrimaryTrackInformation</h2> |
---|
| 132 | |
---|
| 133 | These abstract classes allow the user to attach information regarding the |
---|
| 134 | generated primary vertex and primary particle. Concrete class objects derived |
---|
| 135 | from these classes should be attached to <i>G4PrimaryVertex</i> and |
---|
| 136 | <i>G4PrimaryParticle</i> class objects, respectively. |
---|
| 137 | <p> |
---|
| 138 | The concrete class objects are deleted by the Geant4 Kernel when the |
---|
| 139 | associated G4PrimaryVertex or G4PrimaryParticle class objects are deleted |
---|
| 140 | along with the deletion of G4Event. |
---|
| 141 | |
---|
| 142 | <a name="6.3.4"> |
---|
| 143 | <h2>6.3.4 G4VUserRegionInformation</h2> |
---|
| 144 | |
---|
| 145 | This abstract base class allows the user to attach information associated |
---|
| 146 | with a region. For example, it would be quite beneficial to add some methods |
---|
| 147 | returning a boolean flag to indicate the characteristics of the region |
---|
| 148 | (e.g. tracker, calorimeter, etc.). With this example, the user can easily and |
---|
| 149 | quickly identify the detector component. |
---|
| 150 | <p> |
---|
| 151 | <center> |
---|
| 152 | <table border=1 cellpadding=10> |
---|
| 153 | <tr> |
---|
| 154 | <td> |
---|
| 155 | <pre> |
---|
| 156 | class RE01RegionInformation : public G4VUserRegionInformation |
---|
| 157 | { |
---|
| 158 | public: |
---|
| 159 | RE01RegionInformation(); |
---|
| 160 | ~RE01RegionInformation(); |
---|
| 161 | void Print() const; |
---|
| 162 | |
---|
| 163 | private: |
---|
| 164 | G4bool isWorld; |
---|
| 165 | G4bool isTracker; |
---|
| 166 | G4bool isCalorimeter; |
---|
| 167 | |
---|
| 168 | public: |
---|
| 169 | inline void SetWorld(G4bool v=true) {isWorld = v;} |
---|
| 170 | inline void SetTracker(G4bool v=true) {isTracker = v;} |
---|
| 171 | inline void SetCalorimeter(G4bool v=true) {isCalorimeter = v;} |
---|
| 172 | inline G4bool IsWorld() const {return isWorld;} |
---|
| 173 | inline G4bool IsTracker() const {return isTracker;} |
---|
| 174 | inline G4bool IsCalorimeter() const {return isCalorimeter;} |
---|
| 175 | }; |
---|
| 176 | </pre> |
---|
| 177 | </td> |
---|
| 178 | </tr> |
---|
| 179 | <tr> |
---|
| 180 | <td align=center> |
---|
| 181 | Source listing 6.3.2<BR> |
---|
| 182 | <tt>A sample region information class</tt> |
---|
| 183 | </td> |
---|
| 184 | </tr> |
---|
| 185 | </table></center> |
---|
| 186 | <p> |
---|
| 187 | The following code is an example of a stepping action. Here, a track is |
---|
| 188 | suspended when it enters the "calorimeter region" from the "tracker region". |
---|
| 189 | <p> |
---|
| 190 | <center> |
---|
| 191 | <table border=1 cellpadding=10> |
---|
| 192 | <tr> |
---|
| 193 | <td> |
---|
| 194 | <pre> |
---|
| 195 | void RE01SteppingAction::UserSteppingAction(const G4Step * theStep) |
---|
| 196 | { |
---|
| 197 | // Suspend a track if it is entering into the calorimeter |
---|
| 198 | |
---|
| 199 | // check if it is alive |
---|
| 200 | G4Track * theTrack = theStep->GetTrack(); |
---|
| 201 | if(theTrack->GetTrackStatus()!=fAlive) { return; } |
---|
| 202 | |
---|
| 203 | // get region information |
---|
| 204 | G4StepPoint * thePrePoint = theStep->GetPreStepPoint(); |
---|
| 205 | G4LogicalVolume * thePreLV = thePrePoint->GetPhysicalVolume()->GetLogicalVolume(); |
---|
| 206 | RE01RegionInformation* thePreRInfo |
---|
| 207 | = (RE01RegionInformation*)(thePreLV->GetRegion()->GetUserInformation()); |
---|
| 208 | G4StepPoint * thePostPoint = theStep->GetPostStepPoint(); |
---|
| 209 | G4LogicalVolume * thePostLV = thePostPoint->GetPhysicalVolume()->GetLogicalVolume(); |
---|
| 210 | RE01RegionInformation* thePostRInfo |
---|
| 211 | = (RE01RegionInformation*)(thePostLV->GetRegion()->GetUserInformation()); |
---|
| 212 | |
---|
| 213 | // check if it is entering to the calorimeter volume |
---|
| 214 | if(!(thePreRInfo->IsCalorimeter()) && (thePostRInfo->IsCalorimeter())) |
---|
| 215 | { theTrack->SetTrackStatus(fSuspend); } |
---|
| 216 | } |
---|
| 217 | </pre> |
---|
| 218 | </td> |
---|
| 219 | </tr> |
---|
| 220 | <tr> |
---|
| 221 | <td align=center> |
---|
| 222 | Source listing 6.3.2<BR> |
---|
| 223 | <tt>Sample use of a region information class</tt> |
---|
| 224 | </td> |
---|
| 225 | </tr> |
---|
| 226 | </table></center> |
---|
| 227 | |
---|
| 228 | <BR><BR> |
---|
| 229 | <HR><A HREF="../../../../Authors/html/subjectsToAuthors.html"> |
---|
| 230 | <I>About the authors</A></I> </P></CENTER> |
---|
| 231 | |
---|
| 232 | </BODY> |
---|
| 233 | </HTML> |
---|