Jpp 20.0.0-72-g597b30bc9
the software that should make you happy
Loading...
Searching...
No Matches
JDETECTOR::JK40DefaultSimulatorInterface Class Referenceabstract

Default K40 simulator interface. More...

#include <JK40DefaultSimulatorInterface.hh>

Inheritance diagram for JDETECTOR::JK40DefaultSimulatorInterface:
JDETECTOR::JK40Simulator JDETECTOR::JK40DefaultSimulator JTRIGGER::JK40RunByRunSimulator

Classes

struct  cdf_type
 Auxiliary data structure for selecting values according associated probabilities. More...
 
struct  probability_type
 Auxiliary data structure for value with associated probability. More...
 

Public Member Functions

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.
 
virtual double getProbability (const double ct) const =0
 Get probability of coincidence.
 
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 void generateHits (const JModule &module, const JTimeRange &period, JModuleData &output) const override
 Generate hits.
 
virtual void generateHits (const module_pair &input, const JTimeRange &period, const module_data &output) const override
 Generate mixed-L1/L0 hits.
 

Static Public Member Functions

static double getSigma ()
 Get intrinsic time smearing of K40 coincidences.
 
static void setSigma (const double sigma)
 Set intrinsic time smearing of K40 coincidences.
 

Protected Member Functions

 JK40DefaultSimulatorInterface ()
 Default constructor.
 

Static Private Member Functions

static double & get_sigma ()
 Get intrinsic time smearing of K40 coincidences.
 

Detailed Description

Default K40 simulator interface.

This class provides for a default implementation of the JK40Simulator interface which is based on a set of virtual methods. These methods constitute a user interface to the K40 background simulation.

Definition at line 42 of file JK40DefaultSimulatorInterface.hh.

Constructor & Destructor Documentation

◆ JK40DefaultSimulatorInterface()

JDETECTOR::JK40DefaultSimulatorInterface::JK40DefaultSimulatorInterface ( )
inlineprotected

Default constructor.

Definition at line 113 of file JK40DefaultSimulatorInterface.hh.

114 {}

Member Function Documentation

◆ getSinglesRate()

virtual double JDETECTOR::JK40DefaultSimulatorInterface::getSinglesRate ( const JPMTIdentifier & pmt) const
pure virtual

Get singles rate as a function of PMT.

Parameters
pmtPMT identifier
Returns
rate [Hz]

Implemented in JDETECTOR::JK40DefaultSimulator, and JTRIGGER::JK40RunByRunSimulator.

◆ getMultiplesRate()

virtual double JDETECTOR::JK40DefaultSimulatorInterface::getMultiplesRate ( const JModuleIdentifier & module,
const int M ) const
pure virtual

Get multiples rate as a function of optical module.

Parameters
moduleoptical module identifier
Mmultiplicity (M >= 2)
Returns
rate [Hz]

Implemented in JDETECTOR::JK40DefaultSimulator.

◆ getProbability()

virtual double JDETECTOR::JK40DefaultSimulatorInterface::getProbability ( const double ct) const
pure virtual

Get probability of coincidence.

Parameters
ctcosine space angle between PMT axes
Returns
probability

Implemented in JDETECTOR::JK40DefaultSimulator.

◆ getL01Rate()

virtual double JDETECTOR::JK40DefaultSimulatorInterface::getL01Rate ( ) const
pure virtual

Get mixed L0 (lower module) and L1 (upper module) rate [Hz].

Returns
rate [Hz]

Implemented in JDETECTOR::JK40DefaultSimulator.

◆ getL10Rate()

virtual double JDETECTOR::JK40DefaultSimulatorInterface::getL10Rate ( ) const
pure virtual

Get mixed L1 (lower module) and L0 (upper module) rate [Hz].

Returns
rate [Hz]

Implemented in JDETECTOR::JK40DefaultSimulator.

◆ generateHits() [1/2]

virtual void JDETECTOR::JK40DefaultSimulatorInterface::generateHits ( const JModule & module,
const JTimeRange & period,
JModuleData & output ) const
inlineoverridevirtual

Generate hits.

Parameters
modulemodule
periodtime window [ns]
outputbackground data

Implements JDETECTOR::JK40Simulator.

Definition at line 169 of file JK40DefaultSimulatorInterface.hh.

