16#include <FairRuntimeDb.h>
24#include <FairRunAna.h>
28#include <fairlogger/Logger.h>
38 auto CheckOverlapping(
const T& peak, std::vector<T>& peaks) ->
decltype(peaks.begin());
40 void ReOverlapping(
typename std::vector<T>::iterator v_iter, std::vector<T>& peaks);
42 void RemovePeakAt(
typename std::vector<T>::iterator v_iter, std::vector<T>& peaks);
44 void set_par_with_hit_module_par(Tamex::Params& par,
45 const R3B::Neuland::HitModulePar& module_par,
50 par.saturation_coefficient = module_par.
pmt_saturation.get(side).value;
51 par.energy_gain = module_par.
energy_gain.get(side).value;
52 par.pedestal = module_par.
pedestal.get(side).value;
54 par.min_energy = 1 / par.energy_gain;
69 :
time_(channel_signal.time)
71 const auto& par = channel.
GetPar();
90 LOG(fatal) <<
"channel is not bound to FQTPeak object!";
92 const auto& par = channel->
GetPar();
103 LOG(warn) <<
"the times of both PMT signals are 0!";
105 return (
leading_edge_time_ <= (other.leading_edge_time_ + other.time_over_thresh_)) &&
143 auto is_valid =
false;
150 R3BLOG(warn,
"Can't setup parameter in the root file correctly!.");
155 if (
GetPaddle()->GetPaddleID() > PaddleId_max)
157 LOG(warn) <<
"Paddle id " <<
GetPaddle()->GetPaddleID() <<
" exceeds the id " << PaddleId_max
158 <<
" in the parameter file!";
180 auto peakQdc = peak.GetEnergy();
181 auto peakTime = peak.GetLETime();
202 auto peak_energy = peak.GetEnergy();
203 auto peakTime = peak.GetLETime();
208 signal.tle = peakTime;
216 const auto& par =
GetPar();
217 return ((energy * par.energy_gain) + par.pedestal);
220 template <
typename Peak>
223 if (peaks.size() <= 1)
228 std::sort(peaks.begin(), peaks.end(), std::less{});
229 for (
auto front_peak = peaks.begin(); front_peak != peaks.end(); ++front_peak)
231 auto end_peak = std::remove_if(front_peak + 1,
233 [&front_peak](
auto& peak)
235 if (*front_peak == peak)
237 (*front_peak) += peak;
242 peaks.erase(end_peak, peaks.end());
252 std::sort(peaks.begin(), peaks.end(), std::less{});
254 for (
auto front_peak = peaks.begin(); front_peak != peaks.end(); ++front_peak)
256 auto last_leading_time = front_peak->GetLETime();
257 auto end_peak = std::remove_if(front_peak + 1,
261 if ((peak - last_leading_time) < distance)
263 front_peak->AddEnergy(peak.GetEnergy());
264 last_leading_time = peak.GetLETime();
269 peaks.erase(end_peak, peaks.end());
279 std::sort(peaks.begin(), peaks.end(), std::less{});
281 auto& front_peak = peaks.front();
282 std::for_each(peaks.begin() + 1,
286 if ((peak - front_peak) < time_window)
288 front_peak.AddEnergy(peak.GetEnergy());
291 peaks.erase(peaks.begin() + 1, peaks.end());
312 template <
typename Peak>
316 auto it_end = std::remove_if(peaks.begin(),
318 [
this](
const auto& peak) { return peak.GetHeight() < this->GetPar().pmt_thresh; });
319 peaks.erase(it_end, peaks.end());
324 FQTPeaks.reserve(pmtPeaks.size());
327 std::sort(pmtPeaks.begin(), pmtPeaks.end());
331 for (
auto const& peak : pmtPeaks)
333 FQTPeaks.emplace_back(peak,
this);
341 set_par_with_hit_module_par(
par_, module_par,
GetSide());
374 qdc =
par_.rnd_gen.get().Gaus(qdc,
par_.energy_res_rel * qdc);
383 if (
par_.experimental_data_is_corrected_for_saturation)
385 qdc = qdc / (1 -
par_.saturation_coefficient * qdc);
#define R3BLOG(severity, x)
ChannelCalSignal CalSignal
std::vector< CalSignal > CalSignals
AbstractChannel(R3B::Side side, bool has_cal_output=false)
auto GetSide() const -> R3B::Side
auto GetPaddle() const -> AbstractPaddle *
auto smear_energy(double) const -> double
auto GetPar() const -> const Tamex::Params &
auto smear_time(double) const -> double
static void do_peak_pileup(std::vector< Peak > &peaks)
void construct_cal_signals(CalSignals &cal_signals) const override
auto calculate_ToT(double energy) const -> double
void pre_construct() override
void construct_hits(Hits &hits) override
std::vector< FQTPeak > fqt_peaks_
auto to_unsat_energy(double) const -> double
auto CreateHit(const FQTPeak &peak) const -> Hit
PeakPileUpStrategy pileup_strategy_
void extra_reset() override
static void peak_pileup_in_time_window(std::vector< FQTPeak > &peaks, double time_window)
R3B::Neuland::Cal2HitPar * neuland_hit_par_
void add_signal(Signal) override
void fqt_peak_pileup(std::vector< FQTPeak > &peaks)
auto check_paddle_id_in_hit_par() const -> bool
static void peak_pileup_with_distance(std::vector< FQTPeak > &peaks, double distance)
void apply_threshold(std::vector< Peak > &)
auto CreateCalSignal(const FQTPeak &peak) const -> CalSignal
std::vector< PMTPeak > pmt_peaks_
void construct_FQT_peaks(std::vector< FQTPeak > &FQTPeaks, std::vector< PMTPeak > &pmtPeaks)
Channel(Side, PeakPileUpStrategy strategy, TRandom3 &)
FQTPeak(const PMTPeak &pmtPeak, Channel *channel)
double trailing_edge_time_
auto GetLETime() const -> double
auto operator==(const FQTPeak &other) const -> bool
static auto Energy2ToT(double height, const Params &par) -> double
void operator+=(const FQTPeak &other)
static auto ToT2Energy(double width, const Params &par) -> double
double leading_edge_time_
auto operator+=(const PMTPeak &other) -> PMTPeak &
const size_t TmxPeaksInitialCapacity
double time
Time value of the channel signal.
double intensity
Intensity of the channel signal.
std::reference_wrapper< TRandom3 > rnd_gen
Reference to shared random generator.
LRPair< ValueError< double > > pedestal
LRPair< ValueError< double > > pmt_threshold
LRPair< ValueError< double > > energy_gain
LRPair< ValueError< double > > pmt_saturation