00001 #ifndef TGET4HITUNPACKED_H 00002 #define TGET4HITUNPACKED_H 00003 00004 #include "roc/Message.h" 00005 #include "TObject.h" 00006 00007 #define BIN_SIZE_IN_NS 0.05 00008 #define EPOCH_IN_BINS 524288 00009 #define EPOCH_IN_NS 26214.4 00010 #define CYCLE_IN_EPOCHS 1048576 00011 00012 #define TIME_GATE 0.05 // Messages are accepted only if the epoch 00013 // difference is less than +/- TIME_GATE 00014 00015 class CENoGET4DataEvent 00016 { 00017 public: 00018 UChar_t ucMessType; 00019 CENoGET4DataEvent( UChar_t typ_in) 00020 { 00021 ucMessType = typ_in; 00022 } 00023 }; 00024 00025 class CELeadingEdgeAlreadySet 00026 { 00027 }; 00028 00029 class CETrailingEdgeAlreadySet 00030 { 00031 }; 00032 00033 class CEGivesNegativeToT 00034 { 00035 }; 00036 00037 class CEOutOfTimeGate 00038 { 00039 }; 00040 00041 class CEHitIsNotComplete 00042 { 00043 }; 00044 class CEOutOfTimeGateDetail 00045 { 00046 public: 00047 Double_t tot; // raw tot 00048 Double_t tot_past; // tot - value of 1 epoch 00049 CEOutOfTimeGateDetail( Double_t tot_in) 00050 { 00051 tot = tot_in; 00052 tot_past = tot_in - TIME_GATE*EPOCH_IN_NS; 00053 } 00054 }; 00055 00056 class CEGivesNegativeToTDetail 00057 { 00058 public: 00059 Double_t tot; // raw tot 00060 Double_t tot_fut; // tot - value of 1 epoch 00061 CEGivesNegativeToTDetail( Double_t tot_in) 00062 { 00063 tot = tot_in; 00064 tot_fut = tot_in + TIME_GATE*EPOCH_IN_NS; 00065 } 00066 }; 00067 00068 #include "TObject.h" 00069 00070 #include <stdint.h> 00071 00072 class TGet4HitUnpacked: public TObject 00073 { 00074 ClassDef(TGet4HitUnpacked, 1); //The class title 00075 00076 protected: 00077 UChar_t uc_get4; 00078 UChar_t uc_channel; 00079 00080 UInt_t u_EpochCycleLeading; 00081 ULong64_t u_EpochNoLeadingEdge; 00082 UInt_t u_TsLeadingEdge; 00083 UInt_t u_EpochCycleTrailing; 00084 ULong64_t u_EpochNoTrailingEdge; 00085 UInt_t u_TsTrailingEdge; 00086 00087 Bool_t m_bLeadingEdgeSet; 00088 Bool_t m_bTrailingEdgeSet; 00089 00090 00091 public: 00092 TGet4HitUnpacked( void ); 00093 TGet4HitUnpacked & operator=( const TGet4HitUnpacked &) ; // Copy constructor, needed for memory reason? 00094 00095 #ifndef ROC_GET4_BUILDEVENT 00096 // Definition check because ROOT did not aknowledge roc::message in 00097 // old versions 00098 // Maybe unnecessary 00099 void SetMessage( roc::Message &, ULong64_t , UInt_t ); 00100 #endif // ROC_GET4_BUILDEVENT 00101 00102 void ClearHit( void ); 00103 Bool_t Complete( void ) const; 00104 Double_t GetTOT( void ) const; 00105 Long64_t GetRawTOT( void ) const; 00106 Double_t Spacing( const TGet4HitUnpacked & ) const; 00107 Int_t CyclesDiff( const TGet4HitUnpacked & ) const; 00108 Int_t EpochsDiff( const TGet4HitUnpacked & ) const; 00109 00110 UChar_t GetGet4Index() const; 00111 UChar_t GetChannel() const; 00112 UInt_t GetFullChan() const; 00113 UInt_t GetEpochCycleLeading() const; 00114 ULong64_t GetEpochLeading() const; 00115 UInt_t GetTsLeading() const; 00116 UInt_t GetEpochCycleTrailing() const; 00117 ULong64_t GetEpochTrailing() const; 00118 UInt_t GetTsTrailing() const; 00119 ULong64_t GetFullTime() const; 00120 ULong64_t GetFullTimeSeconds() const; 00121 00122 void SetGet4Index(UChar_t); 00123 void SetChannel(UChar_t); 00124 void SetFullChan(UInt_t); 00125 // Used normally only for EXT_SYNC messages 00126 void SetEpochLeading(ULong64_t, UInt_t); 00127 void SetTsLeading(UInt_t); 00128 00129 Bool_t IsLeadingSet() const; 00130 Bool_t IsTrailingSet() const; 00131 00132 Long64_t EpochEdgesDiff(); 00133 00134 /* This is the function used to sort Hits in a list in 00135 * function TimeOrderBlock 00136 * For this, it compares 00137 * 1) The epoch index cycles 00138 * 2) The epoch indexes 00139 * 3) the leading edge timestamps 00140 */ 00141 bool operator<(const TGet4HitUnpacked &rhs) const; 00142 }; 00143 00144 #endif // TGET4HITUNPACKED_H