LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
opdet::OptDetDigitizer Class Reference
Inheritance diagram for opdet::OptDetDigitizer:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 OptDetDigitizer (const fhicl::ParameterSet &)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
void fillProductDescriptions ()
 
void registerProducts (ProductDescriptions &productsToRegister)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Member Functions

void produce (art::Event &) override
 
void AddDarkNoise (std::vector< double > &RawWF, double gain)
 
void AddWaveform (optdata::TimeSlice_t time, std::vector< double > &OldPulse, std::vector< double > &NewPulse, double factor, bool extend=false)
 
optdata::ChannelData ApplyDigitization (std::vector< double > const RawWF, optdata::Channel_t const ch) const
 

Private Attributes

std::string fInputModule
 
float fSampleFreq
 
float fTimeBegin
 
float fTimeEnd
 
float fQE
 
optdata::ADC_Count_t fSaturationScale
 
std::vector< optdata::ADC_Count_tfPedMeanArray
 
float fDarkRate
 
optdata::ADC_Count_t fPedFlucAmp
 
float fPedFlucRate
 
std::vector< double > fSinglePEWaveform
 
bool fSimGainSpread
 
CLHEP::HepRandomEngine & fEngine
 
CLHEP::RandFlat fFlatRandom
 
CLHEP::RandPoisson fPoissonRandom
 
art::ServiceHandle< OpDigiPropertiesfOpDigiProperties
 
art::ServiceHandle< geo::Geometry const > fGeom
 

Detailed Description

Definition at line 37 of file OptDetDigitizer_module.cc.

Member Typedef Documentation

Definition at line 17 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::detail::Producer::Table = Modifier::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 26 of file Producer.h.

Constructor & Destructor Documentation

opdet::OptDetDigitizer::OptDetDigitizer ( const fhicl::ParameterSet )
explicit

Definition at line 85 of file OptDetDigitizer_module.cc.

References art::detail::EngineCreator::createEngine(), fDarkRate, fEngine, fFlatRandom, fInputModule, fOpDigiProperties, fPedFlucAmp, fPedFlucRate, fPedMeanArray, fPoissonRandom, fQE, fSampleFreq, fSaturationScale, fSimGainSpread, fSinglePEWaveform, fTimeBegin, and fTimeEnd.

86  : EDProducer{pset}
88  pset,
89  "Seed"))
92  {
93  // Infrastructure piece
94  produces<std::vector<optdata::ChannelDataGroup>>();
95 
97  // Input Module and histogram parameters come from .fcl
98  fInputModule = pset.get<std::string>("InputModule");
99  fSimGainSpread = pset.get<bool>("SimGainSpread");
100  fTimeBegin = fOpDigiProperties->TimeBegin();
101  fTimeEnd = fOpDigiProperties->TimeEnd();
102  fSampleFreq = fOpDigiProperties->SampleFreq();
103  fQE = fOpDigiProperties->QE();
104  fDarkRate = fOpDigiProperties->DarkRate();
105  fPedFlucAmp = fOpDigiProperties->PedFlucAmp();
106  fPedFlucRate = fOpDigiProperties->PedFlucRate();
107  fSaturationScale = fOpDigiProperties->SaturationScale();
108  fPedMeanArray = fOpDigiProperties->PedMeanArray();
109 
110  fSinglePEWaveform = fOpDigiProperties->SinglePEWaveform();
111  }
base_engine_t & createEngine(seed_t seed)
optdata::ADC_Count_t fSaturationScale
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
optdata::ADC_Count_t fPedFlucAmp
CLHEP::RandPoisson fPoissonRandom
art::ServiceHandle< OpDigiProperties > fOpDigiProperties
std::vector< double > fSinglePEWaveform
std::vector< optdata::ADC_Count_t > fPedMeanArray
CLHEP::HepRandomEngine & fEngine

Member Function Documentation

void opdet::OptDetDigitizer::AddDarkNoise ( std::vector< double > &  RawWF,
double  gain 
)
private

Definition at line 129 of file OptDetDigitizer_module.cc.

