Jpp
Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Protected Member Functions | Protected Attributes | Private Attributes | List of all members
JDETECTOR::JK40RunByRunSimulator Class Reference

K40 simulation based on run-by-run information. More...

#include <JK40RunByRunSimulator.hh>

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

Public Member Functions

 JK40RunByRunSimulator (const JSummaryRouter &router, const JK40Rates &rates)
 Constructor. More...
 
virtual double getSinglesRate (const JPMTIdentifier &pmt) const
 Get singles rate as a function of PMT. More...
 
double getSinglesRate () const
 Get singles rate. More...
 
virtual double getMultiplesRate (const JModuleIdentifier &module, const int M) const
 Get multiples rate as a function of optical module. More...
 
double getMultiplesRate (const multiplicity_type M) const
 Get multiples rate. More...
 
virtual double getProbability (const double ct) const
 Get probability of coincidence. More...
 
virtual void generateHits (const JModule &module, const JTimeRange &period, JModuleData &output) const
 Generate hits. More...
 
multiplicity_type getLowerL1Multiplicity () const
 Get lower multiplicty. More...
 
multiplicity_type getUpperL1Multiplicity () const
 Get upper multiplicty. More...
 
void correct (const double QE)
 Correct rates for global efficiency,. More...
 

Static Public Member Functions

static JK40DefaultSimulatorgetInstance ()
 Get reference to unique instance of this class object. More...
 
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 Public Attributes

static const multiplicity_type LOWER_L1_MULTIPLICITY = 2
 Lower L1 multiplicity. More...
 

Static Protected Member Functions

static double p1 ()
 Parameters for probability of coincidence as a function of the cosine of space angle between PMT axes. More...
 
static double p2 ()
 
static double p3 ()
 
static double p4 ()
 

Protected Attributes

const JSummaryRoutersummary_router
 
JRateL0_t rateL0
 singles rate [Hz] More...
 
JRateL1_t rateL1
 multiples rates [Hz] 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

K40 simulation based on run-by-run information.

This class overwrites the method JK40DefaultSimulator::getSinglesRate. The singles rate is determined from summary data.

Definition at line 29 of file JK40RunByRunSimulator.hh.

Constructor & Destructor Documentation

◆ JK40RunByRunSimulator()

JDETECTOR::JK40RunByRunSimulator::JK40RunByRunSimulator ( const JSummaryRouter router,
const JK40Rates rates 
)
inline

Constructor.

Parameters
routersummary router
ratesK40 rates [Hz]

Definition at line 39 of file JK40RunByRunSimulator.hh.

40  :
41  JK40DefaultSimulator(rates),
42  summary_router(router)
43  {}

Member Function Documentation

◆ getSinglesRate() [1/2]

virtual double JDETECTOR::JK40RunByRunSimulator::getSinglesRate ( const JPMTIdentifier pmt) const
inlinevirtual

Get singles rate as a function of PMT.

Parameters
pmtPMT identifier
Returns
rate [Hz]

Reimplemented from JDETECTOR::JK40DefaultSimulator.

Definition at line 52 of file JK40RunByRunSimulator.hh.

53  {
55 
57 
58  return frame.getRate(pmt.getPMTAddress());
59  }
60 
61  return 0.0;
62  }

◆ getInstance()

static JK40DefaultSimulator& JDETECTOR::JK40DefaultSimulator::getInstance ( )
inlinestaticinherited

Get reference to unique instance of this class object.

This method returns an object with default values. The singles and multiples rates are taken from KM3NeT internal note "Detector simulations for KM3NeT".

Returns
reference to this class object

Definition at line 57 of file JK40DefaultSimulator.hh.

58  {
59  static JK40DefaultSimulator k40Simulator(JK40Rates::getInstance());
60 
61  return k40Simulator;
62  }

◆ getSinglesRate() [2/2]

double JDETECTOR::JK40Rates::getSinglesRate ( ) const
inlineinherited

Get singles rate.

Returns
rate [Hz]

Definition at line 97 of file JK40Rates.hh.

98  {
99  return rateL0;
100  }

◆ getMultiplesRate() [1/2]

virtual double JDETECTOR::JK40DefaultSimulator::getMultiplesRate ( const JModuleIdentifier module,
const int  M 
) const
inlinevirtualinherited

