17 : Producer(name, process) {
32 hgcroc_ = std::make_unique<ldmx::HgcrocEmulator>(hgcrocParams);
33 clockCycle_ = hgcrocParams.getParameter<
double>(
"clockCycle");
34 nADCs_ = hgcrocParams.getParameter<
int>(
"nADCs");
35 iSOI_ = hgcrocParams.getParameter<
int>(
"iSOI");
36 noise_ = hgcrocParams.getParameter<
bool>(
"noise");
54 double readoutThreshold = ps.
getParameter<
double>(
"avgReadoutThreshold");
55 double pedestal = ps.
getParameter<
double>(
"avgPedestal");
56 double noiseRMS = ps.
getParameter<
double>(
"avgNoiseRMS");
68 const auto& rseed = getCondition<framework::RandomNumberSeedService>(
71 rseed.getSeed(
"EcalDigiProducer::NoiseGenerator"));
74 const auto& rseed = getCondition<framework::RandomNumberSeedService>(
77 rseed.getSeed(
"EcalDigiProducer::NoiseInjector"));
80 const auto& rseed = getCondition<framework::RandomNumberSeedService>(
82 hgcroc_->seedGenerator(rseed.getSeed(
"EcalDigiProducer::HgcrocEmulator"));
86 getCondition<conditions::DoubleTableCondition>(
"EcalHgcrocConditions"));
93 std::set<unsigned int>
113 for (
auto const& simHit : ecalSimHits) {
114 std::vector<std::pair<double, double>> pulses_at_chip;
115 for (
int iContrib = 0; iContrib < simHit.getNumberOfContribs();
126 pulses_at_chip.emplace_back(
127 simHit.getContrib(iContrib).edep *
MeV_,
128 simHit.getContrib(iContrib).time
129 - simHit.getPosition().at(2) /
134 unsigned int hitID = simHit.
getID();
135 filledDetIDs.insert(hitID);
146 std::vector<ldmx::HgcrocDigiCollection::Sample> digiToAdd;
147 if (
hgcroc_->digitize(hitID, pulses_at_chip, digiToAdd)) {
148 ecalDigis.
addDigi(hitID, digiToAdd);
162 const auto& geom = getCondition<ldmx::EcalGeometry>(
163 ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);
164 int nEcalLayers = geom.getNumLayers();
165 int nModulesPerLayer = geom.getNumModulesPerLayer();
166 int nCellsPerModule = geom.getNumCellsPerModule();
167 int numEmptyChannels = nEcalLayers * nModulesPerLayer * nCellsPerModule -
173 auto noiseHitAmplitudes{
175 std::vector<std::pair<double, double>> fake_pulse(1, {0., 0.});
176 for (
double noiseHit : noiseHitAmplitudes) {
179 unsigned int noiseID;
185 noiseID = detID.raw();
186 }
while (filledDetIDs.find(noiseID) != filledDetIDs.end());
187 filledDetIDs.insert(noiseID);
193 (
hgcroc_->readoutThreshold(noiseID) -
hgcroc_->pedestal(noiseID));
196 ecalDigis.
addDigi(noiseID,
hgcroc_->noiseDigi(noiseID, noiseHit));
201 for (
int layer{0}; layer < nEcalLayers; layer++) {
202 for (
int module{0};
module < nModulesPerLayer;
module++) {
203 for (int cell{0}; cell < nCellsPerModule; cell++) {
206 if (filledDetIDs.find(channel) != filledDetIDs.end())
continue;
215 event.add(digiCollName_, ecalDigis);
Class that performs basic ECal digitization.
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.
Conditions object for random number seeds.
int iSOI_
Index for the Sample Of Interest in the list of digi samples.
bool noise_
Put noise into empty channels, not configurable, only helpful in development.
virtual void configure(framework::config::Parameters &)
Configure this producer from the python configuration.
std::string inputCollName_
input hit collection name
double clockCycle_
Time interval for chip clock in ns.
int nADCs_
Depth of ADC buffer.
std::unique_ptr< ldmx::NoiseGenerator > noiseGenerator_
Generates noise hits based off of number of cells that are not hit.
EcalDigiProducer(const std::string &name, framework::Process &process)
Constructor Makes unique noise generator and injector for this class.
std::unique_ptr< TRandom3 > noiseInjector_
Generates Gaussian noise on top of real hits.
virtual void produce(framework::Event &event)
Simulates measurement of pulse and creates digi collection for input event.
virtual ~EcalDigiProducer()
Destructor Deletes digi collection if it has been created.
double ns_
Total number of channels in the ECal.
std::string digiCollName_
output hit collection name
double MeV_
Conversion from energy in MeV to voltage in mV.
std::string inputPassName_
input pass name
std::unique_ptr< ldmx::HgcrocEmulator > hgcroc_
Hgcroc Emulator to digitize analog voltage signals.
bool zero_suppression_
When emulating noise in empty channels, do we zero suppress?
Implements an event buffer system for storing event data.
Class which represents the process under execution.
static const std::string CONDITIONS_OBJECT_NAME
Conditions object name.
Class encapsulating parameters for configuring a processor.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Extension of DetectorID providing access to ECal layers and cell numbers in a hex grid.
Represents a collection of the digi hits readout by an HGCROC.
void setNumSamplesPerDigi(unsigned int n)
Set number of samples for each digi.
void setSampleOfInterestIndex(unsigned int n)
Set index of sample of interest.
void addDigi(unsigned int id, const std::vector< Sample > &digi)
Add samples to collection.
unsigned int getNumDigis() const
Get total number of digis.
Stores simulated calorimeter hit information.
int getID() const
Get the detector ID.