LDMX Software
TrigHcalEnergySum.cxx
2
4#include "Hcal/HcalTriggerGeometry.h"
5#include "Recon/Event/CaloTrigPrim.h"
7#include "Trigger/Event/TrigEnergySum.h"
8
9namespace trigger {
10
12 in_proc_ = ps.get<std::string>("inputProc");
13 quad_coll_name_ = ps.get<std::string>("quadCollName");
14 combined_quad_coll_name_ = ps.get<std::string>("combinedQuadCollName");
15}
17 // mV/ADC: 1.2
18 // MeV/MIP: 4.66
19 // PE/MIP: 68 (summed over BOTH ends, based on 1808.05219, p38)
20 // mV/PE: 5
21 // mV/MeV: 72.961 (= 5*68/4.66)
22 // const float mV_per_adc = 1.2;
23 // adc gain
24 // these are unused, should they be? FIXME
25 // const float pe_per_adc = mV_per_adc / 5;
26 // const float MeV_per_adc = mV_per_adc / 72.961;
27 // const float samp_frac = 371/4e3; // ad-hoc, from a 4 GeV neutron sample
28
29 // interaction length in Fe ('steel') = 16.77 cm (132.1 g/cm2)
30 // polystyrene = 77.07 cm (81.7 g/cm2)
31 // back hcal is 20mm bar, 25mm absorber
32 // these are unused, should they be? FIXME
33 // const float had_samp_frac =
34 // (20 / 77.07) / (20 / 77.07 + 25 / 16.77); // 0.148266
35 // const float em_samp_frac =
36 // (20 / 41.31) / (20 / 41.31 + 25 / 1.757); // 0.032906
37 // const float samp_frac = (em_samp_frac + 2 * had_samp_frac) / 3; //
38 // 0.109813 const float attenuation = exp(-1 / 5.); // 5m attenuation length,
39 // 1m half-bar
40
41 // for(auto t : event.searchProducts("","","")) std::cout << t.name() << " "
42 // << t.passname() << " " << t.type() << std::endl;
43
44 if (!event.exists(quad_coll_name_, in_proc_)) {
45 // std::cout << "missing collection! : " << quad_coll_name_ << " " <<
46 // in_proc_
47 // << std::endl;
48 return;
49 }
50
51 // auto
52 // oneEndedQuads{event.getObject<ldmx::CaloTrigPrimCollection>(quad_coll_name_)};
53 const std::vector<ldmx::CaloTrigPrim> one_ended_quads =
54 event.getCollection<ldmx::CaloTrigPrim>(quad_coll_name_, in_proc_);
55
56 //
57 // sum bar ends to produce the combined quads
58 std::map<int, ldmx::CaloTrigPrim> two_ended_quad_map;
59 for (const auto& one_ended_quad : one_ended_quads) {
60 const ldmx::HcalTriggerID end_id(one_ended_quad.getId());
61 ldmx::HcalTriggerID combo_id(end_id.section(), end_id.layer(),
62 end_id.superstrip(), 2);
63 auto ptr = two_ended_quad_map.find(combo_id.raw());
64 if (ptr == two_ended_quad_map.end()) {
65 two_ended_quad_map[combo_id.raw()] = one_ended_quad;
66 } else {
67 ptr->second.setPrimitive(ptr->second.getPrimitive() +
68 one_ended_quad.getPrimitive());
69 }
70 }
71 ldmx::CaloTrigPrimCollection two_ended_quads;
72 for (auto p : two_ended_quad_map) two_ended_quads.push_back(p.second);
73 event.add(combined_quad_coll_name_, two_ended_quads);
74
75 //
76 // Produce the layer-by-layer energy sums
77 const unsigned int layer_max = 50;
78 const unsigned int side_layer_max = 16;
79 trigger::TrigEnergySumCollection back_layer_sums;
80 trigger::TrigEnergySumCollection side_layer_sums;
81 back_layer_sums.resize(layer_max);
82 for (int i = 0; i < layer_max; i++) back_layer_sums[i].setLayer(i);
83 side_layer_sums.resize(side_layer_max);
84 for (int i = 0; i < side_layer_max; i++) side_layer_sums[i].setLayer(i);
85
86 int total_adc = 0;
87 std::map<int, int> section_sum;
88 for (auto p : two_ended_quad_map) {
89 auto tp = p.second;
90 int adc = tp.getPrimitive();
91 total_adc += adc;
92 ldmx::HcalTriggerID combo_id(tp.getId());
93 int ilayer = combo_id.layer();
94 if (ilayer >= back_layer_sums.size()) {
95 std::cout << "[TrigHcalEnergySum.cxx] Warning(!), layer " << ilayer
96 << " is out-of-bounds.\n";
97 continue;
98 }
99 int isec = combo_id.section();
100
101 if (isec == 0)
102 back_layer_sums[ilayer].setHwEnergy(adc +
103 back_layer_sums[ilayer].hwEnergy());
104 else
105 side_layer_sums[ilayer].setHwEnergy(adc +
106 side_layer_sums[ilayer].hwEnergy());
107
108 auto ptr = section_sum.find(isec);
109 if (ptr == section_sum.end()) {
110 section_sum[isec] = adc;
111 } else {
112 section_sum[isec] += adc;
113 }
114 }
115 event.add(combined_quad_coll_name_ + "BackLayerSums", back_layer_sums);
116 event.add(combined_quad_coll_name_ + "SideLayerSums", side_layer_sums);
117
118 trigger::TrigEnergySumCollection section_sums;
119 for (auto p : section_sum) {
120 section_sums.emplace_back(-1, p.first, p.second);
121 }
122 event.add(combined_quad_coll_name_ + "SectionSums", section_sums);
123
124 // Also store total energy for now
125 trigger::TrigEnergySum total_sum;
126 total_sum.setLayer(-1);
127 total_sum.setHwEnergy(total_adc);
128 event.add(combined_quad_coll_name_ + "Sum", total_sum);
129}
130
131} // namespace trigger
132
Class that represents a reconstructed hit in a calorimeter cell within the detector.
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class that translates HCal ID into positions of strip hits.
HcalEnergySum algo.
Implements an event buffer system for storing event data.
Definition Event.h:42
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.
Definition Event.cxx:92
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
Contains the trigger output for generic calo objects.
RawValue raw() const
Definition DetectorID.h:68
Extension of DetectorID providing access to HCal trigger cell.
int superstrip() const
Get the value of the 'superstrip' field from the ID.
int layer() const
Get the value of the layer field from the ID.
Contains the trigger output for generic calo objects.
virtual void configure(framework::config::Parameters &ps)
Callback for the EventProcessor to configure itself from the given set of parameters.
virtual void produce(framework::Event &event)
Process the event and put new data products into it.