Index: trunk/MagicSoft/Mars/manalysis/MSourcePosfromStarPos.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MSourcePosfromStarPos.cc	(revision 3274)
+++ trunk/MagicSoft/Mars/manalysis/MSourcePosfromStarPos.cc	(revision 3296)
@@ -79,5 +79,5 @@
     fRuns  = 0;
     fSize  = 100;
-    fStars = 1;
+    fStars = 0;
 
     fRunNr.Set(fSize);
@@ -88,10 +88,11 @@
     fdPhiTel.Set(fSize);
 
-    fDecStar.Set(fStars);
-    fRaStar.Set(fStars);
-    fxStar.ResizeTo(fStars,fSize);
-    fyStar.ResizeTo(fStars,fSize);
-    fdxStar.ResizeTo(fStars,fSize);
-    fdyStar.ResizeTo(fStars,fSize);
+    fDecStar.Set(1);
+    fRaStar.Set(1);
+    fxStar.ResizeTo(1,fSize);
+    fyStar.ResizeTo(1,fSize);
+    fdxStar.ResizeTo(1,fSize);
+    fdyStar.ResizeTo(1,fSize);
+
 }
 
@@ -137,4 +138,5 @@
                * 360.0 / (24.0 * kRad2Deg);
 
+  fStars += 1;
   fDecStar.Set(fStars);
   fDecStar[fStars-1] = (decStarDeg + decStarMin/60.0 + decStarSec/3600.0)
@@ -167,5 +169,5 @@
 
   // convert into radians
-  Int_t fStars = fDecStar.GetSize() + 1;
+  fStars = fDecStar.GetSize() + 1;
   fDecStar.Set(fStars);
   fDecStar[fStars-1] = (decStarDeg + decStarMin/60.0 + decStarSec/3600.0)
@@ -223,4 +225,5 @@
     //
 
