Changeset 19850


Ignore:
Timestamp:
11/01/19 14:51:25 (5 years ago)
Author:
tbretz
Message:
This is also used to catch some option from the runheaders before pre-processing. Therefore, this has to be handles properly.
File:
1 edited

Legend:

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

    r19848 r19850  
    290290    fNumTotalEvents = 0;
    291291
    292     MCorsikaRunHeader runheader;
     292    bool allocated = false;
     293    MCorsikaRunHeader *runheader = fRunHeader;
     294    if (!runheader)
     295    {
     296        runheader = new MCorsikaRunHeader;
     297        allocated = true;
     298    }
    293299
    294300    Bool_t rc = kTRUE;
    295 
    296301    while (1)
    297302    {
     
    314319               {
    315320               if (blockType == 1200)
    316                   status = runheader.ReadEvt(fInFormat, blockLength / sizeof(Float_t));
     321                  status = runheader->ReadEvt(fInFormat, blockLength / sizeof(Float_t));
    317322
    318323               else if(blockType == 1201)
     
    323328                  vector<Float_t> buffer(blockLength / sizeof(Float_t));
    324329                  status = fInFormat->Read(buffer.data(), blockLength);
    325                   status = runheader.ReadEventHeader(buffer.data());
     330                  status = runheader->ReadEventHeader(buffer.data());
    326331                  break;
    327332                  }
     
    335340            if (!fInFormat->SeekEvtEnd())
    336341            {
    337                *fLog << (fForceMode?warn:err) << "ERROR - RUNE section not found in file." << endl;
     342                *fLog << (fForceMode?warn:err) << "ERROR - RUNE section not found in file." << endl;
     343               if (allocated)
     344                   delete runheader;
    338345               if (!fForceMode)
    339346                  return fForceMode ? kTRUE : kFALSE;
    340347            }
    341348
    342             if (!runheader.ReadEvtEnd(fInFormat, kTRUE))
     349            if (!runheader->ReadEvtEnd(fInFormat, kTRUE))
    343350            {
    344351               *fLog << (fForceMode?warn:err) << "ERROR - Reading RUNE section failed." << endl;
     352               if (allocated)
     353                   delete runheader;
    345354               if (!fForceMode)
    346355                  return kFALSE;
    347356            }
    348357
    349             fNumTotalEvents += runheader.GetNumEvents()*runheader.GetNumReuse()*
     358            fNumTotalEvents += runheader->GetNumEvents()*runheader->GetNumReuse()*
    350359                (fTelescopeIdx<0 && fNumTelescope==0 ? fNumTelescopes : 1);
    351360            continue;
     
    354363    }
    355364
     365    if (allocated)
     366        delete runheader;
    356367    return rc;
    357368}
Note: See TracChangeset for help on using the changeset viewer.