| 1 | <!-- ******************************************************** -->
|
|---|
| 2 | <!-- -->
|
|---|
| 3 | <!-- [History] -->
|
|---|
| 4 | <!-- New section on Reverse MC: L. Desorgher, Dec-2009 -->
|
|---|
| 5 | <!-- Converted to DocBook: Katsuya Amako, Aug-2006 -->
|
|---|
| 6 | <!-- Changed by: Dennis Wright, 25-Jun-2002 -->
|
|---|
| 7 | <!-- -->
|
|---|
| 8 | <!-- ******************************************************** -->
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 | <!-- ******************* Section (Level#1) ****************** -->
|
|---|
| 12 | <sect1 id="sect.EvtBias">
|
|---|
| 13 | <title>
|
|---|
| 14 | Event Biasing Techniques
|
|---|
| 15 | </title>
|
|---|
| 16 |
|
|---|
| 17 | <!-- ******************* Section (Level#2) ****************** -->
|
|---|
| 18 | <sect2 id="sect.EvtBias.ScorImpRoul">
|
|---|
| 19 | <title>
|
|---|
| 20 | Scoring, Geometrical Importance Sampling and Weight Roulette
|
|---|
| 21 | </title>
|
|---|
| 22 |
|
|---|
| 23 | <para>
|
|---|
| 24 | Geant4 provides event biasing techniques which may be used to save
|
|---|
| 25 | computing time in such applications as the simulation of radiation
|
|---|
| 26 | shielding. These are <emphasis>geometrical splitting
|
|---|
| 27 | </emphasis> and <emphasis>Russian roulette</emphasis>
|
|---|
| 28 | (also called geometrical importance sampling), and
|
|---|
| 29 | <emphasis>weight roulette</emphasis>. Scoring is carried out by <emphasis>G4MultiFunctionalDetector</emphasis> (see <xref
|
|---|
| 30 | linkend="sect.Hits.G4Multi" /> and <xref linkend="sect.Hits.G4VPrim" />) using the standard Geant4 scoring technique.
|
|---|
| 31 | Biasing specific scorers have been implemented and are described within
|
|---|
| 32 | <emphasis>G4MultiFunctionDetector</emphasis> documentation. In this chapter, it is assumed that
|
|---|
| 33 | the reader is familiar with both the usage of Geant4 and the
|
|---|
| 34 | concepts of importance sampling. More detailed documentation may be
|
|---|
| 35 | found in the documents
|
|---|
| 36 | <ulink url="http://geant4.cern.ch/collaboration/working_groups/geometry/biasing/Sampling.html">
|
|---|
| 37 | 'Scoring, geometrical importance sampling and weight roulette'
|
|---|
| 38 | </ulink>.
|
|---|
| 39 | A detailed description of different use-cases which employ the sampling
|
|---|
| 40 | and scoring techniques can be found in the document
|
|---|
| 41 | <ulink url="http://geant4.cern.ch/collaboration/working_groups/geometry/biasing/BiasScoreUseCases.html">
|
|---|
| 42 | 'Use cases of importance sampling and scoring in Geant4'
|
|---|
| 43 | </ulink>.
|
|---|
| 44 | </para>
|
|---|
| 45 |
|
|---|
| 46 | <para>
|
|---|
| 47 | The purpose of importance sampling is to save computing time by
|
|---|
| 48 | sampling less often the particle histories entering "less
|
|---|
| 49 | important" geometry regions, and more often in more "important"
|
|---|
| 50 | regions. Given the same amount of computing time, an
|
|---|
| 51 | importance-sampled and an analogue-sampled simulation must show
|
|---|
| 52 | equal mean values, while the importance-sampled simulation will
|
|---|
| 53 | have a decreased variance.
|
|---|
| 54 | </para>
|
|---|
| 55 |
|
|---|
| 56 | <para>
|
|---|
| 57 | The implementation of scoring is independent of the implementation
|
|---|
| 58 | of importance sampling. However both share common concepts.
|
|---|
| 59 | <emphasis>Scoring and importance sampling apply to particle types chosen
|
|---|
| 60 | by the user</emphasis>, which should be borne in mind when interpreting the
|
|---|
| 61 | output of any biased simulation.
|
|---|
| 62 | </para>
|
|---|
| 63 |
|
|---|
| 64 | <para>
|
|---|
| 65 | Examples on how to use scoring and importance sampling may be found
|
|---|
| 66 | in <literal>examples/extended/biasing</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.jpg"
|
|---|
| 613 | format="JPG" contentwidth="9.0cm" align="center" />
|
|---|
| 614 | </imageobject>
|
|---|
| 615 | <imageobject role="html">
|
|---|
| 616 | <imagedata fileref="./AllResources/Fundamentals/wwconcept.jpg"
|
|---|
| 617 | format="JPG" 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 | </sect4>
|
|---|
| 1048 | </sect3>
|
|---|
| 1049 |
|
|---|
| 1050 |
|
|---|
| 1051 | <!-- ******************* Section (Level#3) ****************** -->
|
|---|
| 1052 | <sect3 id="sect.EvtBias.PhysBias.">
|
|---|
| 1053 | <title>
|
|---|
| 1054 | G4WrapperProcess
|
|---|
| 1055 | </title>
|
|---|
| 1056 |
|
|---|
| 1057 | <para>
|
|---|
| 1058 | G4WrapperProcess can be used to implement user defined event
|
|---|
| 1059 | biasing. G4WrapperProcess, which is a process itself, wraps an
|
|---|
| 1060 | existing process. By default, all function calls are forwared to
|
|---|
| 1061 | the wrapped process. It is a non-invasive way to modify the
|
|---|
| 1062 | behaviour of an existing process.
|
|---|
| 1063 | </para>
|
|---|
| 1064 |
|
|---|
| 1065 | <para>
|
|---|
| 1066 | To use this utility, first create a derived class inheriting
|
|---|
| 1067 | from G4WrapperProcess. Override the methods whose behaviour you
|
|---|
| 1068 | would like to modify, for example, PostStepDoIt, and register the
|
|---|
| 1069 | derived class in place of the process to be wrapped. Finally,
|
|---|
| 1070 | register the wrapped process with G4WrapperProcess. The code
|
|---|
| 1071 | snippets below demonstrate its use.
|
|---|
| 1072 |
|
|---|
| 1073 | <informalexample>
|
|---|
| 1074 | <programlisting>
|
|---|
| 1075 | class MyWrapperProcess : public G4WrapperProcess {
|
|---|
| 1076 | ...
|
|---|
| 1077 | G4VParticleChange* PostStepDoIt(const G4Track& track,
|
|---|
| 1078 | const G4Step& step) {
|
|---|
| 1079 | // Do something interesting
|
|---|
| 1080 | }
|
|---|
| 1081 | };
|
|---|
| 1082 |
|
|---|
| 1083 |
|
|---|
| 1084 | void MyPhysicsList::ConstructProcess()
|
|---|
| 1085 | {
|
|---|
| 1086 | ...
|
|---|
| 1087 | G4LowEnergyBremsstrahlung* bremProcess =
|
|---|
| 1088 | new G4LowEnergyBremsstrahlung();
|
|---|
| 1089 |
|
|---|
| 1090 | MyWrapperProcess* wrapper = new MyWrapperProcess();
|
|---|
| 1091 | wrapper->RegisterProcess(bremProcess);
|
|---|
| 1092 |
|
|---|
| 1093 | processManager->AddProcess(wrapper, -1, -1, 3);
|
|---|
| 1094 | }
|
|---|
| 1095 | </programlisting>
|
|---|
| 1096 | </informalexample>
|
|---|
| 1097 | </para>
|
|---|
| 1098 |
|
|---|
| 1099 | </sect3>
|
|---|
| 1100 |
|
|---|
| 1101 | </sect2>
|
|---|
| 1102 |
|
|---|
| 1103 | <!-- ******************* Section (Level#2) ****************** -->
|
|---|
| 1104 | <sect2 id="sect.EvtBias.ReverseMC">
|
|---|
| 1105 | <title>
|
|---|
| 1106 | Adjoint/Reverse Monte Carlo
|
|---|
| 1107 | </title>
|
|---|
| 1108 |
|
|---|
| 1109 | <para>
|
|---|
| 1110 | Another powerful biasing technique available in Geant4 is the Reverse Monte Carlo (RMC) method,
|
|---|
| 1111 | also known as the Adjoint Monte Carlo method. In this method particles are generated on the external
|
|---|
| 1112 | boundary of the sensitive part of the geometry and then are tracked backward in the geometry till they
|
|---|
| 1113 | reach the external source surface,
|
|---|
| 1114 | or exceed an energy threshold. By this way the computing time is focused only on particle tracks
|
|---|
| 1115 | that are contributing to the tallies.
|
|---|
| 1116 | The RMC method is much rapid than the Forward MC method when the sensitive part of the geometry is
|
|---|
| 1117 | small compared to the rest of the geometry and to the external source, that has to be extensive and
|
|---|
| 1118 | not beam like. At the moment the RMC method is implemented in Geant4 only for some electromagnetic
|
|---|
| 1119 | processes (see <xref linkend="sect.EvtBias.ReverseMC.InG4.Process" />). An example illustrating the use
|
|---|
| 1120 | of the Reverse MC method in Geant4 is distributed within the Geant4
|
|---|
| 1121 | toolkit in <emphasis role="bold">examples/extended/biasing/ReverseMC01</emphasis>.
|
|---|
| 1122 | </para>
|
|---|
| 1123 |
|
|---|
| 1124 | <!-- ******************* Section (Level#3) ****************** -->
|
|---|
| 1125 | <sect3 id="sect.EvtBias.ReverseMC.InG4">
|
|---|
| 1126 | <title>
|
|---|
| 1127 | Treatment of the Reverse MC method in Geant4
|
|---|
| 1128 | </title>
|
|---|
| 1129 |
|
|---|
| 1130 | <para>
|
|---|
| 1131 | Different G4Adjoint classes have been implemented into the Geant4
|
|---|
| 1132 | toolkit in order to run an adjoint/reverse simulation in a Geant4 application.
|
|---|
| 1133 | This implementation is illustrated in <xref linkend="fig.EvtBias.ReverseMC.InG4_1" />.
|
|---|
| 1134 | An adjoint run is divided in a serie of alternative adjoint and forward tracking of adjoint and normal particles.
|
|---|
| 1135 | One Geant4 event treats one of this tracking phase.
|
|---|
| 1136 | </para>
|
|---|
| 1137 |
|
|---|
| 1138 | <figure id="fig.EvtBias.ReverseMC.InG4_1">
|
|---|
| 1139 | <title>
|
|---|
| 1140 | Schematic view of an adjoint/reverse simulation in Geant4
|
|---|
| 1141 | </title>
|
|---|
| 1142 | <mediaobject>
|
|---|
| 1143 | <imageobject role="fo">
|
|---|
| 1144 | <imagedata fileref="./AllResources/Fundamentals/ReverseMC_tracking.png"
|
|---|
| 1145 | format="png" align="center" />
|
|---|
| 1146 | </imageobject>
|
|---|
| 1147 | <imageobject role="html">
|
|---|
| 1148 | <imagedata fileref="./AllResources/Fundamentals/ReverseMC_tracking.png"
|
|---|
| 1149 | format="png" align="center" />
|
|---|
| 1150 | </imageobject>
|
|---|
| 1151 | </mediaobject>
|
|---|
| 1152 | </figure>
|
|---|
| 1153 |
|
|---|
| 1154 |
|
|---|
| 1155 | <!-- ******************* Section (Level#4) ****************** -->
|
|---|
| 1156 | <sect4 id="sect.EvtBias.ReverseMC.InG4.AdjointTracking">
|
|---|
| 1157 | <title>
|
|---|
| 1158 | Adjoint tracking phase
|
|---|
| 1159 | </title>
|
|---|
| 1160 |
|
|---|
| 1161 | <para>
|
|---|
| 1162 | Adjoint particles (adjoint_e-, adjoint_gamma,...) are generated one by one on the so called adjoint source
|
|---|
| 1163 | with random position, energy (1/E distribution) and direction. The adjoint source is the
|
|---|
| 1164 | external surface of a user defined volume or of a user defined sphere. The adjoint
|
|---|
| 1165 | source should contain one or several sensitive volumes and should be small compared to the entire geometry.
|
|---|
| 1166 | The user can set the minimum and maximum energy of the adjoint source. After its
|
|---|
| 1167 | generation the adjoint primary particle is tracked backward in the geometry till a user defined
|
|---|
| 1168 | external surface
|
|---|
| 1169 | (spherical or boundary of a volume) or is killed before if it reaches a user defined upper energy limit that
|
|---|
| 1170 | represents the maximum energy of the external source. During the reverse tracking, reverse
|
|---|
| 1171 | processes take place where the adjoint particle being tracked can be either scattered
|
|---|
| 1172 | or transformed in another type of adjoint particle. During the reverse tracking the
|
|---|
| 1173 | G4AdjointSimulationManager replaces the user defined primary, run, stepping, ... actions, by its own actions.
|
|---|
| 1174 | A reverse tracking phase corresponds to one Geant4 event.
|
|---|
| 1175 | </para>
|
|---|
| 1176 |
|
|---|
| 1177 | </sect4>
|
|---|
| 1178 |
|
|---|
| 1179 | <!-- ******************* Section (Level#4) ****************** -->
|
|---|
| 1180 | <sect4 id="sect.EvtBias.ReverseMC.InG4.ForwardTracking">
|
|---|
| 1181 | <title>
|
|---|
| 1182 | Forward tracking phase
|
|---|
| 1183 | </title>
|
|---|
| 1184 |
|
|---|
| 1185 | <para>
|
|---|
| 1186 | When an adjoint particle reaches the external surface its weight, type, position,
|
|---|
| 1187 | and direction are registered and a normal primary particle, with a type equivalent to the last generated primary
|
|---|
| 1188 | adjoint, is generated with the same energy, position but opposite direction and is tracked in the forward direction
|
|---|
| 1189 | in the sensitive region as in a forward MC simulation.
|
|---|
| 1190 | During this forward tracking phase the
|
|---|
| 1191 | event, stacking, stepping, tracking actions defined by the user for his forward simulation are used.
|
|---|
| 1192 | By this clear separation between
|
|---|
| 1193 | adjoint and forward tracking phases, the code of the user developed for a forward simulation
|
|---|
| 1194 | should be only slightly modified to adapt it for an adjoint simulation (see <xref linkend="sect.EvtBias.ReverseMC.UserCoding" />).
|
|---|
| 1195 | Indeed the computation of the signals is done by the same actions
|
|---|
| 1196 | or classes that the one used in the forward simulation mode.
|
|---|
| 1197 | A forward tracking phase corresponds to one G4 event.
|
|---|
| 1198 | </para>
|
|---|
| 1199 |
|
|---|
| 1200 | </sect4>
|
|---|
| 1201 |
|
|---|
| 1202 | <!-- ******************* Section (Level#4) ****************** -->
|
|---|
| 1203 | <sect4 id="sect.EvtBias.ReverseMC.InG4.Process">
|
|---|
| 1204 | <title>
|
|---|
| 1205 | Reverse processes
|
|---|
| 1206 | </title>
|
|---|
| 1207 |
|
|---|
| 1208 | <para>
|
|---|
| 1209 | During the reverse tracking, reverse processes act on the adjoint particles.
|
|---|
| 1210 | The reverse processes that are at the moment available in Geant4 are the:
|
|---|
| 1211 | <itemizedlist spacing="compact">
|
|---|
| 1212 | <listitem><para>
|
|---|
| 1213 | Reverse discrete ionization for e-, proton and ions
|
|---|
| 1214 | </para></listitem>
|
|---|
| 1215 | <listitem><para>
|
|---|
| 1216 | Continuous gain of energy by ionization and bremsstrahlung for e- and by ionization for protons and ions
|
|---|
| 1217 | </para></listitem>
|
|---|
| 1218 | <listitem><para>
|
|---|
| 1219 | Reverse discrete e- bremsstrahlung
|
|---|
| 1220 | </para></listitem>
|
|---|
| 1221 | <listitem><para>
|
|---|
| 1222 | Reverse photo-electric effect
|
|---|
| 1223 | </para></listitem>
|
|---|
| 1224 | <listitem><para>
|
|---|
| 1225 | Reverse Compton scattering
|
|---|
| 1226 | </para></listitem>
|
|---|
| 1227 | <listitem><para>
|
|---|
| 1228 | Approximated multiple scattering (see comment in <xref linkend="sect.EvtBias.ReverseMC.Limitation.ReverseMS"/>)
|
|---|
| 1229 | </para></listitem>
|
|---|
| 1230 | </itemizedlist>
|
|---|
| 1231 | It is important to note that the electromagnetic reverse processes are cut dependent
|
|---|
| 1232 | as their equivalent forward processes. The implementation of the reverse processes is based on
|
|---|
| 1233 | the forward processes implemented in the G4 standard electromagnetic package.
|
|---|
| 1234 | </para>
|
|---|
| 1235 |
|
|---|
| 1236 | </sect4>
|
|---|
| 1237 |
|
|---|
| 1238 | <!-- ******************* Section (Level#4) ****************** -->
|
|---|
| 1239 | <sect4 id="sect.EvtBias.ReverseMC.InG4.RemarkOnNbEvents">
|
|---|
| 1240 | <title>
|
|---|
| 1241 | Nb of adjoint particle types and nb of G4 events of an adjoint simulation
|
|---|
| 1242 | </title>
|
|---|
| 1243 |
|
|---|
| 1244 | <para>
|
|---|
| 1245 | The list of type of adjoint and forward particles that are generated on the adjoint source
|
|---|
| 1246 | and considered in the simulation is a function of the adjoint processes declared in the physics list.
|
|---|
| 1247 | For example if only the e- and gamma electromagnetic processes are considered,
|
|---|
| 1248 | only adjoint e- and adjoint gamma will be considered as primaries.
|
|---|
| 1249 | In this case an adjoint event will be divided in four G4 event consisting in the reverse tracking of an adjoint e-,
|
|---|
| 1250 | the forward tracking of its equivalent forward e-, the reverse tracking of
|
|---|
| 1251 | an adjoint gamma, and the forward tracking of its equivalent forward gamma.
|
|---|
| 1252 | In this case a run of 100 adjoint events will consist into 400 Geant4 events.
|
|---|
| 1253 | If the proton ionization is also considered adjoint and forward protons are also generated as primaries
|
|---|
| 1254 | and 600 Geant4 events are processed for 100 adjoint events.
|
|---|
| 1255 | </para>
|
|---|
| 1256 |
|
|---|
| 1257 | </sect4>
|
|---|
| 1258 |
|
|---|
| 1259 | </sect3>
|
|---|
| 1260 |
|
|---|
| 1261 | <!-- ******************* Section (Level#3) ****************** -->
|
|---|
| 1262 | <sect3 id="sect.EvtBias.ReverseMC.UserCoding">
|
|---|
| 1263 | <title>
|
|---|
| 1264 | How to update a G4 application to use the reverse Monte Carlo mode
|
|---|
| 1265 | </title>
|
|---|
| 1266 |
|
|---|
| 1267 | <para>
|
|---|
| 1268 | Some modifications are needed to an existing Geant4 application in order to adapt
|
|---|
| 1269 | it for the use of the reverse simulation mode
|
|---|
| 1270 | (see also the G4 example <emphasis role="bold">examples/extended/biasing/ReverseMC01</emphasis>).
|
|---|
| 1271 | It consists into the:
|
|---|
| 1272 |
|
|---|
| 1273 | <itemizedlist spacing="compact">
|
|---|
| 1274 | <listitem><para>
|
|---|
| 1275 | Creation of the adjoint simulation manager in the main code
|
|---|
| 1276 | </para></listitem>
|
|---|
| 1277 | <listitem><para>
|
|---|
| 1278 | Optional declaration of user actions that will be used during the adjoint tracking phase
|
|---|
| 1279 | </para></listitem>
|
|---|
| 1280 | <listitem><para>
|
|---|
| 1281 | Use of a special physics lists that combine the adjoint and forward processes
|
|---|
| 1282 | </para></listitem>
|
|---|
| 1283 | <listitem><para>
|
|---|
| 1284 | Modification of the user analysis part of the code
|
|---|
| 1285 | </para></listitem>
|
|---|
| 1286 | </itemizedlist>
|
|---|
| 1287 | </para>
|
|---|
| 1288 |
|
|---|
| 1289 |
|
|---|
| 1290 | <!-- ******************* Section (Level#4) ****************** -->
|
|---|
| 1291 | <sect4 id="sect.EvtBias.ReverseMC.UserCoding.Main">
|
|---|
| 1292 | <title>
|
|---|
| 1293 | Creation of G4AdjointSimManager in the main
|
|---|
| 1294 | </title>
|
|---|
| 1295 | <para>
|
|---|
| 1296 | The class G4AdjointSimManager represents the manager of an adjoint simulation.
|
|---|
| 1297 | This static class should be created somewhere in the main code. The way to do that is illustrated below
|
|---|
| 1298 | <informalexample>
|
|---|
| 1299 | <programlisting>
|
|---|
| 1300 | int main(int argc,char** argv) {
|
|---|
| 1301 | ...
|
|---|
| 1302 | G4AdjointSimManager* theAdjointSimManager = G4AdjointSimManager::GetInstance();
|
|---|
| 1303 | ...
|
|---|
| 1304 | }
|
|---|
| 1305 | </programlisting>
|
|---|
| 1306 | </informalexample>
|
|---|
| 1307 | By doing this the G4 application can be run in the reverse MC mode as well
|
|---|
| 1308 | as in the forward MC mode.
|
|---|
| 1309 | It is important to note that G4AdjointSimManager
|
|---|
| 1310 | is not a new G4RunManager and that the creation of G4RunManager in the main and the declaration of the geometry,
|
|---|
| 1311 | physics list, and user actions to G4RunManager is still needed.
|
|---|
| 1312 | The definition of the adjoint and external sources and the start of an adjoint simulation can be controlled
|
|---|
| 1313 | by G4UI commands in the directory <emphasis role="bold">/adjoint</emphasis>.
|
|---|
| 1314 | </para>
|
|---|
| 1315 | </sect4>
|
|---|
| 1316 |
|
|---|
| 1317 |
|
|---|
| 1318 | <!-- ******************* Section (Level#4) ****************** -->
|
|---|
| 1319 | <sect4 id="sect.EvtBias.ReverseMC.UserCoding.AdjointActions">
|
|---|
| 1320 | <title>
|
|---|
| 1321 | Optional declaration of adjoint user actions
|
|---|
| 1322 | </title>
|
|---|
| 1323 | <para>
|
|---|
| 1324 | During an adjoint simulation the user stepping, tracking, stacking and event actions declared to G4RunManager
|
|---|
| 1325 | are used only during the G4 events dedicated to the forward tracking of normal particles in the sensitive region,
|
|---|
| 1326 | while during the events where adjoint particles are tracked backward the following happen concerning these actions:
|
|---|
| 1327 |
|
|---|
| 1328 | <itemizedlist spacing="compact">
|
|---|
| 1329 | <listitem><para>
|
|---|
| 1330 | The user stepping action is replaced by G4AdjointSteppingAction that is reponsible to stop an adjoint track when
|
|---|
| 1331 | it reaches the external source, exceed the maximum energy of the external source, or cross the adjoint source surface.
|
|---|
| 1332 | If needed the user can declare its own stepping action that will be called by G4AdjointSteppingAction after the
|
|---|
| 1333 | check of stopping track conditions. This stepping action can be different that the stepping action used for the
|
|---|
| 1334 | forward simulation. It is declared to G4AdjointSimManager by the following lines of code :
|
|---|
| 1335 |
|
|---|
| 1336 | <informalexample><programlisting>
|
|---|
| 1337 | G4AdjointSimManager* theAdjointSimManager = G4AdjointSimManager::GetInstance();
|
|---|
| 1338 | theAdjointSimManager->SetAdjointSteppingAction(aUserDefinedSteppingAction);
|
|---|
| 1339 | </programlisting></informalexample>
|
|---|
| 1340 |
|
|---|
| 1341 | </para></listitem>
|
|---|
| 1342 |
|
|---|
| 1343 | <listitem><para>
|
|---|
| 1344 | No stacking, tracking and event actions are considered by default. If needed the user can declare to G4AdjointSimManager
|
|---|
| 1345 | stacking, tracking and event actions that will be used only during the adjoint tracking phase.
|
|---|
| 1346 | The following lines of code show how to declare these adjoint actions to G4AdjointSimManager:
|
|---|
| 1347 |
|
|---|
| 1348 | <informalexample><programlisting>
|
|---|
| 1349 | G4AdjointSimManager* theAdjointSimManager = G4AdjointSimManager::GetInstance();
|
|---|
| 1350 | theAdjointSimManager->SetAdjointEventAction(aUserDefinedEventAction);
|
|---|
| 1351 | theAdjointSimManager->SetAdjointStackingAction(aUserDefinedStackingAction);
|
|---|
| 1352 | theAdjointSimManager->SetAdjointTrackingAction(aUserDefinedTrackingAction);
|
|---|
| 1353 | </programlisting></informalexample>
|
|---|
| 1354 |
|
|---|
| 1355 | </para></listitem>
|
|---|
| 1356 |
|
|---|
| 1357 | </itemizedlist>
|
|---|
| 1358 | By default no user run action is considered in an adjoint simulation but if needed such action can be declared to
|
|---|
| 1359 | G4AdjointSimManager as such:
|
|---|
| 1360 | <informalexample><programlisting>
|
|---|
| 1361 | G4AdjointSimManager* theAdjointSimManager = G4AdjointSimManager::GetInstance();
|
|---|
| 1362 | theAdjointSimManager->SetAdjointRunAction(aUserDefinedRunAction);
|
|---|
| 1363 | </programlisting></informalexample>
|
|---|
| 1364 |
|
|---|
| 1365 | </para>
|
|---|
| 1366 |
|
|---|
| 1367 | </sect4>
|
|---|
| 1368 |
|
|---|
| 1369 | <!-- ******************* Section (Level#4) ****************** -->
|
|---|
| 1370 | <sect4 id="sect.EvtBias.ReverseMC.UserCoding.PhysicsList">
|
|---|
| 1371 | <title>
|
|---|
| 1372 | Physics list for reverse and forward electromagnetic processes
|
|---|
| 1373 | </title>
|
|---|
| 1374 |
|
|---|
| 1375 | <para>
|
|---|
| 1376 | To run an adjoint simulation a specific physics list should be used where existing G4 adjoint electromagnetic processes
|
|---|
| 1377 | and their forward equivalent have to be declared.
|
|---|
| 1378 | An example of such physics list is provided by the class G4AdjointPhysicsLits in the G4 example
|
|---|
| 1379 | <emphasis role="bold">extended/biasing/ReverseMC01</emphasis>.
|
|---|
| 1380 | </para>
|
|---|
| 1381 |
|
|---|
| 1382 | </sect4>
|
|---|
| 1383 |
|
|---|
| 1384 | <!-- ******************* Section (Level#4) ****************** -->
|
|---|
| 1385 | <sect4 id="sect.EvtBias.ReverseMC.UserCoding.Analysis">
|
|---|
| 1386 | <title>
|
|---|
| 1387 | Modification in the analysis part of the code
|
|---|
| 1388 | </title>
|
|---|
| 1389 |
|
|---|
| 1390 | <para>
|
|---|
| 1391 | The user code should be modified to normalize the signals computed during the forward tracking phase to the weight of the last adjoint particle
|
|---|
| 1392 | that reaches the external surface.
|
|---|
| 1393 | This weight represents the statistical weight that the last full adjoint tracks (from the adjoint source
|
|---|
| 1394 | to the external source) would have in a forward simulation. If multiplied by a signal and registered in function of energy
|
|---|
| 1395 | and/or direction the simulation results will give an answer matrix of this signal.
|
|---|
| 1396 | To normalize it to a given spectrum it has to be furthermore multiplied by a directional differential flux
|
|---|
| 1397 | corresponding to this spectrum
|
|---|
| 1398 |
|
|---|
| 1399 | The weight, direction, position , kinetic energy and type of the last adjoint particle that reaches the
|
|---|
| 1400 | external source, and that would represents the primary of a forward simulation, can be get from G4AdjointSimManager by using for example the following line of codes
|
|---|
| 1401 | <informalexample><programlisting>
|
|---|
| 1402 |
|
|---|
| 1403 | G4AdjointSimManager* theAdjointSimManager = G4AdjointSimManager::GetInstance();
|
|---|
| 1404 | G4String particle_name = theAdjointSimManager->GetFwdParticleNameAtEndOfLastAdjointTrack();
|
|---|
| 1405 | G4int PDGEncoding= theAdjointSimManager->GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack();
|
|---|
| 1406 | G4double weight = theAdjointSimManager->GetWeightAtEndOfLastAdjointTrack();
|
|---|
| 1407 | G4double Ekin = theAdjointSimManager->GetEkinAtEndOfLastAdjointTrack();
|
|---|
| 1408 | G4double Ekin_per_nuc=theAdjointSimManager->GetEkinNucAtEndOfLastAdjointTrack(); // in case of ions
|
|---|
| 1409 | G4ThreeVector dir = theAdjointSimManager->GetDirectionAtEndOfLastAdjointTrack();
|
|---|
| 1410 | G4ThreeVector pos = theAdjointSimManager->GetPositionAtEndOfLastAdjointTrack();
|
|---|
| 1411 |
|
|---|
| 1412 | </programlisting></informalexample>
|
|---|
| 1413 |
|
|---|
| 1414 | </para>
|
|---|
| 1415 |
|
|---|
| 1416 | <para>
|
|---|
| 1417 | In order to have a code working for both forward and adjoint simulation mode, the extra code needed in user actions or analysis
|
|---|
| 1418 | manager for the adjoint
|
|---|
| 1419 | simulation mode can be separated to the code needed only for the normal forward simulation by using the following public method
|
|---|
| 1420 | of G4AdjointSimManager:
|
|---|
| 1421 | <informalexample><programlisting>
|
|---|
| 1422 | G4bool GetAdjointSimMode();
|
|---|
| 1423 | </programlisting></informalexample>
|
|---|
| 1424 | that returns true if an adjoint simulation is running and false if not.
|
|---|
| 1425 |
|
|---|
| 1426 | </para>
|
|---|
| 1427 |
|
|---|
| 1428 | <para>
|
|---|
| 1429 | The following code example shows how to normalize a detector signal and compute an answer matrix
|
|---|
| 1430 | in the case of an adjoint simulation.
|
|---|
| 1431 | <example id="sect.EvtBias.ReverseMC.UserCoding.Analysis_1">
|
|---|
| 1432 | <title>
|
|---|
| 1433 | Normalization in the case of an adjoint simulation. The detector signal S computed during the forward tracking
|
|---|
| 1434 | phase is normalized to a primary source of e- with a differential directional flux given by the function F.
|
|---|
| 1435 | An answer matrix of the signal is also computed.
|
|---|
| 1436 | </title>
|
|---|
| 1437 |
|
|---|
| 1438 | <programlisting>
|
|---|
| 1439 |
|
|---|
| 1440 | G4double S = ...; // signal in the sensitive volume computed during a forward tracking phase
|
|---|
| 1441 |
|
|---|
| 1442 | //Normalization of the signal for an adjoint simulation
|
|---|
| 1443 | G4AdjointSimManager* theAdjSimManager = G4AdjointSimManager::GetInstance();
|
|---|
| 1444 | if (theAdjSimManager->GetAdjointSimMode()) {
|
|---|
| 1445 | G4double normalized_S=0.; //normalized to a given e- primary spectrum
|
|---|
| 1446 | G4double S_for_answer_matrix=0.; //for e- answer matrix
|
|---|
| 1447 |
|
|---|
| 1448 | if (theAdjSimManager->GetFwdParticleNameAtEndOfLastAdjointTrack() == "e-"){
|
|---|
| 1449 | G4double ekin_prim = theAdjSimManager->GetEkinAtEndOfLastAdjointTrack();
|
|---|
| 1450 | G4ThreeVector dir_prim = theAdjointSimManager->GetDirectionAtEndOfLastAdjointTrack();
|
|---|
| 1451 | G4double weight_prim = theAdjSimManager->GetWeightAtEndOfLastAdjointTrack();
|
|---|
| 1452 | S_for_answer_matrix = S*weight_prim;
|
|---|
| 1453 | normalized_S = S_for_answer_matrix*F(ekin_prim,dir); //F(ekin_prim,dir_prim) gives the differential directional flux of primary e-
|
|---|
| 1454 | }
|
|---|
| 1455 | //follows the code where normalized_S and S_for_answer_matrix are registered or whatever
|
|---|
| 1456 | ....
|
|---|
| 1457 | }
|
|---|
| 1458 |
|
|---|
| 1459 | //analysis/normalization code for forward simulation
|
|---|
| 1460 | else {
|
|---|
| 1461 | ...
|
|---|
| 1462 | }
|
|---|
| 1463 | ...
|
|---|
| 1464 | </programlisting>
|
|---|
| 1465 | </example>
|
|---|
| 1466 |
|
|---|
| 1467 | </para>
|
|---|
| 1468 |
|
|---|
| 1469 | </sect4>
|
|---|
| 1470 |
|
|---|
| 1471 | </sect3>
|
|---|
| 1472 |
|
|---|
| 1473 | <!-- ******************* Section (Level#3) ****************** -->
|
|---|
| 1474 | <sect3 id="sect.EvtBias.ReverseMC.Control">
|
|---|
| 1475 | <title>
|
|---|
| 1476 | Control of an adjoint simulation
|
|---|
| 1477 | </title>
|
|---|
| 1478 |
|
|---|
| 1479 | <para>
|
|---|
| 1480 | The G4UI commands in the directory
|
|---|
| 1481 | <ulink url="./AllResources/Control/UIcommands/_adjoint_.html">/adjoint</ulink>.
|
|---|
| 1482 | allow the user to :
|
|---|
| 1483 | <itemizedlist spacing="compact">
|
|---|
| 1484 | <listitem><para>
|
|---|
| 1485 | Define the adjoint source where adjoint primaries are generated
|
|---|
| 1486 | </para></listitem>
|
|---|
| 1487 | <listitem><para>
|
|---|
| 1488 | Define the external source till which adjoint particles are tracked
|
|---|
| 1489 | </para></listitem>
|
|---|
| 1490 | <listitem><para>
|
|---|
| 1491 | Start an adjoint simulation
|
|---|
| 1492 | </para></listitem>
|
|---|
| 1493 | </itemizedlist>
|
|---|
| 1494 | </para>
|
|---|
| 1495 | </sect3>
|
|---|
| 1496 |
|
|---|
| 1497 | <!-- ******************* Section (Level#3) ****************** -->
|
|---|
| 1498 | <sect3 id="sect.EvtBias.ReverseMC.Limitation">
|
|---|
| 1499 | <title>
|
|---|
| 1500 | Known issues in the Reverse MC mode
|
|---|
| 1501 | </title>
|
|---|
| 1502 |
|
|---|
| 1503 | <!-- ******************* Section (Level#4) ****************** -->
|
|---|
| 1504 | <sect4 id="sect.EvtBias.ReverseMC.Limitation.Weight">
|
|---|
| 1505 | <title>
|
|---|
| 1506 | Occasional wrong high weight in the adjoint simulation
|
|---|
| 1507 | </title>
|
|---|
| 1508 |
|
|---|
| 1509 | <para>
|
|---|
| 1510 | In rare cases an adjoint track may get a wrong high weight when reaching the external source.
|
|---|
| 1511 | While this happens not often it may corrupt the simulation results significantly. This happens
|
|---|
| 1512 | in some tracks where both reverse photo-electric and bremsstrahlung processes take place at low energy.
|
|---|
| 1513 | We still need some investigations to remove this problem at the level of physical adjoint/reverse processes.
|
|---|
| 1514 | However this problem can be solved at the level of event actions or analysis in the user code by adding a test on the
|
|---|
| 1515 | normalized signal during an adjoint simulation. An example of such test has been implemented in the Geant4 example
|
|---|
| 1516 | <emphasis role="bold"> extended/biasing/ReverseMC01 </emphasis>.
|
|---|
| 1517 | In this implementation an event is rejected when the relative error of the computed normalized energy deposited
|
|---|
| 1518 | increases during one event by more than 50% while the computed precision is already below 10%.
|
|---|
| 1519 | </para>
|
|---|
| 1520 |
|
|---|
| 1521 | </sect4>
|
|---|
| 1522 |
|
|---|
| 1523 | <!-- ******************* Section (Level#4) ****************** -->
|
|---|
| 1524 | <sect4 id="sect.EvtBias.ReverseMC.Limitation.ReverseBrem">
|
|---|
| 1525 | <title>
|
|---|
| 1526 | Reverse bremsstrahlung
|
|---|
| 1527 | </title>
|
|---|
| 1528 |
|
|---|
| 1529 | <para>
|
|---|
| 1530 | A difference between the differential cross sections used in the adjoint and forward bremsstrahlung
|
|---|
| 1531 | models is the source of a higher flux of >100 keV gamma in the reverse simulation compared to the forward simulation mode.
|
|---|
| 1532 | In principle the adjoint processes/models should make use of the direct differential cross section to sample
|
|---|
| 1533 | the adjoint secondaries and compute the adjoint cross section. However due to the way the effective differential cross section is
|
|---|
| 1534 | considered in the forward model G4eBremsstrahlungModel this was not possible to achieve for the reverse bremsstrahlung.
|
|---|
| 1535 | Indeed the differential cross section used in G4AdjointeBremstrahlungModel is obtained by the numerical derivation
|
|---|
| 1536 | over the cut energy of the direct cross section provided by G4eBremsstrahlungModel.
|
|---|
| 1537 | This would be a correct procedure if the distribution of secondary in G4eBremsstrahlungModel
|
|---|
| 1538 | would match this differential cross section. Unfortunately it is not the case as independent parameterization are used
|
|---|
| 1539 | in G4eBremsstrahlungModel for both the cross sections and the sampling of secondaries. (It means that in the forward case
|
|---|
| 1540 | if one would integrate the effective differential cross section considered in the simulation we would not find back
|
|---|
| 1541 | the used cross section).
|
|---|
| 1542 | In the future we plan to correct this problem by using an extra weight correction factor after the occurrence of a reverse
|
|---|
| 1543 | bremsstrahlung. This weight factor should be the ratio between the differential CS used in the adjoint simulation and the
|
|---|
| 1544 | one effectively used in the forward processes. As it is impossible to have a simple and direct access to the forward differential CS
|
|---|
| 1545 | in G4eBremsstrahlungModel we are investigating the feasibility to use the differential CS considered in
|
|---|
| 1546 | G4Penelope models.
|
|---|
| 1547 | </para>
|
|---|
| 1548 |
|
|---|
| 1549 | </sect4>
|
|---|
| 1550 |
|
|---|
| 1551 | <!-- ******************* Section (Level#4) ****************** -->
|
|---|
| 1552 | <sect4 id="sect.EvtBias.ReverseMC.Limitation.ReverseMS">
|
|---|
| 1553 | <title>
|
|---|
| 1554 | Reverse multiple scattering
|
|---|
| 1555 | </title>
|
|---|
| 1556 |
|
|---|
| 1557 | <para>
|
|---|
| 1558 | For the reverse multiple scattering the same model is used than in the forward case.
|
|---|
| 1559 | This approximation makes that the discrepancy between the adjoint and forward
|
|---|
| 1560 | simulation cases can get to a level of ~ 10-15% relative differences in the test cases that we have considered.
|
|---|
| 1561 | In the future we plan to improve the adjoint multiple scattering models by forcing the computation of
|
|---|
| 1562 | multiple scattering effect at the end of an adjoint step.
|
|---|
| 1563 | </para>
|
|---|
| 1564 |
|
|---|
| 1565 | </sect4>
|
|---|
| 1566 |
|
|---|
| 1567 | </sect3>
|
|---|
| 1568 | </sect2>
|
|---|
| 1569 | </sect1>
|
|---|