4std::string summary_extract_value(
const std::string& line,
const std::string& keyword)
6 size_t start = line.find(keyword);
7 if(start != std::string::npos && start == 0)
9 start += keyword.length();
10 std::string value = line.substr(start);
13 size_t first_not_space = value.find_first_not_of(
" \t");
14 if(first_not_space != std::string::npos)
15 value = value.substr(first_not_space);
17 size_t last_not_space = value.find_last_not_of(
" \t");
18 if(last_not_space != std::string::npos)
19 value = value.substr(0, last_not_space + 1);
28void Bartender_Summary(
const std::string ¯ofile,
int MCID,
double duration) {
29 bool isConstantBins =
true, isShaping =
false;
31 std::ofstream outfile(
"Bartender_summaries.txt", std::ios::app);
33 outfile <<
"Bartender serial number (MCID): " << MCID <<
"\n\n";
36 tm* current_time = localtime(&now);
37 outfile <<
"Date: " << asctime(current_time);
38 outfile <<
"User Name: " << getlogin() <<
"\n";
39 outfile <<
"Duration of the simulation: " << duration <<
" s\n\n";
41 std::ifstream run_file(macrofile);
44 std::cerr <<
"Can't open run macro file!" << std::endl;
49 std::string brand, model;
51 while(std::getline(run_file, line))
53 line = line.substr(line.find_first_not_of(
" \t"));
55 if(line.find(
"Brand:") != std::string::npos)
56 brand = summary_extract_value(line,
"Brand:");
57 else if(line.find(
"TypeNo:") != std::string::npos)
59 model = summary_extract_value(line,
"TypeNo:");
60 if(!brand.empty() && !model.empty())
61 outfile <<
"SiPM: " << brand <<
" " << model <<
'\n';
63 else if(line.find(
"V =") != std::string::npos)
65 std::string V_value = summary_extract_value(line,
"V =");
67 outfile <<
"Voltage: " << V_value <<
'\n';
69 else if(line.find(
"T =") != std::string::npos)
71 std::string T_value = summary_extract_value(line,
"T =");
73 outfile <<
"Temperature: " << T_value <<
'\n';
75 else if(line.find(
"Sampling speed =") != std::string::npos)
77 std::string sampling_value = summary_extract_value(line,
"Sampling speed =");
78 if(!sampling_value.empty())
79 outfile <<
"Sampling speed (template): " << sampling_value <<
'\n';
81 else if(line.find(
"R_shaper =") != std::string::npos)
83 std::string R_value = summary_extract_value(line,
"R_shaper =");
85 outfile <<
"R_shaper (template): " << R_value <<
'\n';
87 else if(line.find(
"Gain =") != std::string::npos)
89 std::string gain_value = summary_extract_value(line,
"Gain =");
90 if(!gain_value.empty())
91 outfile <<
"Gain (template): " << gain_value <<
'\n';
93 else if(line ==
"Constant Bins = true")
95 outfile <<
"Constant Bins = true" <<
'\n';
97 else if(line ==
"Constant Bins = false")
99 outfile <<
"Constant Bins = false" <<
'\n';
100 isConstantBins =
false;
102 else if(!isConstantBins && line.find(
"BinSize sigma =") != std::string::npos)
104 std::string sigmaBin_value = summary_extract_value(line,
"BinSize sigma =");
105 if(!sigmaBin_value.empty())
106 outfile <<
"Bin (sigma) = " << sigmaBin_value <<
'\n';
108 else if(line.find(
"Sampling speed_sim =") != std::string::npos)
110 std::string sampling_value = summary_extract_value(line,
"Sampling speed_sim =");
111 if(!sampling_value.empty())
112 outfile <<
"Sampling speed: " << sampling_value <<
'\n';
114 else if(line ==
"Use shaping = true")
116 outfile <<
"Shaping = ON" <<
'\n';
119 else if(line ==
"Use shaping = false")
121 outfile <<
"Shaping = OFF" <<
'\n';
123 else if(isShaping && line.find(
"Tau_shaping =") != std::string::npos)
125 std::string Tau_value = summary_extract_value(line,
"Tau_shaping =");
126 if(!Tau_value.empty())
127 outfile <<
"Tau_shaping = " << Tau_value <<
'\n';
129 else if(line.find(
"Gain_sim =") != std::string::npos)
131 std::string gain_value = summary_extract_value(line,
"Gain_sim =");
132 if(!gain_value.empty())
133 outfile <<
"Gain: " << gain_value <<
'\n';
135 else if(line.find(
"Noise (sigma) =") != std::string::npos)
137 std::string noise_value = summary_extract_value(line,
"Noise (sigma) =");
138 if(!noise_value.empty())
139 outfile <<
"Noise (sigma): " << noise_value <<
'\n';
145 outfile <<
"\n########################################################\n\n";