BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnDataSelector.C
Go to the documentation of this file.
1
// @(#)bmnroot/macro/miscellaneous:$Id$
2
// Author: Pavel Batyuk <pavel.batyuk@jinr.ru> 2019-09-24
3
4
////////////////////////////////////////////////////////////////////////////////
5
// //
6
// BmnDataSelector //
7
// //
8
// A useful macro to select data either for alignment (TString data = "align")//
9
// or phys. analysis (TString data = "phys") //
10
// Valid for RUN6 amn 7 (BM@N, SRC) //
11
// The BM@N UniDb used //
12
////////////////////////////////////////////////////////////////////////////////
13
#include <
Rtypes.h
>
14
#include <
TString.h
>
15
#include <vector>
16
17
R__ADD_INCLUDE_PATH
($VMCWORKDIR)
18
#include "macro/run/bmnloadlibs.C"
19
20
using namespace
std
;
21
22
void
BmnDataSelector
(
Int_t
run_period = 6,
// 6 or 7
23
TString
setup =
"BM@N"
,
// BM@N or SRC
24
TString
data =
"align"
)
25
{
// phys or align
26
// ---- Load libraries --------------------------------------------------
27
bmnloadlibs();
// load BmnRoot libraries
28
29
Int_t
nTargets;
30
TString
* targets =
nullptr
;
31
32
Int_t
nEne;
33
Double_t
* energies =
nullptr
;
34
35
Int_t
kStart = -1;
36
Int_t
kFinish = -1;
37
38
if
(run_period == 7 && setup.Contains(
"BM@N"
)) {
39
nTargets = 6;
40
targets =
new
TString
[nTargets];
41
targets[0] =
"C"
;
42
targets[1] =
"Al"
;
43
targets[2] =
"Cu"
;
44
targets[3] =
"Sn"
;
45
targets[4] =
"Pb"
;
46
targets[5] =
"-"
;
47
48
nEne = 4;
49
energies =
new
Double_t
[nEne];
50
energies[0] = 2.3;
51
energies[1] = 2.6;
52
energies[2] = 2.94;
53
energies[3] = 3.2;
54
55
kStart = 3589;
56
kFinish = 5186;
57
}
else
if
(run_period == 7 && setup.Contains(
"SRC"
)) {
58
nTargets = 6;
59
targets =
new
TString
[nTargets];
60
targets[0] =
"H2"
;
61
targets[1] =
"Pb"
;
62
targets[2] =
"SRC Lead 1"
;
63
targets[3] =
"SRC Lead 2"
;
64
targets[4] =
"SRC Lead 3"
;
65
targets[5] =
"-"
;
66
67
nEne = 1;
68
energies =
new
Double_t
[nEne];
69
energies[0] = 3.17;
70
71
kStart = 2041;
72
kFinish = 3589;
73
74
}
else
{
75
setup =
""
;
76
77
nTargets = 6;
78
targets =
new
TString
[nTargets];
79
targets[0] =
"C"
;
80
targets[1] =
"Al"
;
81
targets[2] =
"Cu"
;
82
targets[3] =
"Pb"
;
83
targets[4] =
"C2H4"
;
84
targets[5] =
"-"
;
85
86
nEne = 3;
87
energies =
new
Double_t
[nEne];
88
energies[0] = 3.5;
89
energies[1] = 4.0;
90
energies[2] = 4.5;
91
92
kStart = 1170;
93
kFinish = 1993;
94
}
95
96
vector<Double_t> ene;
97
vector<TString> targ;
98
vector<Int_t> run;
99
vector<Double_t> apprCurrent;
100
101
for
(
Int_t
iRun = kStart; iRun < kFinish; iRun++) {
102
UniRun
* pCurrentRun =
UniRun::GetRun
(run_period, iRun);
103
if
(pCurrentRun == NULL) {
104
delete
pCurrentRun;
105
continue
;
106
}
107
108
if
(pCurrentRun->
GetEnergy
() == NULL || pCurrentRun->
GetFieldVoltage
() == NULL)
109
continue
;
110
111
run.push_back(iRun);
112
if
(pCurrentRun->
GetTargetParticle
())
113
targ.push_back(*pCurrentRun->
GetTargetParticle
());
114
else
115
targ.push_back(
"-"
);
116
ene.push_back(*pCurrentRun->
GetEnergy
());
117
apprCurrent.push_back(*pCurrentRun->
GetFieldVoltage
());
118
119
delete
pCurrentRun;
120
}
121
122
if
(data !=
"align"
&& data !=
"phys"
) {
123
cout <<
"Specify correct arguments!!"
<< endl;
124
throw
;
125
}
126
const
Int_t
size = run.size();
127
FILE* outFile = fopen(
TString
(
"file_"
+ data +
"Events.txt"
).Data(),
"w"
);
128
fprintf(outFile, (data.Contains(
"align"
) ?
"Files to be used for ALIGNMENT\n"
:
"Files to be used for PHYSICS\n"
));
129
fprintf(outFile,
"\n"
);
130
for
(
Int_t
iEne = 0; iEne < nEne; iEne++) {
131
fprintf(outFile,
"T = %G GeV/n\n"
, energies[iEne]);
132
fprintf(outFile,
"------------------------------------------------------\n"
);
133
134
TString
buffs[nTargets];
135
for
(
Int_t
iEle = 0; iEle < nTargets; iEle++)
136
buffs[iEle] =
TString::Format
(
"%s --> "
, targets[iEle].Data());
137
138
for
(
Int_t
iSize = 0; iSize < size; iSize++) {
139
// Get energy we are considering ...
140
if
(ene[iSize] != energies[iEne])
141
continue
;
142
if
(data.Contains(
"align"
)) {
143
if
(apprCurrent[iSize] > 5.)
144
continue
;
145
}
else
{
146
if
(apprCurrent[iSize] < 5.)
147
continue
;
148
}
149
150
// Get target ...
151
for
(
Int_t
iTarg = 0; iTarg < nTargets; iTarg++)
152
if
(targ[iSize] == targets[iTarg])
153
buffs[iTarg] +=
TString::Format
(
"%d "
, run[iSize]);
154
}
155
156
for
(
Int_t
iTarg = 0; iTarg < nTargets; iTarg++) {
157
fprintf(outFile,
"%s"
, buffs[iTarg].Data());
158
fprintf(outFile,
"\n\n"
);
159
}
160
fprintf(outFile,
"\n"
);
161
}
162
fclose(outFile);
163
164
delete
[] targets;
165
delete
[] energies;
166
}
Int_t
int Int_t
Double_t
double Double_t
Rtypes.h
R__ADD_INCLUDE_PATH
#define R__ADD_INCLUDE_PATH(PATH)
TString.h
TString
TString::Format
static TString Format(const char *fmt,...)
UniRun
UniRun.h Class for the table: run_.
Definition
UniRun.h:21
UniRun::GetEnergy
double * GetEnergy()
get energy of the current run
Definition
UniRun.h:113
UniRun::GetRun
static UniRun * GetRun(int period_number, int run_number)
get run from the database
Definition
UniRun.cxx:161
UniRun::GetFieldVoltage
double * GetFieldVoltage()
get field voltage of the current run
Definition
UniRun.h:121
UniRun::GetTargetParticle
TString GetTargetParticle()
get target particle of the current run
Definition
UniRun.h:111
BmnDataSelector
void BmnDataSelector(Int_t run_period=6, TString setup="BM@N", TString data="align")
Definition
BmnDataSelector.C:22
std
Definition
json.hpp:4446
install
macro
miscellaneous
BmnDataSelector.C
Generated on
for BmnRoot by
1.17.0