Public Member Functions | Private Member Functions | Private Attributes | List of all members
mcdatadaq::DataLoggerSimulator Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-05-05/MockDataDAQ/include/DataLoggerSimulator.h"

Public Member Functions

 DataLoggerSimulator ()
 Constructor. More...
 
 ~DataLoggerSimulator ()
 Destructor. More...
 
bool produceEvent (const std::vector< daqdataformats::RawDataBlock * > &, daqdataformats::RawTrigger *)
 
bool nextEvent ()
 Advance to the next event - clear Event and advance it's number. More...
 

Private Member Functions

bool writeEvent ()
 Write Event Object into output file. More...
 
bool writeRun ()
 Write Run Object into output file. More...
 

Private Attributes

daqdataformats::RawEvent fCurrentEvent
 Event Object. More...
 
daqdataformats::RawRunHeader fCurrentRunHeader
 Run Object. More...
 
FILE * fOutputEventFile
 File for events. More...
 
FILE * fOutputRunFile
 File for the run. More...
 

Detailed Description

Definition at line 24 of file DataLoggerSimulator.h.

Constructor & Destructor Documentation

mcdatadaq::DataLoggerSimulator::DataLoggerSimulator ( )

Constructor.

Setup the Event Object

Open event files

Open run file if needed

Definition at line 27 of file DataLoggerSimulator.cpp.

References EVENT_KEYWORD_IN_FILE_NAME, fCurrentEvent, fOutputEventFile, fOutputRunFile, mcdatadaq::Configuration::getFullFileName(), mcdatadaq::Configuration::getInstance(), mcdatadaq::Configuration::isProducingJustMicroSlices(), mcdatadaq::Configuration::isProducingRunObject(), RUN_KEYWORD_IN_FILE_NAME, and string.

27  :
30 {
31 
33 
34  /// Setup the Event Object
35  fCurrentEvent.setRunNumber (1);
36  fCurrentEvent.setSubrun (1);
37  fCurrentEvent.setEventNumber(1);
38 
39 
40  /// Open event files
41  if(!config->isProducingJustMicroSlices()){
42  const std::string final_file_name_event = config->getFullFileName(EVENT_KEYWORD_IN_FILE_NAME);
43  fOutputEventFile = fopen (final_file_name_event.c_str(),"wb");
44 
45  /// Open run file if needed
46  if(config->isProducingRunObject()){
47  const std::string final_file_name_run = config->getFullFileName(RUN_KEYWORD_IN_FILE_NAME);
48  fOutputRunFile = fopen (final_file_name_run.c_str(),"wb");
49  }// end of opening run file
50  }// end of opening event and run files
51 
52 }
Definition: config.py:1
FILE * fOutputEventFile
File for events.
static Configuration * getInstance()
Method to obtain the class instance.
#define EVENT_KEYWORD_IN_FILE_NAME
Keyword in the file name for Events&#39;s file.
FILE * fOutputRunFile
File for the run.
daqdataformats::RawEvent fCurrentEvent
Event Object.
#define RUN_KEYWORD_IN_FILE_NAME
enum BeamMode string
mcdatadaq::DataLoggerSimulator::~DataLoggerSimulator ( )

Destructor.

Close output files

Definition at line 56 of file DataLoggerSimulator.cpp.

References om::cout, fclose(), fCurrentRunHeader, fOutputEventFile, fOutputRunFile, and writeRun().

56  {
57 
58  std::cout<<"Destructing DataLoggerSimulator\n";
59 
60  /// Close output files
61  if(fOutputEventFile) {
63  }
64 
65  if(fOutputRunFile){
66  fCurrentRunHeader.close();
67  writeRun();
69  }
70 }
bool writeRun()
Write Run Object into output file.
FILE * fOutputEventFile
File for events.
fclose(fg1)
daqdataformats::RawRunHeader fCurrentRunHeader
Run Object.
OStream cout
Definition: OStream.cxx:6
FILE * fOutputRunFile
File for the run.

Member Function Documentation

bool mcdatadaq::DataLoggerSimulator::nextEvent ( )

Advance to the next event - clear Event and advance it's number.

Definition at line 118 of file DataLoggerSimulator.cpp.

References fCurrentEvent.

Referenced by mcdatadaq::DAQSimulator::nextEvent().

118  {
119 
120  fCurrentEvent.getHeader()->setDataBlockNumber(0);
121  fCurrentEvent.getHeader()->setEventSize( fCurrentEvent.getHeader()->sizeofdata()
122  +fCurrentEvent.getTrigger()->sizeofdata()
123  );
124  fCurrentEvent.getHeader()->advanceEventNumber();
125  fCurrentEvent.getHeader()->setCRCCalculationUsed(false);
126 
127  return true;
128 }
daqdataformats::RawEvent fCurrentEvent
Event Object.
bool mcdatadaq::DataLoggerSimulator::produceEvent ( const std::vector< daqdataformats::RawDataBlock * > &  datablocks,
daqdataformats::RawTrigger trigger 
)

