89{
93
95 JLimit_t& numberOfEvents = inputFile.getLimit();
99 double TMaxLocal_ns;
100 int numberOfTimeslices;
103 double Pmin;
107
108 try {
109
110 JParser<> zap(
"Example program to search for correlations between triggered events and timeslice data.");
111
117 zap[
'T'] =
make_field(TMaxLocal_ns,
"time window for local coincidences (L1),") = 20.0;
118 zap[
'N'] =
make_field(numberOfTimeslices,
"time slice difference between triggered event and L1.") = 100;
121 zap[
'p'] =
make_field(Pmin,
"minimal probability for background to be signal.") = 1.0e-7;
125
127 }
128 catch(const exception& error) {
130 }
131
132
134
135 try {
137 }
140 }
141
144 }
145
147
149 const double BOOST = 20.0;
151
153
155
159
161
165
167
169
171
173
174 if (selector == "") {
175
181 } else {
183 }
184
185 NOTICE(
"Selected class " << ps->getClassName() <<
endl);
186
187 } else {
188
189 ps = zmap[selector];
190
191 ps->configure(inputFile);
192 }
193
194 ps->setLimit(inputFile.getLimit());
195
197
198 map_type buffer;
199
201
202 if (in.getCounter()%1000 == 0) {
204 }
205
207
208
209
210 double t0 = 0.0;
212
214 if (router.hasModule(
hit->getModuleID())) {
217 }
218 }
219
222
223 buffer[event->getFrameIndex()].push_back(t0);
224 }
226
227
228 while (ps->hasNext()) {
229
230 if (ps->getCounter()%1000 == 0) {
232 }
233
235
236 map_type::const_iterator p = buffer.lower_bound(timeslice->
getFrameIndex() - numberOfTimeslices);
237 map_type::const_iterator q = buffer.upper_bound(timeslice->
getFrameIndex() + numberOfTimeslices);
238
240
241 for (map_type::const_iterator i = p; i != q; ++i) {
243 }
244
246 continue;
247 }
248
249 for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
250
251 if (router.hasModule(frame->getModuleID())) {
252
254
255 buildL1(*frame, router.getModule(frame->getModuleID()),
back_inserter(data));
256
258
260
262
264
266
267 for (map_type::const_iterator i = p; i != q; ++i) {
268 for (map_type::mapped_type::const_iterator t0 = i->second.begin(); t0 != i->second.end(); ++t0) {
269 h1->Fill(t2 - *t0);
270 }
271 }
272
273 t1 = t2;
274 }
275 }
276 }
277 }
278 }
280
281
282
283
284 TF1 f1("f1", "[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2])) + [3]");
285
286 string option = "L";
287
289 option += "Q";
290 }
291
292
294
296
297 if (
module->getFloor() != 0) {
298
299 status[module->getID()] = DEFAULT;
300
302
303 if (p ==
manager.end() || p->second->GetEntries() == 0) {
304
305 status[module->getID()] = NODATA;
306
307 continue;
308 }
309
310 TH1D* h1 = p->second;
311
312
313
318
319 for (int i = 1; i != h1->GetNbinsX(); ++i) {
320
323
327 }
328
330 }
331
332 ymin /= h1->GetNbinsX();
333
334 f1.SetParameter(0,
ymax);
335 f1.SetParameter(1, x0);
337 f1.SetParameter(2, sigma);
338 else
340 f1.SetParameter(3,
ymin);
341
342 for (
Int_t i = 0; i != f1.GetNpar(); ++i) {
343 f1.SetParError(i, 0.0);
344 }
345
346
347
348 h1->Fit(&f1, option.c_str(), "same", x0 - 5 * sigma, x0 + 5 * sigma);
349
351 f1.GetParameter(0) >= f1.GetParameter(3)) {
352
353 status[module->getID()] = IN_SYNC;
354 }
355
356 double fm =
fmod(f1.GetParameter(1), getFrameTime());
357
360
363 <<
FIXED(15,3) << f1.GetParameter(1) <<
' '
364 <<
FIXED(12,3) << f1.GetParameter(0) <<
' '
365 <<
FIXED(12,3) << f1.GetParameter(3) <<
' '
368
369
370
373
374 for (
Int_t i = 1, ns = -(numberOfTimeslices + 1); i <= h1->GetNbinsX(); ++i) {
375
378
380 ++ns;
381 }
382
386 bg[ns].put(y);
387 }
388
390
391 const Double_t y = getBackground(i->second, bg[i->first]);
392 const Double_t P = TMath::PoissonI(i->second.getTotal(), y);
393
395 cout <<
"Module/peak " <<
setw(10) <<
module->getID() << ' '
396 << setw(4) << i->first << ' '
397 << "["
398 << FIXED(15,1) << i->first * getFrameTime() - TMax_ns
399 << ","
400 << FIXED(15,1) << i->first * getFrameTime() + TMax_ns
401 << "]"
402 << " S/N = "
403 << FIXED(7,1) << i->second.getTotal() << " / "
404 << FIXED(7,1) << y << ' '
405 << SCIENTIFIC(12,3) << P << ' '
406 << (i->second.getTotal() > y && P < Pmin && i->first != 0 ? "***" : "") << endl;
407 }
408
409 if (i->second.getTotal() > y && P < Pmin)
410 ++i;
411 else
413 }
414
415 if (!(
sn.size() == 1 &&
416 sn.begin()->first == 0)) {
417
418 status[module->getID()] = (sn.size() == 1 ? OUT_SYNC : ERROR);
419
420 ERROR(
"Module/error "
422 <<
"number of peaks " <<
sn.size() <<
' '
423 <<
"peak " << (
sn.size() == 1 ?
MAKE_CSTRING(
sn.begin()->first) :
"?") <<
' '
425 }
426 }
427 }
428
430
432
434
437
438 NOTICE(
"Module " <<
setw(8) << i->first <<
" set out-of-sync." <<
endl);
439
440 JModule&
module = detector.getModule(router.getAddress(i->first));
441
442 module.getStatus().set(MODULE_OUT_OF_SYNC);
443
444 for (JModule::iterator pmt =
module.begin(); pmt !=
module.end(); ++pmt) {
446 }
447 }
448 }
449
451 }
452
455 }
456
459
463 }
467 }
468 }
469
471
473
474 return 0;
475}
#define DEBUG(A)
Message macros.
#define QAQC(A)
QA/QC output macro.
int qaqc
QA/QC file descriptor.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
#define MAKE_CSTRING(A)
Make C-string.
Simple wrapper around JModuleRouter class for direct addressing of PMT data in detector data structur...
Data structure for a composite optical module.
Template definition of a multi-dimensional oscillation probability interpolation table.
Template definition for direct access of elements in ROOT TChain.
int getFrameIndex() const
Get frame index.
JTriggerCounter_t next()
Increment trigger counter.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const char * getTime()
Get current local time conform ISO-8601 standard.
KM3NeT DAQ data structures and auxiliaries.
double getFrameTime()
Get frame time duration.
double getMaximalTime(const double R_Hz)
Get maximal time for given rate.
std::map< int, range_type > map_type
static const int OUT_OF_SYNC
Enable (disable) synchronous signal from this PMT if this status bit is 0 (1);.
Auxiliary data structure for floating point format specification.
Transmission with position.
status_type getStatus(const JType< status_type > &type) const
Get status.
Auxiliary class to select ROOT class based on class name.
Auxiliary class for defining the range of iterations of objects.
static counter_type max()
Get maximum counter value.
Auxiliary data structure for L1 build parameters.