Index: branches/MarsWobble/msim/MSimPointingPos.cc
===================================================================
--- branches/MarsWobble/msim/MSimPointingPos.cc	(revision 18162)
+++ branches/MarsWobble/msim/MSimPointingPos.cc	(revision 18163)
@@ -39,5 +39,5 @@
 //
 // If no view cone option was given and off-target observations are switched
-// on by setting fOffTargetDistance!=0 the poitnting position is calculated:
+// on by setting fOffTargetDistance!=0 the pointing position is calculated:
 //
 //  1) fOffTargetDistance < 0:
@@ -51,4 +51,18 @@
 //     fOffTargetDistance. (phi==0 is the direction of positive theta)
 //
+// The original zenith and azimuth coordinates of the shower axis are stored in
+// the MSimSourcePos container.
+//
+// If the view cone option was given and off-target observations are switched on
+// the orientation is fixed to the main direction around the view cone was
+// produced.
+// In addition a 'quasi'-simulated source position is calculated,
+// depending on fOffTargetDistance and fOffTargetPhi (see 1) and 2) above).
+// The corresponding zenith and azimuth coordinates are stored in the
+// MSimSourcePos container. This is of course not a physical source position,
+// but it can be used to determine the performance of wobble analysis on
+// background events (which are homogenous distributed).
+//
+//
 //
 //  Input Containers:
@@ -58,4 +72,5 @@
 //  Output Containers:
 //   MPointingPos
+//   MSimSourcePos
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -84,5 +99,5 @@
 //
 MSimPointingPos::MSimPointingPos(const char* name, const char *title)
-    : fRunHeader(0), fEvtHeader(0), fPointing(0),
+    : fRunHeader(0), fEvtHeader(0), fPointing(0), fSimSourcePosition(0),
     fOffTargetDistance(0), fOffTargetPhi(-1)
 
@@ -139,4 +154,8 @@
 {
     fPointing = (MPointingPos*)pList->FindCreateObj("MPointingPos");
+    if (!fPointing)
+        return kFALSE;
+
+    fSimSourcePosition = (MPointingPos*)pList->FindCreateObj("MPointingPos","MSimSourcePos");
     if (!fPointing)
         return kFALSE;
@@ -180,6 +199,6 @@
     {
         *fLog << warn;
-        *fLog << "WARNING - Combining the view cone option with off-target observations doesn't make sense." << endl;
-        *fLog << "          Option for off-target observations will be ignored." << endl;
+        *fLog << "WARNING - Combining the view cone option with off-target pointing can lead to not homogenous events." << endl;
+        *fLog << "          A simulated source position according to the off-target parameters will be created instead." << endl;
     }
     // FIXME: Check also the enlightened region on the ground!
@@ -209,35 +228,41 @@
 
     // Local sky coordinates (direction of telescope axis)
-    Double_t zd = viewcone ? fRunHeader->GetZdMin() : fEvtHeader->GetZd()*TMath::RadToDeg();  // x==north
-    Double_t az = viewcone ? fRunHeader->GetAzMin() : fEvtHeader->GetAz()*TMath::RadToDeg();  // y==west
-
-    if (!viewcone)
-    {
-        Double_t dtheta, dphi;
-        GetDelta(dtheta, dphi);
-
-        const Double_t theta = zd*TMath::DegToRad();
-        const Double_t phi   = az*TMath::DegToRad();
-
-        TVector3 src, pnt;
-        src.SetMagThetaPhi(1, theta,        phi);
-        pnt.SetMagThetaPhi(1, theta+dtheta, phi);
-
-        pnt.Rotate(dphi, src);
-
-        zd = pnt.Theta()*TMath::RadToDeg();
-        az = pnt.Phi()  *TMath::RadToDeg();
-    }
+    Double_t zdCorsika = viewcone ? fRunHeader->GetZdMin() : fEvtHeader->GetZd()*TMath::RadToDeg();  // x==north
+    Double_t azCorsika = viewcone ? fRunHeader->GetAzMin() : fEvtHeader->GetAz()*TMath::RadToDeg();  // y==west
+
+    // Calculate off target position in local sky coordinates
+    Double_t dtheta, dphi;
+    GetDelta(dtheta, dphi);
+
+    const Double_t theta = zdCorsika*TMath::DegToRad();
+    const Double_t phi   = azCorsika*TMath::DegToRad();
+
+    TVector3 originalVector, wobbleVector;
+    originalVector.SetMagThetaPhi(1, theta,        phi);
+    wobbleVector.SetMagThetaPhi(1, theta+dtheta, phi);
+
+    wobbleVector.Rotate(dphi, originalVector);
+
+    Double_t zdWobble, azWobble;
+    zdWobble = wobbleVector.Theta()*TMath::RadToDeg();
+    azWobble = wobbleVector.Phi()  *TMath::RadToDeg();
 
     // Transform the corsika coordinate system (north is magnetic north)
     // into the telescopes local coordinate system. Note, that all vectors
     // are already correctly oriented.
-    az += fRunHeader->GetMagneticFieldAz()*TMath::RadToDeg();
-
-    // Setup the pointing position
-    fPointing->SetLocalPosition(zd, az);
-
-    // Calculate incident angle between magnetic field direction
-    // and pointing direction ( phi and theta? )
+    azCorsika += fRunHeader->GetMagneticFieldAz()*TMath::RadToDeg();
+    azWobble += fRunHeader->GetMagneticFieldAz()*TMath::RadToDeg();
+
+    // Setup the pointing and the simulated source position
+    if (!viewcone)
+    {
+        fPointing->SetLocalPosition(zdWobble, azWobble);
+        fSimSourcePosition->SetLocalPosition(zdCorsika, azCorsika);
+    }
+    else
+    {
+        fPointing->SetLocalPosition(zdCorsika, azCorsika);
+        fSimSourcePosition->SetLocalPosition(zdWobble, azWobble);
+    }
 
     return kTRUE;
