Changeset 9949 for trunk/Mars


Ignore:
Timestamp:
09/29/10 21:30:21 (14 years ago)
Author:
tbretz
Message:
Fixed a problem reading the RUNE section in the raw corsika files and accelerated plain readcorsika.
Location:
trunk/Mars
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/Changelog

    r9948 r9949  
    2323   * msimreflector/MMirrorSquare.[h,cc]:
    2424     - implemented WriteM
     25
     26   * mcorsika/MCorsikaEvtHeader.cc, mcorsika/MCorsikaFormat.[h,cc],
     27     mcorsika/MCorsikaRunHeader.cc:
     28     - fixed a problem with reading the RUNE section in corsikas
     29       raw format
     30
     31   * readcorsika.cc:
     32     - speed up reading by ot printing the single photons if debug
     33       level less than 3
     34
     35   * msim/MPhotonEvent.cc:
     36     - don't loop over all (mostly empty) slots in Print()
    2537
    2638
  • trunk/Mars/mcorsika/MCorsikaEvtHeader.cc

    r9941 r9949  
    129129Int_t MCorsikaEvtHeader::ReadEvt(MCorsikaFormat *fInFormat)
    130130{
    131     if (!fInFormat->SeekNextBlock("EVTH", 1202))
    132         return kFALSE;
     131    const Int_t rc=fInFormat->SeekNextBlock("EVTH", 1202);
     132    if (rc!=kTRUE)
     133        return rc;
    133134
    134135    Float_t f[273];
    135136    if (!fInFormat->ReadData(272, f))
    136         return kFALSE;
     137        return kERROR;
    137138
    138139    fEvtNumber  = TMath::Nint(f[0]);
     
    169170    fWeightedNumPhotons = 0;
    170171
    171     return !fInFormat->Eof();
     172    return fInFormat->Eof() ? kERROR : kTRUE;
    172173}
    173174
     
    177178Int_t MCorsikaEvtHeader::ReadEvtEnd(MCorsikaFormat * fInFormat)
    178179{
    179     if (!fInFormat->SeekNextBlock("EVTE", 1209))
    180         return kFALSE;
     180    if (fInFormat->SeekNextBlock("EVTE", 1209)!=kTRUE)
     181        return kERROR;
    181182
    182183    //fin.seekg(-1088,ios::cur);
    183184
    184185    Float_t f[2];
    185 
    186186    if (!fInFormat->ReadData(2, f))
    187         return kFALSE;
     187        return kERROR;
    188188
    189189    const UInt_t evtnum = TMath::Nint(f[0]);
     
    199199    fWeightedNumPhotons = f[1];
    200200
    201     return !fInFormat->Eof();
    202 }
     201    return fInFormat->Eof() ? kERROR : kTRUE;
     202}
  • trunk/Mars/mcorsika/MCorsikaFormat.cc

    r9946 r9949  
    151151// of the id.
    152152//
    153 Bool_t MCorsikaFormatRaw::SeekNextBlock(const char * id, unsigned short type) const
     153Int_t MCorsikaFormatRaw::SeekNextBlock(const char * id, unsigned short type) const
    154154{
    155155    char blockHeader[5]="\0\0\0\0";
     
    162162    // but find the end of a run. This is expected, therefor no error
    163163    // message.
    164     if (strcmp(id, "EVTH")==0 && strcmp(blockHeader, "RUNE")==0)
    165         return kTRUE;
     164    if (strcmp(blockHeader, "RUNE")==0)
     165        return kFALSE;
    166166
    167167    gLog << err << "ERROR - Wrong identifier: " << id << " expected.";
    168168    gLog << " But read " << blockHeader << " from file." << endl;
    169169
    170     return kFALSE;
     170    return kERROR;
    171171}
    172172
     
    182182Bool_t MCorsikaFormatRaw::SeekEvtEnd()
    183183{
    184 
    185184    // Search subblockwise backward (Block: 5733*4 = 21*273*4)
    186185    for (int i=1; i<22; i++)
     
    250249// of the id.
    251250//
    252 Bool_t MCorsikaFormatEventIO::SeekNextBlock(const char * id, unsigned short type) const
     251Int_t MCorsikaFormatEventIO::SeekNextBlock(const char * id, unsigned short type) const
    253252{
    254253    cout << "Seek " << type << endl;
     
    267266        {
    268267            gLog << err << "MCorsikaFormatEventIO::SeekNextBlock: ERROR - Unexpected end-of-file seeking " << id << " (" << type << ")." << endl;
    269             return kFALSE;
     268            return kERROR;
    270269        }
    271270
     
    343342    // we have to search in the file
    344343    fIn->seekg(currentPos, ios::beg);
    345     if (!SeekNextBlock("RUNE", 1210))
     344    if (SeekNextBlock("RUNE", 1210)!=kTRUE)
    346345        return kFALSE;
    347346
  • trunk/Mars/mcorsika/MCorsikaFormat.h

    r9943 r9949  
    2727   virtual ~MCorsikaFormat();
    2828
    29    virtual Bool_t SeekNextBlock(const char * id, unsigned short type) const = 0;
     29   virtual Int_t SeekNextBlock(const char * id, unsigned short type) const = 0;
    3030   virtual void   UnreadLastHeader() const = 0;
    3131
     
    6060        : MCorsikaFormat(in) {}
    6161
    62    Bool_t SeekNextBlock(const char * id, unsigned short type) const;
     62   Int_t SeekNextBlock(const char * id, unsigned short type) const;
    6363   void   UnreadLastHeader() const;
    6464
     
    7979        : MCorsikaFormat(in) {fRunePos = std::streampos(0);}
    8080
    81     Bool_t SeekNextBlock(const char *id, unsigned short type) const;
     81    Int_t SeekNextBlock(const char *id, unsigned short type) const;
    8282    void   UnreadLastHeader() const;
    8383
  • trunk/Mars/mcorsika/MCorsikaRunHeader.cc

    r9937 r9949  
    8585Bool_t MCorsikaRunHeader::ReadEvt(MCorsikaFormat * fInFormat)
    8686{
    87     if (!fInFormat->SeekNextBlock("RUNH", 1200))
     87    if (fInFormat->SeekNextBlock("RUNH", 1200)!=kTRUE)
    8888        return kFALSE;
    8989
     
    158158    // f[145] Muon multiple scattering flag
    159159
    160     if (!fInFormat->SeekNextBlock("EVTH", 1202))
     160    if (fInFormat->SeekNextBlock("EVTH", 1202)!=kTRUE)
    161161        return kFALSE;
    162162
     
    221221Bool_t MCorsikaRunHeader::ReadEvtEnd(MCorsikaFormat * fInFormat)
    222222{
    223 
    224     if (!fInFormat->SeekNextBlock("RUNE", 1210))
     223    if (fInFormat->SeekNextBlock("RUNE", 1210)!=kTRUE)
    225224        return kFALSE;
    226225
  • trunk/Mars/msim/MPhotonEvent.cc

    r9942 r9949  
    398398Int_t MPhotonEvent::GetNumExternal() const
    399399{
    400     Int_t n=0;
    401 
    402     for (int i=0; i<GetNumPhotons(); i++)
     400    const Int_t n=GetNumPhotons();
     401
     402    Int_t rc = 0;
     403    for (int i=0; i<n; i++)
    403404        if ((*this)[i].GetPrimary()!=MMcEvtBasic::kNightSky)
    404             n++;
    405 
    406     return n;
     405            rc++;
     406
     407    return rc;
    407408}
    408409
     
    816817}
    817818*/
     819
    818820// --------------------------------------------------------------------------
    819821//
     
    822824void MPhotonEvent::Print(Option_t *) const
    823825{
    824     fData.Print();
     826    // This is much faster than looping over all entries and discarding
     827    // the empty ones
     828    const UInt_t n = GetNumPhotons();
     829    for (UInt_t i=0; i<n; i++)
     830        operator[](i).Print();
    825831}
    826832
  • trunk/Mars/readcorsika.cc

    r9933 r9949  
    164164        tasks.AddToList(&print0);
    165165        tasks.AddToList(&print1);
    166         tasks.AddToList(&print4);
     166        if (gLog.GetDebugLevel()>2)
     167            tasks.AddToList(&print4);
    167168    }
    168169    else
Note: See TracChangeset for help on using the changeset viewer.