///////////////////////////////////////////////////////////// // // HTrb3TdcUnpacker // // This is class to unpack and calibrate data of single FPGA TDC // It should be similar to functionality of hadaq::TdcProcessor from 'stream' framework // ///////////////////////////////////////////////////////////// #ifndef HTRB3TDCUNPACKER_H #define HTRB3TDCUNPACKER_H #include "htrb3unpacker.h" #include "htrb3calpar.h" #include "hades.h" #include "hevent.h" #include "heventheader.h" #include "TObject.h" #include #include class HTrb3CalparTdc; class HTrb3TdcUnpacker : public HTrb3Unpacker { #define REFCHAN 0 //#define USE_FILLED_TDC 1 // switch to use list of TDCs with data only (CAUTION: TDC with missing ref time will not emmit warnings if they don't transport data) public: struct ChannelRec { Double_t rising_tm[10]; Double_t falling_tm[10]; UInt_t rising_mult; UInt_t falling_mult; Bool_t hasData; ChannelRec() : rising_mult(0), falling_mult(0), hasData(kFALSE) {} void clear() { rising_mult = 0; falling_mult = 0; hasData = kFALSE; } void addHit(Bool_t rising, Double_t tm) { if (rising) { if (rising_mult < 10) rising_tm[rising_mult++] = tm; } else { if (falling_mult < 10) falling_tm[falling_mult++] = tm; } hasData = kTRUE; } Double_t getHit(Bool_t rising, UInt_t cnt) { return rising ? (cnt0 ? rising_tm[rising_mult-1] : 0.) : (falling_mult>0 ? falling_tm[falling_mult-1] : 0.); } void substractRefTime(Double_t reftm) { for (UInt_t n=0;nchanList; // list of channels containing data (if USE_FILLED_TDC is defined) Bool_t fhasData ; //! TDC(size_t numchannels=maxchan) : pSubEvtId(0), fTdcId(0), nChan(numchannels), fNcalibr(0), fFoundInStream(kFALSE) { chanList.reserve(maxchan); } void clear() { for (UInt_t i = 0; i < nChan; ++i) fCh[i].clear(); chanList.clear(); fhasData = kFALSE; } Bool_t hasData(){ for (UInt_t ch=0;ch=numChannels()) return kFALSE; if(!fhasData) return kTRUE; if(!fFoundInStream) return kTRUE; // skipp empty data if (fCh[refch].rising_mult<=0) { Long_t seqnum = -1; if (gHades != 0 && gHades->getCurrentEvent() != 0 && gHades->getCurrentEvent()->getHeader() != 0) { seqnum = gHades->getCurrentEvent()->getHeader()->getEventSeqNumber(); } cerr << " Warning: No reference time for trb=0x" << hex << getTrbAddr() <<" sub event 0x"<