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

beamtime/tof-tdctest/go4/GET4V10/TGet4v1Event.cxx (r4864/r4433)

Go to the documentation of this file.
00001 /* Generated by Together */
00002 
00003 #include "TGet4v1Event.h"
00004 
00005 #include "TGo4Version.h"
00006 #if __GO4BUILDVERSION__ > 40502
00007 #include "go4iostream.h"
00008 #else
00009 #include "Riostream.h"
00010 #endif
00011 
00012 Bool_t TGet4v1MessageExtended::RocOrder( const TGet4v1MessageExtended &messageToCompare) const
00013 {
00014    /*
00015     * TODO: update with 32bit
00016     */
00017    if( uRocEpochCycle < messageToCompare.GetRocCycle() )      // messageToCompare in next Cycle
00018       return kTRUE;
00019    else if( uRocEpochCycle > messageToCompare.GetRocCycle() ) // messageToCompare in prev Cycle
00020       return kFALSE;
00021    else if( uRocEpoch < messageToCompare.GetRocEpoch() )      // messageToCompare in next Epoch
00022       return kTRUE;
00023    else if( uRocEpoch > messageToCompare.GetRocEpoch() )      // messageToCompare in prev Epoch
00024       return kFALSE;
00025    else  // Same cycle and same epoch!
00026    {
00027       UInt_t typ1 = fxMessage.getMessageType();
00028       UInt_t typ2 = (messageToCompare.GetRocMessage()).getMessageType();
00029       if( typ1 == roc::MSG_SYS && typ2 == roc::MSG_SYS)       // Both External synch messages
00030       {
00031          if( fxMessage.getField(23,12) <= (messageToCompare.GetRocMessage()).getField(23,12) )
00032             return kTRUE;
00033          else return kFALSE;
00034       }
00035       else if( typ1 == roc::MSG_SYS )                        // Only this message is Ext Synch
00036       {
00037          if( ((fxMessage.getField(23,12))<<7) <= (messageToCompare.GetRocMessage()).getGet4Ts() )
00038             return kTRUE;
00039          else return kFALSE;
00040       }
00041       else if(  typ2 == roc::MSG_SYS)                        // Only messageToCompare is Ext Synch
00042       {
00043          if( fxMessage.getGet4Ts() <= (((messageToCompare.GetRocMessage()).getField(23,12))<<7) )
00044             return kTRUE;
00045          else return kFALSE;
00046       }
00047       else                                                   // Both are data messages
00048       {
00049          if( fxMessage.getGet4Ts() <= (messageToCompare.GetRocMessage()).getGet4Ts() )
00050             return kTRUE;
00051          else return kFALSE;
00052       }
00053    }
00054 }
00055 
00056 Double_t TGet4v1MessageExtended::RocSpacing( const TGet4v1MessageExtended &messageToCompare) const
00057 {
00058    /*
00059     * TODO: update with 32bit
00060     */
00061    UInt_t typ1 = fxMessage.getMessageType();
00062    UInt_t typ2 = (messageToCompare.GetRocMessage()).getMessageType();
00063    if( roc::MSG_GET4 != typ1 || roc::MSG_GET4 != typ2 ) // not a hit info
00064       return -1;
00065    // distance between two messages in bin multiplied by 0.05 ns.
00066    double dSpacing = GET4_BIN_SIZE_IN_PS * (double) ( (double) (messageToCompare.GetRocMessage()).getGet4Ts() -
00067                   (double)fxMessage.getGet4Ts() );
00068    // When messages are not in the same epoch
00069    // the time  has to be corrected
00070    if ( uRocEpoch != messageToCompare.GetRocEpoch() )
00071    {
00072       if( uRocEpochCycle != messageToCompare.GetRocCycle() )
00073       {
00074          dSpacing += GET4_EPOCH_IN_PS * (double) ( (double)messageToCompare.GetRocEpoch() -
00075                                           (double)uRocEpoch +
00076                                           (double)GET4_CYCLE_IN_EPOCHS * (double) ( (double)messageToCompare.GetRocCycle() -
00077                                           (double)uRocEpochCycle )  );
00078       }
00079       else
00080       {
00081          dSpacing += GET4_EPOCH_IN_PS * (double) ( (double)messageToCompare.GetRocEpoch() -
00082                                        (double)uRocEpoch );
00083       }
00084    }
00085    // returns time in ps.
00086    return dSpacing;
00087 }
00088 
00089 void TGet4v1MessageExtended::Print( unsigned kind ) const
00090 {
00091    if( roc::MSG_SYS == fxMessage.getMessageType() )
00092    {
00093       UChar_t ucSysMesType = fxMessage.getSysMesType();
00094       if( get4v10::SYSMSG_GET4V1_32BIT_0  <= ucSysMesType &&
00095           get4v10::SYSMSG_GET4V1_32BIT_15 >= ucSysMesType   )
00096       {
00097          Print32Bit( kind );
00098       } // case SYSMSG_GET4V1_32BIT + channel!
00099          else fxMessage.printData( kind, uRocEpoch + GET4_CYCLE_IN_EPOCHS*uRocEpochCycle );
00100    }
00101       else fxMessage.printData( kind, uRocEpoch + GET4_CYCLE_IN_EPOCHS*uRocEpochCycle );
00102 
00103 }
00104 void TGet4v1MessageExtended::Print32Bit( unsigned kind  ) const
00105 {
00106 
00107    TString sPrintout ="";
00108    ULong64_t data = ((ULong64_t)fxMessage.getField( 48, 16 ) )<<48 |
00109                     ((ULong64_t)fxMessage.getField( 32, 16 ) )<<32 |
00110                     ((ULong64_t)fxMessage.getField( 16, 16 ) )<<16 |
00111                     ((ULong64_t)fxMessage.getField(  0, 16 ) );
00112 
00113    if( kind & roc::msg_print_Hex )
00114    {
00115       UChar_t* arr = (uint8_t*) &data;
00116       sPrintout  += Form("%02X:%02X:%02X:%02X:%02X:%02X ",
00117             arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]);
00118    } // if( kind & msg_print_Hex )
00119 
00120    if( kind & roc::msg_print_Prefix )
00121    {
00122       sPrintout  += Form( "Msg:%u Roc:%u ", fxMessage.getMessageType(), fxMessage.getRocNumber());
00123    } // if( kind & msg_print_Prefix)
00124    if (kind & roc::msg_print_Human)
00125    {
00126       Double_t timeInSec = fxMessage.getMsgFullTimeD(fuFulltime >> 14)/1.e9; // <--- to be change !!!!!
00127       sPrintout += Form( "SysType:%2x Data:%8x @%17.11f : ", fxMessage.getSysMesType(), fxMessage.getSysMesData(), timeInSec);
00128    } // if( kind & msg_print_Human )
00129       else sPrintout += Form( "SysType:%2x Data:%8x : ", fxMessage.getSysMesType(), fxMessage.getSysMesData());
00130 
00131    UInt_t get4_32b_type  = getFieldBE(fxMessage, 46, 2);  //(dataBE>>46) & 0x3;
00132    switch(get4_32b_type)
00133    {
00134       case 0: // epoch message
00135       {
00136          UInt_t get4_32b_ep_epoch = getFieldBE(fxMessage, 17,24);  //(dataBE>>17)  & 0xFFFFFF;
00137          UInt_t get4_32b_ep_sync  = getBitBE(fxMessage, 16);       //(dataBE>>16)  & 0x000001;
00138          sPrintout += Form( "Get4 V1 32 bits, type:0x%02x => Epoch %08d Sync: %1d",
00139                get4_32b_type, get4_32b_ep_epoch, get4_32b_ep_sync );
00140          break;
00141       }
00142       case 1: // slow control message
00143       {
00144          UInt_t get4_32b_sl_data = getFieldBE(fxMessage, 16, 24); //(dataBE>>16) & 0xFFFFFF;
00145          UInt_t get4_32b_sl_type = getFieldBE(fxMessage, 40, 2);  //(dataBE>>40) & 0x3;
00146          UInt_t get4_32b_sl_edge = getBitBE(fxMessage, 42);       //(dataBE>>42) & 0x1;
00147          UInt_t get4_32b_sl_chan = getFieldBE(fxMessage, 43, 2);  //(dataBE>>43) & 0x3;
00148          sPrintout += Form("Get4 V1 32 bits, type:0x%02x => Slow control Chan:%01d Edge:%01d Type:%01x Data:0x%06x",
00149                get4_32b_type, get4_32b_sl_chan, get4_32b_sl_edge, get4_32b_sl_type, get4_32b_sl_data );
00150          break;
00151       }
00152       case 2: // error event
00153       {
00154          UInt_t get4_32b_er_code = getFieldBE(fxMessage, 16,7); //(dataBE>>16)  & 0x7f;
00155          UInt_t get4_32b_er_chan = getFieldBE(fxMessage, 42,2); //(dataBE>>42)  & 0x3;
00156          UInt_t get4_32b_er_edge = getBitBE(fxMessage, 44);     //(dataBE>>44)  & 0x1;
00157          sPrintout += Form("Get4 V1 32 bits, type:0x%02x => Error 0x%02x Channel %1d Edge %1d",
00158                get4_32b_type, get4_32b_er_code, get4_32b_er_chan, get4_32b_er_edge );
00159          break;
00160       }
00161       case 3: // data event
00162       {
00163          UInt_t get4_32b_dat_tot  = getFieldBE(fxMessage, 16,  8); //(dataBE>>16) & 0xff;
00164          UInt_t get4_32b_dat_ft   = getFieldBE(fxMessage, 24,  7); //(dataBE>>24) & 0x7f;
00165          UInt_t get4_32b_dat_ts   = getFieldBE(fxMessage, 31,12);  //(dataBE>>31) & 0xfff;
00166          UInt_t get4_32b_dat_chan = getFieldBE(fxMessage, 43, 2);  //(dataBE>>43) & 0x3;
00167          UInt_t get4_32b_dat_dll  = getBitBE(fxMessage, 45);       //(dataBE>>45) & 0x1;
00168          sPrintout += Form("Get4 V1 32 bits, type:0x%02x => Data Dll %1d Channel %1d Ts:0x%04d Ft:0x%03d Tot:0x%03d",
00169                get4_32b_type, get4_32b_dat_dll, get4_32b_dat_chan, get4_32b_dat_ts,
00170                get4_32b_dat_ft, get4_32b_dat_tot);
00171          break;
00172       }
00173       default:
00174          sPrintout += Form("Get4 V1 32 bits, type:0x%02x ", get4_32b_type );
00175       break;
00176    } // switch(get4_32b_type)
00177    cout<<sPrintout<<endl;
00178 }
00179 
00180 /*****************************************************************************/
00181 /* Get4 v1.0 hit */
00182 void  Get4v1Hit::Clear( Option_t *t )
00183 {
00184    fbTimeSet = kFALSE;
00185    fbTotSet  = kFALSE;
00186    fdTot     = 0.0;
00187    fbIs32Bit = kFALSE;
00188 }
00189 void Get4v1Hit::SetFullHit24Bits( TGet4v1MessageExtended& mesTime, TGet4v1MessageExtended& mesTot)
00190 {
00191    if( kFALSE == mesTime.Is32Bit() && kFALSE == mesTot.Is32Bit() )
00192    {
00193       /* TODO
00194        * Check on compatibility Time with Tot
00195        */
00196       fTimeMessage = mesTime;
00197       fTotMessage = mesTot;
00198       fbTimeSet = kTRUE;
00199       fbTotSet  = kTRUE;
00200       fbIs32Bit = kFALSE;
00201       CalculateTot();
00202    } // if( kFALSE == mesTime.Is32Bit() && kFALSE == mesTot.Is32Bit() )
00203 }
00204 void Get4v1Hit::SetFullHit32Bits( TGet4v1MessageExtended& mesHit, Double_t d32bTotRange )
00205 {
00206    if( kTRUE == mesHit.Is32Bit() )
00207    {
00208       fTimeMessage = mesHit;
00209       fbTimeSet = kTRUE;
00210       fbTotSet  = kTRUE;
00211       fbIs32Bit = kTRUE;
00212       CalculateTot( d32bTotRange );
00213    } // if( mesHit.Is32Bit() )
00214 }
00215 void Get4v1Hit::SetTime24Bits( TGet4v1MessageExtended& mesTime )
00216 {
00217    if( kFALSE == mesTime.Is32Bit() )
00218    {
00219       fTimeMessage = mesTime;
00220       fbTimeSet = kTRUE;
00221       fbIs32Bit = kFALSE;
00222       /* TODO
00223        * Check on compatibility Time with Tot
00224        */
00225       if( kTRUE == IsComplete() )
00226          CalculateTot();
00227    } // if( kFALSE == mesTime.Is32Bit() && kFALSE == mesTot.Is32Bit() )
00228 }
00229 void Get4v1Hit::SetTot24Bits(  TGet4v1MessageExtended& mesTot )
00230 {
00231    if(  kFALSE == mesTot.Is32Bit() )
00232    {
00233       fTotMessage = mesTot;
00234       fbTotSet  = kTRUE;
00235       fbIs32Bit = kFALSE;
00236       /* TODO
00237        * Check on compatibility Time with Tot
00238        */
00239       if( kTRUE == IsComplete() )
00240          CalculateTot();
00241    } // if( kFALSE == mesTot.Is32Bit() )
00242 }
00243 void Get4v1Hit::CalculateTot( Double_t d32bTotRange )
00244 {
00245    if( kTRUE == fbIs32Bit )
00246       fdTot = ((Double_t)fTimeMessage.getGet4V10R32HitTot() ) * (d32bTotRange/255.0);
00247       else fdTot = fTimeMessage.RocSpacing( fTotMessage);
00248 }
00249 Double_t Get4v1Hit::GetHitTime()
00250 {
00251    /*
00252     * TODO: Epoch borders!!!
00253     */
00254    if( kTRUE == fbIs32Bit )
00255       return GET4_BIN_SIZE_IN_PS * fTimeMessage.getGet4V10R32HitTimeBin();
00256       else return GET4_BIN_SIZE_IN_PS * (fTimeMessage.GetRocMessage()).getGet4Ts();
00257 }
00258 Int_t Get4v1Hit::GetHitLeadingFTS()
00259 {
00260    if( kTRUE == fbIs32Bit )
00261       return (Int_t)(fTimeMessage.getGet4V10R32HitFt());
00262       else return (Int_t)( ( (fTimeMessage.GetRocMessage()).getGet4Ts() )%NB_BIN_GET4_FTS );
00263 }
00264 Int_t Get4v1Hit::GetHitTrailingFTS()
00265 {
00266    if( kTRUE == fbIs32Bit )
00267       return 0;
00268       else return (Int_t)( ( (fTotMessage.GetRocMessage()).getGet4Ts() )%NB_BIN_GET4_FTS );
00269 }
00270 Double_t Get4v1Hit::GetTimeDiff( Get4v1Hit& hitToCompare )
00271 {
00272    if( kTRUE == fbIs32Bit &&
00273          kTRUE == hitToCompare.Is32Bit() )
00274    {
00275       // Both 32 bits
00276       /*
00277        * TODO: update RocSpacing, this is just a temp solution, not sure of resolution!!!
00278        * or use GetHitTime with epoch border check!!!!
00279        */
00280       return (hitToCompare.GetHitFullTimeD() - GetHitFullTimeD())*1000.0;
00281    }
00282    else if( kTRUE == fbIs32Bit )
00283       return -1000000.0; // Not both the same => crazy ?!?
00284    else if( kTRUE == hitToCompare.Is32Bit() )
00285       return 1000000.0; // Not both the same => crazy ?!?
00286    else // Both 24 bits
00287       return fTimeMessage.RocSpacing( (hitToCompare.GetTimeMessage()) );
00288 }
00289 /*****************************************************************************/
00290 /* Get4 v1.0 TDC */
00291 Get4v1Tdc::~Get4v1Tdc()
00292 {
00293    Clear();
00294 }
00295 /*
00296 Get4v1Tdc::Get4v1Tdc(const Get4v1Tdc& src) : TObject()
00297 {
00298    for( Int_t iChan = 0; iChan < NB_CHAN_GET4; iChan++)
00299       fHits[iChan] = src.fHits[iChan];
00300 }
00301 Get4v1Tdc & Get4v1Tdc::operator=(const Get4v1Tdc& src)
00302 {
00303    // TObject copy attempt....
00304    TObject* ptrObj1 = this;
00305    TObject* ptrObj2 = &src;
00306    *ptrObj1 = *ptrObj2;
00307 
00308    for( Int_t iChan = 0; iChan < NB_CHAN_GET4; iChan++)
00309       this.fHits[iChan] = src.fHits[iChan];
00310    return *this;
00311 }
00312 */
00313 void  Get4v1Tdc::Clear(Option_t *t )
00314 {
00315    for(UInt_t uChannelIndex = 0; uChannelIndex < NB_CHAN_GET4; uChannelIndex++)
00316    {
00317       for(UInt_t uHitIndex = 0; uHitIndex < fHits[uChannelIndex].size(); uHitIndex++)
00318          fHits[uChannelIndex][uHitIndex].Clear();
00319       fHits[uChannelIndex].clear();
00320    }
00321 }
00322 UInt_t  Get4v1Tdc::Size()
00323 {
00324    UInt_t uSize = 0;
00325    for(UInt_t uChannelIndex = 0; uChannelIndex < NB_CHAN_GET4; uChannelIndex++)
00326       uSize += fHits[uChannelIndex].size();
00327    return uSize;
00328 }
00329 
00330 /*****************************************************************************/
00331 /* Real Event */
00332 Get4v1Event::~Get4v1Event()
00333 {
00334    Clear();
00335 }
00336 void  Get4v1Event::Clear( Option_t *t )
00337 {
00338   // all members should be cleared.
00339    for(UInt_t uGet4Index = 0; uGet4Index < MAX_GET4; uGet4Index++)
00340       fGet4Boards[uGet4Index].Clear( );
00341 
00342    for(UInt_t uRocIndex = 0; uRocIndex < MAX_ROC; uRocIndex++)
00343    {
00344       fPureRocMessages[uRocIndex].clear();
00345       fdTriggerFullTime[uRocIndex] = 0.0;
00346    } // for(UInt_t uRocIndex = 0; uRocIndex < MAX_GET4; uRocIndex++)
00347 
00348    fuMbsEventNumber      = 0;
00349    fuEventNbInsideMbsEvt = 0;
00350    fuGlobalEventNumber   = 0;
00351    fbMbsSyncedEvent      = kFALSE;
00352    fuSyncEventNumber     = 0;
00353 }
00354 UInt_t  Get4v1Event::Size()
00355 {
00356    UInt_t uSize = 0;
00357    for(UInt_t uGet4Index = 0; uGet4Index < MAX_GET4; uGet4Index++)
00358       uSize += fGet4Boards[uGet4Index].Size( );
00359    return uSize;
00360 }
00361 Bool_t  Get4v1Event::IsEmpty()
00362 {
00363    Bool_t bEmpty = kTRUE;
00364    for(UInt_t uGet4Index = 0; uGet4Index < MAX_GET4; uGet4Index++)
00365       bEmpty &= ( 0 == fGet4Boards[uGet4Index].Size( ) );
00366    return bEmpty;
00367 }
00368 Bool_t  Get4v1Event::HasTrigger()
00369 {
00370    Bool_t bTrigger = kFALSE;
00371    for(UInt_t uRocIndex = 0; uRocIndex < MAX_ROC; uRocIndex++)
00372       if( 0 < fdTriggerFullTime[uRocIndex] )
00373       {
00374          bTrigger = kTRUE;
00375          break;
00376       }
00377    return bTrigger;
00378 }
00379 
00381 /* GO4 ~ LMD ~ MBS event */
00382 TGet4v1Event::TGet4v1Event(const char* name, Short_t id) :
00383       TGo4EventElement(name,name,id)
00384 {
00385    cout << "**** TGet4v1Event: Create instance " << name <<" with composite id "<<id<< endl;
00386 }
00387 
00388 TGet4v1Event::TGet4v1Event() :
00389       TGo4EventElement()
00390 {
00391 }
00392 
00393 TGet4v1Event::~TGet4v1Event()
00394 {
00395    Clear();
00396 }
00397 
00398 void  TGet4v1Event::Clear( Option_t *t )
00399 {
00400   // all members should be cleared.
00401    for(UInt_t uEventIndex = 0; uEventIndex < fEvents.size(); uEventIndex++)
00402       fEvents[uEventIndex].Clear();
00403    fEvents.clear();
00404    SetValid(kFALSE);
00405 }
00406 
00407 ULong64_t TGet4v1Event::CalcGlobalTime(Double_t deltaTrigger)
00408 {
00409 
00410    ULong64_t rev=fLastGlobalTriggerTm;
00411    rev+=deltaTrigger;
00412    return rev;
00413 }
00414 

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