+    *fLog << all << "---------------------------------" << endl;
     while(1)
     {
@@ -249,4 +252,12 @@
     *fLog << "all data were read" << endl;
     FixSize();
+
+    if (fDecSource == 0.0  ||  fRaSource == 0.0  ||  fStars == 0) 
+    {
+      *fLog << err << "MSourcePosfromStarPos::PreProcess; there are no sky coordinates defined for the source or from stars" 
+            << endl;
+    }
+    *fLog << all << "---------------------------------" << endl;
+
     //-------------------------------------------------------------
 
@@ -287,4 +298,5 @@
 		    Double_t &dxSource,    Double_t &dySource)
 {
+  /*
   *fLog << "MSourcePosfromStarPos::SourcefromStar :  printout in degrees" << endl;
   *fLog << "       decStar, raStar = " << decStar[0]*kRad2Deg << ",  " 
@@ -306,5 +318,5 @@
   *fLog << "       xStar, yStar = " << xStar[0] << ",  " 
         << yStar[0] << endl;
-
+  */
 
   // the units are assumed to be radians for theta, phi, dec and ra
@@ -324,15 +336,16 @@
   Double_t sinal =    a1 * sin(phiTel) * denom;
 
-  *fLog << "thetaTel, phiTel, cosal, sinal = " << thetaTel << ",  "
-        << phiTel << ",  " << cosal << ",  " << sinal << endl;
+  //*fLog << "thetaTel, phiTel, cosal, sinal = " << thetaTel << ",  "
+  //      << phiTel << ",  " << cosal << ",  " << sinal << endl;
 
 
   // calculate coordinates of source in system B (see TDAS 00-11, eqs. (2))
-  Double_t xB0 =  cos(decSource) * cos(raSource);
-  Double_t yB0 =  cos(decSource) * sin(raSource);
+  // note that right ascension and hour angle go into opposite directions
+  Double_t xB0 =  cos(decSource) * cos(-raSource);
+  Double_t yB0 =  cos(decSource) * sin(-raSource);
   Double_t zB0 = -sin(decSource);
 
-  *fLog << "xB0, yB0, zB0 = " << xB0 << ",  " << yB0 << ",  "
-        << zB0 << endl;
+  //*fLog << "xB0, yB0, zB0 = " << xB0 << ",  " << yB0 << ",  "
+  //      << zB0 << endl;
 
   //-----------------------------------------------------
@@ -351,14 +364,15 @@
     sumwy += weighty;
 
-  *fLog << "weightx, weighty = " << weightx << ",  " << weighty << endl;
+    //*fLog << "weightx, weighty = " << weightx << ",  " << weighty << endl;
 
     // calculate coordinates of star in system B (see TDAS 00-11, eqs. (2))
-    Double_t xB  =  cos(decStar[i]) * cos(raStar[i]);
-    Double_t yB  =  cos(decStar[i]) * sin(raStar[i]);
+    // note that right ascension and hour angle go into opposite directions
+    Double_t xB  =  cos(decStar[i]) * cos(-raStar[i]);
+    Double_t yB  =  cos(decStar[i]) * sin(-raStar[i]);
     Double_t zB  = -sin(decStar[i]);
 
 
-  *fLog << "xB, yB, zB = " << xB << ",  " << yB << ",  "
-        << zB << endl;
+    //*fLog << "xB, yB, zB = " << xB << ",  " << yB << ",  "
+    //    << zB << endl;
 
  
@@ -375,6 +389,6 @@
     Double_t z = -(xB*xB0 + yB*yB0 + zB*zB0);
 
-  *fLog << "x, y, z = " << x << ",  " << y << ",  "
-        << z << endl;
+    //*fLog << "x, y, z = " << x << ",  " << y << ",  "
+    //    << z << endl;
 
 
@@ -383,5 +397,5 @@
     Double_t ytilde = -f/z * (sinal*x + cosal*y);
 
-  *fLog << "xtilde, ytile = " << xtilde << ",  " << ytilde << endl;
+    //*fLog << "xtilde, ytile = " << xtilde << ",  " << ytilde << endl;
 
 
@@ -399,7 +413,11 @@
   dySource = 1.0 / sqrt(sumwy);
     
-  *fLog << all << "MSourcePosfromStarPos::SourcefromStar; xSource, ySource = "
+  /*
+  Int_t run = fRun->GetRunNumber();
+  *fLog << all << "MSourcePosfromStarPos::SourcefromStar; run, xSource, ySource = "
+        << run << " : "
         << xSource << " +- " << dxSource << ",   " 
         << ySource << " +- " << dySource << endl; 
+   */
 }
 
