Jpp 21.0.0-rc.1-88-g0130508c4
the software that should make you happy
Loading...
Searching...
No Matches
JRateK40.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <map>
4
5#include "TROOT.h"
6#include "TFile.h"
7#include "TH1D.h"
8#include "TFormula.h"
9
10#include "JROOT/JRootToolkit.hh"
11
13
14#include "JPhysics/KM3NeT.hh"
15#include "JPhysics/KM3NeT2D.hh"
16#include "JPhysics/Antares.hh"
17#include "JPhysics/JPDF.hh" //for module radius
18#include "JPhysics/JPDFSupportkit.hh" //for absorption tuning
20
21#include "Jeep/JContainer.hh"
22#include "Jeep/JParser.hh"
23#include "Jeep/JMessage.hh"
24
25
26
27/**
28 * \file
29 *
30 * Example program to calculate singles rate.\n
31 * The calculation is based on Antares internal note ANTARES-PHYS-2006-005 by Juergen Brunner.\n
32 * According Antares internal note ANTARES-PHYS-2012-013, the absorption length is used (and not the attenuation length).
33 * \author mdejong, vkulikovskiy
34 */
35int main(int argc, char* argv[])
36{
37 using namespace std;
38 using namespace JPP;
39
40 typedef JContainer< map<double, double> > container_type;
41
42 string outputFile;
43 double bequerel;
44 JPMTParameters parameters;
45 container_type fd;
46 TFormula f1;
47 int debug;
48 JAbsorptionLength absorptionLength;
49
50 try {
51
52 JProperties properties = parameters.getProperties();
53
54 properties.insert(gmake_property(absorptionLength));
55
56 JParser<> zap("Example program to calculate singles rate.");
57
58 zap['o'] = make_field(outputFile) = "k40.root";
59 zap['b'] = make_field(bequerel, "radioactivity") = 14687.6; // [m^-3 s^-1] 14527.6+(40*4) https://git.km3net.de/common/jpp/-/merge_requests/859
60 zap['P'] = make_field(properties, "PMT parameters") = JPARSER::initialised();
61 zap['f'] = make_field(fd, "filter data") = JPARSER::initialised();
62 zap['F'] = make_field(f1, "filter function") = JPARSER::initialised();
63
64 zap['d'] = make_field(debug) = 3;
65
66 zap(argc, argv);
67 }
68 catch(const exception &error) {
69 FATAL(error.what() << endl);
70 }
71
72 using namespace NAMESPACE;
73
75
76 for (const auto& i : fd) {
77 g1[i.first] = i.second;
78 }
79
80 g1.compile();
81 g1.setExceptionHandler(new typename JPolint1Function1D_t::JDefaultResult(JMATH::zero));
82
83 const JPMTAnalogueSignalProcessor cpu(parameters);
84
85 //For Geant4 inputs see https://git.km3net.de/vkulikovskiy/g4ly
86
87 const double wmin = 280.0; // minimal wavelength [nm]
88 const double wmax = 700.0; // maximal wavelength [nm]
89 const double ng = 47.11; // Geant4 simulations of K40 decays in (wmin,wmax) window
90 const int npe = 1; // number of photo-electrons for each decay
91 const double cpow = 2.156; // 1/lambda^cpow shape of the Cherenkov photons distribution is a fit from Geant4
92
93 TFile out(outputFile.c_str(), "recreate");
94
95 const double dx = 1.5; // [nm]
96 const int nx = (int) ((wmax - wmin) / dx);
97
98 TH1D h0("h0", NULL, nx, wmin, wmax);
99 TH1D h1("h1", NULL, nx, wmin, wmax);
100
101
102 double R[] = { 0.0, 0.0 };
103 double W[] = { 0.0, 0.0 };
104
105 const string option[] = { "1Dx1D", "2D" };
106
107 for (double x = -1.0, dx = 0.02; x <= +1.0; x += dx) {
108 W[0] += getPhotocathodeArea() * getAngularAcceptance(x) * dx;
109 }
110
111 double Y = 1.0;
112
113 Y *= cpow - 1.0;
114 Y /= pow(wmin, 1.0 - cpow) - pow(wmax, 1.0 - cpow);
115
116 Y *= bequerel * ng;
117
118 Y *= cpu.getSurvivalProbability(npe);
119 Y *= 0.5e-3;
120
121
122 double A[] = { 0.0, 0.0 };
123
124 for (int ix = 1; ix <= h0.GetXaxis()->GetNbins(); ++ix) {
125
126 const double w = h0.GetXaxis()->GetBinCenter(ix);
127 const double dw = h0.GetXaxis()->GetBinWidth (ix);
128
129 W[1] = 0.0;
130
131 for (double x = -1.0, dx = 0.02; x <= +1.0; x += dx) {
132 W[1] += KM3NET2D::getPhotocathodeArea2D(x, w) * dx;
133 }
134
135 double U = Y / pow(w,cpow);
136
137 if (!g1.empty()) {
138 U *= g1(w);
139 }
140 if (f1.IsValid()) {
141 U *= f1.Eval(w);
142 }
143
144 R[0] += W[0] * U * dw * getQE(w) * absorptionLength.getAbsorptionLength(w);
145 R[1] += W[1] * U * dw * absorptionLength.getAbsorptionLength(w);
146 A[0] += W[0] * U * dw * getQE(w);
147 A[1] += W[1] * U * dw;
148
149 h0.SetBinContent(ix, W[0] * U * getQE(w) * absorptionLength.getAbsorptionLength(w));
150 h1.SetBinContent(ix, W[1] * U * absorptionLength.getAbsorptionLength(w));
151 }
152 double labs[] = { 0.0, 0.0 };
153
154 cout << "PMT survival probability: " << cpu.getSurvivalProbability(npe) << endl;
155
156 for (int i = 0; i != sizeof(R)/sizeof(R[0]); ++i) {
157
158 labs[i] = R[i]/A[i];
159
160 const double corr = R[i]*(1.0-exp(-MODULE_RADIUS_M/labs[i])); //rate due to coincidences within the DOM
161
162 cout << setw(6) << left << option[i] + ":" << right
163 << " rate " << FIXED(7,3) << R[i] << " [kHz]"
164 << " corrected " << FIXED(7,3) << R[i] - corr << " [kHz]"
165 << " <l_abs> " << FIXED(7,3) << labs[i] << " [m]" << endl;
166 }
167
168 out.Write();
169 out.Close();
170}
Properties of Antares PMT and deep-sea water.
Container I/O.
string outputFile
double getAngularAcceptance(const double x)
Angular acceptence of PMT.
Definition JDrawLED.cc:68
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:74
PMT analogue signal processor.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2140
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Double_t g1(const Double_t x)
Function.
Definition JQuantiles.cc:25
Properties of KM3NeT PMT and deep-sea water.
Properties of KM3NeT PMT and deep-sea water.
Data structure for PMT parameters.
JProperties getProperties(const JEquationParameters &equation=JPMTParameters::getEquationParameters())
Get properties of this class.
Utility class to parse parameter values.
Utility class to parse command line options.
Definition JParser.hh:1697
Template class for polynomial interpolation in 1D.
Definition JPolint.hh:1095
int main()
static const JZero zero
Function object to assign zero value.
Definition JZero.hh:105
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
static const JPhotocathodeArea2D getPhotocathodeArea2D
Function object for effective photo-cathode area of PMT.
Definition KM3NeT2D.hh:5235
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
virtual double getSurvivalProbability(const int NPE) const override
Probability that a hit survives the simulation of the PMT.
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Definition JContainer.hh:42
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:67
Auxiliary data structure to customize absorption length.
static double getAbsorptionLength(const double lambda)
Get absorption length.
void setExceptionHandler(const JSupervisor &supervisor)
Set the supervisor for handling of exceptions.