Process the event and put new data products into it.
17 {
20 ecal::EcalTriggerGeometry::CONDITIONS_OBJECT_NAME);
21
22 if (!event.
exists(hitCollName_))
return;
23 auto ecalTrigDigis{
24 event.getObject<ldmx::HgcrocTrigDigiCollection>(hitCollName_)};
25
26 std::vector<Hit> hits{};
27 ecalTpToE cvt;
28 for (const auto& trigDigi : ecalTrigDigis) {
30 float e = cvt.calc(trigDigi.linearPrimitive(), tid.layer());
31
32
33
34
35
36
37 double x, y, z;
38
39
40
41
42
44
45
47 hit.e = e;
48 hit.x = x;
49 hit.y = y;
50 hit.z = z;
51 hit.layer = tid.layer();
52 hit.cell_id = tid.getTriggerCellID();
53 hit.module_id = tid.module();
54 hit.idx = hits.size();
55 hits.push_back(hit);
56 }
57
58
59 ClusterGeometry myGeo;
60 if (!myGeo.is_initialized) {
61 for (int imod = 0; imod < 7; imod++) {
62 for (int icell = 0; icell < 48; icell++) {
65 myGeo.AddTP(id.raw(), icell, imod, xx, yy);
66 }
67 }
68 myGeo.Initialize();
69 }
70 IdealClusterBuilder builder;
71 builder.SetClusterGeo(&myGeo);
72 for (const auto& h : hits) builder.AddHit(h);
73
74 builder.BuildClusters();
75 auto clusters = builder.GetClusters();
76
77 TrigCaloClusterCollection trigClusters;
78 for (const auto& c : clusters) {
79 TrigCaloCluster t(c.x, c.y, c.z, c.e);
80 t.setXYZerr(c.xx, c.yy, c.zz);
81 t.setdxdz(c.dxdz);
82 t.setdydz(c.dydz);
83 t.setdxdze(c.dxdze);
84 t.setdydze(c.dydze);
85 t.set3D(!c.is2D);
86 t.setLayer(c.layer);
87 t.setFirstLayer(c.first_layer);
88 t.setLastLayer(c.last_layer);
89 t.setDepth(c.depth);
90 int nTP = 0;
91 if (c.is2D) {
92 nTP = c.hits.size();
93 } else {
94 for (const auto& c2d : c.clusters2d) nTP += c2d.hits.size();
95 }
96 t.setNTP(nTP);
97 trigClusters.push_back(t);
98 }
99
100 event.add(clusterCollName_, trigClusters);
101}
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.