Index: trunk/MagicSoft/Mars/msimcamera/MSimRandomPhotons.cc
===================================================================
--- trunk/MagicSoft/Mars/msimcamera/MSimRandomPhotons.cc	(revision 9518)
+++ trunk/MagicSoft/Mars/msimcamera/MSimRandomPhotons.cc	(revision 9521)
@@ -34,4 +34,40 @@
 // FIXME: We should add the wavelength distribution.
 //
+// The artificial night sky background rate is calculated as follows:
+//
+//  * The photon detection efficiency vs. wavelength of the detector is obtained
+//    from "PhotonDetectionEfficiency" of type "MParSpline"
+//
+//  * The angular acceptance of the light collectors is obtained
+//    from "ConesAngularAcceptance" of type "MParSpline"
+//
+//  * The spectral acceptance of the light collectors is obtained
+//    from "ConesTransmission" of type "MParSpline"
+//
+//  * The reflectivity of the mirrors vs wavelength is obtained
+//    from "MirrorReflectivity" of type "MParSpline"
+//
+// The rate is then calculated as
+//
+//   R = R0 * Ai * f
+//
+// R0 is the night sky background rate as given in Eckart's paper. Ai the
+// area of the cones acceptance window, f is given as:
+//
+//   f = nm * Min(Ar, sr*d^2)
+//
+// with
+//
+//   nm being the integral of the product of the mirror reflectivity, the cone
+//   transmission and the photon detection efficiency.
+//
+//   d the distance of the focal plane to the mirror
+//
+//   Ar is the total reflective area of the reflector
+//
+//   sr is the effective solid angle corresponding to the integral of the
+//   cones angular acceptance
+//
+//
 //  Input Containers:
 //   fNameGeomCam [MGeomCam]
@@ -151,12 +187,15 @@
     }
 
+    *fLog << warn << "FIXME: A check is needed that the PDE is 0 at both ends!" << endl;
+
     const MParSpline *s1 = (MParSpline*)pList->FindObject("PhotonDetectionEfficiency", "MParSpline");
     const MParSpline *s2 = (MParSpline*)pList->FindObject("ConesAngularAcceptance",    "MParSpline");
     const MParSpline *s3 = (MParSpline*)pList->FindObject("MirrorReflectivity",        "MParSpline");
+    const MParSpline *s5 = (MParSpline*)pList->FindObject("ConesTransmission",         "MParSpline");
 
     const Double_t d2  = fGeom->GetCameraDist()*fGeom->GetCameraDist();
-    const Double_t pde = s1 && s1->GetSpline() ? s1->GetSpline()->Integral() : 1;
+//    const Double_t pde = s1 && s1->GetSpline() ? s1->GetSpline()->Integral() : 1;
     const Double_t sr  = s2 && s2->GetSpline() ? s2->GetSpline()->IntegralSolidAngle() : 1;
-    const Double_t mir = s3 && s3->GetSpline() ? s3->GetSpline()->Integral() : 1;
+//    const Double_t mir = s3 && s3->GetSpline() ? s3->GetSpline()->Integral() : 1;
     const Double_t Ar  = r->GetA()/1e4;
 
@@ -168,4 +207,5 @@
     MParSpline *s4 = (MParSpline*)s1->Clone();
     s4->Multiply(*s3->GetSpline());
+    s4->Multiply(*s5->GetSpline());
 
     const Double_t nm = s4 && s4->GetSpline() ? s4->GetSpline()->Integral() : 1;
@@ -180,7 +220,7 @@
     *fLog << "Reflector area:                 " << Form("%.2f", Ar) << "m^2" << endl;
     *fLog << "Resulting eff. collection area: " << Form("%.1f", TMath::Min(Ar, sr*d2)) << "m^2" << endl;
-    *fLog << "Eff. wavelength band (PDE):     " << Form("%.1f", pde) << "nm" << endl;
-    *fLog << "Eff. wavelength band (Mirror):  " << Form("%.1f", mir) << "nm" << endl;
-    *fLog << "Eff. wavelength band (PDE+MIR): " << Form("%.1f", nm) << "nm" << endl;
+//    *fLog << "Eff. wavelength band (PDE):     " << Form("%.1f", pde) << "nm" << endl;
+//    *fLog << "Eff. wavelength band (Mirror):  " << Form("%.1f", mir) << "nm" << endl;
+    *fLog << "Eff. wavelength band (MIR+Cone+PDE): " << Form("%.1f", nm) << "nm" << endl;
     *fLog << "Pixel area of " << fNameGeomCam << "[0]: " << Form("%.2e", (*fGeom)[0].GetA()*conv*conv) << "sr" << endl;
     //*fLog << "Effective angular acceptance:     " << sr << "sr" << endl;
@@ -290,5 +330,5 @@
 //
 //    FrequencyFixed: 0.040
-//    FrequencyNSB:   0.040
+//    FrequencyNSB:   5.8
 //
 // The fixed frequency is given in units fitting the units of the time.
