Index: /trunk/MagicSoft/Mars/macros/pointspreadfunction.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/pointspreadfunction.C	(revision 3112)
+++ /trunk/MagicSoft/Mars/macros/pointspreadfunction.C	(revision 3113)
@@ -37,9 +37,12 @@
 //     (It's possible not to use the calibration file and then the gain     //
 //      of the pmts are supouse to be the same for all of them.             //
+//  3- The third argument is just the number of dc measurements you want    //
+//     analize. If you put 0 it just stops after each fit and show you      //
+//     results.                                                             //
 //                                                                          //
 //--------------------------------------------------------------------------// 
 
 const Int_t numPixels = 577;
-Int_t nPixelsFitted; // 396[inners] 36[3rings] 60[4rings] 90[5rings]
+Int_t nPixelsFitted; 
 Bool_t isPixelsFitted[numPixels];
 Float_t z[numPixels],x[numPixels],y[numPixels],errorz[numPixels];
@@ -47,4 +50,7 @@
 
 //______________________________________________________________________________
+//
+// Function use for Minuit to do the fit
+//
 void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
 {
@@ -73,4 +79,7 @@
 
 //______________________________________________________________________________
+//
+// The 2D gaussian fucntion use to fit the spot of the star
+//
 Double_t func(float x,float y,Double_t *par)
 {
@@ -102,8 +111,7 @@
 }
 
+
 void pointspreadfunction(TString fname, TString clname = "NULL", Int_t userNumLines = 1000)
 {
-
-// First run over continuos light files to have a DC calibration
 
 
@@ -131,4 +139,9 @@
     if (clname != "NULL")
     {
+
+	//
+	// First run over continuos light files to have a DC calibration
+	//
+
 	MParList plist0;
 	
@@ -179,13 +192,12 @@
 	    currrms[swpix] /= meanofcurrmean;	
 	    
-// 	cout << "swpixel " << swpix << " dc fCalib " << currmean[swpix] << " +- " << currrms[swpix] << endl;
 	}
 	
 	
-	//    curr.Print();
 /*     MHCamera display0(geomcam);
        display0.SetPrettyPalette();
        display0.Draw();
        
+	//    curr.Print();
        display0.SetCamContent(currbis);
        cout << "PSF>> DC mean values drawn" << endl;
@@ -198,14 +210,17 @@
     else
     {
+	// If you don't use the continuous light this is the currrms[] array 
+	// is the error associated to the currents TMinuit will use.
 	for (Int_t swpix=0; swpix<numPixels; swpix++)
 	{
 	    currmean[swpix] = 1.;
-	    currrms[swpix] = 0.2;
+	    currrms[swpix] = 0.2; 
 	}
 	
     }
 
-// Now we can run over the dc data to extract the psf rms. 
-	
+//
+// Now we can run over the dc data to extract the psf. 
+//	
     const Int_t maxNumLines = 10000;
 	
@@ -241,5 +256,4 @@
     MHCamera display(geomcam);
     display.SetPrettyPalette();
-//    display.SetInvDeepBlueSeaPalette()
     display.Draw();
     gPad->SetLogy();
@@ -252,7 +266,4 @@
     Double_t xmean,xsigma,ymean,ysigma;
     Double_t xmeanerror,xsigmaerror,ymeanerror,ysigmaerror;
-
-//    TVector xellipsecenter;
-//    TVector yellipsecenter;
 
     TEllipse ellipse;
@@ -274,4 +285,10 @@
 
     TCanvas *psfcanvas = new TCanvas("psfcanvas","Point Spread Funtion 2D",200,20,900,700);
+
+
+    //
+    // Using the first dc meausrement we search the star and we define the area to be fitted
+    // around 3 rings of neightbords around the peak of the star.
+    // 
 
     tlist.Process();
@@ -362,4 +379,7 @@
 	break;
 */
+
+    // Minuit initialization
+
     TMinuit *gMinuit = new TMinuit(7);  //initialize TMinuit with a maximum of 5 params
     gMinuit->SetFCN(fcn);
@@ -402,6 +422,4 @@
     gMinuit->mnparm(3, "ymean", vstart[3], step[3], lowlimit[3], uplimit[3],ierflg);
     gMinuit->mnparm(4, "ysigma", vstart[4], step[4], lowlimit[4], uplimit[4],ierflg);
-
-    numLines++;
 
     while (tlist.Process() && numLines < maxNumLines)
@@ -479,5 +497,4 @@
 	}
 */
-	    numLines++;
 	    // Remove the comments if you want to go through the file
 	    //event-by-event:
@@ -492,4 +509,5 @@
 		    break;
 	    }
+	    numLines++;
 	}
     }
@@ -498,7 +516,9 @@
     evtloop.PostProcess();
 
-//Draw the ditributions of the sigmas the point spread function
-
-    cout<<"Number of lines "<<numLines<<endl;
+    //
+    // Draw the ditributions of the sigmas the point spread function
+    //
+
+    cout<<"PSF>> Number of lines "<<numLines<<endl;
 
     gROOT->Reset();
