Ignore:
Timestamp:
07/23/10 10:48:12 (14 years ago)
Author:
rohlfs
Message:
can read also EventIO files
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mcorsika/MCorsikaEvtHeader.cc

    r9571 r9616  
    3434/////////////////////////////////////////////////////////////////////////////
    3535#include "MCorsikaEvtHeader.h"
     36#include "MCorsikaFormat.h"
    3637
    3738#include <iomanip>
     
    121122// return FALSE if there is no  header anymore, else TRUE
    122123//
    123 Int_t MCorsikaEvtHeader::ReadEvt(std::istream &fin)
     124Int_t MCorsikaEvtHeader::ReadEvt(MCorsikaFormat * fInFormat)
    124125{
    125     char evth[4];
    126     fin.read(evth, 4);
    127     if (memcmp(evth, "EVTH", 4))
    128     {
    129         fin.seekg(-4, ios::cur);
     126
     127    if (!fInFormat->SeekNextBlock("EVTH", 1202))
    130128        return kFALSE;
    131     }
    132129
    133130    Float_t f[273];
    134     fin.read((char*)&f, 273*4);
     131    if (!fInFormat->ReadData(272, f))
     132        return kFALSE;
    135133
    136134    fEvtNumber  = TMath::Nint(f[0]);
     
    160158    if (n!=1)
    161159    {
    162         *fLog << err << "ERROR - Currently only one impact parameter per event is supported." << endl;
    163         return kFALSE;
     160        *fLog << err  << "ERROR  - Currently only one impact parameter per event is supported." << endl;
     161        *fLog << warn << "WARNING - This error is replaced by a warning." << endl;
    164162    }
    165163
     
    167165    fY = -f[97];    //fY = f[117];
    168166
    169     fin.seekg(1088-273*4, ios::cur);
    170 
    171     return !fin.eof();
     167    return !fInFormat->Eof();
    172168}
    173169
     
    175171// this member function is for reading the event end block
    176172
    177 Bool_t MCorsikaEvtHeader::ReadEvtEnd(std::istream &fin)
     173Bool_t MCorsikaEvtHeader::ReadEvtEnd(MCorsikaFormat * fInFormat)
    178174{
     175
     176    if (!fInFormat->SeekNextBlock("EVTE", 1209))
     177        return kFALSE;
     178
    179179    //fin.seekg(-1088,ios::cur);
    180180
    181181    Float_t f[2];
    182     fin.read((char*)&f, 2*4);
     182
     183    if (!fInFormat->ReadData(2, f))
     184        return kFALSE;
    183185
    184186    const UInt_t evtnum = TMath::Nint(f[0]);
     
    192194    fWeightedNumPhotons = f[1];
    193195
    194     fin.seekg(1080,ios::cur);
    195 
    196     return !fin.eof();
     196    return !fInFormat->Eof();
    197197}
    198198
Note: See TracChangeset for help on using the changeset viewer.