Jpp  15.0.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JCalibrateK40.hh
Go to the documentation of this file.
1 #ifndef __JCALIBRATE_JCALIBRATEK40__
2 #define __JCALIBRATE_JCALIBRATEK40__
3 
4 #include <cmath>
5 #include <algorithm>
6 
8 #include "JDetector/JModule.hh"
9 #include "JMath/JMathToolkit.hh"
10 
11 /**
12  * \author mdejong
13  */
14 
15 namespace JCALIBRATE {}
16 namespace JPP { using namespace JCALIBRATE; }
17 
18 namespace JCALIBRATE {
19 
21  using JDETECTOR::JModule;
22 
23 
24  /**
25  * Histogram naming.
26  */
27  static const char* const weights_hist_t = "weights_hist"; //!< Name of histogram with normalisation constants.
28 
29  static const char* const W1_overall_t = "W1_overall"; //!< Named bin for duration of the run
30  static const char* const WS_t = "WS"; //!< Named bin for time residual bin width
31  static const char* const WB_t = "WB"; //!< Named bin for value of TMax_ns in JCalibrateK40
32 
33  static const char* const _2S = ".2S"; //!< Name extension for 2D counts
34  static const char* const _1B = ".1B"; //!< Name extension for 1D background
35  static const char* const _1L = ".1L"; //!< Name extension for 1D live time
36  static const char* const _2R = ".2R"; //!< Name extension for 2D rate measured
37  static const char* const _2F = ".2F"; //!< Name extension for 2F rate fitted
38  static const char* const _1D = ".1D"; //!< Name extension for 1D time offset
39  static const char* const _1F = ".1F"; //!< Name extension for 1D time offset fit
40 
42 
43 
44  /**
45  * Auxiliary class to sort pairs of PMT addresses within optical module.
46  */
48  /**
49  * Constructor.
50  *
51  * \param module detector module
52  * \param epsilon precision
53  */
55  const double epsilon = 1.0e-5) :
56  __module (module),
57  __epsilon(epsilon)
58  {}
59 
60 
61  /**
62  * Comparison of two pairs of PMT addresses.
63  *
64  * \param first first pair of PMT addresses
65  * \param second second pair of PMT addresses
66  * \return true if first pair has larger space angle; else false
67  */
68  inline bool operator()(const pair_type& first, const pair_type& second) const
69  {
70  using namespace std;
71 
72  if (fabs(this->getDot(first) - this->getDot(second)) > __epsilon)
73  return this->getDot(first) < this->getDot(second);
74  else if (max(first.first, first.second) == max(second.first, second.second))
75  return min(first.first, first.second) < min(second.first, second.second);
76  else
77  return max(first.first, first.second) < max(second.first, second.second);
78  }
79 
80 
81  /**
82  * Get cosine of space angle between PMT axes.
83  *
84  * \param pair pair of PMT addresses
85  * \return cosine
86  */
87  inline double getDot(const pair_type& pair) const
88  {
89  return JMATH::getDot(__module.getPMT(pair.first),
90  __module.getPMT(pair.second));
91  }
92 
93  protected:
94  const JModule& __module;
95  const double __epsilon;
96  };
97 
98 
99  /**
100  * Coincidence probability of two PMTs within one module.
101  *
102  * \param E1 expected counts of PMT 1 in certain time interval
103  * \param E2 expected counts of PMT 2 in certain time interval
104  * \param ED expected counts on the rest of the DOM, excluding PMT 1 and PMT 2
105  * \param M_min DOM multiplicity lower limit
106  * \param M_max DOM multiplicity upper limit
107  * \return coincidence probability of two PMTs in a certain time interval
108  */
109  inline double coincidenceP(double E1, double E2, double ED, int M_min, int M_max)
110  {
111  // first, always calculate the probability for 2-fold multiplicity
112  double P = exp(-E1) * E1 * exp(-E2) * E2 * exp(-ED);
113 
114  // second, calculate the probability of multiplicity at lower limit
115  for (int m = 2; m < M_min; m++) {
116  P = P * ( ED/(m-1) + E1/m + E2/m );
117  }
118 
119  // third, add the probabilities of multiplicities upto upper limit
120  double P_sum = P;
121 
122  for (int m = M_min+1; m <= M_max; m++) {
123  P = P * ( ED/(m-1) + E1/m + E2/m );
124  P_sum = P_sum + P;
125  }
126 
127  return P_sum;
128  }
129 }
130 
131 #endif
JCombinatorics::pair_type pair_type
Auxiliary class to convert pair of indices to unique index and back.
Auxiliary methods for geometrical methods.
Data structure for a composite optical module.
Definition: JModule.hh:68
static const char *const WB_t
Named bin for value of TMax_ns in JCalibrateK40.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable STRING $argv[2] set_array QUANTILES set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))" set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"` source JAcoustics.sh -- typeset -A TRIPODS get_tripods $WORKDIR/tripod.txt TRIPODS XMEAN
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
double getDot(const pair_type &pair) const
Get cosine of space angle between PMT axes.
static const char *const _1F
Name extension for 1D time offset fit.
static const char *const WS_t
Named bin for time residual bin width.
static const char *const _2F
Name extension for 2F rate fitted.
Auxiliary class to sort pairs of PMT addresses within optical module.
static const char *const _1B
Name extension for 1D background.
double getDot(const JFirst_t &first, const JSecond_t &second)
Get dot product of objects.
static const char *const _2R
Name extension for 2D rate measured.
const JPMT & getPMT(const int index) const
Get PMT.
Definition: JModule.hh:173
static const char *const weights_hist_t
Histogram naming.
static const char *const _1L
Name extension for 1D live time.
JPairwiseComparator(const JModule &module, const double epsilon=1.0e-5)
Constructor.
static const char *const W1_overall_t
Named bin for duration of the run.
bool operator()(const pair_type &first, const pair_type &second) const
Comparison of two pairs of PMT addresses.
double coincidenceP(double E1, double E2, double ED, int M_min, int M_max)
Coincidence probability of two PMTs within one module.
static const char *const _1D
Name extension for 1D time offset.
then $DIR JPlotNPE PDG P
Definition: JPlotNPE-PDG.sh:62
static const char *const _2S
Name extension for 2D counts.
Data structure for optical module.