Index: trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 6587)
+++ trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 6588)
@@ -5061,4 +5061,13 @@
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.91  2005/02/18 10:24:51  moralejo
+// 
+// Added switch to low gain (see MFadc.cxx). Before, in all events all 
+// pixels had low gain branch, no matter how small the signal in the high
+// gain was. Now we require a minimum signal in the high gain to fill the
+// low gain slices with the scaled-down signal. In case the switch does
+// not occur, the low gain slices are simply the continuation of the
+// high gain ones, with the noise the same as in the high gain.
+//
 // Revision 1.90  2005/02/17 15:37:12  moralejo
 //
Index: trunk/MagicSoft/Simulation/Detector/Camera/input.card
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/input.card	(revision 6587)
+++ trunk/MagicSoft/Simulation/Detector/Camera/input.card	(revision 6588)
@@ -5,9 +5,13 @@
 ct_geom 1
 # Quantum efficiency file:
-qe_file 0  /home/pcmagic00/moralejo/MagicSoft/Simulation/Detector/Data/qe-emi-coat.RFL.dat
+qe_file 0  /users/emc/moralejo/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]
-calibration_run 375. 12. 200. 2.5 5
+# 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
+# line below shows how to create a pedestal run (= cal. with 0-photon pulses):
+#calibration_run 0. 0. 0. 0. 1000
 # Ascii output file name:
 #data_file ./Gamma_zbin0_0_7_1000to1009_w0.dat
@@ -15,5 +19,6 @@
 # root output file name:
 #root_file ./Gamma_zbin0_0_7_1000to1009_w0.root
-root_file ./prueba.root
+#root_file ./19990101_00001_P_MonteCarlo_E.root
+root_file ./19990101_00002_C_MonteCarlo_E.root
 # Trigger characteristics: gate length (ns), min. overlapping time (ns),
 # amplitude and FWHM of (gaussian) single phe response for trigger:
@@ -21,26 +26,26 @@
 # L1 Trigger condition: CT number, threshold (mV), multiplicity and topology:
 trigger_single 0 4 4 2
+# 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.13 10
+nsb_mean 0.183 10
 # Starfield (see Starfieldadder program)
-# starfield_file /home/pcmagic00/moralejo/MagicSoft/Simulation/Detector/Starfield/starfield.rfl
-# Electronic noise in FADC (sigma in ADC counts): Inner pixels, outer pixels, digital noise: 
-#fadc_noise 1.48 2.1 0.
-elec_noise_off
+# starfield_file /users/emc/moralejo/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
 # Mean pedestal per slice (ADC counts):
 fadc_pedestal 10.
 # Additional sigma of mirror spot (cm):
-sigma_xy_cm_spot 1.
-# Fraction of currently active mirror:
-mirror_fraction 0 1.
+sigma_xy_cm_spot 1.4
 # Seeds for random number generation:
 seeds 66767 45069
 # Directory where NSB database can be found for inner and outer pixels:
-nsb_directory  /home/pcmagic00/moralejo/MagicSoft/Simulation/Detector/StarLight/inner/
-nsb_dir_outer  /home/pcmagic00/moralejo/MagicSoft/Simulation/Detector/StarLight/outer/
+nsb_directory  /users/emc/moralejo/MagicSoft/Simulation/Detector/StarLight/inner/
+nsb_dir_outer  /users/emc/moralejo/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 6587)
+++ trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx	(revision 6588)
@@ -24,5 +24,5 @@
 	     Float_t trigger_delay, Float_t fadc_slices_per_ns,
 	     Int_t fadc_slices_written, Int_t gainswitchamp,
-	     Int_t shiftfromswitch2lowgain) {
+	     Int_t shiftfromswitch2lowgain, Int_t hi2logainpeak) {
   //
   //  Constructor overloaded II 
@@ -55,4 +55,5 @@
   fGainSwitchAmp = gainswitchamp;
   fShiftFromSwitch2LowGain = shiftfromswitch2lowgain;
+  fHi2LoGainPeak = hi2logainpeak;
 
   fSlices_mFadc = (Int_t)(TOTAL_TRIGGER_TIME*fFadcSlicesPerNanosec);
@@ -988,4 +989,6 @@
 
       // Now put the low gain:
+      // FIXME: for now, the shift between the high and low gain peaks has to be an integer number
+      // of FADC slices. But in the data the shift is ~16.5 slices. This has to be implemented.
       i=0;
       for ( Int_t is = iFirstSlice; is < (iFirstSlice+fFadcSlices); is++ ) 
@@ -995,5 +998,5 @@
 	      if (switch_i > 0 && (i+fFadcSlices) >= switch_i)
 		output_lowgain[ip][i] = pedestal[ip] + 
-		  (sig[ip][is]-pedestal[ip])/high2low_gain;
+		  (sig[ip][is-(fHi2LoGainPeak-fFadcSlices)]-pedestal[ip])/high2low_gain;
 	      // Once the shift occurs, low gain is filled with the high
 	      // gain signal scaled down by the factor high2low_gain
Index: trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.hxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.hxx	(revision 6587)
+++ trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.hxx	(revision 6588)
@@ -110,8 +110,14 @@
                         // to fill the low gain with a scaled down version of the pulse in the
                         // high gain. Else we put in the continuation of the high gain. 
+                        // By default it is now 120 ADC counts (see constructor).
 
   Int_t fShiftFromSwitch2LowGain; 
   // Distance in FADC slices from the slice in which the amplitude
   // fGainSwitchAmp is reached to were the switch to low gain will happen.
+  // By default it is now 13 slices (see constructor)
+
+  Int_t fHi2LoGainPeak;
+  // Distance in FADC slices from the signal peak in the high gain to the signal peak in
+  // the low gain. By default we set now 16 slices (see constructor).
 
   //
@@ -138,5 +144,6 @@
 	Int_t   fadc_slices_written = FADC_SLICES,
 	Int_t   gainswitchamp = 120,
-	Int_t   shiftfromswitch2lowgain = 13);
+	Int_t   shiftfromswitch2lowgain = 13,
+	Int_t   hi2logainpeak = 16);
 
   void SetSeed(UInt_t seed)  {GenElec->SetSeed(seed);}