Get multiples rate as a function of optical module.

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

Implements JDETECTOR::JK40DefaultSimulatorInterface.

Definition at line 84 of file JK40DefaultSimulator.hh.

85  {
87  }

◆ getMultiplesRate() [2/2]

double JDETECTOR::JK40Rates::getMultiplesRate ( const multiplicity_type  M) const
inlineinherited

Get multiples rate.

Parameters
Mmultiplicity (M >= JK40Rates::LOWER_L1_MULTIPLICITY)
Returns
rate [Hz]

Definition at line 109 of file JK40Rates.hh.

110  {
112  return rateL1[M - LOWER_L1_MULTIPLICITY];
113  else
114  return 0.0;
115  }

◆ getProbability()

virtual double JDETECTOR::JK40DefaultSimulator::getProbability ( const double  ct) const
inlinevirtualinherited

Get probability of coincidence.

Parameters
ctcosine space angle between PMT axes
Returns
probability

Implements JDETECTOR::JK40DefaultSimulatorInterface.

Definition at line 96 of file JK40DefaultSimulator.hh.

97  {
98  return exp(ct * (p1() + ct * (p2() + ct * (p3() + ct*p4()))));
99  }

◆ p1()

static double JDETECTOR::JK40DefaultSimulator::p1 ( )
inlinestaticprotectedinherited

Parameters for probability of coincidence as a function of the cosine of space angle between PMT axes.

Values are provided by V.Kulikovski.

Definition at line 155 of file JK40DefaultSimulator.hh.

155 { return 2.85261; }

◆ p2()

static double JDETECTOR::JK40DefaultSimulator::p2 ( )
inlinestaticprotectedinherited

Definition at line 156 of file JK40DefaultSimulator.hh.

156 { return -0.949097; }

◆ p3()

static double JDETECTOR::JK40DefaultSimulator::p3 ( )
inlinestaticprotectedinherited

Definition at line 157 of file JK40DefaultSimulator.hh.

157 { return 0.182419; }

◆ p4()

static double JDETECTOR::JK40DefaultSimulator::p4 ( )
inlinestaticprotectedinherited

Definition at line 158 of file JK40DefaultSimulator.hh.

158 { return 1.23075; }

◆ generateHits()

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

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  }

◆ getRandomIndex()

static unsigned int JDETECTOR::JK40DefaultSimulatorInterface::getRandomIndex ( const JBuffer1D_t buffer,
const double  random 
)
inlinestaticinherited

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  }

◆ getSigma()

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

Get intrinsic time smearing of K40 coincidences.

Returns
sigma [ns]

Definition at line 278 of file JK40DefaultSimulatorInterface.hh.

279  {
280  return 0.5;
281  }

◆ getLowerL1Multiplicity()

multiplicity_type JDETECTOR::JK40Rates::getLowerL1Multiplicity ( ) const
inlineinherited

Get lower multiplicty.

Returns
lower multiplicity

Definition at line 123 of file JK40Rates.hh.

124  {
125  return LOWER_L1_MULTIPLICITY;
126  }

◆ getUpperL1Multiplicity()

multiplicity_type JDETECTOR::JK40Rates::getUpperL1Multiplicity ( ) const
inlineinherited

Get upper multiplicty.

Returns
upper multiplicity

Definition at line 134 of file JK40Rates.hh.

135  {
136  return rateL1.size() + 1;
137  }

◆ correct()

void JDETECTOR::JK40Rates::correct ( const double  QE)
inlineinherited

Correct rates for global efficiency,.

Parameters
QEglobal efficiency

Definition at line 145 of file JK40Rates.hh.

146  {
147  if (QE > 0.0) {
148 
149  rateL0 /= QE;
150 
151  JRateL1_t buffer = rateL1;
152 
154 
155  // determine contribution from higher multiplicities
156 
157  double R = 0.0;
158 
159  for (multiplicity_type i = M + 1; i <= getUpperL1Multiplicity(); ++i) {
160  R += buffer[i - LOWER_L1_MULTIPLICITY] * TMath::Binomial(i, M) * pow(QE, M) * pow(1.0 - QE, i - M);
161  }
162 
163  if (getMultiplesRate(M) > R)
164  buffer[M - LOWER_L1_MULTIPLICITY] = (getMultiplesRate(M) - R) / pow(QE, M);
165  else
166  buffer[M - LOWER_L1_MULTIPLICITY] = 0.0;
167  }
168 
169  rateL1 = buffer;
170 
171  } else {
172 
173  rateL0 = 0.0;
174 
175  for (JRateL1_t::iterator i = rateL1.begin(); i != rateL1.end(); ++i) {
176  *i = 0.0;
177  }
178  }
179  }

