32{
35
36 string inputFile;
38 double E_GeV;
39 double R_Hz;
42
43 try {
44
45 JParser<> zap(
"Demonstration program to plot RMS of arrival time of first hit as a function of the minimal distance of approach of a muon to the PMT.");
46
49 zap[
'E'] =
make_field(E_GeV,
"muon energy [GeV]");
50 zap[
'R'] =
make_field(R_Hz,
"background rate [Hz]");
51 zap[
'D'] =
make_field(dir,
"(theta, phi) of PMT [rad]");
53
54 zap(argc, argv);
55 }
56 catch(const exception &error) {
57 FATAL(error.what() << endl);
58 }
59
60
66
67 JFunction1D_t::JSupervisor supervisor(new JFunction1D_t::JDefaultResult(zero));
68
69 const JPDFType_t pdf_t[] = { DIRECT_LIGHT_FROM_MUON,
70 SCATTERED_LIGHT_FROM_MUON,
71 DIRECT_LIGHT_FROM_EMSHOWERS,
72 SCATTERED_LIGHT_FROM_EMSHOWERS };
73
74 const int N = sizeof(pdf_t) / sizeof(pdf_t[0]);
75
76 JPDF_t pdf[N];
77
78 for (int i = 0; i != N; ++i) {
79
80 try {
81
82 const string file_name = getFilename(inputFile, pdf_t[i]);
83
84 NOTICE(
"loading input from file " << file_name <<
"... " << flush);
85
86 pdf[i].load(file_name.c_str());
87
89 }
92 }
93
94 pdf[i].setExceptionHandler(supervisor);
95 }
96
97
99
100 if (X.empty()) {
101 X.push_back( 5.0);
102 X.push_back( 15.0);
103 X.push_back( 25.0);
104 X.push_back( 35.0);
105 X.push_back( 45.0);
106 X.push_back( 55.0);
107 X.push_back( 65.0);
108 X.push_back( 75.0);
109 X.push_back( 85.0);
110 X.push_back( 95.0);
111 }
112
113
115
117
118 for (vector<double>::const_iterator i = X.begin(); i != X.end(); ++i) {
119
120 ostringstream os;
121
122 os << "t[" << *i << "]";
123
124 buffer.push_back(new TH1D(os.str().c_str(), NULL, 5000, -250.0, +250.0));
125 }
126
128
129 {
130 vector<double>::const_iterator
j = X.begin();
131 vector<double>::const_iterator i =
j++;
132
133 x.push_back(*i - 0.5*(*j-*i));
134
135 for (;
j != X.end(); ++i, ++
j)
136 x.push_back(0.5*(*i+*j));
137
138 --i;
140
141 x.push_back(*j + 0.5*(*j-*i));
142 }
143
144 TH1D rms("rms", NULL, X.size(), &x[0]);
145
146
147 JFunction1D_t::result_type p[4];
148
150
152
153 const double Tmin = -250.0;
154 const double Tmax = +250.0;
155
157
158 for (size_t i = 0; i != X.size(); ++i) {
159
160 TH1D* h = buffer[i];
161 const double R = X[i];
162
164
165 for (
int j = 1;
j <= h->GetNbinsX(); ++
j) {
166
167 const double t1 = h->GetBinCenter(j);
168
170
172
173 for (int k = 0; k != 4; ++k) {
175 }
176
177
178 const double v =
179 p[0].v +
180 p[1].v +
181 p[2].v * E_GeV +
182 p[3].v * E_GeV +
183 R_Hz * 1e-9 * (t1 - Tmin);
184
185
186 const double V =
187 p[0].V +
188 p[1].V +
189 p[2].V * E_GeV +
190 p[3].V * E_GeV +
191 R_Hz * 1e-9 * (Tmax - Tmin);
192
193
195 p[0].f +
196 p[1].f +
197 p[2].f * E_GeV +
198 p[3].f * E_GeV +
199 R_Hz * 1e-9;
200
201 const double W = exp(-v) *
y / (1.0 - exp(-V));
202
204
205 zsp[t1] = W;
206
207 h->SetBinContent(j,W);
208 }
209
210 zsp.compile();
211
212 try {
213
215
216 const double sig =
result.getFWHM() * 0.5 / sqrt(2.0*log(2.0));
217
218 rms.Fill(R, sig);
219
220 NOTICE(
"integral " << R <<
' ' <<
result.getIntegral() << endl);
221 }
222 catch(const exception&) {}
223 }
224
225 if (n != 0) {
226
227 const float w = 1.0 / (float) n;
228
229 if (
debug > notice_t) {
230 timer.
print(cout, w);
231 }
232 }
233
234 out.Write();
235 out.Close();
236}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Auxiliary class for CPU timing and usage.
void print(std::ostream &out, const JScale_t scale=milli_t) const
Print timer data.
Data structure for angles in three dimensions.
double getTheta() const
Get theta angle.
double getPhi() const
Get phi angle.
virtual const char * what() const override
Get error message.
Utility class to parse command line options.
Multi-dimensional PDF table for arrival time of Cherenkov light.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).