21 #include <sys/types.h> 30 #include "art_root_io/TFileService.h" 31 #include "art_root_io/TFileDirectory.h" 36 #include "nurandom/RandomUtils/NuRandomService.h" 56 #include "CLHEP/Random/RandFlat.h" 57 #include "CLHEP/Random/RandGaussQ.h" 131 produces< std::vector<raw::RawDigit> >();
133 produces< std::vector<raw::RawDigit> >(
"preSpill");
134 produces< std::vector<raw::RawDigit> >(
"postSpill");
138 TString compression(pset.get<
std::string >(
"CompressionType"));
139 if(compression.Contains(
"Huffman",TString::kIgnoreCase)) fCompression =
raw::kHuffman;
140 if(compression.Contains(
"ZeroSuppression",TString::kIgnoreCase)) fCompression =
raw::kZeroSuppression;
181 fNoiseDist = tfs->make<TH1D>(
"Noise",
";Noise (ADC);", 1000, -10., 10.);
187 MF_LOG_DEBUG(
"SimWireDUNE10kt") <<
"Warning: FFTSize not a power of 2. " 188 <<
"May cause issues in (de)convolution.\n";
191 mf::LogError(
"SimWireDUNE10kt") <<
"Cannot have number of readout samples " 192 <<
"greater than FFTSize!";
214 for(
int i = 0; i <
fNTicks; ++i)
222 for(
int i = 0; i <
fNTicks; ++i)
232 for(
int i = 0; i <
fNTicks; ++i)
251 unsigned int signalSize =
fNTicks;
254 std::vector<short> adcvec(signalSize, 0);
255 std::vector<short> adcvecPreSpill(signalSize, 0);
256 std::vector<short> adcvecPostSpill(signalSize, 0);
257 std::vector<const sim::SimChannel*> chanHandle;
268 for(
size_t c = 0;
c < chanHandle.size(); ++
c){
269 channels[chanHandle[
c]->Channel()] = chanHandle[
c];
277 std::unique_ptr< std::vector<raw::RawDigit> > digcol(
new std::vector<raw::RawDigit>);
278 std::unique_ptr< std::vector<raw::RawDigit> > digcolPreSpill(prepost?
new std::vector<raw::RawDigit>:
nullptr);
279 std::unique_ptr< std::vector<raw::RawDigit> > digcolPostSpill(prepost?
new std::vector<raw::RawDigit>:
nullptr);
281 unsigned int chan = 0;
285 std::vector<double> fChargeWorkPreSpill, fChargeWorkPostSpill;
296 digcolPreSpill->reserve(geo->
Nchannels());
297 digcolPostSpill->reserve(geo->
Nchannels());
301 for(chan = 0; chan < geo->
Nchannels(); chan++) {
309 fChargeWorkPreSpill.clear();
310 fChargeWorkPostSpill.clear();
311 fChargeWorkPreSpill.resize(
fNTicks,0);
312 fChargeWorkPostSpill.resize(
fNTicks,0);
335 fChargeWorkPreSpill.resize(
fNTicks,0);
336 fChargeWorkPostSpill.resize(
fNTicks,0);
337 sss->
Convolute(clockData, chan, fChargeWorkPreSpill);
338 sss->
Convolute(clockData, chan, fChargeWorkPostSpill);
366 double *fChargeWork_a=0;
367 double *fChargeWorkPreSpill_a=0;
368 double *fChargeWorkPostSpill_a=0;
370 short *adcvecPreSpill_a=0;
371 short *adcvecPostSpill_a=0;
375 float *noise_a_Upre=0;
376 float *noise_a_Vpre=0;
377 float *noise_a_Zpre=0;
378 float *noise_a_Upost=0;
379 float *noise_a_Vpost=0;
380 float *noise_a_Zpost=0;
384 adcvec_a = adcvec.data();
386 fChargeWorkPreSpill_a = fChargeWorkPreSpill.data();
387 fChargeWorkPostSpill_a = fChargeWorkPostSpill.data();
388 adcvecPreSpill_a = adcvecPreSpill.data();
389 adcvecPostSpill_a = adcvecPostSpill.data();
412 mf::LogError(
"SimWireDUNE10kt") <<
"ERROR: CHANNEL NUMBER " << chan <<
" OUTSIDE OF PLANE";
418 for(
unsigned int i = 0; i < signalSize; ++i){
419 if(view==
geo::kU) { tnoise = noise_a_U[i]; }
420 else if (view==
geo::kV) { tnoise = noise_a_V[i]; }
421 else { tnoise = noise_a_Z[i]; }
422 tmpfv = tnoise + fChargeWork_a[i];
427 if ( tmpfv < 0 - ped_mean)
429 adcvec_a[i] = (tmpfv >=0) ? (
short) (tmpfv+0.5) : (short) (tmpfv-0.5);
432 for(
unsigned int i = 0; i < signalSize; ++i){
433 if(view==
geo::kU) { tnoisepre = noise_a_Upre[i]; tnoisepost = noise_a_Upost[i]; }
434 else if(view==
geo::kV) { tnoisepre = noise_a_Vpre[i]; tnoisepost = noise_a_Vpost[i]; }
435 else { tnoisepre = noise_a_Zpre[i]; tnoisepost = noise_a_Zpost[i]; }
437 tmpfv = tnoisepre + fChargeWorkPreSpill_a[i];
443 if ( tmpfv < 0- ped_mean ){
446 adcvecPreSpill_a[i] = (tmpfv >=0) ? (
short) (tmpfv+0.5) : (short) (tmpfv-0.5);
448 tmpfv = tnoisepost + fChargeWorkPostSpill_a[i];
454 if ( tmpfv < 0 - ped_mean){
457 adcvecPostSpill_a[i] = (tmpfv >=0) ? (
short) (tmpfv+0.5) : (short) (tmpfv-0.5);
463 std::map< double, int > fShapingTimeOrder;
464 fShapingTimeOrder = { {0.5, 0}, {1.0, 1}, {2.0, 2}, {3.0, 3} };
467 if ( fShapingTimeOrder.find( fShapingTime ) != fShapingTimeOrder.end() ){
469 fNoiseFactVec.resize(2);
470 for (
auto& item : tempNoiseVec) {
471 fNoiseFactVec[i] = item.at( fShapingTimeOrder.find( fShapingTime )->second );
472 fNoiseFactVec[i] *= fASICGain/4.7;
479 <<
"Shaping Time received from signalservices_microboone.fcl is not one of allowed values" 481 <<
"Allowed values: 0.5, 1.0, 2.0, 3.0 usec" 487 CLHEP::RandGaussQ rGauss_Ind(
fEngine, 0.0, fNoiseFactVec[0]);
488 CLHEP::RandGaussQ rGauss_Col(
fEngine, 0.0, fNoiseFactVec[1]);
491 for(
unsigned int i = 0; i < signalSize; ++i){
492 if(view==
geo::kU) { tnoise = rGauss_Ind.fire(); }
493 else if (view==
geo::kV) { tnoise = rGauss_Ind.fire(); }
494 else { tnoise = rGauss_Col.fire(); }
495 tmpfv = tnoise + fChargeWork_a[i];
500 if ( tmpfv < 0 - ped_mean)
502 adcvec_a[i] = (tmpfv >=0) ? (
short) (tmpfv+0.5) : (short) (tmpfv-0.5);
505 for(
unsigned int i = 0; i < signalSize; ++i){
506 if(view==
geo::kU) { tnoisepre = rGauss_Ind.fire(); tnoisepost = rGauss_Ind.fire(); }
507 else if(view==
geo::kV) { tnoisepre = rGauss_Ind.fire(); tnoisepost = rGauss_Ind.fire(); }
508 else { tnoisepre = rGauss_Col.fire(); tnoisepost = rGauss_Col.fire(); }
510 tmpfv = tnoisepre + fChargeWorkPreSpill_a[i];
516 if ( tmpfv < 0 - ped_mean){
519 adcvecPreSpill_a[i] = (tmpfv >=0) ? (
short) (tmpfv+0.5) : (short) (tmpfv-0.5);
521 tmpfv = tnoisepost + fChargeWorkPostSpill_a[i];
527 if ( tmpfv < 0 - ped_mean){
530 adcvecPostSpill_a[i] = (tmpfv >=0) ? (
short) (tmpfv+0.5) : (short) (tmpfv-0.5);
535 for(
unsigned int i = 0; i < signalSize; ++i){
536 tmpfv = fChargeWork_a[i];
541 if ( tmpfv < 0 - ped_mean)
543 adcvec_a[i] = (tmpfv >=0) ? (
short) (tmpfv+0.5) : (short) (tmpfv-0.5);
546 for(
unsigned int i = 0; i < signalSize; ++i){
547 tmpfv = fChargeWorkPreSpill_a[i];
552 if ( tmpfv < 0 - ped_mean) {
553 tmpfv = 0- ped_mean; }
554 adcvecPreSpill_a[i] = (tmpfv >=0) ? (
short) (tmpfv+0.5) : (short) (tmpfv-0.5);
555 tmpfv = fChargeWorkPostSpill_a[i];
560 if ( tmpfv < 0 - ped_mean) {
561 tmpfv = 0- ped_mean; }
562 adcvecPostSpill_a[i] = (tmpfv >=0) ? (
short) (tmpfv+0.5) : (short) (tmpfv-0.5);
580 adcvec.resize(signalSize);
583 digcol->push_back(rd);
599 adcvecPreSpill.resize(signalSize);
600 adcvecPostSpill.resize(signalSize);
603 digcolPreSpill->push_back(rdPreSpill);
605 digcolPostSpill->push_back(rdPostSpill);
633 std::vector<TComplex> noiseFrequency(
fNTicks/2+1, 0.);
636 double lofilter = 0.;
638 double rnd[2] = {0.};
642 for(
int i=0; i<
fNTicks/2+1; ++i){
646 lofilter = 1.0/(1.0+exp(-(i-
fLowCutoff/binWidth)/0.5));
648 flat.fireArray(2,rnd,0,1);
649 pval *= lofilter*(0.9+0.2*rnd[0]);
651 phase = rnd[1]*2.*TMath::Pi();
653 TComplex tc(pval*cos(phase),pval*sin(phase));
654 noiseFrequency[i] += tc;
661 fFFT->
DoInvFFT(noiseFrequency, noise);
663 noiseFrequency.clear();
668 for(
unsigned int i = 0; i < noise.size(); ++i) noise[i] *= 1.*
fNTicks;
unsigned int fNoiseArrayPoints
number of points in randomly generated noise array
float fNoiseWidthV
exponential noise width (kHz) for V plane
base_engine_t & createEngine(seed_t seed)
std::string fDriftEModuleLabel
module making the ionization electrons
double GetShapingTime(Channel channel) const override
enum raw::_compress Compress_t
float fLowCutoffU
low frequency filter cutoff (kHz) for U plane
Collection of charge vs time digitized from a single readout channel.
Energy deposited on a readout channel by simulated tracks.
float fNoiseFactV
noise scale factor for V plane
unsigned int fNoiseModel
noise model
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
std::vector< DoubleVec > GetNoiseFactVec() const override
EDProducer(fhicl::ParameterSet const &pset)
float fLowCutoff
low frequency filter cutoff (kHz)
TH1D * fNoiseDist
distribution of noise counts
Detector simulation of raw signals on wires.
float fInductionPed
ADC value of baseline for induction plane.
Planes which measure Z direction.
const float adcsaturation
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::vector< std::vector< float > > fNoiseV
noise on each channel for each time for V plane
unsigned int fNoiseOn
noise turned on or off for debugging; default is on
void reconfigure(fhicl::ParameterSet const &p)
Service to provide microboone-specific signal shaping for simulation (convolution) and reconstruction...
art framework interface to geometry description
void DoInvFFT(std::vector< TComplex > &input, std::vector< T > &output)
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
std::vector< std::vector< float > > fNoiseZ
noise on each channel for each time for Z (collection) plane
float fCollectionPed
ADC value of baseline for collection plane.
Zero Suppression algorithm.
unsigned int fNTimeSamples
number of ADC readout samples in all readout frames (per event)
int fNearestNeighbor
Maximum distance between hits above threshold before they are separated into different blocks...
#define DEFINE_ART_MODULE(klass)
double fSampleRate
sampling rate in ns
float fNoiseFactZ
noise scale factor for Z (collection) plane
float fNoiseWidth
exponential noise width (kHz)
Signal from induction planes.
double Charge(TDC_t tdc) const
Returns the total number of ionization electrons on this channel in the specified TDC...
enum geo::_plane_sigtype SigType_t
T get(std::string const &key) const
SimWireDUNE10kt(fhicl::ParameterSet const &pset)
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
float fLowCutoffZ
low frequency filter cutoff (kHz) for Z (collection) plane
auto array(Array const &a)
Returns a manipulator which will print the specified array.
float fNoiseWidthU
exponential noise width (kHz) for U plane
void Convolute(detinfo::DetectorClocksData const &clockData, Channel channel, std::vector< T > &func) const
std::vector< double > fChargeWork
void GenNoise(std::vector< float > &array)
float fNoiseWidthZ
exponential noise width (kHz) for Z (collection) plane
float fNoiseFact
noise scale factor
std::vector< std::vector< float > > fNoiseU
noise on each channel for each time for U plane
void Compress(std::vector< short > &adc, raw::Compress_t compress)
Compresses a raw data buffer.
CLHEP::HepRandomEngine & fEngine
raw::Compress_t fCompression
compression type to use
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
Tools and modules for checking out the basics of the Monte Carlo.
double GetASICGain(Channel channel) const override
unsigned int fNSamplesReadout
number of ADC readout samples in 1 readout frame
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
LArSoft geometry interface.
unsigned int fZeroThreshold
Zero suppression threshold.
int fNTicks
number of ticks of the clock
float fNoiseFactU
noise scale factor for U plane
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
void produce(art::Event &evt)
Signal from collection planes.
std::vector< double > DoubleVec
float fLowCutoffV
low frequency filter cutoff (kHz) for V plane