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);
112 FATAL(
"Frame time must be an integer multiple of bin width");
118 load(detectorFile, detector);
132 pts->configure(inputFile);
134 int fEnd = pts->rbegin()->getFrameIndex();
135 int fStart = pts->begin( )->getFrameIndex();
137 if (fEnd > inputFile.getUpperLimit()) {
138 fEnd = fStart + inputFile.getUpperLimit();
142 double tStart_ms = (fStart - 1) *
getFrameTime() / 1.0e6;
144 int runNumber = pts->begin()->getRunNumber();
146 TString runTag = Form(
"%d" , runNumber);
148 double tRun_ms = tEnd_ms - tStart_ms;
150 NOTICE(
"START/END/DURATION [s]: " << tStart_ms / 1000 <<
" " << tEnd_ms / 1000 <<
" " << tRun_ms / 1000 << endl);
169 int nx = (tEnd_ms - tStart_ms) / binWidth_ms;
171 JManager_t RT_DOM(
new TH1F(
"RT_%", NULL, nx , tStart_ms, tEnd_ms));
172 JManager_t NC_DOM(
new TH1F(
"NC_%", NULL, nx / 100, tStart_ms, tEnd_ms));
174 TString rt_tag = runTag + TString(
".RT_DET_%");
175 TString nc_tag = runTag + TString(
".NC_DET_%");
177 JManager_t RT_DET(
new TH1F(rt_tag, NULL, nx, tStart_ms, tEnd_ms));
178 JManager_t NC_DET(
new TH1F(nc_tag, NULL, nx / 100, tStart_ms, tEnd_ms));
189 if (nx >= max_size) {
190 FATAL(
"2D histogram size not supported by ROOT file output; limit input size (-n) below " << floor(max_size / 100.0) << endl);
193 TString rt2d_tag = runTag + TString(
".RT2D_DET");
195 hT =
new h2d_t(rt2d_tag, NULL, nx, tStart_ms, tEnd_ms, ny, -TMax_ns, +TMax_ns);
210 if (pts->hasNext()) {
211 curr = *(pts->next());
214 FATAL(
"Input file is too short.");
219 for ( ; pts->hasNext() && counter != inputFile.getLimit(); ++counter) {
221 STATUS(
"timeslice: " << setw(10) << counter <<
'\r');
DEBUG(endl);
235 if (backVeto && ((in - ic) == 1)) {
237 summaryRouter.
update(nextSummary);
242 for (JDAQTimeslice::const_iterator frame = curr.begin(); frame != curr.end(); ++frame) {
244 const int moduleID = frame->getModuleID();
245 const JModule& module = moduleRouter.getModule(moduleID);
246 const string moduleLabel =
getLabel(module);
248 TH1F* RD = RT_DOM[moduleLabel];
254 if (frame->testHighRateVeto() || frame->testFIFOStatus()) {
256 veto[
pmt] = ( frame->testHighRateVeto(
pmt) || frame->testFIFOStatus(
pmt) );
262 if (nextSummary != NULL) {
276 NC_DOM[moduleLabel]->Fill(tTimeslice_ms,
count(veto.begin(), veto.end(),
false));
280 JSuperFrame2D_t& buffer2D = JSuperFrame2D_t::demultiplex(*frame, module, totSelector_ns);
282 for (JSuperFrame2D_t::iterator i = buffer2D.begin(); i != buffer2D.end(); ++i) {
283 if (veto[i->getPMTAddress()]) {
288 buffer2D.preprocess(JPreprocessor::join_t, match);
290 JSuperFrame1D_t& data = JSuperFrame1D_t::multiplex(buffer2D); data.pop_back();
295 if (data.size() > 1) {
300 sort(data.begin(), data.end());
307 const double tHit_ms = tTimeslice_ms + (p->getT() / 1.0e6);
309 if (TMax_ns == 0.0) {
317 while (++q != data.end() && q->getT() - p->getT() <= TMax_ns) {}
321 if (multiplicityRange(M)) {
333 double dt = JCombinatorics::getSign(__p->getPMT(), __q->getPMT()) * (__q->getT() - __p->getT());
335 hT->Fill(tHit_ms, dt, 1.0 / W);
353 if (nextSummary != NULL) {
delete nextSummary; }
366 NOTICE(
"Processing histograms." << endl);
368 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
370 string moduleLabel =
getLabel(*module);
372 if (RT_DOM.count(moduleLabel) && NC_DOM.count(moduleLabel)) {
374 TH1F* rt = RT_DOM.at(moduleLabel);
375 TH1F* nc = NC_DOM.at(moduleLabel);
377 for (
int b = 1; b <= rt->GetXaxis()->GetNbins(); b++) {
379 double r = rt->GetBinContent(b);
380 double t = rt->GetBinCenter( b);
382 RT_DET[
"SUM"]->Fill(t, r);
387 for (
int b = 1; b <= nc->GetXaxis()->GetNbins(); b++) {
389 double n = nc->GetBinContent(b);
390 double t = nc->GetBinCenter( b);
392 NC_DET[
"SUM"]->Fill(t, n);
398 DEBUG(moduleLabel <<
" not active." << endl);
404 NOTICE(
"Writing output file" << endl);
406 if (outputFile !=
"") {
408 TFile out(outputFile.c_str(),
"RECREATE");
410 NOTICE(
"Writing 1D histograms" << endl);
415 NOTICE(
"Writing 2D histogram" << endl);
421 if (!globalOutputOnly) {
423 TString dir_tag = runTag + TString(
".Modules");
425 NOTICE(
"Writing individual modules histograms" << endl);
427 TDirectory* dir = out.mkdir(dir_tag);
432 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.
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
const JDAQSummaryFrame & getSummaryFrame(const JDAQModuleIdentifier &module) const
Get summary frame.
Long64_t counter_type
Type definition for counter.
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.
esac $JPP_DIR examples JDetector JTransitTime o $OUTPUT_FILE n N $NPE T $TTS_NS d $DEBUG for HISTOGRAM in tts tt2 pmt
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.
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.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Router for fast addressing of summary data in JDAQSummaryslice data structure as a function of the op...
Auxiliary class to select JTreeScanner based on ROOT class name.
bool testHighRateVeto() const
Test high-rate veto status.
alias put_queue eval echo n
2-dimensional frame with time calibrated data from one optical module.
Auxiliary class to select DAQ hits based on time-over-treshold value.
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.