Index: /trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc	(revision 2206)
+++ /trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc	(revision 2207)
@@ -340,4 +340,7 @@
 void MStatusDisplay::SetLogStream(MLog *log, Bool_t enable)
 {
+    if (gROOT->IsBatch())
+        return;
+
     if (log && fLogBox==NULL)
     {
@@ -455,4 +458,6 @@
 void MStatusDisplay::SetStatusLine1(const char *txt)
 {
+    if (gROOT->IsBatch())
+        return;
     fStatusBar->SetText(txt, 0);
     gClient->ProcessEventsFor(fStatusBar);
@@ -465,4 +470,6 @@
 void MStatusDisplay::SetStatusLine2(const char *txt)
 {
+    if (gROOT->IsBatch())
+        return;
     fStatusBar->SetText(txt, 1);
     gClient->ProcessEventsFor(fStatusBar);
@@ -491,10 +498,11 @@
 //
 MStatusDisplay::MStatusDisplay(Long_t t)
-: TGMainFrame(gClient->GetRoot(), 1, 1), fTimer(this, t, kTRUE), fStatus(kLoopNone), fLog(&gLog), fLogIdx(-1), fLogTimer(this, 250, kTRUE), fLogBox(NULL), fIsLocked(0)
+: TGMainFrame(gClient ? gClient->GetRoot() : NULL, 1, 1), fTimer(this, t, kTRUE), fStatus(kLoopNone), fLog(&gLog), fLogIdx(-1), fLogTimer(this, 250, kTRUE), fLogBox(NULL), fIsLocked(0)
 {
     gROOT->GetListOfSpecials()->Add(this);
-    gROOT->GetListOfCleanups()->Add(this);
 
     fFont = gVirtualX->LoadQueryFont("7x13bold");
+
+    fBatch.SetOwner();
 
     //
@@ -521,8 +529,11 @@
     // Add Widgets (from top to bottom)
     //
-    AddMenuBar();
-    AddTabs();
-    AddProgressBar();
-    AddStatusBar();
+    if (gClient) // BATCH MODE
+    {
+        AddMenuBar();
+        AddTabs();
+        AddProgressBar();
+        AddStatusBar();
+    }
 
     //
@@ -547,4 +558,6 @@
 MStatusDisplay::~MStatusDisplay()
 {
+    gROOT->GetListOfSpecials()->Remove(this);
+
     SetLogStream(NULL);
 
@@ -553,8 +566,5 @@
     if (fFont)
         gVirtualX->DeleteFont(fFont);
-
-    gROOT->GetListOfSpecials()->Remove(this);
-    gROOT->GetListOfCleanups()->Remove(this);
-} 
+}
 
 // --------------------------------------------------------------------------
@@ -594,4 +604,7 @@
 TCanvas *MStatusDisplay::GetCanvas(int i) const
 {
+    if (gROOT->IsBatch())
+        return (TCanvas*)fBatch.At(i-1);
+
     if (i<0 || i>=fTab->GetNumberOfTabs())
     {
@@ -656,8 +669,15 @@
 TCanvas &MStatusDisplay::AddTab(const char *name)
 {
+    if (gROOT->IsBatch())
+    {
+        TCanvas *c = new TCanvas(name, name);
+        fBatch.Add(c);
+        return *c;
+    }
+
     // Add new tab
     TGCompositeFrame *f = fTab->AddTab(name);
 
-    // create root embedded canvas and add it to the tab
+    // create root emb 0edded canvas and add it to the tab
     TRootEmbeddedCanvas *ec = new TRootEmbeddedCanvas(name, f, f->GetWidth(), f->GetHeight(), 0);
     f->AddFrame(ec, fLayCanvas);
@@ -676,9 +696,10 @@
     // layout and map new tab
 //#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,00)
+//    MapSubwindows();
+//    Layout();
+//#else
+    Layout();
     MapSubwindows();
     Layout();
-//#else
-//    Layout();
-//    MapSubwindows();
 //#endif
 
@@ -707,7 +728,14 @@
         return;
 
-    c->Modified();
-    c->Update();
-    c->Paint();
+    // Code taken from TCanvas::Update() and TCanvas::Paint
+    c->FeedbackMode(kFALSE);  // Goto double buffer mode
+    c->Paint();               // Repaint all pad's
+    c->Flush();               // Copy all pad pixmaps to the screen
+    //c->SetCursor(kCross);
+
+    // Old version
+    //c->Modified();
+    //c->Update();
+    //c->Paint();
 }
 
@@ -803,4 +831,7 @@
 Bool_t MStatusDisplay::HasCanvas(const TCanvas *c) const
 {
+    if (gROOT->IsBatch())
+        return fBatch.FindObject(c);
+
     for (int i=1; i<fTab->GetNumberOfTabs(); i++)
         if (c==GetCanvas(i))
@@ -829,5 +860,5 @@
     case kLoopStop:
     case kFileExit:
-        if (id==kFileExit && !fIsLocked)
+        if (id==kFileExit)
             delete this;
         fStatus = (Status_t)id;
@@ -1154,5 +1185,5 @@
 void MStatusDisplay::SetNoContextMenu(Bool_t flag)
 {
-    if (fIsLocked>1)
+    if (fIsLocked>1 || gROOT->IsBatch())
         return;
 
@@ -1173,4 +1204,7 @@
 Bool_t MStatusDisplay::HandleTimer(TTimer *timer)
 {
+    if (gROOT->IsBatch())
+        return kTRUE;
+
     const Int_t c = fTab->GetCurrent();
 
@@ -1302,14 +1336,20 @@
     }
 
-    if (num>=fTab->GetNumberOfTabs())
+    if (!gROOT->IsBatch() && num>=fTab->GetNumberOfTabs())
     {
         *fLog << warn << "MStatusDisplay::Write: Tab doesn't exist... skipped." << endl;
         return 0;
     }
+    if (gROOT->IsBatch() && num>fBatch.GetSize())
+    {
+        *fLog << warn << "MStatusDisplay::Write: Tab doesn't exist... skipped." << endl;
+        return 0;
+    }
 
     TObjArray list;
 
-    const Int_t from = num<0 ? 1 : num;
-    const Int_t to   = num<0 ? fTab->GetNumberOfTabs() : num+1;
+    const Int_t max  = gROOT->IsBatch() ? fBatch.GetSize()+1 : fTab->GetNumberOfTabs();
+    const Int_t from = num<0 ?   1 : num;
+    const Int_t to   = num<0 ? max : num+1;
 
     TCanvas *c;
@@ -1406,4 +1446,7 @@
 Bool_t MStatusDisplay::CheckTabForCanvas(int num) const
 {
+    if (gROOT->IsBatch())
+        return num>0 && num<=fBatch.GetSize() || num<0;
+
     if (num>=fTab->GetNumberOfTabs())
     {
@@ -1530,6 +1573,7 @@
     // Maintain tab numbers
     //
-    const Int_t from = num<0 ? 1 : num;
-    const Int_t to   = num<0 ? fTab->GetNumberOfTabs() : num+1;
+    const Int_t max  = gROOT->IsBatch() ? fBatch.GetSize()+1 : fTab->GetNumberOfTabs();
+    const Int_t from = num<0 ?   1 : num;
+    const Int_t to   = num<0 ? max : num+1;
 
     for (int i=from; i<to; i++)
@@ -1572,5 +1616,4 @@
         CanvasSetFillColor(*n, kWhite);
         l.Add(n);
-
         //
         // Paint canvas into root file
@@ -1578,5 +1621,5 @@
         if (num<0)
             *fLog << inf << " - ";
-        *fLog << inf << "Writing Tab #" << i << ": " << c->GetName() << " (" << n << ") ";
+        *fLog << inf << "Writing Tab #" << i << ": " << c->GetName() << " (" << c << ") ";
         if (num>0)
             *fLog << "to " << name;
@@ -1614,5 +1657,4 @@
 
     gPad = NULL; // Important!
-
     l.Delete();
 
@@ -1621,5 +1663,6 @@
 
     gVirtualPS = psave;
-    padsav->cd();
+    if (padsav)
+        padsav->cd();
 
     *fLog << inf << "done." << endl;
@@ -1632,4 +1675,9 @@
 Bool_t MStatusDisplay::SaveAsGIF(Int_t num, TString name)
 {
+    if (gROOT->IsBatch())
+    {
+        *fLog << warn << "Sorry, writing gif-files is not available in batch mode." << endl;
+        return 0;
+    }
     SetStatusLine1("Writing GIF file...");
     SetStatusLine2("");
Index: /trunk/MagicSoft/Mars/mmain/MStatusDisplay.h
===================================================================
--- /trunk/MagicSoft/Mars/mmain/MStatusDisplay.h	(revision 2206)
+++ /trunk/MagicSoft/Mars/mmain/MStatusDisplay.h	(revision 2207)
@@ -74,4 +74,6 @@
 
     UInt_t fIsLocked;
+
+    TList fBatch;
 
     void AddMenuBar();
Index: /trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.cc	(revision 2206)
+++ /trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.cc	(revision 2207)
@@ -65,5 +65,5 @@
 } 
 
-Bool_t MMcCollectionAreaCalc::PreProcess (MParList *pList)
+Int_t MMcCollectionAreaCalc::PreProcess (MParList *pList)
 {
     // connect the raw data with this task
@@ -151,5 +151,5 @@
 }
 
-Bool_t MMcCollectionAreaCalc::Process()
+Int_t MMcCollectionAreaCalc::Process()
 {
     const Double_t energy = fMcEvt->GetEnergy();
@@ -178,5 +178,5 @@
 }
 
-Bool_t MMcCollectionAreaCalc::PostProcess()
+Int_t MMcCollectionAreaCalc::PostProcess()
 { 
     //
Index: /trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.h	(revision 2206)
+++ /trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.h	(revision 2207)
@@ -30,13 +30,13 @@
     Bool_t fAllEvtsTriggered;
 
+    Bool_t ReInit(MParList *plist);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
 public:
     MMcCollectionAreaCalc(const char *input=NULL,
                           const char *name=NULL, const char *title=NULL);
-
-    Bool_t ReInit(MParList *plist);
-
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
 
     ClassDef(MMcCollectionAreaCalc, 0) // Task to calculate the collection area histogram
Index: /trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc	(revision 2206)
+++ /trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc	(revision 2207)
@@ -100,5 +100,5 @@
 // connect Monte Carlo data with this task
 //
-Bool_t MMcThresholdCalc::PreProcess(MParList* pList)
+Int_t MMcThresholdCalc::PreProcess(MParList* pList)
 {
     //
@@ -142,5 +142,5 @@
 // distribution to get the energy threshold.
 //
-Bool_t MMcThresholdCalc::Process()
+Int_t MMcThresholdCalc::Process()
 {
     const Float_t energy   = fMcEvt->GetEnergy();
@@ -160,5 +160,5 @@
 // Some iterations are done to be sure the fit parameters converge.
 //
-Bool_t MMcThresholdCalc::PostProcess()
+Int_t MMcThresholdCalc::PostProcess()
 {
     for (UInt_t i=0; i<fNum; i++)
Index: /trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.h	(revision 2206)
+++ /trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.h	(revision 2207)
@@ -14,5 +14,5 @@
 #endif
 #ifndef ROOT_TObjArray
-#include "TObjArray.h"
+#include <TObjArray.h>
 #endif
 
@@ -39,13 +39,12 @@
     MHMcEnergy *GetHEnergy(UInt_t i) { return (MHMcEnergy*)(*fEnergy)[i]; }
 
+    Int_t PreProcess(MParList* pList);
+    Int_t Process();
+    Int_t PostProcess();
+
 public:
-
     MMcThresholdCalc(const Int_t dim = 0,
                      const char* name = NULL, const char* title = NULL);
     ~MMcThresholdCalc();
-
-    Bool_t PreProcess(MParList* pList);
-    Bool_t Process();
-    Bool_t PostProcess();
 
     ClassDef(MMcThresholdCalc, 0) // Task to compute the energy threshold
Index: /trunk/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.cc	(revision 2206)
+++ /trunk/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.cc	(revision 2207)
@@ -16,5 +16,5 @@
 !
 !
-!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !   Author(s): Harald Kornmayer 1/2001
 !
@@ -63,5 +63,5 @@
 //  options, either Montecarlo files with a single trigger option.
 //
-Bool_t MMcTimeGenerate::PreProcess (MParList *pList)
+Int_t MMcTimeGenerate::PreProcess (MParList *pList)
 {
     // connect the raw data with this task
@@ -77,5 +77,5 @@
 //
 //
-Bool_t MMcTimeGenerate::Process()
+Int_t MMcTimeGenerate::Process()
 {
     Double_t dt;
Index: /trunk/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.h
===================================================================
--- /trunk/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.h	(revision 2206)
+++ /trunk/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.h	(revision 2207)
@@ -20,4 +20,7 @@
     Double_t fDeadTime;
 
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
 public:
     MMcTimeGenerate(const char *name=NULL, const char *title=NULL);
@@ -25,7 +28,4 @@
     ~MMcTimeGenerate();
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-
     ClassDef(MMcTimeGenerate, 0) // To generate a random time
 };
Index: /trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc	(revision 2206)
+++ /trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc	(revision 2207)
@@ -16,15 +16,19 @@
 !
 !
-!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !   Author(s): Harald Kornmayer 1/2001
 !
 !   Copyright: MAGIC Software Development, 2000-2003
 !
-!   Modified 4/7/2002 Abelardo Moralejo: now the dimension of fTrigger is
-!    set dinamically, to allow an arbitrary large number of trigger 
-!    conditions to be processed.
-!
 !
 \* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Modified 4/7/2002 Abelardo Moralejo: now the dimension of fTrigger is
+//  set dinamically, to allow an arbitrary large number of trigger
+//  conditions to be processed.
+//
+/////////////////////////////////////////////////////////////////////////////
 #include "MMcTriggerRateCalc.h"
 
@@ -32,4 +36,5 @@
 
 #include <TCanvas.h>
+#include <TGraphErrors.h>
 
 #include "MLog.h"
@@ -215,5 +220,5 @@
 //  options, either Montecarlo files with a single trigger option.
 //
-Bool_t MMcTriggerRateCalc::PreProcess (MParList *pList)
+Int_t MMcTriggerRateCalc::PreProcess (MParList *pList)
 {
     // connect the raw data with this task
@@ -266,5 +271,5 @@
 //  MHMcRate container.
 //
-Bool_t MMcTriggerRateCalc::Process()
+Int_t MMcTriggerRateCalc::Process()
 {
     //
@@ -318,5 +323,5 @@
 //  The PostProcess-function calculates and shows the trigger rate
 //
-Bool_t MMcTriggerRateCalc::PostProcess()
+Int_t MMcTriggerRateCalc::PostProcess()
 {
     for (UInt_t i=0; i<fNum; i++)
@@ -374,5 +379,5 @@
      sure, that the histograms are not overwritten.
      Also the comment for the function doesn't match the rules.
-
+     BTW: please replace all arrays by Root lists (TArray*, TList, etc)
   TCanvas *c = MH::MakeDefCanvas("Rate");
 
Index: /trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h	(revision 2206)
+++ /trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h	(revision 2207)
@@ -9,6 +9,4 @@
 #endif
 
-#include <TGraphErrors.h>
-
 class MParList;
 class MMcEvt;
@@ -17,9 +15,10 @@
 class MMcTrig;
 class MHMcRate;
+class TH1F;
 
 class MMcTriggerRateCalc : public MTask
 {
 private:
-    MMcEvt    *fMcEvt;        //!
+    MMcEvt    *fMcEvt;     //!
 
     TObjArray *fMcRate;
@@ -29,16 +28,18 @@
     MMcCorsikaRunHeader *fMcCorRunHeader; 
 
-    UInt_t     fNum;           // decoded dimension
+    UInt_t     fNum;       // decoded dimension
     UInt_t     fFirst;
     UInt_t     fLast;
 
-    Float_t*   fTrigNSB;   // Number of triggers due to NSB alone
+    Float_t   *fTrigNSB;   // Number of triggers due to NSB alone
     Float_t    fSimNSB;    // Number of simulated NSB-only events
 
-    Float_t*   fTrigger;       // Number of triggered showers
-    Float_t    fShowers;       // Number of simulated showers
-    Float_t    fAnalShow;      // Number of analysed showers
+    Float_t   *fTrigger;   // Number of triggered showers
+    Float_t    fShowers;   // Number of simulated showers
+    Float_t    fAnalShow;  // Number of analysed showers
 
-    Int_t      fPartId;        // Incident particle that generates showers
+    Int_t      fPartId;    // Incident particle that generates showers
+
+    TH1F      *fHist[5];
 
     void Init(int dim, float *trigbg,
@@ -48,5 +49,9 @@
     MMcTrig  *GetTrig(UInt_t i) const { return (MMcTrig*)((*fMcTrig)[i]); }
 
-    TH1F*     fHist[5];
+    Bool_t ReInit(MParList *plist);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
 
 public:
@@ -59,10 +64,4 @@
     ~MMcTriggerRateCalc();
 
-    Bool_t ReInit(MParList *plist);
-
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
-
     TH1F* GetHist(Int_t i) {return fHist[i];}
 
Index: /trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc	(revision 2206)
+++ /trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc	(revision 2207)
@@ -91,5 +91,5 @@
 // number of columns (with the same meaning).
 //
-Bool_t MRanForestCalc::PreProcess(MParList *plist)
+Int_t MRanForestCalc::PreProcess(MParList *plist)
 {
     fRanForest = (MRanForest*)plist->FindObject("MRanForest");
@@ -137,5 +137,5 @@
 //
 //
-Bool_t MRanForestCalc::Process()
+Int_t MRanForestCalc::Process()
 {
     // first copy the data from the data array to a vector event
Index: /trunk/MagicSoft/Mars/mranforest/MRanForestCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/mranforest/MRanForestCalc.h	(revision 2206)
+++ /trunk/MagicSoft/Mars/mranforest/MRanForestCalc.h	(revision 2207)
@@ -24,4 +24,7 @@
     MRanTree    *fRanTree;
 
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+
 public:
     MRanForestCalc(const char *name=NULL, const char *title=NULL);
@@ -33,7 +36,4 @@
     void SetUseNumTrees(UShort_t n=100) { fNum = n; }
 
-    Bool_t PreProcess(MParList *plist);
-    Bool_t Process();
-
     ClassDef(MRanForestCalc, 0) // Task
 };
Index: /trunk/MagicSoft/Mars/mranforest/MRanForestFill.cc
===================================================================
--- /trunk/MagicSoft/Mars/mranforest/MRanForestFill.cc	(revision 2206)
+++ /trunk/MagicSoft/Mars/mranforest/MRanForestFill.cc	(revision 2207)
@@ -72,5 +72,5 @@
 
 // --------------------------------------------------------------------------
-Bool_t MRanForestFill::PreProcess(MParList *plist)
+Int_t MRanForestFill::PreProcess(MParList *plist)
 {
     fRanTree = (MRanTree*)plist->FindObject("MRanTree");
@@ -96,5 +96,5 @@
 //
 //
-Bool_t MRanForestFill::Process()
+Int_t MRanForestFill::Process()
 {
     fNum++;
@@ -105,5 +105,5 @@
 }
 
-Bool_t MRanForestFill::PostProcess()
+Int_t MRanForestFill::PostProcess()
 {
     fRanForest->SetNumTrees(fNum);
Index: /trunk/MagicSoft/Mars/mranforest/MRanForestFill.h
===================================================================
--- /trunk/MagicSoft/Mars/mranforest/MRanForestFill.h	(revision 2206)
+++ /trunk/MagicSoft/Mars/mranforest/MRanForestFill.h	(revision 2207)
@@ -20,4 +20,8 @@
     Int_t fNum;
 
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+    Int_t PostProcess();
+
 public:
     MRanForestFill(const char *name=NULL, const char *title=NULL);
@@ -26,8 +30,4 @@
     void SetNumTrees(UShort_t n=100) { fNumTrees = n; }
 
-    Bool_t PreProcess(MParList *plist);
-    Bool_t Process();
-    Bool_t PostProcess();
-
     ClassDef(MRanForestFill, 0) // Task
 };
Index: /trunk/MagicSoft/Mars/mranforest/MRanForestGrow.cc
===================================================================
--- /trunk/MagicSoft/Mars/mranforest/MRanForestGrow.cc	(revision 2206)
+++ /trunk/MagicSoft/Mars/mranforest/MRanForestGrow.cc	(revision 2207)
@@ -75,5 +75,5 @@
 // number of columns (with the same meaning).
 //
-Bool_t MRanForestGrow::PreProcess(MParList *plist)
+Int_t MRanForestGrow::PreProcess(MParList *plist)
 {
     fMGammas = (MHMatrix*)plist->FindObject("MatrixGammas", "MHMatrix");
@@ -122,5 +122,5 @@
 //
 //
-Bool_t MRanForestGrow::Process()
+Int_t MRanForestGrow::Process()
 {
     Bool_t not_last=fRanForest->GrowForest();
@@ -130,5 +130,5 @@
 }
 
-Bool_t MRanForestGrow::PostProcess()
+Int_t MRanForestGrow::PostProcess()
 {
     fRanTree->SetReadyToSave();
Index: /trunk/MagicSoft/Mars/mranforest/MRanForestGrow.h
===================================================================
--- /trunk/MagicSoft/Mars/mranforest/MRanForestGrow.h	(revision 2206)
+++ /trunk/MagicSoft/Mars/mranforest/MRanForestGrow.h	(revision 2207)
@@ -31,4 +31,8 @@
     Int_t fNdSize;
 
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
 public:
     MRanForestGrow(const char *name=NULL, const char *title=NULL);
@@ -38,8 +42,4 @@
     void SetNdSize(Int_t n)  {    fNdSize=n;  }
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
-
     ClassDef(MRanForestGrow, 0) // Task to grow a random forest
 };
Index: /trunk/MagicSoft/Mars/mraw/MRawEvtData.cc
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 2206)
+++ /trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 2207)
@@ -64,4 +64,5 @@
 #include "MArrayS.h"
 #include "MArrayB.h"
+#include "MGeomCam.h"
 #include "MRawRunHeader.h"
 #include "MRawEvtPixelIter.h"
@@ -472,5 +473,5 @@
 }
 
-Bool_t MRawEvtData::GetPixelContent(Float_t &val, Int_t idx, Float_t ratio, Int_t type) const
+Bool_t MRawEvtData::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
 {
     MRawEvtPixelIter Next(const_cast<MRawEvtData*>(this));
@@ -478,5 +479,7 @@
         return kFALSE;
 
-    val = Next.GetSumHiGainSamples();
+    val = Next.GetSumHiGainSamples()-(float)GetNumHiGainSamples()*fHiGainFadcSamples->GetArray()[0];
+    val *= cam.GetPixRatio(idx);
+
     return kTRUE;
 }
Index: /trunk/MagicSoft/Mars/mraw/MRawEvtData.h
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawEvtData.h	(revision 2206)
+++ /trunk/MagicSoft/Mars/mraw/MRawEvtData.h	(revision 2207)
@@ -64,5 +64,5 @@
     void ReadEvt(istream &fin);
 
-    Bool_t GetPixelContent(Float_t &val, Int_t idx, Float_t ratio=1, Int_t type=0) const;
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
     void   DrawPixelContent(Int_t num) const
     {
Index: /trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc	(revision 2206)
+++ /trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc	(revision 2207)
@@ -203,4 +203,19 @@
 }
 
+Byte_t MRawEvtPixelIter::GetNumMaxHiGainSample() const
+{
+    Byte_t max  = 0;
+    Byte_t maxi = 0;
+
+    for (int i=0; i<fNumHiGainSamples; i++)
+        if (fHiGainPos[i]>max)
+        {
+            max = fHiGainPos[i];
+            maxi = i;
+        }
+
+    return maxi;
+}
+
 // --------------------------------------------------------------------------
 //
Index: /trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h	(revision 2206)
+++ /trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h	(revision 2207)
@@ -81,4 +81,6 @@
     Float_t GetVarHiGainSamples() const;
 
+    Byte_t GetNumMaxHiGainSample() const;
+
     Bool_t HasLoGain() const
     {
Index: /trunk/MagicSoft/Mars/mraw/MRawFileRead.cc
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawFileRead.cc	(revision 2206)
+++ /trunk/MagicSoft/Mars/mraw/MRawFileRead.cc	(revision 2207)
@@ -128,5 +128,5 @@
 // Now the EvtHeader and EvtData containers are initialized.
 //
-Bool_t MRawFileRead::PreProcess(MParList *pList)
+Int_t MRawFileRead::PreProcess(MParList *pList)
 {
     //
@@ -192,5 +192,5 @@
 //  - the raw data information of one event is read
 //
-Bool_t MRawFileRead::Process()
+Int_t MRawFileRead::Process()
 {
     //
@@ -236,5 +236,5 @@
 //  if it doesn't match.
 //
-Bool_t MRawFileRead::PostProcess()
+Int_t MRawFileRead::PostProcess()
 {
     //
Index: /trunk/MagicSoft/Mars/mraw/MRawFileRead.h
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawFileRead.h	(revision 2206)
+++ /trunk/MagicSoft/Mars/mraw/MRawFileRead.h	(revision 2207)
@@ -29,11 +29,12 @@
     ifstream       *fIn;            //! buffered input stream (file to read from)
 
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+
 public:
     MRawFileRead(const char *filename, const char *name=NULL, const char *title=NULL);
     ~MRawFileRead();
-
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
 
     ClassDef(MRawFileRead, 0)	// Task to read the raw data binary file
Index: /trunk/MagicSoft/Mars/mraw/MRawFileWrite.cc
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawFileWrite.cc	(revision 2206)
+++ /trunk/MagicSoft/Mars/mraw/MRawFileWrite.cc	(revision 2207)
@@ -109,5 +109,5 @@
 // are created.
 //
-Bool_t MRawFileWrite::PreProcess (MParList *pList)
+Int_t MRawFileWrite::PreProcess (MParList *pList)
 {
     //
@@ -231,5 +231,5 @@
 // event should be filled in and fills  it into this tree.
 //
-Bool_t MRawFileWrite::Process()
+Int_t MRawFileWrite::Process()
 {
     //
Index: /trunk/MagicSoft/Mars/mraw/MRawFileWrite.h
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawFileWrite.h	(revision 2206)
+++ /trunk/MagicSoft/Mars/mraw/MRawFileWrite.h	(revision 2207)
@@ -41,6 +41,6 @@
     ~MRawFileWrite();
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
 
     ClassDef(MRawFileWrite, 0)	// Task to write the raw data containers to a root file
Index: /trunk/MagicSoft/Mars/mraw/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mraw/Makefile	(revision 2206)
+++ /trunk/MagicSoft/Mars/mraw/Makefile	(revision 2207)
@@ -22,5 +22,5 @@
 #  connect the include files defined in the config.mk file
 #
-INCLUDES = -I. -I../mbase -I../MBase -I../mgui
+INCLUDES = -I. -I../mbase -I../mgui -I../mgeom -I../MBase
 
 #------------------------------------------------------------------------------
