| 1 | <!-- ******************************************************** -->
|
|---|
| 2 | <!-- -->
|
|---|
| 3 | <!-- [History] -->
|
|---|
| 4 | <!-- Converted to DocBook: Katsuya Amako, Aug-2006 -->
|
|---|
| 5 | <!-- Changed by: Dennis Wright, 25-Jun-2002 -->
|
|---|
| 6 | <!-- -->
|
|---|
| 7 | <!-- ******************************************************** -->
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 | <!-- ******************* Section (Level#1) ****************** -->
|
|---|
| 11 | <sect1 id="sect.EvtBias">
|
|---|
| 12 | <title>
|
|---|
| 13 | Event Biasing Techniques
|
|---|
| 14 | </title>
|
|---|
| 15 |
|
|---|
| 16 | <!-- ******************* Section (Level#2) ****************** -->
|
|---|
| 17 | <sect2 id="sect.EvtBias.ScorImpRoul">
|
|---|
| 18 | <title>
|
|---|
| 19 | Scoring, Geometrical Importance Sampling and Weight Roulette
|
|---|
| 20 | </title>
|
|---|
| 21 |
|
|---|
| 22 | <para>
|
|---|
| 23 | Geant4 provides event biasing techniques which may be used to save
|
|---|
| 24 | computing time in such applications as the simulation of radiation
|
|---|
| 25 | shielding. These are <emphasis>geometrical splitting
|
|---|
| 26 | </emphasis> and <emphasis>Russian roulette</emphasis>
|
|---|
| 27 | (also called geometrical importance sampling), and
|
|---|
| 28 | <emphasis>weight roulette</emphasis>. Scoring is carried out by <emphasis>G4MultiFunctionalDetector</emphasis> (see <xref
|
|---|
| 29 | linkend="sect.Hits.G4Multi" /> and <xref linkend="sect.Hits.G4VPrim" />) using the standard Geant4 scoring technique.
|
|---|
| 30 | Biasing specific scorers have been implemented and are described within
|
|---|
| 31 | <emphasis>G4MultiFunctionDetector</emphasis> documentation. In this chapter, it is assumed that
|
|---|
| 32 | the reader is familiar with both the usage of Geant4 and the
|
|---|
| 33 | concepts of importance sampling. More detailed documentation may be
|
|---|
| 34 | found in the documents
|
|---|
| 35 | <ulink url="http://geant4.web.cern.ch/geant4/collaboration/working_groups/geometry/index.shtml">
|
|---|
| 36 | 'Latest development in importance sampling and scoring'
|
|---|
| 37 | </ulink>.
|
|---|
| 38 | A detailed description of different use-cases which employ the sampling
|
|---|
| 39 | and scoring techniques can be found in the document
|
|---|
| 40 | <ulink url="http://geant4.web.cern.ch/geant4/collaboration/working_groups/geometry/index.shtml">
|
|---|
| 41 | 'Scoring and geometrical importance sampling use cases'
|
|---|
| 42 | </ulink>.
|
|---|
| 43 | </para>
|
|---|
| 44 |
|
|---|
| 45 | <para>
|
|---|
| 46 | The purpose of importance sampling is to save computing time by
|
|---|
| 47 | sampling less often the particle histories entering "less
|
|---|
| 48 | important" geometry regions, and more often in more "important"
|
|---|
| 49 | regions. Given the same amount of computing time, an
|
|---|
| 50 | importance-sampled and an analogue-sampled simulation must show
|
|---|
| 51 | equal mean values, while the importance-sampled simulation will
|
|---|
| 52 | have a decreased variance.
|
|---|
| 53 | </para>
|
|---|
| 54 |
|
|---|
| 55 | <para>
|
|---|
| 56 | The implementation of scoring is independent of the implementation
|
|---|
| 57 | of importance sampling. However both share common concepts.
|
|---|
| 58 | <emphasis>Scoring and importance sampling apply to particle types chosen
|
|---|
| 59 | by the user</emphasis>, which should be borne in mind when interpreting the
|
|---|
| 60 | output of any biased simulation.
|
|---|
| 61 | </para>
|
|---|
| 62 |
|
|---|
| 63 | <para>
|
|---|
| 64 | Examples on how to use scoring and importance sampling may be found
|
|---|
| 65 | in <literal>examples/extended/biasing</literal> and
|
|---|
| 66 | <literal>examples/advanced/Tiara</literal>.
|
|---|
| 67 | </para>
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 | <!-- ******************* Section (Level#3) ****************** -->
|
|---|
| 71 | <sect3 id="sect.EvtBias.ScorImpRoul.Geom">
|
|---|
| 72 | <title>
|
|---|
| 73 | Geometries
|
|---|
| 74 | </title>
|
|---|
| 75 |
|
|---|
| 76 | <para>
|
|---|
| 77 | The kind of scoring referred to in this note and the importance
|
|---|
| 78 | sampling apply to spatial cells provided by the user.
|
|---|
| 79 | </para>
|
|---|
| 80 |
|
|---|
| 81 | <para>
|
|---|
| 82 | A <emphasis role="bold">cell</emphasis> is a physical volume (further specified
|
|---|
| 83 | by it's replica number, if the volume is a replica). Cells may be defined
|
|---|
| 84 | in two kinds of geometries:
|
|---|
| 85 |
|
|---|
| 86 | <orderedlist spacing="compact">
|
|---|
| 87 | <listitem><para>
|
|---|
| 88 | <emphasis role="bold">mass geometry</emphasis>: the geometry setup of the
|
|---|
| 89 | experiment to be simulated. Physics processes apply to this geometry.
|
|---|
| 90 | </para></listitem>
|
|---|
| 91 | <listitem><para>
|
|---|
| 92 | <emphasis role="bold">parallel-geometry</emphasis>: a geometry constructed
|
|---|
| 93 | to define the physical volumes according to which scoring and/or importance
|
|---|
| 94 | sampling is applied.
|
|---|
| 95 | </para></listitem>
|
|---|
| 96 | </orderedlist>
|
|---|
| 97 | </para>
|
|---|
| 98 |
|
|---|
| 99 | <para>
|
|---|
| 100 | The user has the choice to score and/or sample by importance the
|
|---|
| 101 | particles of the chosen type, according to mass geometry or to
|
|---|
| 102 | parallel geometry. It is possible to utilize several parallel
|
|---|
| 103 | geometries in addition to the mass geometry. This provides the user
|
|---|
| 104 | with a lot of flexibility to define separate geometries for
|
|---|
| 105 | different particle types in order to apply scoring or/and
|
|---|
| 106 | importance sampling.
|
|---|
| 107 | </para>
|
|---|
| 108 |
|
|---|
| 109 | <para>
|
|---|
| 110 | <note>
|
|---|
| 111 | Parallel geometries should be constructed using the implementation as
|
|---|
| 112 | described in <xref linkend="sect.ParaGeom"/>.
|
|---|
| 113 |
|
|---|
| 114 | There are a few conditions for parallel geometries:
|
|---|
| 115 |
|
|---|
| 116 | <itemizedlist spacing="compact">
|
|---|
| 117 | <listitem><para>
|
|---|
| 118 | The world volume for parallel and mass geometries must be identical copies.
|
|---|
| 119 | </para></listitem>
|
|---|
| 120 | <listitem><para>
|
|---|
| 121 | Scoring and importance cells must not share boundaries with the world volume.
|
|---|
| 122 | </para></listitem>
|
|---|
| 123 | </itemizedlist>
|
|---|
| 124 | </note>
|
|---|
| 125 | </para>
|
|---|
| 126 |
|
|---|
| 127 | </sect3>
|
|---|
| 128 |
|
|---|
| 129 | <!-- ******************* Section (Level#3) ****************** -->
|
|---|
| 130 | <sect3 id="sect.EvtBias.ScorImpRoul.ChgSamp">
|
|---|
| 131 | <title>
|
|---|
| 132 | Changing the Sampling
|
|---|
| 133 | </title>
|
|---|
| 134 |
|
|---|
| 135 | <para>
|
|---|
| 136 | Samplers are higher level tools which perform the necessary
|
|---|
| 137 | changes of the Geant4 sampling in order to apply importance
|
|---|
| 138 | sampling and weight roulette.
|
|---|
| 139 | </para>
|
|---|
| 140 |
|
|---|
| 141 | <para>
|
|---|
| 142 | Variance reduction (and scoring through the
|
|---|
| 143 | <emphasis>G4MultiFunctionalDetector</emphasis>)
|
|---|
| 144 | may be combined arbitrarily for chosen particle types and may be applied to the
|
|---|
| 145 | mass or to parallel geometries.
|
|---|
| 146 | </para>
|
|---|
| 147 |
|
|---|
| 148 | <para>
|
|---|
| 149 | The <literal>G4GeometrySampler</literal> can be applied equally to mass or
|
|---|
| 150 | parallel geometries with an abstract interface supplied by <literal>G4VSampler</literal>.
|
|---|
| 151 | <literal>G4VSampler</literal> provides
|
|---|
| 152 | <literal>Prepare...</literal> methods and a <literal>Configure</literal>
|
|---|
| 153 | method:
|
|---|
| 154 |
|
|---|
| 155 | <anchor id="anchor_EvtBias_G4VSampler" />
|
|---|
| 156 | <informalexample>
|
|---|
| 157 | <programlisting>
|
|---|
| 158 | class G4VSampler
|
|---|
| 159 | {
|
|---|
| 160 | public:
|
|---|
| 161 | G4VSampler();
|
|---|
| 162 | virtual ~G4VSampler();
|
|---|
| 163 | virtual void PrepareImportanceSampling(G4VIStore *istore,
|
|---|
| 164 | const G4VImportanceAlgorithm
|
|---|
| 165 | *ialg = 0) = 0;
|
|---|
| 166 | virtual void PrepareWeightRoulett(G4double wsurvive = 0.5,
|
|---|
| 167 | G4double wlimit = 0.25,
|
|---|
| 168 | G4double isource = 1) = 0;
|
|---|
| 169 | virtual void PrepareWeightWindow(G4VWeightWindowStore *wwstore,
|
|---|
| 170 | G4VWeightWindowAlgorithm *wwAlg = 0,
|
|---|
| 171 | G4PlaceOfAction placeOfAction =
|
|---|
| 172 | onBoundary) = 0;
|
|---|
| 173 | virtual void Configure() = 0;
|
|---|
| 174 | virtual void ClearSampling() = 0;
|
|---|
| 175 | virtual G4bool IsConfigured() const = 0;
|
|---|
| 176 | };
|
|---|
| 177 | </programlisting>
|
|---|
| 178 | </informalexample>
|
|---|
| 179 | </para>
|
|---|
| 180 |
|
|---|
| 181 | <para>
|
|---|
| 182 | The methods for setting up the desired combination need specific
|
|---|
| 183 | information:
|
|---|
| 184 |
|
|---|
| 185 | <itemizedlist spacing="compact">
|
|---|
| 186 | <listitem><para>
|
|---|
| 187 | Importance sampling: message <literal>PrepareImportanceSampling</literal>
|
|---|
| 188 | with a
|
|---|
| 189 | <link linkend="anchor_EvtBias_G4VIStore">
|
|---|
| 190 | <literal>G4VIStore</literal></link>
|
|---|
| 191 | and optionally a <literal>G4VImportanceAlgorithm</literal>
|
|---|
| 192 | </para></listitem>
|
|---|
| 193 | <listitem><para>
|
|---|
| 194 | Weight window: message <literal>PrepareWeightWindow</literal> with the
|
|---|
| 195 | arguments:
|
|---|
| 196 | <itemizedlist spacing="compact">
|
|---|
| 197 | <listitem><para>
|
|---|
| 198 | <emphasis>*wwstore</emphasis>: a
|
|---|
| 199 | <literal>G4VWeightWindowStore</literal> for retrieving the lower
|
|---|
| 200 | weight bounds for the energy-space cells
|
|---|
| 201 | </para></listitem>
|
|---|
| 202 | <listitem><para>
|
|---|
| 203 | <emphasis>*wwAlg</emphasis>: a
|
|---|
| 204 | <literal>G4VWeightWindowAlgorithm</literal> if a customized algorithm
|
|---|
| 205 | should be used
|
|---|
| 206 | </para></listitem>
|
|---|
| 207 | <listitem><para>
|
|---|
| 208 | <emphasis>placeOfAction</emphasis>: a
|
|---|
| 209 | <literal>G4PlaceOfAction</literal> specifying where to perform the
|
|---|
| 210 | biasing
|
|---|
| 211 | </para></listitem>
|
|---|
| 212 | </itemizedlist>
|
|---|
| 213 | </para></listitem>
|
|---|
| 214 | <listitem><para>
|
|---|
| 215 | Weight roulette: message <literal>PrepareWeightRoulett</literal> with the
|
|---|
| 216 | optional parameters:
|
|---|
| 217 | <itemizedlist spacing="compact">
|
|---|
| 218 | <listitem><para>
|
|---|
| 219 | <emphasis>wsurvive</emphasis>: survival weight
|
|---|
| 220 | </para></listitem>
|
|---|
| 221 | <listitem><para>
|
|---|
| 222 | <emphasis>wlimit</emphasis>: minimal allowed
|
|---|
| 223 | value of weight * source importance / cell importance
|
|---|
| 224 | </para></listitem>
|
|---|
| 225 | <listitem><para>
|
|---|
| 226 | <emphasis>isource</emphasis>: importance of the source cell
|
|---|
| 227 | </para></listitem>
|
|---|
| 228 | </itemizedlist>
|
|---|
| 229 | </para></listitem>
|
|---|
| 230 | </itemizedlist>
|
|---|
| 231 | </para>
|
|---|
| 232 |
|
|---|
| 233 | <para>
|
|---|
| 234 | Each object of a sampler class is responsible for one particle
|
|---|
| 235 | type. The particle type is given to the constructor of the sampler
|
|---|
| 236 | classes via the particle type name, e.g. "neutron". Depending on
|
|---|
| 237 | the specific purpose, the <literal>Configure()</literal> of a sampler will
|
|---|
| 238 | set up specialized processes (derived from <literal>G4VProcess</literal>) for
|
|---|
| 239 | transportation in the parallel geometry, importance
|
|---|
| 240 | sampling and weight roulette for the given particle type. When
|
|---|
| 241 | <literal>Configure()</literal> is invoked the sampler places the processes in
|
|---|
| 242 | the correct order independent of the order in which user invoked
|
|---|
| 243 | the <literal>Prepare...</literal> methods.
|
|---|
| 244 | </para>
|
|---|
| 245 |
|
|---|
| 246 | <para>
|
|---|
| 247 | <note>
|
|---|
| 248 | <para>
|
|---|
| 249 | <itemizedlist spacing="compact">
|
|---|
| 250 | <listitem><para>
|
|---|
| 251 | The <literal>Prepare...()</literal> functions may each only be invoked
|
|---|
| 252 | once.
|
|---|
| 253 | </para></listitem>
|
|---|
| 254 | <listitem><para>
|
|---|
| 255 | To configure the sampling the function <literal>Configure()</literal>
|
|---|
| 256 | must be called <emphasis>after</emphasis> the
|
|---|
| 257 | <literal>G4RunManager</literal> has been initialized and the PhysicsList has
|
|---|
| 258 | been instantiated.
|
|---|
| 259 | </para></listitem>
|
|---|
| 260 | </itemizedlist>
|
|---|
| 261 | </para>
|
|---|
| 262 | </note>
|
|---|
| 263 | </para>
|
|---|
| 264 |
|
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 268 | <para>
|
|---|
| 269 | The interface and framework are demonstrated in the
|
|---|
| 270 | <literal>examples/extended/biasing</literal> directory, with the main changes being to the
|
|---|
| 271 | G4GeometrySampler class and the fact that in the parallel case the WorldVolume
|
|---|
| 272 | is a copy of the Mass World.
|
|---|
| 273 |
|
|---|
| 274 | The parallel geometry now has to inherit from
|
|---|
| 275 | <emphasis>G4VUserParallelWorld</emphasis> which also has the <emphasis>GetWorld()</emphasis> method
|
|---|
| 276 | in order to retrieve a copy of the mass geometry WorldVolume.
|
|---|
| 277 |
|
|---|
| 278 | <informalexample>
|
|---|
| 279 | <programlisting>
|
|---|
| 280 | class B02ImportanceDetectorConstruction : public G4VUserParallelWorld
|
|---|
| 281 | ghostWorld = GetWorld();
|
|---|
| 282 | </programlisting>
|
|---|
| 283 | </informalexample>
|
|---|
| 284 |
|
|---|
| 285 | </para>
|
|---|
| 286 |
|
|---|
| 287 | <para>
|
|---|
| 288 | The constructor for <emphasis>G4GeometrySampler</emphasis> takes a pointer to
|
|---|
| 289 | the physical world volume and the particle type name (e.g. "neutron") as arguments.
|
|---|
| 290 | In a single mass geometry the sampler is created as follows:
|
|---|
| 291 |
|
|---|
| 292 | <informalexample>
|
|---|
| 293 | <programlisting>
|
|---|
| 294 | G4GeometrySampler mgs(detector->GetWorldVolume(),"neutron");
|
|---|
| 295 | mgs.SetParallel(false);
|
|---|
| 296 | </programlisting>
|
|---|
| 297 | </informalexample>
|
|---|
| 298 |
|
|---|
| 299 |
|
|---|
| 300 | Whilst the following lines of code are required in order to set up the sampler for the
|
|---|
| 301 | parallel geometry case:
|
|---|
| 302 |
|
|---|
| 303 | <informalexample>
|
|---|
| 304 | <programlisting>
|
|---|
| 305 | G4VPhysicalVolume* ghostWorld = pdet->GetWorldVolume();
|
|---|
| 306 |
|
|---|
| 307 | G4GeometrySampler pgs(ghostWorld,"neutron");
|
|---|
| 308 |
|
|---|
| 309 | pgs.SetParallel(true);
|
|---|
| 310 | </programlisting>
|
|---|
| 311 | </informalexample>
|
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 | Also note that the preparation and configuration of the samplers has to be
|
|---|
| 315 | carried out <emphasis>after</emphasis> the instantiation of the UserPhysicsList
|
|---|
| 316 | and after the initialisation of the <emphasis>G4RunManager</emphasis>:
|
|---|
| 317 |
|
|---|
| 318 | <informalexample>
|
|---|
| 319 | <programlisting>
|
|---|
| 320 | pgs.PrepareImportanceSampling(&aIstore, 0);
|
|---|
| 321 | pgs.Configure();
|
|---|
| 322 | </programlisting>
|
|---|
| 323 | </informalexample>
|
|---|
| 324 |
|
|---|
| 325 | Due to the fact that biasing is a process and has to be inserted after all the
|
|---|
| 326 | other processes have been created.
|
|---|
| 327 | </para>
|
|---|
| 328 |
|
|---|
| 329 |
|
|---|
| 330 | </sect3>
|
|---|
| 331 |
|
|---|
| 332 | <!-- ******************* Section (Level#3) ****************** -->
|
|---|
| 333 | <sect3 id="sect.EvtBias.ScorImpRoul.ImpSamp">
|
|---|
| 334 | <title>
|
|---|
| 335 | Importance Sampling
|
|---|
| 336 | </title>
|
|---|
| 337 |
|
|---|
| 338 | <para>
|
|---|
| 339 | Importance sampling acts on particles crossing boundaries
|
|---|
| 340 | between "importance cells". The action taken depends on the
|
|---|
| 341 | importance values assigned to the cells. In general a particle
|
|---|
| 342 | history is either split or Russian roulette is played if the
|
|---|
| 343 | importance increases or decreases, respectively. A weight assigned
|
|---|
| 344 | to the history is changed according to the action taken.
|
|---|
| 345 | </para>
|
|---|
| 346 |
|
|---|
| 347 | <para>
|
|---|
| 348 | The tools provided for importance sampling require the user to
|
|---|
| 349 | have a good understanding of the physics in the problem. This is
|
|---|
| 350 | because the user has to decide which particle types require
|
|---|
| 351 | importance sampled, define the cells, and assign importance values
|
|---|
| 352 | to the cells. If this is not done properly the results cannot be
|
|---|
| 353 | expected to describe a real experiment.
|
|---|
| 354 | </para>
|
|---|
| 355 |
|
|---|
| 356 | <para>
|
|---|
| 357 | The assignment of importance values to a cell is done using an
|
|---|
| 358 | importance store described below.
|
|---|
| 359 | </para>
|
|---|
| 360 |
|
|---|
| 361 | <para>
|
|---|
| 362 | An "importance store" with the interface <literal>G4VIStore</literal> is
|
|---|
| 363 | used to store importance values related to cells. In order to do
|
|---|
| 364 | importance sampling the user has to create an object (e.g. of class
|
|---|
| 365 | <literal>G4IStore</literal>) of type <literal>G4VIStore</literal>. The samplers may be
|
|---|
| 366 | given a <literal>G4VIStore</literal>. The user fills the store with cells and
|
|---|
| 367 | their importance values.
|
|---|
| 368 | </para>
|
|---|
| 369 |
|
|---|
| 370 | <para>
|
|---|
| 371 | An importance store has to be constructed with a reference to
|
|---|
| 372 | the world volume of the geometry used for importance sampling. This
|
|---|
| 373 | may be the world volume of the mass or of a parallel geometry.
|
|---|
| 374 | Importance stores derive from the interface <literal>G4VIStore</literal>:
|
|---|
| 375 |
|
|---|
| 376 | <anchor id="anchor_EvtBias_G4VIStore" />
|
|---|
| 377 | <informalexample>
|
|---|
| 378 | <programlisting>
|
|---|
| 379 | class G4VIStore
|
|---|
| 380 | {
|
|---|
| 381 | public:
|
|---|
| 382 | G4VIStore();
|
|---|
| 383 | virtual ~G4VIStore();
|
|---|
| 384 | virtual G4double GetImportance(const G4GeometryCell &gCell) const = 0;
|
|---|
| 385 | virtual G4bool IsKnown(const G4GeometryCell &gCell) const = 0;
|
|---|
| 386 | virtual const G4VPhysicalVolume &GetWorldVolume() const = 0;
|
|---|
| 387 | };
|
|---|
| 388 | </programlisting>
|
|---|
| 389 | </informalexample>
|
|---|
| 390 | </para>
|
|---|
| 391 |
|
|---|
| 392 | <para>
|
|---|
| 393 | A concrete implementation of an importance store is provided by
|
|---|
| 394 | the class <literal>G4VStore</literal>. The <emphasis>public</emphasis>
|
|---|
| 395 | part of the class is:
|
|---|
| 396 |
|
|---|
| 397 | <informalexample>
|
|---|
| 398 | <programlisting>
|
|---|
| 399 | class G4IStore : public G4VIStore
|
|---|
| 400 | {
|
|---|
| 401 | public:
|
|---|
| 402 | explicit G4IStore(const G4VPhysicalVolume &worldvolume);
|
|---|
| 403 | virtual ~G4IStore();
|
|---|
| 404 | virtual G4double GetImportance(const G4GeometryCell &gCell) const;
|
|---|
| 405 | virtual G4bool IsKnown(const G4GeometryCell &gCell) const;
|
|---|
| 406 | virtual const G4VPhysicalVolume &GetWorldVolume() const;
|
|---|
| 407 | void AddImportanceGeometryCell(G4double importance,
|
|---|
| 408 | const G4GeometryCell &gCell);
|
|---|
| 409 | void AddImportanceGeometryCell(G4double importance,
|
|---|
| 410 | const G4VPhysicalVolume &,
|
|---|
| 411 | G4int aRepNum = 0);
|
|---|
| 412 | void ChangeImportance(G4double importance,
|
|---|
| 413 | const G4GeometryCell &gCell);
|
|---|
| 414 | void ChangeImportance(G4double importance,
|
|---|
| 415 | const G4VPhysicalVolume &,
|
|---|
| 416 | G4int aRepNum = 0);
|
|---|
| 417 | G4double GetImportance(const G4VPhysicalVolume &,
|
|---|
| 418 | G4int aRepNum = 0) const ;
|
|---|
| 419 | private: .....
|
|---|
| 420 | };
|
|---|
| 421 | </programlisting>
|
|---|
| 422 | </informalexample>
|
|---|
| 423 | </para>
|
|---|
| 424 |
|
|---|
| 425 | <para>
|
|---|
| 426 | The member function <literal>AddImportanceGeometryCell()</literal> enters
|
|---|
| 427 | a cell and an importance value into the importance store. The
|
|---|
| 428 | importance values may be returned either according to a physical
|
|---|
| 429 | volume and a replica number or according to a
|
|---|
| 430 | <literal>G4GeometryCell</literal>. The user must be aware of the
|
|---|
| 431 | interpretation of assigning importance values to a cell.
|
|---|
| 432 | If scoring is also implemented then this is attached to logical volumes, in
|
|---|
| 433 | which case the physical volume and replica number method should be used for
|
|---|
| 434 | assigning importance values. See <literal>examples/extended/biasing
|
|---|
| 435 | B01</literal> and <literal>B02</literal> for examples of this.
|
|---|
| 436 | </para>
|
|---|
| 437 |
|
|---|
| 438 | <para>
|
|---|
| 439 | <note>
|
|---|
| 440 | <para>
|
|---|
| 441 | <itemizedlist spacing="compact">
|
|---|
| 442 | <listitem><para>
|
|---|
| 443 | An importance value must be assigned to every cell.
|
|---|
| 444 | </para></listitem>
|
|---|
| 445 | </itemizedlist>
|
|---|
| 446 | </para>
|
|---|
| 447 | </note>
|
|---|
| 448 | </para>
|
|---|
| 449 |
|
|---|
| 450 | <para>
|
|---|
| 451 | The different cases:
|
|---|
| 452 |
|
|---|
| 453 | <itemizedlist spacing="compact">
|
|---|
| 454 | <listitem><para>
|
|---|
| 455 | <emphasis>Cell is not in store</emphasis>
|
|---|
| 456 | <para>
|
|---|
| 457 | Not filling a certain cell in the store will cause an
|
|---|
| 458 | exception.
|
|---|
| 459 | </para>
|
|---|
| 460 | </para></listitem>
|
|---|
| 461 | <listitem><para>
|
|---|
| 462 | <emphasis>Importance value = zero</emphasis>
|
|---|
| 463 | <para>
|
|---|
| 464 | Tracks of the chosen particle type will be killed.
|
|---|
| 465 | </para>
|
|---|
| 466 | </para></listitem>
|
|---|
| 467 | <listitem><para>
|
|---|
| 468 | <emphasis>importance values > 0</emphasis>
|
|---|
| 469 | <para>
|
|---|
| 470 | Normal allowed values
|
|---|
| 471 | </para>
|
|---|
| 472 | </para></listitem>
|
|---|
| 473 | <listitem><para>
|
|---|
| 474 | <emphasis>Importance value smaller zero</emphasis>
|
|---|
| 475 | <para>
|
|---|
| 476 | Not allowed!
|
|---|
| 477 | </para>
|
|---|
| 478 | </para></listitem>
|
|---|
| 479 | </itemizedlist>
|
|---|
| 480 | </para>
|
|---|
| 481 |
|
|---|
| 482 | </sect3>
|
|---|
| 483 |
|
|---|
| 484 | <!-- ******************* Section (Level#3) ****************** -->
|
|---|
| 485 | <sect3 id="sect.EvtBias.ScorImpRoul.SampAlgor">
|
|---|
| 486 | <title>
|
|---|
| 487 | The Importance Sampling Algorithm
|
|---|
| 488 | </title>
|
|---|
| 489 |
|
|---|
| 490 | <para>
|
|---|
| 491 | Importance sampling supports using a customized importance
|
|---|
| 492 | sampling algorithm. To this end, the sampler interface
|
|---|
| 493 | <link linkend="anchor_EvtBias_G4VSampler">
|
|---|
| 494 | <literal>G4VSampler</literal></link>
|
|---|
| 495 | may be given a pointer to the interface
|
|---|
| 496 | <literal>G4VImportanceAlgorithm</literal>:
|
|---|
| 497 |
|
|---|
| 498 | <informalexample>
|
|---|
| 499 | <programlisting>
|
|---|
| 500 | class G4VImportanceAlgorithm
|
|---|
| 501 | {
|
|---|
| 502 | public:
|
|---|
| 503 | G4VImportanceAlgorithm();
|
|---|
| 504 | virtual ~G4VImportanceAlgorithm();
|
|---|
| 505 | virtual G4Nsplit_Weight Calculate(G4double ipre,
|
|---|
| 506 | G4double ipost,
|
|---|
| 507 | G4double init_w) const = 0;
|
|---|
| 508 | };
|
|---|
| 509 | </programlisting>
|
|---|
| 510 | </informalexample>
|
|---|
| 511 | </para>
|
|---|
| 512 |
|
|---|
| 513 | <para>
|
|---|
| 514 | The method <literal>Calculate()</literal> takes the arguments:
|
|---|
| 515 |
|
|---|
| 516 | <itemizedlist spacing="compact">
|
|---|
| 517 | <listitem><para>
|
|---|
| 518 | <emphasis>ipre, ipost</emphasis>: importance
|
|---|
| 519 | of the previous cell and the importance of the current cell,
|
|---|
| 520 | respectively.
|
|---|
| 521 | </para></listitem>
|
|---|
| 522 | <listitem><para>
|
|---|
| 523 | <emphasis>init_w</emphasis>: the particles weight
|
|---|
| 524 | </para></listitem>
|
|---|
| 525 | </itemizedlist>
|
|---|
| 526 | </para>
|
|---|
| 527 |
|
|---|
| 528 | <para>
|
|---|
| 529 | It returns the struct:
|
|---|
| 530 |
|
|---|
| 531 | <informalexample>
|
|---|
| 532 | <programlisting>
|
|---|
| 533 | class G4Nsplit_Weight
|
|---|
| 534 | {
|
|---|
| 535 | public:
|
|---|
| 536 |
|
|---|
| 537 | G4int fN;
|
|---|
| 538 | G4double fW;
|
|---|
| 539 | };
|
|---|
| 540 | </programlisting>
|
|---|
| 541 | </informalexample>
|
|---|
| 542 |
|
|---|
| 543 | <itemizedlist spacing="compact">
|
|---|
| 544 | <listitem><para>
|
|---|
| 545 | <emphasis>fN</emphasis>: the calculated
|
|---|
| 546 | number of particles to exit the importance sampling
|
|---|
| 547 | </para></listitem>
|
|---|
| 548 | <listitem><para>
|
|---|
| 549 | <emphasis>fW</emphasis>: the weight of the particles
|
|---|
| 550 | </para></listitem>
|
|---|
| 551 | </itemizedlist>
|
|---|
| 552 | </para>
|
|---|
| 553 |
|
|---|
| 554 | <para>
|
|---|
| 555 | The user may have a customized algorithm used by providing a
|
|---|
| 556 | class inheriting from <literal>G4VImportanceAlgorithm</literal>.
|
|---|
| 557 | </para>
|
|---|
| 558 |
|
|---|
| 559 | <para>
|
|---|
| 560 | If no customized algorithm is given to the sampler the default
|
|---|
| 561 | importance sampling algorithm is used. This algorithm is
|
|---|
| 562 | implemented in <literal>G4ImportanceAlgorithm</literal>.
|
|---|
| 563 | </para>
|
|---|
| 564 |
|
|---|
| 565 | </sect3>
|
|---|
| 566 |
|
|---|
| 567 | <!-- ******************* Section (Level#3) ****************** -->
|
|---|
| 568 | <sect3 id="sect.EvtBias.ScorImpRoul.WeightWin">
|
|---|
| 569 | <title>
|
|---|
| 570 | The Weight Window Technique
|
|---|
| 571 | </title>
|
|---|
| 572 |
|
|---|
| 573 | <para>
|
|---|
| 574 | The weight window technique is a weight-based alternative to
|
|---|
| 575 | importance sampling:
|
|---|
| 576 |
|
|---|
| 577 | <itemizedlist spacing="compact">
|
|---|
| 578 | <listitem><para>
|
|---|
| 579 | applies splitting and Russian roulette depending on space
|
|---|
| 580 | (cells) and energy
|
|---|
| 581 | </para></listitem>
|
|---|
| 582 | <listitem><para>
|
|---|
| 583 | user defines weight windows in contrast to defining importance
|
|---|
| 584 | values as in importance sampling
|
|---|
| 585 | </para></listitem>
|
|---|
| 586 | </itemizedlist>
|
|---|
| 587 | </para>
|
|---|
| 588 |
|
|---|
| 589 | <para>
|
|---|
| 590 | In contrast to importance sampling this technique is not weight
|
|---|
| 591 | blind. Instead the technique is applied according to the particle
|
|---|
| 592 | weight with respect to the current energy-space cell.
|
|---|
| 593 | </para>
|
|---|
| 594 |
|
|---|
| 595 | <para>
|
|---|
| 596 | Therefore the technique is convenient to apply in combination
|
|---|
| 597 | with other variance reduction techniques such as cross-section
|
|---|
| 598 | biasing and implicit capture.
|
|---|
| 599 | </para>
|
|---|
| 600 |
|
|---|
| 601 | <para>
|
|---|
| 602 | A weight window may be specified for every cell and for several
|
|---|
| 603 | energy regions: <emphasis>space-energy cell</emphasis>.
|
|---|
| 604 |
|
|---|
| 605 | <figure id="fig.EvtBias.WeightWindow">
|
|---|
| 606 | <title>
|
|---|
| 607 | Weight window concept
|
|---|
| 608 | </title>
|
|---|
| 609 |
|
|---|
| 610 | <mediaobject>
|
|---|
| 611 | <imageobject role="fo">
|
|---|
| 612 | <imagedata fileref="./AllResources/Fundamentals/wwconcept.gif"
|
|---|
| 613 | format="GIF" contentwidth="9.0cm" align="center" />
|
|---|
| 614 | </imageobject>
|
|---|
| 615 | <imageobject role="html">
|
|---|
| 616 | <imagedata fileref="./AllResources/Fundamentals/wwconcept.gif"
|
|---|
| 617 | format="GIF" align="center" />
|
|---|
| 618 | </imageobject>
|
|---|
| 619 | <textobject>
|
|---|
| 620 | <phrase>Weight window concept</phrase>
|
|---|
| 621 | </textobject>
|
|---|
| 622 | </mediaobject>
|
|---|
| 623 | </figure>
|
|---|
| 624 | </para>
|
|---|
| 625 |
|
|---|
| 626 | <!-- ******* Bridgehead ******* -->
|
|---|
| 627 | <bridgehead renderas='sect4'>
|
|---|
| 628 | Weight window concept
|
|---|
| 629 | </bridgehead>
|
|---|
| 630 |
|
|---|
| 631 | <para>
|
|---|
| 632 | The user specifies a <emphasis>lower weight bound W_L</emphasis>
|
|---|
| 633 | for every space-energy cell.
|
|---|
| 634 |
|
|---|
| 635 | <itemizedlist spacing="compact">
|
|---|
| 636 | <listitem><para>
|
|---|
| 637 | The upper weight bound W_U and the survival weight W_S are
|
|---|
| 638 | calculated as:
|
|---|
| 639 | <para>
|
|---|
| 640 | W_U = C_U <emphasis>W_L</emphasis> and
|
|---|
| 641 | </para>
|
|---|
| 642 | <para>
|
|---|
| 643 | W_S = C_S <emphasis>W_L</emphasis>.
|
|---|
| 644 | </para>
|
|---|
| 645 | </para></listitem>
|
|---|
| 646 | <listitem><para>
|
|---|
| 647 | The user specifies C_S and C_U once for the whole problem.
|
|---|
| 648 | </para></listitem>
|
|---|
| 649 | <listitem><para>
|
|---|
| 650 | The user may give different sets of energy bounds for every cell
|
|---|
| 651 | or one set for all geometrical cells
|
|---|
| 652 | </para></listitem>
|
|---|
| 653 | <listitem><para>
|
|---|
| 654 | Special case: if C_S = C_U = 1 for all energies then weight
|
|---|
| 655 | window is equivalent to importance sampling
|
|---|
| 656 | </para></listitem>
|
|---|
| 657 | <listitem><para>
|
|---|
| 658 | The user can choose to apply the technique: at boundaries, on
|
|---|
| 659 | collisions or on boundaries and collisions
|
|---|
| 660 | </para></listitem>
|
|---|
| 661 | </itemizedlist>
|
|---|
| 662 | </para>
|
|---|
| 663 |
|
|---|
| 664 | <para>
|
|---|
| 665 | The energy-space cells are realized by <literal>G4GeometryCell</literal>
|
|---|
| 666 | as in importance sampling. The cells are stored in a weight window
|
|---|
| 667 | store defined by <literal>G4VWeightWindowStore</literal>:
|
|---|
| 668 |
|
|---|
| 669 | <informalexample>
|
|---|
| 670 | <programlisting>
|
|---|
| 671 | class G4VWeightWindowStore {
|
|---|
| 672 | public:
|
|---|
| 673 | G4VWeightWindowStore();
|
|---|
| 674 | virtual ~G4VWeightWindowStore();
|
|---|
| 675 | virtual G4double GetLowerWeitgh(const G4GeometryCell &gCell,
|
|---|
| 676 | G4double partEnergy) const = 0;
|
|---|
| 677 | virtual G4bool IsKnown(const G4GeometryCell &gCell) const = 0;
|
|---|
| 678 | virtual const G4VPhysicalVolume &GetWorldVolume() const = 0;
|
|---|
| 679 | };
|
|---|
| 680 | </programlisting>
|
|---|
| 681 | </informalexample>
|
|---|
| 682 | </para>
|
|---|
| 683 |
|
|---|
| 684 | <para>
|
|---|
| 685 | A concrete implementation is provided:
|
|---|
| 686 |
|
|---|
| 687 | <informalexample>
|
|---|
| 688 | <programlisting>
|
|---|
| 689 | class G4WeightWindowStore: public G4VWeightWindowStore {
|
|---|
| 690 | public:
|
|---|
| 691 | explicit G4WeightWindowStore(const G4VPhysicalVolume &worldvolume);
|
|---|
| 692 | virtual ~G4WeightWindowStore();
|
|---|
| 693 | virtual G4double GetLowerWeitgh(const G4GeometryCell &gCell,
|
|---|
| 694 | G4double partEnergy) const;
|
|---|
| 695 | virtual G4bool IsKnown(const G4GeometryCell &gCell) const;
|
|---|
| 696 | virtual const G4VPhysicalVolume &GetWorldVolume() const;
|
|---|
| 697 | void AddLowerWeights(const G4GeometryCell &gCell,
|
|---|
| 698 | const std::vector<G4double> &lowerWeights);
|
|---|
| 699 | void AddUpperEboundLowerWeightPairs(const G4GeometryCell &gCell,
|
|---|
| 700 | const G4UpperEnergyToLowerWeightMap&
|
|---|
| 701 | enWeMap);
|
|---|
| 702 | void SetGeneralUpperEnergyBounds(const
|
|---|
| 703 | std::set<G4double, std::less<G4double> > & enBounds);
|
|---|
| 704 |
|
|---|
| 705 | private::
|
|---|
| 706 | ...
|
|---|
| 707 | };
|
|---|
| 708 | </programlisting>
|
|---|
| 709 | </informalexample>
|
|---|
| 710 | </para>
|
|---|
| 711 |
|
|---|
| 712 | <para>
|
|---|
| 713 | The user may choose equal energy bounds for all cells. In this
|
|---|
| 714 | case a set of upper energy bounds must be given to the store using
|
|---|
| 715 | the method <literal>SetGeneralUpperEnergyBounds</literal>. If a general set
|
|---|
| 716 | of energy bounds have been set <literal>AddLowerWeights</literal> can be used
|
|---|
| 717 | to add the cells.
|
|---|
| 718 | </para>
|
|---|
| 719 |
|
|---|
| 720 | <para>
|
|---|
| 721 | Alternatively, the user may chose different energy regions for
|
|---|
| 722 | different cells. In this case the user must provide a mapping of
|
|---|
| 723 | upper energy bounds to lower weight bounds for every cell using the
|
|---|
| 724 | method <literal>AddUpperEboundLowerWeightPairs</literal>.
|
|---|
| 725 | </para>
|
|---|
| 726 |
|
|---|
| 727 | <para>
|
|---|
| 728 | Weight window algorithms implementing the interface class
|
|---|
| 729 | <literal>G4VWeightWindowAlgorithm</literal> can be used to define a
|
|---|
| 730 | customized algorithm:
|
|---|
| 731 |
|
|---|
| 732 | <informalexample>
|
|---|
| 733 | <programlisting>
|
|---|
| 734 | class G4VWeightWindowAlgorithm {
|
|---|
| 735 | public:
|
|---|
| 736 | G4VWeightWindowAlgorithm();
|
|---|
| 737 | virtual ~G4VWeightWindowAlgorithm();
|
|---|
| 738 | virtual G4Nsplit_Weight Calculate(G4double init_w,
|
|---|
| 739 | G4double lowerWeightBound) const = 0;
|
|---|
| 740 | };
|
|---|
| 741 | </programlisting>
|
|---|
| 742 | </informalexample>
|
|---|
| 743 | </para>
|
|---|
| 744 |
|
|---|
| 745 | <para>
|
|---|
| 746 | A concrete implementation is provided and used as a default:
|
|---|
| 747 |
|
|---|
| 748 | <informalexample>
|
|---|
| 749 | <programlisting>
|
|---|
| 750 | class G4WeightWindowAlgorithm : public G4VWeightWindowAlgorithm {
|
|---|
| 751 | public:
|
|---|
| 752 | G4WeightWindowAlgorithm(G4double upperLimitFaktor = 5,
|
|---|
| 753 | G4double survivalFaktor = 3,
|
|---|
| 754 | G4int maxNumberOfSplits = 5);
|
|---|
| 755 | virtual ~G4WeightWindowAlgorithm();
|
|---|
| 756 | virtual G4Nsplit_Weight Calculate(G4double init_w,
|
|---|
| 757 | G4double lowerWeightBound) const;
|
|---|
| 758 | private:
|
|---|
| 759 | ...
|
|---|
| 760 | };
|
|---|
| 761 | </programlisting>
|
|---|
| 762 | </informalexample>
|
|---|
| 763 | </para>
|
|---|
| 764 |
|
|---|
| 765 | <para>
|
|---|
| 766 | The constructor takes three parameters which are used to:
|
|---|
| 767 | calculate the upper weight bound (upperLimitFaktor), calculate the
|
|---|
| 768 | survival weight (survivalFaktor), and introduce a maximal number
|
|---|
| 769 | (maxNumberOfSplits) of copies to be created in one go.
|
|---|
| 770 | </para>
|
|---|
| 771 |
|
|---|
| 772 | <para>
|
|---|
| 773 | In addition, the inverse of the maxNumberOfSplits is used to
|
|---|
| 774 | specify the minimum survival probability in case of Russian
|
|---|
| 775 | roulette.
|
|---|
| 776 | </para>
|
|---|
| 777 |
|
|---|
| 778 | </sect3>
|
|---|
| 779 |
|
|---|
| 780 | <!-- ******************* Section (Level#3) ****************** -->
|
|---|
| 781 | <sect3 id="sect.EvtBias.ScorImpRoul.WeigRoul">
|
|---|
| 782 | <title>
|
|---|
| 783 | The Weight Roulette Technique
|
|---|
| 784 | </title>
|
|---|
| 785 |
|
|---|
| 786 | <para>
|
|---|
| 787 | Weight roulette (also called weight cutoff) is usually applied
|
|---|
| 788 | if importance sampling and implicit capture are used together.
|
|---|
| 789 | Implicit capture is not described here but it is useful to note
|
|---|
| 790 | that this procedure reduces a particle weight in every collision
|
|---|
| 791 | instead of killing the particle with some probability.
|
|---|
| 792 | </para>
|
|---|
| 793 |
|
|---|
| 794 | <para>
|
|---|
| 795 | Together with importance sampling the weight of a particle may
|
|---|
| 796 | become so low that it does not change any result significantly.
|
|---|
| 797 | Hence tracking a very low weight particle is a waste of computing
|
|---|
| 798 | time. Weight roulette is applied in order to solve this
|
|---|
| 799 | problem.
|
|---|
| 800 | </para>
|
|---|
| 801 |
|
|---|
| 802 | <!-- ******* Bridgehead ******* -->
|
|---|
| 803 | <bridgehead renderas='sect4'>
|
|---|
| 804 | The weight roulette concept
|
|---|
| 805 | </bridgehead>
|
|---|
| 806 |
|
|---|
| 807 | <para>
|
|---|
| 808 | Weight roulette takes into account the importance "Ic" of the
|
|---|
| 809 | current cell and the importance "Is" of the cell in which the
|
|---|
| 810 | source is located, by using the ratio "R=Is/Ic".
|
|---|
| 811 | </para>
|
|---|
| 812 |
|
|---|
| 813 | <para>
|
|---|
| 814 | Weight roulette uses a relative minimal weight limit and a
|
|---|
| 815 | relative survival weight. When a particle falls below the weight
|
|---|
| 816 | limit Russian roulette is applied. If the particle survives,
|
|---|
| 817 | tracking will be continued and the particle weight will be set to
|
|---|
| 818 | the survival weight.
|
|---|
| 819 | </para>
|
|---|
| 820 |
|
|---|
| 821 | <para>
|
|---|
| 822 | The weight roulette uses the following parameters with their
|
|---|
| 823 | default values:
|
|---|
| 824 |
|
|---|
| 825 | <itemizedlist spacing="compact">
|
|---|
| 826 | <listitem><para>
|
|---|
| 827 | <emphasis>wsurvival</emphasis>: 0.5
|
|---|
| 828 | </para></listitem>
|
|---|
| 829 | <listitem><para>
|
|---|
| 830 | <emphasis>wlimit</emphasis>: 0.25
|
|---|
| 831 | </para></listitem>
|
|---|
| 832 | <listitem><para>
|
|---|
| 833 | <emphasis>isource</emphasis>: 1
|
|---|
| 834 | </para></listitem>
|
|---|
| 835 | </itemizedlist>
|
|---|
| 836 | </para>
|
|---|
| 837 |
|
|---|
| 838 | <para>
|
|---|
| 839 | The following algorithm is applied:
|
|---|
| 840 | </para>
|
|---|
| 841 |
|
|---|
| 842 | <para>
|
|---|
| 843 | If a particle weight "w" is lower than R*wlimit:
|
|---|
| 844 |
|
|---|
| 845 | <itemizedlist spacing="compact">
|
|---|
| 846 | <listitem><para>
|
|---|
| 847 | the weight of the particle will be changed to "ws = wsurvival*R"
|
|---|
| 848 | </para></listitem>
|
|---|
| 849 | <listitem><para>
|
|---|
| 850 | the probability for the particle to survive is "p = w/ws"
|
|---|
| 851 | </para></listitem>
|
|---|
| 852 | </itemizedlist>
|
|---|
| 853 | </para>
|
|---|
| 854 |
|
|---|
| 855 | </sect3>
|
|---|
| 856 | </sect2>
|
|---|
| 857 |
|
|---|
| 858 |
|
|---|
| 859 | <!-- ******************* Section (Level#2) ****************** -->
|
|---|
| 860 | <sect2 id="sect.EvtBias.PhysBias">
|
|---|
| 861 | <title>
|
|---|
| 862 | Physics Based Biasing
|
|---|
| 863 | </title>
|
|---|
| 864 |
|
|---|
| 865 | <para>
|
|---|
| 866 | Geant4 supports physics based biasing through a number of general
|
|---|
| 867 | use, built in biasing techniques. A utility class,
|
|---|
| 868 | G4WrapperProcess, is also available to support user defined
|
|---|
| 869 | biasing.
|
|---|
| 870 | </para>
|
|---|
| 871 |
|
|---|
| 872 | <!-- ******************* Section (Level#3) ****************** -->
|
|---|
| 873 | <sect3 id="sect.EvtBias.PhysBias.BuiltInOpt">
|
|---|
| 874 | <title>
|
|---|
| 875 | Built in Biasing Options
|
|---|
| 876 | </title>
|
|---|
| 877 |
|
|---|
| 878 | <!-- ******************* Section (Level#4) ****************** -->
|
|---|
| 879 | <sect4 id="sect.EvtBias.PhysBias.BuiltInOpt.PrimPart">
|
|---|
| 880 | <title>
|
|---|
| 881 | Primary Particle Biasing
|
|---|
| 882 | </title>
|
|---|
| 883 |
|
|---|
| 884 | <para>
|
|---|
| 885 | Primary particle biasing can be used to increase the number of
|
|---|
| 886 | primary particles generated in a particular phase space region of
|
|---|
| 887 | interest. The weight of the primary particle is modified as
|
|---|
| 888 | appropriate. A general implementation is provided through the
|
|---|
| 889 | G4GeneralParticleSource class. It is possible to bias position,
|
|---|
| 890 | angular and energy distributions.
|
|---|
| 891 | </para>
|
|---|
| 892 |
|
|---|
| 893 | <para>
|
|---|
| 894 | G4GeneralParticleSource is a concrete implementation of
|
|---|
| 895 | G4VPrimaryGenerator. To use, instantiate G4GeneralParticleSource in
|
|---|
| 896 | the G4VUserPrimaryGeneratorAction class, as demonstrated below.
|
|---|
| 897 |
|
|---|
| 898 | <informalexample>
|
|---|
| 899 | <programlisting>
|
|---|
| 900 | MyPrimaryGeneratorAction::MyPrimaryGeneratorAction() {
|
|---|
| 901 | generator = new G4GeneralParticleSource;
|
|---|
| 902 | }
|
|---|
| 903 |
|
|---|
| 904 | void
|
|---|
| 905 | MyPrimaryGeneratorAction::GeneratePrimaries(G4Event*anEvent){
|
|---|
| 906 | generator->GeneratePrimaryVertex(anEvent);
|
|---|
| 907 | }
|
|---|
| 908 | </programlisting>
|
|---|
| 909 | </informalexample>
|
|---|
| 910 | </para>
|
|---|
| 911 |
|
|---|
| 912 | <para>
|
|---|
| 913 | The biasing can be configured through interactive commands.
|
|---|
| 914 | Extensive documentation can be found in
|
|---|
| 915 | <ulink url="http://reat.space.qinetiq.com/gps/">
|
|---|
| 916 | Primary particle biasing</ulink>. Examples are also distributed
|
|---|
| 917 | with the Geant4 distribution in
|
|---|
| 918 | <emphasis role="bold">examples/extended/eventgenerator/exgps</emphasis>.
|
|---|
| 919 | </para>
|
|---|
| 920 |
|
|---|
| 921 | </sect4>
|
|---|
| 922 |
|
|---|
| 923 | <!-- ******************* Section (Level#4) ****************** -->
|
|---|
| 924 | <sect4 id="sect.EvtBias.PhysBias.BuiltInOpt.RadDcy">
|
|---|
| 925 | <title>
|
|---|
| 926 | Radioactive Decay Biasing
|
|---|
| 927 | </title>
|
|---|
| 928 |
|
|---|
| 929 | <para>
|
|---|
| 930 | The G4RadioactiveDecay class simulates the decay of radioactive
|
|---|
| 931 | nuclei and implements the following biasing options:
|
|---|
| 932 |
|
|---|
| 933 | <itemizedlist spacing="compact">
|
|---|
| 934 | <listitem><para>
|
|---|
| 935 | Increase the sampling rate of radionuclides within observation
|
|---|
| 936 | times through a user defined probability distribution function
|
|---|
| 937 | </para></listitem>
|
|---|
| 938 | <listitem><para>
|
|---|
| 939 | Nuclear splitting, where the parent nuclide is split into a
|
|---|
| 940 | user defined number of nuclides
|
|---|
| 941 | </para></listitem>
|
|---|
| 942 | <listitem><para>
|
|---|
| 943 | Branching ratio biasing where branching ratios are sampled with
|
|---|
| 944 | equal probability
|
|---|
| 945 | </para></listitem>
|
|---|
| 946 | </itemizedlist>
|
|---|
| 947 | </para>
|
|---|
| 948 |
|
|---|
| 949 | <para>
|
|---|
| 950 | G4RadioactiveDecay is a process which must be registered with a
|
|---|
| 951 | process manager, as demonstrated below.
|
|---|
| 952 |
|
|---|
| 953 | <informalexample>
|
|---|
| 954 | <programlisting>
|
|---|
| 955 | void MyPhysicsList::ConstructProcess()
|
|---|
| 956 | {
|
|---|
| 957 | ...
|
|---|
| 958 | G4RadioactiveDecay* theRadioactiveDecay =
|
|---|
| 959 | new G4RadioactiveDecay();
|
|---|
| 960 |
|
|---|
| 961 | G4ProcessManager* pmanager = ...
|
|---|
| 962 | pmanager ->AddProcess(theRadioactiveDecay);
|
|---|
| 963 | ...
|
|---|
| 964 | }
|
|---|
| 965 | </programlisting>
|
|---|
| 966 | </informalexample>
|
|---|
| 967 | </para>
|
|---|
| 968 |
|
|---|
| 969 | <para>
|
|---|
| 970 | The biasing can be controlled either in compiled code or through
|
|---|
| 971 | interactive commands. Extensive documentation can be found in
|
|---|
| 972 |
|
|---|
| 973 | <ulink url="http://reat.space.qinetiq.com/septimess/exrdm/">
|
|---|
| 974 | Radioactive decay biasing example
|
|---|
| 975 | </ulink>
|
|---|
| 976 | and
|
|---|
| 977 | <ulink url="http://www.space.qinetiq.com/geant4/rdm.html">
|
|---|
| 978 | Radioactive decay biasing
|
|---|
| 979 | </ulink>.
|
|---|
| 980 | </para>
|
|---|
| 981 |
|
|---|
| 982 | <para>
|
|---|
| 983 | Radioactive decay biasing examples are also distributed with the Geant4
|
|---|
| 984 | distribution in
|
|---|
| 985 | <emphasis role="bold">examples/extended/radioactivedecay/exrdm</emphasis>.
|
|---|
| 986 | </para>
|
|---|
| 987 |
|
|---|
| 988 | </sect4>
|
|---|
| 989 |
|
|---|
| 990 | <!-- ******************* Section (Level#4) ****************** -->
|
|---|
| 991 | <sect4 id="sect.EvtBias.PhysBias.BuiltInOpt.HadLeadPar">
|
|---|
| 992 | <title>
|
|---|
| 993 | Hadronic Leading Particle Biasing
|
|---|
| 994 | </title>
|
|---|
| 995 |
|
|---|
| 996 | <para>
|
|---|
| 997 | One hadronic leading particle biasing technique is
|
|---|
| 998 | implemented in the G4HadLeadBias utility. This method keeps only
|
|---|
| 999 | the most important part of the event, as well as representative
|
|---|
| 1000 | tracks of each given particle type. So the track with the highest
|
|---|
| 1001 | energy as well as one of each of Baryon, pi0, mesons and leptons.
|
|---|
| 1002 | As usual, appropriate weights are assigned to the particles.
|
|---|
| 1003 | Setting the <emphasis role="bold">SwitchLeadBiasOn</emphasis>
|
|---|
| 1004 | environmental variable will activate this utility.
|
|---|
| 1005 | </para>
|
|---|
| 1006 |
|
|---|
| 1007 | </sect4>
|
|---|
| 1008 |
|
|---|
| 1009 | <!-- ******************* Section (Level#4) ****************** -->
|
|---|
| 1010 | <sect4 id="sect.EvtBias.PhysBias.BuiltInOpt.HadCrsSect">
|
|---|
| 1011 | <title>
|
|---|
| 1012 | Hadronic Cross Section Biasing
|
|---|
| 1013 | </title>
|
|---|
| 1014 |
|
|---|
| 1015 | <para>
|
|---|
| 1016 | Cross section biasing artificially enhances/reduces the cross
|
|---|
| 1017 | section of a process. This may be useful for studying thin layer
|
|---|
| 1018 | interactions or thick layer shielding. The built in hadronic cross
|
|---|
| 1019 | section biasing applies to photon inelastic, electron nuclear and
|
|---|
| 1020 | positron nuclear processes.
|
|---|
| 1021 | </para>
|
|---|
| 1022 |
|
|---|
| 1023 | <para>
|
|---|
| 1024 | The biasing is controlled through the
|
|---|
| 1025 | <emphasis role="bold">BiasCrossSectionByFactor</emphasis> method
|
|---|
| 1026 | in G4HadronicProcess, as demonstrated below.
|
|---|
| 1027 |
|
|---|
| 1028 | <informalexample>
|
|---|
| 1029 | <programlisting>
|
|---|
| 1030 | void MyPhysicsList::ConstructProcess()
|
|---|
| 1031 | {
|
|---|
| 1032 | ...
|
|---|
| 1033 | G4ElectroNuclearReaction * theElectroReaction =
|
|---|
| 1034 | new G4ElectroNuclearReaction;
|
|---|
| 1035 |
|
|---|
| 1036 | G4ElectronNuclearProcess theElectronNuclearProcess;
|
|---|
| 1037 | theElectronNuclearProcess.RegisterMe(theElectroReaction);
|
|---|
| 1038 | theElectronNuclearProcess.BiasCrossSectionByFactor(100);
|
|---|
| 1039 |
|
|---|
| 1040 | pManager->AddDiscreteProcess(&theElectronNuclearProcess);
|
|---|
| 1041 | ...
|
|---|
| 1042 | }
|
|---|
| 1043 | </programlisting>
|
|---|
| 1044 | </informalexample>
|
|---|
| 1045 | </para>
|
|---|
| 1046 |
|
|---|
| 1047 | <para>
|
|---|
| 1048 | More details can be found in
|
|---|
| 1049 | <ulink url="http://www.triumf.ca/geant4-03/talks/03-Wednesday-AM-1/03-J.Wellisch/biasing.hadronics.pdf">
|
|---|
| 1050 | Hadronic cross section biasing
|
|---|
| 1051 | </ulink>.
|
|---|
| 1052 | </para>
|
|---|
| 1053 |
|
|---|
| 1054 | </sect4>
|
|---|
| 1055 | </sect3>
|
|---|
| 1056 |
|
|---|
| 1057 |
|
|---|
| 1058 | <!-- ******************* Section (Level#3) ****************** -->
|
|---|
| 1059 | <sect3 id="sect.EvtBias.PhysBias.">
|
|---|
| 1060 | <title>
|
|---|
| 1061 | G4WrapperProcess
|
|---|
| 1062 | </title>
|
|---|
| 1063 |
|
|---|
| 1064 | <para>
|
|---|
| 1065 | G4WrapperProcess can be used to implement user defined event
|
|---|
| 1066 | biasing. G4WrapperProcess, which is a process itself, wraps an
|
|---|
| 1067 | existing process. By default, all function calls are forwared to
|
|---|
| 1068 | the wrapped process. It is a non-invasive way to modify the
|
|---|
| 1069 | behaviour of an existing process.
|
|---|
| 1070 | </para>
|
|---|
| 1071 |
|
|---|
| 1072 | <para>
|
|---|
| 1073 | To use this utility, first create a derived class inheriting
|
|---|
| 1074 | from G4WrapperProcess. Override the methods whose behaviour you
|
|---|
| 1075 | would like to modify, for example, PostStepDoIt, and register the
|
|---|
| 1076 | derived class in place of the process to be wrapped. Finally,
|
|---|
| 1077 | register the wrapped process with G4WrapperProcess. The code
|
|---|
| 1078 | snippets below demonstrate its use.
|
|---|
| 1079 |
|
|---|
| 1080 | <informalexample>
|
|---|
| 1081 | <programlisting>
|
|---|
| 1082 | class MyWrapperProcess : public G4WrapperProcess {
|
|---|
| 1083 | ...
|
|---|
| 1084 | G4VParticleChange* PostStepDoIt(const G4Track& track,
|
|---|
| 1085 | const G4Step& step) {
|
|---|
| 1086 | // Do something interesting
|
|---|
| 1087 | }
|
|---|
| 1088 | };
|
|---|
| 1089 |
|
|---|
| 1090 |
|
|---|
| 1091 | void MyPhysicsList::ConstructProcess()
|
|---|
| 1092 | {
|
|---|
| 1093 | ...
|
|---|
| 1094 | G4LowEnergyBremsstrahlung* bremProcess =
|
|---|
| 1095 | new G4LowEnergyBremsstrahlung();
|
|---|
| 1096 |
|
|---|
| 1097 | MyWrapperProcess* wrapper = new MyWrapperProcess();
|
|---|
| 1098 | wrapper->RegisterProcess(bremProcess);
|
|---|
| 1099 |
|
|---|
| 1100 | processManager->AddProcess(wrapper, -1, -1, 3);
|
|---|
| 1101 | }
|
|---|
| 1102 | </programlisting>
|
|---|
| 1103 | </informalexample>
|
|---|
| 1104 | </para>
|
|---|
| 1105 |
|
|---|
| 1106 | </sect3>
|
|---|
| 1107 |
|
|---|
| 1108 | </sect2>
|
|---|
| 1109 | </sect1> |
|---|