112 return (
n == 0 ? 1 :
n);
255 std::ostringstream os;
260 std::remove(os.str().c_str());
263 this->
open(os.str().c_str());
283 const string file_name = this->
getFile()->GetName();
295 <<
"_" << cal.
getYear() <<
'-' <<
FILL(2,
'0') <<
cal.getMonth() <<
'-' <<
FILL(2,
'0') <<
cal.getDay()
315 std::remove(file_name.c_str());
357 out <<
object.getFile()->GetName();
363 out <<
object.sizeL0 <<
'/'
364 <<
object.sizeL1 <<
'/'
365 <<
object.sizeL2 <<
'/'
366 <<
object.sizeSN <<
'/';
409 const std::string&
server,
415 const std::string& path,
416 const std::string& archive) :
453 virtual void actionInit(
int length,
const char* buffer)
override
467 catch(
const std::exception& error) {
526 properties.
read(
string(buffer, length));
528 catch(
const std::exception& error) {
553 catch (
const exception&) {
571 <<
"Assuming that this process is the only process on this CPU and setting parameters accordingly.";
583 if (find(
IP.begin(),
IP.end(), i->hostname) !=
IP.end()) {
587 if (i->port ==
this->port) {
594 JNoticeStream(
logger) <<
"Zero data filters on this machine according to process list (if it exists). "
595 <<
"Assuming one datafilter on this machine.";
603 error <<
"This process cannot be found in the process list. Why do I exist?";
604 error <<
" my IP addresses:";
610 error <<
" my port: " << this->
port;
611 error <<
" process list";
614 error <<
' ' << i->hostname <<
':' << i->port;
621 <<
", but in the process list I am referred to as " <<
thisProcess->index;
632 JNoticeStream(
logger) <<
"Maximum queue size is too large given the number of processes on this machine. "
633 <<
"Queue size reduced to "
812 virtual void actionStop(
int length,
const char* buffer)
override
828 virtual void actionQuit(
int length,
const char* buffer)
override
840 for (JChannelList_t::const_iterator channel =
channelList.begin(); channel !=
channelList.end(); ++channel) {
841 if (!channel->isReady()) {
842 mask.
set(channel->getFileDescriptor());
856 if (mask.
has(channel->getFileDescriptor())) {
860 if (channel->isReady()) {
871 catch(
const std::exception& error) {
873 JErrorStream(
logErrorRun) <<
"Update frame queue " << channel->getFileDescriptor() <<
' ' << channel->size() <<
' ' << error.what();
890 catch(
const std::exception& error) {
893 JErrorStream(
logger) <<
"Disconnect channel " << channel->getFileDescriptor() <<
' ' << error.what();
911 socket.setKeepAlive (
true);
912 socket.setNonBlocking(
false);
944 modules.insert(i->getModuleID());
972 <<
" adjusting frames per slice to " <<
modules.size();
984 error <<
"Timeout -> processed incomplete timeslice: "
987 <<
"Queue depth = " <<
timeslices.size() <<
';'
994 error <<
" intermittent problem -> continues as-is";
1001 modules.insert(i->getModuleID());
1036 using namespace std;
1046 if (preamble.
getLength() != channel.size()) {
1049 <<
"preamble.getLength() = " << preamble.
getLength() <<
';'
1050 <<
"channel.size(): " << channel.size() <<
';';
1061 <<
" -> Dropping frame.";
1078 <<
" -> dropping frame;"
1091 <<
" -> Dropping frame.";
1134 using namespace std;
1161 for (JDAQTimesliceL0::const_iterator frame = timeslice.begin(); frame != timeslice.end(); ++frame) {
1172 <<
"module = " << frame->getModuleID() <<
";"
1182 const JModule&
module = moduleRouter->getModule(frame->getModuleID());
1187 buffer.applyHighRateVeto(
parameters.highRateVeto_Hz);
1199 if (buffer.begin() != __end) {
1202 frame->getModuleIdentifier(),
1216 frame->getModuleIdentifier(),
1224 frame->getModuleIdentifier(),
1232 frame->getModuleIdentifier(),
1252 this->
put(timesliceTX);
1269 getTriggerMask(
triggerNB->getTriggerBit()),
1331 }
catch(
const std::exception& error) {
1336 <<
"time slice not correctly processed;"
1399 using namespace std;
1464 catch(
const std::exception& error) {
1497 if (this->empty()) {
1503 int min = std::numeric_limits<int>::max();
1505 for (const_iterator i = this->begin(); i != this->end(); ++i) {
1506 if (i->second < min) {
1522 if (this->empty()) {
1528 int max = std::numeric_limits<int>::lowest();
1530 for (const_iterator i = this->begin(); i != this->end(); ++i) {
1531 if (i->second > max) {
1616 using namespace std;
1617 using namespace JPP;
1634 JParser<> zap(
"Application for real-time filtering of data.");
1636 zap[
'H'] =
make_field(server,
"host name of server for command messages") =
"localhost";
1637 zap[
'M'] =
make_field(logger,
"host name of server for logger messages") =
"localhost";
1638 zap[
'D'] =
make_field(hostname,
"host name of server of data writer") =
"";
1640 zap[
'P'] =
make_field(port,
"port to listen for incoming data from data queue");
1643 zap[
'p'] =
make_field(path,
"directory for temporary storage of circular buffer") =
"/tmp/";
1644 zap[
'A'] =
make_field(archive,
"directory for permanent archival of circular buffer") =
"/tmp/";
1649 catch(
const std::exception& error) {
KM3NeT DAQ constants, bit handling, etc.
int main(int argc, char *argv[])
Data structure for detector geometry and calibration.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Basic data structure for L0 hit.
Basic data structure for L1 hit.
General purpose messaging.
Hostname and IP address functions.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
I/O formatting auxiliaries.
Utility class to parse parameter values.
ROOT TTree parameter settings of various packages.
Scheduling of actions via fixed latency intervals.
Basic data structure for time and time over threshold information of hit.
Auxiliary methods to convert data members or return values of member methods of a set of objects to a...
int getRunNumber() const
Get run number.
JDAQStateMachine::ev_error_event ev_error
JDAQStateMachine::ev_configure_event ev_configure
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
Utility class to parse parameter values.
bool read(const JEquation &equation)
Read equation.
Auxiliary class for CPU timing and usage.
unsigned long long usec_ucpu
unsigned long long usec_wall
unsigned long long usec_scpu
virtual bool is_open() const =0
Check is device is open.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Auxiliary class for method select.
void set(const int file_descriptor)
Set file descriptor.
bool has(const int file_descriptor) const
Has file descriptor.
Exception for opening of file.
Message logging based on ControlHost.
Interface for logging messages.
Message logger with time scheduler.
Message logging based on std::ostream.
std::string toString() const
Convert tag to string.
Template definition of a multi-dimensional oscillation probability interpolation table.
multifunction_type::value_type value_type
TFile * getFile() const
Get file.
JTreeWriter< T, JRootCreateFlatTree< T >::value > * out
virtual bool put(const T &object) override
Object output.
ROOT TTree object output.
virtual void close() override
Close file.
Auxiliary class to build KM3NETDAQ::JDAQEvent for a triggered event.
Simple data structure for the DAQ preamble required for a correct calculation of the object size for ...
int getLength() const
Get length.
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
int getRunNumber() const
Get run number.
int getFrameIndex() const
Get frame index.
Control unit client base class.
JSharedPointer< JControlHost > server
message server
bool isRunning() const
Check if this client is in runnig state.
void replaceEvent(const JTag &oldTag, const JTag &newTag, JDAQEvent_t &event)
Replace tag of given event in event table.
JMessageLogger logger
message logger
void addSubscription(const JSubscription &subscription)
Add custom subscription.
int getModuleID() const
Get module identifier.
Auxiliary class for itemization of process list.
std::string index
index in process list
Data frame of one optical module.
static void reset()
Reset counter of unique instance of this class object.
Main class for real-time filtering of data.
long long int number_of_packets_received
JMessageScheduler logErrorRun
int dumpLimit
maximum number of time slices to be dumped
JSinglePointer< JServerSocket > serversocket
server for data queue connections
JMessageScheduler logErrorDetector
virtual void actionRunning() override
This method is repeatedly called when this client machine is in state Running and the clock interval ...
JCircularBuffer_t c_buffer
virtual void actionSelect(const JFileDescriptorMask &mask) override
Action method following last select call.
long long int numberOfBytes
long long int number_of_packets_discarded
JMessageScheduler logErrorIndex
static bool compare(const JDAQProcess &first, const JDAQProcess &second)
Sort DAQ process by index.
virtual void actionInit(int length, const char *buffer) override
void put(const T &object)
Auxiliary method to send object to data server.
long long int number_of_bytes_received
virtual void actionContinue(int length, const char *buffer) override
std::vector< JSocketInputChannel_t > JChannelList_t
long long int maxQueueSize
int port
server socket port
long long int totalCPURAM
JTimeslice< hit_type > JTimeslice_t
void processTimeSlice(const JDAQTimesliceL0 ×lice)
Process time slice.
std::deque< JDAQTimesliceL0 > timeslices
buffer with pending time slice data
std::vector< JDAQProcess > dataQueues
JMessageScheduler logErrorOvercomplete
long long int number_of_reads
JSuperFrame2D< hit_type > JSuperFrame2D_t
virtual void actionStop(int length, const char *buffer) override
JSinglePointer< JBuildL2_t > buildNB
JSinglePointer< JBuildL2_t > buildL2
JSinglePointer< JBuildL1_t > buildL1
JBuildL1< hit_type > JBuildL1_t
virtual void actionExit() override
virtual void actionQuit(int length, const char *buffer) override
virtual void actionTagged(const JTag &tag, int length, const char *buffer) override
Tagged action to handle alerts.
std::string hostname
host name of data server
virtual void actionConfigure(int length, const char *buffer) override
JSuperFrame1D< hit_type > JSuperFrame1D_t
long long int numberOfTimeslicesProcessed
void updateFrameQueue(const JSocketInputChannel_t &channel)
Update queue with data frames.
JChannelList_t channelList
connections to data queue
long long int numberOfIncompleteTimeslicesProcessed
JSinglePointer< JTrigger3DMuon > trigger3DMuon
JDataFilter(const std::string &name, const std::string &server, const std::string &hostname, JLogger *logger, const int level, const int port, const int backlog, const std::string &path, const std::string &archive)
Constructor.
JSocketInputChannel< JDAQAbstractPreamble > JSocketInputChannel_t
virtual void setSelect(JFileDescriptorMask &mask) const override
Set the file descriptor mask for the select call.
JMessageScheduler logErrorIncomplete
virtual void actionEnter() override
Interface methods for actions corresponding to state transitions.
JStatus dumpMask
mask for data to be dumped
JSinglePointer< JModuleRouter > moduleRouter
JSinglePointer< JControlHost_t > datawriter
controlhost of data server (to which data writer should be connected)
JSinglePointer< JTimesliceRouter > timesliceRouter
JControlHostObjectOutput< JDAQTypes_t > JControlHost_t
JSinglePointer< JTriggerNB > triggerNB
long long int numberOfEvents
std::vector< JDAQProcess > dataFilters
JBuildL2< hit_type > JBuildL2_t
JSinglePointer< JTrigger3DShower > trigger3DShower
virtual void actionStart(int length, const char *buffer) override
virtual void actionPause(int length, const char *buffer) override
JSinglePointer< JTriggerMXShower > triggerMXShower
virtual void actionReset(int length, const char *buffer) override
JSinglePointer< JBuildL2_t > buildSN
JTriggerParameters parameters
void typeout()
Report status to message logger.
double getMaximalDistance(const JDetector &detector, const bool option=false)
Get maximal distance between modules in detector.
std::string getFullPath(const std::string &path)
Get full path, i.e. add JEEP::PATHNAME_SEPARATOR if necessary.
const array_type< JValue_t > & make_array(const JValue_t(&array)[N])
Method to create array of values.
T getMaximum(const array_type< T > &buffer, const T value)
Get maximum of values.
std::string trim(const std::string &buffer)
Trim string.
static const long long int GIGABYTE
Number of bytes in a mega-byte.
int getSizeOfPacket(const KM3NETDAQ::JDAQAbstractPreamble &preamble)
Get size of packeet.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
const char * getName()
Get ROOT name of given data type.
static const JLocalTime getLocalTime
Function object to get local time in micro seconds.
unsigned long long int getRAM()
Get RAM of this CPU.
std::vector< std::string > getListOfIPaddresses()
Get list of IP address (decimal-dot notation).
int rename(const std::string &inputFile, const std::string &outputFile)
Rename file across file systems.
static JStat getFileStatus
Function object for file status.
static const JChecksum checksum
Function object to perform check-sum of raw data.
KM3NeT DAQ data structures and auxiliaries.
size_t getNumberOfFrames(const size_t number_of_frames, const double factor)
Get expected number of frames according a given allowed fraction of active modules.
static const JNET::JTag RC_DFILTER
double getFrameTime()
Get frame time duration.
static const JNET::JTag RC_ALERT
static const int DFILTER_DQUEUE_BUFFER_SIZE
socket JDataFilter.cc <- DataQueue.cc
static const int DFILTER_RECEIVE_BUFFER_SIZE
socket JDataFilter.cc <- JLigier.cc
static const JNET::JTag RC_CMD
static const int DFILTER_SEND_BUFFER_SIZE
socket JDataFilter.cc -> JDataWriter.cc
static const JNET::JTag IO_TRIGGER_PARAMETERS
size_t getSizeof()
Definition of method to get size of data type.
static const int HIGH_RATE_VETO_DISABLE
Enable (disable) use of high-rate veto test if this status bit is 0 (1);.
Auxiliary data structure for sequence of same character.
Auxiliary data structure for floating point format specification.
Match of two events considering overlap in time and position.
Auxiliary class for handling status.
void set(const int bit)
Set PMT status.
Level specific message streamers.
Auxiliary class for all subscription.
Auxiliary class for date and time.
int getYear() const
year a.d.
Auxiliary data structure for result of checksum.
@ EPMT_t
PMT number error.
@ TIME_t
Time order error.
Router for fast addressing of hits in KM3NETDAQ::JDAQTimeslice data structure as a function of the op...
const JTag & getUniqueTag() const
Get unique tag of this run control client.
const std::string & getFullName() const
Get full name of this run control client.
void setClockInterval(const long long int interval_us)
Set interval time.
long long int getClockInterval() const
Get interval time.
Timeslice data structure for L0 data.
std::string archive
Directory for permanent archival.
std::string path
Directory for temporary storage.
Long64_t sizeL1
Number of L1 time slices.
Long64_t sizeSN
Number of SN time slices.
friend std::ostream & operator<<(std::ostream &out, const JCircularBuffer_t &object)
Write circular buffer to output stream.
static const int MAXIMUM_FILE_NUMBER
maximum file number for overwrite protection.
JTag tag
Unique tag of this process.
Long64_t sizeL0
Number of L0 time slices.
void close(const bool option)
Close file.
Long64_t sizeL2
Number of L2 time slices.
void disable()
Disable writing.
JCircularBuffer_t(const std::string &path, const std::string &archive, const JTag &tag)
Constructor.
bool is_enabled() const
Check whether writing of data is enabled.