Changeset 3139 for trunk/MagicSoft


Ignore:
Timestamp:
02/13/04 14:56:42 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r3138 r3139  
    3434   * mbase/MTime.[h,cc]:
    3535     - Changed UpDMagicTime to support nanosec instead of millisec
     36     - exchanged Reset() by Clear() not to clear the yy/mm/dd
     37       information away in an eventloop
    3638
    3739   * mraw/MRawEvtHeader.[h,cc]:
  • trunk/MagicSoft/Mars/NEWS

    r3126 r3139  
    4747   - added support for DAQ raw data file format V2
    4848
    49    - implemented an arbitrary time stamp for the events calculated from the
    50      run number, the date of start and the FADC clock tick from the first
    51      module
     49   - implemented an arbitrary time stamp for the events from raw-data
     50     files with file version<3. It is calculated from the run number,
     51     the date of start and the FADC clock tick from the first module
     52
     53   - implemented the correct decoding of the event time-stamp
     54     coming from the DAQ for raw-data files with file-version>2
    5255
    5356   - added a new classes storing the pedestals in units of photons:
  • trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc

    r2875 r3139  
    236236}
    237237
     238// --------------------------------------------------------------------------
     239//
     240// Decode the binary Time Stamp. For more detailed information see the
     241// source code.
     242//
    238243Bool_t MRawEvtHeader::DecodeTime(UInt_t abstime[2]) const
    239244{
    240     // BADC|1032 --> DCBA|3210 (Byte swap - exchange MSB and LSB)
    241     /*
    242     *fLog << hex << all << setfill('0') << setw(8) << abstime[0] << " " << setw(8) << abstime[1] << "  ";
    243 
    244     for (int i=4*8-1; i>=0; i--)
    245         *fLog << (int)(abstime[0]&BIT(i)?1:0);
    246     *fLog << " ";
    247     for (int i=4*8-1; i>=0; i--)
    248        *fLog << (int)(abstime[1]&BIT(i)?1:0);
    249     */
    250     *fLog << endl;
    251 
    252     abstime[0] = (abstime[0]<<16) | (abstime[0]>>16);
    253 //  abstime[1] = (abstime[1]<<16) | (abstime[1]>>16);
    254 //    *fLog << hex << abstime[0] << " " << abstime[1] << endl;
    255 //    *fLog << dec;
    256 
    257     abstime[0] = abstime[0]<<8&0xff00 | abstime[0]>>8&0x00ff | abstime[0]&0xffff0000;
    258     abstime[1] = abstime[1]<<8&0xff00 | abstime[1]>>8&0x00ff | abstime[1]&0xffff0000;
    259 
    260 
    261 /*    *fLog << hex << abstime[0] << " " << abstime[1] << endl;
    262 */
    263 
    264     // Strange thing!
    265     Char_t t = abstime[0]>>8 &0xf;
    266     abstime[0] &= 0xfffff0ff;
    267 
    268 //    *fLog << abstime[0]<< " " << (int)t << endl;
    269 
    270 
    271     for (int i=0; i<4; i++)
    272     {
    273         abstime[0] |= (t&BIT(i) ? 1 : 0)<<(11-i);
    274         //*fLog << ((t&BIT(i) ? 1 : 0)<<(11-i)) << " ";
    275     }
    276 
    277     //*fLog << endl << abstime[0]<< endl;
    278 
    279     // Decode
    280     const Byte_t h = (abstime[0]>>18 & 0x3)*10 + (abstime[0]>>14 & 0xf);
    281     const Byte_t m = (abstime[0]>>11 & 0x7)*10 + (abstime[0]>> 7 & 0xf);
    282     const Byte_t s = (abstime[0]>> 4 & 0x7)*10 + (abstime[0]>> 0 & 0xf);
    283     const Int_t ms =
    284         ((abstime[0]>>12)&0xf)*1000 +
    285         ((abstime[0]>> 8)&0xf)* 100 +
    286         ((abstime[0]>> 4)&0xf)*  10 +
    287         ((abstime[0]>> 0)&0xf)*   1;
    288 
    289     // hms   =3210 -->  h=2:4 m=3:4 s=3:4
    290     // subsec=DCBA --> subsec?
    291     /*
    292     *fLog << all << dec << setfill('0') << setw(2) << (int)h << ":" << setw(2) << (int)m << ":" << setw(2) << (int)s;
    293     *fLog << " " << hex;
    294     *fLog << (int)(abstime[0]>>12 & 0xf) << ".";
    295     *fLog << (int)(abstime[0]>> 8 & 0xf) << ".";
    296     *fLog << (int)(abstime[0]>> 4 & 0xf) << ".";
    297     *fLog << (int)(abstime[0]>> 0 & 0xf);
    298     *fLog << endl;
    299     */
     245    //
     246    // SuperSecond (20 bits giving hh:mm:ss)
     247    // ------------
     248    //
     249    // Reading the hours:
     250    // Swap bits: 23->16, 22->17, 21->16, 20->19
     251    //
     252    abstime[0] =
     253        abstime[0]>>7 & 0x00010000 |
     254        abstime[0]>>5 & 0x00020000 |
     255        abstime[0]>>3 & 0x00040000 |
     256        abstime[0]>>1 & 0x00080000 |
     257        abstime[0]    & 0xff00ffff;
     258
     259    //
     260    // SubSecond (24 bits giving number of clock ticks of a 5Mhz signal since
     261    // the beginning of last second, i.e., number of ns with a precision of to
     262    // 200 ns)
     263    // ----------
     264    //
     265    // Due to a problem with one Digital Module, three of the less significant
     266    // eight bits of the subsecond are corrupted. So, until new DM's arrive to
     267    // La Palma, we won't use the eight first bits of the subsecond.
     268    // This reduces the precision from 200 ns to of 51.2 us.
     269    //
     270    abstime[1] &= 0xffffff00;
     271
     272    //
     273    // Decode Time Stamp
     274    //
     275    const Byte_t h  = (abstime[0]>>18 & 0x3)*10 + (abstime[0]>>14 & 0xf);
     276    const Byte_t m  = (abstime[0]>>11 & 0x7)*10 + (abstime[0]>> 7 & 0xf);
     277    const Byte_t s  = (abstime[0]>> 4 & 0x7)*10 + (abstime[0]>> 0 & 0xf);
     278    const UInt_t ns =  abstime[1]*200;
     279
     280    //
    300281    // Update the time stamp with the current event time.
    301282    // Make sure, that the time stamp was initialized correctly
    302283    // with the start-date/time of the run (after reading the run header)
    303284    //
    304     // Here the nanosec precision is ignored... (FIXME!)
    305 
    306     return kTRUE;
    307 
    308     static int i=0;
    309     i++;
    310     //fTime->Print();
    311     //    fTime->UpdMagicTime(h, m, s, 0/*ms*/);
    312     //fTime->Print();
    313     return i<25;
    314     //return fTime->UpdMagicTime(h, m, s, ms);
     285    return fTime->UpdMagicTime(h, m, s, ns);
    315286}
    316287
     
    319290// read the EVENT HEADER information from the input stream
    320291// return FALSE if there is now header anymore, else TRUE
     292//
     293// For version>2 we expect to have a valid time-stamp in the files.
    321294//
    322295// Updates the time stamp with the current event time.
     
    326299// Remark: This 'feature' disallows single runs of more than 11h!
    327300//
    328 int MRawEvtHeader::ReadEvt(istream &fin)
     301int MRawEvtHeader::ReadEvt(istream &fin, UShort_t ver)
    329302{
    330303    fin.read((char*)&fDAQEvtNumber, 4);  // Total=4
    331304
    332     UInt_t abstime[2];                   // BADC|1032
     305    UInt_t abstime[2];
    333306    fin.read((char*)abstime,        8);  // Total=12
    334     /*
    335     if (!DecodeTime(abstime))
    336     {
    337         *fLog << err << "ERROR - Event time in event header invalid... abort." << endl;
    338         return kFALSE;
    339     }
    340     */
     307
     308    if (ver>2)
     309        if (!DecodeTime(abstime))
     310        {
     311            *fLog << err << "ERROR - Event time in event header invalid... abort." << endl;
     312            return kFALSE;
     313        }
     314
    341315    Byte_t dummy[4];
    342316    fin.read((char*)&fNumTrigLvl1,  4);  // Total=16
     
    357331    return !fin.eof();
    358332}
     333
  • trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h

    r2728 r3139  
    6060    UInt_t GetDAQEvtNumber() const { return fDAQEvtNumber; }
    6161
    62     int ReadEvt(istream& fin);
     62    int ReadEvt(istream& fin, UShort_t ver);
    6363
    6464    ClassDef(MRawEvtHeader, 1) // Parameter Conatiner for raw EVENT HEADER
  • trunk/MagicSoft/Mars/mraw/MRawRead.cc

    r2875 r3139  
    121121// --------------------------------------------------------------------------
    122122//
    123 // This is a workaround for the oldest runs (run-number<3490)
     123// This is a workaround for the oldest runs (file version<3)
    124124// for which no time stamp was available.
    125125// For this runs a fake time stamp is created
     
    137137    const Double_t t   = tm/mhz;                       // [us]
    138138    const UInt_t ns    = (UInt_t)fmod(t*1e3, 1e6);
    139     const UShort_t ms  = (UShort_t)fmod(t/1e3, 1e3);
     139    //const UShort_t ms  = (UShort_t)fmod(t/1e3, 1e3);
    140140    const Byte_t s     = (Byte_t)fmod(t/1e6, 60);
    141141
     
    146146    m %= 360; // 6h
    147147
    148     fRawEvtTime->UpdMagicTime(m/60, m%60, s, ms/*, ns*/);
     148    fRawEvtTime->UpdMagicTime(m/60, m%60, s, ns);
    149149}
    150150
     
    155155Bool_t MRawRead::ReadEvent(istream &fin)
    156156{
     157    //
     158    //  Get file format version
     159    //
     160    const UShort_t ver = fRawRunHeader->GetFormatVersion();
     161
    157162    //
    158163    //  Read in the next EVENT HEADER (see specification),
    159164    // if there is no next event anymore stop eventloop
    160165    //
    161     if (!fRawEvtHeader->ReadEvt(fin))
     166    if (!fRawEvtHeader->ReadEvt(fin, ver))
    162167        return kFALSE;
    163168
     
    177182    //
    178183    fRawCrateArray->SetSize(nc);
    179 
    180     //
    181     //  Get file format version
    182     //
    183     const UShort_t ver = fRawRunHeader->GetFormatVersion();
    184184
    185185    //
     
    197197    }
    198198
    199     // This is a workaround for the oldest runs (run-number<3490)
     199    // This is a workaround for the oldest runs (version<3)
    200200    // for which no time stamp was available.
    201201    // For this runs a fake time stamp is created
    202     //if (fRawRunHeader->GetRunNumber()<3490)
    203     CreateFakeTime();
     202    if (ver<3)
     203        CreateFakeTime();
    204204
    205205    // FIXME: For all other runs we should enhance the precision
Note: See TracChangeset for help on using the changeset viewer.