ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
templates.hh
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file templates.hh
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
//
27
//
28
//
29
// -*- C++ -*-
30
//
31
// -----------------------------------------------------------------------
32
// This file should define some platform dependent features and some
33
// useful utilities.
34
// -----------------------------------------------------------------------
35
36
// =======================================================================
37
// Gabriele Cosmo - Created: 5th September 1995
38
// Gabriele Cosmo - Minor change: 08/02/1996
39
// Gabriele Cosmo - Added DBL_MIN, FLT_MIN, DBL_DIG,
40
// DBL_MAX, FLT_DIG, FLT_MAX : 12/04/1996
41
// Gabriele Cosmo - Removed boolean enum definition : 29/11/1996
42
// Gunter Folger - Added G4SwapPtr() and G4SwapObj() : 31/07/1997
43
// Gabriele Cosmo - Adapted signatures of min(), max() to
44
// STL's ones, thanks to E.Tcherniaev : 31/07/1997
45
// Gabriele Cosmo,
46
// Evgueni Tcherniaev - Migrated to CLHEP: 04/12/1997
47
// =======================================================================
48
49
#ifndef templates_h
50
#define templates_h 1
51
52
#include <limits>
53
#include <climits>
54
55
//
56
// If HIGH_PRECISION is defined to TRUE (ie. != 0) then the type "Float"
57
// is typedefed to "double". If it is FALSE (ie. 0) it is typedefed
58
// to "float".
59
//
60
#ifndef HIGH_PRECISION
61
#define HIGH_PRECISION 1
62
#endif
63
64
#if HIGH_PRECISION
65
typedef
double
Float
;
66
#else
67
typedef
float
Float
;
68
#endif
69
70
// Following values have been taken from limits.h
71
// and temporarly defined for portability on HP-UX.
72
73
#ifndef DBL_MIN
/* Min decimal value of a double */
74
#define DBL_MIN std::numeric_limits<double>::min() // 2.2250738585072014e-308
75
#endif
76
77
#ifndef DBL_DIG
/* Digits of precision of a double */
78
#define DBL_DIG std::numeric_limits<double>::digits10 // 15
79
#endif
80
81
#ifndef DBL_MAX
/* Max decimal value of a double */
82
#define DBL_MAX std::numeric_limits<double>::max() // 1.7976931348623157e+308
83
#endif
84
85
#ifndef DBL_EPSILON
86
#define DBL_EPSILON std::numeric_limits<double>::epsilon()
87
#endif // 2.2204460492503131e-16
88
89
#ifndef FLT_MIN
/* Min decimal value of a float */
90
#define FLT_MIN std::numeric_limits<float>::min() // 1.17549435e-38F
91
#endif
92
93
#ifndef FLT_DIG
/* Digits of precision of a float */
94
#define FLT_DIG std::numeric_limits<float>::digits10 // 6
95
#endif
96
97
#ifndef FLT_MAX
/* Max decimal value of a float */
98
#define FLT_MAX std::numeric_limits<float>::max() // 3.40282347e+38F
99
#endif
100
101
#ifndef FLT_EPSILON
102
#define FLT_EPSILON std::numeric_limits<float>::epsilon()
103
#endif // 1.192092896e-07F
104
105
#ifndef MAXFLOAT
/* Max decimal value of a float */
106
#define MAXFLOAT std::numeric_limits<float>::max() // 3.40282347e+38F
107
#endif
108
109
#ifndef INT_MAX
/* Max decimal value of a int */
110
#define INT_MAX std::numeric_limits<int>::max() // 2147483647
111
#endif
112
113
#ifndef INT_MIN
/* Min decimal value of a int */
114
#define INT_MIN std::numeric_limits<int>::min() // -2147483648
115
#endif
116
117
#ifndef LOG_EKIN_MIN
/* Min value of the natural logarithm of kin. energy. */
118
#define LOG_EKIN_MIN -30
119
#endif
120
121
//---------------------------------
122
123
template
<
class
T>
124
inline
void
G4SwapPtr
(
T
*&
a
,
T
*&
b
)
125
{
126
T
*
tmp
=
a
;
127
a =
b
;
128
b =
tmp
;
129
}
130
131
template
<
class
T>
132
inline
void
G4SwapObj
(
T
*
a
,
T
*
b
)
133
{
134
T
tmp
= *
a
;
135
*a = *
b
;
136
*b =
tmp
;
137
}
138
139
//-----------------------------
140
141
#ifndef G4_SQR_DEFINED
142
#define G4_SQR_DEFINED
143
#ifdef sqr
144
#undef sqr
145
#endif
146
147
template
<
class
T>
148
inline
T
sqr
(
const
T
&
x
)
149
{
150
return
x*
x
;
151
}
152
#endif
153
154
inline
int
G4lrint
(
double
ad)
155
{
156
return
(ad>0) ?
static_cast<
int
>
(ad+.5) :
static_cast<
int
>
(ad-.5);
157
}
158
159
inline
int
G4lint
(
double
ad)
160
{
161
return
(ad>0) ?
static_cast<
int
>
(ad) : static_cast<int>(ad-1.);
162
}
163
164
inline
int
G4rint
(
double
ad)
165
{
166
return
(ad>0) ?
static_cast<
int
>
(ad+1) : static_cast<int>(ad);
167
}
168
169
//-----------------------------
170
171
// Use the following function to get rid of "unused parameter" warnings
172
// Example:
173
//
174
// #ifdef SOME_CONDITION
175
// void doSomething(int val)
176
// {
177
// something = val;
178
// }
179
// #else
180
// void doSomething(int)
181
// { }
182
// #endif
183
//
184
// can be simplified to:
185
//
186
// void doSomething(int val)
187
// {
188
// #ifdef SOME_CONDITION
189
// something = val;
190
// #else
191
// G4ConsumeParameters(val);
192
// #endif
193
// }
194
//
195
// or:
196
//
197
// void doSomething(int val)
198
// {
199
// #ifdef SOME_CONDITION
200
// something = val;
201
// #endif
202
// // function call does nothing -- will be "optimized" out
203
// G4ConsumeParameters(val);
204
// }
205
//
206
template
<
typename
... _Args>
207
inline
void
G4ConsumeParameters
(_Args&&...)
208
{ }
209
210
#endif // templates_h
geant4
tree
geant4-10.6-release
source
global
management
include
templates.hh
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:21
using
1.8.2 with
ECCE GitHub integration