EIC Software
Reference for
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
CbmLitUtils.h
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file CbmLitUtils.h
1
#ifndef CBMLITUTILS_H_
2
#define CBMLITUTILS_H_
3
4
class
TCanvas;
5
6
#include <vector>
7
#include <string>
8
#include <sstream>
9
#include <iostream>
10
11
using
std::string;
12
using
std::vector
;
13
14
namespace
lit
15
{
16
17
template
<
class
T>
18
string
ToString
(
19
const
T
&
value
)
20
{
21
std::stringstream ss;
22
ss << (
T
)value;
23
return
ss.str();
24
}
25
26
template
<
class
T>
27
string
NumberToString
(
28
const
T
&
value
,
int
precision
= 1)
29
{
30
// First determine number of digits in float
31
string
digis = ToString<int>(
value
);
32
int
ndigis = digis.size();
33
34
std::stringstream ss;
35
ss.precision(ndigis +
precision
);
36
ss <<
value
;
37
return
ss.str();
38
}
39
40
/* Returns -1 if x<0, +1 if x>0, 0 if x==0 */
41
template
<
class
T>
42
int
Sign
(
43
const
T
&
x
)
44
{
45
static
const
T
ZERO = 0;
46
return
(x > ZERO) ? 1 : ((x < ZERO) ? -1 : 0);
47
}
48
49
void
SaveCanvasAsImage
(
50
TCanvas*
c
,
51
const
std::string& dir);
52
53
string
FindAndReplace
(
54
const
string
&
name
,
55
const
string
& oldSubstr,
56
const
string
& newSubstr);
57
58
vector<string>
Split
(
59
const
string
&
name
,
60
char
delimiter);
61
}
62
63
#endif
/* CBMLITUTILS_H_ */
EicRoot
blob
master
littrack
std
utils
CbmLitUtils.h
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:36
using
1.8.2 with
EIC GitHub integration