MiniballSort
Loading...
Searching...
No Matches
MidasConverter.hh
Go to the documentation of this file.
1#ifndef __MIDASCONVERTER_HH
2#define __MIDASCONVERTER_HH
3
4// MiniballConverter header
5#ifndef __CONVERTER_HH
6# include "Converter.hh"
7#endif
8
9
11
12public:
13
14 MiniballMidasConverter( std::shared_ptr<MiniballSettings> myset )
16 mbs_data = false;
17 midas_data = true;
18 med_data = false;
19 };
21
22 int ConvertFile( std::string input_file_name,
23 unsigned long start_block = 0,
24 long end_block = -1 );
25 int ConvertBlock( char *input_block, long nblock );
26
27 bool ProcessCurrentBlock( long nblock );
28
29 void SetBlockHeader( char *input_header );
30 void ProcessBlockHeader( long nblock );
31
32 void SetBlockData( char *input_data );
33 void ProcessBlockData( long nblock );
34
35 bool GetFebexChanID();
36 int ProcessTraceData( int pos );
37 void ProcessFebexData( long nblock );
38 void FinishFebexData( long nblock );
39 void ProcessInfoData( long nblock );
40
41
42
43private:
44
45 // enumeration for swapping modes
46 enum swap_t {
47 SWAP_KNOWN = 1, // We know the swapping mode already
48 SWAP_WORDS = 2, // We need to swap pairs of 32-bit words
49 SWAP_ENDIAN = 4 // We need to swap endianness
50 };
51 Int_t swap;
52
53 // Swap endianness of a 32-bit integer 0x01234567 -> 0x67452301
54 inline UInt_t Swap32(UInt_t datum) {
55 return(((datum & 0xFF000000) >> 24) |
56 ((datum & 0x00FF0000) >> 8) |
57 ((datum & 0x0000FF00) << 8) |
58 ((datum & 0x000000FF) << 24));
59 };
60
61 // Swap the two halves of a 64-bit integer 0x0123456789ABCDEF ->
62 // 0x89ABCDEF01234567
63 inline ULong64_t SwapWords(ULong64_t datum) {
64 return(((datum & 0xFFFFFFFF00000000LL) >> 32) |
65 ((datum & 0x00000000FFFFFFFFLL) << 32));
66 };
67
68 // Swap endianness of a 64-bit integer 0x0123456789ABCDEF ->
69 // 0xEFCDAB8967452301
70 inline ULong64_t Swap64(ULong64_t datum) {
71 return(((datum & 0xFF00000000000000LL) >> 56) |
72 ((datum & 0x00FF000000000000LL) >> 40) |
73 ((datum & 0x0000FF0000000000LL) >> 24) |
74 ((datum & 0x000000FF00000000LL) >> 8) |
75 ((datum & 0x00000000FF000000LL) << 8) |
76 ((datum & 0x0000000000FF0000LL) << 24) |
77 ((datum & 0x000000000000FF00LL) << 40) |
78 ((datum & 0x00000000000000FFLL) << 56));
79 };
80
81 // Get nth word
82 inline ULong64_t GetWord( UInt_t n = 0 ){
83
84 // If word number is out of range, return zero
85 if( n >= WORD_SIZE ) return(0);
86
87 // Perform byte swapping according to swap mode
88 ULong64_t result = data[n];
89 if (swap & SWAP_ENDIAN) result = Swap64(result);
90 if (swap & SWAP_WORDS) result = SwapWords(result);
91 return(result);
92
93 };
94
95
96 // Set the size of the block and its components.
97 static const int HEADER_SIZE = 24; // Size of header in bytes
98 static const int DATA_BLOCK_SIZE = 0x10000; // Block size for FEBEX data = 64 kB?
100 static const int WORD_SIZE = 5 * ( MAIN_SIZE / ( 5 * sizeof(ULong64_t) ) );
101 unsigned int BLOCKS_NUM = 0;
102
103 // Set the arrays for the block components.
106
107 // Data words - 1 word of 64 bits (8 bytes)
108 ULong64_t word;
109
110 // Data words - 2 words of 32 bits (4 byte).
111 UInt_t word_0;
112 UInt_t word_1;
113
114 // Pointer to the data words
115 ULong64_t *data;
116
117 // End of data in a block looks like:
118 // word_0 = 0xFFFFFFFF, word_1 = 0xFFFFFFFF.
119 // This flag is set true when we hit that point
121
122 // Raw data variables
123 Char_t header_id[8]; // 8 byte. Must be this string 'EBYEDATA'.
124 UInt_t header_sequence; // 4 byte.
125 UShort_t header_stream; // 2 byte.
126 UShort_t header_tape; // 2 byte.
127 UShort_t header_MyEndian; // 2 byte. If 1 then correct endianess.
128 UShort_t header_DataEndian; // 2 byte.
129 UInt_t header_DataLen; // 4 byte.
130
131};
132
133#endif
void SetBlockData(char *input_data)
void ProcessFebexData(long nblock)
void ProcessBlockHeader(long nblock)
void FinishFebexData(long nblock)
ULong64_t SwapWords(ULong64_t datum)
static const int WORD_SIZE
MiniballMidasConverter(std::shared_ptr< MiniballSettings > myset)
char block_data[MAIN_SIZE]
static const int DATA_BLOCK_SIZE
void ProcessBlockData(long nblock)
static const int HEADER_SIZE
UInt_t Swap32(UInt_t datum)
int ConvertFile(std::string input_file_name, unsigned long start_block=0, long end_block=-1)
bool ProcessCurrentBlock(long nblock)
ULong64_t GetWord(UInt_t n=0)
int ConvertBlock(char *input_block, long nblock)
void SetBlockHeader(char *input_header)
char block_header[HEADER_SIZE]
static const int MAIN_SIZE
ULong64_t Swap64(ULong64_t datum)
void ProcessInfoData(long nblock)
std::shared_ptr< MiniballSettings > myset
Definition mb_sort.cc:123