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