Member Data Documentation

◆ summary_router

const JSummaryRouter& JDETECTOR::JK40RunByRunSimulator::summary_router
protected

Definition at line 66 of file JK40RunByRunSimulator.hh.

◆ probability2D

JBuffer2D_t JDETECTOR::JK40DefaultSimulatorInterface::probability2D
mutableprivateinherited

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

◆ probability1D

JBuffer1D_t JDETECTOR::JK40DefaultSimulatorInterface::probability1D
mutableprivateinherited

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

◆ probabilityND

JBuffer1D_t JDETECTOR::JK40DefaultSimulatorInterface::probabilityND
mutableprivateinherited

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

◆ rateL1_Hz

JBuffer1D_t JDETECTOR::JK40DefaultSimulatorInterface::rateL1_Hz
mutableprivateinherited

Multiples rate as a function of the multiplicity.

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

Definition at line 309 of file JK40DefaultSimulatorInterface.hh.

◆ LOWER_L1_MULTIPLICITY

const multiplicity_type JDETECTOR::JK40Rates::LOWER_L1_MULTIPLICITY = 2
staticinherited

Lower L1 multiplicity.

Definition at line 232 of file JK40Rates.hh.

◆ rateL0

JRateL0_t JDETECTOR::JK40Rates::rateL0
protectedinherited

singles rate [Hz]

Definition at line 236 of file JK40Rates.hh.

◆ rateL1

JRateL1_t JDETECTOR::JK40Rates::rateL1
protectedinherited

multiples rates [Hz]

Definition at line 237 of file JK40Rates.hh.


