-
Notifications
You must be signed in to change notification settings - Fork 0
/
_CompareCountsPass1Pass3.C
executable file
·116 lines (100 loc) · 4.23 KB
/
_CompareCountsPass1Pass3.C
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
// _CompareCountsPass1Pass3.C
// David Grund, Mar 06, 2022
#include <fstream> // print output to txt file
#include <iomanip> // std::setprecision()
#include "TSystem.h"
void CompareCounts(Bool_t isPass1Calibrated, Bool_t isPass3Calibrated);
void _CompareCountsPass1Pass3()
{
CompareCounts(kFALSE,kTRUE);
CompareCounts(kFALSE,kFALSE);
return;
}
void CompareCounts(Bool_t isPass1Calibrated = kFALSE, Bool_t isPass3Calibrated = kFALSE)
{
gSystem->Exec("mkdir -p Results/_CompareCountsPass1Pass3/");
Double_t counterMC_pass1[19] = { 0 };
Double_t counterMC_pass3[19] = { 0 };
TString cutsNames[14] = {"CCUP31","runNum","ADAofl","ADCofl","V0Aofl","V0Cofl",
"SPDmat","PIDmuo","rap<.8","eta<.8","oppCha","ms2245",
"pT3032","ms3032"};
ifstream ifs;
// MC
// pass1
TString str_MC_pass1 = "";
if(!isPass1Calibrated) str_MC_pass1 = "Results/pass1_4bins/CountEvents_MC/cuts_numbersOnly.txt";
else str_MC_pass1 = "Results/pass1_4bins_calibPID/CountEvents_MC/cuts_numbersOnly.txt";
ifs.open(str_MC_pass1.Data());
for(Int_t i = 0; i < 19; i++){
ifs >> counterMC_pass1[i];
Printf("%i: %.0f", i, counterMC_pass1[i]);
}
ifs.close();
// pass3
TString str_MC_pass3 = "";
if(!isPass3Calibrated) str_MC_pass3 = "Results/pass3_4bins/CountEvents_MC/cuts_numbersOnly.txt";
else str_MC_pass3 = "Results/pass3_4bins_calibPID/CountEvents_MC/cuts_numbersOnly.txt";
ifs.open(str_MC_pass3.Data());
for(Int_t i = 0; i < 19; i++){
ifs >> counterMC_pass3[i];
Printf("%i: %.0f", i, counterMC_pass3[i]);
}
ifs.close();
// print the ratios to a new file
TString str_p1 = "No";
TString str_p3 = "No";
if(isPass1Calibrated) str_p1 = "Yes";
if(isPass3Calibrated) str_p3 = "Yes";
TString str_out_MC = Form("Results/_CompareCountsPass1Pass3/MC_calib_p1%s_p3%s.txt", str_p1.Data(), str_p3.Data());
ofstream outfile;
outfile.open(str_out_MC.Data());
outfile << "cutName nEv_p1\tnEv_p3\tratio\n";
for(Int_t i = 3; i < 17; i++){
Double_t ratio = counterMC_pass1[i] / counterMC_pass3[i];
outfile << std::fixed << std::setprecision(0)
<< Form("%s", cutsNames[i-3].Data()) << "\t"
<< counterMC_pass1[i] << "\t" << counterMC_pass3[i] << "\t"
<< std::fixed << std::setprecision(3)
<< ratio << "\n";
}
outfile.close();
Printf("*** Results printed to %s.***", str_out_MC.Data());
Double_t counterData_pass1[18] = { 0 };
Double_t counterData_pass3[18] = { 0 };
// data
// pass1
TString str_data_pass1 = "";
if(!isPass1Calibrated) str_data_pass1 = "Results/pass1_4bins/CountEvents/cuts_numbersOnly.txt";
else str_data_pass1 = "Results/pass1_4bins_calibPID/CountEvents/cuts_numbersOnly.txt";
ifs.open(str_data_pass1.Data());
for(Int_t i = 0; i < 18; i++){
ifs >> counterData_pass1[i];
Printf("%i: %.0f", i, counterData_pass1[i]);
}
ifs.close();
// pass3
TString str_data_pass3 = "";
if(!isPass3Calibrated) str_data_pass3 = "Results/pass3_4bins/CountEvents/cuts_numbersOnly.txt";
else str_data_pass3 = "Results/pass3_4bins_calibPID/CountEvents/cuts_numbersOnly.txt";
ifs.open(str_data_pass3.Data());
for(Int_t i = 0; i < 18; i++){
ifs >> counterData_pass3[i];
Printf("%i: %.0f", i, counterData_pass3[i]);
}
ifs.close();
// print the ratios to a new file
TString str_out_data = Form("Results/_CompareCountsPass1Pass3/data_calib_p1%s_p3%s.txt", str_p1.Data(), str_p3.Data());
outfile.open(str_out_data.Data());
outfile << "cutName nEv_p1\tnEv_p3\tratio\n";
for(Int_t i = 3; i < 16; i++){
Double_t ratio = counterData_pass1[i] / counterData_pass3[i];
outfile << std::fixed << std::setprecision(0)
<< Form("%s", cutsNames[i-2].Data()) << "\t"
<< counterData_pass1[i] << "\t" << counterData_pass3[i] << "\t"
<< std::fixed << std::setprecision(3)
<< ratio << "\n";
}
outfile.close();
Printf("*** Results printed to %s.***", str_out_data.Data());
return;
}