11 if (!event.
exists(tpCollName_))
return;
13 event.getObject<ldmx::HgcrocTrigDigiCollection>(tpCollName_)};
15 std::map<int, ldmx::HgcrocTrigDigiCollection> lDigis;
16 std::map<int, ldmx::HgcrocTrigDigiCollection> rDigis;
17 std::map<int, ldmx::HgcrocTrigDigiCollection> cDigis;
18 std::map<int, int> lSums;
19 std::map<int, int> rSums;
20 std::map<int, int> cSums;
21 for (
const auto& trigDigi : ecalTrigDigis) {
23 int module = tid.module();
24 int layer = tid.
layer();
26 auto ptr = lDigis.find(layer);
27 if (ptr == lDigis.end()) {
28 lDigis[layer] = {trigDigi};
29 lSums[layer] = trigDigi.linearPrimitive();
31 lDigis[layer].push_back(trigDigi);
32 lSums[layer] += trigDigi.linearPrimitive();
34 }
else if (module > 0) {
35 auto ptr = rDigis.find(layer);
36 if (ptr == rDigis.end()) {
37 rDigis[layer] = {trigDigi};
38 rSums[layer] = trigDigi.linearPrimitive();
40 rDigis[layer].push_back(trigDigi);
41 rSums[layer] += trigDigi.linearPrimitive();
44 auto ptr = cDigis.find(layer);
45 if (ptr == cDigis.end()) {
46 cDigis[layer] = {trigDigi};
47 cSums[layer] = trigDigi.linearPrimitive();
49 cDigis[layer].push_back(trigDigi);
50 cSums[layer] += trigDigi.linearPrimitive();
58 ldmx::HgcrocTrigDigiCollection passTPs;
59 passTPs.reserve(ecalTrigDigis.size());
60 for (
auto& pair : lDigis) {
61 auto& digis = pair.second;
62 if (digis.size() > maxOuterTPs_) {
63 std::sort(digis.begin(), digis.end(),
65 return a.getId() > b.getId();
67 digis.resize(maxCentralTPs_);
69 passTPs.insert(passTPs.end(), digis.begin(), digis.end());
71 for (
auto& pair : rDigis) {
72 auto& digis = pair.second;
73 if (digis.size() > maxOuterTPs_) {
74 std::sort(digis.begin(), digis.end(),
76 return a.getId() > b.getId();
78 digis.resize(maxCentralTPs_);
80 passTPs.insert(passTPs.end(), digis.begin(), digis.end());
83 for (
auto& pair : cDigis) {
84 auto& digis = pair.second;
85 if (digis.size() > maxCentralTPs_) {
86 std::sort(digis.begin(), digis.end(),
88 return a.getPrimitive() > b.getPrimitive();
90 digis.resize(maxCentralTPs_);
92 passTPs.insert(passTPs.end(), digis.begin(), digis.end());
96 TrigCaloHitCollection passTrigHits;
97 for (
const auto& tp : passTPs) {
99 decodeTP(tp, x, y, z, e);
100 passTrigHits.emplace_back(x, y, z, e);
103 TrigEnergySumCollection passTrigSums;
105 for (
auto& pair : lSums) {
106 double e = cvt.calc(pair.second, pair.first);
108 passTrigSums.emplace_back(pair.first, 4, e);
110 for (
auto& pair : rSums) {
111 double e = cvt.calc(pair.second, pair.first);
113 passTrigSums.emplace_back(pair.first, 1, e);
115 for (
auto& pair : cSums) {
116 double e = cvt.calc(pair.second, pair.first);
118 passTrigSums.emplace_back(pair.first, 0, e);
121 event.add(passCollName_ +
"Hits", passTrigHits);
122 event.add(passCollName_ +
"Sums", passTrigSums);