Classes | |
class | BadVersionIssue |
class | FullEventFragment |
class | Header |
class | Issue |
class | NoSuchChildIssue |
class | NotAlignedIssue |
class | UnboundSourceIdentifierIssue |
class | OutOfBoundsIssue |
class | PagedMemory |
class | ROBFragment |
class | ROSFragment |
class | SizeCheckIssue |
class | SubDetectorFragment |
class | TooBigCountIssue |
class | WrongMarkerIssue |
class | WrongSizeIssue |
Namespaces | |
namespace | helper |
namespace | old |
namespace | write |
Typedefs | |
typedef enum HeaderMarker | HeaderMarker |
typedef enum RunType | RunType |
typedef enum SubDetector | SubDetector |
typedef enum GenericStatus | GenericStatus |
Enumerations | |
enum | HeaderMarker { ROD = 0xee1234ee, ROB = 0xdd1234dd, ROS = 0xcc1234cc, SUB_DETECTOR = 0xbb1234bb, FULL_EVENT = 0xaa1234aa } |
enum | RunType { PHYSICS = 0x00, CALIBRATION = 0x01, COSMICS = 0x02, TEST = 0x0f } |
enum | SubDetector { FULL_SD_EVENT = 0x00, PIXEL_BARREL = 0x11, PIXEL_FORWARD_A_SIDE = 0x12, PIXEL_FORWARD_C_SIDE = 0x13, PIXEL_B_LAYER = 0x14, SCT_BARREL_A_SIDE = 0x21, SCT_BARREL_C_SIDE = 0x22, SCT_ENDCAP_A_SIDE = 0x23, SCT_ENDCAP_C_SIDE = 0x24, TRT_ANCILLARY_CRATE = 0x30, TRT_BARREL_A_SIDE = 0x31, TRT_BARREL_C_SIDE = 0x32, TRT_ENDCAP_A_SIDE = 0x33, TRT_ENDCAP_C_SIDE = 0x34, LAR_EM_BARREL_A_SIDE = 0x41, LAR_EM_BARREL_C_SIDE = 0x42, LAR_EM_ENDCAP_A_SIDE = 0x43, LAR_EM_ENDCAP_C_SIDE = 0x44, LAR_HAD_ENDCAP_A_SIDE = 0x45, LAR_HAD_ENDCAP_C_SIDE = 0x46, LAR_FCAL_A_SIDE = 0x47, LAR_FCAL_C_SIDE = 0x48, TILECAL_LASER_CRATE = 0x50, TILECAL_BARREL_A_SIDE = 0x51, TILECAL_BARREL_C_SIDE = 0x52, TILECAL_EXT_A_SIDE = 0x53, TILECAL_EXT_C_SIDE = 0x54, MUON_ANCILLARY_CRATE = 0x60, MUON_MDT_BARREL_A_SIDE = 0x61, MUON_MDT_BARREL_C_SIDE = 0x62, MUON_MDT_ENDCAP_A_SIDE = 0x63, MUON_MDT_ENDCAP_C_SIDE = 0x64, MUON_RPC_BARREL_A_SIDE = 0x65, MUON_RPC_BARREL_C_SIDE = 0x66, MUON_TGC_ENDCAP_A_SIDE = 0x67, MUON_TGC_ENDCAP_C_SIDE = 0x68, MUON_CSC_ENDCAP_A_SIDE = 0x69, MUON_CSC_ENDCAP_C_SIDE = 0x6A, TDAQ_BEAM_CRATE = 0x70, TDAQ_CALO_PREPROC = 0x71, TDAQ_CALO_CLUSTER_PROC_DAQ = 0x72, TDAQ_CALO_CLUSTER_PROC_ROI = 0x73, TDAQ_CALO_JET_PROC_DAQ = 0x74, TDAQ_CALO_JET_PROC_ROI = 0x75, TDAQ_MUON_CTP_INTERFACE = 0x76, TDAQ_CTP = 0x77, TDAQ_L2SV = 0x78, TDAQ_SFI = 0x79, TDAQ_SFO = 0x7a, TDAQ_LVL2 = 0x7b, TDAQ_EVENT_FILTER = 0x7c, OTHER = 0x81, BESIII_MDC = 0xa1, BESIII_TOF = 0xa2, BESIII_EMC = 0xa3, BESIII_MUC = 0xa4, BESIII_TRG = 0xa5 } |
enum | GenericStatus { NO_ERROR = 0x0, BCID_CHECK_FAIL = 0x1, LVL1ID_CHECK_FAIL = 0x2, TIMEOUT = 0x4, DATA_CORRUPTION = 0x8, INTERNAL_OVERFLOW = 0x16 } |
Functions | |
HeaderMarker | child_marker (HeaderMarker e) |
std::string | marker2string (const eformat::HeaderMarker &e) |
std::string | marker2string (uint32_t e) |
uint32_t * | next_fragment (std::fstream &fs, uint32_t *addr=0, size_t size=0) |
size_t | find_rods (const uint32_t *block_start, size_t block_size, const uint32_t **rod=0, uint32_t *rod_size=0, size_t max_count=0) |
template<class TPointer> | |
size_t | find_fragments (eformat::HeaderMarker marker, TPointer block_start, size_t block_size, TPointer *frag=0, size_t max_count=0) |
size_t | get_robs (const uint32_t *fragment, const uint32_t **rob, size_t max_count) |
template<class TPointer> | |
size_t | find_fragments (eformat::HeaderMarker marker, TPointer block_start, size_t block_size, TPointer *frag, size_t max_count) |
eformat::HeaderMarker | child_marker (eformat::HeaderMarker e) |
std::string | marker2string (const eformat::HeaderMarker &e) |
std::string | marker2string (uint32_t e) |
uint32_t * | next_fragment (std::fstream &fs, uint32_t *addr, size_t size) |
size_t | find_rods (const uint32_t *block_start, size_t block_size, const uint32_t **rod, uint32_t *rod_size, size_t max_count) |
size_t | get_robs (const uint32_t *fragment, const uint32_t **rob, size_t max_count) |
Variables | |
const uint32_t | STATUS_FRONT = 0 |
status goes in front of data block | |
const uint32_t | STATUS_BACK = 1 |
status goes after data block | |
const uint32_t | DEFAULT_STATUS = NO_ERROR |
const uint32_t | DEFAULT_VERSION = 0x03000000 |
const uint16_t | MAJOR_DEFAULT_VERSION = 0x0300 |
const uint16_t | MAJOR_OLD_VERSION = 0x0204 |
typedef enum HeaderMarker eformat::HeaderMarker |
An alias
Definition at line 35 of file HeaderMarker.h.
typedef enum RunType eformat::RunType |
An alias
Definition at line 31 of file RunNumber.h.
typedef enum SubDetector eformat::SubDetector |
An alias
Definition at line 87 of file SourceIdentifier.h.
typedef enum GenericStatus eformat::GenericStatus |
The types of header markers available. They are all 32 bit numbers, with 1234 in the middle for the identification of byte ordering (endianness).
ROD | The ROD marker. |
ROB | The ROB marker. |
ROS | The ROS marker. |
SUB_DETECTOR | The SubDet. marker. |
FULL_EVENT |
Definition at line 26 of file HeaderMarker.h.
00026 { ROD = 0xee1234ee, 00027 ROB = 0xdd1234dd, 00028 ROS = 0xcc1234cc, 00029 SUB_DETECTOR = 0xbb1234bb, 00030 FULL_EVENT = 0xaa1234aa};
enum eformat::RunType |
Physics Types
Definition at line 23 of file RunNumber.h.
00023 { PHYSICS = 0x00, 00024 CALIBRATION = 0x01, 00025 COSMICS = 0x02, 00026 TEST = 0x0f};
enum eformat::SubDetector |
Sub-detector ID
Definition at line 25 of file SourceIdentifier.h.
00025 { FULL_SD_EVENT = 0x00, 00026 PIXEL_BARREL = 0x11, 00027 PIXEL_FORWARD_A_SIDE = 0x12, 00028 PIXEL_FORWARD_C_SIDE = 0x13, 00029 PIXEL_B_LAYER = 0x14, 00030 SCT_BARREL_A_SIDE = 0x21, 00031 SCT_BARREL_C_SIDE = 0x22, 00032 SCT_ENDCAP_A_SIDE = 0x23, 00033 SCT_ENDCAP_C_SIDE = 0x24, 00034 TRT_ANCILLARY_CRATE = 0x30, 00035 TRT_BARREL_A_SIDE = 0x31, 00036 TRT_BARREL_C_SIDE = 0x32, 00037 TRT_ENDCAP_A_SIDE = 0x33, 00038 TRT_ENDCAP_C_SIDE = 0x34, 00039 LAR_EM_BARREL_A_SIDE = 0x41, 00040 LAR_EM_BARREL_C_SIDE = 0x42, 00041 LAR_EM_ENDCAP_A_SIDE = 0x43, 00042 LAR_EM_ENDCAP_C_SIDE = 0x44, 00043 LAR_HAD_ENDCAP_A_SIDE = 0x45, 00044 LAR_HAD_ENDCAP_C_SIDE = 0x46, 00045 LAR_FCAL_A_SIDE = 0x47, 00046 LAR_FCAL_C_SIDE = 0x48, 00047 TILECAL_LASER_CRATE = 0x50, 00048 TILECAL_BARREL_A_SIDE = 0x51, 00049 TILECAL_BARREL_C_SIDE = 0x52, 00050 TILECAL_EXT_A_SIDE = 0x53, 00051 TILECAL_EXT_C_SIDE = 0x54, 00052 MUON_ANCILLARY_CRATE = 0x60, 00053 MUON_MDT_BARREL_A_SIDE = 0x61, 00054 MUON_MDT_BARREL_C_SIDE = 0x62, 00055 MUON_MDT_ENDCAP_A_SIDE = 0x63, 00056 MUON_MDT_ENDCAP_C_SIDE = 0x64, 00057 MUON_RPC_BARREL_A_SIDE = 0x65, 00058 MUON_RPC_BARREL_C_SIDE = 0x66, 00059 MUON_TGC_ENDCAP_A_SIDE = 0x67, 00060 MUON_TGC_ENDCAP_C_SIDE = 0x68, 00061 MUON_CSC_ENDCAP_A_SIDE = 0x69, 00062 MUON_CSC_ENDCAP_C_SIDE = 0x6A, 00063 TDAQ_BEAM_CRATE = 0x70, 00064 TDAQ_CALO_PREPROC = 0x71, 00065 TDAQ_CALO_CLUSTER_PROC_DAQ = 0x72, 00066 TDAQ_CALO_CLUSTER_PROC_ROI = 0x73, 00067 TDAQ_CALO_JET_PROC_DAQ = 0x74, 00068 TDAQ_CALO_JET_PROC_ROI = 0x75, 00069 TDAQ_MUON_CTP_INTERFACE = 0x76, 00070 TDAQ_CTP = 0x77, 00071 TDAQ_L2SV = 0x78, 00072 TDAQ_SFI = 0x79, 00073 TDAQ_SFO = 0x7a, 00074 TDAQ_LVL2 = 0x7b, 00075 TDAQ_EVENT_FILTER = 0x7c, 00076 OTHER = 0x81, 00077 BESIII_MDC = 0xa1, 00078 BESIII_TOF = 0xa2, 00079 BESIII_EMC = 0xa3, 00080 BESIII_MUC = 0xa4, 00081 BESIII_TRG = 0xa5 00082 };
Defines possible generic errors for the status words
Definition at line 24 of file Status.h.
00024 { 00025 NO_ERROR = 0x0, 00026 BCID_CHECK_FAIL = 0x1, 00027 LVL1ID_CHECK_FAIL = 0x2, 00028 TIMEOUT = 0x4, 00029 DATA_CORRUPTION = 0x8, 00030 INTERNAL_OVERFLOW = 0x16 00031 };
HeaderMarker eformat::child_marker | ( | HeaderMarker | e | ) |
Returns the child marker of a given parent marker
e | The marker from which you would like to the get child fragment type from |
Definition at line 15 of file HeaderMarker.cxx.
References FULL_EVENT, ROB, ROD, ROS, and SUB_DETECTOR.
Referenced by eformat::Header< TPointer >::children().
00016 { 00017 using namespace eformat; 00018 switch (e) { 00019 case FULL_EVENT: 00020 return SUB_DETECTOR; 00021 case SUB_DETECTOR: 00022 return ROS; 00023 case ROS: 00024 return ROB; 00025 case ROB: 00026 return ROD; 00027 default: 00028 break; 00029 } 00030 return FULL_EVENT; 00031 }
std::string eformat::marker2string | ( | const eformat::HeaderMarker & | e | ) |
Returns a string that represents the string of the equivalent marker
e | The enumeration value |
Definition at line 33 of file HeaderMarker.cxx.
Referenced by eformat::Header< TPointer >::check(), eformat::Header< TPointer >::child(), marker2string(), and eformat::Header< TPointer >::nchildren().
00034 { 00035 using namespace eformat; 00036 switch (e) { 00037 case ROD: 00038 return "ROD"; 00039 case ROB: 00040 return "ROB"; 00041 case ROS: 00042 return "ROS"; 00043 case SUB_DETECTOR: 00044 return "SUB_DETECTOR"; 00045 case FULL_EVENT: 00046 return "FULL_EVENT"; 00047 } 00048 return "UNKNOWN_MARKER"; 00049 }
std::string eformat::marker2string | ( | uint32_t | e | ) |
Returns a string that represents the string of the equivalent marker
e | The enumeration value |
Definition at line 51 of file HeaderMarker.cxx.
References marker2string().
00052 { 00053 return marker2string((eformat::HeaderMarker)e); 00054 }
uint32_t* eformat::next_fragment | ( | std::fstream & | fs, | |
uint32_t * | addr = 0 , |
|||
size_t | size = 0 | |||
) |
This function will read the next fragment in a normal, already opened, std::fstream. The space for the fragment will be allocated dynamically and the user should free it. Otherwise, if the user wants to re-use a pre-allocated memory space, the second and third arguments can be given, in which case the function will check if the space is enough. If the space is not enough, NULL is returned.
fs | The input filestream | |
addr | The optional user allocated space | |
size | The optional size, in bytes, of the allocated space |
Definition at line 22 of file util.cxx.
References ERS_DEBUG_2, ERS_DEBUG_3, FULL_EVENT, HEX, ROB, ROD, ROS, and SUB_DETECTOR.
Referenced by main().
00024 { 00025 using namespace eformat; 00026 00027 off_t offset = fs.tellg(); 00028 ERS_DEBUG_3("Current stream position is 0x%lx", offset); 00029 00030 uint32_t data[2]; 00031 if (fs && fs.good() && ! fs.eof()) { 00032 //soft check, so we don't make mistakes 00033 fs.read((char*)data, 8); 00034 if (!fs.good() || fs.eof()) return 0; // end-of-file 00035 switch((HeaderMarker)data[0]) { 00036 case FULL_EVENT: 00037 case SUB_DETECTOR: 00038 case ROS: 00039 case ROB: 00040 case ROD: 00041 break; 00042 default: 00043 //stop! 00044 std::cout << "Word at offset " << HEX(offset) << " is not one of " 00045 << HEX(FULL_EVENT) << ", " 00046 << HEX(SUB_DETECTOR) << ", " 00047 << HEX(ROS) << ", " 00048 << HEX(ROB) << "or " 00049 << HEX(ROS) << ". Stopping execution..." << std::endl; 00050 return 0; 00051 } 00052 } 00053 else return 0; //file is over 00054 00055 //data[1] is the fragment size, in words. Take it and read the fragment 00056 ERS_DEBUG_3("Resetting stream position to 0x%lx...", offset); 00057 fs.seekg(offset); 00058 if (addr && (size >= (data[1]*4))) { 00059 //space is preallocated and checked 00060 ERS_DEBUG_3("Reading fragment data..."); 00061 fs.read((char*)addr, data[1]*4); 00062 ERS_DEBUG_2("Size of fragment readout is %u bytes", 4*data[1]); 00063 ERS_DEBUG_3("Stream position is 0x%lx", offset = fs.tellg()); 00064 return addr; 00065 } 00066 else if (addr) { 00067 std::cout << "The fragment at offset " << HEX(offset) << " has " 00068 << data[1]*4 << " bytes and you provided only " 00069 << size << " bytes in your buffer. Stopping execution..." 00070 << std::endl; 00071 return 0; 00072 } 00073 00074 //if I get here, is because I have to allocate space myself 00075 ERS_DEBUG_3("Allocating fragment data storage of size %ud bytes", 4*data[1]); 00076 uint32_t* retval = new uint32_t[data[1]]; 00077 ERS_DEBUG_3("Reading fragment data..."); 00078 fs.read((char*)retval, data[1]*4); 00079 ERS_DEBUG_2("Size of fragment readout is %u bytes", 4*data[1]); 00080 ERS_DEBUG_3("Stream position is 0x%lx", offset = fs.tellg()); 00081 return retval; 00082 }
size_t eformat::find_rods | ( | const uint32_t * | block_start, | |
size_t | block_size, | |||
const uint32_t ** | rod = 0 , |
|||
uint32_t * | rod_size = 0 , |
|||
size_t | max_count = 0 | |||
) |
Returns pointers (to words) to the start of each ROD fragment block in a piece of memory. This is primarily intended for LVL2 supervisor usage.
block_start | The start address of the data block you want to dig the ROD pointers from | |
block_size | The size of the block, in 32-bit words | |
rod | A (optional) pointer to set of pre-allocated pointers | |
rod_size | A (optional) pointer to set of pre-allocated size_t's, where the size of each ROD, in words, will be stored. | |
max_count | The maximum number of blocks to dig out from block_start , if rod is not NULL. If rod is NULL, this is meaningless. |
Definition at line 84 of file util.cxx.
References counter, EFORMAT_WRONG_MARKER, and ROD.
00087 { 00088 const uint32_t* block_end = block_start + block_size; 00089 size_t counter = 0; 00090 while (block_end > block_start) { 00091 uint32_t curr_rod_size = 12; //< base size for a ROD as eformat 2.4 00092 curr_rod_size += *(block_end-3) + *(block_end-2); //status and data sizes 00093 block_end -= curr_rod_size; 00094 if (rod && counter < max_count) { 00095 if (block_end[0] != eformat::ROD) 00096 throw EFORMAT_WRONG_MARKER(block_end[0], eformat::ROD); 00097 rod_size[counter] = curr_rod_size; 00098 rod[counter] = block_end; 00099 } 00100 ++counter; 00101 } 00102 return counter; 00103 }
size_t eformat::find_fragments | ( | eformat::HeaderMarker | marker, | |
TPointer | block_start, | |||
size_t | block_size, | |||
TPointer * | frag = 0 , |
|||
size_t | max_count = 0 | |||
) |
A generic method to find all fragments in a contiguous area of memory. These fragments cannot be RODFragments. For that, use the eformat::find_rods().
marker | The marker you are searching for. | |
block_start | A pointer to the block start | |
block_size | The overall size of this block, in 32-bit words | |
frag | A (optional) preallocated set of pointers to hold the found fragments. If frag is NULL, only counts the number of children. | |
max_count | The maximum number of fragments I'll search for, if frag is not NULL. If frag is NULL, this flag has no meaning. |
Definition at line 111 of file util.h.
References counter, EFORMAT_WRONG_MARKER, and next.
Referenced by eformat::Header< TPointer >::children().
00114 { 00115 uint32_t counter = 0; 00116 TPointer next = block_start; 00117 TPointer endp = block_start; 00118 endp += block_size; 00119 while (next < endp) { 00120 if (next[0] != marker) throw EFORMAT_WRONG_MARKER(next[0], marker); 00121 if (frag && counter < max_count) frag[counter] = next; 00122 ++counter; 00123 next += next[1]; 00124 } 00125 return counter; 00126 }
size_t eformat::get_robs | ( | const uint32_t * | fragment, | |
const uint32_t ** | rob, | |||
size_t | max_count | |||
) |
Gets pointers to all ROB fragments from a fragment of a type which is not known in advance.
fragment | The top level fragment to extract the other ROBFragment's from. | |
rod | A pointer to set of pre-allocated pointers | |
max_count | The maximum number of blocks to dig out from block_start . |
Definition at line 105 of file util.cxx.
References eformat::Header< TPointer >::children(), counter, ERS_DEBUG_1, FULL_EVENT, get_robs(), genRecEmupikp::i, ROB, ROD, ROS, eformat::Header< TPointer >::source_id(), and SUB_DETECTOR.
Referenced by EFEventLoopMgr::executeEvent(), get_robs(), main(), MixerAlg::nextEvent(), RawDataInputSvc::nextEvent(), and RawEventReader::readEvent().
00107 { 00108 using namespace eformat; 00109 ERS_DEBUG_1("Getting all ROB's from 0x%x...", fragment[0]); 00110 00111 size_t counter = 0; 00112 switch ((eformat::HeaderMarker)(fragment[0])) { 00113 case ROD: 00114 return 0; 00115 case ROB: 00116 { 00117 if ( max_count > 0 ) { 00118 rob[0] = fragment; 00119 ++counter; 00120 } 00121 else return 0; //not enough space 00122 } 00123 break; 00124 case ROS: 00125 { 00126 eformat::ROSFragment<const uint32_t*> ros(fragment); 00127 counter += ros.children(rob, max_count); 00128 ERS_DEBUG_1("ROS 0x%x contains %d ROB's", ros.source_id(), counter); 00129 } 00130 break; 00131 case SUB_DETECTOR: 00132 { 00133 eformat::SubDetectorFragment<const uint32_t*> sd(fragment); 00134 const uint32_t* ros[256]; 00135 size_t ros_counter = sd.children(ros, 256); 00136 for (size_t i=0; i<ros_counter; ++i) 00137 counter += get_robs(ros[i], &rob[counter], max_count - counter); 00138 ERS_DEBUG_1("Subdetector 0x%x contains %d ROB's", sd.source_id(), 00139 counter); 00140 } 00141 break; 00142 case FULL_EVENT: 00143 { 00144 eformat::FullEventFragment<const uint32_t*> fe(fragment); 00145 const uint32_t* sd[64]; 00146 size_t sd_counter = fe.children(sd, 64); 00147 for (size_t i=0; i<sd_counter; ++i) 00148 counter += get_robs(sd[i], &rob[counter], max_count - counter); 00149 ERS_DEBUG_1("Fullevent 0x%x contains %d ROB's", fe.source_id(), counter); 00150 } 00151 break; 00152 } 00153 00154 return counter; 00155 }
size_t eformat::find_fragments | ( | eformat::HeaderMarker | marker, | |
TPointer | block_start, | |||
size_t | block_size, | |||
TPointer * | frag = 0 , |
|||
size_t | max_count = 0 | |||
) |
A generic method to find all fragments in a contiguous area of memory. These fragments cannot be RODFragments. For that, use the eformat::find_rods().
marker | The marker you are searching for. | |
block_start | A pointer to the block start | |
block_size | The overall size of this block, in 32-bit words | |
frag | A (optional) preallocated set of pointers to hold the found fragments. If frag is NULL, only counts the number of children. | |
max_count | The maximum number of fragments I'll search for, if frag is not NULL. If frag is NULL, this flag has no meaning. |
Definition at line 111 of file util.h.
References counter, EFORMAT_WRONG_MARKER, and next.
Referenced by eformat::Header< TPointer >::children().
00114 { 00115 uint32_t counter = 0; 00116 TPointer next = block_start; 00117 TPointer endp = block_start; 00118 endp += block_size; 00119 while (next < endp) { 00120 if (next[0] != marker) throw EFORMAT_WRONG_MARKER(next[0], marker); 00121 if (frag && counter < max_count) frag[counter] = next; 00122 ++counter; 00123 next += next[1]; 00124 } 00125 return counter; 00126 }
eformat::HeaderMarker eformat::child_marker | ( | HeaderMarker | e | ) |
Returns the child marker of a given parent marker
e | The marker from which you would like to the get child fragment type from |
Definition at line 15 of file HeaderMarker.cxx.
References FULL_EVENT, ROB, ROD, ROS, and SUB_DETECTOR.
Referenced by eformat::Header< TPointer >::children().
00016 { 00017 using namespace eformat; 00018 switch (e) { 00019 case FULL_EVENT: 00020 return SUB_DETECTOR; 00021 case SUB_DETECTOR: 00022 return ROS; 00023 case ROS: 00024 return ROB; 00025 case ROB: 00026 return ROD; 00027 default: 00028 break; 00029 } 00030 return FULL_EVENT; 00031 }
std::string eformat::marker2string | ( | const eformat::HeaderMarker & | e | ) |
Returns a string that represents the string of the equivalent marker
e | The enumeration value |
Definition at line 33 of file HeaderMarker.cxx.
References FULL_EVENT, ROB, ROD, ROS, and SUB_DETECTOR.
00034 { 00035 using namespace eformat; 00036 switch (e) { 00037 case ROD: 00038 return "ROD"; 00039 case ROB: 00040 return "ROB"; 00041 case ROS: 00042 return "ROS"; 00043 case SUB_DETECTOR: 00044 return "SUB_DETECTOR"; 00045 case FULL_EVENT: 00046 return "FULL_EVENT"; 00047 } 00048 return "UNKNOWN_MARKER"; 00049 }
std::string eformat::marker2string | ( | uint32_t | e | ) |
Returns a string that represents the string of the equivalent marker
e | The enumeration value |
Definition at line 51 of file HeaderMarker.cxx.
References marker2string().
00052 { 00053 return marker2string((eformat::HeaderMarker)e); 00054 }
uint32_t* eformat::next_fragment | ( | std::fstream & | fs, | |
uint32_t * | addr = 0 , |
|||
size_t | size = 0 | |||
) |
This function will read the next fragment in a normal, already opened, std::fstream. The space for the fragment will be allocated dynamically and the user should free it. Otherwise, if the user wants to re-use a pre-allocated memory space, the second and third arguments can be given, in which case the function will check if the space is enough. If the space is not enough, NULL is returned.
fs | The input filestream | |
addr | The optional user allocated space | |
size | The optional size, in bytes, of the allocated space |
Definition at line 22 of file util.cxx.
References ERS_DEBUG_2, ERS_DEBUG_3, FULL_EVENT, HEX, ROB, ROD, ROS, and SUB_DETECTOR.
Referenced by main().
00024 { 00025 using namespace eformat; 00026 00027 off_t offset = fs.tellg(); 00028 ERS_DEBUG_3("Current stream position is 0x%lx", offset); 00029 00030 uint32_t data[2]; 00031 if (fs && fs.good() && ! fs.eof()) { 00032 //soft check, so we don't make mistakes 00033 fs.read((char*)data, 8); 00034 if (!fs.good() || fs.eof()) return 0; // end-of-file 00035 switch((HeaderMarker)data[0]) { 00036 case FULL_EVENT: 00037 case SUB_DETECTOR: 00038 case ROS: 00039 case ROB: 00040 case ROD: 00041 break; 00042 default: 00043 //stop! 00044 std::cout << "Word at offset " << HEX(offset) << " is not one of " 00045 << HEX(FULL_EVENT) << ", " 00046 << HEX(SUB_DETECTOR) << ", " 00047 << HEX(ROS) << ", " 00048 << HEX(ROB) << "or " 00049 << HEX(ROS) << ". Stopping execution..." << std::endl; 00050 return 0; 00051 } 00052 } 00053 else return 0; //file is over 00054 00055 //data[1] is the fragment size, in words. Take it and read the fragment 00056 ERS_DEBUG_3("Resetting stream position to 0x%lx...", offset); 00057 fs.seekg(offset); 00058 if (addr && (size >= (data[1]*4))) { 00059 //space is preallocated and checked 00060 ERS_DEBUG_3("Reading fragment data..."); 00061 fs.read((char*)addr, data[1]*4); 00062 ERS_DEBUG_2("Size of fragment readout is %u bytes", 4*data[1]); 00063 ERS_DEBUG_3("Stream position is 0x%lx", offset = fs.tellg()); 00064 return addr; 00065 } 00066 else if (addr) { 00067 std::cout << "The fragment at offset " << HEX(offset) << " has " 00068 << data[1]*4 << " bytes and you provided only " 00069 << size << " bytes in your buffer. Stopping execution..." 00070 << std::endl; 00071 return 0; 00072 } 00073 00074 //if I get here, is because I have to allocate space myself 00075 ERS_DEBUG_3("Allocating fragment data storage of size %ud bytes", 4*data[1]); 00076 uint32_t* retval = new uint32_t[data[1]]; 00077 ERS_DEBUG_3("Reading fragment data..."); 00078 fs.read((char*)retval, data[1]*4); 00079 ERS_DEBUG_2("Size of fragment readout is %u bytes", 4*data[1]); 00080 ERS_DEBUG_3("Stream position is 0x%lx", offset = fs.tellg()); 00081 return retval; 00082 }
size_t eformat::find_rods | ( | const uint32_t * | block_start, | |
size_t | block_size, | |||
const uint32_t ** | rod = 0 , |
|||
uint32_t * | rod_size = 0 , |
|||
size_t | max_count = 0 | |||
) |
Returns pointers (to words) to the start of each ROD fragment block in a piece of memory. This is primarily intended for LVL2 supervisor usage.
block_start | The start address of the data block you want to dig the ROD pointers from | |
block_size | The size of the block, in 32-bit words | |
rod | A (optional) pointer to set of pre-allocated pointers | |
rod_size | A (optional) pointer to set of pre-allocated size_t's, where the size of each ROD, in words, will be stored. | |
max_count | The maximum number of blocks to dig out from block_start , if rod is not NULL. If rod is NULL, this is meaningless. |
Definition at line 84 of file util.cxx.
References counter, EFORMAT_WRONG_MARKER, and ROD.
00087 { 00088 const uint32_t* block_end = block_start + block_size; 00089 size_t counter = 0; 00090 while (block_end > block_start) { 00091 uint32_t curr_rod_size = 12; //< base size for a ROD as eformat 2.4 00092 curr_rod_size += *(block_end-3) + *(block_end-2); //status and data sizes 00093 block_end -= curr_rod_size; 00094 if (rod && counter < max_count) { 00095 if (block_end[0] != eformat::ROD) 00096 throw EFORMAT_WRONG_MARKER(block_end[0], eformat::ROD); 00097 rod_size[counter] = curr_rod_size; 00098 rod[counter] = block_end; 00099 } 00100 ++counter; 00101 } 00102 return counter; 00103 }
size_t eformat::get_robs | ( | const uint32_t * | fragment, | |
const uint32_t ** | rob, | |||
size_t | max_count | |||
) |
Gets pointers to all ROB fragments from a fragment of a type which is not known in advance.
fragment | The top level fragment to extract the other ROBFragment's from. | |
rod | A pointer to set of pre-allocated pointers | |
max_count | The maximum number of blocks to dig out from block_start . |
Definition at line 105 of file util.cxx.
References eformat::Header< TPointer >::children(), counter, ERS_DEBUG_1, FULL_EVENT, get_robs(), genRecEmupikp::i, ROB, ROD, ROS, eformat::Header< TPointer >::source_id(), and SUB_DETECTOR.
Referenced by EFEventLoopMgr::executeEvent(), get_robs(), main(), RawDataInputSvc::nextEvent(), MixerAlg::nextEvent(), and RawEventReader::readEvent().
00107 { 00108 using namespace eformat; 00109 ERS_DEBUG_1("Getting all ROB's from 0x%x...", fragment[0]); 00110 00111 size_t counter = 0; 00112 switch ((eformat::HeaderMarker)(fragment[0])) { 00113 case ROD: 00114 return 0; 00115 case ROB: 00116 { 00117 if ( max_count > 0 ) { 00118 rob[0] = fragment; 00119 ++counter; 00120 } 00121 else return 0; //not enough space 00122 } 00123 break; 00124 case ROS: 00125 { 00126 eformat::ROSFragment<const uint32_t*> ros(fragment); 00127 counter += ros.children(rob, max_count); 00128 ERS_DEBUG_1("ROS 0x%x contains %d ROB's", ros.source_id(), counter); 00129 } 00130 break; 00131 case SUB_DETECTOR: 00132 { 00133 eformat::SubDetectorFragment<const uint32_t*> sd(fragment); 00134 const uint32_t* ros[256]; 00135 size_t ros_counter = sd.children(ros, 256); 00136 for (size_t i=0; i<ros_counter; ++i) 00137 counter += get_robs(ros[i], &rob[counter], max_count - counter); 00138 ERS_DEBUG_1("Subdetector 0x%x contains %d ROB's", sd.source_id(), 00139 counter); 00140 } 00141 break; 00142 case FULL_EVENT: 00143 { 00144 eformat::FullEventFragment<const uint32_t*> fe(fragment); 00145 const uint32_t* sd[64]; 00146 size_t sd_counter = fe.children(sd, 64); 00147 for (size_t i=0; i<sd_counter; ++i) 00148 counter += get_robs(sd[i], &rob[counter], max_count - counter); 00149 ERS_DEBUG_1("Fullevent 0x%x contains %d ROB's", fe.source_id(), counter); 00150 } 00151 break; 00152 } 00153 00154 return counter; 00155 }
const uint32_t eformat::STATUS_FRONT = 0 |
status goes in front of data block
Definition at line 38 of file Status.h.
Referenced by main(), eformat::write::ROBFragment::operator=(), eformat::write::ROBFragment::ROBFragment(), eformat::old::RODFragment::status(), and eformat::write::ROBFragment::status_position().
const uint32_t eformat::STATUS_BACK = 1 |
status goes after data block
Definition at line 39 of file Status.h.
Referenced by eformat::old::RODFragment::data().
const uint32_t eformat::DEFAULT_STATUS = NO_ERROR |
The default status to use
Definition at line 44 of file Status.h.
Referenced by eformat::write::FullEventFragment::FullEventFragment(), eformat::write::ROBFragment::ROBFragment(), eformat::write::ROSFragment::ROSFragment(), and eformat::write::SubDetectorFragment::SubDetectorFragment().
const uint32_t eformat::DEFAULT_VERSION = 0x03000000 |
The default eformat version to use
Definition at line 24 of file Version.h.
Referenced by eformat::write::FullEventFragment::FullEventFragment(), eformat::write::SubDetectorFragment::minor_version(), eformat::write::ROSFragment::minor_version(), eformat::write::ROBFragment::minor_version(), eformat::write::FullEventFragment::minor_version(), eformat::write::ROBFragment::ROBFragment(), eformat::write::ROBFragment::rod_minor_version(), eformat::write::ROSFragment::ROSFragment(), and eformat::write::SubDetectorFragment::SubDetectorFragment().
const uint16_t eformat::MAJOR_DEFAULT_VERSION = 0x0300 |
The major default eformat version to use
Definition at line 29 of file Version.h.
Referenced by eformat::ROBFragment< TPointer >::check(), eformat::Header< TPointer >::check(), eformat::old::convert(), convert_ros(), and main().
const uint16_t eformat::MAJOR_OLD_VERSION = 0x0204 |
The major default eformat version to use
Definition at line 34 of file Version.h.
Referenced by eformat::old::RODFragment::check(), eformat::old::Header::check(), eformat::old::convert(), and convert_ros().