#include #include #include #include "JDAQ/JDAQTimesliceIO.hh" #include "JDAQ/JDAQEventIO.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "JDetector/JDetectorSupportkit.hh" #include "JDetector/JModuleRouter.hh" #include "JTrigger/JHit.hh" #include "JTrigger/JHitR1.hh" #include "JTrigger/JTimeslice.hh" #include "JTrigger/JSuperFrame1D.hh" #include "JTrigger/JSuperFrame2D.hh" #include "JTrigger/JEventOverlap.hh" #include "JTrigger/JTimesliceRouter.hh" #include "JTrigger/JTriggerInput.hh" #include "JTrigger/JTriggerOutput.hh" #include "JTrigger/JTriggeredEvent.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * Auxiliary program to test JTriggeredEvent class. */ int main(int argc, char **argv) { using namespace std; using namespace JPP; using namespace KM3NETDAQ; int debug; try { JParser<> zap; zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JDetector detector; JModule module = getModule(1001); const double t0 = 123.456; // arbitrary time offset for (JModule::iterator pmt = module.begin(); pmt != module.end(); ++pmt) { pmt->setT0(t0); } detector.push_back(module); const JModuleRouter moduleRouter(detector); const JDAQHit::JTDC_t Tmin = 1; const JDAQHit::JTDC_t Tmax = 10; const JDAQHit::JTDC_t Tp = 1; const double TMaxLocal_ns = Tp; // time window for second hit in same event const double TMaxEvent_ns = Tp; // time window for merging consecutive events typedef JHit hit_type; typedef JSuperFrame1D JSuperFrame1D_t; typedef JSuperFrame2D JSuperFrame2D_t; typedef JTimeslice JTimeslice_t; for (JDAQHit::JTOT_t tot = 0; tot < 250; tot += 5) { DEBUG(endl << "Test time-over-threshold " << (int) tot << " [ns]" << endl << endl); JDAQTimeslice timeslice; JDAQSuperFrame frame(JDAQSuperFrameHeader(timeslice.getDAQChronometer(), module.getID())); const JDAQHit::JPMT_t PMT = 0; for (JDAQHit::JTDC_t t1 = Tmin; t1 < Tmax; t1 += Tp) { frame.add(JDAQHit(PMT, t1, tot)); } timeslice.push_back(frame); DEBUG(timeslice << endl); const JTimesliceRouter timesliceRouter(timeslice, 1000); JTimeslice_t timesliceL0(timeslice.getDAQChronometer()); for (JDAQTimeslice::const_iterator frame = timeslice.begin(); frame != timeslice.end(); ++frame) { const JModule& module = moduleRouter.getModule(frame->getModuleID()); const JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*frame, module); timesliceL0.push_back(JSuperFrame1D_t::multiplex(buffer)); } JTriggerInput input(timesliceL0); JTriggerOutput output; ASSERT(input.size() > 1); for (size_t i = 0; i != input.size() - 1; ++i) { // skip last hit to ensure two DAQ hits per triggered event output.push_back(JEvent(timeslice.getDAQChronometer(), input[i], // root hit i % NUMBER_OF_TRIGGER_BITS)); } for (JTriggerOutput::const_iterator evt = output.begin(); evt != output.end(); ++evt) { const JTriggeredEvent tev(*evt, timesliceRouter, moduleRouter, TMaxLocal_ns); ASSERT(tev.size() == 2, "Number of triggered hits " << tev.size()); } output.merge(JEventOverlap(TMaxEvent_ns)); ASSERT(output.size() == 1u); const JEvent& evt = output[0]; DEBUG("Event:" << endl); for (JEvent::const_iterator hit = evt.begin(); hit != evt.end(); ++hit) { DEBUG(setw(4) << hit->getModuleID() << ' ' << FIXED(5,1) << hit->getT() << ' ' << setw(8) << hex << hit->getTriggerMask() << dec << endl); } const JTriggeredEvent tev(evt, timesliceRouter, moduleRouter, TMaxLocal_ns, true); DEBUG(tev << endl); ASSERT((int) tev.size() == (int) timeslice[0].size()); ASSERT((int) tev.size () == (int) timeslice[0].size()); } return 0; }