24 #include "CLHEP/Random/RandFlat.h" 25 #include "CLHEP/Random/RandGaussQ.h" 26 #include "CLHEP/Random/RandPoisson.h" 68 void AddTimedWaveform (
int time, std::vector<double>& OldPulse, std::vector<double>& NewPulse);
139 produces<std::vector< raw::OpDetPulse> >();
166 CLHEP::HepRandomEngine &engine = rng->
getEngine();
196 if( (binTime + NewPulse.size() ) > OldPulse.size())
197 OldPulse.resize(binTime + NewPulse.size());
200 for(
size_t i = 0; i!=NewPulse.size(); ++i)
202 OldPulse.at(binTime+i) += NewPulse.at(i);
214 std::unique_ptr<std::vector< raw::OpDetPulse > > StoragePtr (
new std::vector<raw::OpDetPulse>);
226 double TimeEnd_ns =
fTimeEnd * 1000;
229 int nSamples = ( TimeEnd_ns-TimeBegin_ns)*SampleFreq_ns;
235 std::vector<std::vector<double> > PulsesFromDetPhotons(NOpChannels,std::vector<double>(nSamples,0.0));
253 if(odresponse->
detected(Ch, Phot, readoutCh))
257 if((Phot.Time > TimeBegin_ns) && (Phot.Time < TimeEnd_ns))
259 int binTime = int((Phot.Time - TimeBegin_ns) * SampleFreq_ns);
275 for (
auto const& photon : (*photonHandle) )
277 int Ch=photon.OpChannel;
280 std::map<int, int> PhotonsMap = photon.DetectedPhotons;
283 for(
auto it = PhotonsMap.begin(); it!= PhotonsMap.end(); it++)
285 for(
int i = 0; i < it->second; i++)
293 if((it->first > TimeBegin_ns) && (it->first < TimeEnd_ns))
295 int binTime = int((it->first - TimeBegin_ns) * SampleFreq_ns);
312 std::vector<raw::OpDetPulse*> ThePulses(NOpChannels);
313 for(
int iCh=0; iCh!=NOpChannels; ++iCh)
315 PulsesFromDetPhotons[iCh].resize((TimeEnd_ns - TimeBegin_ns) * SampleFreq_ns);
320 unsigned int NumberOfPulses =
fPoissonRandom->fire(MeanDarkPulses);
322 for(
size_t i=0; i!=NumberOfPulses; ++i)
331 for(
size_t i=0; i!=PulsesFromDetPhotons[iCh].size(); ++i)
338 std::vector<short> shortvec;
340 for(
size_t i=0; i!=PulsesFromDetPhotons[iCh].size(); ++i)
343 int ThisSample = PulsesFromDetPhotons[iCh].at(i);
346 if(
fFlatRandom->fire(1.0) > (ThisSample - int(ThisSample)))
347 shortvec.push_back(
int(ThisSample));
349 shortvec.push_back(
int(ThisSample)+1);
353 if(
fFlatRandom->fire(1.0) > (int(ThisSample)-ThisSample))
354 shortvec.push_back(
int(ThisSample));
356 shortvec.push_back(
int(ThisSample)-1);
366 evt.
put(std::move(StoragePtr));
Store parameters for running LArG4.
CLHEP::RandFlat * fFlatRandom
void AddTimedWaveform(int time, std::vector< double > &OldPulse, std::vector< double > &NewPulse)
virtual bool detected(int OpChannel, const sim::OnePhoton &Phot, int &newOpChannel) const
OpMCDigi(const fhicl::ParameterSet &)
ProductID put(std::unique_ptr< PROD > &&product)
base_engine_t & getEngine() const
contains objects relating to OpDet hits
base_engine_t & createEngine(seed_t seed)
#define DEFINE_ART_MODULE(klass)
virtual int NOpChannels() const
T get(std::string const &key) const
void produce(art::Event &)
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
CLHEP::RandPoisson * fPoissonRandom
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
std::vector< double > fSinglePEWaveform
list_type::const_iterator const_iterator
Tools and modules for checking out the basics of the Monte Carlo.
static sim::SimPhotonsCollection GetSimPhotonsCollection(const art::Event &evt, std::string moduleLabel)
bool UseLitePhotons() const