415 std::unique_ptr< std::vector< raw::OpDetWaveform > >
416 pulseVecPtr(std::make_unique< std::vector< raw::OpDetWaveform > >());
421 if (!fUseLitePhotons)
423 <<
"Sorry, but for now only Lite Photon digitization is implemented!" 444 for(
unsigned int opDet=0; opDet<
nOpDet; opDet++)
447 std::vector< std::vector< double > > pdWaveforms(nChannelsPerOpDet, std::vector< double >(
nSamples, static_cast< double >(
fPedestal)));
448 std::vector<std::vector<FocusList>> fls(nOpDet,std::vector<FocusList>(nChannelsPerOpDet, FocusList(
nSamples,
fPadding)));
456 if(fUseLitePhotons) litePhotonHandle = evt.
getHandle< std::vector< sim::SimPhotonsLite > >(mod);
459 if(!fUseLitePhotons) PhotonHandle = evt.
getHandle< std::vector< sim::SimPhotons > >(mod);
465 for (
auto const& litePhotons : (*litePhotonHandle))
469 if(opDet == (
unsigned)litePhotons.OpChannel)
475 CreatePDWaveform(litePhotons, *odResponse, *geometry, pdWaveforms, fls[opDet]);
476 if((
unsigned)modulecounter<fInputModule.size())
continue;
479 hardwareChannel < nChannelsPerOpDet; ++hardwareChannel) fls[opDet][hardwareChannel].AddRange(0,
SampleSize);
499 for (
unsigned int hardwareChannel = 0;
500 hardwareChannel < nChannelsPerOpDet; ++hardwareChannel)
502 for(
const std::pair<int, int>&
p: fls[opDet][hardwareChannel].
ranges){
505 const std::vector<double>
sub(pdWaveforms[hardwareChannel].
begin()+
p.first,
506 pdWaveforms[hardwareChannel].begin()+
p.second+1);
508 std::vector< short > waveformOfShorts =
512 std::map< size_t, std::vector < short > > mapTickWaveform =
514 SplitWaveform(waveformOfShorts, fls[opDet][hardwareChannel]) :
515 std::map< size_t, std::vector< short > >{ std::make_pair(0,
519 unsigned int opChannel = geometry->
OpChannel(opDet, hardwareChannel);
520 for (
auto const& pairTickWaveform : mapTickWaveform)
523 static_cast< double >(
TickToTime(pairTickWaveform.first+
p.first));
529 pairTickWaveform.second.size());
531 for (
short const&
value : pairTickWaveform.second)
534 adcVec.emplace_back(value); counter++;
538 pulseVecPtr->emplace_back(
std::move(adcVec));
549 for (
auto const& Photons : (*PhotonHandle))
551 if(opDet == (
unsigned)Photons.OpChannel())
554 if((
unsigned)modulecounter<fInputModule.size())
continue;
563 for (
unsigned int hardwareChannel = 0;
564 hardwareChannel < nChannelsPerOpDet; ++hardwareChannel)
566 for(
const std::pair<int, int>&
p: fls[opDet][hardwareChannel].ranges){
569 const std::vector<double>
sub(pdWaveforms[hardwareChannel].
begin()+
p.first,
570 pdWaveforms[hardwareChannel].begin()+
p.second+1);
572 std::vector< short > waveformOfShorts =
575 std::map< size_t, std::vector < short > > mapTickWaveform =
577 SplitWaveform(waveformOfShorts, fls[opDet][hardwareChannel]) :
578 std::map< size_t, std::vector< short > >{ std::make_pair(0,
582 unsigned int opChannel = geometry->
OpChannel(opDet, hardwareChannel);
583 for (
auto const& pairTickWaveform : mapTickWaveform)
586 static_cast< double >(
TickToTime(pairTickWaveform.first+
p.first));
592 pairTickWaveform.second.size());
594 for (
short const&
value : pairTickWaveform.second)
597 adcVec.emplace_back(value); counter++;
601 pulseVecPtr->emplace_back(
std::move(adcVec));
608 if(fUseLitePhotons) litePhotonHandle.
clear();
609 if(!fUseLitePhotons) PhotonHandle.clear();
622 for(
unsigned int j=0; j < pulseVecPtr->size(); j++)
624 unsigned int opDet= pulseVecPtr->at(j).ChannelNumber();
626 for (
unsigned int i = 0; i< pulseVecPtr->at(j).Waveform().size() ; i++)
adc_value[opDet][i] = pulseVecPtr->at(j).Waveform()[i];
void CreatePDWaveform(sim::SimPhotonsLite const &, opdet::OpDetResponseInterface const &, geo::Geometry const &, std::vector< std::vector< double > > &, std::vector< FocusList > &)
EventNumber_t event() const
void AddDarkNoise(std::vector< std::vector< double > > &, std::vector< FocusList > &fls, int opDet)
Handle< PROD > getHandle(SelectorBase const &) const
unsigned int NOpHardwareChannels(int opDet) const
std::vector< double > t_photon
std::vector< int > op_photon
double TickToTime(size_t tick) const
SubRunNumber_t subRun() const
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::vector< short > VectorOfDoublesToVectorOfShorts(std::vector< double > const &) const
std::vector< std::string > fInputModule
void AddLineNoise(std::vector< std::vector< double > > &, const std::vector< FocusList > &fls) const
unsigned int OpChannel(int detNum, int hardwareChannel) const
Convert detector number and hardware channel to unique channel.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::vector< short * > adc_value
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
std::map< size_t, std::vector< short > > SplitWaveform(std::vector< short > const &, const FocusList &)
bool UseLitePhotons() const
std::string sub(const std::string &a, const std::string &b)