LDMX Software
TrigEcalClusterProducer.cxx
2
5#include "Recon/Event/HgcrocTrigDigi.h"
6#include "Trigger/Event/TrigCaloCluster.h"
7#include "Trigger/Event/TrigCaloHit.h"
8#include "Trigger/IdealClusterBuilder.h"
9
10namespace trigger {
11
13 hitCollName_ = ps.getParameter<std::string>("hitCollName");
14 clusterCollName_ = ps.getParameter<std::string>("clusterCollName");
15}
16
18 const ecal::EcalTriggerGeometry& geom =
19 getCondition<ecal::EcalTriggerGeometry>(
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) {
29 ldmx::EcalTriggerID tid(trigDigi.getId());
30 float e = cvt.calc(trigDigi.linearPrimitive(), tid.layer());
31
32 // float sie = hgc_compression_factor_ * trigDigi.linearPrimitive() *
33 // gain_ * mVtoMeV_; // in MeV, before layer corrections
34 // float e = (sie / mipSiEnergy_ * layerWeights.at(tid.layer()) + sie) *
35 // secondOrderEnergyCorrection_;
36
37 double x, y, z;
38 // const auto center_ecalID = geom.centerInTriggerCell(tid);
39 // const ldmx::EcalGeometry& hexReadout = getCondition<ldmx::EcalGeometry>(
40 // ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);
41 // hexReadout.getCellAbsolutePosition(center_ecalID,x,y,z);
42 // std::tie(x,y) = geom.globalPosition( tid );
43 std::tie(x, y, z) = geom.globalPosition(tid);
44
45 // produce Hit object for clustering class
46 Hit hit;
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 // move to once per run
59 ClusterGeometry myGeo;
60 if (!myGeo.is_initialized) {
61 for (int imod = 0; imod < 7; imod++) {
62 for (int icell = 0; icell < 48; icell++) {
63 ldmx::EcalTriggerID id(0, imod, icell);
64 auto [xx, yy, zz] = geom.globalPosition(id);
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 // TODO: add options to configure the builder here
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}
102} // namespace trigger
103
104DECLARE_PRODUCER_NS(trigger, TrigEcalClusterProducer);
Class that translates raw positions of ECal module hits into cells in a hexagonal readout.
#define DECLARE_PRODUCER_NS(NS, CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class that represents a digitized hit in a calorimeter cell readout by an HGCROC.
ECal clustering algorithm.
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.
Implements an event buffer system for storing event data.
Definition Event.h:41
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:27
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
Extension of DetectorID providing access to ECal trigger cell information.
int layer() const
Get the value of the layer field from the ID.
int module() const
Get the value of the module field from the ID.
int getTriggerCellID() const
Get the value of the trigger cell field from the ID.
Class for clusters built from trigger calo hits.
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.