/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/include/parser/DifReader.hh

Go to the documentation of this file.
00001 /* @version $Revision: 1850 $ * @modifiedby $Author: jacquem $ * @lastmodified $Date: 2012-08-22 09:59:31 +0200 (Wed, 22 Aug 2012) $ */
00002 
00003 ////////////////////////////////////////////////////////////////////////
00004 // MICROMEGAS
00005 //
00006 //       EVENT RECONSTRUCTION SOFTWARE FOR DIF-BASED BOARDS
00007 //
00008 ////////////////////////////////////////////////////////////////////////
00009 // created 26.10.2009
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 /* bitstream stuff */
00023 /* Warning this value must be greater than the size of N+1 compressed */
00024 /* frames (including I,P and B frame)                                 */
00025 /* where N is the distance between I and P frames                     */
00026 #define BUFFER_SIZE (1024*1024)
00027 //typedef int HANDLE;
00028 
00029 typedef struct {
00030 } bitstream;
00031 
00032 //////////////////////////////////////////////////////////////////////////
00033 // file markers
00034 // NB : the bit pattern for digits 0xA and 0xB allow to distinguish between a header
00035 //      and a data error (Hardroc only)
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 // the generic class for every DifReader - every class should derive from this one
00045 class DifReader : public AcquisitionParser {
00046   //------ methods --------//
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   // bit handling
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     /* read the stream for bit reading */
00064     unsigned char *initGetBits(const int bufLen, const bool binaryFile);
00065     /* free allocated resources */
00066     void finishGetBits();
00067     /* read 1 bit from the bit stream */
00068     unsigned int getBit();
00069     /* read N bits from the bit stream */
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   // display and debugging functions
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   //------ data members -------//
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;                // the global (unix) timestamp in seconds
00094     i64 globalTimeMilli;           // the global (unix) timestamp in millisecond
00095     typedef std::map<i32, i64> BcIdDifAbsOrgMap_t; // list of the absolute bcIds for each DIF
00096     BcIdDifAbsOrgMap_t bcIdDifAbsOrgMap;
00097     const i64 getbcIdAbsOrg(const i32 difId, const i64 bcIdAbs);
00098 }; // class DifReader
00099 
00100 #endif // DIF_READER_HH

Generated on Mon Jan 7 13:15:20 2013 for MicromegasFramework by  doxygen 1.4.7