Index: trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 5273)
+++ trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 5275)
@@ -21,7 +21,7 @@
 //
 // $RCSfile: camera.cxx,v $
-// $Revision: 1.75 $
+// $Revision: 1.76 $
 // $Author: moralejo $ 
-// $Date: 2004-10-14 12:55:02 $
+// $Date: 2004-10-14 16:56:43 $
 //
 ////////////////////////////////////////////////////////////////////////
@@ -4025,4 +4025,11 @@
   float C1, C2, C3, rho;
 
+  // A. Moralejo, October 2004
+  // Introduced the FADC jitter of 1 FADC slice. This is a time to be added to the 
+  // time of all photons in an event, before digitalization of the signal. We use 
+  // a positive value between 0 and 1 slice for technical reasons, but it is 
+  // totally equivalent to having made  +- 1 FADC slice
+
+  float fadc_jitter = (1./fadc->GetFadcSlicesPerNanosec()) * random.Uniform(0., 1.);
 
   //- - - - - - - - - - - - - - - - - - - - - - - - - 
@@ -4195,6 +4202,6 @@
     // store the new photoelectron
 
-    fadc->Fill(ipixnum,(t-*tmin_ns) , 
-	       trigger->FillShow(ipixnum,t-*tmin_ns),
+    fadc->Fill(ipixnum,(t-*tmin_ns) + fadc_jitter , 
+	       trigger->FillShow(ipixnum, t-*tmin_ns + fadc_jitter),
 	       !((*camgeom)[ipixnum].GetD()>(*camgeom)[0].GetD()));
     
@@ -4597,10 +4604,14 @@
 	  Fadc_CT[ict]->Pedestals();
 
-	  // Set the trigger time. The 3 ns are such that the pulse appears well 
-	  // centered if the FADC range is the usual 50 ns.
-	  // If you want to shift the pulse position, do not change the value here,
+	  // Set the trigger time. The 3 ns are such that the calibration pulses
+	  // appear roughly at the same position as for the case of real data.
+	  // If you want to shift the pulse position, do not change this value here,
 	  // use the option trigger_delay in the input card instead.
-
-	  Fadc_CT[ict]->TriggeredFadc(13.);
+	  // The additional value 3*sigma_time makes that the pulse maximum is, in 
+	  // average, in the same position no matter of the time width of the pulse
+	  // (see in produce_calib_phes(...) that in order to avoid negative times 
+	  // we shift the time of the photons by this same amount!)
+
+	  Fadc_CT[ict]->TriggeredFadc(3.+3*sigma_time);
 
 	  //
@@ -4686,4 +4697,11 @@
   random.SetSeed(seed);
 
+  // Introduce the FADC jitter of 1 FADC slice. This is a time to be added to the 
+  // time of all photons in an event, before digitalization of the signal. We use 
+  // a positive value between 0 and 1 slice for technical reasons, but it is 
+  // totally equivalent to having made  +- 1 FADC slice
+
+  float fadc_jitter = (1./fadc->GetFadcSlicesPerNanosec()) * random.Uniform(0., 1.);
+
   //
   // Create photons and "map" them into the pixels
@@ -4715,9 +4733,13 @@
 
       // time
-      //      time = random.Gaus(0., sigma_time);
-      time = 10.;
+      // We do not want negative times, so center the gaussian at 3 sigma 
+      // and reject negative values:
+
+      do
+	time = random.Gaus(3*sigma_time, sigma_time);
+      while (time < 0.);
 
       // wavelength
-      wl = lambda;
+      wl = random.Gaus(lambda, sigma_lambda);
 
       if( (wl > WAVEBANDBOUND6) || (wl < WAVEBANDBOUND1))
@@ -4792,5 +4814,5 @@
 
       //
-      // Apply incient angular correction due to Light Guides, plexiglas,
+      // Apply incident angular correction due to Light Guides, plexiglas,
       // 1st dynode collection efficiency, double crossings... etc. 
       // This information is contained in the file Data/LightCollection.dat,
@@ -4837,6 +4859,6 @@
       // store the new photoelectron
 
-      fadc->Fill(ipixnum,(time) , 
-		 trigger->FillShow(ipixnum, time),
+      fadc->Fill(ipixnum, time + fadc_jitter, 
+		 trigger->FillShow(ipixnum, time + fadc_jitter),
 		 !((*camgeom)[ipixnum].GetD()>(*camgeom)[0].GetD()));
     
@@ -4860,4 +4882,7 @@
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.75  2004/10/14 12:55:02  moralejo
+// *** empty log message ***
+//
 // Revision 1.74  2004/10/13 17:05:05  moralejo
 // *** empty log message ***
