Index: trunk/Mars/mcorsika/MCorsikaEvtHeader.cc
===================================================================
--- trunk/Mars/mcorsika/MCorsikaEvtHeader.cc	(revision 9893)
+++ trunk/Mars/mcorsika/MCorsikaEvtHeader.cc	(revision 9937)
@@ -32,4 +32,9 @@
 //
 //
+// Class Version 3:
+// ----------------
+//  - UInt_t fNumReuse
+//
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MCorsikaEvtHeader.h"
@@ -55,5 +60,5 @@
 //
 MCorsikaEvtHeader::MCorsikaEvtHeader(const char *name, const char *title)
-    : fX(0), fY(0)
+    : fNumReuse((UInt_t)-1), fX(0), fY(0)
 {
     fName  = name  ? name  : "MCorsikaEvtHeader";
@@ -104,5 +109,5 @@
 {
     *fLog << all;
-    *fLog << "Event Number:              " << dec << fEvtNumber << endl;
+    *fLog << "Event Number:              " << dec << fEvtNumber << " (reused=" << fNumReuse << ")" << endl;
 //    *fLog << "Particle ID:               " << MMcEvt::GetParticleName(fParticleID) << endl;
     *fLog << "Energy:                    " << fTotalEnergy << "GeV" << endl;
@@ -122,7 +127,6 @@
 // return FALSE if there is no  header anymore, else TRUE
 //
-Int_t MCorsikaEvtHeader::ReadEvt(MCorsikaFormat * fInFormat)
+Int_t MCorsikaEvtHeader::ReadEvt(MCorsikaFormat *fInFormat)
 {
-
     if (!fInFormat->SeekNextBlock("EVTH", 1202))
         return kFALSE;
@@ -151,17 +155,14 @@
     fMomentumZ = -f[8];  // Does this minus make sense?!
 
-    // FIXME: Correct for direction of magnetic field!
     fZd        = f[9];
     fAz        = TMath::Pi()-f[10];
 
-    const Int_t n = TMath::Nint(f[96]);
-    if (n!=1)
-    {
-        *fLog << err  << "ERROR   - Currently only one impact parameter per event is supported." << endl;
-        *fLog << warn << "WARNING - This error is replaced by a warning." << endl;
-    }
+    // f[96] // Number of reuse of event [max=20]
 
-    fX =  f[117];   //fX = f[97];
-    fY = -f[97];    //fY = f[117];
+    // FIXME: Check fNumReuse<20
+    fX =  f[117 + fNumReuse];
+    fY = -f[ 97 + fNumReuse];
+
+    fWeightedNumPhotons = 0;
 
     return !fInFormat->Eof();
@@ -171,7 +172,6 @@
 // this member function is for reading the event end block
 
-Bool_t MCorsikaEvtHeader::ReadEvtEnd(MCorsikaFormat * fInFormat)
+Int_t MCorsikaEvtHeader::ReadEvtEnd(MCorsikaFormat * fInFormat)
 {
-
     if (!fInFormat->SeekNextBlock("EVTE", 1209))
         return kFALSE;
@@ -192,7 +192,8 @@
     }
 
+    // FIXME: What's the meaning of this if in case of reusing the event this number
+    //        exists only once?
     fWeightedNumPhotons = f[1];
 
     return !fInFormat->Eof();
 }
-
Index: trunk/Mars/mcorsika/MCorsikaEvtHeader.h
===================================================================
--- trunk/Mars/mcorsika/MCorsikaEvtHeader.h	(revision 9893)
+++ trunk/Mars/mcorsika/MCorsikaEvtHeader.h	(revision 9937)
@@ -20,4 +20,5 @@
 private:
     UInt_t   fEvtNumber;              // Event number
+    UInt_t   fNumReuse;               // Counter of the reuse of the same shower
 //    UInt_t   fParticleID;             // Particle ID (see MMcEvtBasic or CORSIKA manual)
     Float_t  fTotalEnergy;            // [GeV] 
@@ -46,4 +47,5 @@
 
     UInt_t GetEvtNumber() const { return fEvtNumber; }
+    UInt_t GetNumReuse() const { return fNumReuse; }
 //    UInt_t GetParticleID() const { return fParticleID; }
 
@@ -62,8 +64,11 @@
     Double_t GetImpact() const;
 
-    Int_t  ReadEvt(MCorsikaFormat * fInFormat);    // read in event header block
-    Bool_t ReadEvtEnd(MCorsikaFormat * fInFormat); // read in event end block
+    void IncNumReuse() { fNumReuse++; }
+    void ResetNumReuse() { fNumReuse=(UInt_t)-1; }
 
-    ClassDef(MCorsikaEvtHeader, 1) // Parameter Conatiner for raw EVENT HEADER
+    Int_t ReadEvt(MCorsikaFormat *informat);    // read in event header block
+    Int_t ReadEvtEnd(MCorsikaFormat *informat); // read in event end block
+
+    ClassDef(MCorsikaEvtHeader, 3) // Parameter Conatiner for raw EVENT HEADER
 }; 
 
Index: trunk/Mars/mcorsika/MCorsikaRead.cc
===================================================================
--- trunk/Mars/mcorsika/MCorsikaRead.cc	(revision 9893)
+++ trunk/Mars/mcorsika/MCorsikaRead.cc	(revision 9937)
@@ -319,5 +319,5 @@
             }
 
