Index: trunk/Mars/hawc/fresnellens_image.C
===================================================================
--- trunk/Mars/hawc/fresnellens_image.C	(revision 19632)
+++ trunk/Mars/hawc/fresnellens_image.C	(revision 19636)
@@ -1,2 +1,16 @@
+/*****************************************************************
+
+ fresnellens_image.C - Example how to simulate a fresnel lens
+
+ To run the macro from the command line (assuming you are in a directory
+ Mars/build where you have built your Mars environment) you have to do
+
+    root ../hawc/fresnellens_image.C
+
+ or from within root
+
+    [0] .x ../hawc/fresnellens_image.C
+
+******************************************************************/
 void fresnellens_image()
 {
@@ -4,8 +18,8 @@
     Double_t telaz = 0;      // [deg] Telescope orientation Azimuth
 
-    Double_t dzd   = 8;      // [deg] Relative angle of light ray Zd
+    Double_t dzd   = 85;      // [deg] Relative angle of light ray Zd
     Double_t daz   = 0;      // [deg] Relative angle of light ray Az
 
-    Double_t F     = 0.5021; // [m]   Distance of camera to lens
+    Double_t F     = 0.5021; // [m]   Distance of camera to lens (w.r.t. to lens exit)
     //                       // This is different from F in MFresnelLens!
 
@@ -13,10 +27,20 @@
 
     MFresnelLens lens("Reflector");
+    //lens.DefineLens(F, D, w, H, lambda);
+    //lens.EnableSlopeAbsorption();
+    //lens.EnableDraftAbsorption();
+    //lens.DisableBottomReflection();
+    //lens.DisableMultiEntry();
+    //lens.DisableFresnelReflection();
+    //lens.SetMinHits(5);
+    //lens.SetMaxHits(0);
+    lens.ReadTransmission("resmc/hawcseye/transmission-pmma-3mm.txt", 0.3, true);
 
-    MPointingPos pointpos;
-    pointpos.SetLocalPosition(telzd, telaz);
 
-    MPointingPos srcpos("Source");
-    srcpos.SetLocalPosition(dzd, daz);
+    MParSpline pde("PhotonDetectionEfficiency");
+    MParSpline acc("ConesAngularAcceptance");
+
+    pde.ReadFile("resmc/hawcseye/pde.txt");
+    acc.ReadFile("resmc/hawcseye/cones-angular-acceptance.txt");
 
     MGeomCamFAMOUS geom(F);
@@ -24,6 +48,12 @@
     MSimRays simrays;
     simrays.SetNameReflector("Reflector");
-    simrays.SetWavelengthRange(700, 700);
+    simrays.SetWavelengthRange(300, 890);
     //simrays.SetNumPhotons(100000);
+
+    MPointingPos srcpos("Source");
+    srcpos.SetLocalPosition(dzd, daz);
+
+    MPointingPos pointpos;
+    pointpos.SetLocalPosition(telzd, telaz);
 
     // ----------------------------------------------
@@ -37,4 +67,6 @@
     plist.AddToList(&srcpos);
     plist.AddToList(&geom);
+    plist.AddToList(&pde);
+    plist.AddToList(&acc);
 
     tlist.AddToList(&simrays);
@@ -46,4 +78,5 @@
     MHPhotonEvent plane4(2, "HMirrorPlane4");
     MHPhotonEvent planeC(9, "HPhotonEventCamera");
+    MHPhotonEvent planeS(9, "HPhotonEventCamera");
 
     planeG.SetMaxImpact(60);
@@ -55,4 +88,5 @@
     MFillH fill4(&plane4, "MirrorPlane4", "FillCameraPlane");
     MFillH fillC(&planeC, "MPhotonEvent", "FillCamera");
+    MFillH fillS(&planeS, "MPhotonEvent", "FillCamera");
 
     fillG.SetNameTab("Ground",      "Photon distribution at ground");
@@ -61,7 +95,18 @@
     fill3.SetNameTab("LensOut",     "Photon distribution at plane output surface");
     fill4.SetNameTab("CameraPlane", "Photon distribution at camera plane");
-    fillC.SetNameTab("Camera",      "Photon distribution which hit a sensor in the focal plane");
+    fillC.SetNameTab("Camera",      "Photon distribution which hit a cone in the focal plane");
+    fillS.SetNameTab("Sensor",      "Photon distribution which hit a sensor in the focal plane");
+
+    MSimAbsorption absapd("SimPhotonDetectionEfficiency");
+    MSimAbsorption cones("SimConesAngularAcceptance");
+    absapd.SetParName("PhotonDetectionEfficiency");
+    cones.SetParName("ConesAngularAcceptance");
+    cones.SetUseTheta();
+    cones.SetForce();
+    absapd.SetForce();
+    // We loose another 4% at the cone surface!
 
     tlist.AddToList(&fillG);
+    tlist.AddToList(&absapd);
 
     MSimReflector simref;
@@ -75,4 +120,6 @@
     tlist.AddToList(&fill4);
     tlist.AddToList(&fillC);
+    tlist.AddToList(&cones);
+    tlist.AddToList(&fillS);
 
     //tlist.SetAccelerator(MTask::kAccDontReset|MTask::kAccDontTime);
@@ -84,5 +131,5 @@
     loop.SetParList(&plist);
 
-    if (!loop.Eventloop(100))
+    if (!loop.Eventloop(510))
         return;
 }
