Index: /trunk/Mars/ceres.cc
===================================================================
--- /trunk/Mars/ceres.cc	(revision 19847)
+++ /trunk/Mars/ceres.cc	(revision 19848)
@@ -148,5 +148,8 @@
     gLog.Setup(arg);
 
-    StartUpMessage();
+    const Bool_t kCheckOnly = arg.HasOnlyAndRemove("--check");
+
+    if (!kCheckOnly)
+        StartUpMessage();
 
     if (arg.HasOnly("-V") || arg.HasOnly("--version"))
@@ -159,7 +162,7 @@
     }
 
-    const Bool_t  kBatch      = arg.HasOnlyAndRemove("-b");
+    const Bool_t  kBatch      = arg.HasOnlyAndRemove("-b") || kCheckOnly;
     //const Int_t   kCompLvl   = arg.GetIntAndRemove("--comp=", 1);
-    const Bool_t  kForce      = arg.HasOnlyAndRemove("-ff");
+    const Bool_t  kForce      = arg.HasOnlyAndRemove("-ff") && !kCheckOnly;
     const Bool_t  kDebugMem   = arg.HasOnlyAndRemove("--debug-mem");
     const Bool_t  kNullOut    = arg.HasOnlyAndRemove("--dev-null");
@@ -340,4 +343,7 @@
     MArray::Class()->IgnoreTObjectStreamer();
     MParContainer::Class()->IgnoreTObjectStreamer();
+
+    if (kCheckOnly)
+        gROOT->SetBatch();
 
     TApplication app("ceres", &argc, argv);
@@ -381,7 +387,11 @@
         // job.SetPathIn(kInpath); // not yet needed
 
