Public Member Functions | Private Member Functions | Private Attributes | List of all members
opdet::OptDetDigitizer Class Reference
Inheritance diagram for opdet::OptDetDigitizer:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 OptDetDigitizer (const fhicl::ParameterSet &)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
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)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
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)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

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
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
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 ()
 

Detailed Description

Definition at line 37 of file OptDetDigitizer_module.cc.

Constructor & Destructor Documentation

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

Definition at line 86 of file OptDetDigitizer_module.cc.

87  : EDProducer{pset}
91  {
92  // Infrastructure piece
93  produces<std::vector< optdata::ChannelDataGroup> >();
94 
96  // Input Module and histogram parameters come from .fcl
97  fInputModule = pset.get<std::string>("InputModule");
98  fSimGainSpread = pset.get<bool >("SimGainSpread");
99  fTimeBegin = fOpDigiProperties->TimeBegin();
100  fTimeEnd = fOpDigiProperties->TimeEnd();
101  fSampleFreq = fOpDigiProperties->SampleFreq();
102  fQE = fOpDigiProperties->QE();
103  fDarkRate = fOpDigiProperties->DarkRate();
104  fPedFlucAmp = fOpDigiProperties->PedFlucAmp();
105  fPedFlucRate= fOpDigiProperties->PedFlucRate();
106  fSaturationScale = fOpDigiProperties->SaturationScale();
107  fPedMeanArray = fOpDigiProperties->PedMeanArray();
108 
109  fSinglePEWaveform = fOpDigiProperties->SinglePEWaveform();
110  }
base_engine_t & createEngine(seed_t seed)
optdata::ADC_Count_t fSaturationScale
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
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 128 of file OptDetDigitizer_module.cc.

128  {
129  // Add dark noise
130  double MeanDarkPulses = fDarkRate * (fTimeEnd-fTimeBegin) / 1000000;
131 
132  unsigned int NumberOfPulses = fPoissonRandom.fire(MeanDarkPulses);
133  for(size_t i=0; i!=NumberOfPulses; ++i)
134  {
135  double PulseTime_ns = fTimeBegin*1000 + (fTimeEnd-fTimeBegin)*1000*(fFlatRandom.fire(1.0)); // Should be in ns
136  optdata::TimeSlice_t PulseTime_ts = fOpDigiProperties->GetTimeSlice(PulseTime_ns);
137  AddWaveform( PulseTime_ts,
138  RawWF,
140  gain);
141  }
142 
143  }
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 114 of file OptDetDigitizer_module.cc.

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

Definition at line 145 of file OptDetDigitizer_module.cc.

147  {
148  //
149  // Digitization includes...
150  // (a) amplitude digitization
151  // (b) saturation
152  // (c) pedestal fluctuation
153  //
154 
155  // prepare return data container
156  optdata::ChannelData chData(ch);
157  chData.reserve(rawWF.size());
158  optdata::ADC_Count_t baseMean(fPedMeanArray.at(ch));
159  for(optdata::TimeSlice_t time=0; time<rawWF.size(); ++time)
160  {
161  double thisSample = rawWF[time];
162 
163  optdata::ADC_Count_t thisCount = (optdata::ADC_Count_t)(thisSample)+baseMean;
164 
165  // (a) amplitude digitization
166  if(CLHEP::RandFlat::shoot(1.0) < (thisSample - int(thisSample)))
167  thisCount+=1;
168 
169  // (b) saturation
170  if(thisCount > fSaturationScale) thisCount = fSaturationScale;
171 
172  chData.push_back(thisCount);
173  }
174 
175  // (c) pedestal fluctuation
176  double timeSpan = chData.size() * 1.e-6/(fOpDigiProperties->SampleFreq());
177  unsigned int nFluc = CLHEP::RandPoisson::shoot(fPedFlucRate * timeSpan);
178  for(size_t i=0; i<nFluc; ++i)
179  {
180  optdata::TimeSlice_t pulseTime(CLHEP::RandFlat::shoot(0.0,(double)(chData.size())));
181  optdata::ADC_Count_t amp = chData[pulseTime];
182  if( CLHEP::RandFlat::shoot(0.,1.) > 0.5)
183  {
184  amp += fPedFlucAmp;
185  if(amp > fSaturationScale) amp=fSaturationScale;
186  }
187  else
188  amp -= fPedFlucAmp;
189  chData[pulseTime] = amp;
190  }
191 
192  return chData;
193  }
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
void opdet::OptDetDigitizer::produce ( art::Event evt)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 197 of file OptDetDigitizer_module.cc.

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

Member Data Documentation

float opdet::OptDetDigitizer::fDarkRate
private

Definition at line 52 of file OptDetDigitizer_module.cc.

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

Definition at line 61 of file OptDetDigitizer_module.cc.

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

Definition at line 62 of file OptDetDigitizer_module.cc.

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

Definition at line 73 of file OptDetDigitizer_module.cc.

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

Definition at line 45 of file OptDetDigitizer_module.cc.

art::ServiceHandle<OpDigiProperties> opdet::OptDetDigitizer::fOpDigiProperties
private

Definition at line 72 of file OptDetDigitizer_module.cc.

optdata::ADC_Count_t opdet::OptDetDigitizer::fPedFlucAmp
private

Definition at line 53 of file OptDetDigitizer_module.cc.

float opdet::OptDetDigitizer::fPedFlucRate
private

Definition at line 54 of file OptDetDigitizer_module.cc.

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

Definition at line 51 of file OptDetDigitizer_module.cc.

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

Definition at line 63 of file OptDetDigitizer_module.cc.

float opdet::OptDetDigitizer::fQE
private

Definition at line 49 of file OptDetDigitizer_module.cc.

float opdet::OptDetDigitizer::fSampleFreq
private

Definition at line 46 of file OptDetDigitizer_module.cc.

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

Definition at line 50 of file OptDetDigitizer_module.cc.

bool opdet::OptDetDigitizer::fSimGainSpread
private

Definition at line 59 of file OptDetDigitizer_module.cc.

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

Definition at line 57 of file OptDetDigitizer_module.cc.

float opdet::OptDetDigitizer::fTimeBegin
private

Definition at line 47 of file OptDetDigitizer_module.cc.

float opdet::OptDetDigitizer::fTimeEnd
private

Definition at line 48 of file OptDetDigitizer_module.cc.


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