11     , fSampling(fParams.frequency/ 1000.) 
 
   12     , fSampling_Daphne(fParams.frequency_Daphne/ 1000.) 
 
   13     , fXArapucaVUVEff(fParams.XArapucaVUVEff / fParams.larProp->ScintPreScale())
 
   14     , fXArapucaVISEff(fParams.XArapucaVISEff / fParams.larProp->ScintPreScale())
 
   15     , fADCSaturation(fParams.Baseline + fParams.Saturation * fParams.ADC * fParams.MeanAmplitude)
 
   23     if(fXArapucaVUVEff > 1.0001 || fXArapucaVISEff > 1.0001)
 
   24       mf::LogWarning(
"DigiArapucaSBNDAlg")
 
   25         << 
"Quantum efficiency set in fhicl file " 
   26         << fParams.XArapucaVUVEff << 
" or " << fParams.XArapucaVISEff
 
   27         << 
" seems to be too large!\n" 
   28         << 
"Final QE must be equal to or smaller than the scintillation " 
   29         << 
"pre scale applied at simulation time.\n" 
   30         << 
"Please check this number (ScintPreScale): " 
   31         << fParams.larProp->ScintPreScale();
 
   34     cet::search_path sp(
"FW_SEARCH_PATH");
 
   35     sp.find_file(fParams.ArapucaDataFile, fname);
 
   36     TFile* 
