GamR  0.0.0
GammaROOT
Loading...
Searching...
No Matches
CoincidenceCubeDiff.hh
Go to the documentation of this file.
1#ifndef GAMRSORT_COINCIDENCECUBEDIFF_HH
2#define GAMRSORT_COINCIDENCECUBEDIFF_HH
3
4#include "Sorter.hh"
5
6namespace GamR {
7namespace Sort {
8namespace Type {
9
10template <class DetX, class DetY, size_t X, size_t Y, size_t Z>
12private:
13 Sorter *p;
14 std::shared_ptr<TH3D> ptrCube;
15 std::string Prefix;
16 std::string GroupX;
17 std::string GroupY;
18 std::string GroupZ;
19
20public:
21 CoincidenceCubeDiff(Sorter *parent, std::vector<std::string> opts) : p(parent)
22 {
23 if (opts.size() < 3)
24 throw std::length_error("Invalid arguments, expect: Prefix GroupX GroupY");
25 Prefix = opts[0];
26 GroupX = opts[1];
27 GroupY = opts[2];
28 std::string name(Prefix + "_g" + GroupX + "m" + X + "g" + GroupY + "m" + Y + "d" + Z);
29 ptrCube = p->GetCube(name);
30 ptrCube->SetBins(512, 0, 2048, 512, 0, 2048, 256, -128 * 24.41,
31 128 * 24.41); // Make knob?
32 // ptrCube -> SetCanExtend(TH1::kAllAxes);
33 }
34
35 void operator()(TTreeReader &R)
36 {
37 TTreeReaderValue<std::vector<DetX>> rDetsX(R, ("DetGroup._" + GroupX).c_str());
38 TTreeReaderValue<std::vector<DetY>> rDetsY(R, ("DetGroup._" + GroupY).c_str());
39 while (R.Next() && !p->Done()) {
40 p->Tick();
41 std::vector<DetX> vecDetsX = *rDetsX;
42 std::vector<DetY> vecDetsY = *rDetsY;
43 if (vecDetsX.size() + vecDetsY.size() < 2) {
44 continue;
45 }
46 for (auto &Det1 : vecDetsX) {
47 for (auto &Det2 : vecDetsY) {
48 if (Det1.ID == Det2.ID) {
49 continue;
50 }
51 auto x = Det1.template GetCal<X>();
52 auto y = Det2.template GetCal<Y>();
53 auto z1 = Det1.template GetCal<Z>();
54 auto z2 = Det2.template GetCal<Z>();
55
56 auto rx = Det1.template Get<X>();
57 auto ry = Det2.template Get<Y>();
58 auto rz1 = Det1.template Get<Z>();
59 auto rz2 = Det2.template Get<Z>();
60
61 if (!(rx && ry && rz1 && rz2)) {
62 continue;
63 }
64 ptrCube->Fill(x, y, z2 - z1);
65 } // fold 2
66 } // fold 1
67 } // all events
68 } // Sorter::CoincidenceMatrix::operator()
69};
70
71} // namespace Type
72} // namespace Sort
73} // namespace GamR
74
75#endif
CoincidenceCubeDiff(Sorter *parent, std::vector< std::string > opts)
Definition Gain.cc:19