70 JLimit_t& numberOfEvents = inputFile.getLimit();
78 bool globalOutputOnly;
86 JParser<> zap(
"Example program to examine rates as a function of time on ms-level timescales.");
89 zap[
'o'] =
make_field(outputFile) =
"ripple.root";
90 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
92 zap[
'C'] =
make_field(selector) = getROOTClassSelection<JDAQTimesliceTypes_t>();
93 zap[
'T'] =
make_field(TMax_ns,
"Time window for local coincidences (if 0 run in L0 mode)") = 0.0;
94 zap[
'B'] =
make_field(binWidth_ms,
"Bin width (experimental)") = 1;
95 zap[
'V'] =
make_field(backVeto,
"Apply retroactive veto.");
96 zap[
'D'] =
make_field(mode2D,
"L1 mode: create 2D histogram with time differences of coincidences (heavy memory usage, ignored if TMax_ns = 0)");
97 zap[
'O'] =
make_field(globalOutputOnly,
"Write only aggregate histograms");
98 zap[
'M'] =
make_field(multiplicityRange,
"L1 mode: multiplicity range (ignored if TMax_ns = 0)") =
JRange<int>(2,31);
105 catch(
const exception &error) {
106 FATAL(error.what() << endl);
111 FATAL(
"Frame time must be an integer multiple of bin width");
117 load(detectorFile, detector);
131 pts->configure(inputFile);
133 int fEnd = pts->rbegin()->getFrameIndex();
134 int fStart = pts->begin( )->getFrameIndex();
136 if (fEnd > inputFile.getUpperLimit()) {
137 fEnd = fStart + inputFile.getUpperLimit();
141 double tStart_ms = (fStart - 1) *
getFrameTime() / 1.0e6;
143 int runNumber = pts->begin()->getRunNumber();
145 TString runTag = Form(
"%d" , runNumber);
147 double tRun_ms = tEnd_ms - tStart_ms;
149 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 JManager_t RT_DOM(
new TH1F(
"RT_%", NULL, nx , tStart_ms, tEnd_ms));
171 JManager_t NC_DOM(
new TH1F(
"NC_%", NULL, nx / 100, tStart_ms, tEnd_ms));
173 TString rt_tag = runTag + TString(
".RT_DET_%");
174 TString nc_tag = runTag + TString(
".NC_DET_%");
176 JManager_t RT_DET(
new TH1F(rt_tag, NULL, nx, tStart_ms, tEnd_ms));
177 JManager_t NC_DET(
new TH1F(nc_tag, NULL, nx / 100, tStart_ms, tEnd_ms));
188 if (nx >= max_size) {
189 FATAL(
"2D histogram size not supported by ROOT file output; limit input size (-n) below " << floor(max_size / 100.0) << endl);
192 TString rt2d_tag = runTag + TString(
".RT2D_DET");
194 hT =
new h2d_t(rt2d_tag, NULL, nx, tStart_ms, tEnd_ms, ny, -TMax_ns, +TMax_ns);
209 if (pts->hasNext()) {
210 curr = *(pts->next());
213 FATAL(
"Input file is too short.");
218 for ( ; pts->hasNext() && counter != inputFile.getLimit(); ++counter) {
220 STATUS(
"timeslice: " << setw(10) << counter <<
'\r');
DEBUG(endl);
234 if (backVeto && ((in - ic) == 1)) {
236 summaryRouter.
update(nextSummary);
241 for (JDAQTimeslice::const_iterator frame = curr.begin(); frame != curr.end(); ++frame) {
243 const int moduleID = frame->getModuleID();
244 const JModule& module = moduleRouter.getModule(moduleID);
245 const string moduleLabel =
getLabel(module);
247 TH1F* RD = RT_DOM[moduleLabel];
253 if (frame->testHighRateVeto() || frame->testFIFOStatus()) {
255 veto[pmt] = ( frame->testHighRateVeto(pmt) || frame->testFIFOStatus(pmt) );
261 if (nextSummary != NULL) {
275 NC_DOM[moduleLabel]->Fill(tTimeslice_ms, count(veto.begin(), veto.end(),
false));
279 JSuperFrame2D_t& buffer2D = JSuperFrame2D_t::demultiplex(*frame, module, totSelector_ns);
281 for (JSuperFrame2D_t::iterator
i = buffer2D.begin();
i != buffer2D.end(); ++
i) {
282 if (veto[
i->getPMTAddress()]) {
287 buffer2D.preprocess(JPreprocessor::join_t, match);
289 JSuperFrame1D_t&
data = JSuperFrame1D_t::multiplex(buffer2D);
294 if (data.size() > 1) {
299 sort(data.begin(), data.end());
306 const double tHit_ms = tTimeslice_ms + (p->getT() / 1.0e6);
308 if (TMax_ns == 0.0) {
316 while (++q != data.end() && q->getT() - p->getT() <= TMax_ns) {}
320 if (multiplicityRange(M)) {
332 double dt = JCombinatorics::getSign(__p->getPMT(), __q->getPMT()) * (__q->getT() - __p->getT());
334 hT->Fill(tHit_ms, dt, 1.0 / W);
352 if (nextSummary != NULL) {
delete nextSummary; }
365 NOTICE(
"Processing histograms." << endl);
367 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
369 string moduleLabel =
getLabel(*module);
371 if (RT_DOM.count(moduleLabel) && NC_DOM.count(moduleLabel)) {
373 TH1F* rt = RT_DOM.at(moduleLabel);
374 TH1F* nc = NC_DOM.at(moduleLabel);
376 for (
int b = 1; b <= rt->GetXaxis()->GetNbins(); b++) {
378 double r = rt->GetBinContent(b);
379 double t = rt->GetBinCenter( b);
381 RT_DET[
"SUM"]->Fill(t, r);
386 for (
int b = 1; b <= nc->GetXaxis()->GetNbins(); b++) {
388 double n = nc->GetBinContent(b);
389 double t = nc->GetBinCenter( b);
391 NC_DET[
"SUM"]->Fill(t, n);
397 DEBUG(moduleLabel <<
" not active." << endl);
403 NOTICE(
"Writing output file" << endl);
405 if (outputFile !=
"") {
407 TFile out(outputFile.c_str(),
"RECREATE");
409 NOTICE(
"Writing 1D histograms" << endl);
414 NOTICE(
"Writing 2D histogram" << endl);
420 if (!globalOutputOnly) {
422 TString dir_tag = runTag + TString(
".Modules");
424 NOTICE(
"Writing individual modules histograms" << endl);
426 TDirectory* dir = out.mkdir(dir_tag);
431 NOTICE(
"Closing file" << endl);
Utility class to parse command line options.
void update(const JDAQSummaryslice *ps)
Update router.
Data structure for a composite optical module.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
Auxiliary class to select ROOT class based on class name.
Router for direct addressing of module data in detector data structure.
Auxiliary interface for direct access of elements in ROOT TChain.
Long64_t counter_type
Type definition for counter.
Auxiliary class for a type holder.
const JDAQSummaryFrame & getSummaryFrame() const
Get default summary frame.
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.
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 for defining the range of iterations of objects.
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Reduced data structure for L0 hit.
#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.
Router for fast addressing of summary data in KM3NETDAQ::JDAQSummaryslice data structure as a functio...
Auxiliary class to select JTreeScanner based on ROOT class name.
bool testHighRateVeto() const
Test high-rate veto status.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
2-dimensional frame with time calibrated data from one optical module.
Auxiliary class to select DAQ hits based on time-over-treshold value.
do set_variable DETECTOR_TXT $WORKDIR detector
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
const unsigned int h2d_limit
#define DEBUG(A)
Message macros.
bool testFIFOStatus() const
Test FIFO status.