Changeset 8966 for trunk


Ignore:
Timestamp:
06/16/08 23:51:58 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r8965 r8966  
    2020
    2121
    22  2008/06/15 Thomas Bretz
     22 2008/06/17 Thomas Bretz
    2323
    2424   * datacenter/macros/plotdb.C:
     
    3535     - made a sunken border around the canvas
    3636     - SetFrameBorderMode(0) per default
     37
     38   * mraw/MRawRunHeader.[h,cc]:
     39     - added some consistency checks
     40     - make the bug fix for the wrong number of events also for
     41       V10 and V11
     42     - added Getters for RunID and FileID used to idetify
     43       the runs more clever than run-number and file-number
    3744
    3845
  • trunk/MagicSoft/Mars/mraw/MRawRunHeader.cc

    r8946 r8966  
    268268// --------------------------------------------------------------------------
    269269//
     270// Consistency checks. See code for detils.
     271//
     272Bool_t MRawRunHeader::IsConsistent() const
     273{
     274    // FIXME: Match first digits of run-number with telescope number
     275
     276    if (fFormatVersion>10)
     277    {
     278        if (GetRunID()!=fTelescopeNumber && GetRunID()!=fTelescopeNumber*10U && GetRunID()!=fTelescopeNumber*10U+5U)
     279        {
     280            *fLog << err << "ERROR - Telscope number " << fTelescopeNumber << " doesn't match the first two digits of the run number " << fRunNumber << "." << endl;
     281            return kFALSE;
     282        }
     283
     284        // Old formats can not contain a run number larger 0
     285        if (fRunNumber<1000000)
     286        {
     287            *fLog << err << "ERROR - Run number " << fRunNumber << " smaller than 1000000." << endl;
     288            return kFALSE;
     289        }
     290    }
     291
     292    // Check for correct number of bytes in data stream
     293    if (fFormatVersion>7 && fNumBytesPerSample!=2)
     294    {
     295        *fLog << err << "ERROR - " << fNumBytesPerSample << " bytes per sample are not supported!" << endl;
     296        return kFALSE;
     297    }
     298
     299    // If we have a vlid stop time check its consistency with the start time
     300    if (fRunStop!=MTime() && fRunStop<fRunStart)
     301    {
     302        *fLog << err << "ERROR - Stop time smaller than start time." << endl;
     303        return kFALSE;
     304    }
     305
     306    // No file numbers larger than 999 allowed in general
     307    if (fFileNumber>999)
     308    {
     309        *fLog << err << "ERROR - File number " << fFileNumber << " larger than 999." << endl;
     310        return kFALSE;
     311    }
     312
     313    // Old formats can not contain a run number larger 0
     314    if (fFormatVersion<11 && fFileNumber>0)
     315    {
     316        *fLog << err << "ERROR - File number " << fFileNumber << " larger than 0." << endl;
     317        return kFALSE;
     318    }
     319
     320    if (fFormatVersion>1)
     321    {
     322        // For most of the formats the start time must be valid
     323        if (fRunStart==MTime())
     324        {
     325            *fLog << err << "ERROR - Start time invalid." << endl;
     326            return kFALSE;
     327        }
     328
     329        // For most of the formats an invalid stop time cannot happen if file closed
     330        if (fMagicNumber==kMagicNumber && fRunStop==MTime())
     331        {
     332            *fLog << err << "ERROR - File closed but stop time invalid." << endl;
     333            return kFALSE;
     334        }
     335    }
     336    return kTRUE;
     337}
     338
     339// --------------------------------------------------------------------------
     340//
    270341// This implements a fix of the pixel assignment before 25.9.2005
    271342//
     
    398469// --------------------------------------------------------------------------
    399470//
     471// Fixes to fix bugs in the run header
     472//
     473Bool_t MRawRunHeader::Fixes()
     474{
     475    if (fFormatVersion>8)
     476    {
     477        fNumEvents--;
     478        fNumEventsRead--;
     479        *fLog << inf << "Format >V8: Stored number of events decreased by 1." << endl;
     480    }
     481
     482    return FixAssignment();
     483}
     484
     485// --------------------------------------------------------------------------
     486//
    400487//  Reading function to read/interpret the file formats 1-10
    401488//
     
    479566    fin.read((char*)&fNumEvents, 4);     // Total=70
    480567
    481     if (fFormatVersion>8)
    482     {
    483         fin.read((char*)&fNumEventsRead, 4);     // Total=70
    484         fNumEvents--;
    485         fNumEventsRead--;
    486         *fLog << inf << "Format V9: Stored number of events decreased by 1." << endl;
    487     }
    488 
    489568    // New in general features: (should they be included in new MAGIC1 formats, too?)
    490569    fNumBytesPerSample  = 1;      // 2 for MUX DATA
     
    497576        fin.read((char*)&fSamplingFrequency,  2); // [MHz], 2000 for MuxFadc
    498577        fin.read((char*)&fFadcResolution,     1); // nominal resolution [# Bits], 10 for MuxFadc
    499 
    500         if (fNumBytesPerSample!=2)
    501         {
    502             *fLog << err << "ERROR - " << fNumBytesPerSample << " bytes per sample are not supported!" << endl;
    503             return kFALSE;
    504         }
    505578    }
    506579
     
    511584        fRunStop.ReadBinary(fin);               // Total += 7
    512585    }
     586
     587    // ----- Consistency checks -----
     588    if (!IsConsistent())
     589        return kFALSE;
    513590
    514591    //
     
    524601        fin.read(dummy, 16);
    525602
    526     return FixAssignment();
     603    return Fixes();
    527604}
    528605
     
    631708    fRunStop.SetBinary(Int+91);
    632709
     710    // ----- Consistency checks -----
     711    if (!IsConsistent())
     712        return kFALSE;
     713
    633714    // ----- 388 bytes so far -----
    634715
     
    646727        (*fPixAssignment)[i] = Int[97+i];
    647728
    648     return FixAssignment();
     729    return Fixes();
    649730}
    650731
  • trunk/MagicSoft/Mars/mraw/MRawRunHeader.h

    r8946 r8966  
    7272    Bool_t SwapAssignment(Short_t id0, Short_t id1);
    7373    Bool_t FixAssignment();
     74    Bool_t Fixes();
     75    Bool_t IsConsistent() const;
     76
    7477    Bool_t ReadEvtOld(istream& fin);
    7578
     
    102105    UShort_t GetSoftVersion() const       { return fSoftVersion; }
    103106    UInt_t   GetRunNumber() const         { return fRunNumber; }
     107    UInt_t   GetFileNumber() const        { return fFileNumber; }
     108    UInt_t   GetRunID() const             { return (fRunNumber/1000000)%100; }
     109    UInt_t   GetFileID() const            { return fRunNumber>1000000?(fRunNumber%1000000)*1000+(fFileNumber%1000):fRunNumber; }
     110    UShort_t GetTelescopeNumber() const   { return fRunType; }
    104111    UShort_t GetRunType() const           { return fRunType; }
    105112    const Char_t *GetRunTypeStr() const;
Note: See TracChangeset for help on using the changeset viewer.