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 hit_coll_name_ = ps.get<std::string>("hitCollName");
14 cluster_coll_name_ = ps.get<std::string>("clusterCollName");
15 hit_coll_passname_ = ps.get<std::string>("hit_coll_passname");
16 hit_coll_name_events_passname_ =
17 ps.get<std::string>("hit_coll_name_events_passname");
18}
19
21 const ecal::EcalTriggerGeometry& geom =
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) {
32 ldmx::EcalTriggerID tid(trig_digi.getId());
33 float e = cvt.calc(trig_digi.linearPrimitive(), tid.layer());
34
35 // float sie = hgc_compression_factor_ * trigDigi.linearPrimitive() *
36 // gain_ * m_vto_me_v_; // in MeV, before layer corrections
37 // float e = (sie / mip_si_energy_ * layerWeights.at(tid.layer()) + sie) *
38 // second_order_energy_correction_;
39
40 double x, y, z;
41 // const auto center_ecalID = geom.centerInTriggerCell(tid);
42 // const ldmx::EcalGeometry& hexReadout = getCondition<ldmx::EcalGeometry>(
43 // ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);
44 // hexReadout.getCellAbsolutePosition(center_ecalID,x,y,z);
45 // std::tie(x,y) = geom.globalPosition( tid );
46 std::tie(x, y, z) = geom.globalPosition(tid);
47
48 // produce Hit object for clustering class
49 Hit hit;
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 // move to once per run
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++) {
66 ldmx::EcalTriggerID id(0, imod, icell);
67 auto [xx, yy, zz] = geom.globalPosition(id);
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 // TODO: add options to configure the builder here
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}
105} // namespace trigger
106
Class that translates raw positions of ECal module hits into cells in a hexagonal readout.
#define DECLARE_PRODUCER(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.
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.
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
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.