Jpp
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
37  static const char* const _2F = ".2F"; //!< Name extension for 2F rate
38 
40 
41 
42  /**
43  * Auxiliary class to sort pairs of PMT addresses within optical module.
44  */
46  /**
47  * Constructor.
48  *
49  * \param module detector module
50  * \param epsilon precision
51  */
53  const double epsilon = 1.0e-5) :
54  __module (module),
55  __epsilon(epsilon)
56  {}
57 
58 
59  /**
60  * Comparison of two pairs of PMT addresses.
61  *
62  * \param first first pair of PMT addresses
63  * \param second second pair of PMT addresses
64  * \return true if first pair has larger space angle; else false
65  */
66  inline bool operator()(const pair_type& first, const pair_type& second) const
67  {
68  using namespace std;
69 
70  if (fabs(this->getDot(first) - this->getDot(second)) > __epsilon)
71  return this->getDot(first) < this->getDot(second);
72  else if (max(first.first, first.second) == max(second.first, second.second))
73  return min(first.first, first.second) < min(second.first, second.second);
74  else
75  return max(first.first, first.second) < max(second.first, second.second);
76  }
77 
78 
79  /**
80  * Get cosine of space angle between PMT axes.
81  *
82  * \param pair pair of PMT addresses
83  * \return cosine
84  */
85  inline double getDot(const pair_type& pair) const
86  {
87  return JMATH::getDot(__module.getPMT(pair.first),
88  __module.getPMT(pair.second));
89  }
90 
91  protected:
92  const JModule& __module;
93  const double __epsilon;
94  };
95 
96 
97  /**
98  * Coincidence probability of two PMTs.
99  *
100  * \param E1 Expected counts of PMT1 in certain time interval
101  * \param E2 Expected counts of PMT2 in certain time interval
102  * \param ED Expected counts on the rest of the DOM, excluding PMT1 and PMT2
103  * \param M_min DOM multiplicity lower limit
104  * \param M_max DOM multiplicity higher limit
105  * \return Coincidence probability of two PMTs in a certain time interval
106  */
107  inline double coincidenceP(double E1, double E2, double ED, int M_min, int M_max)
108  {
109  //first always calculate the probability for 2-fold multiplicity
110  double P = exp(-E1) * E1 * exp(-E2) * E2 * exp(-ED);
111 
112  //second calculate the prob at the lower M limit
113  for (int m = 2; m < M_min; m++) {
114  P = P * ( ED/(m-1) + E1/m + E2/m );
115  }
116 
117  //third, add the probabilities of higher multiplicities
118  double P_sum = P;
119 
120  for (int m = M_min+1; m <= M_max; m++) {
121  P = P * ( ED/(m-1) + E1/m + E2/m );
122  P_sum = P_sum + P;
123  }
124 
125  return P_sum;
126  }
127 }
128 
129 #endif
JModule.hh
JCALIBRATE::_2F
static const char *const _2F
Name extension for 2F rate.
Definition: JCalibrateK40.hh:37
JCALIBRATE::_1L
static const char *const _1L
Name extension for 1D live time.
Definition: JCalibrateK40.hh:35
JCALIBRATE
Definition: JCalibrateK40.hh:15
JCALIBRATE::_2S
static const char *const _2S
Name extension for 2D counts.
Definition: JCalibrateK40.hh:33
JCALIBRATE::weights_hist_t
static const char *const weights_hist_t
Histogram naming.
Definition: JCalibrateK40.hh:27
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JCALIBRATE::coincidenceP
double coincidenceP(double E1, double E2, double ED, int M_min, int M_max)
Coincidence probability of two PMTs.
Definition: JCalibrateK40.hh:107
JMathToolkit.hh
JDETECTOR::JModule::getPMT
const JPMT & getPMT(const int index) const
Get PMT.
Definition: JModule.hh:173
JCALIBRATE::WB_t
static const char *const WB_t
Named bin for value of TMax_ns in JCalibrateK40.
Definition: JCalibrateK40.hh:31
JDETECTOR::JModule
Data structure for a composite optical module.
Definition: JModule.hh:49
JCALIBRATE::W1_overall_t
static const char *const W1_overall_t
Named bin for duration of the run.
Definition: JCalibrateK40.hh:29
std::pair
Definition: JSTDTypes.hh:15
JTOOLS::JCombinatorics
Auxiliary class to convert pair of indices to unique index and back.
Definition: JCombinatorics.hh:22
JCALIBRATE::JPairwiseComparator::JPairwiseComparator
JPairwiseComparator(const JModule &module, const double epsilon=1.0e-5)
Constructor.
Definition: JCalibrateK40.hh:52
JCALIBRATE::pair_type
JCombinatorics::pair_type pair_type
Definition: JCalibrateK40.hh:39
JCALIBRATE::JPairwiseComparator::getDot
double getDot(const pair_type &pair) const
Get cosine of space angle between PMT axes.
Definition: JCalibrateK40.hh:85
std
Definition: jaanetDictionary.h:36
JCombinatorics.hh
JCALIBRATE::_1B
static const char *const _1B
Name extension for 1D background.
Definition: JCalibrateK40.hh:34
JCALIBRATE::JPairwiseComparator::__epsilon
const double __epsilon
Definition: JCalibrateK40.hh:93
JCALIBRATE::JPairwiseComparator::__module
const JModule & __module
Definition: JCalibrateK40.hh:92
JCALIBRATE::JPairwiseComparator
Auxiliary class to sort pairs of PMT addresses within optical module.
Definition: JCalibrateK40.hh:45
JCALIBRATE::JPairwiseComparator::operator()
bool operator()(const pair_type &first, const pair_type &second) const
Comparison of two pairs of PMT addresses.
Definition: JCalibrateK40.hh:66
JCALIBRATE::WS_t
static const char *const WS_t
Named bin for time residual bin width.
Definition: JCalibrateK40.hh:30
JCALIBRATE::_2R
static const char *const _2R
Name extension for 2D rate.
Definition: JCalibrateK40.hh:36
JMATH::getDot
double getDot(const JFirst_t &first, const JSecond_t &second)
Get dot product of objects.
Definition: JMathToolkit.hh:131