Index: trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx	(revision 1065)
+++ trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx	(revision 1066)
@@ -1,3 +1,3 @@
-/////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////
 //
 //  MFadc
@@ -18,80 +18,5 @@
 #include "MGFadcSignal.hxx"
 
-MFadc::MFadc() { 
-  //
-  //  default constructor 
-  //  
-  //  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 = MFADC_RESPONSE_FWHM       ; 
-  ampl_resp = MFADC_RESPONSE_AMPLITUDE  ; 
-  
-  //
-  //    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.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;
-    }
-  }
-
-}
-
-MFadc::MFadc(Float_t ampl, Float_t fwhm) { 
+MFadc::MFadc(Float_t ampl, Float_t fwhm) {
   //
   //  Constructor overloaded II 
@@ -108,5 +33,5 @@
   //    set up the response shape
   // 
-  Int_t  i,j ; 
+  Int_t  i ;
   
   Float_t   sigma ; 
@@ -139,12 +64,5 @@
   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 ; 
-  }
+  Reset();
 
   //
@@ -155,35 +73,13 @@
     pedestal[i] = 0.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() { 
-  //
-  //  set all values of the signals to zero
-  //
-  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;
-    }
-  }
+    //
+    //  set all values of the signals to zero
+    //  set tha values of FADC slices that would be read after trigger to zero
+    //
+    memset(used, 0, CAMERA_PIXELS*sizeof(Bool_t));
+    memset(output, 0, CAMERA_PIXELS*FADC_SLICES*sizeof(UChar_t));
 }
 
@@ -213,5 +109,5 @@
     used [iPix] = TRUE ; 
     
-    for (i=0; i < SLICES_MFADC; i++ ) {
+    for (i=0; i < (Int_t) SLICES_MFADC; i++ ) {
       sig[iPix][i] = 0. ; 
     }
@@ -240,5 +136,5 @@
     for ( i = 0 ; i<RESPONSE_SLICES; i++ ) {
       ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ; 
-      if ( (ichanfadc) < SLICES_MFADC ) {  
+      if ( (ichanfadc) < (Int_t)SLICES_MFADC ) {  
 	sig[iPix][ichanfadc] += (amplitude * sing_resp[i] )  ; 
       } 
@@ -276,9 +172,9 @@
     used [iPix] = TRUE ; 
     
-    for (i=0; i < SLICES_MFADC; i++ ) {
+    for (i=0; i < (Int_t)SLICES_MFADC; i++ ) {
       sig[iPix][i] = 0. ; 
     }
   }
-  for ( i = 0 ; i<SLICES_MFADC; i++ ) {
+  for ( i = 0 ; i<(Int_t)SLICES_MFADC; i++ ) {
     sig[iPix][i] = resp[i] ; 
   }
@@ -310,9 +206,9 @@
     used [iPix] = TRUE ; 
     
-    for (i=0; i < SLICES_MFADC; i++ ) {
+    for (i=0; i < (Int_t)SLICES_MFADC; i++ ) {
       sig[iPix][i] = 0. ; 
     }
   }
-  for ( i = 0 ; i<SLICES_MFADC; i++ ) {
+  for ( i = 0 ; i<(Int_t)SLICES_MFADC; i++ ) {
     sig[iPix][i] += resp[i] ; 
   }
@@ -371,5 +267,5 @@
 
   for(i=0;i<CAMERA_PIXELS;i++)
-    for(j=0;j<SLICES_MFADC;j++)
+    for(j=0;j<(Int_t)SLICES_MFADC;j++)
       sig[i][j]+=pedestal[i];
 }
@@ -429,4 +325,5 @@
     }
   }
+  delete GenOff;
 }
 
@@ -438,5 +335,5 @@
   for ( Int_t i = 0 ; i < CAMERA_PIXELS; i++) {
     if ( used [i] == TRUE ) {
-      for ( Int_t is=0 ; is< SLICES_MFADC ; is++ ) {
+      for ( Int_t is=0 ; is< (Int_t)SLICES_MFADC ; is++ ) {
 
 	sig[i][is] += GenElec->Gaus(0., 2.) ; 
@@ -458,5 +355,5 @@
       printf ("Pid %3d",  ip ) ; 
 
-      for ( Int_t is=0 ; is < SLICES_MFADC; is++ ) {
+      for ( Int_t is=0 ; is < (Int_t)SLICES_MFADC; is++ ) {
 
 	if ( sig[ip][is] > 0. ) {
@@ -565,5 +462,5 @@
       i=0;
       for ( Int_t is=iFirstSlice ; is < (iFirstSlice+FADC_SLICES) ; is++ ) {
-	if (is< SLICES_MFADC && sig[ip][is]>0.0)
+	if (is< (Int_t)SLICES_MFADC && sig[ip][is]>0.0)
 	  output[ip][i++]=(UChar_t) sig[ip][is];
 	else 
@@ -612,5 +509,5 @@
       //
       
-      for (Int_t ibin=1; ibin <=SLICES_MFADC; ibin++) {
+      for (Int_t ibin=1; ibin <=(Int_t)SLICES_MFADC; ibin++) {
 	hist->SetBinContent (ibin, sig[i][ibin-1]) ;
       }
