Index: trunk/MagicSoft/Mars/manalysis/MGeomApply.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MGeomApply.cc	(revision 3659)
+++ trunk/MagicSoft/Mars/manalysis/MGeomApply.cc	(revision 3660)
@@ -127,5 +127,5 @@
     if (!cam)
     {
-        *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
+       *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
         return kFALSE;
     }
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 3659)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 3660)
@@ -1038,6 +1038,6 @@
 {
 
-  Float_t flux    = pindiode.GetMeanFluxOutsidePlexiglass();
-  Float_t fluxerr = pindiode.GetMeanFluxOutsidePlexiglassErr();
+  Float_t flux    = pindiode.GetFluxOutsidePlexiglass();
+  Float_t fluxerr = pindiode.GetFluxOutsidePlexiglassErr();
 
   TIter Next(fPixels);
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargePINDiode.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargePINDiode.cc	(revision 3659)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargePINDiode.cc	(revision 3660)
@@ -31,4 +31,21 @@
 // is the documentation for the moment.
 //
+// Currently, the following numbers are implemented:
+//
+// Area of Inner Pixel Ai: 779.423 +- 0  mm^2 
+// Area of PIN Diode   Ap: 100.000 +- 10 mm^2 
+//
+// Ratio of areas: 
+//
+// Distance of PIN Diode to pulser D1:   1.5  +- 0.3 m
+// Distance of Inner Pixel to pulser D2: 18.0 +- 0.5 m
+//
+//                         Ai*D1*D1
+// gkSolidAngleRatio   =   -------- = 0.054
+//                         Ap*D2*D2
+//
+// gkSolidAngleRatioErr = 0.01
+//
+// 
 /////////////////////////////////////////////////////////////////////////////
 #include "MCalibrationChargePINDiode.h"
@@ -44,22 +61,6 @@
 const Float_t MCalibrationChargePINDiode::fgChargeToPhotons    = -1.; 
 const Float_t MCalibrationChargePINDiode::fgChargeToPhotonsErr = -1.; 
-//
-// Area of Inner Pixel w.r.t. PIN Diode (which is 1 cm2)
-//
-// Distance of PIN Diode to pulser D1:   1.5  +- 0.3 m
-// Distance of Inner Pixel to pulser D2: 18.0 +- 0.5 m
-//
-//
-//                 D1*D1
-// conversion C = ------ = 0.0069
-//                 D2*D2
-//
-// Delta C / C  = 2 * Sqrt( (Delta D1/D1)2 + (Delta D2/D2)2 )
-// Delta C / C  = 0.4
-// 
-// C = 0.007 +- 0.003
-//
-const Float_t MCalibrationChargePINDiode::gkFluxCameravsPINDiode      = 0.007;
-const Float_t MCalibrationChargePINDiode::gkFluxCameravsPINDiodeErr   = 0.003;
+const Float_t MCalibrationChargePINDiode::gkSolidAngleRatio      = 0.055;
+const Float_t MCalibrationChargePINDiode::gkSolidAngleRatioErr   = 0.01;
 //
 // Average QE of the PIN Diode
@@ -120,20 +121,16 @@
   SetTimeFitValid       ( kFALSE );
     
-  fPed                          =  -1.;
-  fPedRms                       =  -1.;
-
-  fRmsChargeMean                =  -1.;
-  fRmsChargeMeanErr             =  -1.;
-  fRmsChargeSigma               =  -1.;  
-  fRmsChargeSigmaErr            =  -1.;
-
-  fAbsTimeMean                  =  -1.;
-  fAbsTimeRms                   =  -1.;
-
-  fConvPhotons                  =  -1.;
-  fConvPhotonsVar               =  -1.;
-
-  fMeanFluxOutsidePlexiglass    =  -1.;  
-  fMeanFluxOutsidePlexiglassVar =  -1.;
+  fAbsTimeMean              =  -1.;
+  fAbsTimeRms               =  -1.;
+  fFluxOutsidePlexiglass    =  -1.;  
+  fFluxOutsidePlexiglassVar =  -1.;
+  fNumPhotons               =  -1.;
+  fNumPhotonsVar            =  -1.;
+  fPed                      =  -1.;
+  fPedRms                   =  -1.;
+  fRmsChargeMean            =  -1.;
+  fRmsChargeMeanErr         =  -1.;
+  fRmsChargeSigma           =  -1.;  
+  fRmsChargeSigmaErr        =  -1.;
 
   MCalibrationPix::Clear();
@@ -193,13 +190,13 @@
 // --------------------------------------------------------------------------
 //
-// Return -1 if fMeanFluxOutsidePlexiglassVar is smaller than 0.
-// Return square root of fMeanFluxOutsidePlexiglassVar
+// Return -1 if fFluxOutsidePlexiglassVar is smaller than 0.
+// Return square root of fFluxOutsidePlexiglassVar
 // 
-Float_t MCalibrationChargePINDiode::GetMeanFluxOutsidePlexiglassErr() const
-{
-  if (fMeanFluxOutsidePlexiglassVar < 0.)
+Float_t MCalibrationChargePINDiode::GetFluxOutsidePlexiglassErr() const
+{
+  if (fFluxOutsidePlexiglassVar < 0.)
     return -1.;
   
-  return TMath::Sqrt(fMeanFluxOutsidePlexiglassVar);
+  return TMath::Sqrt(fFluxOutsidePlexiglassVar);
 }
 
@@ -227,8 +224,15 @@
 // Return kFALSE if IsChargeFitValid() is kFALSE
 //
-// Calculate fMeanFluxOutsidePlexiglass with the formula:
-// - fMeanFluxOutsidePlexiglass = fConvPhotons*gkPINDiodeArea*gkFluxCameravsPINDiode 
-//                              / gkPINDiodeQE (of the corr. colour) 
-// - fMeanFluxOutsidePlexiglass = fConvPhotons*gkPINDiodeArea*gkFluxCameravsPINDiode 
+// Calculate fFluxOutsidePlexiglass with the formula:
+// - fFluxOutsidePlexiglass    = fNumPhotons*gkSolidAngleRatio / gkPINDiodeQE (of the corr. colour) 
+// - fFluxOutsidePlexiglassVar = sqrt( fNumPhotonsVar / ( fNumPhotons * fNumPhotons ) 
+//                             + ( gkSolidAngleRatioErr * gkSolidAngleRatioErr / gkSolidAngleRatio / gkSolidAngleRatio )
+//                             + ( gkPINDiodeQEErr * gkPINDiodeQEErr / gkPINDiodeQE / gkPINDiodeQE )
+//                               ) * fFluxOutsidePlexiglass * * fFluxOutsidePlexiglass
+//
+// If the fFluxOutsidePlexiglass is smaller than 0., return kFALSE
+// If the Variance is smaller than 0., return kFALSE
+//
+// SetFluxOutsidePlexiglassAvailable() and return kTRUE
 //
 Bool_t MCalibrationChargePINDiode::CalcFluxOutsidePlexiglass()
@@ -238,37 +242,40 @@
     return kFALSE;
   
-  // Start calculation of number of photons per mm^2 on the camera
-  fMeanFluxOutsidePlexiglass  = fConvPhotons * gkPINDiodeArea;
+  //
+  // Start calculation of number of photons per mm^2 on an inner pixel:
   // Correct for the distance between camera and PIN Diode and for different areas.
-  fMeanFluxOutsidePlexiglass *= gkFluxCameravsPINDiode;
-
+  //
+  fFluxOutsidePlexiglass  = fNumPhotons * gkSolidAngleRatio;
+
+  //
   // Start calculation of number of photons relative Variance (!!)
-  fMeanFluxOutsidePlexiglassVar  = fConvPhotonsVar
-                                 / ( fConvPhotons * fConvPhotons  )  ;
-  fMeanFluxOutsidePlexiglassVar += gkFluxCameravsPINDiodeErr*gkFluxCameravsPINDiodeErr
-                                 / gkFluxCameravsPINDiode/gkFluxCameravsPINDiode;
-  
+  //
+  const Float_t numphotRelVar    = fNumPhotonsVar / ( fNumPhotons * fNumPhotons  )  ;
+  const Float_t solidangleRelVar = gkSolidAngleRatioErr* gkSolidAngleRatioErr
+                              / ( gkSolidAngleRatio    * gkSolidAngleRatio   );
+  Float_t fluxRelVar            = numphotRelVar + solidangleRelVar ;
+
   switch (fColor)
     {
     case kGREEN:
-      fMeanFluxOutsidePlexiglass    /= gkPINDiodeQEGreen;
-      fMeanFluxOutsidePlexiglassVar += gkPINDiodeQEGreenErr*gkPINDiodeQEGreenErr
-                                     / gkPINDiodeQEGreen/gkPINDiodeQEGreen;
+      fFluxOutsidePlexiglass /=  gkPINDiodeQEGreen;
+      fluxRelVar             +=  gkPINDiodeQEGreenErr* gkPINDiodeQEGreenErr
+                             / ( gkPINDiodeQEGreen   * gkPINDiodeQEGreen    );
       break;
     case kBLUE:
-      fMeanFluxOutsidePlexiglass    /= gkPINDiodeQEBlue;
-      fMeanFluxOutsidePlexiglassVar += gkPINDiodeQEBlueErr*gkPINDiodeQEBlueErr
-                                     / gkPINDiodeQEBlue/gkPINDiodeQEBlue;
+      fFluxOutsidePlexiglass /=  gkPINDiodeQEBlue;
+      fluxRelVar             +=  gkPINDiodeQEBlueErr* gkPINDiodeQEBlueErr
+                             / ( gkPINDiodeQEBlue   * gkPINDiodeQEBlue   );
       break; 
     case kUV:
-      fMeanFluxOutsidePlexiglass    /= gkPINDiodeQEUV;
-      fMeanFluxOutsidePlexiglassVar += gkPINDiodeQEUVErr*gkPINDiodeQEUVErr
-                                     / gkPINDiodeQEUV/gkPINDiodeQEUV;
+      fFluxOutsidePlexiglass /=  gkPINDiodeQEUV;
+      fluxRelVar             +=  gkPINDiodeQEUVErr* gkPINDiodeQEUVErr
+                             / ( gkPINDiodeQEUV   * gkPINDiodeQEUV    );
       break;
     case kCT1:
     default:
-      fMeanFluxOutsidePlexiglass    /= gkPINDiodeQECT1;
-      fMeanFluxOutsidePlexiglassVar += gkPINDiodeQECT1Err*gkPINDiodeQECT1Err
-                                     / gkPINDiodeQECT1/gkPINDiodeQECT1;
+      fFluxOutsidePlexiglass /=  gkPINDiodeQECT1;
+      fluxRelVar             +=  gkPINDiodeQECT1Err* gkPINDiodeQECT1Err
+                             / ( gkPINDiodeQECT1   * gkPINDiodeQECT1    );
       break;
     }
@@ -277,10 +284,10 @@
   *fLog << inf << endl;
   *fLog << inf << " Mean Photon flux [ph/mm^2] outside Plexiglass: " 
-        << fMeanFluxOutsidePlexiglass << endl;
-
-  if (fMeanFluxOutsidePlexiglass < 0.)
+        << fFluxOutsidePlexiglass << endl;
+
+  if (fFluxOutsidePlexiglass < 0.)
       return kFALSE;
 
-  if (fMeanFluxOutsidePlexiglassVar < 0.)
+  if (fluxRelVar < 0.)
       return kFALSE;
 
@@ -290,8 +297,8 @@
   // Finish calculation of errors -> convert from relative variance to absolute variance
   //
-  fMeanFluxOutsidePlexiglassVar *= fMeanFluxOutsidePlexiglass*fMeanFluxOutsidePlexiglass;
+  fFluxOutsidePlexiglassVar *= fluxRelVar * fFluxOutsidePlexiglass * fFluxOutsidePlexiglass;
 
   *fLog << inf << " Error on Photon flux [ph/mm^2] outside Plexiglass: " 
-        << GetMeanFluxOutsidePlexiglassErr() << endl;
+        << GetFluxOutsidePlexiglassErr() << endl;
   *fLog << inf << endl;
 
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargePINDiode.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargePINDiode.h	(revision 3659)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargePINDiode.h	(revision 3660)
@@ -13,6 +13,4 @@
   static const Float_t fgChargeToPhotonsErr;      //! Default for fChargeToPhotonsVar
   static const Float_t gkPINDiodeArea;            //! PIN Diode Effective Area in mm^2  
-  static const Float_t gkFluxCameravsPINDiode;    //! Flux Conversion PIN Diode - inner pixel
-  static const Float_t gkFluxCameravsPINDiodeErr; //! Error of flux conv. PIN Diode - inner pixel
   static const Float_t gkPINDiodeQEGreen;         //! Quantum Efficiency at 520 nm
   static const Float_t gkPINDiodeQEBlue;          //! Quantum Efficiency at 460 nm
@@ -20,8 +18,9 @@
   static const Float_t gkPINDiodeQECT1;           //! Quantum Efficiency at 370 nm
   static const Float_t gkPINDiodeQEGreenErr;      //! Uncertainty QE at 520 nm
-  static const Float_t gkPINDiodeQEBlueErr ;      //! Uncertainty QE at 460 nm
-  static const Float_t gkPINDiodeQEUVErr   ;      //! Uncertainty QE at 370 nm
-  static const Float_t gkPINDiodeQECT1Err  ;      //! Uncertainty QE at 370 nmu
- 
+  static const Float_t gkPINDiodeQEBlueErr;       //! Uncertainty QE at 460 nm
+  static const Float_t gkPINDiodeQEUVErr;         //! Uncertainty QE at 370 nm
+  static const Float_t gkPINDiodeQECT1Err;        //! Uncertainty QE at 370 nmu
+  static const Float_t gkSolidAngleRatio;         //! Solid angles ratio PIN Diode - inner pixel
+  static const Float_t gkSolidAngleRatioErr;      //! Error solid angle ratio PIN Diode - inn. pix.
 
   Float_t fAbsTimeMean;                   // Mean Absolute Arrival Time
@@ -33,8 +32,8 @@
   Float_t fChargeToPhotons;               // Mean conv. PIN Diode charge to number of incident photons
   Float_t fChargeToPhotonsVar;            // Variance of mean conv. PIN Diode charge to nr. incident photons
-  Float_t fConvPhotons;                   // Number photons incidident on PIN Diode
-  Float_t fConvPhotonsVar;                // Error on nr. photons incid. on PIN Diode
-  Float_t fMeanFluxOutsidePlexiglass;     // Mean number photons in INNER PIXEL outside plexiglass
-  Float_t fMeanFluxOutsidePlexiglassVar;  // Error on nr. photons in INNER PIXEL outside plexiglass
+  Float_t fNumPhotons;                    // Number photons incidident on PIN Diode
+  Float_t fNumPhotonsVar;                 // Variance nr. photons incid. on PIN Diode
+  Float_t fFluxOutsidePlexiglass;         // Mean number photons in INNER PIXEL outside plexiglass
+  Float_t fFluxOutsidePlexiglassVar;      // Error on nr. photons in INNER PIXEL outside plexiglass
   Float_t fPed;                           // Mean pedestal (from MPedestalPix)
   Float_t fPedRms;                        // Pedestal  RMS (from MPedestalPix)
@@ -73,6 +72,6 @@
 
   // Getters
-  Float_t GetMeanFluxOutsidePlexiglass()    const { return fMeanFluxOutsidePlexiglass; }
-  Float_t GetMeanFluxOutsidePlexiglassErr() const;
+  Float_t GetFluxOutsidePlexiglass()    const { return fFluxOutsidePlexiglass; }
+  Float_t GetFluxOutsidePlexiglassErr() const;
 
   // Pedestals
