Index: trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 1089)
+++ trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 1195)
@@ -21,7 +21,7 @@
 //
 // $RCSfile: camera.cxx,v $
-// $Revision: 1.30 $
+// $Revision: 1.31 $
 // $Author: blanch $ 
-// $Date: 2001-11-27 09:49:54 $
+// $Date: 2002-01-18 17:41:02 $
 //
 ////////////////////////////////////////////////////////////////////////
@@ -240,8 +240,10 @@
 static float Trigger_response_fwhm = 2.0;
 static float Trigger_overlaping_time= 0.25;
+static float Trigger_noise= 0.3;
 
 //@: Properties of the FADC
 static float FADC_response_ampl = MFADC_RESPONSE_AMPLITUDE;
 static float FADC_response_fwhm = MFADC_RESPONSE_FWHM;
+static float FADC_noise = 2.0;
 
 //@: Trigger conditions for a single trigger mode
@@ -431,4 +433,6 @@
   int i, j, k;                //@< simple counters
 
+  int addElecNoise;           //@< Will we add ElecNoise?
+
   int simulateNSB;            //@< Will we simulate NSB?
   int nphe2NSB;               //@< From how many phe will we simulate NSB?
@@ -621,5 +625,6 @@
 
   qTailCut = get_tail_cut();
-  simulateNSB = get_nsb( &meanNSB, &nphe2NSB );
+  addElecNoise = add_elec_noise(&FADC_noise, &Trigger_noise);
+  simulateNSB = get_nsb( &meanNSB, &nphe2NSB );  
   countIslands = get_islands_cut( &nIslandsCut );
 
@@ -950,6 +955,7 @@
 
   for(i=0;i<CAMERA_PIXELS;i++){
-      fadc_elecnoise[i]=2.0;
-  }
+      fadc_elecnoise[i]=FADC_noise;
+  }
+
   fadc.GetPedestals(&fadc_pedestals[0]);
 
@@ -1380,7 +1386,9 @@
 	//   This is done inside the class MTrigger by the method ElecNoise. 
 	//   
-	Trigger.ElecNoise() ;
-	
-	fadc.ElecNoise() ;
+	if (addElecNoise){	
+	    Trigger.ElecNoise(Trigger_noise) ;
+	    
+	    fadc.ElecNoise(FADC_noise) ;
+	}
 
 	//  We should simulate the AC coupling behaviour:
@@ -1441,6 +1449,4 @@
 		  if(Lev0!=0)
 		      Lev1=Trigger.FirstLevel();
-		  if (Write_McTrig)
-		    McTrig[iconcount]->SetFirstLevel (Lev1);
 		  if(Lev1>0) {
 		    btrigger= 1;
@@ -1448,16 +1454,18 @@
 		  }
 		  
+		  Lev0=1;
 		  if(Lev1==0 && (Write_All_Images || btrigger)){
 		    btrigger= 1;
 		    Lev1=1;
+		    Lev0=0;
 		  }
 		  numPix=0;
 		  for (Int_t ii=0;ii<Lev1;ii++){
-		    if (Write_McTrig)
-		      McTrig[iconcount]->SetTime(Trigger.GetFirstLevelTime(ii),ii+1);
-		    if (Write_McTrig){
-		      Trigger.GetMapDiskriminator(trigger_map);
-		      McTrig[iconcount]->SetMapPixels(trigger_map,ii);
-		    }
+		      if (Write_McTrig){
+			  McTrig[iconcount]->SetFirstLevel ((ii+1)*Lev0);
+			  McTrig[iconcount]->SetTime(Trigger.GetFirstLevelTime(ii),ii+1);
+			  Trigger.GetMapDiskriminator(trigger_map);
+			  McTrig[iconcount]->SetMapPixels(trigger_map,ii);
+		      }
 		    //
 		    //  fill inside the class fadc the member output
@@ -1477,5 +1485,5 @@
 			  fadcValues->AddAt(fadc.GetFadcSignal(i,j),j);
 			}
-			EvtData[iconcount]->AddPixel(i+1000*ii,fadcValues,0);
+			EvtData[iconcount]->AddPixel(i,fadcValues,0);
 		      }
 		    }
@@ -1565,12 +1573,12 @@
 	  if ( Lev0 > 0 || Write_All_Images) {
 	    Lev1= Trigger.FirstLevel();
-	    if (Write_McTrig)
-	      McTrig[0]->SetFirstLevel (Lev1);
 	  }
 	  if (Lev1>0){
 	    ++ntrigger;
 	  }
+	  Lev0=1;
 	  if (Lev1==0 && Write_All_Images){ 
 	    Lev1=1;
+	    Lev0=0;
 	  }
 
@@ -1584,8 +1592,7 @@
 	    fadc.TriggeredFadc(Trigger.GetFirstLevelTime(ii));
 
-	    if (Write_McTrig)
+	    if (Write_McTrig){
+	      McTrig[0]->SetFirstLevel ((ii+1)*Lev0);
 	      McTrig[0]->SetTime(Trigger.GetFirstLevelTime(ii),ii+1);
-
-	    if (Write_McTrig){
 	      Trigger.GetMapDiskriminator(trigger_map);
 	      McTrig[0]->SetMapPixels(trigger_map,ii);
@@ -1608,5 +1615,5 @@
 		  fadcValues->AddAt(fadc.GetFadcSignal(i,j),j);
 		}
-		EvtData[0]->AddPixel(i+ii*1000,fadcValues,0);
+		EvtData[0]->AddPixel(i,fadcValues,0);
 	      }
 	    }	    
@@ -3310,4 +3317,7 @@
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.30  2001/11/27 09:49:54  blanch
+// Fixing bug which was treating wrongly the extension of star photons.
+//
 // Revision 1.29  2001/11/14 17:38:23  blanch
 // Sveral changes have been done:
@@ -3390,4 +3400,7 @@
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.30  2001/11/27 09:49:54  blanch
+// Fixing bug which was treating wrongly the extension of star photons.
+//
 // Revision 1.29  2001/11/14 17:38:23  blanch
 // Sveral changes have been done:
