32 #include "CLHEP/Random/RandFlat.h" 33 #include "CLHEP/Random/RandPoisson.h" 66 void AddTimedWaveform(
int time, std::vector<double>& OldPulse, std::vector<double>& NewPulse);
88 produces<std::vector<raw::OpDetPulse>>();
100 std::vector<double>& OldPulse,
101 std::vector<double>& NewPulse)
104 if ((binTime + NewPulse.size()) > OldPulse.size()) {
105 OldPulse.resize(binTime + NewPulse.size());
109 for (
size_t i = 0; i != NewPulse.size(); ++i) {
110 OldPulse.at(binTime + i) += NewPulse.at(i);
118 auto StoragePtr = std::make_unique<std::vector<raw::OpDetPulse>>();
122 } -> UseLitePhotons();
127 double const TimeBegin_ns =
fTimeBegin * 1000;
128 double const TimeEnd_ns =
fTimeEnd * 1000;
131 int const nSamples = (TimeEnd_ns - TimeBegin_ns) * SampleFreq_ns;
135 std::vector<std::vector<double>> PulsesFromDetPhotons(NOpChannels,
136 std::vector<double>(nSamples, 0.0));
138 if (!fUseLitePhotons) {
143 for (
auto const& pr : ThePhotCollection) {
152 if (!odresponse->
detected(Ch, Phot, readoutCh)) {
continue; }
158 if ((Phot.Time > TimeBegin_ns) && (Phot.Time < TimeEnd_ns)) {
159 auto const binTime =
static_cast<int>((Phot.Time - TimeBegin_ns) * SampleFreq_ns);
166 auto const photons = *evt.
getValidHandle<std::vector<sim::SimPhotonsLite>>(
"largeant");
168 for (
auto const& photon : photons) {
169 int const Ch = photon.OpChannel;
172 std::map<int, int> PhotonsMap = photon.DetectedPhotons;
175 for (
auto const& pr : photon.DetectedPhotons) {
176 for (
int i = 0; i < pr.second; i++) {
182 if ((pr.first > TimeBegin_ns) && (pr.first < TimeEnd_ns)) {
183 auto const binTime =
static_cast<int>((pr.first - TimeBegin_ns) * SampleFreq_ns);
195 std::vector<raw::OpDetPulse*> ThePulses(NOpChannels);
196 for (
int iCh = 0; iCh != NOpChannels; ++iCh) {
197 PulsesFromDetPhotons[iCh].resize((TimeEnd_ns - TimeBegin_ns) * SampleFreq_ns);
201 unsigned const int NumberOfPulses =
fPoissonRandom.fire(MeanDarkPulses);
203 for (
size_t i = 0; i != NumberOfPulses; ++i) {
205 int const binTime =
static_cast<int>(PulseTime *
fSampleFreq);
211 for (
size_t i = 0; i != PulsesFromDetPhotons[iCh].size(); ++i) {
218 std::vector<short> shortvec;
220 for (
size_t i = 0; i != PulsesFromDetPhotons[iCh].size(); ++i) {
222 int ThisSample = PulsesFromDetPhotons[iCh].at(i);
223 if (ThisSample > 0) {
224 if (
fFlatRandom.fire(1.0) > (ThisSample - int(ThisSample)))
225 shortvec.push_back(
int(ThisSample));
227 shortvec.push_back(
int(ThisSample) + 1);
230 if (
fFlatRandom.fire(1.0) > (int(ThisSample) - ThisSample))
231 shortvec.push_back(
int(ThisSample));
233 shortvec.push_back(
int(ThisSample) - 1);
237 StoragePtr->emplace_back(iCh, shortvec, 0,
fTimeBegin);
241 evt.
put(std::move(StoragePtr));
base_engine_t & createEngine(seed_t seed)
Store parameters for running LArG4.
int OpChannel() const
Returns the optical channel number this object is associated to.
void AddTimedWaveform(int time, std::vector< double > &OldPulse, std::vector< double > &NewPulse)
EDProducer(fhicl::ParameterSet const &pset)
All information of a photon entering the sensitive optical detector volume.
void produce(art::Event &) override
virtual bool detected(int OpChannel, const sim::OnePhoton &Phot, int &newOpChannel) const
CLHEP::HepRandomEngine & fEngine
OpMCDigi(const fhicl::ParameterSet &)
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Simulation objects for optical detectors.
#define DEFINE_ART_MODULE(klass)
virtual int NOpChannels() const
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
virtual bool detectedLite(int OpChannel, int &newOpChannel) const
Collection of photons which recorded on one channel.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
std::vector< double > fSinglePEWaveform
CLHEP::RandFlat fFlatRandom
Collection of sim::SimPhotons, indexed by channel number.
static sim::SimPhotonsCollection GetSimPhotonsCollection(const art::Event &evt, std::string moduleLabel)
CLHEP::RandPoisson fPoissonRandom