• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

onlinemonitor/rocmonitor/TGet4MessageFull.cxx (r4864/r2196)

Go to the documentation of this file.
00001 #include "TGet4MessageFull.h"
00002 
00003 TGet4MessageFull::TGet4MessageFull( void )
00004 {
00005    uRocEpoch        = 0;
00006    uRocEpochCycle   = 0;
00007 
00008    uLocalEpoch      = 0;
00009    uLocalEpochCycle = 0;
00010 }
00011 TGet4MessageFull::TGet4MessageFull( roc::Message & messIn, UInt_t rocEpochIn,
00012                                           UInt_t rocCycleIn, UInt_t localEpochIn, 
00013                                           UInt_t localCycleIn)
00014 {
00015    mDataMessages    = messIn;
00016    uRocEpoch        = rocEpochIn;
00017    uRocEpochCycle   = rocCycleIn;
00018 
00019    uLocalEpoch      = localEpochIn;
00020    uLocalEpochCycle = localCycleIn;
00021 }
00022 
00023 
00024 Bool_t TGet4MessageFull::SetMessageFull( roc::Message & messIn, UInt_t rocEpochIn,
00025                                           UInt_t rocCycleIn, UInt_t localEpochIn, 
00026                                           UInt_t localCycleIn)
00027 {
00028    mDataMessages    = messIn;
00029    uRocEpoch        = rocEpochIn;
00030    uRocEpochCycle   = rocCycleIn;
00031 
00032    uLocalEpoch      = localEpochIn;
00033    uLocalEpochCycle = localCycleIn;
00034 
00035    return kTRUE;
00036 }
00037 Bool_t TGet4MessageFull::SetMessage( roc::Message & messIn)
00038 {
00039    mDataMessages    = messIn;
00040 
00041    return kTRUE;
00042 }
00043 Bool_t TGet4MessageFull::SetRocEpoch( UInt_t rocEpochIn)
00044 {
00045    uRocEpoch        = rocEpochIn;
00046 
00047    return kTRUE;
00048 }
00049 Bool_t TGet4MessageFull::SetRocCycle( UInt_t rocCycleIn)
00050 {
00051    uRocEpochCycle   = rocCycleIn;
00052 
00053    return kTRUE;
00054 }
00055 Bool_t TGet4MessageFull::SetLocalEpoch( UInt_t localEpochIn)
00056 {
00057    uLocalEpoch      = localEpochIn;
00058 
00059    return kTRUE;
00060 }
00061 Bool_t TGet4MessageFull::SetLocalCycle( UInt_t localCycleIn)
00062 {
00063    uLocalEpochCycle = localCycleIn;
00064 
00065    return kTRUE;
00066 }
00067 
00068 roc::Message TGet4MessageFull::GetMessage() const
00069 {
00070    return mDataMessages;
00071 }
00072 UInt_t TGet4MessageFull::GetRocEpoch() const
00073 {
00074    return uRocEpoch;
00075 }
00076 UInt_t TGet4MessageFull::GetRocCycle() const
00077 {
00078    return uRocEpochCycle;
00079 }
00080 UInt_t TGet4MessageFull::GetLocalEpoch() const
00081 {
00082    return uLocalEpoch;
00083 }
00084 UInt_t TGet4MessageFull::GetLocalCycle() const
00085 {
00086    return uLocalEpochCycle;
00087 }
00088 
00089 /* This is the function used to sort Messages in the filled vectors
00090  * For this, it compares the timestamps, taking into account whether the
00091  * message is a data message or an external synchronization message
00092  */
00093 bool TGet4MessageFull::operator<(const TGet4MessageFull &rhs) const
00094 { 
00095    if( kTRUE == LocalOrder( rhs ) )
00096       return true;
00097       else return false; 
00098 }
00099 Bool_t TGet4MessageFull::RocOrder( const TGet4MessageFull &messageToCompare) const
00100 {
00101    if( uRocEpochCycle < messageToCompare.GetRocCycle() )      // messageToCompare in next Cycle
00102       return kTRUE;
00103    else if( uRocEpochCycle > messageToCompare.GetRocCycle() ) // messageToCompare in prev Cycle
00104       return kFALSE;
00105    else if( uRocEpoch < messageToCompare.GetRocEpoch() )      // messageToCompare in next Epoch
00106       return kTRUE;
00107    else if( uRocEpoch > messageToCompare.GetRocEpoch() )      // messageToCompare in prev Epoch
00108       return kFALSE;
00109    else  // Same cycle and same epoch!
00110    {
00111       UInt_t typ1 = mDataMessages.getMessageType();
00112       UInt_t typ2 = (messageToCompare.GetMessage()).getMessageType();
00113       if( typ1 == roc::MSG_SYS && typ2 == roc::MSG_SYS)       // Both External synch messages
00114       {
00115          if( mDataMessages.getField(23,12) <= (messageToCompare.GetMessage()).getField(23,12) )
00116             return kTRUE;
00117          else return kFALSE;
00118       }
00119       else if( typ1 == roc::MSG_SYS )                        // Only this message is Ext Synch
00120       {
00121          if( ((mDataMessages.getField(23,12))<<7) <= (messageToCompare.GetMessage()).getGet4Ts() )
00122             return kTRUE;
00123          else return kFALSE;
00124       }
00125       else if(  typ2 == roc::MSG_SYS)                        // Only messageToCompare is Ext Synch
00126       {
00127          if( mDataMessages.getGet4Ts() <= (((messageToCompare.GetMessage()).getField(23,12))<<7) )
00128             return kTRUE;
00129          else return kFALSE;
00130       }
00131       else                                                   // Both are data messages
00132       {
00133          if( mDataMessages.getGet4Ts() <= (messageToCompare.GetMessage()).getGet4Ts() )
00134             return kTRUE;
00135          else return kFALSE;
00136       }
00137    }
00138 }
00139 Bool_t TGet4MessageFull::LocalOrder( const TGet4MessageFull &messageToCompare) const
00140 {
00141    if( uLocalEpochCycle < messageToCompare.GetLocalCycle() )      // messageToCompare in next Cycle
00142       return kTRUE;
00143    else if( uLocalEpochCycle > messageToCompare.GetLocalCycle() ) // messageToCompare in prev Cycle
00144       return kFALSE;
00145    else if( uLocalEpoch < messageToCompare.GetLocalEpoch() )      // messageToCompare in next Epoch
00146       return kTRUE;
00147    else if( uLocalEpoch > messageToCompare.GetLocalEpoch() )      // messageToCompare in prev Epoch
00148       return kFALSE;
00149    else  // Same cycle and same epoch!
00150    {
00151       UInt_t typ1 = mDataMessages.getMessageType();
00152       UInt_t typ2 = (messageToCompare.GetMessage()).getMessageType();
00153       if( typ1 == roc::MSG_SYS && typ2 == roc::MSG_SYS)       // Both External synch messages
00154       {
00155          if( mDataMessages.getField(23,12) <= (messageToCompare.GetMessage()).getField(23,12) )
00156             return kTRUE;
00157          else return kFALSE;
00158       }
00159       else if( typ1 == roc::MSG_SYS )                        // Only this message is Ext Synch
00160       {
00161          if( ((mDataMessages.getField(23,12))<<7) <= (messageToCompare.GetMessage()).getGet4Ts() )
00162             return kTRUE;
00163          else return kFALSE;
00164       }
00165       else if(  typ2 == roc::MSG_SYS)                        // Only messageToCompare is Ext Synch
00166       {
00167          if( mDataMessages.getGet4Ts() <= (((messageToCompare.GetMessage()).getField(23,12))<<7) )
00168             return kTRUE;
00169          else return kFALSE;
00170       }
00171       else                                                   // Both are data messages
00172       {
00173          if( mDataMessages.getGet4Ts() <= (messageToCompare.GetMessage()).getGet4Ts() )
00174             return kTRUE;
00175          else return kFALSE;
00176       }
00177    }
00178 } 
00179    
00180 #define BIN_SIZE_IN_NS         0.05
00181 #define EPOCH_IN_BINS     524288
00182 #define EPOCH_IN_NS        26214.4
00183 #define CYCLE_IN_EPOCHS  1048576   
00184 Double_t TGet4MessageFull::RocSpacing( const TGet4MessageFull &messageToCompare) const
00185 {     
00186    // distance between two messages in bin multiplied by 0.05 ns.
00187    double dSpacing = BIN_SIZE_IN_NS * (double) ( (double) (messageToCompare.GetMessage()).getGet4Ts() -
00188                   (double)mDataMessages.getGet4Ts() );
00189    // When messages are not in the same epoch
00190    // the time  has to be corrected
00191    if ( uRocEpoch != messageToCompare.GetRocEpoch() )
00192    {
00193       if( uRocEpochCycle != messageToCompare.GetRocCycle() )
00194       {
00195          dSpacing += EPOCH_IN_NS * (double) ( (double)messageToCompare.GetRocEpoch() - 
00196                                           (double)uRocEpoch +
00197                                           (double)CYCLE_IN_EPOCHS * (double) ( (double)messageToCompare.GetRocCycle() - 
00198                                           (double)uRocEpochCycle )  );
00199       }
00200       else
00201       {
00202          dSpacing += EPOCH_IN_NS * (double) ( (double)messageToCompare.GetRocEpoch() - 
00203                                        (double)uRocEpoch );
00204       }
00205    }
00206    // returns time in ns.
00207    return dSpacing;
00208 }
00209 Double_t TGet4MessageFull::LocalSpacing( const TGet4MessageFull &messageToCompare) const
00210 {   
00211    // distance between two messages in bin multiplied by 0.05 ns.
00212    double dSpacing = BIN_SIZE_IN_NS * (double) ( (double) (messageToCompare.GetMessage()).getGet4Ts() -
00213                   (double)mDataMessages.getGet4Ts() );
00214    // When messages are not in the same epoch
00215    // the time  has to be corrected
00216    if ( uLocalEpoch != messageToCompare.GetLocalEpoch() )
00217    {
00218       if( uLocalEpochCycle != messageToCompare.GetLocalCycle() )
00219       {
00220          dSpacing += EPOCH_IN_NS * (double) ( (double)messageToCompare.GetLocalEpoch() - 
00221                                           (double)uLocalEpoch +
00222                                           (double)CYCLE_IN_EPOCHS * (double) ( (double)messageToCompare.GetLocalCycle() - 
00223                                           (double)uLocalEpochCycle )  );
00224       }
00225       else
00226       {
00227          dSpacing += EPOCH_IN_NS * (double) ( (double)messageToCompare.GetLocalEpoch() - 
00228                                        (double)uLocalEpoch );
00229       }
00230    }
00231    // returns time in ns.
00232    return dSpacing;
00233 }

Generated on Tue Dec 10 2013 04:52:23 for ROCsoft by  doxygen 1.7.1