Index: trunk/MagicSoft/Simulation/Detector/Camera/creadparam.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/creadparam.cxx	(revision 6709)
+++ trunk/MagicSoft/Simulation/Detector/Camera/creadparam.cxx	(revision 6710)
@@ -19,7 +19,7 @@
 //=
 //= $RCSfile: creadparam.cxx,v $
-//= $Revision: 1.37 $
+//= $Revision: 1.38 $
 //= $Author: moralejo $ 
-//= $Date: 2005-02-17 09:15:28 $
+//= $Date: 2005-03-02 20:49:19 $
 //=
 //=//////////////////////////////////////////////////////////////////////
@@ -103,5 +103,5 @@
 static float misp_y = 0.; // Mispointing in y
 
-static float trig_delay = 25.;  // Delay in ns between beginning of FADC
+static float trig_delay = 19.;  // Delay in ns between beginning of FADC
                                 // time window and the trigger instant.
 
@@ -1445,4 +1445,17 @@
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.37  2005/02/17 09:15:28  moralejo
+//
+// Set as default option that of writing all event headers to output file,
+// not only those of the triggered events. To disable it, set the input card
+// flag "no_write_all_event_headers".
+//
+// Changed such that output images for events below the minimum number of
+// photoelectrons nphe2NSB required to simulate the noise (NSB & electronic)
+// will be empty. This will avoid the problem of these events being processed,
+// without any noise, later in the chain. Although those images are not in the
+// output, one can still check in the headers (MMcTrig) how many such events
+// with less than nphe2NSB photoelectrons would have triggered.
+//
 // Revision 1.36  2005/02/10 19:28:10  moralejo
 //
Index: trunk/MagicSoft/Simulation/Detector/Camera/input.card
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/input.card	(revision 6709)
+++ trunk/MagicSoft/Simulation/Detector/Camera/input.card	(revision 6710)
@@ -5,11 +5,11 @@
 ct_geom 1
 # Quantum efficiency file:
-qe_file 0  /users/emc/moralejo/MagicSoft/Simulation/Detector/Data/qe-emi-coat.RFL.dat
+qe_file 0  /home/magic/MagicSoft/Simulation/Detector/Data/qe-emi-coat.RFL.dat
 # Input file (one per telescope):
 # input_file 0 /data1/magic/reflex/Gamma_zbin0_0_7_1000to1009_w0.rfl
 # Perform calibration run: lambda sigma_lambda phot_per_pixel time_fwhm n_events [selected_pixel]
 # The values below correspond roughly to 10 LED UV 
-#calibration_run 375. 12. 120. 2.5 3000
-calibration_run 375. 12. 120. 2.5 10
+#calibration_run 375. 12. 120. 2.5 5000
+calibration_run 375. 12. 120. 0.01 1
 # line below shows how to create a pedestal run (= cal. with 0-photon pulses):
 #calibration_run 0. 0. 0. 0. 1000
@@ -26,17 +26,19 @@
 # L1 Trigger condition: CT number, threshold (mV), multiplicity and topology:
 trigger_single 0 4 4 2
+# To shift the pulses in the FADC window, modify the trigger delay (ns):
+#trigger_delay 18.
 # Correction to overall light collection efficiency:  CT#  fraction
 mirror_fraction 0 0.73
 # Switch on NSB:
-nsb_on
-#nsb_off
+#nsb_on
+nsb_off
 # Number of photons from the diffuse NSB (nphe / ns 0.1*0.1 deg^2 239 m^2) and
 # minimum number of phe from shower required to simulate NSB:
 nsb_mean 0.183 10
 # Starfield (see Starfieldadder program)
-# starfield_file /users/emc/moralejo/MagicSoft/Simulation/Detector/Starfield/starfield.rfl
+# starfield_file /home/magic/MagicSoft/Simulation/Detector/Starfield/starfield.rfl
 # Electronic noise in FADC (sigma in ADC counts): Inner pixels, outer pixels, digital noise:
-fadc_noise 1.3 2.4 1.
-#elec_noise_off
+#fadc_noise 1.3 2.4 1.
+elec_noise_off
 # Mean pedestal per slice (ADC counts):
 fadc_pedestal 10.
@@ -46,6 +48,6 @@
 seeds 66767 45069
 # Directory where NSB database can be found for inner and outer pixels:
