38 throw std::length_error(
"Invalid arguments, expect: group ref_E ref_p "
39 "ref_P ref_b ref_B id1 id2 ... idn");
42 std::copy(opts.begin(), opts.end(), std::ostream_iterator<std::string>(
ss,
"\n"));
55 ptrRefPhoton = std::make_shared<GamR::Nucleus::Photon>(energy, pklow, pkhigh, bglow, bghigh);
56 ptrRefPhoton->SetName(
"TC_REF");
57 p->WriteObject(ptrRefPhoton.get());
65 ptrPkMatrixSum = p->GetMatrix(
"P_TCAL");
66 ptrBgMatrixSum = p->GetMatrix(
"B_TCAL");
68 ptrPkMatrixSum->SetBins(2048, 0, 2048, 2048, -1024, 1024);
69 ptrBgMatrixSum->SetBins(2048, 0, 2048, 2048, -1024, 1024);
71 std::stringstream ssTitle;
72 for (
const auto &i : detIds) {
73 for (
const auto &j : detIds) {
81 ptrPkMatrix[{i, j}] = p->GetMatrix((
"P" +
ss.str()));
82 ptrBgMatrix[{i, j}] = p->GetMatrix((
"B" +
ss.str()));
84 ssTitle <<
"$E_{" << i <<
"}=" << ptrRefPhoton->GetEnergy() <<
"$ Gate: $";
85 ssTitle << ptrRefPhoton->GetGate()->GetLow() <<
"\\to";
86 ssTitle << ptrRefPhoton->GetGate()->GetHigh();
87 ssTitle <<
"$;Gamma Energy, E_{" << j;
88 ssTitle <<
"} [keV];$\\Delta t = t_{" << j <<
"}-t_{" << i <<
"}$";
90 ptrPkMatrix[{i, j}]->SetTitle(ssTitle.str().c_str());
91 ptrPkMatrix[{i, j}]->SetBins(2048, 0, 2048, 2048, -1024, 1024);
96 ptrBgMatrix[{i, j}]->SetTitle(ssTitle.str().c_str());
97 ptrBgMatrix[{i, j}]->SetBins(2048, 0, 2048, 2048, -1024, 1024);
104 std::string group =
"DetGroup._" + gid;
105 TTreeReaderValue<std::vector<Det>> rdrDets(R, group.c_str());
106 while (R.Next() && !p->Done()) {
107 std::vector<Det> vecDets = *rdrDets;
109 if (vecDets.size() < 2) {
112 for (
auto &deti : vecDets) {
113 for (
auto &detj : vecDets) {
114 if (deti.ID == detj.ID) {
117 Bool_t pkgated = ptrRefPhoton->GetGate()->Pass(deti.template GetCal<E>());
118 Bool_t bggated = ptrRefPhoton->GetGateBG()->Pass(deti.template GetCal<E>());
120 if ((pkgated || bggated) && (deti.template Get<T>() > 0) && (detj.template Get<T>() > 0)) {
122 auto tdiff = detj.template Get<T>() - deti.template Get<T>();
124 ptrPkMatrix[{deti.ID, detj.ID}]->Fill(detj.template GetCal<E>(), tdiff);
125 ptrPkMatrixSum->Fill(detj.template GetCal<E>(), tdiff);
126 }
else if (bggated) {
127 ptrBgMatrix[{deti.ID, detj.ID}]->Fill(detj.template GetCal<E>(), tdiff);
128 ptrBgMatrixSum->Fill(detj.template GetCal<E>(), tdiff);