44 if (!event.
exists(quadCollName_, inProc_)) {
52 const std::vector<ldmx::CaloTrigPrim> oneEndedQuads =
57 std::map<int, ldmx::CaloTrigPrim> twoEndedQuadMap;
58 for (
const auto& oneEndedQuad : oneEndedQuads) {
62 auto ptr = twoEndedQuadMap.find(combo_id.
raw());
63 if (ptr == twoEndedQuadMap.end()) {
64 twoEndedQuadMap[combo_id.
raw()] = oneEndedQuad;
66 ptr->second.setPrimitive(ptr->second.getPrimitive() +
67 oneEndedQuad.getPrimitive());
70 ldmx::CaloTrigPrimCollection twoEndedQuads;
71 for (
auto p : twoEndedQuadMap) twoEndedQuads.push_back(p.second);
72 event.add(combinedQuadCollName_, twoEndedQuads);
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);
86 std::map<int, int> section_sum;
87 for (
auto p : twoEndedQuadMap) {
89 int adc = tp.getPrimitive();
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";
98 int isec = combo_id.section();
101 backLayerSums[ilayer].setHwEnergy(adc + backLayerSums[ilayer].hwEnergy());
103 sideLayerSums[ilayer].setHwEnergy(adc + sideLayerSums[ilayer].hwEnergy());
105 auto ptr = section_sum.find(isec);
106 if (ptr == section_sum.end()) {
107 section_sum[isec] = adc;
109 section_sum[isec] += adc;
112 event.add(combinedQuadCollName_ +
"BackLayerSums", backLayerSums);
113 event.add(combinedQuadCollName_ +
"SideLayerSums", sideLayerSums);
115 trigger::TrigEnergySumCollection sectionSums;
116 for (
auto p : section_sum) {
117 sectionSums.emplace_back(-1, p.first, p.second);
119 event.add(combinedQuadCollName_ +
"SectionSums", sectionSums);
123 totalSum.setLayer(-1);
124 totalSum.setHwEnergy(total_adc);
125 event.add(combinedQuadCollName_ +
"Sum", totalSum);
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.