file = TFile::Open(fname.c_str(), 
"READ");
 
   41     std::vector<double>* timeTPB_p;
 
   42     file->GetObject(
"timeTPB", timeTPB_p);
 
   43     fTimeTPB = std::make_unique<CLHEP::RandGeneral>
 
   44       (*
fEngine, timeTPB_p->data(), timeTPB_p->size());
 
   46     std::vector<double>* TimeXArapucaVUV_p;
 
   47     file->GetObject(
"TimeXArapucaVUV", TimeXArapucaVUV_p);
 
   48     fTimeXArapucaVUV = std::make_unique<CLHEP::RandGeneral>
 
   49       (*
fEngine, TimeXArapucaVUV_p->data(), TimeXArapucaVUV_p->size());
 
   51     size_t pulseSize = fParams.PulseLength * fSampling;
 
   52     fWaveformSP.resize(pulseSize);
 
   54     size_t pulseSize_Daphne = fParams.PulseLength * fSampling_Daphne;
 
   55     fWaveformSP_Daphne.resize(pulseSize_Daphne);
 
   57     if(fParams.ArapucaSinglePEmodel) {
 
   58       mf::LogDebug(
"DigiArapucaSBNDAlg") << 
" using testbench pe response";
 
   59       TFile* file =  TFile::Open(fname.c_str(), 
"READ");
 
   60       std::vector<double>* SinglePEVec_40ftCable_Daphne;
 
   61       std::vector<double>* SinglePEVec_40ftCable_Apsaia;
 
   62       file->GetObject(
"SinglePEVec_40ftCable_Apsaia", SinglePEVec_40ftCable_Apsaia);
 
   63       file->GetObject(
"SinglePEVec_40ftCable_Daphne", SinglePEVec_40ftCable_Daphne);
 
   64       fWaveformSP = *SinglePEVec_40ftCable_Apsaia;
 
   65       fWaveformSP_Daphne = *SinglePEVec_40ftCable_Daphne;
 
   68       mf::LogDebug(
"DigiArapucaSBNDAlg") << 
" using ideal pe response";
 
   69       Pulse1PE(fWaveformSP,fSampling);
 
   70       Pulse1PE(fWaveformSP_Daphne,fSampling_Daphne);
 
   81     std::vector<short unsigned int>& waveform,
 
   89     waveform = std::vector<short unsigned int> (waves.begin(), waves.end());
 
   96     std::vector<short unsigned int>& waveform,
 
  109     waveform = std::vector<short unsigned int> (waves.begin(), waves.end());
 
  116     std::vector<double>& wave,
 
  121     if(pdtype == 
"xarapuca_vuv") {
 
  122       for(
size_t i = 0; i < simphotons.size(); i++) {
 
  125           if(tphoton < 0.) 
continue; 
 
  129           if(timeBin < wave.size()) {
 
  137     else if(pdtype == 
"xarapuca_vis") {
 
  138       for(
size_t i = 0; i < simphotons.size(); i++) {
 
  141           if(tphoton < 0.) 
continue; 
 
  145           if(timeBin < wave.size()) {
 
  155       throw cet::exception(
"DigiARAPUCASBNDAlg") << 
"Wrong pdtype: " << pdtype << std::endl;
 
  168     std::map<int, int> 
const& photonMap,
 
  170     std::vector<double>& wave,
 
  174     if(pdtype == 
"xarapuca_vuv"){
 
  177     else if(pdtype == 
"xarapuca_vis"){
 
  183       throw cet::exception(
"DigiARAPUCASBNDAlg") << 
"Wrong pdtype: " << pdtype << std::endl;
 
  198     std::unique_ptr<CLHEP::RandGeneral>& timeHisto,
 
  199     std::vector<double>& wave,
 
  200     std::map<int, int> 
const& photonMap,
 
  208     size_t acceptedPhotons;
 
  210     for (
auto const& photonMember : photonMap) {
 
  213       meanPhotons = photonMember.second*effT;
 
  215       for(
size_t i = 0; i < acceptedPhotons; i++) {
 
  216         tphoton = timeHisto->fire();
 
  217         tphoton += photonMember.first - t_min;
 
  218         if(tphoton < 0.) 
continue; 
 
  223           if(timeBin < wave.size()) {
 
  236     std::vector<double>& wave,
 
  237     std::map<int, int> 
const& photonMap,
 
  243     size_t acceptedPhotons;
 
  246     for (
auto const& photonMember : photonMap) {
 
  249       meanPhotons = photonMember.second*effT;
 
  251       for(
size_t i = 0; i < acceptedPhotons; i++) {
 
  253         tphoton += photonMember.first - t_min + 
fTimeTPB->fire();
 
  254         if(tphoton < 0.) 
continue; 
 
  258           if(timeBin < wave.size()) {
 
  272     for(
size_t i = 0; i<fWaveformSP.size(); i++) {
 
  273       double time = 
static_cast<double>(i) / sampling;
 
  280     const size_t time_bin,
 
  281     std::vector<double>& wave,
 
  282     const std::vector<double>& fWaveformSP,
 
  286     size_t max = time_bin + fWaveformSP.size() < wave.size() ? time_bin + fWaveformSP.size() : wave.size();
 
  287     auto min_it = std::next(wave.begin(), time_bin);
 
  288     auto max_it = std::next(wave.begin(), max);
 
  290     double nphotons_aux= nphotons;
 
  294                    fWaveformSP.begin(), min_it,
 
  295                    [nphotons_aux](
double w, 
double ws) -> 
double {
 
  296                      return w + 
ws*nphotons_aux  ; });
 
  301     std::replace_if(wave.begin(), wave.end(),
 
  322                    [
this](
double w) -> 
double {
 
  333     while(darkNoiseTime < wave.size()) {
 
  334       size_t timeBin = std::round(darkNoiseTime);
 
  337       if(timeBin < wave.size()) 
AddSPE(timeBin, wave, WaveformSP, nCT);
 
  347     for(
size_t i = 0; i < simphotons.size(); i++) {
 
  348       if(simphotons[i].Time < t_min) t_min = simphotons[i].Time;
 
  356     for (
auto const& mapMember : photonMap) {
 
  357       if(mapMember.second != 0) 
return (
double)mapMember.first;
 
  371     fBaseConfig.Baseline              = config.
baseline();
 
  375     fBaseConfig.RiseTime              = config.
riseTime();
 
  376     fBaseConfig.FallTime              = config.
fallTime();
 
  380     fBaseConfig.CrossTalk             = config.
crossTalk();
 
  382     fBaseConfig.PeakTime              = config.
peakTime();
 
  394     CLHEP::HepRandomEngine* engine
 
  404     params.engine = engine;
 
  406     return std::make_unique<DigiArapucaSBNDAlg>(params);
 
double FindMinimumTime(sim::SimPhotons const &simphotons)
fhicl::Atom< double > saturation
fhicl::Atom< double > xArapucaVUVEff
std::vector< double > fWaveformSP_Daphne
void AddDarkNoise(std::vector< double > &wave, std::vector< double > &WaveformSP)
fhicl::Atom< double > voltageToADC
fhicl::Atom< double > baseline
void AddLineNoise(std::vector< double > &wave)
const double fXArapucaVISEff
DigiArapucaSBNDAlg::ConfigurationParameters_t fBaseConfig
Part of the configuration learned from configuration files. 
std::map< int, int > DetectedPhotons
Number of photons detected at each given time: time tick -> photons. 
const double fXArapucaVUVEff
std::unique_ptr< CLHEP::RandGeneral > fTimeXArapucaVUV
CLHEP::RandExponential fExponentialGen
fhicl::Atom< double > riseTime
fhicl::Atom< bool > makeAmpFluctuations
fhicl::Atom< double > crossTalk
fhicl::Atom< double > xArapucaVISEff
std::vector< double > fWaveformSP
void ConstructWaveformLite(int ch, sim::SimPhotonsLite const &litesimphotons, std::vector< short unsigned int > &waveform, std::string pdtype, bool is_daphne, double start_time, unsigned n_samples)
fEngine(art::ServiceHandle< rndm::NuRandomService >() ->createEngine(*this, pset,"Seed"))
void AddSPE(size_t time_bin, std::vector< double > &wave, const std::vector< double > &fWaveformSP, int nphotons)
std::unique_ptr< CLHEP::RandGeneral > fTimeTPB
const double fADCSaturation
ElecClock const & OpticalClock() const noexcept
Borrow a const Optical clock with time set to Trigger time [us]. 
detinfo::LArProperties const * larProp
LarProperties service provider. 
const double fSampling_Daphne
fhicl::Atom< double > ampFluctuation
std::unique_ptr< DigiArapucaSBNDAlg > operator()(detinfo::LArProperties const &larProp, detinfo::DetectorClocksData const &clockData, CLHEP::HepRandomEngine *engine) const 
fhicl::Atom< bool > ArapucasinglePEmodel
void CreateSaturation(std::vector< double > &wave)
DigiArapucaSBNDAlgMaker(Config const &config)
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Collection of photons which recorded on one channel. 
Compact representation of photons on a channel. 
then echo fcl sbnd_project sbnd_project sbnd_project sbnd_project production production start_time
void CreatePDWaveform(sim::SimPhotons const &SimPhotons, double t_min, std::vector< double > &wave, std::string pdtype, bool is_daphne)
fhicl::Atom< double > pulseLength
CLHEP::RandPoissonQ fPoissonQGen
void CreatePDWaveformLite(std::map< int, int > const &photonMap, double t_min, std::vector< double > &wave, std::string pdtype, bool is_daphne)
Contains all timing reference information for the detector. 
DigiArapucaSBNDAlg(ConfigurationParameters_t const &config)
CLHEP::RandGaussQ fGaussQGen
fhicl::Atom< double > meanAmplitude
void Pulse1PE(std::vector< double > &wave, const double sampling)
fhicl::Atom< double > darkNoiseRate
constexpr double Frequency() const 
Frequency in MHz. 
fhicl::Atom< double > peakTime
fhicl::Atom< double > fallTime
const ConfigurationParameters_t fParams
fhicl::Atom< double > baselineRMS
double frequency_Daphne
Optical-clock frequency for daphne readouts. 
fhicl::Atom< double > DaphneFrequency
void ConstructWaveform(int ch, sim::SimPhotons const &simphotons, std::vector< short unsigned int > &waveform, std::string pdtype, bool is_daphne, double start_time, unsigned n_samples)
void SinglePDWaveformCreatorLite(double effT, std::unique_ptr< CLHEP::RandGeneral > &timeHisto, std::vector< double > &wave, std::map< int, int > const &photonMap, double const &t_min, bool is_daphne)
fhicl::Atom< std::string > arapucaDataFile
double FindMinimumTimeLite(std::map< int, int > const &photonMap)
fhicl::Atom< double > decayTXArapucaVIS