Go to the documentation of this file.00001 #ifndef TROCEVENT_H
00002 #define TROCEVENT_H
00003
00004 #include "TGo4EventElement.h"
00005 #include "TGo4CompositeEvent.h"
00006 #include <vector>
00007
00008
00009
00010
00011
00012
00013 #include "roc/Message.h"
00014
00016 #include "TGet4MessageFull.h"
00017
00018
00019
00020
00021 #define MAX_ROC 15
00022
00023
00024 #define MAX_FEET 7
00025
00026
00027 #define MAX_GET4 14
00028
00029 #define MAX_NX 4
00030
00031
00032 #define MAX_GET4_NUM 2
00033
00034 #define MAX_GET4_CH 4
00035
00036
00037 #define NB_BIN_GET4 128
00038
00039 #define MAX_AUX 4
00040
00041 #define MAX_SYNC 2
00042
00043 #define NUM_NXCHANNELS 128
00044
00045
00046
00047 #define SET_ROCS {1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
00048
00049
00050 #include <stdint.h>
00051
00052
00053
00054
00055
00056
00057
00058
00059 class TRocMessageExtended
00060 {
00061 public:
00062
00063 TRocMessageExtended(const roc::Message& msg, uint64_t fulltime=0, float adccorr=0.) :
00064 fxMessage(msg),
00065 ffCorrectedADC(adccorr),
00066 fuFulltime(fulltime),
00067 ffTriggerDeltaT(0),
00068 uRocEpoch( 0 )
00069 {
00070 }
00071
00072 TRocMessageExtended() :
00073 fxMessage(),
00074 ffCorrectedADC(0.),
00075 fuFulltime(0),
00076 ffTriggerDeltaT(0),
00077 uRocEpoch( 0 )
00078 {
00079 }
00080
00081 TRocMessageExtended(const TRocMessageExtended& src)
00082 {
00083 assign(src);
00084 }
00085
00086 virtual ~TRocMessageExtended(){}
00087
00088
00089 bool operator<(const TRocMessageExtended &rhs) const
00090 { return (fuFulltime < rhs.fuFulltime); }
00091
00092 void SetRocMessage(const roc::Message & source)
00093 {
00094 fxMessage=source;
00095 }
00096
00097 const roc::Message& GetRocMessage() const
00098 {
00099 return fxMessage;
00100 }
00101
00102 uint8_t GetMessageType() const
00103 {
00104 return fxMessage.getMessageType();
00105 }
00106 void SetCorrectedNxADC(float val)
00107 {
00108 ffCorrectedADC=val;
00109 }
00110
00111 float GetCorrectedNxADC() const
00112 {
00113 return ffCorrectedADC;
00114 }
00115
00116 float GetNxADC() const
00117 {
00118 return fxMessage.getNxAdcValue();
00119 }
00120
00121 void SetFullTime(uint64_t ts)
00122 {
00123 fuFulltime=ts;
00124 }
00125
00126 uint64_t GetFullTime() const
00127 {
00128 return fuFulltime;
00129 }
00130
00131 uint16_t GetRocNumber() const
00132 {
00133 return fxMessage.getRocNumber();
00134 }
00135
00136
00137 Byte_t GetNxNumber() const
00138 {
00139 return fxMessage.getNxNumber();
00140 }
00141
00142 Byte_t GetNxChNum() const
00143 {
00144 return fxMessage.getNxChNum();
00145 }
00146
00147 uint8_t GetGet4Number() const
00148 {
00149 return fxMessage.getGet4Number();
00150 }
00151
00152
00153 uint8_t GetGet4ChNum() const
00154 {
00155 return fxMessage.getGet4ChNum();
00156 }
00157
00158 uint32_t GetGet4Ts() const
00159 {
00160 return fxMessage.getGet4Ts();
00161 }
00162
00163 Bool_t IsRisingGet4Edge() const
00164 {
00165 return fxMessage.getGet4Edge();
00166 }
00167
00168 void SetTriggerDeltaT(float dt)
00169 {
00170 ffTriggerDeltaT=dt;
00171 }
00172
00173 float GetTriggerDeltaT() const
00174 {
00175 return ffTriggerDeltaT;
00176 }
00177
00178 Bool_t SetGet4MessageFull( const roc::Message & DataMessIn, UInt_t rocEpochIn,
00179 UInt_t rocCycleIn, UInt_t localEpochIn,
00180 UInt_t localCycleIn, Bool_t bUseLocal)
00181 {
00182 fxMessage = DataMessIn;
00183 uRocEpoch = rocEpochIn;
00184 uRocEpochCycle = rocCycleIn;
00185
00186 uLocalEpoch = localEpochIn;
00187 uLocalEpochCycle = localCycleIn;
00188
00189 if(kTRUE == bUseLocal)
00190 {
00191 if( roc::MSG_GET4 == fxMessage.getMessageType() )
00192 fuFulltime = fxMessage.getMsgFullTime( uLocalEpoch );
00193 else if(roc::MSG_SYS == fxMessage.getMessageType() &&
00194 roc::SYSMSG_GET4_EVENT == fxMessage.getSysMesType() )
00195 fuFulltime = fxMessage.FullTimeStamp2(uLocalEpoch, (fxMessage.getField(23,12)<<7) )
00196 / 20 + 512;
00197 }
00198 else
00199 {
00200 if( roc::MSG_GET4 == fxMessage.getMessageType() )
00201 fuFulltime = fxMessage.getMsgFullTime( uRocEpoch );
00202 else if(roc::MSG_SYS == fxMessage.getMessageType() &&
00203 roc::SYSMSG_GET4_EVENT == fxMessage.getSysMesType() )
00204 fuFulltime = fxMessage.FullTimeStamp2(uRocEpoch, (fxMessage.getField(23,12)<<7) )
00205 / 20 + 512;
00206 }
00207
00208 return kTRUE;
00209 }
00210
00211 Bool_t SetRocEpoch( UInt_t rocEpochIn)
00212 {
00213 uRocEpoch = rocEpochIn;
00214 if( roc::MSG_GET4 == fxMessage.getMessageType() )
00215 fuFulltime = fxMessage.getMsgFullTime( uRocEpoch );
00216 else if(roc::MSG_SYS == fxMessage.getMessageType() &&
00217 roc::SYSMSG_GET4_EVENT == fxMessage.getSysMesType() )
00218 fuFulltime = fxMessage.FullTimeStamp2(uRocEpoch, (fxMessage.getField(23,12)<<7) )
00219 / 20 + 512;
00220 return kTRUE;
00221 }
00222 Bool_t SetRocCycle( UInt_t rocCycleIn)
00223 {
00224 uRocEpochCycle = rocCycleIn;
00225 return kTRUE;
00226 }
00227 Bool_t SetLocalEpoch( ULong64_t localEpochIn)
00228 {
00229 uLocalEpoch = localEpochIn;
00230 return kTRUE;
00231 }
00232 Bool_t SetLocalCycle( UInt_t localCycleIn)
00233 {
00234 uLocalEpochCycle = localCycleIn;
00235 return kTRUE;
00236 }
00237
00238 UInt_t GetRocEpoch() const
00239 {
00240 return uRocEpoch;
00241 }
00242 UInt_t GetRocCycle() const
00243 {
00244 return uRocEpochCycle;
00245 }
00246 UInt_t GetLocalEpoch() const
00247 {
00248 return uLocalEpoch;
00249 }
00250 UInt_t GetLocalCycle() const
00251 {
00252 return uLocalEpochCycle;
00253 }
00254
00255 Bool_t RocOrder( const TRocMessageExtended &messageToCompare )const;
00256 Bool_t LocalOrder( const TRocMessageExtended &messageToCompare) const;
00257 Double_t RocSpacing( const TRocMessageExtended &messageToCompare) const;
00258 Double_t LocalSpacing( const TRocMessageExtended &messageToCompare) const;
00259
00260 void Print( unsigned kind = roc::msg_print_Human ) const;
00261
00262 void assign(const TRocMessageExtended& src)
00263 {
00264 fxMessage = src.fxMessage;
00265
00266
00267 ffCorrectedADC = src.ffCorrectedADC;
00268
00269
00270 fuFulltime = src.fuFulltime;
00271
00272
00273
00274 ffTriggerDeltaT = src.ffTriggerDeltaT;
00275
00276 uRocEpoch = src.uRocEpoch;
00277 uRocEpochCycle = src.uRocEpochCycle;
00278
00279 uLocalEpoch = src.uLocalEpoch;
00280 uLocalEpochCycle = src.uLocalEpochCycle;
00281 }
00282
00283
00284 TRocMessageExtended& operator=(const TRocMessageExtended& src)
00285 {
00286 assign(src);
00287
00288 return *this;
00289 }
00290
00291 protected:
00292
00293
00294 roc::Message fxMessage;
00295
00296
00297 float ffCorrectedADC;
00298
00299
00300 uint64_t fuFulltime;
00301
00302
00303
00304 float ffTriggerDeltaT;
00305
00306 UInt_t uRocEpoch;
00307 UInt_t uRocEpochCycle;
00308
00309 ULong64_t uLocalEpoch;
00310 UInt_t uLocalEpochCycle;
00311 };
00312
00313 class TRocData : public TGo4EventElement {
00314 public:
00315 TRocData();
00316 TRocData(const char* name, Short_t id=0);
00317 virtual ~TRocData();
00318
00320 virtual void Clear(Option_t *t="");
00321
00322
00323 std::vector<TRocMessageExtended> fExtMessages;
00324
00326
00327 std::vector<TRocMessageExtended> vMessageEventBuffer;
00328
00329
00330
00331 ULong64_t fLastSyncTm[MAX_SYNC];
00332
00333
00334
00335 ULong64_t fLastTriggerTm;
00336
00337 ClassDef(TRocData,1)
00338 };
00339
00340
00341
00342 class TRocEvent : public TGo4CompositeEvent {
00343 public:
00344 TRocEvent();
00345 TRocEvent(const char* name, Short_t id=0);
00346 virtual ~TRocEvent();
00347
00349 double GetEventTime() const { return fLastGlobalTriggerTm*1e-9; }
00350
00351
00352
00353 ULong64_t CalcGlobalTime(Double_t deltaTrigger);
00354
00355
00356 static UInt_t ConfigRocs[MAX_ROC];
00357
00358
00359
00360
00361
00362 ULong64_t fLastGlobalTriggerTm;
00363
00364 ULong64_t fMbsEventNumber;
00365
00366 ClassDef(TRocEvent,3)
00367 };
00368 #endif //TEVENT_H
00369
00370
00371