Index: trunk/MagicSoft/Simulation/Detector/Camera/camera.h
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/camera.h	(revision 5318)
+++ trunk/MagicSoft/Simulation/Detector/Camera/camera.h	(revision 5319)
@@ -19,7 +19,7 @@
 //=
 //= $RCSfile: camera.h,v $
-//= $Revision: 1.24 $
+//= $Revision: 1.25 $
 //= $Author: moralejo $ 
-//= $Date: 2004-10-19 10:35:05 $
+//= $Date: 2004-10-26 14:03:00 $
 //=
 //=//////////////////////////////////////////////////////////////////////
@@ -356,5 +356,6 @@
 			class MFadc *fadc, int *itotnphe, float *nphe,
 			int *nphot, int ict, float lambda, float sigma_lambda,
-			float phot_per_pix, float sigma_time, int selected_pixel);
+			float phot_per_pix, float sigma_time, int selected_pixel,
+			float fadc_jitter);
 
 
@@ -368,4 +369,7 @@
 /*
  *$Log: not supported by cvs2svn $
+ *Revision 1.24  2004/10/19 10:35:05  moralejo
+ **** empty log message ***
+ *
  *Revision 1.23  2004/10/13 17:05:05  moralejo
  **** empty log message ***
Index: trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx	(revision 5318)
+++ trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx	(revision 5319)
@@ -920,4 +920,11 @@
   
   //
+  // Here the slices to write out are calculated. Warning: the digitalization
+  // is NOT done here (it is already done in MFadc::Fill). This procedure only
+  // selects which FADC slices to write out, out of those contained in the sig[][]
+  // array.
+  //
+
+  //
   //  calculate the first slice to write out, according to trigger time: 
   // 
Index: trunk/MagicSoft/Simulation/Detector/include-MTrigger/MTrigger.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/include-MTrigger/MTrigger.cxx	(revision 5318)
+++ trunk/MagicSoft/Simulation/Detector/include-MTrigger/MTrigger.cxx	(revision 5319)
@@ -74,15 +74,15 @@
   //
 
-  fwhm_resp = RESPONSE_FWHM       ; 
-  ampl_resp = RESPONSE_AMPLITUDE  ; 
+  fwhm_resp = RESPONSE_FWHM; 
+  ampl_resp = RESPONSE_AMPLITUDE; 
 
   overlaping_time = TRIGGER_OVERLAPING;
 
-  threshold = CHANNEL_THRESHOLD  ; 
-  
-
-  gate_leng        = TRIGGER_GATE       ; 
-  trigger_multi    = TRIGGER_MULTI      ; 
-  trigger_geometry = TRIGGER_GEOM ; 
+  threshold = CHANNEL_THRESHOLD; 
+  
+
+  gate_leng        = TRIGGER_GATE; 
+  trigger_multi    = TRIGGER_MULTI; 
+  trigger_geometry = TRIGGER_GEOM; 
 
   //
@@ -234,27 +234,9 @@
  
 
-  //
-  //   the amplitude of one single photo electron is not a constant. 
-  //   There exists a measured distribution from Razmik. This distribution
-  //   is used to simulate the noise of the amplitude. 
-  //   For this a histogramm (histPmt) is created and filled with the
-  //   values. 
-  // 
-
-  histPmt = new TH1F ("histPmt","Noise of PMT", 40, 0., 40.) ;
-  
-  Stat_t ValRazmik[41] = { 0., 2.14, 2.06, 2.05, 2.05, 2.06, 2.07, 2.08,  2.15,
-			   2.27, 2.40, 2.48, 2.55, 2.50, 2.35, 2.20,  2.10,
-			   1.90, 1.65, 1.40, 1.25, 1.00, 0.80, 0.65,  0.50,
-			   0.35, 0.27, 0.20, 0.18, 0.16, 0.14, 0.12,  0.10, 
-			   0.08, 0.06, 0.04, 0.02, 0.01, 0.005,0.003, 0.001} ; 
-
-  histMean =  histPmt->GetMean() ;   
-  
-  for (i=0;i<41;i++){
-    histPmt->SetBinContent(i,ValRazmik[i]);
-  }
-
-  histMean =  histPmt->GetMean() ; 
+  // Initialize histogram histPmt which represents the distribution of amplitudes
+  // of the PMT response to a single photpelectron.
+
+  InitGainFluctuations();
+
 
   //
@@ -481,29 +463,18 @@
   peak_time = ( (Float_t) imax )  / ( (Float_t) TRIG_SLICES_PER_NSEC ) ;
  
-  //
-  //   the amplitude of one single photo electron is not a constant. 
-  //   There exists a measured distribution from Razmik. This distribution
-  //   is used to simulate the noise of the amplitude. 
-  //   For this a histogramm (histPmt) is created and filled with the
-  //   values. 
-  // 
-
+
+  // Initialize histogram histPmt which represents the distribution of amplitudes
+  // of the PMT response to a single photpelectron.
+
+  InitGainFluctuations();
+  
+  //
+  // Change name of histogram (tag with CT id) to avoid confusion in the case of
+  // multi-telescope simulations.
+  //
   char histname[32];
   sprintf(histname, "histPmt_%d", ct_id);
-  histPmt = new TH1F (histname,"Noise of PMT", 40, 0., 40.) ;
-  
-  Stat_t ValRazmik[41] = { 0., 2.14, 2.06, 2.05, 2.05, 2.06, 2.07, 2.08,  2.15,
-			   2.27, 2.40, 2.48, 2.55, 2.50, 2.35, 2.20,  2.10,
-			   1.90, 1.65, 1.40, 1.25, 1.00, 0.80, 0.65,  0.50,
-			   0.35, 0.27, 0.20, 0.18, 0.16, 0.14, 0.12,  0.10, 
-			   0.08, 0.06, 0.04, 0.02, 0.01, 0.005,0.003, 0.001} ; 
-
-  histMean =  histPmt->GetMean() ;   
-  
-  for (i=0;i<41;i++){
-    histPmt->SetBinContent(i,ValRazmik[i]);
-  }
-
-  histMean =  histPmt->GetMean() ; 
+  histPmt->SetName(histname);
+
 
   //
@@ -644,16 +615,16 @@
   //
 
-  fwhm_resp = fwhm       ; 
-  ampl_resp = ampl  ; 
+  fwhm_resp = fwhm; 
+  ampl_resp = ampl; 
 
   overlaping_time = overt;
 
     
-  threshold = CHANNEL_THRESHOLD  ; 
-  
-
-  gate_leng        = gate       ; 
-  trigger_multi    = TRIGGER_MULTI      ; 
-  trigger_geometry = TRIGGER_GEOM ; 
+  threshold = CHANNEL_THRESHOLD; 
+  
+
+  gate_leng        = gate; 
+  trigger_multi    = TRIGGER_MULTI; 
+  trigger_geometry = TRIGGER_GEOM; 
 
   cout << endl
@@ -710,27 +681,10 @@
   peak_time = ( (Float_t) imax )  / ( (Float_t) TRIG_SLICES_PER_NSEC ) ;
  
-  //
-  //   the amplitude of one single photo electron is not a constant. 
-  //   There exists a measured distribution from Razmik. This distribution
-  //   is used to simulate the noise of the amplitude. 
-  //   For this a histogramm (histPmt) is created and filled with the
-  //   values. 
-  // 
-
-  histPmt = new TH1F ("histPmt","Noise of PMT", 40, 0., 40.) ;
-  
-  Stat_t ValRazmik[41] = { 0., 2.14, 2.06, 2.05, 2.05, 2.06, 2.07, 2.08,  2.15,
-			   2.27, 2.40, 2.48, 2.55, 2.50, 2.35, 2.20,  2.10,
-			   1.90, 1.65, 1.40, 1.25, 1.00, 0.80, 0.65,  0.50,
-			   0.35, 0.27, 0.20, 0.18, 0.16, 0.14, 0.12,  0.10, 
-			   0.08, 0.06, 0.04, 0.02, 0.01, 0.005,0.003, 0.001} ; 
-
-  histMean =  histPmt->GetMean() ;   
-  
-  for (i=0;i<41;i++){
-    histPmt->SetBinContent(i,ValRazmik[i]);
-  }
-
-  histMean =  histPmt->GetMean() ; 
+
+  // Initialize histogram histPmt which represents the distribution of amplitudes
+  // of the PMT response to a single photpelectron.
+
+  InitGainFluctuations();
+
 
   //
@@ -931,5 +885,8 @@
     //  the FADC simulation
     //
-    PmtAmp =  (histPmt->GetRandom()/histMean) ; 
+    if (fGainFluctuations)
+      PmtAmp =  (histPmt->GetRandom()/histMean) ; 
+    else
+      PmtAmp = 1.0;
 
     // AM April 2004: removed updating of counters nphotshow, nphotnsb,
@@ -960,7 +917,10 @@
     
     //
-    // get the randomized amplitude
-    //
-    PmtAmp =  (histPmt->GetRandom()/histMean) ; 
+    // get the randomized amplitude (unless fGainFluctuations == kFALSE)
+    //
+    if (fGainFluctuations)
+      PmtAmp =  (histPmt->GetRandom()/histMean) ; 
+    else
+      PmtAmp = 1.0;
 
     //
@@ -1061,5 +1021,5 @@
   Float_t rausch ; 
 
-  rausch = RESPONSE_AMPLITUDE * factor ; 
+  rausch = ampl_resp * factor ; 
  
   cout<<"MTrigger::SetElecNoise ... generating database for electronic noise."
@@ -1080,7 +1040,4 @@
   //    to the signal
   //
-  Float_t rausch ; 
-
-  rausch = RESPONSE_AMPLITUDE * factor ; 
 
   UInt_t startslice;
@@ -1900,2 +1857,32 @@
 
 }
+
+//=================================================================
+
+void MTrigger::InitGainFluctuations()
+{
+  //
+  //   The amplitude of one single photo electron is not a constant. 
+  //   There exists a measured distribution from Razmik. This distribution
+  //   is used to simulate the noise of the amplitude. 
+  //   For this a histogramm (histPmt) is created and filled with the
+  //   values. 
+  // 
+
+  histPmt = new TH1F ("histPmt","Noise of PMT", 40, 0., 40.) ;
+  
+  Stat_t ValRazmik[40] = { 2.14, 2.06, 2.05, 2.05, 2.06, 2.07, 2.08,  2.15,
+			   2.27, 2.40, 2.48, 2.55, 2.50, 2.35, 2.20,  2.10,
+			   1.90, 1.65, 1.40, 1.25, 1.00, 0.80, 0.65,  0.50,
+			   0.35, 0.27, 0.20, 0.18, 0.16, 0.14, 0.12,  0.10, 
+			   0.08, 0.06, 0.04, 0.02, 0.01, 0.005,0.003, 0.001} ; 
+
+  for (Int_t i = 0; i < 40; i++)
+    histPmt->SetBinContent(i+1 ,ValRazmik[i]);
+
+  histMean =  histPmt->GetMean() ; 
+
+  fGainFluctuations = kTRUE; // Default value
+
+  return;
+}
Index: trunk/MagicSoft/Simulation/Detector/include-MTrigger/MTrigger.hxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/include-MTrigger/MTrigger.hxx	(revision 5318)
+++ trunk/MagicSoft/Simulation/Detector/include-MTrigger/MTrigger.hxx	(revision 5319)
@@ -32,5 +32,5 @@
 
 //==========
-//  MTrigger
+//  MTrigger   FIXME: some explanations are rather outdated!!
 //
 //  The simulation of the Trigger for MonteCarlo Events is using this
@@ -55,7 +55,5 @@
 //  the standard response function to the analog signal of the pixel.
 //
-//  Each pixel of the camera has such an summed-up analog signal. It may
-//  look like this picture:
-//
+//  Each pixel of the camera has such an summed-up analog signal.
 //
 //  This is the input of the discriminator for the pixels. The output of
@@ -67,14 +65,10 @@
 //  with a given length is created.
 // 
-//  No one can start with the simulation of different trigger levels. 
+//  Now one can start with the simulation of different trigger levels. 
 //  
 //  The TriggerLevelZero is a very easy one. It is just looking if there 
-//  are more then N digital signals at level ON (=1). If this is the case,
+//  are more than N digital signals at level ON (=1). If this is the case,
 //  a TriggerLevelZero signal is created.
 //
-//  The TriggerLevelOne is not implemented now. This will be a kind of next 
-//  neighbour condition (i.e. four neigbouring analog signals at the same 
-//  time, but this requests at least four digital signals at level ON, what 
-//  is equivalent with a TriggerLevelZero.
 //  
 //  
@@ -161,13 +155,14 @@
   Int_t  PixelsSecond[5] ; //  Pixel which fires the trigger
 
-private: 
-
   Float_t  Fill( Int_t, Float_t, Int_t ) ;  
 
   Bool_t PassNextNeighbour( Bool_t m[], Bool_t *n) ; 
 
-  void OverlapingTime( Bool_t m[], Bool_t *n, Int_t ifSli);  //  n[] will have pixels of
-                                       //  m[] that are on for the required verlaping time
- 
+  void OverlapingTime( Bool_t m[], Bool_t *n, Int_t ifSli);  
+  //  n[] will have pixels of m[] that are on for the required overlaping time
+ 
+  Bool_t fGainFluctuations;
+  void InitGainFluctuations();
+
 public:
 
@@ -216,4 +211,6 @@
   }
 
+  void SetGainFluctuations(Bool_t x) { fGainFluctuations = x; }
+
   void CheckThreshold (float *thres, int cells);
 
