BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnManageQA.cxx
Go to the documentation of this file.
1
#include "
BmnManageQA.h
"
2
3
#include <
TDirectory.h
>
4
#include <
TError.h
>
5
#include <
TFile.h
>
6
7
std::vector<std::string>
pathToList
(
const
char
* path);
8
9
TH1F
*
CreateHistogram1
(
const
char
* name,
const
char
* xtitle,
int
nbin,
Float_t
firstBin,
Float_t
lastBin)
10
{
11
TH1F
* h =
new
TH1F
(name, name, nbin, firstBin, lastBin);
12
h->
SetXTitle
(xtitle);
13
return
h;
14
}
15
16
TH2F
*
CreateHistogram2
(
const
char
* name,
17
const
char
* xtitle,
18
const
char
* ytitle,
19
int
nbinx,
20
Float_t
firstBinX,
21
Float_t
lastBinX,
22
int
nbiny,
23
Float_t
firstBinY,
24
Float_t
lastBinY)
25
{
26
TH2F
* h =
new
TH2F
(name, name, nbinx, firstBinX, lastBinX, nbiny, firstBinY, lastBinY);
27
h->
SetXTitle
(xtitle);
28
h->
SetYTitle
(ytitle);
29
return
h;
30
}
31
32
TH3F
*
CreateHistogram3
(
const
char
* name,
33
const
char
* xtitle,
34
const
char
* ytitle,
35
const
char
* ztitle,
36
int
nbinx,
37
Float_t
firstBinX,
38
Float_t
lastBinX,
39
int
nbiny,
40
Float_t
firstBinY,
41
Float_t
lastBinY,
42
int
nbinz,
43
Float_t
firstBinZ,
44
Float_t
lastBinZ)
45
{
46
TH3F
* h =
new
TH3F
(name, name, nbinx, firstBinX, lastBinX, nbiny, firstBinY, lastBinY, nbinz, firstBinZ, lastBinZ);
47
h->
SetXTitle
(xtitle);
48
h->
SetYTitle
(ytitle);
49
h->
SetZTitle
(ztitle);
50
return
h;
51
}
52
53
// go to given directory if directory dose not exists create it
54
55
void
toDirectory
(
const
char
* dir)
56
{
57
std::vector<std::string> splitedPath =
pathToList
(dir);
58
TDirectory
* d = (
TDirectory
*)
gFile
;
59
for
(
size_t
i
= 0;
i
< splitedPath.size();
i
++) {
60
TDirectory
* nextDir = (
TDirectory
*)d->FindObject(splitedPath[
i
].c_str());
61
if
(!nextDir) {
62
d->mkdir(splitedPath[
i
].c_str());
63
nextDir = (
TDirectory
*)d->GetDirectory(splitedPath[
i
].c_str());
64
}
65
if
(!nextDir)
66
Error
(
"QAHelpers::toDir"
,
"Can't create/find directory"
);
67
d = nextDir;
68
}
69
gFile
->cd(dir);
70
}
71
72
// split path for components using '/' as delimeter
73
std::vector<std::string>
pathToList
(
const
char
* path)
74
{
75
std::vector<std::string> result;
76
77
const
char
* begin = path;
78
const
char
* index = path;
79
80
while
(*index) {
81
for
(; *index != 0 && *index !=
'/'
; index++)
82
;
83
if
(begin != index)
84
result.push_back(std::string(begin, index - begin));
85
for
(; *index != 0 && *index ==
'/'
; index++)
86
;
// if several delimeters then skip them all
87
begin = index;
88
}
89
return
result;
90
}
91
92
const
TGeoShape
*
getShape
(
const
TGeoManager
* g,
const
char
* name)
93
{
94
if
(!g) {
95
Error
(
"getShape"
,
"Geo Manager not initialized"
);
96
return
0;
97
}
98
TGeoVolume
* vol =
gGeoManager
->GetVolume(name);
99
if
(!vol) {
100
Error
(
"getShape"
,
"Volume %s not found"
, name);
101
return
0;
102
}
103
104
return
vol->
GetShape
();
105
}
106
107
// Suffixed versions of CreateHistograms...
108
109
TH1F
*
CreateHistogram1
(
const
char
* name,
110
const
std::string& suffix,
111
const
char
* xtitle,
112
int
nbin,
113
Float_t
firstBin,
114
Float_t
lastBin)
115
{
116
std::string fullName = std::string(name) + suffix;
117
return
CreateHistogram1
(fullName.c_str(), xtitle, nbin, firstBin, lastBin);
118
}
119
TH2F
*
CreateHistogram2
(
const
char
* name,
120
const
std::string& suffix,
121
const
char
* xtitle,
122
const
char
* ytitle,
123
int
nbinx,
124
Float_t
firstBinX,
125
Float_t
lastBinX,
126
int
nbiny,
127
Float_t
firstBinY,
128
Float_t
lastBinY)
129
{
130
std::string fullName = std::string(name) + suffix;
131
return
CreateHistogram2
(fullName.c_str(), xtitle, ytitle, nbinx, firstBinX, lastBinX, nbiny, firstBinY, lastBinY);
132
}
133
TH3F
*
CreateHistogram3
(
const
char
* name,
134
const
std::string& suffix,
135
const
char
* xtitle,
136
const
char
* ytitle,
137
const
char
* ztitle,
138
int
nbinx,
139
Float_t
firstBinX,
140
Float_t
lastBinX,
141
int
nbiny,
142
Float_t
firstBinY,
143
Float_t
lastBinY,
144
int
nbinz,
145
Float_t
firstBinZ,
146
Float_t
lastBinZ)
147
{
148
std::string fullName = std::string(name) + suffix;
149
return
CreateHistogram3
(fullName.c_str(), xtitle, ytitle, ztitle, nbinx, firstBinX, lastBinX, nbiny, firstBinY,
150
lastBinY, nbinz, firstBinZ, lastBinZ);
151
}
toDirectory
void toDirectory(const char *dir)
Definition
BmnManageQA.cxx:55
CreateHistogram3
TH3F * CreateHistogram3(const char *name, const char *xtitle, const char *ytitle, const char *ztitle, int nbinx, Float_t firstBinX, Float_t lastBinX, int nbiny, Float_t firstBinY, Float_t lastBinY, int nbinz, Float_t firstBinZ, Float_t lastBinZ)
Definition
BmnManageQA.cxx:32
pathToList
std::vector< std::string > pathToList(const char *path)
Definition
BmnManageQA.cxx:73
getShape
const TGeoShape * getShape(const TGeoManager *g, const char *name)
Definition
BmnManageQA.cxx:92
CreateHistogram2
TH2F * CreateHistogram2(const char *name, const char *xtitle, const char *ytitle, int nbinx, Float_t firstBinX, Float_t lastBinX, int nbiny, Float_t firstBinY, Float_t lastBinY)
Definition
BmnManageQA.cxx:16
CreateHistogram1
TH1F * CreateHistogram1(const char *name, const char *xtitle, int nbin, Float_t firstBin, Float_t lastBin)
Definition
BmnManageQA.cxx:9
i
int i
Definition
P4_F32vec4.h:22
Float_t
float Float_t
TDirectory.h
TError.h
Error
void Error(const char *location, const char *msgfmt,...)
TFile.h
gFile
#define gFile
gGeoManager
R__EXTERN TGeoManager * gGeoManager
TDirectory
TGeoManager
TGeoShape
TGeoVolume
TGeoVolume::GetShape
TGeoShape * GetShape() const
TH1F
TH1::SetXTitle
virtual void SetXTitle(const char *title)
TH1::SetZTitle
virtual void SetZTitle(const char *title)
TH1::SetYTitle
virtual void SetYTitle(const char *title)
TH2F
TH3F
BmnManageQA.h
detectors
gem
BmnManageQA.cxx
Generated on
for BmnRoot by
1.17.0