Given all DataBlocks from the BufferNodes, produce Event Object and also add it to the Run Object

Set Trigger for the event

Loop over Datablocks and add them to the event

Write out the event

Add event to the run object if it is configured to do so. Otherwise, don't bother

Definition at line 73 of file DataLoggerSimulator.cpp.

References daqdataformats::RawEvent::addDataBlock(), daqdataformats::RawEvent::close(), fCurrentEvent, mcdatadaq::Configuration::getInstance(), mcdatadaq::Configuration::isProducingRunObject(), daqdataformats::RawEvent::setTrigger(), writeEvent(), and writeRun().

Referenced by mcdatadaq::DAQSimulator::fillEventAndRun().

74  {
75 
77 
78  /// Set Trigger for the event
79  fCurrentEvent.setTrigger(trigger->getBuffer());
80 
81  /// Loop over Datablocks and add them to the event
82  for(uint32_t idatablock = 0; idatablock < datablocks.size(); idatablock++){
83 
84  daqdataformats::RawDataBlock* current_datablock = datablocks[idatablock];
85  fCurrentEvent.addDataBlock(current_datablock->getBuffer());
86  }// end of loop over datablocks
88 
89  //fCurrentEvent.print();
90 
91  /// Write out the event
92  writeEvent();
93 
94 
95  /// Add event to the run object if it is configured to do so.
96  /// Otherwise, don't bother
97  if(config->isProducingRunObject())
98  writeRun();
99 
100  return true;
101 }
bool writeRun()
Write Run Object into output file.
bool close(const bool produce_crc=false)
Definition: RawEvent.h:63
Definition: config.py:1
static Configuration * getInstance()
Method to obtain the class instance.
IMPLEMENT_MAIN_STANDARD IMPLEMENT_MAIN_setBufferSource bool addDataBlock(const void *buffer)
Definition: RawEvent.h:61
bool setTrigger(const daqdataformats::RawTrigger &tr)
Definition: RawEvent.h:64
daqdataformats::RawEvent fCurrentEvent
Event Object.
bool writeEvent()
Write Event Object into output file.
bool mcdatadaq::DataLoggerSimulator::writeEvent ( )
private

Write Event Object into output file.

Definition at line 104 of file DataLoggerSimulator.cpp.

References fCurrentEvent, fOutputEventFile, mcdatadaq::Configuration::getInstance(), and mcdatadaq::Configuration::writeToFile().

Referenced by produceEvent().

104  {
106  return config->writeToFile(fOutputEventFile, fCurrentEvent);
107 }
Definition: config.py:1
FILE * fOutputEventFile
File for events.
static Configuration * getInstance()
Method to obtain the class instance.
daqdataformats::RawEvent fCurrentEvent
Event Object.
bool mcdatadaq::DataLoggerSimulator::writeRun ( )
private

Write Run Object into output file.

Definition at line 110 of file DataLoggerSimulator.cpp.

References fCurrentEvent, fCurrentRunHeader, fOutputRunFile, mcdatadaq::Configuration::getInstance(), and mcdatadaq::Configuration::writeToFile().

Referenced by produceEvent(), and ~DataLoggerSimulator().

110  {
111  fCurrentRunHeader.addRunSize(fCurrentEvent.sizeofdata());
112  fCurrentRunHeader.advanceEventNumber();
114  return config->writeToFile(fOutputRunFile, fCurrentEvent);
115 }
Definition: config.py:1
static Configuration * getInstance()
Method to obtain the class instance.
daqdataformats::RawRunHeader fCurrentRunHeader
Run Object.
FILE * fOutputRunFile
File for the run.
daqdataformats::RawEvent fCurrentEvent
Event Object.

Member Data Documentation

daqdataformats::RawEvent mcdatadaq::DataLoggerSimulator::fCurrentEvent
private

Event Object.

Definition at line 44 of file DataLoggerSimulator.h.

Referenced by DataLoggerSimulator(), nextEvent(), produceEvent(), writeEvent(), and writeRun().

daqdataformats::RawRunHeader mcdatadaq::DataLoggerSimulator::fCurrentRunHeader
private

Run Object.

Definition at line 45 of file DataLoggerSimulator.h.

Referenced by writeRun(), and ~DataLoggerSimulator().

FILE* mcdatadaq::DataLoggerSimulator::fOutputEventFile
private

File for events.

Definition at line 47 of file DataLoggerSimulator.h.

Referenced by DataLoggerSimulator(), writeEvent(), and ~DataLoggerSimulator().

FILE* mcdatadaq::DataLoggerSimulator::fOutputRunFile
private

File for the run.

Definition at line 48 of file DataLoggerSimulator.h.

Referenced by DataLoggerSimulator(), writeRun(), and ~DataLoggerSimulator().


The documentation for this class was generated from the following files: