ROOT logo
//*-- AUTHOR : Jerzy Pietraszko, Ilse Koenig
//*-- Created : 03/02/2006

/////////////////////////////////////////////////////////////
//
//  HTrb2Unpacker
//
//  This is a base for decoding TRB data and filling arrays. 
//  Derived classes has to provide methods for filling 
//  Detector's Raw categories.
//
/////////////////////////////////////////////////////////////

#ifndef HTRB2UNPACKER_H
#define HTRB2UNPACKER_H

#include "hldunpack.h"

class HTrb2Correction;
class HTrbnetAddressMapping;

class HTrb2Unpacker : public HldUnpack {

protected:
  HTrb2Unpacker(UInt_t id=0);
  virtual ~HTrb2Unpacker(){;}

  HTrb2Correction* trbinlcorr;          // TDC correctirons for the TRB boards
  HTrbnetAddressMapping* trbaddressmap; // mapping table trbnet-address to TRB board

  UInt_t subEvtId;                      // subevent id
  UInt_t uStartPosition;                // position at which to start decoding.
  UInt_t uTrbNetAdress;                 // TrbNetAdress
  UInt_t uSubBlockSize;                 // BlockSize of SubSubEvent (one TRB)
  UInt_t nCountWords;                   // at which data to start decoding

  Int_t trbDataVer;                     // data structure version:
                                        // info: http://hades-wiki.gsi.de/cgi-bin/view/DaqSlowControl/RpcDataStructure
  Int_t debugFlag;                      //! allows to print subevent information to the STDOUT

  Bool_t quietMode;                     //! do not print errors!
  Bool_t reportCritical;                //! report critical errors!
  Bool_t correctINL;                    //! if > 0 performs the INL correction
  Bool_t correctINLboard;               //! if > 0 performs the INL correction for this TRB
  Bool_t highResModeOn;                 //! is set the data are collected in High Res. Mode - 25ps binning
  Bool_t trbDataPairFlag;               //! data in pair mode (leading and width in one word)

  Float_t trbLeadingTime[128][10];        
  Float_t trbTrailingTime[128][10];      
  Float_t trbADC[128][10];               

  UInt_t trbExtensionSize;
  Int_t trbLeadingMult[128];            
  Int_t trbTrailingMult[128];          
  Int_t trbTrailingTotalMult[128];      // FIXME: Pablos private version; total multiplicity for trailings        
  Int_t trbDataExtension[128];

  Bool_t tryRecover_1;                    //! try to recover broken data format (blocksize out of subevent)
  Bool_t tryRecover_2;                    //! try to recover broken data format (trbnet subsub size not equal subsubsize)
public:
  
  Int_t getSubEvtId(void)  { return subEvtId; }
  Int_t getTrbDataVer(void) const { return trbDataVer; }

  virtual Int_t execute(void){ return 0;};
  virtual Bool_t init(void){ return kFALSE; };
  virtual Int_t decode(void);
  virtual Int_t correctOverflow(void);
  virtual Int_t correctRefTimeCh(Int_t); 
  virtual Int_t correctRefTimeCh31(void);
  virtual Int_t correctRefTimeCh127(void);
  virtual Int_t correctRefTimeStartDet23(void);
  virtual Float_t doINLCorrection(Int_t nTrbCh, Int_t nRawTime);

  void clearAll(void);
  void setQuietMode(void)      {quietMode      = kTRUE;}
  void setReportCritical(void) {reportCritical = kTRUE;}
  void setcorrectINL(void)     {correctINL     = kTRUE;}

  void setDebugFlag(Int_t db)  {debugFlag  = db;};
  Int_t getDebugFlag(){ return debugFlag;};

  void printTdcError(UInt_t e, UInt_t trbId);
  Bool_t fill_trail(Int_t ch,Float_t d);
  Bool_t fill_lead(Int_t ch,Float_t d);
  Bool_t fill_pair(Int_t ch,Float_t time, Float_t length);
  void   tryRecover(Bool_t trycase1=kTRUE,Bool_t trycase2=kTRUE) { tryRecover_1=trycase1; tryRecover_2=trycase2;}
public:
  ClassDef(HTrb2Unpacker,0) //Base class for TRB2 unpackers
};

#endif /* !HTRB2UNPACKER_H */


 htrb2unpacker.h:1
 htrb2unpacker.h:2
 htrb2unpacker.h:3
 htrb2unpacker.h:4
 htrb2unpacker.h:5
 htrb2unpacker.h:6
 htrb2unpacker.h:7
 htrb2unpacker.h:8
 htrb2unpacker.h:9
 htrb2unpacker.h:10
 htrb2unpacker.h:11
 htrb2unpacker.h:12
 htrb2unpacker.h:13
 htrb2unpacker.h:14
 htrb2unpacker.h:15
 htrb2unpacker.h:16
 htrb2unpacker.h:17
 htrb2unpacker.h:18
 htrb2unpacker.h:19
 htrb2unpacker.h:20
 htrb2unpacker.h:21
 htrb2unpacker.h:22
 htrb2unpacker.h:23
 htrb2unpacker.h:24
 htrb2unpacker.h:25
 htrb2unpacker.h:26
 htrb2unpacker.h:27
 htrb2unpacker.h:28
 htrb2unpacker.h:29
 htrb2unpacker.h:30
 htrb2unpacker.h:31
 htrb2unpacker.h:32
 htrb2unpacker.h:33
 htrb2unpacker.h:34
 htrb2unpacker.h:35
 htrb2unpacker.h:36
 htrb2unpacker.h:37
 htrb2unpacker.h:38
 htrb2unpacker.h:39
 htrb2unpacker.h:40
 htrb2unpacker.h:41
 htrb2unpacker.h:42
 htrb2unpacker.h:43
 htrb2unpacker.h:44
 htrb2unpacker.h:45
 htrb2unpacker.h:46
 htrb2unpacker.h:47
 htrb2unpacker.h:48
 htrb2unpacker.h:49
 htrb2unpacker.h:50
 htrb2unpacker.h:51
 htrb2unpacker.h:52
 htrb2unpacker.h:53
 htrb2unpacker.h:54
 htrb2unpacker.h:55
 htrb2unpacker.h:56
 htrb2unpacker.h:57
 htrb2unpacker.h:58
 htrb2unpacker.h:59
 htrb2unpacker.h:60
 htrb2unpacker.h:61
 htrb2unpacker.h:62
 htrb2unpacker.h:63
 htrb2unpacker.h:64
 htrb2unpacker.h:65
 htrb2unpacker.h:66
 htrb2unpacker.h:67
 htrb2unpacker.h:68
 htrb2unpacker.h:69
 htrb2unpacker.h:70
 htrb2unpacker.h:71
 htrb2unpacker.h:72
 htrb2unpacker.h:73
 htrb2unpacker.h:74
 htrb2unpacker.h:75
 htrb2unpacker.h:76
 htrb2unpacker.h:77
 htrb2unpacker.h:78
 htrb2unpacker.h:79
 htrb2unpacker.h:80
 htrb2unpacker.h:81
 htrb2unpacker.h:82
 htrb2unpacker.h:83
 htrb2unpacker.h:84
 htrb2unpacker.h:85
 htrb2unpacker.h:86
 htrb2unpacker.h:87
 htrb2unpacker.h:88
 htrb2unpacker.h:89
 htrb2unpacker.h:90
 htrb2unpacker.h:91
 htrb2unpacker.h:92
 htrb2unpacker.h:93
 htrb2unpacker.h:94