19 #include "art/Framework/Core/EDProducer.h"
20 #include "art/Framework/Core/ModuleMacros.h"
21 #include "art/Framework/Principal/Event.h"
22 #include "fhiclcpp/ParameterSet.h"
23 #include "art/Framework/Services/Registry/ServiceHandle.h"
26 #include "nurandom/RandomUtils/NuRandomService.h"
29 #include "CLHEP/Random/RandFlat.h"
30 #include "CLHEP/Random/RandPoisson.h"
42 void produce(art::Event&)
override;
64 void AddDarkNoise (std::vector<double> &RawWF,
double gain);
66 std::vector<double>& OldPulse,
67 std::vector<double>& NewPulse,
73 art::ServiceHandle<geo::Geometry const>
fGeom;
80 DEFINE_ART_MODULE(OptDetDigitizer)
88 ,
fEngine(art::ServiceHandle<rndm::NuRandomService>()->createEngine(*
this, pset,
"Seed"))
93 produces<std::vector< optdata::ChannelDataGroup> >();
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();
109 fSinglePEWaveform = fOpDigiProperties->SinglePEWaveform();
115 std::vector<double> &OldPulse,
116 std::vector<double> &NewPulse,
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;
132 unsigned int NumberOfPulses =
fPoissonRandom.fire(MeanDarkPulses);
133 for(
size_t i=0; i!=NumberOfPulses; ++i)
157 chData.reserve(rawWF.size());
161 double thisSample = rawWF[time];
166 if(CLHEP::RandFlat::shoot(1.0) < (thisSample - int(thisSample)))
172 chData.push_back(thisCount);
177 unsigned int nFluc = CLHEP::RandPoisson::shoot(
fPedFlucRate * timeSpan);
178 for(
size_t i=0; i<nFluc; ++i)
182 if( CLHEP::RandFlat::shoot(0.,1.) > 0.5)
189 chData[pulseTime] = amp;
205 std::unique_ptr< std::vector<optdata::ChannelDataGroup > > StoragePtr (
new std::vector<optdata::ChannelDataGroup>);
211 double timeBegin_ns = fTimeBegin * 1000;
212 double timeEnd_ns =
fTimeEnd * 1000;
226 rawWFGroup_HighGain.reserve(
fGeom->NOpChannels());
227 rawWFGroup_LowGain.reserve(
fGeom->NOpChannels());
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));
259 if( Phot.Time > timeBegin_ns && Phot.Time < timeEnd_ns )
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);
296 rawWFGroup_HighGain.push_back(chData_HighGain);
297 rawWFGroup_LowGain.push_back(chData_LowGain);
300 StoragePtr->push_back(rawWFGroup_HighGain);
301 StoragePtr->push_back(rawWFGroup_LowGain);
303 evt.put(std::move(StoragePtr));
art::ServiceHandle< geo::Geometry const > fGeom
optdata::ChannelData ApplyDigitization(std::vector< double > const RawWF, optdata::Channel_t const ch) const
optdata::ADC_Count_t fSaturationScale
int OpChannel() const
Returns the optical channel number this object is associated to.
CLHEP::RandFlat fFlatRandom
All information of a photon entering the sensitive optical detector volume.
OptDetDigitizer(const fhicl::ParameterSet &)
void produce(art::Event &) override
Simulation objects for optical detectors.
optdata::ADC_Count_t fPedFlucAmp
fEngine(art::ServiceHandle< rndm::NuRandomService >() ->createEngine(*this, pset,"Seed"))
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
Collection of photons which recorded on one channel.
list_type::const_iterator const_iterator
std::vector< double > fSinglePEWaveform
std::vector< optdata::ADC_Count_t > fPedMeanArray
CLHEP::HepRandomEngine & fEngine
Collection of sim::SimPhotons, indexed by channel number.
void AddDarkNoise(std::vector< double > &RawWF, double gain)
static sim::SimPhotonsCollection GetSimPhotonsCollection(const art::Event &evt, std::string moduleLabel)
art framework interface to geometry description