Index: trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 5408)
+++ trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 5417)
@@ -21,7 +21,7 @@
 //
 // $RCSfile: camera.cxx,v $
-// $Revision: 1.81 $
+// $Revision: 1.82 $
 // $Author: moralejo $ 
-// $Date: 2004-11-04 22:00:51 $
+// $Date: 2004-11-17 11:34:49 $
 //
 ////////////////////////////////////////////////////////////////////////
@@ -839,5 +839,25 @@
 
   if (! apply_gain_fluctuations())
-    log(SIGNATURE, "PMT gain fluctuations have been switched OFF in the input card.\n\n"); 
+    {
+      log(SIGNATURE, "PMT gain fluctuations for the signal phes have been switched OFF");
+      log(SIGNATURE, "in the input card.\n\n"); 
+    }
+  if (! apply_noise_gain_fluctuations())
+    {
+      log(SIGNATURE, "PMT gain fluctuations for the NSB phes have been switched OFF\n");
+      log(SIGNATURE, "in the input card.\n\n"); 
+    }
+
+  if ( apply_gain_fluctuations() && !apply_noise_gain_fluctuations())
+    {
+      log(SIGNATURE, "Warning: you switched off PMT gain fluctuations for the NSB\n");
+      log(SIGNATURE, "photoelectrons, but not for the signal photoelectrons.\n\n");
+    }
+  else if ( !apply_gain_fluctuations() && apply_noise_gain_fluctuations())
+    {
+      log(SIGNATURE, "Warning: you switched off PMT gain fluctuations for the signal\n");
+      log(SIGNATURE, "photoelectrons, but not for the NSB photoelectrons.\n");
+    }
+
 
   // log flags information
@@ -1223,5 +1243,8 @@
     HeaderTrig[0]->SetGate(Trigger_gate_length);
     HeaderTrig[0]->SetElecNoise(Trigger_noise);
-  }
+    HeaderTrig[0]->SetGainFluctuations(Trigger_CT[0]->GetGainFluctuations());
+    HeaderTrig[0]->SetNoiseGainFluctuations((Bool_t)apply_noise_gain_fluctuations());
+  }
+
   if(!Trigger_Loop && Write_McTrig && ct_Number>1){
     for(int i=0;i<ct_Number;i++){
@@ -1234,5 +1257,7 @@
       HeaderTrig[i]->SetGate(Trigger_gate_length);
       HeaderTrig[i]->SetElecNoise(Trigger_noise);
-    }    
+      HeaderTrig[i]->SetGainFluctuations(Trigger_CT[i]->GetGainFluctuations());
+      HeaderTrig[i]->SetNoiseGainFluctuations((Bool_t)apply_noise_gain_fluctuations());
+    }
   }  
   if(Trigger_Loop && Write_McTrig){
@@ -1255,4 +1280,6 @@
 	  HeaderTrig[iconcount]->SetGate(Trigger_gate_length);
 	  HeaderTrig[iconcount]->SetElecNoise(Trigger_noise);
+	  HeaderTrig[iconcount]->SetGainFluctuations(Trigger_CT[0]->GetGainFluctuations());
+	  HeaderTrig[iconcount]->SetNoiseGainFluctuations((Bool_t)apply_noise_gain_fluctuations());
 	  iconcount++;
 	}
@@ -1285,4 +1312,12 @@
     HeaderFadc[0]->SetElecNoise(&fadc_elecnoise[0], &fadc_diginoise[0],
 				((MGeomCam*)(camgeom.UncheckedAt(0)))->GetNumPixels());
+
+    //
+    // Fill also the flag indicating whether the PMT gain fluctuations 
+    // were simulated or not:
+    //
+    HeaderFadc[0]->SetGainFluctuations(Trigger_CT[0]->GetGainFluctuations());
+    HeaderFadc[0]->SetNoiseGainFluctuations((Bool_t)apply_noise_gain_fluctuations());
+
   }
 
@@ -1309,4 +1344,12 @@
       HeaderFadc[i]->SetElecNoise(&fadc_elecnoise[0], &fadc_diginoise[0],
 				  ((MGeomCam*)(camgeom.UncheckedAt(i)))->GetNumPixels());
+
+      //
+      // Fill also the flag indicating whether the PMT gain fluctuations 
+      // were simulated or not:
+      //
+      HeaderFadc[i]->SetGainFluctuations(Trigger_CT[i]->GetGainFluctuations());
+      HeaderFadc[i]->SetNoiseGainFluctuations((Bool_t)apply_noise_gain_fluctuations());
+
     }
   }
@@ -1338,4 +1381,8 @@
 	  HeaderFadc[iconcount]->SetElecNoise(&fadc_elecnoise[0],
 					      &fadc_diginoise[0],ct_NPixels);
+
+	  HeaderFadc[iconcount]->SetGainFluctuations(Trigger_CT[0]->GetGainFluctuations());
+	  HeaderFadc[iconcount]->SetNoiseGainFluctuations((Bool_t)apply_noise_gain_fluctuations());
+
 	  iconcount++;
 	}
@@ -1449,5 +1496,5 @@
   MLons lons(0, Trigger_response_ampl, Trigger_response_fwhm,
 	     FADC_shape, FADC_response_integ, FADC_response_fwhm,
-	     FADC_slices_per_ns);
+	     FADC_slices_per_ns, apply_noise_gain_fluctuations());
 
   lons.SetSeed(((UInt_t)(get_seeds(1)*get_seeds(1)*get_seeds(0))));
@@ -1458,5 +1505,5 @@
   MLons lons_outer(0, Trigger_response_ampl, Trigger_response_fwhm,
 		   FADC_shape_out,FADC_resp_integ_out,FADC_resp_fwhm_out,
-		   FADC_slices_per_ns);
+		   FADC_slices_per_ns, apply_noise_gain_fluctuations());
 
   lons_outer.SetSeed(((UInt_t)(get_seeds(1)*get_seeds(0)*get_seeds(0))));
@@ -1617,6 +1664,6 @@
     }
     for(int ie=0; ie < empty_events; ie++){
-      Fadc_CT[ict]->Reset() ; 
-      if (addElecNoise){	
+      Fadc_CT[ict]->Reset(); 
+      if (addElecNoise){
 	Fadc_CT[ict]->ElecNoise() ;
       }
@@ -1639,6 +1686,6 @@
 		  else
 		    {
-		      k=lons.GetResponse(nsb_phepns[ict][ui],0.01,
-					 & nsb_trigresp[0],& nsb_fadcresp[0]);
+		      k = lons.GetResponse(nsb_phepns[ict][ui],0.01,
+					   & nsb_trigresp[0],& nsb_fadcresp[0]);
 		    }
 
@@ -1688,10 +1735,4 @@
 				      ((MGeomCam*)(camgeom.UncheckedAt(ict)))
 				      ->GetNumPixels());
-
-    //
-    // Fill also the flag indicating whether the PMT gain fluctuations 
-    // were simulated or not:
-    //
-    HeaderFadc[ict]->SetGainFluctuations(Trigger_CT[ict]->GetGainFluctuations());
   }
 
@@ -4922,4 +4963,11 @@
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.81  2004/11/04 22:00:51  moralejo
+//
+//  Removed unused variables fTelesTheta and fTelesPhi from MMcRunHeader. They
+//  were not useful because telescope orientation may change from event to
+//  event. Added fMirrorFraction to the MMcConfigRunHeader container in the
+//  camera output.
+//
 // Revision 1.80  2004/10/26 19:21:05  moralejo
 //
