Index: trunk/MagicSoft/Simulation/Detector/Camera/creadparam.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/creadparam.cxx	(revision 5417)
+++ trunk/MagicSoft/Simulation/Detector/Camera/creadparam.cxx	(revision 5418)
@@ -19,7 +19,7 @@
 //=
 //= $RCSfile: creadparam.cxx,v $
-//= $Revision: 1.33 $
+//= $Revision: 1.34 $
 //= $Author: moralejo $ 
-//= $Date: 2004-10-26 13:58:59 $
+//= $Date: 2004-11-17 11:36:07 $
 //=
 //=//////////////////////////////////////////////////////////////////////
@@ -118,5 +118,6 @@
 static int   selected_pixel = -1; // Selected pixel: if >= 0 ==> only this pixel is filled! 
 
-static int   gain_fluctuations = 1; // Is 0 if PMT gain fluctuations are disabled
+static int   gain_fluctuations = 1; // Is 0 if PMT gain fluctuations are disabled for signal
+static int   noise_gain_fluctuations = 1; // Is 0 if PMT gain fluctuations are disabled for NSB noise
 
 // Coordinates of CT locations, in centimeters, in the Corsika system.
@@ -629,4 +630,10 @@
       break;
 
+    case noise_gain_fluctuations_off:
+
+      noise_gain_fluctuations = 0;
+
+      break;
+
     case end_file:            //@< end of the parameters file
 
@@ -1411,4 +1418,9 @@
 }
   
+int apply_noise_gain_fluctuations()
+{
+  return noise_gain_fluctuations;
+}
+  
 
 //=------------------------------------------------------------
@@ -1418,4 +1430,8 @@
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.33  2004/10/26 13:58:59  moralejo
+//
+// Added option gain_fluctuations_off
+//
 // Revision 1.32  2004/10/14 16:53:49  moralejo
 //
Index: trunk/MagicSoft/Simulation/Detector/Camera/creadparam.h
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/creadparam.h	(revision 5417)
+++ trunk/MagicSoft/Simulation/Detector/Camera/creadparam.h	(revision 5418)
@@ -19,7 +19,7 @@
 //=
 //= $RCSfile: creadparam.h,v $
-//= $Revision: 1.29 $
+//= $Revision: 1.30 $
 //= $Author: moralejo $ 
-//= $Date: 2004-10-26 13:58:59 $
+//= $Date: 2004-11-17 11:36:07 $
 //=
 //=//////////////////////////////////////////////////////////////////////
@@ -116,5 +116,6 @@
 T(mirror_fraction), /* Fraction of dish mirror really operative */ \
 T(calibration_run), /* option to produce a calibration file */ \
-T(gain_fluctuations_off), /* Switches off PMT gain fluctuations */ \
+T(gain_fluctuations_off), /* Switches off PMT gain fluctuations for signal */ \
+T(noise_gain_fluctuations_off), /* Switches off PMT gain fluctuations for NSB noise */ \
 T(end_file)         /* end of the parameters file */
 
@@ -197,4 +198,5 @@
  				 float *sigma_time, int *nevents, int *selected_pixel);
 int   apply_gain_fluctuations();
+int   apply_noise_gain_fluctuations();
 //!@}
 
