Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 7559)
+++ trunk/MagicSoft/Mars/Changelog	(revision 7560)
@@ -18,4 +18,25 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2006/03/02 Thomas Bretz
+
+   * callisto.cc:
+     - get result value from pulse pos check
+
+   * mjobs/MJCut.[h,cc]:
+     - added the usage of the new class MSrcPosRndm
+     - added new resource to switch random source position on
+
+   * mjobs/MJPedestal.[h,cc]:
+     - changed return code of Process to int to be able to return
+       the pulse pos check result.
+
+   * mpointing/PointingLinkDef.h, mpointing/Makefile:
+     - added MSrcPosRndm
+
+   * mpointing/MSrcPosRndm.[h,cc]:
+     - added
+
+
+
  2006/03/02 Daniela Dorner
 
Index: trunk/MagicSoft/Mars/callisto.cc
===================================================================
--- trunk/MagicSoft/Mars/callisto.cc	(revision 7559)
+++ trunk/MagicSoft/Mars/callisto.cc	(revision 7560)
@@ -541,6 +541,12 @@
         // Please check the Changelog of 2005/04/20 about further deatils of the next comment
         //if (job1.GetExtractor().InheritsFrom("MExtractTimeAndCharge"))
-        if (!job2.Process())
-        {
+        const Int_t rc = job2.Process();
+        if (rc<=0)
+        {
+            // rc==0:  Error
+            // rc==-1: too much to the left
+            // rc==-2: too much to the right
+            // rc==-3: too much to the right (beyond limits)
+
             gLog << err << "Calculation of pedestal from extrtactor (random) failed." << endl << endl;
             return 2;
Index: trunk/MagicSoft/Mars/mjobs/MJCut.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 7559)
+++ trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 7560)
@@ -55,4 +55,5 @@
 #include "MTaskEnv.h"
 #include "MPointingDevCalc.h"
+#include "MSrcPosRndm.h"
 #include "MSrcPosCalc.h"
 #include "MSrcPosCorrect.h"
@@ -72,4 +73,5 @@
 #include "MPointingPos.h"
 #include "MObservatory.h"
+#include "MHSrcPosCam.h"
 
 ClassImp(MJCut);
@@ -427,5 +429,5 @@
 }
 
-Bool_t MJCut::FillSrcPosCam(const MDataSet &set, MPointingPos &source)
+Bool_t MJCut::FillSrcPosCam(const MDataSet &set, MPointingPos &source, MHSrcPosCam &hsrcpos)
 {
     *fLog << inf;
@@ -467,10 +469,10 @@
     set.AddFilesOn(read);
 
-    MFillH fill("MHSrcPosCam", "MSrcPosCam", "FillSrcPosCam");
+    MFillH fill(&hsrcpos, "MSrcPosCam", "FillSrcPosCam");
     fill.SetNameTab("SrcPos");
 
     // How to get source position from off- and on-data?
     MSrcPosCorrect scor;
-    MSrcPosCalc scalc;
+    MSrcPosCalc    scalc;
     scalc.SetMode(MSrcPosCalc::kDefault);
 
@@ -538,7 +540,13 @@
         *fLog << all << "No source position applied..." << endl;
 
+    MParList plist;
+
+    MHSrcPosCam hsrcpos;
     if (!fIsWobble && source.IsInitialized() && fRndmSrcPos)
-        if (!FillSrcPosCam(set, source))
+    {
+        if (!FillSrcPosCam(set, source, hsrcpos))
             return kFALSE;
+        plist.AddToList(&hsrcpos);
+    }
 
     // --------------------------------------------------------------------------------
@@ -552,5 +560,4 @@
 
     // Setup Parlist
-    MParList plist;
     plist.AddToList(this); // take care of fDisplay!
 
@@ -679,7 +686,10 @@
     hcalc2.SetNameSrcPosCam("MSrcPosAnti");
 
+    MSrcPosRndm srcrndm;
+
     MTaskList tlist2;
     tlist2.AddToList(&scalc);
     tlist2.AddToList(&scor);
+    tlist2.AddToList(&srcrndm);
     tlist2.AddToList(&hcalc);
     if (fIsWobble)
Index: trunk/MagicSoft/Mars/mjobs/MJCut.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCut.h	(revision 7559)
+++ trunk/MagicSoft/Mars/mjobs/MJCut.h	(revision 7560)
@@ -13,4 +13,5 @@
 class MWriteRootFile;
 class MPointingPos;
+class MHSrcPosCam;
 
 class MJCut : public MJob
@@ -48,5 +49,5 @@
     Bool_t   CanStoreResult() const  { return !fPathOut.IsNull() && fStoreResult;  }
 
-    Bool_t   FillSrcPosCam(const MDataSet &set, MPointingPos &source);
+    Bool_t   FillSrcPosCam(const MDataSet &set, MPointingPos &source, MHSrcPosCam &srcpos);
 
 public:
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 7559)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 7560)
@@ -843,5 +843,5 @@
 }
 
