37{
40
42
45 double E;
46 double R;
48 int numberOfEvents;
51
52 try {
53
54 JParser<> zap(
"Program to verify generation of arrival times of Cherenkov photons from a muon using tabulated CDF.");
55
58 zap[
'E'] =
make_field(E,
"muon energy [GeV]") = 1.0;
59 zap[
'R'] =
make_field(R,
"distance of approach [m]");
60 zap[
'D'] =
make_field(dir,
"(theta, phi) of PMT [rad]");
64
65 zap(argc, argv);
66 }
67 catch(const exception& error) {
68 FATAL(error.what() << endl);
69 }
70
71
73
74
79
80 const int N = inputFile.size();
81
82 int type[N];
83 JCDF_t cdf [N];
84
85 try {
86
87 for (int i = 0; i != N; ++i) {
88
89 NOTICE(
"loading input from file " << inputFile[i] <<
"... " << flush);
90
92
93 cdf [i].load(inputFile[i].c_str());
94
96 }
97 }
100 }
101
102
104
105 for ( ; ; ) {
106
108
109 cout << "> " << flush;
111
112 cout << " --> ";
113
114 for (int i = 0; i != N; ++i) {
115
116 try {
117
120
122 npe *= E;
125 }
126
127 cout <<
' ' <<
FIXED(6,2) << t <<
' ' <<
FIXED(5,2) << npe;
128 }
129 catch(const exception& error) {
130 ERROR(error.what() << endl);
131 }
132 }
133
134 cout << endl;
135 }
136
137 return 0;
138 }
139
140
141 int function = 0;
142
143 if (inputFile.size() == 1 &&
getPDFType(inputFile[0]) == DIRECT_LIGHT_FROM_MUON) {
144 function = 1;
145 }
146
147 TH1D* h0 = NULL;
148
149
150
151 const double t0 = 0.0;
152
154
156
158
159 {
160 for ( ;
x < -10.0;
x += 5.0) { X.push_back(t0 + x); }
161 for ( ;
x < +20.0;
x += 1.0) { X.push_back(t0 + x); }
162 for ( ;
x < +50.0;
x += 2.0) { X.push_back(t0 + x); }
163 }
164 if (function != 1) {
165 for ( ;
x < +100.0;
x += 5.0) { X.push_back(t0 + x); }
166 for ( ;
x < +250.0;
x += 10.0) { X.push_back(t0 + x); }
167 for ( ;
x < +500.0;
x += 25.0) { X.push_back(t0 + x); }
168 for ( ;
x < +900.0;
x += 50.0) { X.push_back(t0 + x); }
169 }
170
171 h0 = new TH1D("h0", NULL, X.size() - 1, X.data());
172
173 } else {
174
176 }
177
178 h0->Sumw2();
179
180 JManager<int, TH1D> H1(new TH1D("h1[%]", NULL, 100000, 0.0, +1.0));
181
182 for (int i = 0; i != N; ++i) {
183
184 for (
int j = 1;
j <= H1->GetNbinsX(); ++
j) {
185
186 try {
187
188 const double x = H1->GetBinCenter(j);
189 const double t = cdf[i].getTime(R, dir.
getTheta(), dir.
getPhi(), x);
190
191 H1[i]->SetBinContent(j, t);
192 }
193 catch(const exception& error) {
194 ERROR(error.what() << endl);
195 }
196 }
197 }
198
199 if (numberOfEvents > 0) {
200
202
204
205 for (int counter = 0; counter != numberOfEvents; ++counter) {
206
207 if (counter%1000== 0) {
209 }
210
212
213 for (int i = 0; i != N; ++i) {
214
215 try {
216
218
220 npe *= E;
223 }
224
225 for (int j = gRandom->Poisson(npe); j != 0; --j) {
226
227 const double x = gRandom->Rndm();
228 const double t = cdf[i].getTime(R, dir.
getTheta(), dir.
getPhi(), x);
229
230 h0->Fill(t + t0);
231 }
232 }
233 catch(const exception& error) {
234 NOTICE(error.what() << endl);
235 }
236 }
237
239 }
241
242 const double W = 1.0 / (double) numberOfEvents;
243
245 timer.
print(cout, W);
246 }
247
249 }
250
252
253 out << *h0 << H1;
254
255 out.Write();
256 out.Close();
257}
#define DEBUG(A)
Message macros.
#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 CDF table for arrival time of Cherenkov light.
void convertToPDF(TH1 &h1, const std::string &option="NW", const double factor=1.0)
Convert 1D histogram to PDF.
double getDeltaRaysFromMuon(const double E, const JRange< double > T_GeV=JRange< double >(DELTARAY_TMIN, DELTARAY_TMAX))
Equivalent EM-shower energy due to delta-rays per unit muon track length.
bool is_deltarays(const int pdf)
Test if given PDF type corresponds to Cherenkov light from delta-rays.
bool is_bremsstrahlung(const int pdf)
Test if given PDF type corresponds to Cherenkov light from Bremsstrahlung.
int getPDFType(const std::string &file_name)
Get PDF type.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.