112 if (csvPath.empty()) {
113 B2ERROR(
"Cannot find tcid_correct_theta_phi.csv");
117 std::ifstream infile(csvPath);
118 if (!infile.is_open()) {
119 B2ERROR((
"Failed to open " + csvPath).c_str());
124 bool isFirstLine =
true;
125 while (std::getline(infile, line)) {
131 std::stringstream ss(line);
132 std::string tc_str, theta_str, phi_str;
133 std::getline(ss, tc_str,
',');
134 std::getline(ss, theta_str,
',');
135 std::getline(ss, phi_str,
',');
137 if (tc_str.empty() || theta_str.empty() || phi_str.empty())
continue;
139 int tc = std::stoi(tc_str);
140 if (tc == 0)
continue;
141 double theta = std::stod(theta_str) * TMath::RadToDeg();
142 double phi = std::stod(phi_str) * TMath::RadToDeg();
144 thetaMap[tc] = theta;
155 for (
int tc = 1; tc <= 576; ++tc) {
156 if (thetaMap.count(tc)) {
167 B2INFO(
"Loaded TC geometry (theta/phi) from tcid_correct_theta_phi.csv");
168 B2INFO(Form(
"Example: TC 1 => theta = %.3f deg, phi = %.3f deg",
TCThetaLab[0],
TCPhiLab[0]));
180 B2FATAL(
"No database for TRG GRL config. exp " << evtMetaData->getExperiment() <<
" run "
181 << evtMetaData->getRun());
222 <<
" total_bit_bias=" <<
m_db_trggrlconfig->get_ecltaunn_total_bit_bias().size());
227 for (
unsigned int isector = 0; isector <
m_parameters.nMLP; isector++) {
229 B2ERROR(
"weight of GRL ecltaunn could not be loaded correctly.");
236 for (
unsigned int isector = 0; isector <
m_parameters.nMLP; isector++) {
237 h_target.push_back(
new TH1D((
"h_target_" + to_string(isector)).c_str(),
238 (
"h_target_" + to_string(isector)).c_str(), 100, -40.0, 40.0));
256 std::vector<std::tuple<float, float, float, float, int>> eclClusters;
257 eclClusters.reserve(necl);
259 for (
int ic = 0; ic < necl; ic++) {
260 auto* eclCluster = eclTrgClusterArray[ic];
261 int TC = eclCluster->getMaxTCId();
264 float energy = eclTrgClusterArray[ic]->getEnergyDep() * 1000.0;
265 float time = eclCluster->getTimeAve();
267 float phi =
TCPhiLab[TC - 1 ] + 180;
268 float thetaComp = theta;
270 eclClusters.emplace_back(energy, thetaComp, phi, time, TC);
275 std::sort(eclClusters.begin(), eclClusters.end(),
276 [](
const std::tuple<float, float, float, float, int>& a,
277 const std::tuple<float, float, float, float, int>& b) {
278 return std::get<0>(a) > std::get<0>(b);
281 std::vector<float> MLPinput(24, 0.0f);
282 for (
size_t i = 0; i < eclClusters.size() && i < 6; i++) {
283 float energy, theta, phi, time;
285 std::tie(energy, theta, phi, time, TC) = eclClusters[i];
286 MLPinput[i] = energy;
287 MLPinput[i + 6] = theta;
288 MLPinput[i + 12] = phi;
289 MLPinput[i + 18] = time;
293 float LSB_ADC = 1 / 5.25;
294 float LSB_angle = 1 / 1.40625;
295 std::for_each(MLPinput.begin() + 0, MLPinput.begin() + 6, [LSB_ADC](
float & x) { x = std::ceil(x * LSB_ADC); });
296 std::for_each(MLPinput.begin() + 6, MLPinput.begin() + 12, [LSB_angle](
float & x) { x = std::ceil(x * LSB_angle); });
297 std::for_each(MLPinput.begin() + 12, MLPinput.begin() + 18, [LSB_angle](
float & x) { x = std::ceil(x * LSB_angle); });
299 for (
size_t i = 0; i < eclClusters.size() && i < 6; i++) {
300 float energy, theta, phi, time;
302 std::tie(energy, theta, phi, time, TC) = eclClusters[i];
307 float target =
m_GRLNeuro.runMLP(0, MLPinput);
312 trgInfo->setTauNN(
true);
314 trgInfo->setTauNN(
false);
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.