Ignore:
Timestamp:
12/20/03 13:46:17 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mraw/MRawRead.cc

    r2675 r2728  
    125125}
    126126
     127// --------------------------------------------------------------------------
     128//
     129// This is a workaround for the oldest runs (run-number<3490)
     130// for which no time stamp was available.
     131// For this runs a fake time stamp is created
     132//
     133// Be carefull: This is NOT thread safe!
     134//
     135void MRawRead::CreateFakeTime() const
     136{
     137    static Double_t tm = 0; // Range of roughly 8min
     138    const UInt_t ct = (*fRawCrateArray)[0]->GetFADCClockTick();
     139
     140    tm = ct<tm ? fmod(tm, (UInt_t)(-1))+(UInt_t)(-1)+ct : ct;
     141
     142    const Double_t mhz = 9.375;                        // [1e6 ticks/s]
     143    const Double_t t   = tm/mhz;                       // [us]
     144    const UInt_t ns    = (UInt_t)fmod(t*1e3, 1e6);
     145    const UShort_t ms  = (UShort_t)fmod(t/1e3, 1e3);
     146    const Byte_t s     = (Byte_t)fmod(t/1e6, 60);
     147
     148    // Create an artificial time stamp!
     149    UInt_t m = (Byte_t)fmod(t/60e6, 60);
     150    //const Byte_t h     = (Byte_t)(t/3600e6);
     151    m += fRawRunHeader->GetRunNumber()*10;
     152    m %= 360; // 6h
     153
     154    fRawEvtTime->Set(fRawRunHeader->GetRunStart().Year(),
     155                     fRawRunHeader->GetRunStart().Month(),
     156                     fRawRunHeader->GetRunStart().Day(),
     157                     m/60, m%60, s, ms, ns);
     158}
     159
     160// --------------------------------------------------------------------------
     161//
     162// Read a single event from the stream
     163//
    127164Bool_t MRawRead::ReadEvent(istream &fin)
    128165{
     
    169206    }
    170207
    171     {
    172         // FIXME This is a stupid workaround for the missing time stamp!
    173         //       Might be used depending on the run number in the future
    174         static Double_t tm = 0; // Range of roughly 8min
    175         const UInt_t ct = (*fRawCrateArray)[0]->GetFADCClockTick();
    176 
    177         tm = ct<tm ? fmod(tm, (UInt_t)(-1))+(UInt_t)(-1)+ct : ct;
    178 
    179         const Double_t mhz = 9.375;                        // [1e6 ticks/s]
    180         const Double_t t   = tm/mhz;                       // [us]
    181         const UInt_t ns    = (UInt_t)fmod(t*1e3, 1e6);
    182         const UShort_t ms  = (UShort_t)fmod(t/1e3, 1e3);
    183         const Byte_t s     = (Byte_t)fmod(t/1e6, 60);
    184 
    185         // Create an artificial time stamp!
    186         UInt_t m = (Byte_t)fmod(t/60e6, 60);
    187         //const Byte_t h     = (Byte_t)(t/3600e6);
    188         m += fRawRunHeader->GetRunNumber()*10;
    189         m %= 360; // 6h
    190 
    191         fRawEvtTime->Set(fRawRunHeader->GetRunStart().Year(),
    192                          fRawRunHeader->GetRunStart().Month(),
    193                          fRawRunHeader->GetRunStart().Day(),
    194                          m/60, m%60, s, ms, ns);
    195     }
     208    // This is a workaround for the oldest runs (run-number<3490)
     209    // for which no time stamp was available.
     210    // For this runs a fake time stamp is created
     211    if (fRawRunHeader->GetRunNumber()<3490)
     212        CreateFakeTime();
     213
     214    // FIXME: For all other runs we should enhance the precision
     215    //        of the time-stamp by using the FADCClockTick
     216
    196217    return kTRUE;
    197218}
Note: See TracChangeset for help on using the changeset viewer.