172 {
173 using namespace std;
174 using namespace JPP;
175
176 const size_t N = module.size();
177
178
179 // generate singles
180
181 for (size_t pmt = 0; pmt != N; ++pmt) {
182
183 const double rateL0_Hz = getSinglesRate(JPMTIdentifier(module.getID(), pmt));
184
185 if (rateL0_Hz > 0.0) {
186
187 const bool asap = (output[pmt].size() != 0); // sort as soon as possible
188
189 const double t_ns = 1.0e9 / rateL0_Hz; // interval period [ns]
190
191 for (double t1 = period.getLowerLimit() + gRandom->Exp(t_ns); t1 < period.getUpperLimit(); t1 += gRandom->Exp(t_ns)) {
192 output[pmt].push_back(JPMTSignal(t1, -1)); // see JPMTSignalProcessorInterface::operator()
193 }
194
195 if (asap) {
196 output[pmt].sort();
197 }
198 }
199 }
200
201
202 // generate coincidences
203
204 double totalRateL1_Hz = 0.0;
205
206 // multiples rate as a function of the multiplicity - index i corresponds to multiplicity M = i + 2
207
208 vector<double> rateL1_Hz(N, 0.0);
209
210 for (size_t i = 0; i != N; ++i) {
211 totalRateL1_Hz += rateL1_Hz[i] = getMultiplesRate(module.getID(), i + 2);
212 }
213
214 if (totalRateL1_Hz > 0.0) {
215
217
218 cdf_type<pair_type> probablityL1;
219
220 const double t_ns = 1.0e9 / totalRateL1_Hz; // interval period [ns]
221
222 double t1 = period.getLowerLimit() + gRandom->Exp(t_ns);
223
224 if (t1 < period.getUpperLimit()) {
225
226 // configure pair-wise propabilities
227
228 for (size_t pmt1 = 0; pmt1 != N; ++pmt1) {
229 for (size_t pmt2 = 0; pmt2 != pmt1; ++pmt2) {
230
231 const double ct = getDot(module[pmt1].getDirection(), module[pmt2].getDirection());
232 const double p = getProbability(ct);
233
234 probablityL1.put({pmt1, pmt2}, p);
235 }
236 }
237
238 for ( ; t1 < period.getUpperLimit(); t1 += gRandom->Exp(t_ns)) {
239
240 try {
241
242 // generate two-fold coincidence
243
244 const pair_type& pair = probablityL1(gRandom->Rndm());
245
246 output[pair.first ].insert(JPMTSignal(gRandom->Gaus(t1, getSigma()), 1));
247 output[pair.second].insert(JPMTSignal(gRandom->Gaus(t1, getSigma()), 1));
248
249 // generate larger than two-fold coincidences, if any
250
251 size_t M = 0;
252
253 for (double R = totalRateL1_Hz * gRandom->Rndm(); M != N && (R -= rateL1_Hz[M]) > 0.0; ++M) {}
254
255 if (M != 0) {
256
257 set<size_t> buffer = { pair.first , pair.second }; // hit PMTs
258
259 for ( ; M != 0; --M) {
260
261 vector<double> probability1D(N, 1.0);
262
263 double P = 0.0;
264
265 for (size_t i = 0; i != N; ++i) {
266
267 if (buffer.count(i) == 0) {
268
269 for (set<size_t>::const_iterator pmt = buffer.begin(); pmt != buffer.end(); ++pmt) {
270
271 const double ct = getDot(module[i].getDirection(), module[*pmt].getDirection());
272
273 probability1D[i] *= getProbability(ct);
274 }
275
276 P += probability1D[i];
277
278 } else {
279
280 probability1D[i] = 0.0;
281 }
282 }
283
284 if (P > 0.0) {
285
286 size_t pmt = 0;
287
288 for (P *= gRandom->Rndm(); pmt != N && (P -= probability1D[pmt]) > 0.0; ++pmt) {}
289
290 if (pmt != N) {
291
292 output[pmt].insert(JPMTSignal(gRandom->Gaus(t1, getSigma()), 1));
293
294 buffer.insert(pmt);
295 }
296
297 } else {
298
299 break;
300 }
301 }
302 }
303 }
304 catch (const JNumericalPrecision&) {}
305 }
306 }
307 }
308 }
static double getSigma()
Get 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.
virtual double getProbability(const double ct) const =0
Get probability of coincidence.
Exception for numerical precision error.
JDirection3D getDirection(const Vec &dir)
Get direction.
double getDot(const JFirst_t &first, const JSecond_t &second)
Get dot product of objects.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Data structure for PMT analogue signal.
Data structure for a pair of indices.

