Ignore:
Timestamp:
12/20/03 13:46:17 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mraw
Files:
7 edited

Legend:

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

    r2580 r2728  
    236236}
    237237
     238Bool_t MRawEvtHeader::DecodeTime(UInt_t abstime[2]) const
     239{
     240    // BADC|1032 --> DCBA|3210 (Byte swap - exchange MSB and LSB)
     241    abstime[0] = (abstime[0]<<16) | (abstime[0]>>16);
     242    abstime[1] = (abstime[1]<<16) | (abstime[1]>>16);
     243
     244    const Byte_t h = (abstime[0]>>18 & 0x30)*10 + (abstime[0]>>14 & 0x0f);
     245    const Byte_t m = (abstime[0]>>11 & 0x70)*10 + (abstime[0]>> 7 & 0x0f);
     246    const Byte_t s = (abstime[0]>> 4 & 0x70)*10 + (abstime[0]>> 0 & 0x0f);
     247    const Int_t ms =
     248        ((abstime[1]>>16)&0xf)*1000 +
     249        ((abstime[1]>> 8)&0xf)* 100 +
     250        ((abstime[1]>> 4)&0xf)*  10 +
     251        ((abstime[1]>> 0)&0xf)*   1;
     252
     253    // hms   =3210 -->  h=2:4 m=3:4 s=3:4
     254    // subsec=DCBA --> subsec?
     255    *fLog << dbg << dec;
     256    *fLog << (int)(abstime[0]>>18 & 0x30); // h
     257    *fLog << (int)(abstime[0]>>14 & 0x0f); // h
     258    *fLog << ":";
     259    *fLog << (int)(abstime[0]>>11 & 0x70); // m
     260    *fLog << (int)(abstime[0]>> 7 & 0x0f); // m
     261    *fLog << ":";
     262    *fLog << (int)(abstime[0]>> 4 & 0x70); // s
     263    *fLog << (int)(abstime[0]>> 0 & 0x0f); // s
     264    *fLog << " ";
     265    *fLog << (int)(abstime[1]>>16 & 0xf) << ".";
     266    *fLog << (int)(abstime[1]>> 8 & 0xf) << ".";
     267    *fLog << (int)(abstime[1]>> 4 & 0xf) << ".";
     268    *fLog << (int)(abstime[1]>> 0 & 0xf);
     269    *fLog << endl;
     270
     271    // Update the time stamp with the current event time.
     272    // Make sure, that the time stamp was initialized correctly
     273    // with the start-date/time of the run (after reading the run header)
     274    //
     275    // Here the nanosec precision is ignored... (FIXME!)
     276    return fTime->UpdMagicTime(h, m, s, ms);
     277}
     278
    238279// --------------------------------------------------------------------------
    239280//
     
    241282// return FALSE if there is now header anymore, else TRUE
    242283//
     284// Updates the time stamp with the current event time.
     285// Make sure, that the time stamp was initialized correctly
     286// with the start-date/time of the run (after reading the run header)
     287//
     288// Remark: This 'feature' disallows single runs of more than 11h!
     289//
    243290int MRawEvtHeader::ReadEvt(istream &fin)
    244291{
    245292    fin.read((char*)&fDAQEvtNumber, 4);  // Total=4
    246293
    247     UInt_t abstime[2];
     294    UInt_t abstime[2];                   // BADC|1032
    248295    fin.read((char*)abstime,        8);  // Total=12
    249 
    250     //
    251     // store the time of the event in the corresponding container
    252     //
    253     /*
    254      const Double_t mhz = 9.375;                        // [1e6 ticks/s]
    255      const Double_t t   = (Double_t)abstime[0]/mhz;     // [ns]
    256      const UShort_t ns  = (UShort_t)fmod(t*1e-3, 1e9);
    257      const Byte_t s     = (Byte_t)fmod(t/1e12, 60);
    258      const Byte_t m     = (Byte_t)fmod(t/60e12, 60);
    259      const Byte_t h     = (Byte_t)(t/3600e12);
    260      fTime->SetTime(h, m, s, ns);
    261      */
     296    if (!DecodeTime(abstime))
     297    {
     298        *fLog << err << "ERROR - Event time in event header invalid... abort." << endl;
     299        return kFALSE;
     300    }
    262301
    263302    Byte_t dummy[4];
  • trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h

    r2173 r2728  
    4444    MArrayB *fPixLoGainOn;     //! Array which tell you which pixels have lo gain on
    4545
     46    Bool_t DecodeTime(UInt_t abstime[2]) const;
     47
    4648public:
    47 
    4849    MRawEvtHeader(const char *name=NULL, const char *title=NULL);
    4950    ~MRawEvtHeader();
  • trunk/MagicSoft/Mars/mraw/MRawFileRead.cc

    r2675 r2728  
    151151    fRawRunHeader->Print();
    152152
    153     return fRawRunHeader->GetMagicNumber()==kMagicNumber;
     153    if (fRawRunHeader->GetMagicNumber()!=kMagicNumber)
     154        return kFALSE;
     155
     156    *fRawEvtTime = fRawRunHeader->GetRunStart();
     157
     158    return kTRUE;
    154159}
    155160
  • 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}
  • trunk/MagicSoft/Mars/mraw/MRawRead.h

    r2677 r2728  
    2222    MTime          *fRawEvtTime;    // raw evt time information container to fill from file
    2323
     24    void CreateFakeTime() const;
     25
    2426    Bool_t ReadEvent(istream &fin);
    2527    Int_t  PreProcess(MParList *pList);
  • trunk/MagicSoft/Mars/mraw/MRawRunHeader.cc

    r2645 r2728  
    2929// Root storage container for the RUN HEADER information
    3030//
    31 //
    32 //
    33 //  Version 2:
    34 //  ----------
     31//  Format Version 2:
     32//  -----------------
     33//   - removed mjd from data
     34//   - added start time
     35//   - added stop  time
     36//
     37//  Class Version 2:
     38//  ----------------
    3539//   - removed fMJD, fYear, fMonth, fDay
    3640//   - added fRunStart
    3741//   - added fRunStop
    3842//
    39 //  Version 1:
    40 //  ----------
     43//  Class Version 1:
     44//  ----------------
    4145//   - first implementation
    4246//
     
    212216    for (int i=0; i<GetNumPixel(); i++)
    213217        *fLog << setfill('0') << setw(3) << (*fPixAssignment)[i] << " ";
    214     *fLog << hex << endl;
    215218
    216219    *fLog << endl;
  • trunk/MagicSoft/Mars/mraw/MRawSocketRead.cc

    r2675 r2728  
    252252    }
    253253
     254    *fRawEvtTime = fRawRunHeader->GetRunStart();
     255
    254256    if (!ReadEvent(*fIn))
    255257        return kFALSE;
Note: See TracChangeset for help on using the changeset viewer.