1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz 3/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MMath
|
---|
28 | //
|
---|
29 | /////////////////////////////////////////////////////////////////////////////
|
---|
30 | #include "MMath.h"
|
---|
31 |
|
---|
32 | ClassImp(MMath);
|
---|
33 |
|
---|
34 | using namespace std;
|
---|
35 |
|
---|
36 | // --------------------------------------------------------------------------
|
---|
37 | //
|
---|
38 | // Calculate Significance as
|
---|
39 | // significance = (s-b)/sqrt(s+k*k*b) mit k=s/b
|
---|
40 | //
|
---|
41 | // s: total number of events in signal region
|
---|
42 | // b: number of background events in signal region
|
---|
43 | //
|
---|
44 | Double_t MMath::Significance(Double_t s, Double_t b)
|
---|
45 | {
|
---|
46 | const Double_t k = b==0 ? 0 : s/b;
|
---|
47 | const Double_t f = s+k*k*b;
|
---|
48 |
|
---|
49 | return f==0 ? 0 : (s-b)/TMath::Sqrt(f);
|
---|
50 | }
|
---|
51 |
|
---|
52 | // --------------------------------------------------------------------------
|
---|
53 | //
|
---|
54 | // calculates the significance according to Li & Ma
|
---|
55 | // ApJ 272 (1983) 317, Formula 17
|
---|
56 | //
|
---|
57 | // s // s: number of on events
|
---|
58 | // b // b: number of off events
|
---|
59 | // alpha = t_on/t_off; // t: observation time
|
---|
60 | //
|
---|
61 | Double_t MMath::SignificanceLiMa(Double_t s, Double_t b, Double_t alpha)
|
---|
62 | {
|
---|
63 | const Double_t sum = s+b;
|
---|
64 |
|
---|
65 | if (sum<=0 || alpha<=0)
|
---|
66 | return 0;
|
---|
67 |
|
---|
68 | const Double_t l = s*TMath::Log(s/sum*(alpha+1)/alpha);
|
---|
69 | const Double_t m = b*TMath::Log(b/sum*(alpha+1) );
|
---|
70 |
|
---|
71 | return TMath::Sqrt((l+m)*2);
|
---|
72 | }
|
---|