65 JLimit_t& numberOfEvents = inputFile.getLimit();
74 bool globalOutputOnly;
82 JParser<> zap(
"Example program to examine rates as a function of time on ms-level timescales.");
85 zap[
'o'] =
make_field(outputFile) =
"ripple.root";
86 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
88 zap[
'C'] =
make_field(selector) = getROOTClassSelection<JDAQTimesliceTypes_t>();
89 zap[
'T'] =
make_field(TMax_ns,
"Time window for local coincidences (if 0 run in L0 mode)") = 0.0;
90 zap[
'S'] =
make_field(TMaxSelf_ns,
"Time window for merge of double pulses") = 10.0;
91 zap[
'B'] =
make_field(binWidth_ms,
"Bin width (experimental)") = 1;
92 zap[
'V'] =
make_field(backVeto,
"Apply retroactive veto.");
93 zap[
'D'] =
make_field(mode2D,
"L1 mode: create 2D histogram with time differences of coincidences (heavy memory usage, ignored if TMax_ns = 0)");
94 zap[
'O'] =
make_field(globalOutputOnly,
"Write only aggregate histograms");
95 zap[
'M'] =
make_field(multiplicityRange,
"L1 mode: multiplicity range (ignored if TMax_ns = 0)") =
JRange<int>(2,31);
102 catch(
const exception &error) {
103 FATAL(error.what() << endl);
109 FATAL(
"Frame time must be an integer multiple of bin width");
115 load(detectorFile, detector);
129 pts->configure(inputFile);
131 int fEnd = pts->rbegin()->getFrameIndex();
132 int fStart = pts->begin( )->getFrameIndex();
134 if (fEnd > inputFile.getUpperLimit()) {
135 fEnd = fStart + inputFile.getUpperLimit();
139 double tStart_ms = (fStart - 1) *
getFrameTime() / 1.0e6;
141 int runNumber = pts->begin()->getRunNumber();
143 TString runTag = Form(
"%d" , runNumber);
145 double tRun_ms = tEnd_ms - tStart_ms;
147 NOTICE(
"START/END/DURATION [s]: " << tStart_ms / 1000 <<
" " << tEnd_ms / 1000 <<
" " << tRun_ms / 1000 << endl);
168 int nx = (tEnd_ms - tStart_ms) / binWidth_ms;
170 int x_inf = tStart_ms;
172 JManager_t RT_DOM(
new TH1F(
"RT_%", NULL, nx , x_inf, tEnd_ms));
173 JManager_t NC_DOM(
new TH1F(
"NC_%", NULL, nx / 100, x_inf, tEnd_ms));
175 TString rt_tag = runTag + TString(
".RT_DET_%");
176 TString nc_tag = runTag + TString(
".NC_DET_%");
178 JManager_t RT_DET(
new TH1F(rt_tag, NULL, nx, x_inf, tEnd_ms));
179 JManager_t NC_DET(
new TH1F(nc_tag, NULL, nx / 100, x_inf, tEnd_ms));
190 if (nx >= max_size) {
191 FATAL(
"2D histogram size not supported by ROOT file output; limit input size (-n) below " << floor(max_size / 100.0) << endl);
194 TString rt2d_tag = runTag + TString(
".RT2D_DET");
196 hT =
new h2d_t(rt2d_tag, NULL, nx, x_inf, tEnd_ms, ny, -TMax_ns, +TMax_ns);
211 if (pts->hasNext()) {
212 curr = *(pts->next());
215 FATAL(
"Input file is too short.");
220 for ( ; pts->hasNext() && counter != inputFile.getLimit(); ++counter) {
222 STATUS(
"timeslice: " << setw(10) << counter <<
'\r');
DEBUG(endl);
236 if (backVeto && ((in - ic) == 1)) {
238 summaryRouter.
update(nextSummary);
243 for (JDAQTimeslice::const_iterator frame = curr.begin(); frame != curr.end(); ++frame) {
245 const int DOMID = frame->getModuleID();
246 const JModule& module = moduleRouter.getModule(DOMID);
249 TH1F* RD = RT_DOM[moduleLabel];
255 if (frame->testHighRateVeto() || frame->testFIFOStatus()) {
257 veto[pmt] = ( frame->testHighRateVeto(pmt) || frame->testFIFOStatus(pmt) );
264 if (nextSummary != NULL) {
279 int nActiveChannels = count(veto.begin(), veto.end(),
false);
281 NC_DOM[moduleLabel]->Fill(tTimeslice_ms, nActiveChannels);
286 JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*frame, module);
289 if (veto[i->getPMTAddress()]) {
296 JSuperFrame1D_t& buffer1D = JSuperFrame1D_t::multiplex(buffer);
304 if (totRange_ns(h->getToT())) {
309 if (data.size() > 1) {
314 sort(data.begin(), data.end());
322 const double tHit = p->getT();
323 const double tHit_ms = tTimeslice_ms + (tHit / 1.0e6);
325 if (TMax_ns == 0.0) {
337 while (++q != data.end() && q->getT() - p->getT() <= TMax_ns) {}
339 int M = distance(p, q);
341 if (multiplicityRange(M)) {
355 double dt = JCombinatorics::getSign(__p->getPMT(), __q->getPMT()) * (__q->getT() - __p->getT());
357 hT->Fill(tHit_ms, dt, 1.0 / W);
377 if (nextSummary != NULL) {
delete nextSummary; }
386 NOTICE(
"Processing histograms." << endl);
388 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
392 if (RT_DOM.count(moduleLabel) && NC_DOM.count(moduleLabel)) {
394 TH1F* rt = RT_DOM.at(moduleLabel);
395 TH1F* nc = NC_DOM.at(moduleLabel);
397 for (
int b = 1; b <= rt->GetXaxis()->GetNbins(); b++) {
399 double r = rt->GetBinContent(b);
400 double t = rt->GetBinCenter( b);
402 RT_DET[
"SUM"]->Fill(t, r);
407 for (
int b = 1; b <= nc->GetXaxis()->GetNbins(); b++) {
409 double n = nc->GetBinContent(b);
410 double t = nc->GetBinCenter(b );
412 NC_DET[
"SUM"]->Fill(t, n);
418 DEBUG(moduleLabel <<
" not active." << endl);
424 NOTICE(
"Writing output file" << endl);
430 NOTICE(
"Writing 1D histograms" << endl);
435 NOTICE(
"Writing 2D histogram" << endl);
441 if (!globalOutputOnly) {
443 TString dir_tag = runTag + TString(
".Modules");
445 NOTICE(
"Writing individual modules histograms" << endl);
447 TDirectory* dir = out.mkdir(dir_tag);
452 NOTICE(
"Closing file" << endl);
Utility class to parse command line options.
Data structure for a composite optical module.
Router for fast addressing of summary data in JDAQSummaryslice data structure as a function of the op...
Auxiliary class to select ROOT class based on class name.
Router for direct addressing of module data in detector data structure.
Long64_t counter_type
Type definition for counter.
JSuperFrame2D< hit_type > JSuperFrame2D_t
Auxiliary class for a type holder.
double getTimeOfRTS(const JDAQChronometer &chronometer)
Get time of last RTS in ns since start of run for a given chronometer.
Template definition for direct access of elements in ROOT TChain.
long long int factorial(const long long int n)
Determine factorial.
Auxiliary interface for direct access of elements in ROOT TChain.
Simple wrapper around JModuleRouter class for direct addressing of PMT data in detector data structur...
int getFrameIndex() const
Get frame index.
1-dimensional frame with time calibrated data from one optical module.
Auxiliary class to manage set of compatible ROOT objects (e.g.
Auxiliary class for defining the range of iterations of objects.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
double getFrameTime()
Get frame time duration.
Data storage class for rate measurements of all PMTs in one module.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
const JDAQSummaryFrame & getSummaryFrame(const JDAQModuleIdentifier &module) const
Get summary frame.
Auxiliary class to select JTreeScanner based on ROOT class name.
bool testHighRateVeto() const
Test high-rate veto status.
std::string getModuleLabel(const JModuleLocation &location)
Get module label (DU-floor) for JMonitor applications.
void update(JDAQSummaryslice *ps)
Update router.
std::vector< frame_type >::iterator iterator
Auxiliary class to check whether two consecutive hits should be joined.
2-dimensional frame with time calibrated data from one optical module.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
const unsigned int h2d_limit
#define DEBUG(A)
Message macros.
JSuperFrame1D< hit_type > JSuperFrame1D_t
bool testFIFOStatus() const
Test FIFO status.