Index: trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 5599)
+++ 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
 //
Index: trunk/MagicSoft/Simulation/Detector/Camera/creadparam.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/creadparam.cxx	(revision 5599)
+++ trunk/MagicSoft/Simulation/Detector/Camera/creadparam.cxx	(revision 5600)
@@ -19,7 +19,7 @@
 //=
 //= $RCSfile: creadparam.cxx,v $
-//= $Revision: 1.34 $
-//= $Author: moralejo $ 
-//= $Date: 2004-11-17 11:36:07 $
+//= $Revision: 1.35 $
+//= $Author: MAGIC $ 
+//= $Date: 2004-12-15 01:56:39 $
 //=
 //=//////////////////////////////////////////////////////////////////////
@@ -106,4 +106,7 @@
                                 // time window and the trigger instant.
 
+static float pmt_jitter = 0.25; // Time jitter in ns (sigma of gaussian)
+                                // of the PMT (per phe)
+
 static float CTcoor[MAX_NUMBER_OF_CTS][3]; 
 
@@ -563,4 +566,9 @@
       break;
 
+    case pmt_jitter_ns:
+
+      sscanf(line, "%s %f", token, &pmt_jitter);
+      break;
+
 
     case sigma_xy_cm_spot:
@@ -1389,4 +1397,10 @@
 }
 
+float get_pmt_jitter_ns(){
+
+  return pmt_jitter;
+
+}
+
 float get_telescope_location_cm(int j, int icoor){
 
@@ -1430,4 +1444,7 @@
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.34  2004/11/17 11:36:07  moralejo
+// *** empty log message ***
+//
 // Revision 1.33  2004/10/26 13:58:59  moralejo
 //
Index: trunk/MagicSoft/Simulation/Detector/Camera/creadparam.h
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/creadparam.h	(revision 5599)
+++ trunk/MagicSoft/Simulation/Detector/Camera/creadparam.h	(revision 5600)
@@ -19,7 +19,7 @@
 //=
 //= $RCSfile: creadparam.h,v $
-//= $Revision: 1.30 $
-//= $Author: moralejo $ 
-//= $Date: 2004-11-17 11:36:07 $
+//= $Revision: 1.31 $
+//= $Author: MAGIC $ 
+//= $Date: 2004-12-15 01:56:39 $
 //=
 //=//////////////////////////////////////////////////////////////////////
@@ -118,4 +118,5 @@
 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(pmt_jitter_ns), /* Sets the time jitter of each phe in the PMT */ \
 T(end_file)         /* end of the parameters file */
 
@@ -193,4 +194,5 @@
 float get_telescope_location_cm(int j, int icoor);
 float get_mirror_fraction(int j);
+float get_pmt_jitter_ns();
 
 int   is_calibration_run();
@@ -214,4 +216,7 @@
 /*
  * $Log: not supported by cvs2svn $
+ * Revision 1.30  2004/11/17 11:36:07  moralejo
+ * *** empty log message ***
+ *
  * Revision 1.29  2004/10/26 13:58:59  moralejo
  *
