Jpp test-rotations-old
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  pair_type
 PMT pair. 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 void generateHits (const JModule &module, const JTimeRange &period, JModuleData &output) const
 Generate 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.
 

Private Attributes

 probabilityL1
 
std::vector< double > rateL1_Hz
 Multiples rate as a function of the multiplicity.
 

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 39 of file JK40DefaultSimulatorInterface.hh.

Constructor & Destructor Documentation

◆ JK40DefaultSimulatorInterface()

JDETECTOR::JK40DefaultSimulatorInterface::JK40DefaultSimulatorInterface ( )
inlineprotected

Default constructor.

Definition at line 94 of file JK40DefaultSimulatorInterface.hh.

95 {}

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.

◆ generateHits()

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

Generate hits.

Parameters
modulemodule
periodtime window [ns]
outputbackground data

Implements JDETECTOR::JK40Simulator.

Definition at line 134 of file JK40DefaultSimulatorInterface.hh.

137 {
138 using namespace std;
139 using namespace JPP;
140
141
142 // resize internal buffers
143
144 const size_t N = module.size();
145 const size_t M = (N * (N - 1)) / 2;
146
147 rateL1_Hz .resize(N);
148 probabilityL1.resize(M + 1);
149
150
151 // generate singles
152
153 for (size_t pmt = 0; pmt != N; ++pmt) {
154
155 const double rateL0_Hz = getSinglesRate(JPMTIdentifier(module.getID(), pmt));
156
157 if (rateL0_Hz > 0.0) {
158
159 const double t_ns = 1.0e9 / rateL0_Hz; // [ns]
160
161 for (double t1 = period.getLowerLimit() + gRandom->Exp(t_ns); t1 < period.getUpperLimit(); t1 += gRandom->Exp(t_ns)) {
162 output[pmt].push_back(JPMTSignal(t1, 1));
163 }
164 }
165 }
166
167
168 // generate coincidences
169
170 double totalRateL1_Hz = 0.0;
171
172 for (size_t i = 0; i != N; ++i) {
173 totalRateL1_Hz += rateL1_Hz[i] = getMultiplesRate(module.getID(), i + 2);
174 }
175
176 if (totalRateL1_Hz > 0.0) {
177
178 const double t_ns = 1.0e9 / totalRateL1_Hz; // [ns]
179
180 double t1 = period.getLowerLimit() + gRandom->Exp(t_ns);
181
182 if (t1 < period.getUpperLimit()) {
183
184 // configure pair-wise propabilities
185
186 probabilityL1[0] = { N, N, 0.0};
187
188 size_t i = 0;
189 double P = 0.0;
190
191 for (size_t pmt1 = 0; pmt1 != N; ++pmt1) {
192 for (size_t pmt2 = 0; pmt2 != pmt1; ++pmt2) {
193
194 const double ct = getDot(module[pmt1].getDirection(), module[pmt2].getDirection());
195 const double p = getProbability(ct);
196
197 i += 1;
198 P += p;
199
200 probabilityL1[i] = { pmt1, pmt2, P};
201 }
202 }
203
204 for ( ; t1 < period.getUpperLimit(); t1 += gRandom->Exp(t_ns)) {
205
206 try {
207
208 // generate two-fold coincidence
209
210 const pair_type& pair = probabilityL1(gRandom->Rndm());
211
212 output[pair.pmt1].insert(JPMTSignal(gRandom->Gaus(t1, getSigma()), 1));
213 output[pair.pmt2].insert(JPMTSignal(gRandom->Gaus(t1, getSigma()), 1));
214
215 // generate larger than two-fold coincidences, if any
216
217 size_t M = 0;
218
219 for (double R = totalRateL1_Hz * gRandom->Rndm(); M != N && (R -= rateL1_Hz[M]) > 0.0; ++M) {}
220
221 if (M != 0) {
222
223 set<size_t> buffer = { pair.pmt1, pair.pmt2 }; // hit PMTs
224
225 for ( ; M != 0; --M) {
226
227 vector<double> probability1D(N, 1.0);
228
229 double P = 0.0;
230
231 for (size_t i = 0; i != N; ++i) {
232
233 if (buffer.count(i) == 0) {
234
235 for (set<size_t>::const_iterator pmt = buffer.begin(); pmt != buffer.end(); ++pmt) {
236
237 const double ct = getDot(module[i].getDirection(), module[*pmt].getDirection());
238
239 probability1D[i] *= getProbability(ct);
240 }
241
242 P += probability1D[i];
243
244 } else {
245
246 probability1D[i] = 0.0;
247 }
248 }
249
250 if (P > 0.0) {
251
252 size_t pmt = 0;
253
254 for (P *= gRandom->Rndm(); pmt != N && (P -= probability1D[pmt]) > 0.0; ++pmt) {}
255
256 if (pmt != N) {
257
258 output[pmt].insert(JPMTSignal(gRandom->Gaus(t1, getSigma()), 1));
259
260 buffer.insert(pmt);
261 }
262
263 } else {
264
265 break;
266 }
267 }
268 }
269 }
270 catch (const JNumericalPrecision&) {}
271 }
272 }
273 }
274 }
static double getSigma()
Get intrinsic time smearing of K40 coincidences.
std::vector< double > rateL1_Hz
Multiples rate as a function of the multiplicity.
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 JNeutrinoDirection &first, const JNeutrinoDirection &second)
Dot product.
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.

◆ getSigma()

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

Get intrinsic time smearing of K40 coincidences.

Returns
sigma [ns]

Definition at line 282 of file JK40DefaultSimulatorInterface.hh.

283 {
284 return get_sigma();
285 }
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 293 of file JK40DefaultSimulatorInterface.hh.

294 {
295 get_sigma() = sigma;
296 }
const double sigma[]

◆ get_sigma()

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

Get intrinsic time smearing of K40 coincidences.

Returns
sigma [ns]

Definition at line 304 of file JK40DefaultSimulatorInterface.hh.

305 {
306 static double sigma = 0.5;
307
308 return sigma;
309 }

Member Data Documentation

◆ probabilityL1

JDETECTOR::JK40DefaultSimulatorInterface::probabilityL1
private

◆ rateL1_Hz

std::vector<double> JDETECTOR::JK40DefaultSimulatorInterface::rateL1_Hz
mutableprivate

Multiples rate as a function of the multiplicity.

The index i corresponds to multiplicity M = i + 2.

Definition at line 316 of file JK40DefaultSimulatorInterface.hh.


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