-            fNumTotalEvents += fRunHeader->GetNumEvents();
+            fNumTotalEvents += fRunHeader->GetNumEvents()*fRunHeader->GetNumReuse();
             continue;
         }
@@ -393,28 +393,33 @@
 // Read a single event from the stream
 //
-Bool_t MCorsikaRead::ReadEvent()
-{
-    //
-    // Read in the next EVENT HEADER (see specification),
-    // if there is no next event anymore stop eventloop
-    //
-    Int_t rc = fEvtHeader->ReadEvt(fInFormat); //read event header block
-    if (!rc)
-        return kFALSE;
-
-    rc = fEvent->ReadCorsikaEvt(fInFormat);
-
-    /*
-    // Check if we are allowed to stop reading in the middle of the data
-    if (rc==kFALSE && !fForce)
-    {
-        *fLog << err;
-        *fLog << "ERROR - End of file in the middle of the data stream!" << endl;
-        *fLog << "        Set the force-option to force processing." << endl;
-        return kERROR;
-    }
-    */
-
-    return rc==kTRUE ? fEvtHeader->ReadEvtEnd(fInFormat) : rc;
+Int_t MCorsikaRead::ReadEvent()
+{
+    // Store the position to re-read a single event several times
+    //  FIXME: Does this work with EventIO, too?
+    if (fEvtHeader->GetNumReuse()>=fRunHeader->GetNumReuse()-1)
+    {
+        fInFormat->StorePos();
+        fEvtHeader->ResetNumReuse();
+    }
+    else
+        fInFormat->ResetPos();
+
+    fEvtHeader->IncNumReuse();
+
+    // Read the event header
+    const Int_t rc1 = fEvtHeader->ReadEvt(fInFormat);
+    if (rc1!=kTRUE)
+        return rc1;
+
+    // Check if reusage number should be reset and increase it
+    //  Note, that the trick here is that after reset it is set to -1
+
+    // Read the photons corresponding to the i-th core location
+    const Int_t rc2 = fEvent->ReadCorsikaEvt(fInFormat, fEvtHeader->GetNumReuse()+1);
+    if (rc2!=kTRUE)
+        return rc2;
+
+    // read event end
+    return fEvtHeader->ReadEvtEnd(fInFormat);
 }
 
@@ -434,5 +439,5 @@
         {
             // Read a single event from file
-            const Bool_t rc = ReadEvent();
+            const Int_t rc = ReadEvent();
 
             // kFALSE means: end of file (try next one)
@@ -465,8 +470,10 @@
 Int_t MCorsikaRead::PostProcess()
 {
+    const UInt_t n = fNumEvents*fRunHeader->GetNumReuse();
+
     //
     // Sanity check for the number of events
     //
-    if (fNumEvents==GetNumExecutions()-1 || GetNumExecutions()==0)
+    if (n==GetNumExecutions()-1 || GetNumExecutions()==0)
         return kTRUE;
 
@@ -474,5 +481,5 @@
     *fLog << "Warning - number of read events (" << GetNumExecutions()-1;
     *fLog << ") doesn't match number in run header(s) (";
-    *fLog << fNumEvents << ")." << endl;
+    *fLog << fRunHeader->GetNumReuse() << "*" << fNumEvents << "=" << n << ")." << endl;
 
     return kTRUE;
Index: trunk/Mars/mcorsika/MCorsikaRead.h
===================================================================
--- trunk/Mars/mcorsika/MCorsikaRead.h	(revision 9893)
+++ trunk/Mars/mcorsika/MCorsikaRead.h	(revision 9937)
@@ -29,6 +29,6 @@
     UInt_t    fNumTotalEvents; //! total number of events in all files
 
-    ifstream *fIn;             //! input stream (file to read from)
-	 MCorsikaFormat * fInFormat; //! access to input corsika data
+    ifstream       *fIn;       //! input stream (file to read from)
+    MCorsikaFormat *fInFormat; //! access to input corsika data
 
     MParList *fParList;        //! tasklist to call ReInit from
@@ -42,5 +42,5 @@
     Int_t  OpenNextFile(Bool_t print=kTRUE);
     Bool_t CalcNumTotalEvents();
-    Bool_t ReadEvent();
+    Int_t  ReadEvent();
 
     Int_t PreProcess(MParList *pList);
Index: trunk/Mars/mcorsika/MCorsikaRunHeader.cc
===================================================================
--- trunk/Mars/mcorsika/MCorsikaRunHeader.cc	(revision 9893)
+++ trunk/Mars/mcorsika/MCorsikaRunHeader.cc	(revision 9937)
@@ -42,4 +42,8 @@
 //  + Float_t fAtmosphericCoeffC[5]
 //  + UInt_t  fCerenkovFlag
+//
+// Class Version 3:
+// ----------------
+//  + UInt_t  fNumReuse
 //
 ////////////////////////////////////////////////////////////////////////////
@@ -164,6 +168,6 @@
     fInFormat->UnreadLastHeader();
 
-    const Int_t n = TMath::Nint(g[96]);  // Number i of uses of each cherenkov event
-    if (n!=1)
+    fNumReuse = TMath::Nint(g[96]);  // Number i of uses of each cherenkov event
+    if (fNumReuse!=1)
     {
         *fLog << err  << "ERROR   - Currently only one impact parameter per event is supported." << endl;
@@ -269,5 +273,5 @@
     *fLog << "Particle ID:    " << MMcEvt::GetParticleName(fParticleID) << endl;
     if (fNumEvents>0)
-        *fLog << "Num Events:     " << fNumEvents << endl;
+        *fLog << "Num Events:     " << fNumEvents << " (reuse " << fNumReuse << " times)" << endl;
     *fLog << "Obs Level:     ";
     for (Byte_t i=0; i<fNumObsLevel; i++)
Index: trunk/Mars/mcorsika/MCorsikaRunHeader.h
===================================================================
--- trunk/Mars/mcorsika/MCorsikaRunHeader.h	(revision 9893)
+++ trunk/Mars/mcorsika/MCorsikaRunHeader.h	(revision 9937)
@@ -33,4 +33,5 @@
 
     UInt_t  fRunNumber;               // Run number
+    UInt_t  fNumReuse;                // Number of how many times the same shower is used
     UInt_t  fParticleID;              // Particle ID (see MMcEvtBasic or CORSIKA manual)
     UInt_t  fNumEvents;               // Number of events
@@ -76,4 +77,5 @@
     UInt_t GetParticleID() const { return fParticleID; }
     UInt_t GetNumEvents() const { return fNumEvents; }
+    UInt_t GetNumReuse() const { return fNumReuse; }
 
     const MTime &GetRunStart() const { return fRunStart; }
@@ -128,5 +130,5 @@
     void Print(Option_t *t=NULL) const;
 
-    ClassDef(MCorsikaRunHeader, 2)	// storage container for general info
+    ClassDef(MCorsikaRunHeader, 3)	// storage container for general info
 };
 #endif
