39 using namespace KM3NETDAQ;
48 int statPrintInterval_s;
55 int preTriggerThreshold;
61 JParser<> zap(
"Example program to test receiving of objects from ControlHost server.");
63 zap[
'H'] =
make_field(controlhost,
"CH server (input)") =
"localhost";
64 zap[
'L'] =
make_field(ligier,
"Ligier server (output)") =
"";
68 zap[
'C'] =
make_field(selector) = getROOTClassSelection<JDAQTimesliceTypes_t>();
69 zap[
'Q'] =
make_field(queueLength,
"number of timeslices of trigger queue") = 100;
70 zap[
'W'] =
make_field(windowLength,
"number of timeslices of trigger sliding window") = 5;
71 zap[
'T'] =
make_field(TMax_ns,
"coincidence time window [ns]") = 10;
73 zap[
'S'] =
make_field(preTriggerThreshold,
"muon veto multiplicity threshold") = 4;
74 zap[
'V'] =
make_field(TVeto_ns,
"muon veto time interval") = 1000;
75 zap[
's'] =
make_field(summaryFile,
"summary output file");
76 zap[
'P'] =
make_field(statPrintInterval_s,
"statistics & file print interval [s]") = 30;
83 catch(
const exception &error) {
84 FATAL(error.what() << endl);
87 if (queueLength < windowLength) {
88 FATAL(
"Length of the trigger window must be smaller than the queue.");
94 using namespace JSUPERNOVA;
113 const int detectorSize =
detector.size();
123 typedef priority_queue<trigger_type, vector<trigger_type>, greater<trigger_type> > queue_type;
125 typedef deque<trigger_type> window_type;
134 window_type trgWindow;
135 rates_type moduleRates;
136 npmt_type activeChannels;
140 long int counter_live_ts = 0;
141 long int counter_lost_ts = 0;
167 const string outputTag =
"SNT";
173 for (
int i = 0; i != numberOfTimeouts; ) {
177 data_type* timeslice =
in.next();
179 DEBUG(timeslice->getDAQHeader() << endl);
181 int timesliceSize = timeslice->size();
187 const int r = timeslice->getRunNumber();
193 NOTICE(
"RUN CHANGE" << endl);
195 while (trgQueue.size() > 0) { trgQueue.pop(); }
201 activeChannels.clear();
213 while ( sm.hasNext() ) {
219 for (JDAQSummaryslice::const_iterator summary_frame = summary->begin(); summary_frame != summary->end(); ++summary_frame) {
221 int DOMID = summary_frame->getModuleID();
224 moduleRates[frame_index][DOMID] += summary_frame->getRate(ipmt, 1.0/1000);
227 activeChannels[frame_index] += summary_frame->countActiveChannels();
235 JDataSN preTrigger(TMax_ns, preTriggerThreshold);
237 preTrigger(timeslice, moduleRouter);
243 trgQueue.push(trigger);
249 if (trgQueue.size() >= (unsigned) queueLength) {
251 while (trgWindow.size() <= (unsigned) windowLength) {
253 trigger_type pending = trgQueue.top();
255 if ( trgWindow.size() == 0 || pending > trgWindow.back() ) {
257 trgWindow.push_back( pending );
277 for (
int its = 0; its < windowLength; its++) {
279 set<int> current = trgWindow[its].getModules(F_M1);
281 triggeredModules.insert(current.begin(), current.end());
283 cTrigger += count_if(trgWindow[its].begin(), trgWindow[its].end(), F_M1);
287 mTrigger = triggeredModules.size();
291 int currentFrame = trgWindow[0].frameIndex;
294 trgWindow.pop_front();
302 int activeModules = -1;
303 double detectorRate = 0.0;
305 if (!moduleRates.empty() &&
306 moduleRates.count(currentFrame)) {
311 p != moduleRates.at(currentFrame).end(); p++ ) {
313 detectorRate += p->second;
315 activeModules += (p->second > 0);
320 activeModules = timesliceSize;
329 jd[
"active_doms"] = activeModules;
330 jd[
"detector_rate"] = int(detectorRate);
331 jd[
"run_number"] =
RUN;
332 jd[
"frame_index"] = currentFrame;
334 jd[
"trigger_level"] = cTrigger;
335 jd[
"trigger_ndoms"] = mTrigger;
336 jd[
"active_pmts"] = activeChannels[currentFrame];
338 string msg = jd.dump();
350 if ( (counter_live_ts % ((
int)(statPrintInterval_s / frameTime_s)) == 0 ) ) {
352 double livetime = counter_live_ts * frameTime_s;
354 stats.setLiveTime(livetime);
358 NOTICE(
"=> discarded out-of-order timeslices = " << counter_lost_ts << endl);
360 if (summaryFile !=
"") {
361 ofstream of(summaryFile.c_str());
362 of << stats.toSummaryFile();
369 NOTICE(
"Filling trigger queue: " << trgQueue.size() <<
"/" << queueLength <<
'\r');
374 NOTICE(
"timeout " << setw(3) << i << endl);
Utility class to parse command line options.
int MyId(const std::string &nick_name)
Identify.
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
Data structure for UTC time.
int getFrameIndex() const
Get frame index.
Auxiliary class for time values.
void setDAQLongprint(const bool option)
Set DAQ print option.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
SN trigger statistics, the information is stored in the form of a count as a function of the trigger ...
double getFrameTime()
Get frame time duration.
then rm i $OUTPUT_FILE fi let RUN
Auxiliary class to apply the supernova trigger to SN data.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
SN filter based on multiplicity selection optional suppression of multi-module coincidences WARNING: ...
Timeslice data structure for SN data.
Object iteration through ControlHost.
Auxiliary class to build the supernova trigger dataset.
Normalisation of MUPAGE events.
std::string to_string(const T &value)
Convert value to string.
virtual const char * what() const
Get error message.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
int PutFullString(const JTag &tag, const std::string &buffer)
Send string.
#define DEBUG(A)
Message macros.