00001 #ifndef TGET4V1REC_H 00002 #define TGET4V1REC_H 00003 00004 00005 #include <vector> 00006 #include <stdint.h> 00007 00008 #include "TCBMBeamtimeProc.h" 00009 #include "roc/Iterator.h" 00010 #include "roc/Message.h" 00011 #include "roc/Board.h" 00012 #include "TGet4v1Event.h" 00013 #include "TGet4v1Param.h" 00014 00015 class TGet4Param; 00016 class TGo4MbsSubEvent; 00017 class TLatex; 00018 00019 class TGo4WinCond; 00020 00021 #define NUM_DIFFS 16 00022 #define MOD_DIFFS 7 00023 00024 struct TGet4v1Rec { 00025 00026 Int_t fRocId; 00027 roc::Iterator fIter; // iterator of current roc input buffer 00028 00029 TH1* fMsgTypes; // messages types 00030 TH1* fSysTypes; // system messages types 00031 TH1* fSysUserTypes; // user system messages 00032 TH1* fAUXch; // filling of AUX channels 00033 00034 TH1* fTrigger_All; // time shift between last trigger and hit 00035 TH1* fTrigger_AUX; // time shift between last trigger and all AUX 00036 TH1* fTrigger_All_100; // time shift between last trigger and hit (100ns bin) 00037 TH1* fTrigger_All_us; // time shift between last trigger and hit (1 us bin) 00038 TH1* fTrigger_All_ms; // time shift between last trigger and hit (1 ms bin) 00039 TH1* fTrigger_All_s; // time shift between last trigger and hit (1 s bin) 00040 TGo4WinCond* fTriggerWind; // time window to assign hits to event (relative to last trigger) 00041 TGo4WinCond* fAUXWind; // time window to assign AUX to event (relative to last trigger, differs from NX messages) 00042 TGo4WinCond* fSelfTrigWind; // time window to detect trigger inside data themselves 00043 TH1* fEvntMultipl; // event multiplicity (how many messages selected) 00044 00045 TH1* fALLt; // time distribution of all signals 00046 TH1* fDATAt; // time distribution of data signals 00047 TH1* fERRORt; // time distribution of error signals 00048 TH1* fSLOWCt; // time distribution of slow control signals 00049 TH1* fSelfTriggT; // time distribution of triggers from data 00050 TH1* fAUXt[MAX_AUX]; // time distribution of aux signals 00051 TH1* fSYNCt[MAX_SYNC]; // time distribution of sync signals 00052 TH1* fEPOCHt; // time distribution of epoch signals 00053 TH1* fEPOCH2t[MAX_GET4_PER_ROC]; // time distribution of epoch signals 00054 TH1* fAllSelectedT; // time distribution of all selected hits in an event 00055 TH1* fSelectedT[MAX_GET4_PER_ROC][NB_CHAN_GET4]; // time distribution of hits selected in an event 00056 00057 // Long duration time distribution (1 min. bin, 10 days length) 00058 TH1* fAllLongT; // Long time distribution of all signals 00059 TH1* fDataLongT; // Long time distribution of data signals 00060 TH1* fErrorLongT; // Long time distribution of error signals 00061 TH1* fSlowCLongT; // Long time distribution of slow control signals 00062 TH1* fSelfTriggLongT; // Long time distribution of triggers from data 00063 TH1* fSyncLongT[MAX_SYNC]; // Long time distribution of sync signals 00064 TH1* fEpochLongT; // Long time distribution of epoch signals 00065 TH1* fAllEpoch2LongT; // Long time distribution of all epoch2 signals 00066 TH1* fAllSelLongT; // Long time distribution of all selected hits in an event 00067 00068 uint64_t fLastTm; // 00069 uint64_t fLastTriggerTm; // last time of trigger signal (defined by parameter) 00070 uint64_t fLastAuxTm[MAX_AUX]; // last time of rising edge of AUX signals 00071 uint64_t fLastSyncTm[MAX_SYNC]; // last time of SYNC signals 00072 uint32_t fLastSyncId[MAX_SYNC]; // last ID of SYNC signals 00073 uint64_t fStartSyncTm; // time of SYNC signal in the beginning of subevent 00074 uint64_t fStopSyncTm; // time of SYNC signal at the end of subevent 00075 00076 std::vector<TGet4v1MessageExtended> fUnprocessedMsg; // buffer of not accounted hit messages of previous mbs evnts 00077 00078 Int_t fDabcSeparator; // sync id of the dabc event separator. For event finalizing condition 00079 00080 Bool_t bIgnoreData; // true when data should be ignored during reconfiguration 00081 Int_t fIgnoreCnt; // counter used to process data when ignored, reset when ignore activated 00082 uint64_t fIgnoreTime; // time when ignore message was generated 00083 uint64_t fCollectTime; // time when collect message was generated 00084 00085 /* Modified part */ 00086 00087 // Epochs 00088 UInt_t fuCurrEpoch; // current epoch on the roc 00089 UInt_t fuEpochCycle; // Number of time the epoch counter cycled 00090 UInt_t fuCurrEpoch2[MAX_GET4_PER_ROC]; // current epoch2 for each get4 chip 00091 UInt_t fuEpoch2Cycle[MAX_GET4_PER_ROC]; // Number of time the epoch2 counter cycled 00092 TH1 *fDistribEpochs; 00093 TH2 *fDistribEpochs2; 00094 TH2 *fEpochShiftsPerChip; 00095 TH2 *fEpochShiftsDurationPerChip; 00096 Int_t fiEpochShift[MAX_GET4_PER_ROC]; 00097 UInt_t fuNbShiftedEpochs[MAX_GET4_PER_ROC]; 00098 TH2 *fEpochShiftsDuration[MAX_GET4_PER_ROC]; 00099 00100 // Buffers 00101 // ROC 00102 Bool_t fbBufferWithLastFullEpoch; 00103 std::vector<TGet4v1MessageExtended> fPrevEpochsBuffer[2]; // buffer of all ROC messages in current epoch and previous one 00104 Bool_t fbEpochSinceTrigger; 00105 // GET4s 00106 Bool_t fbBufferWithLastFullEpoch2[MAX_GET4_PER_ROC]; 00107 std::vector<TGet4v1MessageExtended> fPrevEpochs2Buffer[MAX_GET4_PER_ROC][2]; // buffer of all get4 messages in current epoch and previous one 00108 Bool_t bLookInPreviousEpoch[MAX_GET4_PER_ROC]; 00109 Bool_t bLookInNextEpoch[MAX_GET4_PER_ROC]; 00110 Bool_t fbEpoch2SinceTrigger[MAX_GET4_PER_ROC]; 00111 00112 // HitsSelection 00113 Bool_t fbSelectionRocDone; 00114 Bool_t fbSelectionDone[MAX_GET4_PER_ROC]; 00115 Bool_t fbDataTimeOut[MAX_GET4_PER_ROC][NB_CHAN_GET4]; 00116 Bool_t fbDataFallingOut[MAX_GET4_PER_ROC][NB_CHAN_GET4]; 00117 TH1* fTrigger_Get4Channel[MAX_GET4_PER_ROC][NB_CHAN_GET4]; // time shift between last trigger and hit in this Get4 channel 00118 TH1* fTriggerMs_Get4Channel[MAX_GET4_PER_ROC][NB_CHAN_GET4]; // time shift between last trigger and hit in this Get4 channel 00119 TH1* fTriggerS_Get4Channel[MAX_GET4_PER_ROC][NB_CHAN_GET4]; // time shift between last trigger and hit in this Get4 channel 00120 00121 // Triggering on data themselves 00122 TH2* fDataSelfTriggerPerEvent; 00123 TH2* fDataSelfTrigDistanceNs; 00124 TH2* fDataSelfTrigDistanceUs; 00125 TH2* fDataSelfTrigDistanceMs; 00126 TH2* fDataSelfTrigDistanceS; 00127 00128 UInt_t fuDataSelfTriggerCount[MAX_DATA_TRIGG]; 00129 Double_t fdLastFullTimeSelfTrigger[MAX_DATA_TRIGG]; 00130 TGet4v1MessageExtended fextMessLastMainChannel[MAX_DATA_TRIGG]; 00131 Double_t fdLastFullTimeMainChannelTot[MAX_DATA_TRIGG]; 00132 Double_t fdLastFullTimeSecChannel[MAX_DATA_TRIGG][MAX_SEC_TRIG]; 00133 Double_t fdLastFullTimeSecChannelTot[MAX_DATA_TRIGG][MAX_SEC_TRIG]; 00134 00135 // Event statistics 00136 TH1* fNbEventsPerMbsEvent; 00137 TH1* fNbNotEmptyEventsPerMbsEvent; 00138 TH2 *fChannelsMapping; 00139 TH1 *fChannelInputMessCount; 00140 TH2 *fChannelMultiplicity; 00141 TH1 *fChipRateEvolution[MAX_GET4_PER_ROC]; 00142 TH1 *fChannelRateEvolution[MAX_GET4_PER_ROC][NB_CHAN_GET4]; 00143 Double_t fdRateEvolutionBinSize; 00144 UInt_t fuNbHitsChipEpoch[MAX_GET4_PER_ROC]; 00145 00146 00147 /* 00148 * 24 & 32 bits variables & histograms 00149 */ 00150 TH1 *fRawTot[MAX_GET4_PER_ROC][NB_CHAN_GET4]; 00151 TH1 *fTot[MAX_GET4_PER_ROC][NB_CHAN_GET4]; 00152 00153 /* 00154 * 24 bits specific variables & histograms 00155 */ 00156 Bool_t fb24bitsReadoutDetected; 00157 Get4v1Hit fHitTemp24[MAX_GET4_PER_ROC][NB_CHAN_GET4]; 00158 UInt_t fuEpochWithData[MAX_GET4_PER_ROC]; // Data flag for suppressed epoch mode 00159 std::vector<TGet4v1MessageExtended> fEpSuppBuffer[MAX_GET4_PER_ROC]; // temp buffer in supp epoch mode to wait for epoch message 00160 00161 /* 00162 * 32 bits specific variables & histograms 00163 */ 00164 Bool_t fb32bitsReadoutDetected; 00165 TH2 *fGet4V1SlowControlType; 00166 TH2 *fGet4V1SlowControlScaler; 00167 TH2 *fGet4V1SlowControlDeadTime; 00168 TH2 *fGet4V1SlowControlHamming; 00169 TH2 *fGet4V1SlowControlSeuEvo; 00170 TH1 *fGet4ErrorChip; // Get4 System Error chip 00171 TH2 *fGet4ErrorChan; // Get4 System Error channel/edge 00172 TH2 *fGet4ErrorPatt; // Get4 System Error pattern 00173 Bool_t fbDllFlag[MAX_GET4_PER_ROC][NB_CHAN_GET4]; 00174 TH2 *fGet4V1DllLockBit; 00175 00176 TGet4v1MessageExtended fLastExtMess[MAX_GET4_PER_ROC][NB_CHAN_GET4]; 00177 TH2 *fGet4V1HitsDistanceNs[MAX_GET4_PER_ROC]; 00178 TH2 *fGet4V1HitsDistanceUs[MAX_GET4_PER_ROC]; 00179 TH2 *fGet4V1HitsDistanceMs[MAX_GET4_PER_ROC]; 00180 TH2 *fGet4V1HitsDistanceS[MAX_GET4_PER_ROC]; 00181 00182 /* 00183 * Debug Histograms for GET4 v1.x 00184 */ 00185 TH1 *fLeadingFTS[MAX_GET4_PER_ROC][NB_CHAN_GET4]; 00186 TH1 *fTrailingFTS[MAX_GET4_PER_ROC][NB_CHAN_GET4]; 00187 TH1 *fLeadingDnl[MAX_GET4_PER_ROC][NB_CHAN_GET4]; 00188 TH1 *fLeadingDnlSum[MAX_GET4_PER_ROC][NB_CHAN_GET4]; 00189 TH1 *fTrailingDnl[MAX_GET4_PER_ROC][NB_CHAN_GET4]; 00190 TH1 *fTrailingDnlSum[MAX_GET4_PER_ROC][NB_CHAN_GET4]; 00191 00192 TH1 *fTimeDiffInsideChip[2][NB_CHAN_GET4*(NB_CHAN_GET4-1)/2]; 00193 TH1 *fTimeDiffBetweenChips[NB_CHAN_GET4*NB_CHAN_GET4]; 00194 00195 TH1 *fFTCorrel[2][NB_CHAN_GET4*(NB_CHAN_GET4-1)/2]; 00196 TH2 *fFTCorrel2D[2][NB_CHAN_GET4*(NB_CHAN_GET4-1)/2]; 00197 TH1 *fFTCorrelChipToChip[NB_CHAN_GET4*NB_CHAN_GET4]; 00198 00199 TGet4v1Rec(); 00200 00201 ULong64_t GetFullEpochNumber(); 00202 ULong64_t GetFullEpoch2Number( UInt_t uGet4Id); 00203 // Functions to overcome the 32 bit limit in epoch number as input to 00204 // GetMessageFullTime function 00205 ULong64_t GetSuperCycleEpOffset( ); 00206 ULong64_t GetSuperCycleEp2Offset( UInt_t uGet4Id); 00207 Double_t GetSuperCycleEp2OffsetD( UInt_t uGet4Id); 00208 }; 00209 00210 00211 #endif 00212 00213