Index: trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 6386)
+++ trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 6560)
@@ -141,5 +141,5 @@
 //@: flag: TRUE: write the event headers of all events to output; 
 //@:       FALSE: only triggered showers
-static int Write_All_Event_Headers = FALSE;
+static int Write_All_Event_Headers = TRUE;
 
 static int Write_McEvt  = TRUE;
@@ -2011,5 +2011,7 @@
 			    fadc_jitter[ict]);
 
-	  inumphe=(inumphe<inumphe_CT[ict])?inumphe_CT[ict]:inumphe;
+	  inumphe = (inumphe < inumphe_CT[ict])? inumphe_CT[ict] : inumphe;
+	  // inumphe will be the maximum number of phe in any of the telescopes
+
 
 	  if( k != 0 ){ // non-zero return value means error
@@ -2021,5 +2023,5 @@
 	// NSB simulation
 
-	if(simulateNSB && nphe2NSB<=inumphe)
+	if(simulateNSB && inumphe >= nphe2NSB)
 	  {
 
@@ -2083,5 +2085,5 @@
 	    }
 	  
-	  }// end if(simulateNSB && nphe2NSB<=inumphe_CT[0]) ...
+	  }// end if(simulateNSB && inumphe_CT[0] >= nphe2NSB) ...
 
 
@@ -2151,8 +2153,8 @@
 	for(int ict=0;ict<ct_Number;ict++) 
 	  {
-	    if (addElecNoise && nphe2NSB<=inumphe)
+	    if (addElecNoise && inumphe >= nphe2NSB)
 	      {	
-		Trigger_CT[ict]->ElecNoise(Trigger_noise) ;
-		Fadc_CT[ict]->ElecNoise() ;
+		Trigger_CT[ict]->ElecNoise(Trigger_noise);
+		Fadc_CT[ict]->ElecNoise();
 	      }
 	  }
@@ -2187,5 +2189,5 @@
 		    // Rise the discrimnator threshold to avoid huge rates
 
-		    if(riseDiskThres>0.0 && simulateNSB && nphe2NSB<=inumphe)
+		    if(riseDiskThres>0.0 && simulateNSB && inumphe >= nphe2NSB)
 		      for(int ii=0;ii<ct_NPixels;ii++)
 			if( nsb_phepns_rotated[0][ii]>riseDiskThres)
@@ -2471,5 +2473,5 @@
 
 	      // Rise the discrimnator threshold to avoid huge rates
-	      if(riseDiskThres>0.0 && simulateNSB && nphe2NSB<=inumphe)
+	      if(riseDiskThres>0.0 && simulateNSB && inumphe >= nphe2NSB)
 		for(int ii=0;ii<ct_NPixels;ii++)
 		  {
@@ -2564,26 +2566,32 @@
 		EvtHeader[ict]->SetTriggerPattern((UInt_t)MTriggerPattern::kTriggerLvl1);
 
-		//   fill pixel information
-	      
-		if (Lev1MT[ict] /* || Write_All_Event_Headers */){
-		   if (addElecNoise) Fadc_CT[ict]->DigitalNoise();
-		  for(UInt_t i=0;
-		      i<((MGeomCam*)(camgeom.UncheckedAt(ict)))->GetNumPixels();
-		      i++){
+		// Fill pixel information
+		// AM 17/2/2005: added condition on inumphe. Noise is not generated for 
+		// events with less than phe2NSB photoelectrons, and then it is better not
+		// to write the images of those events to the output, so that we avoid them
+		// to be processed (with no noise) later in the chain.
+		
+		if (Lev1MT[ict] && inumphe >= nphe2NSB)
+		  {
+		    if (addElecNoise) 
+		      Fadc_CT[ict]->DigitalNoise();
+		    for(UInt_t i=0;
+			i<((MGeomCam*)(camgeom.UncheckedAt(ict)))->GetNumPixels();
+			i++){
 //
 // AM 15 01 2004 Commented out "continue" statement, so that also pixels
 // containing no C-photons will be written to the output in case of running
-// camera with no noise added to the signal.	      
+// camera with no noise added to the signal.
 // 		    if(!Fadc_CT[ict]->IsPixelUsed(i)) continue;
 //
-		    for (j = 0; j < FADC_slices_written; j++)
-		      {
-			fadcValues->AddAt(Fadc_CT[ict]->GetFadcSignal(i,j),j);
-			fadcValuesLow->AddAt(Fadc_CT[ict]->GetFadcLowGainSignal(i,j),j);
-		      }
-		    EvtData[ict]->AddPixel(i,fadcValues,0);
-		    EvtData[ict]->AddPixel(i,fadcValuesLow,kTRUE);
+		      for (j = 0; j < FADC_slices_written; j++)
+			{
+			  fadcValues->AddAt(Fadc_CT[ict]->GetFadcSignal(i,j),j);
+			  fadcValuesLow->AddAt(Fadc_CT[ict]->GetFadcLowGainSignal(i,j),j);
+			}
+		      EvtData[ict]->AddPixel(i,fadcValues,0);
+		      EvtData[ict]->AddPixel(i,fadcValuesLow,kTRUE);
+		    }
 		  }
-		}
 	      }	
 	    }
