Process the event and put new data products into it.
20 {
23 ecal::EcalTriggerGeometry::CONDITIONS_OBJECT_NAME);
24
25 if (!event.
exists(hit_coll_name_, hit_coll_name_events_passname_))
return;
26 auto ecal_trig_digis{event.getObject<ldmx::HgcrocTrigDigiCollection>(
27 hit_coll_name_, hit_coll_passname_)};
28
29 std::vector<Hit> hits{};
30 EcalTpToE cvt;
31 for (const auto& trig_digi : ecal_trig_digis) {
33 float e = cvt.calc(trig_digi.linearPrimitive(), tid.layer());
34
35
36
37
38
39
40 double x, y, z;
41
42
43
44
45
47
48
50 hit.e_ = e;
51 hit.x_ = x;
52 hit.y_ = y;
53 hit.z_ = z;
54 hit.layer_ = tid.layer();
55 hit.cell_id_ = tid.getTriggerCellID();
56 hit.module_id_ = tid.module();
57 hit.idx_ = hits.size();
58 hits.push_back(hit);
59 }
60
61
62 ClusterGeometry my_geo;
63 if (!my_geo.is_initialized_) {
64 for (int imod = 0; imod < 7; imod++) {
65 for (int icell = 0; icell < 48; icell++) {
68 my_geo.addTp(id.raw(), icell, imod, xx, yy);
69 }
70 }
71 my_geo.initialize();
72 }
73 IdealClusterBuilder builder;
74 builder.setClusterGeo(&my_geo);
75 for (const auto& h : hits) builder.addHit(h);
76
77 builder.buildClusters();
78 auto clusters = builder.getClusters();
79
80 TrigCaloClusterCollection trig_clusters;
81 for (const auto& c : clusters) {
82 TrigCaloCluster t(c.x_, c.y_, c.z_, c.e_);
83 t.setXYZerr(c.xx_, c.yy_, c.zz_);
84 t.setdxdz(c.dxdz_);
85 t.setdydz(c.dydz_);
86 t.setdxdze(c.dxdze_);
87 t.setdydze(c.dydze_);
88 t.set3D(!c.is_2d_);
89 t.setLayer(c.layer_);
90 t.setFirstLayer(c.first_layer_);
91 t.setLastLayer(c.last_layer_);
92 t.setDepth(c.depth_);
93 int n_tp = 0;
94 if (c.is_2d_) {
95 n_tp = c.hits_.size();
96 } else {
97 for (const auto& c2d : c.clusters2d_) n_tp += c2d.hits_.size();
98 }
99 t.setNTP(n_tp);
100 trig_clusters.push_back(t);
101 }
102
103 event.add(cluster_coll_name_, trig_clusters);
104}
defines the relationship between precision cells and trigger cells and provides geometry information ...
std::tuple< double, double, double > globalPosition(ldmx::EcalTriggerID triggerCell) const
Returns the center of the given trigger cell in world coordinates.
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.
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.
Extension of DetectorID providing access to ECal trigger cell information.