The documentation for this class was generated from the following file:
JDETECTOR::JK40DefaultSimulator::p2
static double p2()
Definition: JK40DefaultSimulator.hh:156
JDETECTOR::JK40DefaultSimulator
Default implementation of the simulation of K40 background.
Definition: JK40DefaultSimulator.hh:25
JDETECTOR::JK40Rates::rateL1
JRateL1_t rateL1
multiples rates [Hz]
Definition: JK40Rates.hh:237
JDETECTOR::JK40DefaultSimulatorInterface::getSigma
static double getSigma()
Get intrinsic time smearing of K40 coincidences.
Definition: JK40DefaultSimulatorInterface.hh:278
JDETECTOR::JPMTIdentifier::getModuleID
int getModuleID() const
Get module identifier.
Definition: JPMTIdentifier.hh:62
JDETECTOR::JK40DefaultSimulatorInterface::probability2D
JBuffer2D_t probability2D
This correlation matrix is a two-dimensional array in which element [i][j] corresponds to the probabi...
Definition: JK40DefaultSimulatorInterface.hh:289
std::vector< double >
JTRIGGER::JSummaryRouter::getSummaryFrame
const JDAQSummaryFrame & getSummaryFrame(const JDAQModuleIdentifier &module) const
Get summary frame.
Definition: JSummaryRouter.hh:90
JTOOLS::j
int j
Definition: JPolint.hh:634
JTRIGGER::JSummaryRouter::hasSummaryFrame
bool hasSummaryFrame(const JDAQModuleIdentifier &module) const
Has summary frame.
Definition: JSummaryRouter.hh:102
JDETECTOR::JK40RunByRunSimulator::summary_router
const JSummaryRouter & summary_router
Definition: JK40RunByRunSimulator.hh:66
KM3NETDAQ::JDAQSummaryFrame::getRate
double getRate(const int tdc, const double factor=1.0) const
Get count rate.
Definition: JDAQSummaryFrame.hh:456
JDETECTOR::JK40DefaultSimulatorInterface::getMultiplesRate
virtual double getMultiplesRate(const JModuleIdentifier &module, const int M) const =0
Get multiples rate as a function of optical module.
JDETECTOR::JK40DefaultSimulatorInterface::JBuffer2D_t::resize
void resize(size_t size)
Resize.
Definition: JK40DefaultSimulatorInterface.hh:58
KM3NETDAQ::JDAQSummaryFrame
Data storage class for rate measurements of all PMTs in one module.
Definition: JDAQSummaryFrame.hh:320
JDETECTOR::JK40DefaultSimulator::JK40DefaultSimulator
JK40DefaultSimulator()
Default constructor.
Definition: JK40DefaultSimulator.hh:33
JDETECTOR::JK40DefaultSimulatorInterface::getRandomIndex
static unsigned int getRandomIndex(const JBuffer1D_t &buffer, const double random)
Get index based on random value.
Definition: JK40DefaultSimulatorInterface.hh:244
JLANG::JObjectID::getID
int getID() const
Get identifier.
Definition: JObjectID.hh:55
JDETECTOR::JK40DefaultSimulatorInterface::rateL1_Hz
JBuffer1D_t rateL1_Hz
Multiples rate as a function of the multiplicity.
Definition: JK40DefaultSimulatorInterface.hh:309
THROW
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
JDETECTOR::JK40DefaultSimulatorInterface::getSinglesRate
virtual double getSinglesRate(const JPMTIdentifier &pmt) const =0
Get singles rate as a function of PMT.
JDETECTOR::JK40DefaultSimulator::p1
static double p1()
Parameters for probability of coincidence as a function of the cosine of space angle between PMT axes...
Definition: JK40DefaultSimulator.hh:155
JDETECTOR::multiplicity_type
size_t multiplicity_type
Type definition of multiplicity.
Definition: JK40Rates.hh:33
JDETECTOR::JK40Rates::getInstance
static JK40Rates & getInstance()
Get reference to unique instance of this class object.
Definition: JK40Rates.hh:75
JDETECTOR::JK40Rates::rateL0
JRateL0_t rateL0
singles rate [Hz]
Definition: JK40Rates.hh:236
JDETECTOR::JPMTIdentifier::getPMTAddress
int getPMTAddress() const
Get PMT identifier (= TDC).
Definition: JPMTIdentifier.hh:73
JDETECTOR::JK40DefaultSimulatorInterface::probabilityND
JBuffer1D_t probabilityND
This probability vector is a one-dimensional array in which element [i] corresponds to the probabilit...
Definition: JK40DefaultSimulatorInterface.hh:303
JDETECTOR::JK40DefaultSimulator::p4
static double p4()
Definition: JK40DefaultSimulator.hh:158
JDETECTOR::JPMTIdentifier
PMT identifier.
Definition: JPMTIdentifier.hh:30
JDETECTOR::JK40DefaultSimulatorInterface::probability1D
JBuffer1D_t probability1D
This probability vector is a one-dimensional array in which element [i] corresponds to the probabilit...
Definition: JK40DefaultSimulatorInterface.hh:296
JDETECTOR::JK40Rates::getUpperL1Multiplicity
multiplicity_type getUpperL1Multiplicity() const
Get upper multiplicty.
Definition: JK40Rates.hh:134
JDETECTOR::JK40Rates::getMultiplesRate
double getMultiplesRate(const multiplicity_type M) const
Get multiples rate.
Definition: JK40Rates.hh:109
JDETECTOR::JK40DefaultSimulator::p3
static double p3()
Definition: JK40DefaultSimulator.hh:157
JDETECTOR::JK40Rates::getLowerL1Multiplicity
multiplicity_type getLowerL1Multiplicity() const
Get lower multiplicty.
Definition: JK40Rates.hh:123
JDETECTOR::JPMTSignal
Data structure for PMT analogue signal.
Definition: JPMTSimulator.hh:76
JDETECTOR::JK40DefaultSimulatorInterface::getProbability
virtual double getProbability(const double ct) const =0
Get probability of coincidence.
JMATH::getDot
double getDot(const JFirst_t &first, const JSecond_t &second)
Get dot product of objects.
Definition: JMathToolkit.hh:131
JDETECTOR::JK40Rates::LOWER_L1_MULTIPLICITY
static const multiplicity_type LOWER_L1_MULTIPLICITY
Lower L1 multiplicity.
Definition: JK40Rates.hh:232