00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef DIF_READER_HH
00013 #define DIF_READER_HH
00014
00015 #include <stdio.h>
00016 #include "AcquisitionParser.hh"
00017 #include <sstream>
00018 #include <map>
00019
00020 class Run;
00021
00022
00023
00024
00025
00026 #define BUFFER_SIZE (1024*1024)
00027
00028
00029 typedef struct {
00030 } bitstream;
00031
00032
00033
00034
00035
00036 #define HGN 0xB0 // Header Global Numerique
00037 #define TGN 0xA0 // Trailer Global Numerique, for each hardroc
00038 #define HDHR 0xB4 // Header Data Hardroc
00039 #define TDHR 0xA3 // Trailer Data Hardroc
00040 #define HSC 0xB1 // Header Slow Control data
00041 #define TSC 0xA1 // Trailer Slow Control data
00042
00043
00044
00045 class DifReader : public AcquisitionParser {
00046
00047 public:
00048 DifReader(Run& aRun, FILE *aFile,ui32 firstEventId);
00049 unsigned int getBinData(const int nBytes);
00050 unsigned char *getBinData(const int nBytes, unsigned char *data);
00051 unsigned int getData(const int nBytes);
00052 unsigned char *getData(const int nBytes, unsigned char *data);
00053
00054
00055 private :
00056 unsigned char *bitBuffer;
00057 int bitBufCount;
00058 int bitByteIdx;
00059 int bitIdx;
00060 bool bitBinaryFile;
00061 unsigned char *getBitData();
00062 protected:
00063
00064 unsigned char *initGetBits(const int bufLen, const bool binaryFile);
00065
00066 void finishGetBits();
00067
00068 unsigned int getBit();
00069
00070 unsigned int getBits(const int nBits);
00071 int seekSyncBits(unsigned int sync, const int nBits);
00072 int getBitBufferData(void *buffer, const int len);
00073
00074
00075 public:
00076 inline void setDisplay() { displayData = 1; };
00077 inline int Error() { return fileError; };
00078 void display(const int inc = 0);
00079 inline void Level(const int l) { level = l; };
00080 inline int& Level() { return(level); };
00081
00082
00083 protected:
00084 int fileError;
00085 int displayData;
00086 int level;
00087 int line;
00088 std::ostringstream dataBuf;
00089 void putData(const unsigned int data, const int nBytes);
00090 void putData(const unsigned char *buf, const int nBytes);
00091 void putBinData(const unsigned char *buf, const int nBytes);
00092
00093 i64 globalTime;
00094 i64 globalTimeMilli;
00095 typedef std::map<i32, i64> BcIdDifAbsOrgMap_t;
00096 BcIdDifAbsOrgMap_t bcIdDifAbsOrgMap;
00097 const i64 getbcIdAbsOrg(const i32 difId, const i64 bcIdAbs);
00098 };
00099
00100 #endif // DIF_READER_HH