Process the event and put new data products into it.
16 {
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 if (!event.
exists(quadCollName_, inProc_)) {
45
46
47 return;
48 }
49
50
51
52 const std::vector<ldmx::CaloTrigPrim> oneEndedQuads =
54
55
56
57 std::map<int, ldmx::CaloTrigPrim> twoEndedQuadMap;
58 for (const auto& oneEndedQuad : oneEndedQuads) {
61 end_id.superstrip(), 2);
62 auto ptr = twoEndedQuadMap.find(combo_id.raw());
63 if (ptr == twoEndedQuadMap.end()) {
64 twoEndedQuadMap[combo_id.raw()] = oneEndedQuad;
65 } else {
66 ptr->second.setPrimitive(ptr->second.getPrimitive() +
67 oneEndedQuad.getPrimitive());
68 }
69 }
70 ldmx::CaloTrigPrimCollection twoEndedQuads;
71 for (auto p : twoEndedQuadMap) twoEndedQuads.push_back(p.second);
72 event.add(combinedQuadCollName_, twoEndedQuads);
73
74
75
76 const unsigned int LayerMax = 50;
77 const unsigned int SideLayerMax = 16;
78 trigger::TrigEnergySumCollection backLayerSums;
79 trigger::TrigEnergySumCollection sideLayerSums;
80 backLayerSums.resize(LayerMax);
81 for (int i = 0; i < LayerMax; i++) backLayerSums[i].setLayer(i);
82 sideLayerSums.resize(SideLayerMax);
83 for (int i = 0; i < SideLayerMax; i++) sideLayerSums[i].setLayer(i);
84
85 int total_adc = 0;
86 std::map<int, int> section_sum;
87 for (auto p : twoEndedQuadMap) {
88 auto tp = p.second;
89 int adc = tp.getPrimitive();
90 total_adc += adc;
92 int ilayer = combo_id.layer();
93 if (ilayer >= backLayerSums.size()) {
94 std::cout << "[TrigHcalEnergySum.cxx] Warning(!), layer " << ilayer
95 << " is out-of-bounds.\n";
96 continue;
97 }
98 int isec = combo_id.section();
99
100 if (isec == 0)
101 backLayerSums[ilayer].setHwEnergy(adc + backLayerSums[ilayer].hwEnergy());
102 else
103 sideLayerSums[ilayer].setHwEnergy(adc + sideLayerSums[ilayer].hwEnergy());
104
105 auto ptr = section_sum.find(isec);
106 if (ptr == section_sum.end()) {
107 section_sum[isec] = adc;
108 } else {
109 section_sum[isec] += adc;
110 }
111 }
112 event.add(combinedQuadCollName_ + "BackLayerSums", backLayerSums);
113 event.add(combinedQuadCollName_ + "SideLayerSums", sideLayerSums);
114
115 trigger::TrigEnergySumCollection sectionSums;
116 for (auto p : section_sum) {
117 sectionSums.emplace_back(-1, p.first, p.second);
118 }
119 event.add(combinedQuadCollName_ + "SectionSums", sectionSums);
120
121
123 totalSum.setLayer(-1);
124 totalSum.setHwEnergy(total_adc);
125 event.add(combinedQuadCollName_ + "Sum", totalSum);
126}
bool exists(const std::string &name, const std::string &passName="", bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.
Contains the trigger output for generic calo objects.
Extension of DetectorID providing access to HCal trigger cell.
Contains the trigger output for generic calo objects.