Jpp 21.0.0-rc.1-88-g0130508c4
the software that should make you happy
Loading...
Searching...
No Matches
KM3NETDAQ::JDataWriter::JRunDB Struct Reference

Map run number to trigger parameters. More...

Inheritance diagram for KM3NETDAQ::JDataWriter::JRunDB:
std::map< int, JValue_t >

Public Member Functions

void reset (const int run)
 Remove all entries before given run.
 
bool is_written (const int run) const
 Check if trigger parameters have been written for given run.
 
void read (const char *const data, const size_t size)
 Read trigger parameters.
 
void write (const int run, TFile *file)
 Write trigger parameters for given run if not yet done.
 

Detailed Description

Map run number to trigger parameters.

Definition at line 445 of file JDataWriter.cc.

Member Function Documentation

◆ reset()

void KM3NETDAQ::JDataWriter::JRunDB::reset ( const int run)
inline

Remove all entries before given run.

Parameters
runrun number

Definition at line 453 of file JDataWriter.cc.

454 {
455 while (!this->empty() && this->begin()->first < run) {
456 this->erase(this->begin());
457 }
458 }
void run()
Run as run control client following command messages via JNET::JControlHost.

◆ is_written()

bool KM3NETDAQ::JDataWriter::JRunDB::is_written ( const int run) const
inline

Check if trigger parameters have been written for given run.

Parameters
runrun number
Returns
true if written; else false.

Definition at line 466 of file JDataWriter.cc.

467 {
468 const_iterator p = this->find(run);
469
470 return p != this->end() && p->second.is_written;
471 }

◆ read()

void KM3NETDAQ::JDataWriter::JRunDB::read ( const char *const data,
const size_t size )
inline

Read trigger parameters.

Parameters
datadata
sizesize

Definition at line 479 of file JDataWriter.cc.

480 {
481 using namespace std;
482 using namespace JPP;
483
484
485 const string buffer(data, size);
486
487 istringstream in(buffer);
488
489 int run = -1;
490 JTriggerParameters parameters;
491
492 in >> run;
493
494 if (!in) {
495 THROW(JIOException, "Error reading run number for trigger parameters " << run << endl << in.rdbuf());
496 }
497
498 in >> parameters;
499
500 in.clear(std::ios::eofbit);
501
502 if (!in) {
503 THROW(JIOException, "Error reading trigger parameters " << in.rdbuf());
504 }
505
506 JValue_t& value = (*this)[run];
507
508 if (value.count == 0) {
509 value.parameters = parameters;
510 }
511
512 value.count += 1;
513
514 if (!parameters.equals(value.parameters)) {
515 THROW(JException, "Inconsistent trigger parameters " << endl << value.parameters << " != " << endl << parameters);
516 }
517 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
General exception.
Definition JException.hh:25
Exception for I/O.
std::vector< char > buffer
internal buffer for incoming data
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).

◆ write()

void KM3NETDAQ::JDataWriter::JRunDB::write ( const int run,
TFile * file )
inline

Write trigger parameters for given run if not yet done.

Parameters
runrun number
filepointer to ROOT file

Definition at line 525 of file JDataWriter.cc.

526 {
527 if (file != NULL) {
528
529 iterator p = this->find(run);
530
531 if (p != this->end() && p->second.count != 0 && !p->second.is_written) {
532
533 file->WriteTObject(&p->second.parameters);
534
535 p->second.is_written = true;
536 }
537 }
538 }

The documentation for this struct was generated from the following file: