Go to the documentation of this file.00001
00002
00003 #include "TRocEvent.h"
00004
00005 #include "TGo4Log.h"
00006
00007 UInt_t TRocEvent::ConfigRocs[MAX_ROC] = SET_ROCS;
00008
00009 Bool_t TRocMessageExtended::RocOrder( const TRocMessageExtended &messageToCompare) const
00010 {
00011 if( uRocEpochCycle < messageToCompare.GetRocCycle() )
00012 return kTRUE;
00013 else if( uRocEpochCycle > messageToCompare.GetRocCycle() )
00014 return kFALSE;
00015 else if( uRocEpoch < messageToCompare.GetRocEpoch() )
00016 return kTRUE;
00017 else if( uRocEpoch > messageToCompare.GetRocEpoch() )
00018 return kFALSE;
00019 else
00020 {
00021 UInt_t typ1 = fxMessage.getMessageType();
00022 UInt_t typ2 = (messageToCompare.GetRocMessage()).getMessageType();
00023 if( typ1 == roc::MSG_SYS && typ2 == roc::MSG_SYS)
00024 {
00025 if( fxMessage.getField(23,12) <= (messageToCompare.GetRocMessage()).getField(23,12) )
00026 return kTRUE;
00027 else return kFALSE;
00028 }
00029 else if( typ1 == roc::MSG_SYS )
00030 {
00031 if( ((fxMessage.getField(23,12))<<7) <= (messageToCompare.GetRocMessage()).getGet4Ts() )
00032 return kTRUE;
00033 else return kFALSE;
00034 }
00035 else if( typ2 == roc::MSG_SYS)
00036 {
00037 if( fxMessage.getGet4Ts() <= (((messageToCompare.GetRocMessage()).getField(23,12))<<7) )
00038 return kTRUE;
00039 else return kFALSE;
00040 }
00041 else
00042 {
00043 if( fxMessage.getGet4Ts() <= (messageToCompare.GetRocMessage()).getGet4Ts() )
00044 return kTRUE;
00045 else return kFALSE;
00046 }
00047 }
00048 }
00049 Bool_t TRocMessageExtended::LocalOrder( const TRocMessageExtended &messageToCompare) const
00050 {
00051 if( uLocalEpochCycle < messageToCompare.GetLocalCycle() )
00052 return kTRUE;
00053 else if( uLocalEpochCycle > messageToCompare.GetLocalCycle() )
00054 return kFALSE;
00055 else if( uLocalEpoch < messageToCompare.GetLocalEpoch() )
00056 return kTRUE;
00057 else if( uLocalEpoch > messageToCompare.GetLocalEpoch() )
00058 return kFALSE;
00059 else
00060 {
00061 UInt_t typ1 = fxMessage.getMessageType();
00062 UInt_t typ2 = (messageToCompare.GetRocMessage()).getMessageType();
00063 if( typ1 == roc::MSG_SYS && typ2 == roc::MSG_SYS)
00064 {
00065 if( fxMessage.getField(23,12) <= (messageToCompare.GetRocMessage()).getField(23,12) )
00066 return kTRUE;
00067 else return kFALSE;
00068 }
00069 else if( typ1 == roc::MSG_SYS )
00070 {
00071 if( ((fxMessage.getField(23,12))<<7) <= (messageToCompare.GetRocMessage()).getGet4Ts() )
00072 return kTRUE;
00073 else return kFALSE;
00074 }
00075 else if( typ2 == roc::MSG_SYS)
00076 {
00077 if( fxMessage.getGet4Ts() <= (((messageToCompare.GetRocMessage()).getField(23,12))<<7) )
00078 return kTRUE;
00079 else return kFALSE;
00080 }
00081 else
00082 {
00083 if( fxMessage.getGet4Ts() <= (messageToCompare.GetRocMessage()).getGet4Ts() )
00084 return kTRUE;
00085 else return kFALSE;
00086 }
00087 }
00088 }
00089
00090 #define BIN_SIZE_IN_NS 0.05
00091 #define EPOCH_IN_BINS 524288
00092 #define EPOCH_IN_NS 26214.4
00093 #define CYCLE_IN_EPOCHS 1048576
00094 Double_t TRocMessageExtended::RocSpacing( const TRocMessageExtended &messageToCompare) const
00095 {
00096 UInt_t typ1 = fxMessage.getMessageType();
00097 UInt_t typ2 = (messageToCompare.GetRocMessage()).getMessageType();
00098 if( roc::MSG_GET4 != typ1 || roc::MSG_GET4 != typ2 )
00099 return -1;
00100
00101 double dSpacing = BIN_SIZE_IN_NS * (double) ( (double) (messageToCompare.GetRocMessage()).getGet4Ts() -
00102 (double)fxMessage.getGet4Ts() );
00103
00104
00105 if ( uRocEpoch != messageToCompare.GetRocEpoch() )
00106 {
00107 if( uRocEpochCycle != messageToCompare.GetRocCycle() )
00108 {
00109 dSpacing += EPOCH_IN_NS * (double) ( (double)messageToCompare.GetRocEpoch() -
00110 (double)uRocEpoch +
00111 (double)CYCLE_IN_EPOCHS * (double) ( (double)messageToCompare.GetRocCycle() -
00112 (double)uRocEpochCycle ) );
00113 }
00114 else
00115 {
00116 dSpacing += EPOCH_IN_NS * (double) ( (double)messageToCompare.GetRocEpoch() -
00117 (double)uRocEpoch );
00118 }
00119 }
00120
00121 return dSpacing;
00122 }
00123 Double_t TRocMessageExtended::LocalSpacing( const TRocMessageExtended &messageToCompare) const
00124 {
00125 UInt_t typ1 = fxMessage.getMessageType();
00126 UInt_t typ2 = (messageToCompare.GetRocMessage()).getMessageType();
00127 if( roc::MSG_GET4 != typ1 || roc::MSG_GET4 != typ2 )
00128 return -1;
00129
00130 double dSpacing = BIN_SIZE_IN_NS * (double) ( (double) (messageToCompare.GetRocMessage()).getGet4Ts() -
00131 (double)fxMessage.getGet4Ts() );
00132
00133
00134 if ( uLocalEpoch != messageToCompare.GetLocalEpoch() )
00135 {
00136 if( uLocalEpochCycle != messageToCompare.GetLocalCycle() )
00137 {
00138 dSpacing += EPOCH_IN_NS * (double) ( (double)messageToCompare.GetLocalEpoch() -
00139 (double)uLocalEpoch +
00140 (double)CYCLE_IN_EPOCHS * (double) ( (double)messageToCompare.GetLocalCycle() -
00141 (double)uLocalEpochCycle ) );
00142 }
00143 else
00144 {
00145 dSpacing += EPOCH_IN_NS * (double) ( (double)messageToCompare.GetLocalEpoch() -
00146 (double)uLocalEpoch );
00147 }
00148 }
00149
00150 return dSpacing;
00151 }
00152
00153 void TRocMessageExtended::Print( unsigned kind ) const
00154 {
00155 fxMessage.printData( kind, fuFulltime >> 14 );
00156 }
00157
00158 TRocData::TRocData() : TGo4EventElement()
00159 {
00160 }
00161
00162
00163 TRocData::TRocData(const char* name, Short_t id) :
00164 TGo4EventElement(name,name,id)
00165 {
00166 TGo4Log::Info("TRocData: Create instance %s with composite id %d", name, id);
00167
00168 fLastTriggerTm=0;
00169 for(int snc=0; snc<MAX_SYNC;++snc)
00170 fLastSyncTm[snc]=0;
00171 }
00172
00173
00174 TRocData::~TRocData()
00175 {
00176 }
00177
00178 void TRocData::Clear(Option_t *t)
00179 {
00180 fExtMessages.clear();
00181 vMessageEventBuffer.clear();
00182
00183
00184
00185 }
00186
00187
00189
00190
00191 TRocEvent::TRocEvent(const char* name, Short_t id) :
00192 TGo4CompositeEvent(name,name,id)
00193 {
00194 TGo4Log::Info("TRocEvent: Create instance %s with composite id %d", name, id);
00195 TString modname;
00196 for(int roc=0; roc<MAX_ROC;++roc)
00197 {
00198 if(TRocEvent::ConfigRocs[roc]==0) continue;
00199
00200 modname.Form("ROC%02d",roc);
00201 addEventElement(new TRocData(modname.Data(),roc));
00202 }
00203 }
00204
00205 TRocEvent::TRocEvent() :
00206 TGo4CompositeEvent()
00207 {
00208 }
00209
00210 TRocEvent::~TRocEvent()
00211 {
00212 }
00213
00214 ULong64_t TRocEvent::CalcGlobalTime(Double_t deltaTrigger)
00215 {
00216
00217 ULong64_t rev=fLastGlobalTriggerTm;
00218 rev+=deltaTrigger;
00219 return rev;
00220 }
00221