Index: trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx	(revision 676)
+++ trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx	(revision 677)
@@ -93,4 +93,78 @@
 }
 
+MFadc::MFadc(Float_t ampl, Float_t fwhm) { 
+  //
+  //  Constructor overloaded II 
+  //  
+  //  The procedure is the following: 
+  //  1. some parameters of the trigger are set to default.   
+  //     this parameters of the trigger may be changed
+  //  3. Then the all signals are set to zero
+  
+  fwhm_resp = fwhm       ; 
+  ampl_resp = ampl  ; 
+  
+  //
+  //    set up the response shape
+  // 
+  Int_t  i,j ; 
+  
+  Float_t   sigma ; 
+  Float_t   x, x0 ; 
+
+  sigma = fwhm_resp / 2.35 ; 
+  x0 = 3*sigma ; 
+  
+  Float_t   dX, dX2 ; 
+  
+  dX  = WIDTH_FADC_TIMESLICE / SUBBINS ; 
+  dX2 = dX/2. ; 
+  
+  for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) {  
+
+    x = i * dX + dX2 ; 
+    
+    //
+    //   the value 0.125 was introduced to normalize the things
+    //
+    sing_resp[i] = 0.125 *  
+      ampl_resp * expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ; 
+
+  } 
+
+  //
+  //    init the Random Generator for Electonic Noise
+  //
+
+  GenElec = new TRandom () ; 
+
+  //
+  //  set all the booleans used to FALSE, indicating that the pixel is not 
+  //  used in this event. 
+  //
+  
+  for ( i =0 ; i <CAMERA_PIXELS ; i++ ) { 
+    used [i] = FALSE ; 
+  }
+
+  //
+  //  set all pedestals to 0
+  //
+  
+  for ( i =0 ; i <CAMERA_PIXELS ; i++ ) { 
+    pedestal[i] = 0 ; 
+  }
+
+  //
+  //  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;
+    }
+  }
+
+}
   
 void MFadc::Reset() { 
@@ -208,4 +282,38 @@
   for ( i = 0 ; i<SLICES_MFADC; i++ ) {
     sig[iPix][i] = resp[i] ; 
+  }
+
+}
+
+void MFadc::AddSignal( Int_t iPix, Float_t resp[(Int_t) SLICES_MFADC]) { 
+  
+  //
+  // Adds signals to the fadc reponse from a given array
+  //
+  // parameter is the number of the pixel and the values to be added
+  //
+  //
+
+  Int_t i ; 
+  
+  //
+  //   first we have to check if the pixel iPix is used or not until now
+  //   if this is the first use, reset all signal for that pixels
+  // 
+  if ( iPix > CAMERA_PIXELS ) {
+    cout << " WARNING:  MFadc::Fill() :  iPix greater than CAMERA_PIXELS"
+	 << endl ;
+    exit(987) ; 
+  }
+
+  if ( used[iPix] == FALSE ) {
+    used [iPix] = TRUE ; 
+    
+    for (i=0; i < SLICES_MFADC; i++ ) {
+      sig[iPix][i] = 0. ; 
+    }
+  }
+  for ( i = 0 ; i<SLICES_MFADC; i++ ) {
+    sig[iPix][i] += resp[i] ; 
   }
 
@@ -405,4 +513,5 @@
   }  
 } 
+
 void MFadc::GetResponse( Float_t *resp ) {
   // ============================================================
@@ -415,5 +524,16 @@
   }
 }
- 
+
+void MFadc::GetPedestals( UChar_t *offset) {
+  // ============================================================
+  //
+  //    puts the standard response function into the array resp
+  
+  for ( Int_t i=0; i< CAMERA_PIXELS; i++ ) {
+
+    offset[i] = pedestal[i] ; 
+  }
+}
+
 void MFadc::TriggeredFadc(Float_t time) {
   