◆ generateHits() [2/2]

virtual void JDETECTOR::JK40DefaultSimulatorInterface::generateHits ( const module_pair & input,
const JTimeRange & period,
const module_data & output ) const
inlineoverridevirtual

Generate mixed-L1/L0 hits.

Parameters
inputmodule pair
periodtime window [ns]
outputbackground data

Implements JDETECTOR::JK40Simulator.

Definition at line 318 of file JK40DefaultSimulatorInterface.hh.

321 {
322 using namespace JPP;
323
324 const double rate_Hz = getL01Rate() + getL10Rate();
325
326 if (rate_Hz > 0.0) {
327
328 if (!input.first.empty() && !input.second.empty()) {
329
330 if (neighbours(input.first, input.second)) {
331
332 // locate decay in between modules
333
334 const double ts = 0.8 * fabs(input.first.getZ() - input.second.getZ()) * getInverseSpeedOfLight() * getIndexOfRefraction();
335
336 const JModule& input_lower = (input.first.getFloor() == input.second.getFloor() - 1 ? input.first : input.second);
337 const JModule& input_upper = (input.first.getFloor() == input.second.getFloor() + 1 ? input.first : input.second);
338
339 JModuleData& output_lower = (input.first.getFloor() == input.second.getFloor() - 1 ? output.first : output.second);
340 JModuleData& output_upper = (input.first.getFloor() == input.second.getFloor() + 1 ? output.first : output.second);
341
342 cdf_type<size_t> probability_lower;
343 cdf_type<size_t> probability_upper;
344
345 // use angular dependence of coincidence rate with respect to z-axis
346
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())); }
349
350 const double t_ns = 1.0e9 / rate_Hz; // interval period [ns]
351
352 for (double t1 = period.getLowerLimit() + gRandom->Exp(t_ns); t1 < period.getUpperLimit(); t1 += gRandom->Exp(t_ns)) {
353
354 const bool L01 = gRandom->Uniform(0.0, rate_Hz) < getL01Rate();
355
356 JModuleData& output_L1 = (L01 ? output_upper : output_lower);
357 JModuleData& output_L0 = (L01 ? output_lower : output_upper);
358
359 cdf_type<size_t>& probability_L1 = (L01 ? probability_upper : probability_lower);
360 cdf_type<size_t>& probability_L0 = (L01 ? probability_lower : probability_upper);
361
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));
364
365 output_L0[probability_L0(gRandom->Rndm())].insert(JPMTSignal(gRandom->Gaus(t1 + ts, getSigma()), 1));
366 }
367 }
368 }
369 }
370 }
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].
Data structure for a composite optical module.
Definition JModule.hh:76
bool neighbours(const JLocation &first, const JLocation &second)
Check if two locations are neighbours.
Definition JLocation.hh:263

◆ getSigma()

static double JDETECTOR::JK40DefaultSimulatorInterface::getSigma ( )
inlinestatic

Get intrinsic time smearing of K40 coincidences.

Returns
sigma [ns]

Definition at line 378 of file JK40DefaultSimulatorInterface.hh.

379 {
380 return get_sigma();
381 }
static double & get_sigma()
Get intrinsic time smearing of K40 coincidences.

◆ setSigma()

static void JDETECTOR::JK40DefaultSimulatorInterface::setSigma ( const double sigma)
inlinestatic

Set intrinsic time smearing of K40 coincidences.

Parameters
sigmasigma [ns]

Definition at line 389 of file JK40DefaultSimulatorInterface.hh.

390 {
391 get_sigma() = sigma;
392 }

◆ get_sigma()

static double & JDETECTOR::JK40DefaultSimulatorInterface::get_sigma ( )
inlinestaticprivate

Get intrinsic time smearing of K40 coincidences.

Returns
sigma [ns]

Definition at line 400 of file JK40DefaultSimulatorInterface.hh.

401 {
402 static double sigma = 0.5;
403
404 return sigma;
405 }

The documentation for this class was generated from the following file: