Jpp  16.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Private Member Functions | Private Attributes | List of all members
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  JBuffer1D_t
 1D-linear buffer. More...
 
struct  JBuffer2D_t
 2D-square buffer. More...
 

Public Member Functions

virtual double getSinglesRate (const JPMTIdentifier &pmt) const =0
 Get singles rate as a function of PMT. More...
 
virtual double getMultiplesRate (const JModuleIdentifier &module, const int M) const =0
 Get multiples rate as a function of optical module. More...
 
virtual double getProbability (const double ct) const =0
 Get probability of coincidence. More...
 
virtual void generateHits (const JModule &module, const JTimeRange &period, JModuleData &output) const
 Generate hits. More...
 

Static Public Member Functions

static unsigned int getRandomIndex (const JBuffer1D_t &buffer, const double random)
 Get index based on random value. More...
 
static double getSigma ()
 Get intrinsic time smearing of K40 coincidences. More...
 
static void setSigma (const double sigma)
 Set intrinsic time smearing of K40 coincidences. More...
 

Protected Member Functions

 JK40DefaultSimulatorInterface ()
 Default constructor. More...
 

Static Private Member Functions

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

Private Attributes

JBuffer2D_t probability2D
 This correlation matrix is a two-dimensional array in which element [i][j] corresponds to the probability of a genuine coincidence due to K40 decays, where i and j refer to the indices of the PMTs in the optical module. More...
 
JBuffer1D_t probability1D
 This probability vector is a one-dimensional array in which element [i] corresponds to the probability of a genuine coincidence due to K40 decays, where i refers to the index of the PMT in the optical module. More...
 
JBuffer1D_t probabilityND
 This probability vector is a one-dimensional array in which element [i] corresponds to the probability of an additional hit, where i refers to the index of the PMT in the optical module. More...
 
JBuffer1D_t rateL1_Hz
 Multiples rate as a function of the multiplicity. More...
 

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

Constructor & Destructor Documentation

JDETECTOR::JK40DefaultSimulatorInterface::JK40DefaultSimulatorInterface ( )
inlineprotected

Default constructor.

Definition at line 72 of file JK40DefaultSimulatorInterface.hh.

73  {}

Member Function Documentation

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.

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.

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.

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

115  {
116 
117  // resize internal buffers
118 
119  const int N = module.size();
120 
122  probability1D.resize(N);
123  probabilityND.resize(N);
124 
125  rateL1_Hz.resize(N);
126 
127 
128  // generate singles
129 
130  for (int pmt = 0; pmt != N; ++pmt) {
131 
132  const double rateL0_Hz = getSinglesRate(JPMTIdentifier(module.getID(), pmt));
133 
134  if (rateL0_Hz > 0.0) {
135 
136  const double t_ns = 1.0e9 / rateL0_Hz; // [ns]
137 
138  for (double t1 = period.getLowerLimit() + gRandom->Exp(t_ns); t1 < period.getUpperLimit(); t1 += gRandom->Exp(t_ns)) {
139  output[pmt].push_back(JPMTSignal(t1, 1));
140  }
141  }
142  }
143 
144 
145  // generate coincidences
146 
147  double totalRateL1_Hz = 0.0;
148 
149  for (int i = 0; i != N; ++i) {
150  totalRateL1_Hz += rateL1_Hz[i] = getMultiplesRate(module.getID(), i + 2);
151  }
152 
153  if (totalRateL1_Hz > 0.0) {
154 
155  const double t_ns = 1.0e9 / totalRateL1_Hz; // [ns]
156 
157  double t1 = period.getLowerLimit() + gRandom->Exp(t_ns);
158 
159  if (t1 < period.getUpperLimit()) {
160 
161 
162  // configure correlation matrix
163 
164  for (int i = 0; i != N; ++i) {
165 
166  probability2D[i][i] = 0.0;
167 
168  for (int j = i + 1; j != N; ++j) {
169 
170  const double ct = JMATH::getDot(module[i], module[j]);
171  const double p = getProbability(ct);
172 
173  probability2D[i][j] = p;
174  probability2D[j][i] = p;
175  }
176  }
177 
178 
179  // determine probability of a coincidence as a function of the PMT number
180 
181  for (int i = 0; i != N; ++i) {
182 
183  probability1D[i] = 0.0;
184 
185  for (int j = 0; j != N; ++j) {
186  probability1D[i] += probability2D[i][j];
187  }
188  }
189 
190 
191  for ( ; t1 < period.getUpperLimit(); t1 += gRandom->Exp(t_ns)) {
192 
193 
194  // generate two-fold coincidence
195 
196  const unsigned int pmt1 = getRandomIndex(probability1D, gRandom->Rndm());
197  const unsigned int pmt2 = getRandomIndex(probability2D[pmt1], gRandom->Rndm());
198 
199  output[pmt1].insert(JPMTSignal(gRandom->Gaus(t1, getSigma()), 1));
200  output[pmt2].insert(JPMTSignal(gRandom->Gaus(t1, getSigma()), 1));
201 
202 
203  try {
204 
205  // generate larger than two-fold coincidences, if any
206 
207  unsigned int M = getRandomIndex(rateL1_Hz, gRandom->Rndm());
208 
209  if (M != 0) {
210 
212 
213  for (unsigned int pmtN = pmt2; M != 0; --M) {
214 
215  for (int i = 0; i != N; ++i) {
216  probabilityND[i] *= probability2D[pmtN][i];
217  }
218 
219  probabilityND[pmtN] = 0.0;
220 
221  pmtN = getRandomIndex(probabilityND, gRandom->Rndm());
222 
223  output[pmtN].insert(JPMTSignal(gRandom->Gaus(t1, getSigma()), 1));
224  }
225  }
226  }
227  catch (const JNumericalPrecision&) {}
228  }
229  }
230  }
231  }
static double getSigma()
Get intrinsic time smearing of K40 coincidences.
Data structure for PMT analogue signal.
do $JPP JMEstimator M
Definition: JMEstimator.sh:37
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
JBuffer1D_t probabilityND
This probability vector is a one-dimensional array in which element [i] corresponds to the probabilit...
static unsigned int getRandomIndex(const JBuffer1D_t &buffer, const double random)
Get index based on random value.
virtual double getSinglesRate(const JPMTIdentifier &pmt) const =0
Get singles rate as a function of PMT.
int getID() const
Get identifier.
Definition: JObjectID.hh:50
JBuffer2D_t probability2D
This correlation matrix is a two-dimensional array in which element [i][j] corresponds to the probabi...
JBuffer1D_t rateL1_Hz
Multiples rate as a function of the multiplicity.
double getDot(const JFirst_t &first, const JSecond_t &second)
Get dot product of objects.
virtual double getMultiplesRate(const JModuleIdentifier &module, const int M) const =0
Get multiples rate as a function of optical module.
JBuffer1D_t probability1D
This probability vector is a one-dimensional array in which element [i] corresponds to the probabilit...
int j
Definition: JPolint.hh:682
virtual double getProbability(const double ct) const =0
Get probability of coincidence.
static unsigned int JDETECTOR::JK40DefaultSimulatorInterface::getRandomIndex ( const JBuffer1D_t buffer,
const double  random 
)
inlinestatic

