Index: trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 5419)
+++ trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 5600)
@@ -11,31 +11,7 @@
 // @date        Thu May  7 16:24:22 1998
 //
-//----------------------------------------------------------------------
-//
-// Created: Thu May  7 16:24:22 1998
-// Author:  Jose Carlos Gonzalez
-// Purpose: Program for reflector simulation
-// Notes:   See files README for details
-//    
-//----------------------------------------------------------------------
-//
-// $RCSfile: camera.cxx,v $
-// $Revision: 1.83 $
-// $Author: moralejo $ 
-// $Date: 2004-11-17 11:43:13 $
-//
-////////////////////////////////////////////////////////////////////////
-// @tableofcontents @coverpage
 
 //=-----------------------------------------------------------
 //!@section Source code of |camera.cxx|.
-
-/*!@"
-
-  In this section we show the (commented) code of the program for the
-  read-out of the output files generated by the simulator of the
-  reflector, |reflector 0.3|.
-
-  @"*/
 
 //=-----------------------------------------------------------
@@ -229,5 +205,5 @@
 static  float Azimutal = 90.0;
 
-//@: Miss Pointing Simulation
+//@: Mispointing Simulation
 static   int missPointing = 0;
 static   float missP_x = 0.0;
@@ -238,4 +214,7 @@
 static  float Spot_y=0.0;
 static  float Spotsigma=0.0;
+
+//@: PMT time jitter
+static  float pmt_jitter=0.25;
 
   
@@ -737,4 +716,5 @@
   missPointing = get_misspointing(&missP_x,&missP_y);
   Spotsigma = get_sigma_xy_cm_spot(&Spot_x,&Spot_y);
+  pmt_jitter = get_pmt_jitter_ns();
 
 
@@ -2967,10 +2947,11 @@
     McConfigRunHeader[ict]->InitSizePMTs(ct_NPixels);
     for(int i=0; i<(Int_t)((MGeomCam*)(camgeom.UncheckedAt(ict)))->GetNumPixels();i++){
-      McConfigRunHeader[ict]->AddPMT(i);
-      MGeomPMT &pmt  = McConfigRunHeader[ict]->GetPMT(i);
-      qe_pmt.Set(pointsQE[ict],QE[ict][i][1]);
-      wav_pmt.Set(pointsQE[ict],QElambda);
-      pmt.SetArraySize(pointsQE[ict]);
-      pmt.SetPMTContent(i,wav_pmt,qe_pmt);
+	McConfigRunHeader[ict]->SetPmtTimeJitter(pmt_jitter);
+	McConfigRunHeader[ict]->AddPMT(i);
+	MGeomPMT &pmt  = McConfigRunHeader[ict]->GetPMT(i);
+	qe_pmt.Set(pointsQE[ict],QE[ict][i][1]);
+	wav_pmt.Set(pointsQE[ict],QElambda);
+	pmt.SetArraySize(pointsQE[ict]);
+	pmt.SetPMTContent(i,wav_pmt,qe_pmt);
     }
     
@@ -4076,5 +4057,6 @@
   static UInt_t seed = (UInt_t)(get_seeds(0)*get_seeds(1));
 
-  Float_t t;
+  float time;
+  float pmtjit;
 
   // reset variables
@@ -4119,7 +4101,7 @@
     //  Check if photon is inside trigger time range
 
-    t = photon.get_t() ;
-
-    if (t-*tmin_ns>TOTAL_TRIGGER_TIME) {
+    time = photon.get_t() ;
+
+    if (time-*tmin_ns>TOTAL_TRIGGER_TIME) {
         continue;
     }
@@ -4216,5 +4198,5 @@
 
     //
-    // Apply incient angular correction due to Light Guides, plexiglas,
+    // Apply incident angular correction due to Light Guides, plexiglas,
     // 1st dynode collection efficiency, double crossings... etc. 
     // This information is contained in the file Data/LightCollection.dat
@@ -4260,9 +4242,17 @@
     nphe[ipixnum] += 1.0;
 
+    //
+    // PMT time jitter: gaussian, not negative (MTrigger::FillShow does
+    // not accept negative times!)
+    //
+    do 
+      pmtjit = random.Gaus(3.*pmt_jitter, pmt_jitter);
+    while(pmtjit<0.);
 
     // store the new photoelectron
 
-    fadc->Fill(ipixnum,(t-*tmin_ns) + fadc_jitter , 
-	       trigger->FillShow(ipixnum, t-*tmin_ns + fadc_jitter),
+    fadc->Fill(ipixnum,
+	       (time-*tmin_ns) + pmtjit + fadc_jitter, 
+	       trigger->FillShow(ipixnum, time-*tmin_ns + pmtjit + fadc_jitter),
 	       !((*camgeom)[ipixnum].GetD()>(*camgeom)[0].GetD()));
     
@@ -4770,5 +4760,7 @@
   float **qept;
   float radius_mm, focal_dist_mm;
-  int total_photons;
+  int   total_photons;
+  float pmtjit;
+
   static UInt_t seed = (UInt_t)(get_seeds(0)*get_seeds(1));
 
@@ -4939,8 +4931,16 @@
       nphe[ipixnum] += 1.;
 
+      //
+      // PMT time jitter: gaussian, not negative (MTrigger::FillShow does
+      // not accept negative times!)
+      //
+      do 
+	pmtjit = random.Gaus(3.*pmt_jitter, pmt_jitter);
+      while(pmtjit<0.);
+
       // store the new photoelectron
 
-      fadc->Fill(ipixnum, time + fadc_jitter, 
-		 trigger->FillShow(ipixnum, time + fadc_jitter),
+      fadc->Fill(ipixnum, time + pmtjit + fadc_jitter, 
+		 trigger->FillShow(ipixnum, time + pmtjit + fadc_jitter),
 		 !((*camgeom)[ipixnum].GetD()>(*camgeom)[0].GetD()));
     
@@ -4963,4 +4963,13 @@
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.83  2004/11/17 11:43:13  moralejo
+//
+//  Made the necessary changes in starresponse to account for the new option
+//  to switch off gain fluctuations for the NSB noise database generation.
+//  The option in the Star Response card is "gain_fluctuations_off". The
+//  version number of the NSB database has been updated to 1004 (see
+//  MStarLight.hxx), now including information on whether the gain
+//  fluctuations were on or off when the NSB database was generated.
+//
 // Revision 1.82  2004/11/17 11:34:49  moralejo
 //
