Changeset 18532 for trunk/Mars/mcorsika


Ignore:
Timestamp:
08/05/16 15:26:53 (8 years ago)
Author:
tbretz
Message:
Implemented handling of the magic number at the beginning of the file and skipping it at the end when searching for the RUNE section. Return kFALSE if RUNE has not been found.
Location:
trunk/Mars/mcorsika
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mcorsika/MCorsikaFormat.cc

    r10213 r18532  
    4040
    4141
    42 const unsigned int MCorsikaFormat::kSyncMarker = 0xd41f8a37;
     42const unsigned int MCorsikaFormat::kMagicNumber = 0x5994;
     43const unsigned int MCorsikaFormat::kSyncMarker  = 0xd41f8a37;
    4344
    4445// --------------------------------------------------------------------------
     
    6061    memset(buffer, 0, 5);
    6162    fileIn->read(buffer, 4);
     63
     64    // This seems to be a new corsika binary identifier
     65    const bool hasMagicNumber = *reinterpret_cast<unsigned int*>(buffer) == kMagicNumber;
     66    if (hasMagicNumber)
     67        fileIn->read(buffer, 4);
     68
    6269    fileIn->seekg(-4, ios::cur);
    6370
     
    6572    {
    6673        delete [] buffer;
    67         return new MCorsikaFormatRaw(fileIn);
     74        gLog << inf2 << "Corsika RAW format detected." << endl;
     75        return new MCorsikaFormatRaw(fileIn, hasMagicNumber);
    6876    }
    6977
     
    7179    {
    7280        delete [] buffer;
     81        gLog << inf2 << "Corsika EventIO format detected." << endl;
    7382        return new MCorsikaFormatEventIO(fileIn);
    7483    }
     
    159168    for (int i=1; i<22; i++)
    160169    {
    161         fIn->seekg(-i*273*4, ios::end);
     170        fIn->seekg(-i*273*4-(fHasMagicNumber?4:0), ios::end);
    162171
    163172        char runh[5]="\0\0\0\0";
     
    170179        }
    171180    }
    172    
    173     return kTRUE;
     181
     182    return kFALSE;
    174183}
    175184///////////////////////////////////////////////////////////////////////////////
  • trunk/Mars/mcorsika/MCorsikaFormat.h

    r10213 r18532  
    2020public:
    2121    static const unsigned int kSyncMarker;
     22    static const unsigned int kMagicNumber;
    2223
    2324   MCorsikaFormat(std::istream * in)
     
    4546{
    4647private:
     48   bool fHasMagicNumber;
    4749
    4850public:
    49    MCorsikaFormatRaw(std::istream * in)
    50         : MCorsikaFormat(in) {}
     51   MCorsikaFormatRaw(std::istream * in, bool h)
     52        : MCorsikaFormat(in), fHasMagicNumber(h) {}
    5153
    5254   Bool_t NextBlock(Int_t   readState, Int_t & blockType, Int_t & blockVersion,
Note: See TracChangeset for help on using the changeset viewer.