#ifndef TTripTOldHistoBank_hxx_seen #define TTripTOldHistoBank_hxx_seen // $Id: ITripTOldHistoBank.hxx,v 1.2 2009/09/25 06:02:33 nickwest Exp $ // // The ProHisto class is for the prototype histogram bank used in the first implementation // of the DPT. The ITripTHistoBank and IMidasTripTHisto banks are used for the new // version of the DPT (developed in July 2009, installed a month or two later). #include "rawdpt_data_format.h" #include #include #define TTRIPT_OLDHISTO_BANK_TITLE "TripT Prorotype Histogram Bank" namespace COMET { class ITripTOldHistoBank; class IMidasTripTOldHistoItr; }; /// This is the Access Class for all TripT banks hold hit /// (two ADCs and one TDC) data. It provides getters for the data in /// its header and an iterator over a set of TMidasTripTOldHistos. /// /// For an introduction to this and other Access Classes please see /// \ref oaRawEvent class COMET::ITripTOldHistoBank: public COMET::IMidasBank { public: ITripTOldHistoBank(); explicit ITripTOldHistoBank(const ULong64_t *bank, const char* title = TTRIPT_OLDHISTO_BANK_TITLE); virtual ~ITripTOldHistoBank(); /// Print contents to COMETLog void Print(const Option_t* opt = "") const; // Access methods // These get moved to rawdpt_data_format.h #define RAWDPT_HPS_RMM 2 #define RAWDPT_HSS_RMM 0 #define RAWDPT_HMS_RMM 0x0003 #define RAWDPT_HPS_ENCODING 2 #define RAWDPT_HSS_ENCODING 2 #define RAWDPT_HMS_ENCODING 0x000C #define RAWDPT_HPS_XCHAN 2 #define RAWDPT_HSS_XCHAN 4 #define RAWDPT_HMS_XCHAN 0x0030 #define RAWDPT_HPS_BINDEFLEN 3 #define RAWDPT_HPS_SEQ 4 #define RAWDPT_HPS_SEQMAX 5 #define RAWDPT_HPS_BINDEF 6 #define RAWDPT_HVS_HISTSIZE 1024 #define RAWDPT_HVS_BINDEFMAX 1024 #define RAWDPT_HVS_OFFSET1 6 #define RAWDPT_HVS_OFFSET2 4*48 // = NTRIP*NTFB /// Return the RMM number UInt_t GetRMM() const { return (*(this->GetData16()+ RAWDPT_HPS_RMM) & RAWDPT_HMS_RMM) >> RAWDPT_HSS_RMM; } /// Return the encoding type - only encoding 0 is known for now UInt_t GetEncoding() const { return (*(this->GetData16()+ RAWDPT_HPS_ENCODING) & RAWDPT_HMS_ENCODING) >> RAWDPT_HSS_ENCODING; } /// Return the number of extra channels included (extra channels are the TripT channels which are not connected to the detector UInt_t GetNExtraChan() const { return (*(this->GetData16()+ RAWDPT_HPS_XCHAN) & RAWDPT_HMS_XCHAN) >> RAWDPT_HSS_XCHAN; } /// Get the number of histograms in total (not just the ones in this bank). This is the size of /// the index table UInt_t GetNumAllHisto() const { return RAWDPT_HVS_OFFSET2*(16 + this->GetNExtraChan()); } /// Return the length of the bin definition sequence UInt_t GetBinDefLen() const { return (*(this->GetData16()+ RAWDPT_HPS_BINDEFLEN)); } /// Return pointer to the start of the bin definition sequence const UChar_t* GetBinDefStart() const { return ( reinterpret_cast (this->GetData16() + RAWDPT_HVS_OFFSET1 + this->GetNumAllHisto() )); } /// Return pointer to start of the histograms const UChar_t* GetHistoStart() const { UInt_t shortoffset = RAWDPT_HVS_OFFSET1 + this->GetNumAllHisto(); UInt_t byteoffset = this->GetBinDefLen(); return (this->GetData8() + (shortoffset << 1) + byteoffset); } /// Return the sequence (e.g. 0 of 4, 1 of 4, 2 of 4, 3 of 4 (starts at zero, goes to this->GetSeqMax()-1 ) UInt_t GetSeq() const { return (*(this->GetData16()+ RAWDPT_HPS_SEQ)); } /// Return the encoding type - only encoding 0 is known for now UInt_t GetSeqMax() const { return (*(this->GetData16()+ RAWDPT_HPS_SEQMAX)); } /// Return the max size a histogram could be UInt_t GetMaxHistSize() const { return RAWDPT_HVS_HISTSIZE; } /// Return the max size a bin def list could be once unpacked UInt_t GetMaxBinDef() const { return RAWDPT_HVS_BINDEFMAX; } /// Return the bin definition in raw pairs (starting ADC value, no of bins). You must pass in a preallocated area of memory at least this->GetMaxBinDef() Int_t long. void GetBinDef(UInt_t *bd) const; /// Return low edge (le) and width (w) of each histogram bin from raw definition /// in arrays of at least this->GetMaxHistSize(). Function returns the number of bins UInt_t DecodeBins(UInt_t *le, UInt_t *w) const; /// Fatser version of UInt_t DecodeBins(UInt_t *le, UInt_t *w); if the user has already /// unpacked the bin definition in bd[]. UInt_t DecodeBins(UInt_t *le, UInt_t *w, const UInt_t *bd) const; /// Scooped up from the online code... the online print routine void PrintPackedHistoBlock(const unsigned char *buff, int nbuffmax) const; /// Apart from the methods to move through the list of histograms, the iterator /// has one Getter method itr->GetBinContents(UInt_t *c); Where c is an array /// of at least this->GetMaxHistSize() COMET::IMidasTripTOldHistoItr GetMidasTripTOldHistoItr() const; //#define TESTBINDEF #ifdef TESTBINDEF /// Bin Definition Unpacking Test Routine void TestBinDef(const char *c, const UInt_t *bd) const; /// Do some tests... void DoTestBinDef() const; #endif }; #endif