1#ifndef __JDETECTOR__JK40DEFAULTSIMULATORINTERFACE__
2#define __JDETECTOR__JK40DEFAULTSIMULATORINTERFACE__
71 const double P = this->rbegin()->P * rv;
74 size_t count = this->size();
76 for (
size_t i, step; count != 0; ) {
81 if ((*
this)[i].P < P) {
89 return (*
this)[first].v;
99 void put(
const T& v,
const double P)
102 this->push_back({v, P});
104 this->push_back({v, this->rbegin()->P + P});
176 const size_t N =
module.size();
181 for (
size_t pmt = 0; pmt != N; ++pmt) {
185 if (rateL0_Hz > 0.0) {
187 const bool asap = (output[pmt].size() != 0);
189 const double t_ns = 1.0e9 / rateL0_Hz;
204 double totalRateL1_Hz = 0.0;
210 for (
size_t i = 0; i != N; ++i) {
214 if (totalRateL1_Hz > 0.0) {
220 const double t_ns = 1.0e9 / totalRateL1_Hz;
228 for (
size_t pmt1 = 0; pmt1 != N; ++pmt1) {
229 for (
size_t pmt2 = 0; pmt2 != pmt1; ++pmt2) {
231 const double ct = getDot(module[pmt1].getDirection(), module[pmt2].getDirection());
234 probablityL1.
put({pmt1, pmt2}, p);
238 for ( ; t1 < period.
getUpperLimit(); t1 += gRandom->Exp(t_ns)) {
253 for (
double R = totalRateL1_Hz * gRandom->Rndm(); M != N && (R -= rateL1_Hz[M]) > 0.0; ++M) {}
259 for ( ; M != 0; --M) {
265 for (
size_t i = 0; i != N; ++i) {
267 if (buffer.count(i) == 0) {
271 const double ct = getDot(module[i].getDirection(), module[*pmt].getDirection());
276 P += probability1D[i];
280 probability1D[i] = 0.0;
288 for (P *= gRandom->Rndm(); pmt != N && (P -= probability1D[pmt]) > 0.0; ++pmt) {}
328 if (!input.
first.empty() && !input.
second.empty()) {
334 const double ts = 0.8 * fabs(input.
first.
getZ() - input.
second.
getZ()) * getInverseSpeedOfLight() * getIndexOfRefraction();
347 for (
size_t i = 0; i != input_lower.size(); ++i) { probability_lower.
put(i, this->
getProbability(+1.0 * input_lower[i].getDZ())); }
348 for (
size_t i = 0; i != input_upper.size(); ++i) { probability_upper.
put(i, this->
getProbability(-1.0 * input_upper[i].getDZ())); }
350 const double t_ns = 1.0e9 / rate_Hz;
354 const bool L01 = gRandom->Uniform(0.0, rate_Hz) <
getL01Rate();
356 JModuleData& output_L1 = (L01 ? output_upper : output_lower);
357 JModuleData& output_L0 = (L01 ? output_lower : output_upper);
359 cdf_type<size_t>& probability_L1 = (L01 ? probability_upper : probability_lower);
360 cdf_type<size_t>& probability_L0 = (L01 ? probability_lower : probability_upper);
362 output_L1[probability_L1(gRandom->Rndm())].insert(
JPMTSignal(gRandom->Gaus(t1,
getSigma()), 1));
363 output_L1[probability_L1(gRandom->Rndm())].insert(
JPMTSignal(gRandom->Gaus(t1,
getSigma()), 1));
365 output_L0[probability_L0(gRandom->Rndm())].insert(
JPMTSignal(gRandom->Gaus(t1 + ts,
getSigma()), 1));
402 static double sigma = 0.5;
Compiler version dependent expressions, macros, etc.
Default K40 simulator interface.
static double & get_sigma()
Get intrinsic time smearing of K40 coincidences.
virtual void generateHits(const JModule &module, const JTimeRange &period, JModuleData &output) const override
Generate hits.
static double getSigma()
Get intrinsic time smearing of K40 coincidences.
virtual void generateHits(const module_pair &input, const JTimeRange &period, const module_data &output) const override
Generate mixed-L1/L0 hits.
static void setSigma(const double sigma)
Set intrinsic time smearing of K40 coincidences.
virtual double getSinglesRate(const JPMTIdentifier &pmt) const =0
Get singles rate as a function of PMT.
virtual double getMultiplesRate(const JModuleIdentifier &module, const int M) const =0
Get multiples rate as a function of optical module.
JK40DefaultSimulatorInterface()
Default constructor.
virtual double getL01Rate() const =0
Get mixed L0 (lower module) and L1 (upper module) rate [Hz].
virtual double getL10Rate() const =0
Get mixed L1 (lower module) and L0 (upper module) rate [Hz].
virtual double getProbability(const double ct) const =0
Get probability of coincidence.
Interface for simulation of K40 background.
int getFloor() const
Get floor number.
Data structure for a composite optical module.
double getZ() const
Get z position.
Exception for numerical precision error.
Auxiliary class for object identification.
int getID() const
Get identifier.
file Auxiliary data structures and methods for detector calibration.
bool neighbours(const JLocation &first, const JLocation &second)
Check if two locations are neighbours.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for selecting values according associated probabilities.
const T & operator()(const double rv) const
Get random value according associated probabilities.
void put(const T &v, const double P)
Put value with given probability.
Auxiliary data structure for value with associated probability.
Auxiliary data structure for argument parsing of module data.
Auxiliary data structure for argument parsing of module pair.
Data structure for PMT analogue signal.