-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground_calc.cpp
312 lines (299 loc) · 13.4 KB
/
background_calc.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
#include <stdio.h>
#include <TCut.h>
#include <TFile.h>
#include <TH1.h>
#include <TTree.h>
#include "HPainter2.h"
/****************************************
* Calculate various cuts *
****************************************/
#define NHISTS 31
#define THISTS 5
void background_calc(const char *name, int run_first, int run_last, TCut cAux = (TCut) "")
{
char strs[128];
char strl[1024];
const char *titles[] = {
"gtDiff", "R1", "R2", "RZ", "PX", "PY", "PZ", "NX", "NY", "NZ",
"NE", "NE10", "NE20", "NE30", "NE40", "NH", "PH", "AH", "AE", "AM",
"AMO", "P2AZ", "AH1", "AE1", "P2AZ1", "PX1", "PY1", "PZ1", "PXN", "PYN",
"PZN"};
const char *titlel[] = {
"Time from positron to neutron;us;mHz/us",
"Distance between positron and neutron, 2D;cm;mHz/4cm",
"Distance between positron and neutron, 3D;cm;mHz/4cm",
"Distance between positron and neutron, Z;cm;mHz/cm",
"Positron vertex X;cm;mHz/4cm", "Positron vertex Y;cm;mHz/4cm", "Positron vertex Z;cm;mHz/cm",
"Neutron vertex X;cm;mHz/4cm", "Neutron vertex Y;cm;mHz/4cm", "Neutron vertex Z;cm;mHz/cm",
"Neutron capture energy;MeV;mHz/100keV",
"Neutron capture energy, > 4 cm from the edge;MeV;mHz/100keV",
"Neutron capture energy, > 12 cm from the edge;MeV;mHz/100keV",
"Neutron capture energy, > 24 cm from the edge;MeV;mHz/100keV",
"Neutron capture energy, > 36 cm from the edge;MeV;mHz/100keV",
"Neutron capture hits;hits;mHz/hit",
"Number of SiPM hits in positron cluster;Hits;mHz/hit",
"Number of hits out of the cluster;Hits;mHz/hit",
"Energy out of the cluster;MeV;mHz/100keV",
"The most energetic hit out of the cluster;MeV;mHz/100keV",
"The most energetic hit out of the cluster - other cuts applied;MeV;mHz/100keV",
"Distance from the cluster to the closest hit outside the cluster, Z;cm;mHz/cm",
"Number of hits out of the single hit cluster;Hits;mHz/hit",
"Energy out of the single hit cluster;MeV;mHz/100keV",
"Distance from the cluster to the closest hit outside the single hit cluster, Z;cm;mHz/cm",
"Positron vertex X, single hit cluster;cm;mHz/4cm",
"Positron vertex Y, single hit cluster;cm;mHz/4cm",
"Positron vertex Z, single hit cluster;cm;mHz/cm",
"Positron vertex X, multi hit cluster;cm;mHz/4cm",
"Positron vertex Y, multi hit cluster;cm;mHz/4cm",
"Positron vertex Z, multi hit cluster;cm;mHz/cm"
};
const char *ttitles[] = {"TSHOWER", "TMUON", "TBEFORE", "TAFTER", "TAFTERP"};
const char *ttitlel[] = {
"Time from showering event;us;mHz/2us",
"Time from muon event;us;mHz/2us",
"Time from non-muon event;us;mHz/2us",
"Time after neutron;us;mHz/2us",
"Time after positron;us;mHz/2us",
};
TH1D *h[NHISTS][3];
TH1D *hT[THISTS];
TH1D *hConst;
int i, j;
const char *ptr;
const char *what;
// Main cuts
TCut cVeto("gtFromVeto > 90");
TCut cMuonA("gtFromVeto == 0");
TCut cMuonB("gtFromVeto > 0 && gtFromVeto <= 90");
TCut cIso("((gtFromPrevious > 50 || gtFromPrevious == gtFromVeto) && gtToNext > 80 && EventsBetween == 0)");
TCut cShower("gtFromShower > 120 || ShowerEnergy < 800");
TCut c20("gtDiff > 1");
TCut cX("PositronX[0] < 0 || (PositronX[0] > 2 && PositronX[0] < 94)");
TCut cY("PositronX[1] < 0 || (PositronX[1] > 2 && PositronX[1] < 94)");
TCut cZ("PositronX[2] > 3.5 && PositronX[2] < 95.5");
TCut cRXY("PositronX[0] >= 0 && PositronX[1] >= 0 && NeutronX[0] >= 0 && NeutronX[1] >= 0");
TCut cGamma("AnnihilationEnergy < 1.2 && AnnihilationGammas < 12");
TCut cPe("PositronEnergy > 0.5");
TCut cPh("PositronHits < 8");
TCut cR2("Distance < 40 - 17 * exp(-0.13 * PositronEnergy*PositronEnergy)");
TCut cR3("Distance < 48 - 17 * exp(-0.13 * PositronEnergy*PositronEnergy)");
TCut cR = cR3 && (cRXY || cR2);
TCut cNH("NeutronEnergy < 9.5 && NeutronHits >= 3 && NeutronHits < 20");
TCut cNE("NeutronEnergy > 1.5 + 2.6 * exp(-0.15 * PositronEnergy*PositronEnergy)");
TCut cN = cNH && cNE;
TCut cSingle("!(PositronHits == 1 && (AnnihilationGammas < 1 || AnnihilationEnergy < 0.1))");
TCut cNX10("PositronX[0] > 2 && PositronX[0] < 94");
TCut cNY10("PositronX[1] > 2 && PositronX[1] < 94");
TCut cNZ10("PositronX[2] > 3.5 && PositronX[2] < 95.5");
TCut cN10 = cNX10 && cNY10 && cNZ10;
TCut cNX20("PositronX[0] > 10 && PositronX[0] < 86");
TCut cNY20("PositronX[1] > 10 && PositronX[1] < 86");
TCut cNZ20("PositronX[2] > 11.5 && PositronX[2] < 87.5");
TCut cN20 = cNX20 && cNY20 && cNZ20;
TCut cNX30("PositronX[0] > 22 && PositronX[0] < 74");
TCut cNY30("PositronX[1] > 22 && PositronX[1] < 74");
TCut cNZ30("PositronX[2] > 23.5 && PositronX[2] < 75.5");
TCut cN30 = cNX30 && cNY30 && cNZ30;
TCut cNX40("PositronX[0] > 34 && PositronX[0] < 62");
TCut cNY40("PositronX[1] > 34 && PositronX[1] < 62");
TCut cNZ40("PositronX[2] > 35.5 && PositronX[2] < 63.5");
TCut cN40 = cNX40 && cNY40 && cNZ40;
TCut ct;
TCut cv[3];
cv[0] = cVeto; // neutrino
cv[1] = cMuonA; // fast neutron
cv[2] = cMuonB; // pair of neutrons
ptr = getenv("OUT_DIR");
if (!ptr) ptr = "/home/clusters/rrcmpi/alekseev/igor/bgnd";
sprintf(strl, "%s/%s.root", ptr, name);
TFile *fRoot = new TFile(strl, "RECREATE");
// printf("%s ==>> %s\n", strl, fRoot->GetName());
for (i=0; i<NHISTS; i++) for (j=0; j<3; j++) {
sprintf(strs, "h%s%c", titles[i], 'A' + j);
switch(i) {
case 0: // gtDiff
h[i][j] = new TH1D(strs, titlel[i], 50, 0, 50.0);
break;
case 1: // R1, R2
case 2:
h[i][j] = new TH1D(strs, titlel[i], 40, 0, 160.0);
break;
case 3: // RZ
h[i][j] = new TH1D(strs, titlel[i], 100, -50.0, 50.0);
break;
case 4: // PX, PY, NX, NY, PX1, PY1, PXN, PYN
case 5:
case 7:
case 8:
case 25:
case 26:
case 28:
case 29:
h[i][j] = new TH1D(strs, titlel[i], 25, 0, 100.0);
break;
case 6: // PZ, NZ, PZ1, PZN
case 9:
case 27:
case 30:
h[i][j] = new TH1D(strs, titlel[i], 100, 0, 100.0);
break;
case 10: // NE
case 11: // NE10
case 12: // NE20
case 13: // NE30
case 14: // NE40
h[i][j] = new TH1D(strs, titlel[i], 105, 1.5, 12.0);
break;
case 15: // NH
h[i][j] = new TH1D(strs, titlel[i], 20, 0, 20.0);
break;
case 16: // PH
h[i][j] = new TH1D(strs, titlel[i], 10, 0, 10.0);
break;
case 17: // AH, AH1
case 22:
h[i][j] = new TH1D(strs, titlel[i], 20, 0, 20.0);
break;
case 18: // AE, AM, AMO, AE1
case 19:
case 20:
case 23:
h[i][j] = new TH1D(strs, titlel[i], 40, 0, 4.0);
break;
case 21: // P2AZ, P2AZ1
case 24:
h[i][j] = new TH1D(strs, titlel[i], 30, 0, 30.0);
break;
}
}
for (i=0; i<THISTS; i++) hT[i] = new TH1D(ttitles[i], ttitlel[i], 250, 0, 500);
hConst = new TH1D("hConst", "Run constants", 10, 0, 10);
hConst->GetXaxis()->SetBinLabel(1, "gTime");
ptr = getenv("PAIR_DIR");
if (!ptr) ptr = "/home/clusters/rrcmpi/alekseev/igor/pair7n";
HPainter2 *hp = new HPainter2(0x801E, run_first, run_last, ptr);
if (hp->GetUpTime() < 10) {
printf("%s:%d - %d: no runs !\n", ptr, run_first, run_last);
fRoot->Close();
return;
}
hp->SetFile(fRoot);
hConst->SetBinContent(1, hp->GetUpTime());
for (j=0; j<3; j++) {
ct = cIso && cShower && cX && cY && cZ && cR && cPe && cPh && cGamma && cN && cSingle;
hp->Project(h[0][j], "gtDiff", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cPe && cPh && cGamma && cN && !cRXY && cSingle;
hp->Project(h[1][j], "Distance", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cPe && cPh && cGamma && cN && cRXY && cSingle;
hp->Project(h[2][j], "Distance", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cPe && cPh && cGamma && cN && cSingle;
hp->Project(h[3][j], "DistanceZ", ct && cv[j] && cAux);
ct = cIso && cShower && cY && cZ && cR && cPe && cPh && cGamma && cN && "PositronX[0] >= 0" && cSingle;
hp->Project(h[4][j], "PositronX[0] + 2.0", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cZ && cR && cPe && cPh && cGamma && cN && "PositronX[1] >= 0" && cSingle;
hp->Project(h[5][j], "PositronX[1] + 2.0", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cR && cPe && cPh && cGamma && cN && "PositronX[2] >= 0" && cSingle;
hp->Project(h[6][j], "PositronX[2] + 0.5", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPe && cPh && cGamma && cN && "NeutronX[0] >= 0" && cSingle;
hp->Project(h[7][j], "NeutronX[0] + 2.0", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPe && cPh && cGamma && cN && "NeutronX[1] >= 0" && cSingle;
hp->Project(h[8][j], "NeutronX[1] + 2.0", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPe && cPh && cGamma && cN && "NeutronX[2] >= 0" && cSingle;
hp->Project(h[9][j], "NeutronX[2] + 0.5", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPh && cPe && cGamma && cSingle;
hp->Project(h[10][j], "NeutronEnergy", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPh && cPe && cGamma && cSingle && cN10;
hp->Project(h[11][j], "NeutronEnergy", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPh && cPe && cGamma && cSingle && cN20;
hp->Project(h[12][j], "NeutronEnergy", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPh && cPe && cGamma && cSingle && cN30;
hp->Project(h[13][j], "NeutronEnergy", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPh && cPe && cGamma && cSingle && cN40;
hp->Project(h[14][j], "NeutronEnergy", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPh && cPe && cGamma && cSingle;
hp->Project(h[15][j], "NeutronHits", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPe && cGamma && cN && cSingle;
hp->Project(h[16][j], "PositronHits", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPe && cPh && cN && cSingle && "AnnihilationEnergy < 1.8";
hp->Project(h[17][j], "AnnihilationGammas", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPe && cPh && cN && cSingle && "AnnihilationGammas <= 10";
hp->Project(h[18][j], "AnnihilationEnergy", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPe && cPh && cN && cSingle;
hp->Project(h[19][j], "AnnihilationMax", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPe && cPh && cN && cGamma && cSingle;
hp->Project(h[20][j], "AnnihilationMax", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPe && cPh && cN && cGamma;
hp->Project(h[21][j], "MinPositron2GammaZ", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPe && cN && "PositronHits == 1";
hp->Project(h[22][j], "AnnihilationGammas", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPe && cN && "PositronHits == 1";
hp->Project(h[23][j], "AnnihilationEnergy", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cZ && cR && cPe && cN && cGamma && "PositronHits == 1";
hp->Project(h[24][j], "MinPositron2GammaZ", ct && cv[j] && cAux);
ct = cIso && cShower && cY && cZ && cR && cPe && cGamma && cN && "PositronX[0] >= 0 && PositronHits == 1";
hp->Project(h[25][j], "PositronX[0] + 2.0", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cZ && cR && cPe && cGamma && cN && "PositronX[1] >= 0 && PositronHits == 1";
hp->Project(h[26][j], "PositronX[1] + 2.0", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cR && cPe && cGamma && cN && "PositronX[2] >= 0 && PositronHits == 1";
hp->Project(h[27][j], "PositronX[2] + 0.5", ct && cv[j] && cAux);
ct = cIso && cShower && cY && cZ && cR && cPe && cGamma && cN && "PositronX[0] >= 0 && PositronHits > 1";
hp->Project(h[28][j], "PositronX[0] + 2.0", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cZ && cR && cPe && cGamma && cN && "PositronX[1] >= 0 && PositronHits > 1";
hp->Project(h[29][j], "PositronX[1] + 2.0", ct && cv[j] && cAux);
ct = cIso && cShower && cX && cY && cR && cPe && cGamma && cN && "PositronX[2] >= 0 && PositronHits > 1";
hp->Project(h[30][j], "PositronX[2] + 0.5", ct && cv[j] && cAux);
}
for (i=0; i<THISTS; i++) {
ct = cX && cY && cZ && cR && cPe && cGamma && cN && cSingle && "EventsBetween == 0";
switch(i) {
case 0:
what = "gtFromShower";
ct = ct && TCut("gtToNext > 80");
break;
case 1:
what = "gtFromVeto";
ct = ct && TCut("gtToNext > 80 && gtFromShower > 200");
break;
case 2:
what = "gtFromPrevious";
ct = ct && TCut("gtToNext > 80 && gtFromShower > 200 && gtFromVeto > gtFromPrevious");
break;
case 3:
what = "gtToNext - gtDiff";
ct = ct && TCut("gtFromShower > 200 && gtFromVeto > 60 && gtFromPrevious > 45");
break;
case 4:
what = "gtToNext";
ct = ct && TCut("gtFromShower > 200 && gtFromVeto > 60 && gtFromPrevious > 45");
break;
}
hp->Project(hT[i], what, ct);
}
fRoot->cd();
for (i=0; i<NHISTS; i++) for (j=0; j<3; j++) h[i][j]->Write();
for (i=0; i<THISTS; i++) hT[i]->Write();
hConst->Write();
delete hp;
fRoot->Close();
}
int main(int argc, char **argv)
{
#include "positions.h"
int i;
int N;
const char * auxstr;
if (argc < 2) {
printf("Usage: %s period_number (from 1)\n", argv[0]);
return 100;
}
i = strtol(argv[1], NULL, 10);
N = sizeof(positions) / sizeof(positions[0]);
if (i<1 || i > N) {
printf("Illegal period number %d (max = %d)\n", i, N);
return 110;
}
auxstr = getenv("AUX_CUT");
if (!auxstr) auxstr = "";
background_calc(positions[i-1].name, positions[i-1].first, positions[i-1].last, (TCut) auxstr);
return 0;
}