-Bool_t MJPedestal::PulsePosCheck(const MParList &plist) const
+Int_t MJPedestal::PulsePosCheck(const MParList &plist) const
 {
     if (fIsPixelCheck)
@@ -951,5 +951,5 @@
     {
         *fLog << err << "Pulse is too much to the left, cannot go below 0!" << endl;
-        return kFALSE;
+        return -1;
 
     }
@@ -959,5 +959,5 @@
         *fLog << numhigainsamples << "+" << numlogainsamples << "-1" << endl;
         *fLog << " Cannot extract at all!" << endl;
-        return kFALSE;
+        return -3;
     }
     if (newlast+wslogain > numlogainsamples)
@@ -970,5 +970,5 @@
         *fLog << "(ATTENTION, you will lose late cosmics pulses!)" << endl;
         *fLog << endl;
-        return kFALSE;
+        return -2;
     }
 
@@ -986,5 +986,5 @@
 }
 
-Bool_t MJPedestal::Process()
+Int_t MJPedestal::Process()
 {
     if (!fSequence.IsValid())
@@ -1271,6 +1271,7 @@
         return kFALSE;
 
-    if (!PulsePosCheck(plist))
-        return kFALSE;
+    const Int_t rc = PulsePosCheck(plist);
+    if (rc<1)
+        return rc;
 
     *fLog << all << GetDescriptor() << ": Done." << endl;
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 7559)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 7560)
@@ -104,5 +104,5 @@
     const Bool_t IsUseData() const { return fExtractType == kUseData; }
 
-    Bool_t Process();
+    Int_t Process();
 
     void SetBadPixels(const MBadPixelsCam &bad) { bad.Copy(fBadPixels); }
Index: trunk/MagicSoft/Mars/mpointing/MSrcPosRndm.cc
===================================================================
--- trunk/MagicSoft/Mars/mpointing/MSrcPosRndm.cc	(revision 7560)
+++ trunk/MagicSoft/Mars/mpointing/MSrcPosRndm.cc	(revision 7560)
@@ -0,0 +1,85 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 3/2006 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2006
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MSrcPosRndm
+//
+// Input Container:
+//   MHSrcPosCam
+//
+// Output Container:
+//   MSrcPosCam
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MSrcPosRndm.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MSrcPosCam.h"
+#include "MHSrcPosCam.h"
+
+ClassImp(MSrcPosRndm);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  Search for 'MPointingPos'. Create if not found.
+//
+Int_t MSrcPosRndm::PreProcess(MParList *plist)
+{
+    fSrcPos = (MSrcPosCam*)plist->FindCreateObj("MSrcPosCam");
+    if (!fSrcPos)
+        return kFALSE;
+
+    fHist = (MHSrcPosCam*)plist->FindObject("MHSrcPosCam");
+    if (!fHist)
+    {
+        *fLog << inf << "MHSrcPosCam not found... skipping." << endl;
+        return kSKIP;
+    }
+
+    *fLog << inf << "MHSrcPosCam found... taken to produce a random distribution." << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  See class description.
+//
+Int_t MSrcPosRndm::Process()
+{
+    Axis_t x, y;
+
+    fHist->GetHist().GetRandom2(x, y);
+
+    fSrcPos->SetXY(x, y);
+
+    return kTRUE;
+}
Index: trunk/MagicSoft/Mars/mpointing/MSrcPosRndm.h
===================================================================
--- trunk/MagicSoft/Mars/mpointing/MSrcPosRndm.h	(revision 7560)
+++ trunk/MagicSoft/Mars/mpointing/MSrcPosRndm.h	(revision 7560)
@@ -0,0 +1,30 @@
+#ifndef MARS_MSrcPosRndm
+#define MARS_MSrcPosRndm
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MSrcPosCam;
+class MHSrcPosCam;
+
+class MSrcPosRndm : public MTask
+{
+private:
+    MSrcPosCam   *fSrcPos; //!
+    MHSrcPosCam  *fHist;   //!
+
+    Int_t  PreProcess(MParList *plist);
+    Int_t  Process();
+
+public:
+    MSrcPosRndm() : fSrcPos(0), fHist(0)
+    {
+        fName  = "MSrcPosRndm";
+        fTitle = "Overwrite the source position with a random one from MHSrcPosCam";
+    }
+
+    ClassDef(MSrcPosRndm, 0) //Overwrite the source position with a random one from MHSrcPosCam
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mpointing/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mpointing/Makefile	(revision 7559)
+++ trunk/MagicSoft/Mars/mpointing/Makefile	(revision 7560)
@@ -32,4 +32,5 @@
            MSrcPosCam.cc \
            MSrcPosCalc.cc \
+           MSrcPosRndm.cc \
            MSrcPosCorrect.cc \
            MSrcPosFromModel.cc
Index: trunk/MagicSoft/Mars/mpointing/PointingLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mpointing/PointingLinkDef.h	(revision 7559)
+++ trunk/MagicSoft/Mars/mpointing/PointingLinkDef.h	(revision 7560)
@@ -19,4 +19,5 @@
 #pragma link C++ class MSrcPosCam+;
 #pragma link C++ class MSrcPosCalc+;
+#pragma link C++ class MSrcPosRndm+;
 #pragma link C++ class MSrcPosCorrect+;
 #pragma link C++ class MSrcPosFromModel+;
