Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4qss_misc.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// Authors: Lucio Santi, Rodrigo Castro 2018-21
27
28#ifndef _QSS_MISC_H_
29#define _QSS_MISC_H_
30
32typedef struct QSSSubstep_ *QSSSubstep;
33
34namespace Qss_misc {
35 // Convention of Geant4 notation of indices
36 constexpr unsigned int PXidx= 0;
37 constexpr unsigned int PYidx= 1;
38 constexpr unsigned int PZidx= 2;
39
40 constexpr unsigned int VXidx= 3;
41 constexpr unsigned int VYidx= 4;
42 constexpr unsigned int VZidx= 5;
43
44 // Method parameters & constants
45 constexpr unsigned int MAX_QSS_STEPPER_ORDER= 3;
46 constexpr unsigned int VAR_IDX_END= 6;
47 constexpr unsigned int MIN_SUBSTEPS= 20;
48
49 constexpr G4double INF= 1.0e20;
50}
51
52#if defined(WIN32) || defined(__MINGW32__)
53#define unlikely(x) (x) // Until C++20 can be assumed
54#define likely(x) (x) // >> ditto >>
55#else
56#define unlikely(x) __builtin_expect((x),0) // gcc/clang extension - not portable
57#define likely(x) __builtin_expect((x),1)
58#endif
59
60// #define likely(x) (x) // [[likely]] // The C++20 portable way
61// #define likely(x) (x) // [[unlikely]] // >> >>
62// This syntax appears to be part of C++20
63// See
64// - https://en.cppreference.com/w/cpp/language/attributes/likely
65// - https://stackoverflow.com/questions/51797959/how-to-use-c20s-likely-unlikely-attribute-in-if-else-statement
66// - https://usingstdcpp.org/2018/03/18/jacksonville18-iso-cpp-report/
67
68#define SUBSTEP_STRUCT(sim, i) (sim->substeps[i])
69#define SUBSTEP_START(sim, i) (sim->substeps[(i)].start_time)
70#define SUBSTEP_X(sim, i) (sim->substeps[(i)].x)
71#define SUBSTEP_TX(sim, i) (sim->substeps[(i)].tx)
72#define SUBSTEP_LEN(sim, i) (sim->substeps[(i)].len)
73
74#define LAST_SUBSTEP_STRUCT(sim) (SUBSTEP_STRUCT(sim, sim->cur_substep_idx-1))
75
76#define CUR_SUBSTEP_START(sim) (SUBSTEP_START(sim, sim->cur_substep_idx))
77#define CUR_SUBSTEP_X(sim) (SUBSTEP_X(sim, sim->cur_substep_idx))
78#define CUR_SUBSTEP_TX(sim) (SUBSTEP_TX(sim, sim->cur_substep_idx))
79#define CUR_SUBSTEP_LEN(sim) (SUBSTEP_LEN(sim, sim->cur_substep_idx))
80
81#define CUR_SUBSTEP(sim) (sim->cur_substep_idx)
82#define LAST_SUBSTEP(sim) (sim->cur_substep_idx-1)
83#define MAX_SUBSTEP(sim) (sim->max_substep_idx)
84#define SUBSTEPS(sim) (sim->substeps)
85
94
121
122#endif
double G4double
Definition G4Types.hh:83
struct QSS_simulator_ * QSS_simulator
Definition G4qss_misc.hh:31
struct QSSSubstep_ * QSSSubstep
Definition G4qss_misc.hh:32
constexpr unsigned int PZidx
Definition G4qss_misc.hh:38
constexpr unsigned int PYidx
Definition G4qss_misc.hh:37
constexpr unsigned int VZidx
Definition G4qss_misc.hh:42
constexpr unsigned int VXidx
Definition G4qss_misc.hh:40
constexpr unsigned int VAR_IDX_END
Definition G4qss_misc.hh:46
constexpr G4double INF
Definition G4qss_misc.hh:49
constexpr unsigned int MIN_SUBSTEPS
Definition G4qss_misc.hh:47
constexpr unsigned int PXidx
Definition G4qss_misc.hh:36
constexpr unsigned int MAX_QSS_STEPPER_ORDER
Definition G4qss_misc.hh:45
constexpr unsigned int VYidx
Definition G4qss_misc.hh:41
double tx[Qss_misc::VAR_IDX_END]
Definition G4qss_misc.hh:89
double x[Qss_misc::VAR_IDX_END *(Qss_misc::MAX_QSS_STEPPER_ORDER+1)]
Definition G4qss_misc.hh:88
double start_time
Definition G4qss_misc.hh:91
double tx[Qss_misc::VAR_IDX_END]
Definition G4qss_misc.hh:98
double q[Qss_misc::VAR_IDX_END *(Qss_misc::MAX_QSS_STEPPER_ORDER+1)]
double alg[Qss_misc::VAR_IDX_END]
double dQRel[Qss_misc::VAR_IDX_END]
double tq[Qss_misc::VAR_IDX_END]
double nextStateTime[Qss_misc::VAR_IDX_END]
double dQMin[Qss_misc::VAR_IDX_END]
double x[Qss_misc::VAR_IDX_END *(Qss_misc::MAX_QSS_STEPPER_ORDER+1)]
Definition G4qss_misc.hh:97
double lqu[Qss_misc::VAR_IDX_END]
QSSSubstep substeps
int * SD[Qss_misc::VAR_IDX_END]