@@ -411,14 +429,7 @@
 Bool_t MSourcePosfromStarPos::ReInit(MParList *pList)
 {
-  //if (fDecSource == 0.0  ||  fRaSource == 0.0  ||  fStars == 0) 
-  //{
-  //  *fLog << err << "MSourcePosfromStarPos::ReInit; sky coordinates of star and source are not defined ... aborting" 
-  //        << endl;
-    //return kFALSE;
-  //}
 
   Int_t run = fRun->GetRunNumber();
-
-  *fLog << "MSourcePosfromStarPos::ReInit; run = " << run << endl;
+  *fLog << all << "MSourcePosfromStarPos::ReInit; run = " << run << endl;
 
   //-------------------------------------------------------------------
@@ -437,5 +448,5 @@
       fMcEvt->SetReadyToSave();
 
-      *fLog << "theta, phi = " << thetarad*kRad2Deg << ",  "
+      *fLog << all << "theta, phi = " << thetarad*kRad2Deg << ",  "
             << phirad*kRad2Deg << endl;
        
@@ -443,5 +454,5 @@
       // Get source position and put it into MSrcPosCam
 
-      /*
+      
       if (fStars > 0)
       {
@@ -469,10 +480,10 @@
 
         *fLog << all << "MSourcePosfromStarPos::ReInit; fRunNr, fxSource, fySource = "
-              << fRunNr[i] << ",  " << fxSource << ",  " << fySource 
-              << endl;
+              << fRunNr[i] << ",  " << fxSource << " +- " << fdxSource 
+              << ",  " << fySource  << " +- "  << fdySource << endl;
        
         fSrcPos->SetReadyToSave();       
       }
-      */
+      
 
       return kTRUE;
@@ -483,5 +494,5 @@
           << run << endl;
 
-    Double_t thetadeg = 90.0;
+    Double_t thetadeg = 25.0;
     Double_t thetarad = thetadeg / kRad2Deg;
     fMcEvt->SetTelescopeTheta(thetarad);
@@ -500,6 +511,5 @@
 Int_t MSourcePosfromStarPos::Process()
 {
-  Int_t run = fRun->GetRunNumber();
-
+  //Int_t run = fRun->GetRunNumber();
   //*fLog << "MSourcePosfromStarPos::Process; run = " << run << endl;
     
@@ -524,5 +534,5 @@
 {
   *fLog << "MSourcePosfromStarPos::FixSize; fix size of arrays : fRuns = "
-        << fRuns << endl;
+        << fRuns << ",  fStars = " << fStars << endl;
 
     fSize = fRuns;
@@ -535,9 +545,9 @@
     fdPhiTel.Set(fSize);
 
-    fStars = fxStar.GetNrows();
-    fxStar.ResizeTo(fStars, fSize);
-    fyStar.ResizeTo(fStars, fSize);
-    fdxStar.ResizeTo(fStars, fSize);
-    fdyStar.ResizeTo(fStars, fSize);
+    Int_t fRows = fxStar.GetNrows();
+    fxStar.ResizeTo(fRows, fSize);
+    fyStar.ResizeTo(fRows, fSize);
+    fdxStar.ResizeTo(fRows, fSize);
+    fdyStar.ResizeTo(fRows, fSize);
 }
 
@@ -593,10 +603,10 @@
   *fIn >> ival;
   
-  *fLog << fRuns <<"th run : " << ival << endl;  
+  //*fLog << fRuns <<"th run : " << ival << endl;  
 
   fRunNr.AddAt(ival, fRuns-1);
 
-  *fLog << "check : fRuns, fRunNr[fRuns-1], fRunNr[fRuns] = " << fRuns << ",  "
-        << fRunNr[fRuns-1] << ",  " << fRunNr[fRuns] << endl;
+  //*fLog << "check : fRuns, fRunNr[fRuns-1], fRunNr[fRuns] = " << fRuns << ",  "
+  //      << fRunNr[fRuns-1] << ",  " << fRunNr[fRuns] << endl;
 
   // read mjdS, hmsS, mjdE, hmsE
@@ -614,12 +624,12 @@
   *fIn >> val;
   fThetaTel.AddAt(val/kRad2Deg, fRuns-1);
-  *fLog << "val, fThetaTel[fRuns-1] = " << val << ",  "
-        << fThetaTel[fRuns-1] << endl;
+  //*fLog << "val, fThetaTel[fRuns-1] = " << val << ",  "
+  //    << fThetaTel[fRuns-1] << endl;
 
 
   *fIn >> val;
   fPhiTel.AddAt(val/kRad2Deg, fRuns-1);
-  *fLog << "val, fPhiTel[fRuns-1] = " << val << ",  "
-        << fPhiTel[fRuns-1] << endl;
+  //*fLog << "val, fPhiTel[fRuns-1] = " << val << ",  "
+  //      << fPhiTel[fRuns-1] << endl;
 
 
@@ -635,11 +645,11 @@
     *fIn >> val;
     fxStar(i, fRuns-1) = val / fMm2Deg;;
-    *fLog << "val, fxStar(i, fRuns-1) = " << val << ",  "
-          << fxStar(i, fRuns-1) << endl;
+    //*fLog << "val, fxStar(i, fRuns-1) = " << val << ",  "
+    //      << fxStar(i, fRuns-1) << endl;
 
     *fIn >> val;
     fyStar(i, fRuns-1) = val / fMm2Deg;
-    *fLog << "val, fyStar(i, fRuns-1) = " << val << ",  "
-          << fyStar(i, fRuns-1) << endl;
+    //*fLog << "val, fyStar(i, fRuns-1) = " << val << ",  "
+    //      << fyStar(i, fRuns-1) << endl;
 
 
@@ -701,4 +711,5 @@
 
     const Bool_t noexist = !(*fIn);
+
 
     if (noexist)
