BufferNodeSimulator.cpp
Go to the documentation of this file.
1 /*
2  * File: BufferNodeSimulator.cpp
3  * Author: denis
4  *
5  * Created on February 14, 2012, 2:50 PM
6  */
7 
8 #ifdef NOVACMAKE
11 #else
12 #include "MockDataDAQ/BufferNodeSimulator.h"
13 #include "MockDataDAQ/Configuration.h"
14 #endif
15 
16 #include <DAQDataFormats/RawMilliSlice.h>
17 #include <DAQDataFormats/RawTrigger.h>
18 
19 
20 
21 namespace mcdatadaq{
22 
23 //------------------------------------------------------------------------------
24 BufferNodeSimulator::BufferNodeSimulator(uint32_t buffer_node_id):_bufferNodeID(buffer_node_id) {
25  _dataBlock.setBuffId(_bufferNodeID);
26  _dataBlock.setMonteCarloFlag(true);
27 }
28 
29 //------------------------------------------------------------------------------
31 
32 //------------------------------------------------------------------------------
33 daqdataformats::RawDataBlock* BufferNodeSimulator::getDataBlock(const std::vector<daqdataformats::RawMilliSlice*>& millislices,
35 
36  /// Set Trigger Number taken from Trigger Object
37  _dataBlock.setTrigNum(trigger->getTriggerHeader()->getTriggerNumber());
38 
39  /// Loop over MilliSlices and fill DataBlock
40  for(uint32_t imillislice = 0; imillislice < millislices.size(); imillislice++ ){
41  addMilliSlice(millislices[imillislice]);
42  }// end of loop over MilliSlices
43 
44  _dataBlock.close(); ///< Need to close datablock - produces CRC
45 
46 
47  return &_dataBlock;
48 }
49 
50 //------------------------------------------------------------------------------
52 
54 
55  const daqdataformats::version_t microblock_version = config->getMicroBlockVersion();
56 
57  //millislice->print();
58 
59  /// Loop over microslices. Fill DataBlock with MicroBlocks.
60  const uint32_t number_of_microslices = millislice->getMicrosliceNumber();
61  for(uint32_t imicroslice = 0; imicroslice < number_of_microslices; imicroslice++ ){
62 
63  millislice->setFloatingMicroSlice(imicroslice);
64  daqdataformats::RawMicroSlice* microslice = millislice->getFloatingMicroSlice();
65 
66  _dataBlock.addMicroBlock(millislice->getBuffer(), microslice->getBuffer(), microblock_version);
67  }// end of loop over microslices
68 
69  return true;
70 }
71 
72 //------------------------------------------------------------------------------
74 
75 //------------------------------------------------------------------------------
77 
78  /// This is a fast but very dangerous to clear out the datablock
79  _dataBlock.getHeader()->setCRCCalculationUsed(false);
80  _dataBlock.getHeader()->setNumMicroBlocks(0);
81  _dataBlock.getHeader()->setDataSize(_dataBlock.getHeader()->sizeofdata());
82 
83  return true;
84 }
85 
86 }// end of namespace
bool setFloatingMicroSlice(const uint32_t) const
daqdataformats::RawDataBlock _dataBlock
Data Block.
daqdataformats::RawMicroSlice * getFloatingMicroSlice() const
Definition: RawMilliSlice.h:48
Definition: config.py:1
uint32_t _bufferNodeID
Buffer Node ID.
void * getBuffer() const
Definition: RawDAQData.h:131
Class to hold the data from the global trigger in the correct format.
Definition: RawTrigger.h:40
static Configuration * getInstance()
Method to obtain the class instance.
uint32_t getMicrosliceNumber() const
Definition: RawMilliSlice.h:63
bool close(bool produce_crc=false)
Definition: RawDataBlock.h:80
Something conflicts with RandomNumberGenerator. Keep DAQSimulator.h include below Art Framework inclu...
bool nextEvent()
Advance to the next event - clearing the DataBlock.
daqdataformats::RawDataBlock * getDataBlock(const std::vector< daqdataformats::RawMilliSlice * > &, daqdataformats::RawTrigger *)
Given all MilliSlices for all DCMs and a Trigger from GlobalTrigger, produce DataBlock.
bool addMilliSlice(daqdataformats::RawMilliSlice *)
Add a millislice to the dataBlock.
BufferNodeSimulator(uint32_t buffer_node_id)
Constructor.
uint32_t getBufferNodeID() const
This Buffer Node ID.
Class to hold the MicroSlice data.
Definition: RawMicroSlice.h:48
int32_t version_t
Definition: RawDAQData.h:72
bool addMicroBlock(const void *microblock_buffer, const bool check_mc_flag=true)
Definition: RawDataBlock.h:42
daqdataformats::version_t getMicroBlockVersion() const
Get MicroBlock version.