Get index based on random value.

It is assumed that the values of the input buffer monotonously decrease or increase. This method throws an exception when the summed values in the input buffer is zero.

Parameters
bufferinput values
randomrandom value <0,1]
Returns
index

Definition at line 244 of file JK40DefaultSimulatorInterface.hh.

245  {
246  double x = 0.0;
247 
248  for (JBuffer1D_t::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
249  x += *i;
250  }
251 
252  if (x > 0.0) {
253 
254  x *= random;
255 
256  unsigned int index = 0;
257 
258  for (JBuffer1D_t::const_iterator i = buffer.begin(); i != buffer.end() && (x -= *i) > 0.0; ++i, ++index) {}
259 
260  if (index == buffer.size()) {
261  --index;
262  }
263 
264  return index;
265 
266  } else {
267 
268  THROW(JNumericalPrecision, "getRandomIndex(): zero or negative probability.");
269  }
270  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
static double JDETECTOR::JK40DefaultSimulatorInterface::getSigma ( )
inlinestatic

Get intrinsic time smearing of K40 coincidences.

Returns
sigma [ns]

Definition at line 278 of file JK40DefaultSimulatorInterface.hh.

279  {
280  return get_sigma();
281  }
static double & get_sigma()
Get intrinsic time smearing of K40 coincidences.
static void JDETECTOR::JK40DefaultSimulatorInterface::setSigma ( const double  sigma)
inlinestatic

Set intrinsic time smearing of K40 coincidences.

Parameters
sigmasigma [ns]

Definition at line 289 of file JK40DefaultSimulatorInterface.hh.

290  {
291  get_sigma() = sigma;
292  }
static double & get_sigma()
Get intrinsic time smearing of K40 coincidences.
static double& JDETECTOR::JK40DefaultSimulatorInterface::get_sigma ( )
inlinestaticprivate

Get intrinsic time smearing of K40 coincidences.

Returns
sigma [ns]

Definition at line 300 of file JK40DefaultSimulatorInterface.hh.

301  {
302  static double sigma = 0.5;
303 
304  return sigma;
305  }

Member Data Documentation

JBuffer2D_t JDETECTOR::JK40DefaultSimulatorInterface::probability2D
mutableprivate

This correlation matrix is a two-dimensional array in which element [i][j] corresponds to the probability of a genuine coincidence due to K40 decays, where i and j refer to the indices of the PMTs in the optical module.

Definition at line 313 of file JK40DefaultSimulatorInterface.hh.

JBuffer1D_t JDETECTOR::JK40DefaultSimulatorInterface::probability1D
mutableprivate

This probability vector is a one-dimensional array in which element [i] corresponds to the probability of a genuine coincidence due to K40 decays, where i refers to the index of the PMT in the optical module.

Definition at line 320 of file JK40DefaultSimulatorInterface.hh.

JBuffer1D_t JDETECTOR::JK40DefaultSimulatorInterface::probabilityND
mutableprivate

This probability vector is a one-dimensional array in which element [i] corresponds to the probability of an additional hit, where i refers to the index of the PMT in the optical module.

Definition at line 327 of file JK40DefaultSimulatorInterface.hh.

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


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