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