110 auto colNames =
fHeadNode.GetColumnNames();
111 if(std::find(colNames.begin(), colNames.end(),
"All_Bundle") != colNames.end())
116 if(std::find(colNames.begin(), colNames.end(),
"All_Cyl") == colNames.end())
118 df = df.Define(
"All_Cyl",
119 [](
const RVecI &bunds)
128 if(std::find(colNames.begin(), colNames.end(),
"All_Lay") == colNames.end())
130 df = df.Define(
"All_Lay",
131 [](
const RVecI &bunds)
140 if(std::find(colNames.begin(), colNames.end(),
"nHits_Total") == colNames.end())
142 df = df.Define(
"nHits_Total",
"(double)All_Cyl.size()")
143 .Define(
"nHits_Cyl0",
"Sum(All_Cyl == 0)")
144 .Define(
"nHits_Cyl1",
"Sum(All_Cyl == 1)")
145 .Define(
"nHits_Cyl0_Inner",
"Sum(All_Cyl == 0 && All_Lay == 0)")
146 .Define(
"nHits_Cyl0_Outer",
"Sum(All_Cyl == 0 && All_Lay == 1)")
147 .Define(
"nHits_Cyl1_Inner",
"Sum(All_Cyl == 1 && All_Lay == 0)")
148 .Define(
"nHits_Cyl1_Outer",
"Sum(All_Cyl == 1 && All_Lay == 1)");
151 if(std::find(colNames.begin(), colNames.end(),
"All_ToA") == colNames.end())
154 "All_ToA", [](
const RVecI &b) {
return RVecD(b.size(), 0.0); }, {
"All_Bundle" });
156 if(std::find(colNames.begin(), colNames.end(),
"All_ToT") == colNames.end())
159 "All_ToT", [](
const RVecI &b) {
return RVecUS(b.size(), 0); }, {
"All_Bundle" });
161 if(std::find(colNames.begin(), colNames.end(),
"All_Board") == colNames.end())
164 "All_Board", [](
const RVecI &b) {
return RVecI(b.size(), 0); }, {
"All_Bundle" });
175 "FD00_corrToA", [](
const RVecUI &toa) {
return RVecD(toa) / 2.0; }, {
"FD00_ToA" });
178 for(
const string &
id : {
"01",
"02",
"03" })
180 df_corr = df_corr.Define(
"FD" +
id +
"_corrToA",
181 [](
const RVecUI &toa, Double_t t, Double_t t0)
185 return RVecD(toa) / 2.0 + (t - t0) * 1e3;
187 {
"FD" +
id +
"_ToA",
"FD" +
id +
"_fine_tstamp",
"FD00_fine_tstamp" });
191 auto df_geo = df_corr;
192 vector<string> toa_cols, tot_cols, cyl_cols, lay_cols, bund_cols, board_cols;
195 map<string, int> board_id_map = { {
"00", 0 }, {
"01", 1 }, {
"02", 2 }, {
"03", 3 } };
197 for(
const auto &[id_str, id_num] : board_id_map)
202 string toa_n =
"FD" +
id +
"_ToA_sel";
203 string tot_n =
"FD" +
id +
"_ToT_sel";
204 string cyl_n =
"FD" +
id +
"_cyl_sel";
205 string lay_n =
"FD" +
id +
"_lay_sel";
206 string bund_n =
"FD" +
id +
"_bund_sel";
207 string board_n =
"FD" +
id +
"_board_sel";
209 toa_cols.push_back(toa_n);
210 tot_cols.push_back(tot_n);
211 cyl_cols.push_back(cyl_n);
212 lay_cols.push_back(lay_n);
213 bund_cols.push_back(bund_n);
214 board_cols.push_back(board_n);
217 bool isBoardEnabled =
true;
218 if(!enabledBoards.empty())
220 if(std::find(enabledBoards.begin(), enabledBoards.end(), b_id) == enabledBoards.end())
222 isBoardEnabled =
false;
230 df_geo = df_geo.Define(toa_n, []() {
return RVecD {}; })
231 .Define(tot_n, []() {
return RVecUS {}; })
232 .Define(cyl_n, []() {
return RVecI {}; })
233 .Define(lay_n, []() {
return RVecI {}; })
234 .Define(bund_n, []() {
return RVecI {}; })
235 .Define(board_n, []() {
return RVecI {}; });
241 string toa_tmp = toa_n +
"_tmp";
242 string tot_tmp = tot_n +
"_tmp";
243 string cyl_tmp = cyl_n +
"_tmp";
244 string lay_tmp = lay_n +
"_tmp";
245 string bund_tmp = bund_n +
"_tmp";
246 string board_tmp = board_n +
"_tmp";
249 df_geo = df_geo.Define(toa_tmp,
250 [=](
const RVecD &toa,
const RVecUS &tot)
251 {
return toa[(toa > tMin) && (toa < tMax) && (tot > totMin) && (tot < totMax)]; },
252 {
"FD" +
id +
"_corrToA",
"FD" +
id +
"_ToT" });
254 df_geo = df_geo.Define(tot_tmp,
255 [=](
const RVecD &toa,
const RVecUS &tot)
256 {
return tot[(toa > tMin) && (toa < tMax) && (tot > totMin) && (tot < totMax)]; },
257 {
"FD" +
id +
"_corrToA",
"FD" +
id +
"_ToT" });
260 df_geo = df_geo.Define(bund_tmp,
261 [=](
const RVecD &toa,
const RVecUS &tot,
const RVecUC &chans)
264 auto mask = (toa > tMin) && (toa < tMax) && (tot > totMin) && (tot < totMax);
265 auto sel_chans = chans[mask];
266 for(
auto c : sel_chans)
269 bunds.push_back(gid);
273 {
"FD" +
id +
"_corrToA",
"FD" +
id +
"_ToT",
"FD" +
id +
"_channel" });
276 df_geo = df_geo.Define(cyl_tmp,
277 [](
const RVecI &bunds)
286 df_geo = df_geo.Define(lay_tmp,
287 [](
const RVecI &bunds)
296 df_geo = df_geo.Define(board_tmp,
297 [b_id](
const RVecI &bunds) {
return RVecI(bunds.size(), b_id); }, { bund_tmp });
300 string mask_n =
"FD" +
id +
"_geo_mask";
301 df_geo = df_geo.Define(mask_n,
302 [enabledCylinders, enabledLayers, enabledGeometries](
303 const RVecI &cyls,
const RVecI &lays)
306 RVec<int> mask(cyls.size(), 1);
309 if(enabledCylinders.empty() && enabledLayers.empty() && enabledGeometries.empty())
314 for(
size_t i = 0; i < cyls.size(); ++i)
317 if(!enabledCylinders.empty())
320 for(
auto c : enabledCylinders)
334 if(!enabledLayers.empty())
337 for(
auto l : enabledLayers)
348 if(!enabledGeometries.empty())
351 for(
const auto &geo : enabledGeometries)
353 if(geo.first == cyls[i] && geo.second == lays[i])
365 { cyl_tmp, lay_tmp });
370 .Define(toa_n, [](
const RVecD &v,
const RVecI &m) {
return v[m]; },
372 .Define(tot_n, [](
const RVecUS &v,
const RVecI &m) {
return v[m]; },
374 .Define(cyl_n, [](
const RVecI &v,
const RVecI &m) {
return v[m]; },
376 .Define(lay_n, [](
const RVecI &v,
const RVecI &m) {
return v[m]; },
378 .Define(bund_n, [](
const RVecI &v,
const RVecI &m) {
return v[m]; },
379 { bund_tmp, mask_n })
380 .Define(board_n, [](
const RVecI &v,
const RVecI &m) {
return v[m]; },
381 { board_tmp, mask_n });
389 [](
const RVecI &c0,
const RVecI &c1,
const RVecI &c2,
const RVecI &c3)
390 {
return Concatenate(c0, Concatenate(c1, Concatenate(c2, c3))); },
394 [](
const RVecI &l0,
const RVecI &l1,
const RVecI &l2,
const RVecI &l3)
395 {
return Concatenate(l0, Concatenate(l1, Concatenate(l2, l3))); },
399 [](
const RVecI &b0,
const RVecI &b1,
const RVecI &b2,
const RVecI &b3)
400 {
return Concatenate(b0, Concatenate(b1, Concatenate(b2, b3))); },
404 [](
const RVecD &t0,
const RVecD &t1,
const RVecD &t2,
const RVecD &t3)
405 {
return Concatenate(t0, Concatenate(t1, Concatenate(t2, t3))); },
410 {
return Concatenate(t0, Concatenate(t1, Concatenate(t2, t3))); },
414 [](
const RVecI &b0,
const RVecI &b1,
const RVecI &b2,
const RVecI &b3)
415 {
return Concatenate(b0, Concatenate(b1, Concatenate(b2, b3))); },
419 .Define(
"nHits_Total",
"(double)All_Cyl.size()")
420 .Define(
"nHits_Cyl0",
"Sum(All_Cyl == 0)")
421 .Define(
"nHits_Cyl1",
"Sum(All_Cyl == 1)")
422 .Define(
"nHits_Cyl0_Inner",
"Sum(All_Cyl == 0 && All_Lay == 0)")
423 .Define(
"nHits_Cyl0_Outer",
"Sum(All_Cyl == 0 && All_Lay == 1)")
424 .Define(
"nHits_Cyl1_Inner",
"Sum(All_Cyl == 1 && All_Lay == 0)")
425 .Define(
"nHits_Cyl1_Outer",
"Sum(All_Cyl == 1 && All_Lay == 1)")
428 [](
const RVecD &t0,
const RVecD &t1,
const RVecD &t2,
const RVecD &t3)
430 auto all = Concatenate(t0, Concatenate(t1, Concatenate(t2, t3)));
431 return all.empty() ? std::numeric_limits<Double_t>::infinity() : Min(all);
438 auto all = Concatenate(t0, Concatenate(t1, Concatenate(t2, t3)));
439 return all.empty() ? 0.0 : Sum(all);