@@ -5023,4 +5031,14 @@
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.88  2005/02/11 20:00:01  moralejo
+//
+// Added to output container "MMcEvtBasic" with the most important MC
+// parameters, to be kept for all events (triggered or not) through
+// the whole analysis chain in order to allow the calculation of effective
+// areas.
+//
+// Updated version of MRawRunHeader from 4 to 5. This means the trigger and
+// calibration patterns are correctly set and can be decoded.
+//
 // Revision 1.87  2005/02/10 19:28:10  moralejo
 //
Index: trunk/MagicSoft/Simulation/Detector/Camera/creadparam.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/creadparam.cxx	(revision 6386)
+++ trunk/MagicSoft/Simulation/Detector/Camera/creadparam.cxx	(revision 6560)
@@ -19,7 +19,7 @@
 //=
 //= $RCSfile: creadparam.cxx,v $
-//= $Revision: 1.36 $
+//= $Revision: 1.37 $
 //= $Author: moralejo $ 
-//= $Date: 2005-02-10 19:28:10 $
+//= $Date: 2005-02-17 09:15:28 $
 //=
 //=//////////////////////////////////////////////////////////////////////
@@ -62,5 +62,5 @@
 static int nSkip=0;
 static int Data_From_STDIN = FALSE;
-static int Write_All_Event_Headers = FALSE;
+static int Write_All_Event_Headers = TRUE;
 static int Write_McEvt  = TRUE;
 static int Write_McTrig = FALSE;
@@ -424,8 +424,8 @@
       break;
 
-    case write_all_event_headers:  //@< to write ALL the event headers
+    case no_write_all_event_headers:  //@< to write ALL the event headers
           
       // change boolean value
-      Write_All_Event_Headers = TRUE;
+      Write_All_Event_Headers = FALSE;
 
       break;
@@ -1445,4 +1445,11 @@
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.36  2005/02/10 19:28:10  moralejo
+//
+// Substituted input card option "write_all_events" by
+// "write_all_event_headers". If set, this will make camera to write out
+// the event headers of all the processed events, no matter whether they
+// have triggered or not.
+//
 // Revision 1.35  2004/12/15 01:56:39  MAGIC
 //
Index: trunk/MagicSoft/Simulation/Detector/Camera/creadparam.h
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/creadparam.h	(revision 6386)
+++ trunk/MagicSoft/Simulation/Detector/Camera/creadparam.h	(revision 6560)
@@ -19,7 +19,7 @@
 //=
 //= $RCSfile: creadparam.h,v $
-//= $Revision: 1.32 $
+//= $Revision: 1.33 $
 //= $Author: moralejo $ 
-//= $Date: 2005-02-10 19:28:10 $
+//= $Date: 2005-02-17 09:15:28 $
 //=
 //=//////////////////////////////////////////////////////////////////////
@@ -91,5 +91,6 @@
 T(data_from_stdin), /* to read data from STDIN */ \
 T(skip),            /* skip pathological showers */ \
-T(write_all_event_headers),/* write to file .phe ALL event headers (even w.o. trigger)*/ \
+T(no_write_all_event_headers),/* do NOT write to output file all event
+				 event headers (only those with trigger!)*/ \
 T(nowrite_McEvt),   /* nowrite to file .root McEvt infos */ \
 T(write_McTrig),    /* write to file .root McTrig infos */ \
@@ -216,4 +217,11 @@
 /*
  * $Log: not supported by cvs2svn $
+ * Revision 1.32  2005/02/10 19:28:10  moralejo
+ *
+ * Substituted input card option "write_all_events" by
+ * "write_all_event_headers". If set, this will make camera to write out
+ * the event headers of all the processed events, no matter whether they
+ * have triggered or not.
+ *
  * Revision 1.31  2004/12/15 01:56:39  MAGIC
  *
