Changeset 8946 for trunk


Ignore:
Timestamp:
06/12/08 17:56:54 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r8942 r8946  
    2222 2008/06/12 Thomas Bretz
    2323
     24   * mraw/MRawCrateData.[h,cc], mraw/MRawEvtHeader.[h,cc],
     25     mraw/MRawRunHeader.[h,cc]:
     26     - renamed reading the old format to ReadEvtOld
     27     - implemented reading format>10
     28     - added the header size as new argument to ReadEvt
     29
     30   * mraw/MRawEvtHeader.cc:
     31     - made the argument to DecodeTime const
     32     - fixed the return value in ReadEvtOld. kCONTINUE could
     33       never be returned
     34
     35   * mraw/MRawRead.cc:
     36     - gives header size for format>10 to ReadEvt
     37     - if EvtHeader could not be read correctly return kFALSE
     38     - let MRawCrateData::ReadEvt check end-of-file
     39
     40   * merpp.cc:
     41     - improved explanation for -ff option
     42
     43   * readdaq.cc:
     44     - added -ff option
     45     - added an option to call MReadRawFiles::SetForceMode
     46
     47   * mbase/MTime.[h,cc]:
     48     - added new member function SetBinary to easy processing
     49       of the time from the new run header
     50
     51   * mhflux/MHEffectiveOnTime.cc:
     52     - for the integral (Nm) we have to count also events in under and
     53       overflow bins
     54
     55   * mjobs/MJCalibrateSignal.cc, mjobs/MJCalibration.cc,
     56     mjobs/MJPedestal.cc:
     57     - call MRawFileRead::SetForceMode to get the (corrected)
     58       old behaviour back (not to stop if an event time is
     59       broken but to skip the event)
     60
     61   * mraw/MRawRunHeader.[h,cc]:
     62     - the number of events in format version V9 seems to be
     63       to high by one. We correct for this.
     64     - added new data members for the header sizes
     65     - new data member for the file number
     66     - increased cize of fSourceEpochChar
     67     - consequently increased class version number by 1
     68
    2469   * datacenter/macros/plotdb.C:
    2570     - improved some titles
     
    85130       This ensures that no task can crash due to this
    86131       when processing MCs
    87 
    88    * mraw/MRawRunHeader.cc:
    89      - the number of events in format version V9 seems to be
    90        to high by one. We correct for this.
    91132
    92133   * msql/MSQLMagic.[h,cc]:
  • trunk/MagicSoft/Mars/NEWS

    r8942 r8946  
    7070
    7171   * Implemented cc file version 2008-20-02/0
     72
     73   * Implemented raw data format 11 (the most important change, except
     74     from plenty of changes in the format definition, is the addition
     75     of the file-number in the header) If nobody makes a mistake this
     76     format should have the advantage that it is by definition forward
     77     compatible, so old programs will be able to read newer formats.
    7278
    7379   * Added Pyrometer information to output (stored in a new Tree
  • trunk/MagicSoft/Mars/mbase/MTime.cc

    r8907 r8946  
    827827}
    828828
     829Bool_t MTime::SetBinary(const UInt_t t[6])
     830{
     831    return Set(t[0], t[1], t[2], t[3], t[4], t[5], 0);
     832}
     833
    829834istream &MTime::ReadBinary(istream &fin)
    830835{
  • trunk/MagicSoft/Mars/mbase/MTime.h

    r8907 r8946  
    9898    void     SetCorsikaTime(Float_t time);
    9999    Bool_t   SetStringFmt(const char *time, const char *fmt, const char *loc=0);
     100    Bool_t   SetBinary(const UInt_t t[6]);
    100101    Bool_t   UpdMagicTime(Byte_t h, Byte_t m, Byte_t s, UInt_t ns);
    101102    Bool_t   SetMjd(UInt_t mjd, ULong_t ms, UInt_t ns=0);
  • trunk/MagicSoft/Mars/merpp.cc

    r8933 r8946  
    7979    gLog << "   -u, --update              Update an existing file." << endl << endl;
    8080    gLog << " Raw Data Options:" << endl;
    81     gLog << "   -ff                       Force merpp to ignore broken events" << endl;
     81    gLog << "   -ff                       Force merpp to ignore broken events and don't stop" << endl;
    8282    gLog << "   --interleave=#            Process only each i-th event [default=1]" << endl << endl;
    8383//    gLog << "   --sql=mysql://user:password@url  Insert run into database" << endl << endl;
  • trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc

    r8932 r8946  
    501501Bool_t MHEffectiveOnTime::FitH(TH1D *h, Double_t *res, Bool_t paint) const
    502502{
    503     const Double_t Nm = h->Integral();
     503    // Count also events in under-/overflowbins
     504    const Double_t Nm = h->Integral(0, h->GetNbinsX()+1);
    504505
    505506    // FIXME: Do fit only if contents of bin has changed
  • trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc

    r8938 r8946  
    369369
    370370    MRawFileRead rawread(NULL);
     371    reawread.SetForceMode(); // Ignore broken time-stamps
    371372
    372373    MRead *read = fSequence.IsMonteCarlo() ? (MRead*)&readmc : (MRead*)&rawread;
  • trunk/MagicSoft/Mars/mjobs/MJCalibration.cc

    r8898 r8946  
    16931693    MReadMarsFile read("Events");
    16941694    MRawFileRead rawread(NULL);
     1695    reawread.SetForceMode(); // Ignore broken time-stamps
    16951696
    16961697    if (!fSequence.IsMonteCarlo())
  • trunk/MagicSoft/Mars/mjobs/MJPedestal.cc

    r8898 r8946  
    10151015    MReadMarsFile read("Events");
    10161016    MRawFileRead rawread(NULL);
     1017    reawread.SetForceMode(); // Ignore broken time-stamps
    10171018
    10181019    MDirIter iter;
  • trunk/MagicSoft/Mars/mraw/MRawRunHeader.cc

    r8941 r8946  
    1818!   Author(s): Thomas Bretz 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2007
     20!   Copyright: MAGIC Software Development, 2000-2008
    2121!
    2222!
     
    3232//  RAW DATA FORMAT VERSION
    3333//  =======================
     34//
     35//  Format Version 11:
     36//  -----------------
     37//   * all variables got four bytes
     38//   * header sizes allow to make the format backward compatible
     39//   + fHeaderSizeRun
     40//   + fHeaderSizeEvt
     41//   + fHeaderSizeCrate
     42//   + fFileNumber
     43//   + fNumSamplesRemovedHead
     44//   + fNumSamplesRemovedTail
     45//
     46//  Format Version 10:
     47//  -----------------
     48//    ?
    3449//
    3550//  Format Version 9:
     
    8196//  MRawRunHeader CLASS VERSION
    8297//  ===========================
     98//
     99//  Format Version 10:
     100//  -----------------
     101//   - added fHeaderSizeRun
     102//   - added fHeaderSizeEvt
     103//   - added fHeaderSizeCrate
     104//   - added fFileNumber
     105//   - increased fSourceEpochChar
    83106//
    84107//  Format Version 7:
     
    127150#include <iomanip>
    128151
     152#include <TArrayC.h>
     153
    129154#include "MLog.h"
    130155#include "MLogManip.h"
     
    137162
    138163const UShort_t MRawRunHeader::kMagicNumber      = 0xc0c0;
    139 const Byte_t   MRawRunHeader::kMaxFormatVersion =      9;
     164const Byte_t   MRawRunHeader::kMaxFormatVersion =     11;
    140165
    141166// --------------------------------------------------------------------------
     
    162187    fRunType=kRTNone;  // use 0xffff for invalidation, 0 means: Data run
    163188    fRunNumber=0;
     189    fFileNumber=0;
    164190    memset(fProjectName,     0, 101);
    165191    memset(fSourceName,      0,  81);
     
    329355//   "corrected" also in the signal. Hence signal swapped since 99354
    330356//
    331 // --------------------------------------------------------------------------
    332 
    333357Bool_t MRawRunHeader::FixAssignment()
    334358{
     
    374398// --------------------------------------------------------------------------
    375399//
    376 // Read in one run header from the binary file
    377 //
    378 Bool_t MRawRunHeader::ReadEvt(istream& fin)
    379 {
    380     //
    381     // read one RUN HEADER from the input stream
    382     //
    383     fMagicNumber = 0;
    384 
    385     fin.read((char*)&fMagicNumber, 2);          // Total=2
    386 
    387     //
    388     // check whether the the file has the right file type or not
    389     //
    390     if (fMagicNumber != kMagicNumber && fMagicNumber != kMagicNumber+1)
    391     {
    392         *fLog << err << "ERROR - Wrong Magic Number (0x" << hex << fMagicNumber << "): Not a Magic File!" << endl;
    393         return kFALSE;
    394     }
    395 
    396     if (fMagicNumber == kMagicNumber+1)
    397         *fLog << warn << "WARNING - This file maybe broken (0xc0c1) - DAQ didn't close it correctly!" << endl;
    398 
    399     Byte_t dummy[16];
    400 
    401     // ----- File format version -----
    402     fin.read((char*)&fFormatVersion, 2);     // Total=4
    403     if (fFormatVersion>kMaxFormatVersion)
    404     {
    405         *fLog << err << "ERROR - File format V" << fFormatVersion << " not implemented!" << endl;
    406         return kFALSE;
    407     }
    408 
     400//  Reading function to read/interpret the file formats 1-10
     401//
     402Bool_t MRawRunHeader::ReadEvtOld(istream& fin)
     403{
    409404    if (fFormatVersion==7)
    410405    {
     
    477472    fin.read((char*)&fNumSamplesHiGain, 2); // MUX: Number of samples per pixel
    478473
     474    char dummy[16];
    479475    if (fFormatVersion>8)
    480         fin.read((char*)dummy, 4); // 2xU16 (NumSamplesRemovedHead and NumSamplesRemovedTail)
     476        fin.read(dummy, 4); // 2xU16 (NumSamplesRemovedHead and NumSamplesRemovedTail)
    481477
    482478    // ----- Number of events -----
     
    526522
    527523    if (fFormatVersion<7)
    528         fin.read((char*)&dummy, 16);
     524        fin.read(dummy, 16);
     525
     526    return FixAssignment();
     527}
     528
     529// --------------------------------------------------------------------------
     530//
     531// Read in one run header from the binary file
     532//
     533Bool_t MRawRunHeader::ReadEvt(istream& fin)
     534{
     535    //
     536    // read one RUN HEADER from the input stream
     537    //
     538    fMagicNumber = 0;
     539
     540    fin.read((char*)&fMagicNumber, 2);          // Total=2
     541
     542    //
     543    // check whether the the file has the right file type or not
     544    //
     545    if (fMagicNumber != kMagicNumber && fMagicNumber != kMagicNumber+1)
     546    {
     547        *fLog << err << "ERROR - Wrong Magic Number (0x" << hex << fMagicNumber << "): Not a Magic File!" << endl;
     548        return kFALSE;
     549    }
     550
     551    if (fMagicNumber == kMagicNumber+1)
     552        *fLog << warn << "WARNING - This file maybe broken (0xc0c1) - DAQ didn't close it correctly!" << endl;
     553
     554    // ----- File format version -----
     555    fin.read((char*)&fFormatVersion, 2);     // Total=4
     556    if (fFormatVersion==10 || fFormatVersion>kMaxFormatVersion)
     557    {
     558        *fLog << err << "ERROR - File format V" << fFormatVersion << " not implemented!" << endl;
     559        return kFALSE;
     560    }
     561
     562    // ----- Process old file formats -----
     563    if (fFormatVersion<10)
     564        return ReadEvtOld(fin);
     565
     566    // ----- Overwrite format version for format 11 -----
     567    fin.read((char*)&fFormatVersion, 4);
     568    if (fFormatVersion<11)
     569    {
     570        *fLog << err << "ERROR - Format Version <11." << endl;
     571        return kFALSE;
     572    }
     573
     574    // ----- Read Header by size as written in the header -----
     575    fin.read((char*)&fHeaderSizeRun, 4);
     576    if (fHeaderSizeRun<346)
     577    {
     578        *fLog << err << "ERROR - Event header too small (<388b)." << endl;
     579        return kFALSE;
     580    }
     581
     582    TArrayC h(fHeaderSizeRun-12);
     583    fin.read(h.GetArray(), h.GetSize());
     584    if (!fin)
     585        return kFALSE;
     586
     587    // ----- convert -----
     588    const Byte_t  *Char  = reinterpret_cast<Byte_t* >(h.GetArray());
     589    const UInt_t  *Int   = reinterpret_cast<UInt_t* >(h.GetArray());
     590    //const Float_t *Float = reinterpret_cast<Float_t*>(h.GetArray());
     591
     592    // ----- Start interpretation -----
     593
     594    fHeaderSizeEvt   = Int[0];
     595    fHeaderSizeCrate = Int[1];
     596    fSoftVersion     = Int[2];
     597    fFadcType        = Int[3];
     598    fCameraVersion   = Int[4];
     599    fTelescopeNumber = Int[5];
     600    fRunType         = Int[6];
     601    fRunNumber       = Int[7];
     602    fFileNumber      = Int[8];
     603
     604    memcpy(fProjectName,     Char+ 36, 100);  // 25
     605    memcpy(fSourceName,      Char+136,  80);  // 20
     606    memcpy(fObservationMode, Char+216,  60);  // 15
     607
     608    //F32       fSourceRA     = Float[69];
     609    //F32       fSourceDEC    = Float[70];
     610    //F32       fTelescopeRA  = Float[71];
     611    //F32       fTelescopeDEC = Float[72];
     612
     613    memcpy(fSourceEpochChar, Char+232, 4);
     614
     615    fSourceEpochDate    = Int[74];
     616    fNumCrates          = Int[75];
     617    fNumPixInCrate      = Int[76];
     618    fNumSamplesHiGain   = Int[77];
     619    fNumSamplesLoGain   = 0;
     620
     621    //fNumSamplesRemovedHead = Int[78];
     622    //fNumSamplesRemovedTail = Int[79];
     623
     624    fNumEvents          = Int[80];
     625    fNumEventsRead      = Int[81];
     626    fNumBytesPerSample  = Int[82];
     627    fSamplingFrequency  = Int[83];
     628    fFadcResolution     = Int[84];
     629
     630    fRunStart.SetBinary(Int+85);
     631    fRunStop.SetBinary(Int+91);
     632
     633    // ----- 388 bytes so far -----
     634
     635    const UInt_t n = fNumCrates*fNumPixInCrate;
     636    if (fHeaderSizeRun<388+n*4)
     637    {
     638        *fLog << err << "ERROR - Event header too small to contain pix assignment." << endl;
     639        return kFALSE;
     640    }
     641
     642    // ----- Pixel Assignment -----
     643    fPixAssignment->Set(n);
     644
     645    for (UInt_t i=0; i<n; i++)
     646        (*fPixAssignment)[i] = Int[97+i];
    529647
    530648    return FixAssignment();
     
    578696        *fLog << "Camera=" << fCameraVersion;
    579697    *fLog << endl;
     698    if (fFormatVersion>10)
     699        *fLog << "Header sizes: " << fHeaderSizeRun << "b (run), " << fHeaderSizeEvt << "b (evt), " << fHeaderSizeCrate << "b (crate)" << endl;
    580700    if (fFormatVersion>5)
    581701        *fLog << "Telescope:    " << fTelescopeNumber << endl;
  • trunk/MagicSoft/Mars/mraw/MRawRunHeader.h

    r8892 r8946  
    3939    /* ---- Run Header Informations ---- */
    4040    UShort_t  fMagicNumber;          // File type identifier
     41
     42    UInt_t    fHeaderSizeRun;        // Size of run header
     43    UInt_t    fHeaderSizeEvt;        // Size of evt header
     44    UInt_t    fHeaderSizeCrate;      // Size of crate header
     45
    4146    UShort_t  fFormatVersion;        // File format version
    4247    UShort_t  fSoftVersion;          // DAQ software version
     
    4651    UShort_t  fRunType;              // Run Type
    4752    UInt_t    fRunNumber;            // Run number
     53    UInt_t    fFileNumber;           // File number
    4854    Char_t    fProjectName[101];     // Project name
    4955    Char_t    fSourceName[81];       // Source name
    5056    Char_t    fObservationMode[61];  // observation mode
    51     Char_t    fSourceEpochChar[2];   // epoch char of the source
     57    Char_t    fSourceEpochChar[4];   // epoch char of the source
    5258    UShort_t  fSourceEpochDate;      // epoch date of the source
    5359    UShort_t  fNumCrates;            // number of electronic boards
     
    6672    Bool_t SwapAssignment(Short_t id0, Short_t id1);
    6773    Bool_t FixAssignment();
     74    Bool_t ReadEvtOld(istream& fin);
    6875
    6976public:
     
    9097    // This is to get the numbers...
    9198    UShort_t GetMagicNumber() const       { return fMagicNumber; }
     99    UInt_t   GetHeaderSizeEvt() const     { return fHeaderSizeEvt; }
     100    UInt_t   GetHeaderSizeCrate() const   { return fHeaderSizeCrate; }
    92101    UShort_t GetFormatVersion() const     { return fFormatVersion; }
    93102    UShort_t GetSoftVersion() const       { return fSoftVersion; }
     
    136145    Bool_t ReadEvt(istream& fin);
    137146
    138     ClassDef(MRawRunHeader, 9)  // storage container for general info
     147    ClassDef(MRawRunHeader, 10) // storage container for general info
    139148};
    140149#endif
  • trunk/MagicSoft/Mars/readdaq.cc

    r8088 r8946  
    5353    gLog << "     -d1: print data in decimal values" << endl;
    5454    gLog << "     -c1: print MRawCrateArray data" << endl;
    55     gLog << "     -f:  force reading of runheader" << endl;
     55    gLog << "     -ff: force reading of broken runheader" << endl;
     56    gLog << "     -f:  force reading of files with problems" << endl;
    5657    gLog << "     -?, -h, --help: This help" << endl << endl;
    5758}
     
    8182    // Set verbosity to highest level.
    8283    //
    83     const bool kDecimal    = arg.HasOption("-d") && arg.GetIntAndRemove("-d")==1;
    84     const bool kPrintArray = arg.HasOption("-c") && arg.GetIntAndRemove("-c")==1;
    85     const bool kForce      = arg.HasOnlyAndRemove("-f");
     84    const Bool_t kDecimal    = arg.HasOption("-d") && arg.GetIntAndRemove("-d")==1;
     85    const Bool_t kPrintArray = arg.HasOption("-c") && arg.GetIntAndRemove("-c")==1;
     86    const Bool_t kForce      = arg.HasOnlyAndRemove("-ff");
     87    const Bool_t kForceMode  = arg.HasOnlyAndRemove("-f");
    8688
    8789    //
     
    160162    MRawFileRead read(kNamein);
    161163    read.SetForce(kForce);
     164    read.SetForceMode(kForceMode);
    162165    tasks.AddToList(&read);
    163166
Note: See TracChangeset for help on using the changeset viewer.