106 if (csvPath.empty()) {
107 B2ERROR(
"Cannot find tcid_correct_theta_phi.csv");
111 std::ifstream infile(csvPath);
112 if (!infile.is_open()) {
113 B2ERROR((
"Failed to open " + csvPath).c_str());
118 bool isFirstLine =
true;
119 while (std::getline(infile, line)) {
125 std::stringstream ss(line);
126 std::string tc_str, theta_str, phi_str;
127 std::getline(ss, tc_str,
',');
128 std::getline(ss, theta_str,
',');
129 std::getline(ss, phi_str,
',');
131 if (tc_str.empty() || theta_str.empty() || phi_str.empty())
continue;
133 int tc = std::stoi(tc_str);
134 if (tc == 0)
continue;
135 double theta = std::stod(theta_str) * TMath::RadToDeg();
136 double phi = std::stod(phi_str) * TMath::RadToDeg();
138 thetaMap[tc] = theta;
149 for (
int tc = 1; tc <= 576; ++tc) {
150 if (thetaMap.count(tc)) {
161 B2INFO(
"Loaded TC geometry (theta/phi) from tcid_correct_theta_phi.csv");
162 B2INFO(Form(
"Example: TC 1 => theta = %.3f deg, phi = %.3f deg",
TCThetaLab[0],
TCPhiLab[0]));
174 B2FATAL(
"No database for TRG GRL config. exp " << evtMetaData->getExperiment() <<
" run "
175 << evtMetaData->getRun());
217 <<
" total_bit_bias=" <<
m_db_trggrlconfig->get_ecltaunn_total_bit_bias().size());
222 for (
unsigned int isector = 0; isector <
m_parameters.nMLP; isector++) {
224 B2ERROR(
"weight of GRL ecltaunn could not be loaded correctly.");
231 for (
unsigned int isector = 0; isector <
m_parameters.nMLP; isector++) {
232 h_target.push_back(
new TH1D((
"h_target_" + to_string(isector)).c_str(),
233 (
"h_target_" + to_string(isector)).c_str(), 100, -40.0, 40.0));
251 std::vector<std::tuple<float, float, float, float, int>> eclClusters;
252 eclClusters.reserve(necl);
254 for (
int ic = 0; ic < necl; ic++) {
255 auto* eclCluster = eclTrgClusterArray[ic];
256 int TC = eclCluster->getMaxTCId();
259 float energy = eclTrgClusterArray[ic]->getEnergyDep() * 1000.0;
260 float time = eclCluster->getTimeAve();
262 float phi =
TCPhiLab[TC - 1 ] + 180;
263 float thetaComp = theta;
265 eclClusters.emplace_back(energy, thetaComp, phi, time, TC);
270 std::sort(eclClusters.begin(), eclClusters.end(),
271 [](
const std::tuple<float, float, float, float, int>& a,
272 const std::tuple<float, float, float, float, int>& b) {
273 return std::get<0>(a) > std::get<0>(b);
276 std::vector<float> MLPinput(24, 0.0f);
277 for (
size_t i = 0; i < eclClusters.size() && i < 6; i++) {
278 float energy, theta, phi, time;
280 std::tie(energy, theta, phi, time, TC) = eclClusters[i];
281 MLPinput[i] = energy;
282 MLPinput[i + 6] = theta;
283 MLPinput[i + 12] = phi;
284 MLPinput[i + 18] = time;
288 float LSB_ADC = 1 / 5.25;
289 float LSB_angle = 1 / 1.40625;
290 std::for_each(MLPinput.begin() + 0, MLPinput.begin() + 6, [LSB_ADC](
float & x) { x = std::ceil(x * LSB_ADC); });
291 std::for_each(MLPinput.begin() + 6, MLPinput.begin() + 12, [LSB_angle](
float & x) { x = std::ceil(x * LSB_angle); });
292 std::for_each(MLPinput.begin() + 12, MLPinput.begin() + 18, [LSB_angle](
float & x) { x = std::ceil(x * LSB_angle); });
294 for (
size_t i = 0; i < eclClusters.size() && i < 6; i++) {
295 float energy, theta, phi, time;
297 std::tie(energy, theta, phi, time, TC) = eclClusters[i];
302 for (
unsigned int isector = 0; isector <
m_parameters.nMLP; isector++) {
303 std::vector<float> target =
m_GRLNeuro.runMLP(isector, MLPinput);
304 unsigned num_target = target.size();
305 std::vector<float> nn_thres =
m_parameters.nn_thres[isector];
308 bool target_output =
false;
309 for (
unsigned io = 0; io < num_target; io++) {
310 if (target[io] > nn_thres[io]) {
311 target_output =
true;
315 trgInfo->setTauNN(isector, target_output);