Index: trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx	(revision 378)
+++ trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx	(revision 396)
@@ -33,5 +33,5 @@
   //    set up the response shape
   // 
-  Int_t  i ; 
+  Int_t  i,j ; 
   
   Float_t   sigma ; 
@@ -72,4 +72,15 @@
     used [i] = FALSE ; 
   }
+
+  //
+  //  set tha values of FADC slices that would be read after trigger to zero
+  //
+  
+  for (i=0; i <CAMERA_PIXELS; i++){
+    for (j=0; j<FADC_SLICES;j++){
+       output[i][j]=0;
+    }
+  }
+
 }
 
@@ -79,9 +90,18 @@
   //  set all values of the signals to zero
   //
-  Int_t  i ; 
+  Int_t  i,j ; 
   
   for ( i =0 ; i <CAMERA_PIXELS ; i++ ) {
     used [i] = FALSE ; 
   } 
+  //
+  //  set tha values of FADC slices that would be read after trigger to zero
+  //
+  
+  for (i=0; i <CAMERA_PIXELS; i++){
+    for (j=0; j<FADC_SLICES;j++){
+       output[i][j]=0;
+    }
+  }
 }
 
@@ -158,8 +178,8 @@
   for ( Int_t i = 0 ; i < CAMERA_PIXELS; i++) {
     if ( used [i] == TRUE ) {
-      
       for ( Int_t is=0 ; is< SLICES_MFADC ; is++ ) {
 
 	sig[i][is] += GenElec->Gaus(0., 2.) ; 
+
       }
     }
@@ -203,6 +223,5 @@
   Float_t t ; 
 
-  t = time - 10. ; // to show also the start of the pulse before the
-                   // the trigger time
+  (0 > time - TIME_BEFORE_TRIGGER)? t=0: t=(time-TIME_BEFORE_TRIGGER) ; // to show also the start of the pulse before the trigger time
 
   if ( t < 0. ) {
@@ -235,5 +254,39 @@
 } 
 
-
+void MFadc::TriggeredFadc(Float_t time) {
+  
+  //
+  //    first of all we subtract from the time a offset (8 ns) 
+  // 
+  
+  Float_t t ; 
+
+  (0>time-TIME_BEFORE_TRIGGER)? t=0: t=(time-TIME_BEFORE_TRIGGER) ; // to show also the start of the pulse before the trigger time
+
+  if ( t < 0. ) {
+    cout << " WARNING!! FROM MFADC::SCAN(t) " << endl ; 
+    exit (776) ;  
+  }
+
+  //
+  //  calculate the first slice to write out
+  // 
+  
+  Int_t iFirstSlice ; 
+  Int_t i;
+
+  iFirstSlice = (Int_t) ( t /  WIDTH_FADC_TIMESLICE ) ; 
+
+  for ( Int_t ip=0; ip<CAMERA_PIXELS; ip++ ) {
+    
+    if ( used[ip] == kTRUE ) { 
+      i=0;
+      for ( Int_t is=iFirstSlice ; is < (iFirstSlice+FADC_SLICES); is++ ) {
+	output[ip][i++]=(UChar_t) sig[ip][is];
+      }
+
+    }
+  }  
+} 
 
 void MFadc::ShowSignal (MMcEvt *McEvt, Float_t trigTime) { 
@@ -310,4 +363,11 @@
 }
 
-
-
+Float_t MFadc::GetFadcSignal(Int_t pixel, Int_t slice){
+
+  //  It returns the analog signal for a given pixel and a given FADC
+  //  time slice which would be read.
+
+  return (output[pixel][slice]);
+}
+
+