-        if (!job.Process(arg, seq))
-        {
-            gLog << err << "Calculation of ceres failed." << endl << endl;
+        if (!job.Process(arg, seq, kCheckOnly))
+        {
+            if (job.GetDisplay())
+                delete d;
+
+            if (!kCheckOnly)
+                gLog << err << "Calculation of ceres failed." << endl << endl;
             return 2;
         }
Index: /trunk/Mars/mcorsika/MCorsikaRead.cc
===================================================================
--- /trunk/Mars/mcorsika/MCorsikaRead.cc	(revision 19847)
+++ /trunk/Mars/mcorsika/MCorsikaRead.cc	(revision 19848)
@@ -167,5 +167,5 @@
 // This opens the next file in the list and deletes its name from the list.
 //
-Int_t MCorsikaRead::OpenNextFile(Bool_t print)
+Int_t MCorsikaRead::OpenNextFile(Bool_t print, Bool_t telrequired)
 {
 
@@ -196,33 +196,35 @@
         return kERROR;
 
-    *fLog << inf << "Open file: '" << name << "'" << endl;
-
-    // Check if thsi is a single telescope from a CORSIKA telescope array
-    // This is indicated by the -telXXX attached to the filename
-    TObjArray *res = TPRegexp("(.*/)?cer([0-9]+)-tel([0-9]+)").MatchS(name, "i");
-    if (res->GetLast()==3)
+    *fLog << (telrequired?inf:all) << "Open file: '" << name << "'" << endl;
+
+    if (telrequired)
     {
-        const TString match = res->At(0)->GetName();
-        const TString path  = res->At(1)->GetName();
-        const UInt_t  runid = atoi(res->At(2)->GetName());
-        const UInt_t  telid = atoi(res->At(3)->GetName());
-
-        *fLog << inf2 << "Run " << runid << " detected to be for telescope #" << telid << endl;
-
-        if (telid>=fNumTelescopes)
+        // Check if thsi is a single telescope from a CORSIKA telescope array
+        // This is indicated by the -telXXX attached to the filename
+        TObjArray *res = TPRegexp("(.*/)?cer([0-9]+)-tel([0-9]+)").MatchS(name, "i");
+        if (res->GetLast()==3)
         {
-            *fLog << err << "Position of telescope " << telid << " not defined." << endl;
-            return kERROR;
+            const TString match = res->At(0)->GetName();
+            const TString path  = res->At(1)->GetName();
+            const UInt_t  runid = atoi(res->At(2)->GetName());
+            const UInt_t  telid = atoi(res->At(3)->GetName());
+
+            *fLog << inf2 << "Run " << runid << " detected to be for telescope #" << telid << endl;
+
+            if (telid>=fNumTelescopes)
+            {
+                *fLog << err << "Position of telescope " << telid << " not defined." << endl;
+                return kERROR;
+            }
+
+            *fLog << inf << "Telescope #" << telid << " [X/Y/Z (R)]: ";
+            *fLog << fTelescopeX[telid] << "/";
+            *fLog << fTelescopeY[telid] << "/";
+            *fLog << fTelescopeZ[telid] << " (R=" << fTelescopeR[telid] << ")" << endl;
+
+            fNumTelescope = telid+1;
         }
-
-        *fLog << inf << "Telescope #" << telid << " [X/Y/Z (R)]: ";
-        *fLog << fTelescopeX[telid] << "/";
-        *fLog << fTelescopeY[telid] << "/";
-        *fLog << fTelescopeZ[telid] << " (R=" << fTelescopeR[telid] << ")" << endl;
-
-        fNumTelescope = telid+1;
+        delete res;
     }
-    delete res;
-
 
     if (fDisplay)
@@ -288,9 +290,11 @@
     fNumTotalEvents = 0;
 
+    MCorsikaRunHeader runheader;
+
     Bool_t rc = kTRUE;
 
     while (1)
     {
-        switch (OpenNextFile(kFALSE))
+        switch (OpenNextFile(kFALSE, kFALSE))
         {
         case kFALSE:
@@ -310,5 +314,5 @@
                {
                if (blockType == 1200)
-                  status = fRunHeader->ReadEvt(fInFormat, blockLength / sizeof(Float_t));
+                  status = runheader.ReadEvt(fInFormat, blockLength / sizeof(Float_t));
 
                else if(blockType == 1201)
@@ -319,5 +323,5 @@
                   vector<Float_t> buffer(blockLength / sizeof(Float_t));
                   status = fInFormat->Read(buffer.data(), blockLength);
-                  status = fRunHeader->ReadEventHeader(buffer.data());
+                  status = runheader.ReadEventHeader(buffer.data());
                   break;
                   }
@@ -325,5 +329,5 @@
                   fInFormat->Seek(blockLength);
                }
-                  
+
             if (status != kTRUE)
                return status;
@@ -331,17 +335,17 @@
             if (!fInFormat->SeekEvtEnd())
             {
-               *fLog << (fForceMode?warn:err) << "Error: RUNE section not found in file." << endl;
+               *fLog << (fForceMode?warn:err) << "ERROR - RUNE section not found in file." << endl;
                if (!fForceMode)
                   return fForceMode ? kTRUE : kFALSE;
             }
 
-            if (!fRunHeader->ReadEvtEnd(fInFormat, kTRUE))
+            if (!runheader.ReadEvtEnd(fInFormat, kTRUE))
             {
-               *fLog << (fForceMode?warn:err) << "Error: Reading RUNE section failed." << endl;
+               *fLog << (fForceMode?warn:err) << "ERROR - Reading RUNE section failed." << endl;
                if (!fForceMode)
                   return kFALSE;
             }
 
-            fNumTotalEvents += fRunHeader->GetNumEvents()*fRunHeader->GetNumReuse()*
+            fNumTotalEvents += runheader.GetNumEvents()*runheader.GetNumReuse()*
                 (fTelescopeIdx<0 && fNumTelescope==0 ? fNumTelescopes : 1);
             continue;
@@ -806,11 +810,4 @@
         *fLog << inf2 << "Reading Telecope positions from " << fname << ":" << endl;
 
-        TPRegexp regexp("\\s*TELESCOPE"
-                        "\\s+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)"
-                        "\\s+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)"
-                        "\\s+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)"
-                        "\\s+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)"
-                        "\\s+([0-9]+)\\s*");
-
         ifstream fin(fname);
 
@@ -823,23 +820,26 @@
                 break;
 
-            const TObjArray *res = regexp.MatchS(buf);
-            if (res->GetLast()==9)
+            buf = buf.Strip(TString::kBoth);
+            if (buf(0, 9)!="TELESCOPE")
+                continue;
+
+            float x, y, z, r;
+            int idx;
+            if (sscanf(buf.Data()+9, "%f %f %f %f %d", &x, &y, &z, &r, &idx)!=5)
+                continue;
+
+            if (idx>=fNumTelescopes)
             {
-                const UInt_t idx = atoi(res->At(9)->GetName());
-                if (idx>=fNumTelescopes)
-                {
-                    fNumTelescopes = idx+1;
-                    fTelescopeX.Set(fNumTelescopes);
-                    fTelescopeY.Set(fNumTelescopes);
-                    fTelescopeZ.Set(fNumTelescopes);
-                    fTelescopeR.Set(fNumTelescopes);
-                }
-
-                fTelescopeX[idx] = atof(res->At(1)->GetName());
-                fTelescopeY[idx] = atof(res->At(3)->GetName());
-                fTelescopeZ[idx] = atof(res->At(5)->GetName());
-                fTelescopeR[idx] = atof(res->At(7)->GetName());
+                fNumTelescopes = idx+1;
+                fTelescopeX.Set(fNumTelescopes);
+                fTelescopeY.Set(fNumTelescopes);
+                fTelescopeZ.Set(fNumTelescopes);
+                fTelescopeR.Set(fNumTelescopes);
             }
-            delete res;
+
+            fTelescopeX[idx] = x;
+            fTelescopeY[idx] = y;
+            fTelescopeZ[idx] = z;
+            fTelescopeR[idx] = r;
         }
 
Index: /trunk/Mars/mcorsika/MCorsikaRead.h
===================================================================
--- /trunk/Mars/mcorsika/MCorsikaRead.h	(revision 19847)
+++ /trunk/Mars/mcorsika/MCorsikaRead.h	(revision 19848)
@@ -67,7 +67,5 @@
     //Bool_t    fForce;
 
-
-    Int_t  OpenNextFile(Bool_t print=kTRUE);
-    Bool_t CalcNumTotalEvents();
+    Int_t  OpenNextFile(Bool_t print=kTRUE, Bool_t telrequired=kTRUE);
     Int_t  ReadTelescopePosition();
     Int_t  ReadNextBlockHeader();
@@ -82,4 +80,6 @@
     MCorsikaRead(const char *filename=NULL, const char *name=NULL, const char *title=NULL);
     ~MCorsikaRead();
+
+    Bool_t CalcNumTotalEvents();
 
     void SetForceMode(Bool_t b=kTRUE) { fForceMode=b; }
Index: /trunk/Mars/mjobs/MJSimulation.cc
===================================================================
--- /trunk/Mars/mjobs/MJSimulation.cc	(revision 19847)
+++ /trunk/Mars/mjobs/MJSimulation.cc	(revision 19848)
@@ -396,5 +396,5 @@
 }
 
-Bool_t MJSimulation::Process(const MArgs &args, const MSequence &seq)
+Bool_t MJSimulation::Process(const MArgs &args, const MSequence &seq, Bool_t checkonly)
 {
     // --------------------------------------------------------------------------------
@@ -409,7 +409,8 @@
     // - description of the job itself
     // - list of the to processed sequence
+    if (!checkonly)
+        fLog->Separator(GetDescriptor());
+
     *fLog << inf;
-    fLog->Separator(GetDescriptor());
-
     if (!CheckEnv())
         return kFALSE;
@@ -418,5 +419,5 @@
         *fLog << fSequence.GetFileName() << endl;
     else
-        *fLog << "Input: " << args.GetNumArguments() << "-files" << endl;
+        *fLog << "Input: " << args.GetNumArguments() << " file(s)" << endl;
     *fLog << endl;
 
@@ -550,4 +551,7 @@
         return kFALSE;
     }
+
+    if (checkonly)
+        return read.CalcNumTotalEvents();
 
     // --------------------------------------------------------------------------------
@@ -823,6 +827,6 @@
 
     const char *regex = fRunNumber<0 ?
-        "s/[cC][eE][rR]([0-9]+)(-[tT][eE][lL]([0-9]+))?/%s\\/00$1.%03d%%s_MonteCarlo$3.root/" :
-        "s/[cC][eE][rR][0-9]+([0-9][0-9][0-9])(-[tT][eE][lL]([0-9]+))?/%s\\/%08d.$1%%s_MonteCarlo$3.root/";
+        "s/[cC][eE][rR]([0-9]+)(-[tT][eE][lL]([0-9]+))?/%s\\/00$1.%03d%%s_MonteCarlo$2.root/" :
+        "s/[cC][eE][rR][0-9]+([0-9][0-9][0-9])(-[tT][eE][lL]([0-9]+))?/%s\\/%08d.$1%%s_MonteCarlo$2.root/";
 
     const char *fmt = fFileOut.IsNull() ?
Index: /trunk/Mars/mjobs/MJSimulation.h
===================================================================
--- /trunk/Mars/mjobs/MJSimulation.h	(revision 19847)
+++ /trunk/Mars/mjobs/MJSimulation.h	(revision 19848)
@@ -54,5 +54,5 @@
 
     // Process
-    Bool_t Process(const MArgs &args, const MSequence &seq);
+    Bool_t Process(const MArgs &args, const MSequence &seq, Bool_t checkonly);
 
     ClassDef(MJSimulation, 0) // Job to run the simulation (ceres)
