82{
86
88 JLimit_t& numberOfEvents = inputFile.getLimit();
90 string detectorFile;
91 Double_t TMax_ns;
92 Double_t WBin_ns;
93 double R;
95 size_t recycling;
96 ULong_t seed;
98
99 try {
100
101 JParser<> zap(
"Auxiliary program to determine PMT parameters from OMGsim data.");
102
103 zap[
'f'] =
make_field(inputFile,
"input file.");
106 zap[
'a'] =
make_field(detectorFile,
"detector file.");
107 zap[
'T'] =
make_field(TMax_ns,
"time window [ns].") = 20.0;
108 zap[
'W'] =
make_field(WBin_ns,
"bin width [ns].") = 1.0;
109 zap[
'R'] =
make_field(R,
"radioactivity [Bq]");
111 zap[
'N'] =
make_field(recycling,
"recycling of events") = 1;
114
115 zap(argc, argv);
116 }
117 catch(const exception &error) {
118 FATAL(error.what() << endl);
119 }
120
121
122 gRandom->SetSeed(seed);
123
124
126
127 try {
129 }
132 }
133
135 FATAL(
"Wrong number of modules " <<
detector.size() << endl);
136 }
137
138
140
142
144
145 const Int_t nx = combinatorics.getNumberOfPairs();
146 const Double_t xmin = -0.5;
147 const Double_t xmax = nx - 0.5;
148
149 const Double_t ymin = -floor(TMax_ns) - 0.5*WBin_ns;
150 const Double_t ymax = +floor(TMax_ns) + 0.5*WBin_ns;
151 const Int_t ny = (Int_t) ((ymax - ymin) / WBin_ns);
152
154
155 h2r.Sumw2();
156
157 TH1D h1("M", NULL, 101, -0.5, 100.5);
158
160
161 size_t slewing = module.size();
162
163
164
166
167 for (size_t i = 0; i != module.size(); ++i) {
168
169 router.put(module[i].getID(), i);
170
172
174
175 }
176
178 }
179
180 if (slewing == 0)
182 else if (slewing == module.size())
184 else
185 FATAL(
"Inconsistent PMT slewing options " << slewing << endl);
186
188
189
190 double numberOfPrimaries = 0.0;
191
192 try {
193
194 STATUS(
"Extracting header data... " << flush);
195
197
198 const JHead buffer(header);
199
201 numberOfPrimaries = buffer.norma.numberOfPrimaries;
202 else
204
206
207 } catch(const exception& error) {
208 FATAL(error.what() << endl);
209 }
210
211 if (numberOfPrimaries == 0.0) {
212 FATAL(
"Number of primaries " << numberOfPrimaries << endl);
213 }
214
215
217
219
221
224 }
225
226 const Evt* evt = inputFile.
next();
227
228 if (evt->
mc_hits.size() >= 2u) {
229
231
232 for (
const auto& hit : evt->
mc_hits) {
233
234 if (router.has(hit.pmt_id)) {
235
236 const int pmt = router.get(hit.pmt_id);
237
238 input[pmt].push_back(
JPMTSignal(hit.t, hit.a));
239 }
240 }
241
242 for (size_t i = 0; i != recycling; ++i) {
243
245
246 for (size_t pmt = 0; pmt != module.size(); ++pmt) {
247
248 if (!input[pmt].empty()) {
249
251
253
254 for (const auto& hit : output) {
255 buffer.push_back(
hit_type(pmt, hit));
256 }
257 }
258 }
259
260 if (buffer.size() >= 2u) {
261
262 sort(buffer.begin(), buffer.end());
263
265
267
268 for (++q; q != buffer.end() && q->getT() - p->getT() <= TMax_ns; ++q) {}
269
271
273
275
276 if (M >= 2) {
277 h1.Fill(M);
278 }
279
280 sort(p, q);
281 }
282
283 p = q;
284 }
285
287
288 cout << "hit:";
289
290 for (const auto& hit : buffer) {
291 cout <<
' ' << setw(2) << hit.pmt <<
' ' <<
FIXED(10,1) << hit.getT() <<
' ' <<
FIXED(3,0) << hit.getToT();
292 }
293
294 cout << endl;
295 }
296
297 for (vector<hit_type>::const_iterator p = buffer.begin(); p != buffer.end(); ++p) {
298 for (vector<hit_type>::const_iterator q = buffer.begin(); p != q; ++q) {
299 h2r.Fill((double) combinatorics.getIndex(p->pmt,q->pmt),
301 }
302 }
303 }
304 }
305 }
306 }
308
309
310
311 for (int ix = 0; ix <= h2r.GetXaxis()->GetNbins() + 1; ++ix) {
312 h2r.SetBinContent(ix, 0, 0.0); h2r.SetBinContent(ix, h2r.GetYaxis()->GetNbins() + 1, 0.0);
313 h2r.SetBinError (ix, 0, 0.0); h2r.SetBinError (ix, h2r.GetYaxis()->GetNbins() + 1, 0.0);
314 }
315
316 for (int iy = 0; iy <= h2r.GetYaxis()->GetNbins() + 1; ++iy) {
317 h2r.SetBinContent(0, iy, 0.0); h2r.SetBinContent(h2r.GetXaxis()->GetNbins() + 1, iy, 0.0);
318 h2r.SetBinError (0, iy, 0.0); h2r.SetBinError (h2r.GetXaxis()->GetNbins() + 1, iy, 0.0);
319 }
320
321
322 for (Int_t ix = 1; ix <= h2r.GetXaxis()->GetNbins(); ++ix) {
323 for (Int_t iy = 1; iy <= h2r.GetYaxis()->GetNbins(); ++iy) {
324 if (h2r.GetBinError(ix,iy) == 0.0) {
325 h2r.SetBinError(ix, iy, 1.0);
326 }
327 }
328 }
329
330 h2r.Scale(R / (numberOfPrimaries * recycling * WBin_ns));
331 h1 .Scale(R / (numberOfPrimaries * recycling));
332
333 out << h1 << h2r;
334
335 out.Write();
336 out.Close();
337}
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
#define MAKE_CSTRING(A)
Make C-string.
const JCalibration & getCalibration() const
Get calibration.
Data structure for a composite optical module.
Template data structure for PMT I/O.
Auxiliary class for map of PMT parameters.
const JPMTParameters & getPMTParameters(const JPMTIdentifier &id) const
Get PMT parameters.
Data structure for PMT parameters.
bool slewing
time slewing of analogue signal
int getID() const
Get identifier.
Utility class to parse command line options.
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
static bool getSlewing()
Get slewing option.
static void setSlewing(const bool slewing)
Set slewing option.
static const char *const _2R
Name extension for 2D rate measured.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
KM3NeT DAQ data structures and auxiliaries.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
std::vector< Hit > mc_hits
MC: list of MC truth hits.
Auxiliary data structure for floating point format specification.
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Transmission with position.
Auxiliary class to sort pairs of PMT addresses within optical module.
PMT analogue signal processor.
Data structure for PMT analogue signal.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary class for defining the range of iterations of objects.
static counter_type max()
Get maximum counter value.