@@ -212,4 +214,8 @@
 /*
  * $Log: not supported by cvs2svn $
+ * Revision 1.29  2004/10/26 13:58:59  moralejo
+ *
+ * Added option gain_fluctuations_off
+ *
  * Revision 1.28  2004/10/13 17:05:05  moralejo
  * *** empty log message ***
Index: trunk/MagicSoft/Simulation/Detector/StarResponse/starresponse.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/StarResponse/starresponse.cxx	(revision 5417)
+++ trunk/MagicSoft/Simulation/Detector/StarResponse/starresponse.cxx	(revision 5418)
@@ -25,4 +25,6 @@
   MStarLight  data(fadc->GetFadcSlicesPerNanosec(), fadc->GetResponseSlicesFadc());
   // create  instance of the MStarLight 
+
+  data.SetGainFluctuations(apply_gain_fluctuations());
 
   //  Shall I write the root file???
Index: trunk/MagicSoft/Simulation/Detector/include-MLons/MLons.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/include-MLons/MLons.cxx	(revision 5417)
+++ trunk/MagicSoft/Simulation/Detector/include-MLons/MLons.cxx	(revision 5418)
@@ -19,4 +19,6 @@
   fFwhmFadc = 2.0;
 
+  fGainFluctuations = 1;
+
   RandomNumber = new TRandom();
   RandomNumber -> SetSeed(0);
@@ -26,5 +28,5 @@
 MLons::MLons(Int_t in_shapeT, Float_t in_amplT, Float_t in_FwhmT, 
 	     Int_t in_shapeF, Float_t in_integF, Float_t in_FwhmF,
-	     Float_t in_Fadc_Slices_per_ns)
+	     Float_t in_Fadc_Slices_per_ns, Int_t in_Gain_Fluctuations)
 {
   //--------------------------------------------------------------------
@@ -43,4 +45,6 @@
   fFadcSlicesPerNanosec = in_Fadc_Slices_per_ns;
 
+  fGainFluctuations = in_Gain_Fluctuations;
+
   MSLStored = new MStarLight;
 
@@ -63,4 +67,6 @@
   fIntegFadc   = 0.; 
   fFwhmFadc    = 0.; 
+
+  fGainFluctuations = 1;
 
   MSLStored->Reset();
@@ -221,5 +227,5 @@
       strcat(filename_slt, ".slt");
  
-      // If brightness is different it check if the new file has the
+      // If brightness is different it checks if the new file has the
       // required parameters.
       // Note: I could be faster to store the whole trigger and fadc
@@ -236,4 +242,27 @@
 	  return 0;
 	}
+
+      if ( !MSLStored->GetGainFluctuations() && fGainFluctuations)
+	{
+	  cout << endl << "ERROR! The read NSB database in " << filename_slt << endl;
+	  cout << "has been produced without PMT gain fluctuations. This is incompatible" << endl;
+	  cout << "with the camera input card you are using. Please change the camera" << endl;
+	  cout << "input card (adding the  noise_gain_fluctuations_off  command) or"  << endl;
+	  cout << "produce a new NSB database (using program StarResponse) without" << endl;
+	  cout << "gain fluctuations. Exiting..." << endl << endl;
+	  return 0;
+	}
+
+      else if ( MSLStored->GetGainFluctuations() && !fGainFluctuations)
+	{
+	  cout << endl << "ERROR! The read NSB database in " << filename_slt << endl;
+	  cout << "has been produced with PMT gain fluctuations. This is incompatible" << endl;
+	  cout << "with the camera input card command  noise_gain_fluctuations_off" << endl;
+	  cout << "that you are using. Please change the camera input card or produce a" << endl;
+	  cout << "new NSB database (using program StarResponse) without gain fluctuations." << endl;
+	  cout << "Exiting..." << endl << endl;
+	  return 0;
+	}
+
       MSLStored->SetBrightness(in_br);
 
Index: trunk/MagicSoft/Simulation/Detector/include-MLons/MLons.hxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/include-MLons/MLons.hxx	(revision 5417)
+++ trunk/MagicSoft/Simulation/Detector/include-MLons/MLons.hxx	(revision 5418)
@@ -57,4 +57,8 @@
   Float_t  fFadcSlicesPerNanosec; // The sampling frequency (GHz) of the FADC
 
+  Int_t    fGainFluctuations; // Indicates whether or not  gain fluctuations have
+                              // been simulated for producing the NSB database
+
+
   TRandom  *RandomNumber; // RandomGenerator 
 
@@ -65,5 +69,5 @@
   MLons(Int_t in_shapeT, Float_t in_amplT, Float_t in_FwhmT,
 	Int_t in_shapeF, Float_t in_integF, Float_t in_FwhmF,
-	Float_t in_Fadc_Slices_per_ns);
+	Float_t in_Fadc_Slices_per_ns, Int_t in_Gain_Fluctuations);
 
   void Reset() ;
@@ -83,4 +87,6 @@
   Float_t GetFwhmFadc() ; 
   Float_t GetFadcSlicesPerNanosec() {return fFadcSlicesPerNanosec;}
+  Int_t   GetGainFluctuations() const { return fGainFluctuations; }
+
 
   void GetPath(Char_t *out);