-nsb_directory  /users/emc/moralejo/MagicSoft/Simulation/Detector/StarLight/inner/
-nsb_dir_outer  /users/emc/moralejo/MagicSoft/Simulation/Detector/StarLight/outer/
+nsb_directory  /home/magic/MagicSoft/Simulation/Detector/StarLight/inner/
+nsb_dir_outer  /home/magic/MagicSoft/Simulation/Detector/StarLight/outer/
 #
 # FADC properties: shape of single phe response (1 means realistic one, from
Index: trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx	(revision 6709)
+++ trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx	(revision 6710)
@@ -227,4 +227,5 @@
     fadc_time_offset = trigger_delay - p2 / FADC_SLICES_PER_NSEC; // ns
 
+
     for (i=0; i< fResponseSlicesFadc ; i++ )
       {
@@ -241,13 +242,17 @@
 				   p3+p4*exp(-p1*(exp(-p1*zed_slices)+
 						  p5*zed_slices))+p6*d);
+	response_sum_inner += sing_resp[i];
+
+
+	// Now the low gain:
 
 	zed_slices = x * FADC_SLICES_PER_NSEC - p2_LG;
 	d = (zed_slices>0)? 0.5 : -0.5;
+
 	sing_resp_lowgain[i] =  (Float_t) (p0_LG*exp(-p1_LG*(exp(-p1_LG*zed_slices)+zed_slices))+
-					   p3+p4*exp(-p1_LG*(exp(-p1_LG*zed_slices)+
-							  p5*zed_slices))+p6*d);
-
-	response_sum_inner += sing_resp[i];
+					   p3_LG+p4_LG*exp(-p1_LG*(exp(-p1_LG*zed_slices)+
+							  p5_LG*zed_slices))+p6_LG*d);
 	response_sum_inner_LG += sing_resp_lowgain[i];
+
       }
 
@@ -268,5 +273,4 @@
     sigma = fwhm_resp_outer / 2.35 ; 
     x0 = 3*sigma ; 
-    fadc_time_offset = trigger_delay-x0; // ns
     
     for (i = 0; i < fResponseSlicesFadc ; i++ ) 
@@ -309,16 +313,4 @@
     p6_LG = fPulseParametersLG[6];
 
-    // Now define the time before trigger to read FADC signal when it
-    // has to be written. Here FADC_SLICES_PER_NSEC (=0.3) is the value
-    // for the 300 MHz MAGIC FADCs and must NOT be changed, even if you
-    // use a faster sampling in the simulation (through the input card 
-    // command "fadc_GHz"), because this is just a conversion of units. The
-    // parameters of the "pulpo" pulse shape were obtained with the 300 MHz
-    // FADC and so we convert the time parameter to units of 3.3 ns slices 
-    // just to use the provided parametrization, and no matter what sampling 
-    // frequency we are simulating!
-
-    fadc_time_offset = trigger_delay - p2 / FADC_SLICES_PER_NSEC; // ns
-
     for (i=0; i< fResponseSlicesFadc ; i++ )
       {
@@ -336,12 +328,15 @@
 					p4*exp(-p1*(exp(-p1*zed_slices)+
 						    p5*zed_slices))+p6*d);
+	response_sum_outer += sing_resp_outer[i];
+
+
+	// Now the low gain:
 
 	zed_slices = x * FADC_SLICES_PER_NSEC - p2_LG;
 	d = (zed_slices>0)? 0.5 : -0.5;
+
 	sing_resp_outer_lowgain[i] =  (Float_t) (p0_LG*exp(-p1_LG*(exp(-p1_LG*zed_slices)+zed_slices))+
-						 p3+p4*exp(-p1_LG*(exp(-p1_LG*zed_slices)+
-								   p5*zed_slices))+p6*d);
-
-	response_sum_outer += sing_resp_outer[i];
+						 p3_LG+p4_LG*exp(-p1_LG*(exp(-p1_LG*zed_slices)+
+								   p5_LG*zed_slices))+p6_LG*d);
 	response_sum_outer_LG += sing_resp_outer_lowgain[i];
       }
@@ -492,5 +487,5 @@
     // We take the pulse height in the middle of FADC slices, we start in the
     // first such point after the time "time" (=ichan in response bins). Each
-    // FADC slice corresponds to SUBBINS response bins (SUBBINS=5 by default).
+    // FADC slice corresponds to SUBBINS response bins.
 
     Int_t first_i =  Int_t(SUBBINS/2) - ichan%(Int_t)SUBBINS;
