LDMX Software
EcalRecProducer.cxx
Go to the documentation of this file.
1
8
10#include "Ecal/EcalReconConditions.h"
11#include "Ecal/Event/EcalHit.h"
14
15namespace ecal {
16
17EcalRecProducer::EcalRecProducer(const std::string& name,
18 framework::Process& process)
19 : Producer(name, process) {}
20
22
24 // collection names
25 digiCollName_ = ps.getParameter<std::string>("digiCollName");
26 digiPassName_ = ps.getParameter<std::string>("digiPassName");
27 simHitCollName_ = ps.getParameter<std::string>("simHitCollName");
28 simHitPassName_ = ps.getParameter<std::string>("simHitPassName");
29 recHitCollName_ = ps.getParameter<std::string>("recHitCollName");
30
31 layerWeights_ = ps.getParameter<std::vector<double>>("layerWeights");
33 ps.getParameter<double>("secondOrderEnergyCorrection");
34
35 mip_si_energy_ = ps.getParameter<double>("mip_si_energy");
36 clock_cycle_ = ps.getParameter<double>("clock_cycle");
37 charge_per_mip_ = ps.getParameter<double>("charge_per_mip");
38}
39
41 // Get the Ecal Geometry
42 const auto& geometry = getCondition<ldmx::EcalGeometry>(
43 ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);
44
45 // Get the reconstruction parameters
46 EcalReconConditions the_conditions(
47 getCondition<conditions::DoubleTableCondition>(
49
50 std::vector<ldmx::EcalHit> ecalRecHits;
51 auto ecalDigis =
53 // loop through digis
54 for (auto digi : ecalDigis) {
55 // ID from first digi sample
56 // assuming rest of samples have same ID
57 ldmx::EcalID id(digi.id());
58
59 // ID to real space position
60 auto [x, y, z] = geometry.getPosition(id);
61
62 // TOA is the time of arrival with respect to the 25ns clock window
63 // TODO what to do if hit NOT in first clock cycle?
64 double timeRelClock25 = digi.soi().toa() * (clock_cycle_ / 1024); // ns
65 double hitTime = timeRelClock25;
66
67 // get the estimated charge deposited from digi samples
68 double charge(0.);
69
70 /* debug printout
71 std::cout << "Recon { "
72 << "ID: " << id << ", "
73 << "TOA: " << hitTime << "ns } ";
74 */
75 if (digi.isTOT()) {
76 // TOT - number of clock ticks that pulse was over threshold
77 // this is related to the amplitude of the pulse approximately through a
78 // linear drain rate the amplitude of the pulse is related to the energy
79 // deposited
80
81 // convert the time over threshold into a total energy deposited in the
82 // silicon
83 // (time over threshold [ns] - pedestal) * gain
84 charge = (digi.tot() - the_conditions.totPedestal(id)) *
85 the_conditions.totGain(id);
86
87 /* debug printout
88 std::cout << "TOT Mode -> " << digi.tot() << "TDC -> " << charge << " fC";
89 */
90 } else {
91 // ADC mode of readout
92 // ADC - voltage measurement at a specific time of the pulse
93 // Pulse Shape:
94 // p[0]/(1.0+exp(p[1](t-p[2]+p[3]-p[4])))/(1.0+exp(p[5]*(t-p[6]+p[3]-p[4])))
95 // p[0] = amplitude to be fit (TBD)
96 // p[1] = -0.345 shape parameter - rate of up slope
97 // p[2] = 70.6547 shape parameter - time of up slope relative to shape
98 // fit p[3] = 77.732 shape parameter - time of peak relative to shape fit
99 // p[4] = peak time to be fit (TBD)
100 // p[5] = 0.140068 shape parameter - rate of down slope
101 // p[6] = 87.7649 shape paramter - time of down slope relative to shape
102 // fit
103 // These measurements can be used to fit the pulse shape if TOT is not
104 // available. For now, we simply take the measurement of the SOI as the
105 // peak amplitude.
106
107 charge = (digi.soi().adc_t() - the_conditions.adcPedestal(id)) *
108 the_conditions.adcGain(id);
109
110 /* debug printout
111 std::cout << "ADC Mode -> " << charge << " fC";
112 */
113 }
114
126 if (charge < 0) continue;
127
128 double num_mips_equivalent = charge / charge_per_mip_;
129 double energy_deposited_in_Si = num_mips_equivalent * mip_si_energy_;
130
131 /* debug printout
132 std::cout << " -> " << num_mips_equivalent
133 << " equiv MIPs -> " << energy_deposited_in_Si << " MeV"
134 << std::endl;
135 */
136
137 // incorporate layer weights
138 double reconstructed_energy =
139 (num_mips_equivalent *
140 layerWeights_.at(
141 id.layer()) // energy lost in non-sensitive layers
142 + energy_deposited_in_Si // energy deposited in Si itself
143 ) *
145
146 // copy over information to rec hit structure in new collection
147 ldmx::EcalHit recHit;
148 recHit.setID(id.raw());
149 recHit.setXPos(x);
150 recHit.setYPos(y);
151 recHit.setZPos(z);
152 recHit.setAmplitude(energy_deposited_in_Si);
153 recHit.setEnergy(reconstructed_energy);
154 recHit.setTime(hitTime);
155
156 ecalRecHits.push_back(recHit);
157 }
158
160 // ecal sim hits exist ==> label which hits are real and which are pure
161 // noise
162 auto ecalSimHits{event.getCollection<ldmx::SimCalorimeterHit>(
164 std::set<int> real_hits;
165 for (auto const& sim_hit : ecalSimHits) real_hits.insert(sim_hit.getID());
166 for (auto& hit : ecalRecHits)
167 hit.setNoise(real_hits.find(hit.getID()) == real_hits.end());
168 }
169
170 // add collection to event bus
171 event.add(recHitCollName_, ecalRecHits);
172}
173
174} // namespace ecal
175
176DECLARE_PRODUCER_NS(ecal, EcalRecProducer);
Class that translates raw positions of ECal module hits into cells in a hexagonal readout.
Class that performs basic ECal digitization.
#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.
Class which stores simulated calorimeter hit information.
std::string digiPassName_
Digi Pass Name to use as input.
std::vector< double > layerWeights_
Layer Weights to use for this reconstruction.
double mip_si_energy_
Energy [MeV] deposited by a MIP in Si 0.5mm thick.
virtual ~EcalRecProducer()
Destructor.
std::string digiCollName_
Digi Collection Name to use as input.
double charge_per_mip_
Number of electrons generated by average MIP in Si 0.5mm thick.
std::string recHitCollName_
output hit collection name
std::string simHitPassName_
simhit pass name
EcalRecProducer(const std::string &name, framework::Process &process)
Constructor.
virtual void produce(framework::Event &event)
Produce EcalHits and put them into the event bus using the EcalDigis as input.
virtual void configure(framework::config::Parameters &)
Grabs configure parameters from the python config file.
double clock_cycle_
Length of clock cycle [ns].
std::string simHitCollName_
simhit collection name
double secondOrderEnergyCorrection_
Second Order Energy Correction to use for this reconstruction.
Class to wrap around an double table of conditions.
double adcPedestal(const ldmx::EcalID &id) const
get the ADC pedestal
double adcGain(const ldmx::EcalID &id) const
get the ADC gain
double totPedestal(const ldmx::EcalID &id) const
get the TOT pedestal
static const std::string CONDITIONS_NAME
the name of the EcalReconConditions table (must match python registration name)
double totGain(const ldmx::EcalID &id) const
get the TOT gain
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 which represents the process under execution.
Definition Process.h:36
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
void setYPos(float ypos)
Set the Y position of the hit [mm].
void setID(int id)
Set the detector ID.
void setZPos(float zpos)
Set the Z position of the hit [mm].
void setXPos(float xpos)
Set the X position of the hit [mm].
void setTime(float time)
Set the time of the hit [ns].
void setAmplitude(float amplitude)
Set the amplitude of the hit, which is proportional to the signal in the calorimeter cell without sam...
void setEnergy(float energy)
Set the calorimetric energy of the hit, corrected for sampling factors [MeV].
Stores reconstructed hit information from the ECAL.
Definition EcalHit.h:19
Extension of DetectorID providing access to ECal layers and cell numbers in a hex grid.
Definition EcalID.h:20
Represents a collection of the digi hits readout by an HGCROC.
Stores simulated calorimeter hit information.