References AddWaveform(), fDarkRate, fFlatRandom, fOpDigiProperties, fPoissonRandom, fSinglePEWaveform, fTimeBegin, and fTimeEnd.

Referenced by produce().

130  {
131  // Add dark noise
132  double MeanDarkPulses = fDarkRate * (fTimeEnd - fTimeBegin) / 1000000;
133 
134  unsigned int NumberOfPulses = fPoissonRandom.fire(MeanDarkPulses);
135  for (size_t i = 0; i != NumberOfPulses; ++i) {
136  double PulseTime_ns = fTimeBegin * 1000 + (fTimeEnd - fTimeBegin) * 1000 *
137  (fFlatRandom.fire(1.0)); // Should be in ns
138  optdata::TimeSlice_t PulseTime_ts = fOpDigiProperties->GetTimeSlice(PulseTime_ns);
139  AddWaveform(PulseTime_ts, RawWF, fSinglePEWaveform, gain);
140  }
141  }
void AddWaveform(optdata::TimeSlice_t time, std::vector< double > &OldPulse, std::vector< double > &NewPulse, double factor, bool extend=false)
CLHEP::RandPoisson fPoissonRandom
art::ServiceHandle< OpDigiProperties > fOpDigiProperties
unsigned int TimeSlice_t
Definition: OpticalTypes.h:20
std::vector< double > fSinglePEWaveform
void opdet::OptDetDigitizer::AddWaveform ( optdata::TimeSlice_t  time,
std::vector< double > &  OldPulse,
std::vector< double > &  NewPulse,
double  factor,
bool  extend = false 
)
private

Definition at line 115 of file OptDetDigitizer_module.cc.

Referenced by AddDarkNoise(), and produce().

120  {
121  if ((time + NewPulse.size()) > OldPulse.size() && extend)
122  OldPulse.resize(time + NewPulse.size());
123  for (size_t i = 0; i < NewPulse.size() && (time + i) < OldPulse.size(); ++i)
124  OldPulse[time + i] += NewPulse[i] * factor;
125  }
optdata::ChannelData opdet::OptDetDigitizer::ApplyDigitization ( std::vector< double > const  RawWF,
optdata::Channel_t const  ch 
) const
private

Definition at line 143 of file OptDetDigitizer_module.cc.

References fOpDigiProperties, fPedFlucAmp, fPedFlucRate, fPedMeanArray, and fSaturationScale.

Referenced by produce().

145  {
146  //
147  // Digitization includes...
148  // (a) amplitude digitization
149  // (b) saturation
150  // (c) pedestal fluctuation
151  //
152 
153  // prepare return data container
154  optdata::ChannelData chData(ch);
155  chData.reserve(rawWF.size());
156  optdata::ADC_Count_t baseMean(fPedMeanArray.at(ch));
157  for (optdata::TimeSlice_t time = 0; time < rawWF.size(); ++time) {
158  double thisSample = rawWF[time];
159 
160  optdata::ADC_Count_t thisCount = (optdata::ADC_Count_t)(thisSample) + baseMean;
161 
162  // (a) amplitude digitization
163  if (CLHEP::RandFlat::shoot(1.0) < (thisSample - int(thisSample))) thisCount += 1;
164 
165  // (b) saturation
166  if (thisCount > fSaturationScale) thisCount = fSaturationScale;
167 
168  chData.push_back(thisCount);
169  }
170 
171  // (c) pedestal fluctuation
172  double timeSpan = chData.size() * 1.e-6 / (fOpDigiProperties->SampleFreq());
173  unsigned int nFluc = CLHEP::RandPoisson::shoot(fPedFlucRate * timeSpan);
174  for (size_t i = 0; i < nFluc; ++i) {
175  optdata::TimeSlice_t pulseTime(CLHEP::RandFlat::shoot(0.0, (double)(chData.size())));
176  optdata::ADC_Count_t amp = chData[pulseTime];
177  if (CLHEP::RandFlat::shoot(0., 1.) > 0.5) {
178  amp += fPedFlucAmp;
179  if (amp > fSaturationScale) amp = fSaturationScale;
180  }
181  else
182  amp -= fPedFlucAmp;
183  chData[pulseTime] = amp;
184  }
185 
186  return chData;
187  }
optdata::ADC_Count_t fSaturationScale
uint16_t ADC_Count_t
Definition: OpticalTypes.h:16
optdata::ADC_Count_t fPedFlucAmp
art::ServiceHandle< OpDigiProperties > fOpDigiProperties
unsigned int TimeSlice_t
Definition: OpticalTypes.h:20
std::vector< optdata::ADC_Count_t > fPedMeanArray
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Producer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 22 of file Producer.cc.

References art::detail::Producer::beginJobWithFrame(), and art::detail::Producer::setupQueues().

23  {
24  setupQueues(resources);
25  ProcessingFrame const frame{ScheduleID{}};
26  beginJobWithFrame(frame);
27  }
virtual void setupQueues(SharedResources const &)=0
virtual void beginJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 65 of file Producer.cc.

References art::detail::Producer::beginRunWithFrame(), art::RangeSet::forRun(), art::RunPrincipal::makeRun(), r, art::RunPrincipal::runID(), and art::ModuleContext::scheduleID().

66  {
67  auto r = rp.makeRun(mc, RangeSet::forRun(rp.runID()));
68  ProcessingFrame const frame{mc.scheduleID()};
69  beginRunWithFrame(r, frame);
70  r.commitProducts();
71  return true;
72  }
TRandom r
Definition: spectrum.C:23
virtual void beginRunWithFrame(Run &, ProcessingFrame const &)=0
static RangeSet forRun(RunID)
Definition: RangeSet.cc:51
bool art::detail::Producer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 85 of file Producer.cc.

References art::detail::Producer::beginSubRunWithFrame(), art::RangeSet::forSubRun(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::SubRunPrincipal::subRunID().

86  {
87  auto sr = srp.makeSubRun(mc, RangeSet::forSubRun(srp.subRunID()));
88  ProcessingFrame const frame{mc.scheduleID()};
89  beginSubRunWithFrame(sr, frame);
90  sr.commitProducts();
91  return true;
92  }
virtual void beginSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:57
void art::detail::Producer::doEndJob ( )
inherited

Definition at line 30 of file Producer.cc.

References art::detail::Producer::endJobWithFrame().

31  {
32  ProcessingFrame const frame{ScheduleID{}};
33  endJobWithFrame(frame);
34  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 75 of file Producer.cc.

References art::detail::Producer::endRunWithFrame(), art::RunPrincipal::makeRun(), r, art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

76  {
77  auto r = rp.makeRun(mc, rp.seenRanges());
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(r, frame);
80  r.commitProducts();
81  return true;
82  }
TRandom r
Definition: spectrum.C:23
virtual void endRunWithFrame(Run &, ProcessingFrame const &)=0
bool art::detail::Producer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 95 of file Producer.cc.

References art::detail::Producer::endSubRunWithFrame(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

96  {
97  auto sr = srp.makeSubRun(mc, srp.seenRanges());
98  ProcessingFrame const frame{mc.scheduleID()};
99  endSubRunWithFrame(sr, frame);
100  sr.commitProducts();
101  return true;
102  }
virtual void endSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
bool art::detail::Producer::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited

Definition at line 105 of file Producer.cc.

References art::detail::Producer::checkPutProducts_, e, art::EventPrincipal::makeEvent(), art::detail::Producer::produceWithFrame(), and art::ModuleContext::scheduleID().

110  {
111  auto e = ep.makeEvent(mc);
112  ++counts_run;
113  ProcessingFrame const frame{mc.scheduleID()};
114  produceWithFrame(e, frame);
115  e.commitProducts(checkPutProducts_, &expectedProducts<InEvent>());
116  ++counts_passed;
117  return true;
118  }
bool const checkPutProducts_
Definition: Producer.h:70
Float_t e
Definition: plot.C:35
virtual void produceWithFrame(Event &, ProcessingFrame const &)=0
void art::detail::Producer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 44 of file Producer.cc.

References art::detail::Producer::respondToCloseInputFileWithFrame().

45  {
46  ProcessingFrame const frame{ScheduleID{}};
48  }
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 58 of file Producer.cc.

References art::detail::Producer::respondToCloseOutputFilesWithFrame().

59  {
60  ProcessingFrame const frame{ScheduleID{}};
62  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 37 of file Producer.cc.

References art::detail::Producer::respondToOpenInputFileWithFrame().

38  {
39  ProcessingFrame const frame{ScheduleID{}};
41  }
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 51 of file Producer.cc.

References art::detail::Producer::respondToOpenOutputFilesWithFrame().

52  {
53  ProcessingFrame const frame{ScheduleID{}};
55  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::Modifier::fillProductDescriptions ( )
inherited

Definition at line 10 of file Modifier.cc.

References art::ProductRegistryHelper::fillDescriptions(), and art::ModuleBase::moduleDescription().

11  {
13  }
void fillDescriptions(ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void opdet::OptDetDigitizer::produce ( art::Event evt)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 191 of file OptDetDigitizer_module.cc.

References AddDarkNoise(), AddWaveform(), ApplyDigitization(), fFlatRandom, fGeom, fInputModule, fOpDigiProperties, fQE, fSampleFreq, fSimGainSpread, fSinglePEWaveform, fTimeBegin, fTimeEnd, sim::SimListUtils::GetSimPhotonsCollection(), optdata::kHighGain, optdata::kLowGain, geo::GeometryCore::NOpChannels(), sim::SimPhotons::OpChannel(), and art::Event::put().

192  {
193 
194  //
195  // Event-wise initialization
196  //
197 
198  // Infrastructure piece
199  std::unique_ptr<std::vector<optdata::ChannelDataGroup>> StoragePtr(
200  new std::vector<optdata::ChannelDataGroup>);
201 
202  // Read in the Sim Photons
203  sim::SimPhotonsCollection ThePhotCollection =
205 
206  // Convert units into ns from us/MHz
207  double timeBegin_ns = fTimeBegin * 1000;
208  double timeEnd_ns = fTimeEnd * 1000;
209  double sampleFreq_ns = fSampleFreq / 1000;
210 
211  // Compute # of timeslices to be stored in the output. This is defined by a user input (fcl file)
212  optdata::TimeSlice_t timeSliceWindow(fOpDigiProperties->GetTimeSlice(timeEnd_ns));
213 
214  /*
215  Create output data product, optdata::ChannelDataGroup for each gain channel.
216  Note : Although the frame + sample number in DATA should have a reference of T=0 @ DAQ start time, this is
217  not handled in MC. Hence we do not set them here (use constructor default)
218  */
219  optdata::ChannelDataGroup rawWFGroup_HighGain(optdata::kHighGain);
220  optdata::ChannelDataGroup rawWFGroup_LowGain(optdata::kLowGain);
221  // Reserve entries equal to # of channels
222  rawWFGroup_HighGain.reserve(fGeom->NOpChannels());
223  rawWFGroup_LowGain.reserve(fGeom->NOpChannels());
224 
225  /*
226  Define "raw" waveform container which will be filled based on G4 photon timing + SPE waveform information.
227  Note this is not completely an analog waveform because it is digitized in terms of time (as it is using std::vector).
228  */
229  std::vector<std::vector<double>> rawWF_HighGain(fGeom->NOpChannels(),
230  std::vector<double>(timeSliceWindow, 0.0));
231  std::vector<std::vector<double>> rawWF_LowGain(fGeom->NOpChannels(),
232  std::vector<double>(timeSliceWindow, 0.0));
233 
234  /*
235  Start data processing ... see following steps
236  (1) Loop over input array of optical photons & fill "raw" waveform container w/ corresponding SPE waveform
237  (2) Loop over filled "raw" waveform and process (digitization, adding noise, baseline spread, etc)
238  */
239 
240  //
241  // Step (1) ... loop over G4 optical photons
242  //
243 
244  // For every OpDet, convert PE into waveform and combine all together
245  for (sim::SimPhotonsCollection::const_iterator itOpDet = ThePhotCollection.begin();
246  itOpDet != ThePhotCollection.end();
247  itOpDet++) {
248  const sim::SimPhotons& ThePhot = itOpDet->second;
249 
250  int ch = ThePhot.OpChannel();
251  // For every photon in the hit:
252  for (const sim::OnePhoton& Phot : ThePhot) {
253  // Sample a random subset according to QE
254  if (fFlatRandom.fire(1.0) <= fQE) {
255  optdata::TimeSlice_t PhotonTime(fOpDigiProperties->GetTimeSlice(Phot.Time));
256  if (Phot.Time > timeBegin_ns && Phot.Time < timeEnd_ns) {
257  if (fSimGainSpread) {
258  AddWaveform(
259  PhotonTime, rawWF_HighGain[ch], fSinglePEWaveform, fOpDigiProperties->HighGain(ch));
260  AddWaveform(
261  PhotonTime, rawWF_LowGain[ch], fSinglePEWaveform, fOpDigiProperties->LowGain(ch));
262  }
263  else {
264  AddWaveform(PhotonTime,
265  rawWF_HighGain[ch],
267  fOpDigiProperties->HighGainMean(ch));
268  AddWaveform(PhotonTime,
269  rawWF_LowGain[ch],
271  fOpDigiProperties->LowGainMean(ch));
272  }
273  }
274  } // random QE cut
275  } // for each Photon in SimPhotons
276  }
277 
278  //
279  // Loop over "raw" waveform (channel-wise)
280  //
281  for (unsigned short iCh = 0; iCh < rawWF_LowGain.size(); ++iCh) {
282  rawWF_LowGain[iCh].resize((timeEnd_ns - timeBegin_ns) * sampleFreq_ns);
283  rawWF_HighGain[iCh].resize((timeEnd_ns - timeBegin_ns) * sampleFreq_ns);
284 
285  // Add dark noise
286  if (fSimGainSpread) {
287  AddDarkNoise(rawWF_LowGain[iCh], fOpDigiProperties->LowGain(iCh));
288  AddDarkNoise(rawWF_HighGain[iCh], fOpDigiProperties->HighGain(iCh));
289  }
290  else {
291  AddDarkNoise(rawWF_LowGain[iCh], fOpDigiProperties->LowGainMean(iCh));
292  AddDarkNoise(rawWF_HighGain[iCh], fOpDigiProperties->HighGainMean(iCh));
293  }
294 
295  // Apply digitization and make channel data
296  optdata::ChannelData chData_HighGain(ApplyDigitization(rawWF_HighGain[iCh], iCh));
297  optdata::ChannelData chData_LowGain(ApplyDigitization(rawWF_LowGain[iCh], iCh));
298 
299  rawWFGroup_HighGain.push_back(chData_HighGain);
300  rawWFGroup_LowGain.push_back(chData_LowGain);
301  } // for each OpDet in SimPhotonsCollection
302 
303  StoragePtr->push_back(rawWFGroup_HighGain);
304  StoragePtr->push_back(rawWFGroup_LowGain);
305 
306  evt.put(std::move(StoragePtr));
307  }
art::ServiceHandle< geo::Geometry const > fGeom
optdata::ChannelData ApplyDigitization(std::vector< double > const RawWF, optdata::Channel_t const ch) const
int OpChannel() const
Returns the optical channel number this object is associated to.
Definition: SimPhotons.h:239
All information of a photon entering the sensitive optical detector volume.
Definition: SimPhotons.h:60
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
void AddWaveform(optdata::TimeSlice_t time, std::vector< double > &OldPulse, std::vector< double > &NewPulse, double factor, bool extend=false)
art::ServiceHandle< OpDigiProperties > fOpDigiProperties
Collection of photons which recorded on one channel.
Definition: SimPhotons.h:127
list_type::const_iterator const_iterator
Definition: SimPhotons.h:191
unsigned int TimeSlice_t
Definition: OpticalTypes.h:20
std::vector< double > fSinglePEWaveform
Collection of sim::SimPhotons, indexed by channel number.
Definition: SimPhotons.h:178
void AddDarkNoise(std::vector< double > &RawWF, double gain)
static sim::SimPhotonsCollection GetSimPhotonsCollection(const art::Event &evt, std::string moduleLabel)
void art::Modifier::registerProducts ( ProductDescriptions productsToRegister)
inherited

Definition at line 16 of file Modifier.cc.

References art::ModuleBase::moduleDescription(), and art::ProductRegistryHelper::registerProducts().

17  {
18  ProductRegistryHelper::registerProducts(productsToRegister,
20  }
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)

Member Data Documentation

float opdet::OptDetDigitizer::fDarkRate
private

Definition at line 52 of file OptDetDigitizer_module.cc.

Referenced by AddDarkNoise(), and OptDetDigitizer().

CLHEP::HepRandomEngine& opdet::OptDetDigitizer::fEngine
private

Definition at line 61 of file OptDetDigitizer_module.cc.

Referenced by OptDetDigitizer().

CLHEP::RandFlat opdet::OptDetDigitizer::fFlatRandom
private

Definition at line 62 of file OptDetDigitizer_module.cc.

Referenced by AddDarkNoise(), OptDetDigitizer(), and produce().

art::ServiceHandle<geo::Geometry const> opdet::OptDetDigitizer::fGeom
private

Definition at line 73 of file OptDetDigitizer_module.cc.

Referenced by produce().

std::string opdet::OptDetDigitizer::fInputModule
private

Definition at line 45 of file OptDetDigitizer_module.cc.

Referenced by OptDetDigitizer(), and produce().

art::ServiceHandle<OpDigiProperties> opdet::OptDetDigitizer::fOpDigiProperties
private
optdata::ADC_Count_t opdet::OptDetDigitizer::fPedFlucAmp
private

Definition at line 53 of file OptDetDigitizer_module.cc.

Referenced by ApplyDigitization(), and OptDetDigitizer().

float opdet::OptDetDigitizer::fPedFlucRate
private

Definition at line 54 of file OptDetDigitizer_module.cc.

Referenced by ApplyDigitization(), and OptDetDigitizer().

std::vector<optdata::ADC_Count_t> opdet::OptDetDigitizer::fPedMeanArray
private

Definition at line 51 of file OptDetDigitizer_module.cc.

Referenced by ApplyDigitization(), and OptDetDigitizer().

CLHEP::RandPoisson opdet::OptDetDigitizer::fPoissonRandom
private

Definition at line 63 of file OptDetDigitizer_module.cc.

Referenced by AddDarkNoise(), and OptDetDigitizer().

float opdet::OptDetDigitizer::fQE
private

Definition at line 49 of file OptDetDigitizer_module.cc.

Referenced by OptDetDigitizer(), and produce().

float opdet::OptDetDigitizer::fSampleFreq
private

Definition at line 46 of file OptDetDigitizer_module.cc.

Referenced by OptDetDigitizer(), and produce().

optdata::ADC_Count_t opdet::OptDetDigitizer::fSaturationScale
private

Definition at line 50 of file OptDetDigitizer_module.cc.

Referenced by ApplyDigitization(), and OptDetDigitizer().

bool opdet::OptDetDigitizer::fSimGainSpread
private

Definition at line 59 of file OptDetDigitizer_module.cc.

Referenced by OptDetDigitizer(), and produce().

std::vector<double> opdet::OptDetDigitizer::fSinglePEWaveform
private

Definition at line 57 of file OptDetDigitizer_module.cc.

Referenced by AddDarkNoise(), OptDetDigitizer(), and produce().

float opdet::OptDetDigitizer::fTimeBegin
private

Definition at line 47 of file OptDetDigitizer_module.cc.

Referenced by AddDarkNoise(), OptDetDigitizer(), and produce().

float opdet::OptDetDigitizer::fTimeEnd
private

Definition at line 48 of file OptDetDigitizer_module.cc.

Referenced by AddDarkNoise(), OptDetDigitizer(), and produce().


The documentation for this class was generated from the following file: