Index: trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx	(revision 442)
+++ trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx	(revision 443)
@@ -171,4 +171,79 @@
 }
 
+void MFadc::Baseline(){
+  //  
+  //  It simulates the AC behaviour
+
+  int i,j;
+  Float_t baseline;
+
+  for(j=0;j<CAMERA_PIXELS;j++){
+    baseline=0.0;
+    for(i=0;i<(Int_t) SLICES_MFADC;i++){
+      baseline=+sig[j][i];
+    }
+    baseline=baseline/SLICES_MFADC;
+    for(i=0;i<(Int_t) SLICES_MFADC;i++){
+      sig[j][i]=-baseline;
+    }
+  }
+}
+
+void MFadc::Offset(Float_t offset, Int_t pixel){
+  // 
+  //  It puts an offset in the FADC signal
+  //
+
+  int i,j;
+  float fdum;
+  TRandom *GenOff = new TRandom () ; 
+
+  if (offset<0) {
+    //  It cannot be, so the program assumes that 
+    //  it should generate random values for the offset.
+
+    if (pixel<0) {
+      // It does not exist, so all pixels will have the same offset
+
+      for(i=0;i<CAMERA_PIXELS;i++){
+	if (used[i]){
+	  fdum=(10*GenOff->Rndm());
+	  for(j=0;j<(Int_t) SLICES_MFADC;j++)
+	    sig[i][j]=+fdum;
+	}
+      }
+    } else {
+      // The program will put the specifies offset to the pixel "pixel".
+
+      if (used[pixel]){
+	fdum=(10*GenOff->Rndm());
+	for(j=0;j<(Int_t) SLICES_MFADC;j++)
+	  sig[pixel][j]=+fdum;
+	}
+
+    }
+  }else {
+    //  The "offset" will be the offset for the FADC
+
+    if (pixel<0) {
+      // It does not exist, so all pixels will have the same offset
+
+      for(i=0;i<CAMERA_PIXELS;i++){
+	if (used[i]){
+	  for(j=0;j<(Int_t) SLICES_MFADC;j++)
+	    sig[i][j]=+offset;
+	}
+      }
+    } else {
+      // The program will put the specifies offset to the pixel "pixel".
+
+      if (used[pixel]){
+	for(j=0;j<(Int_t) SLICES_MFADC;j++)
+	  sig[i][j]=+offset;
+      }
+    }
+  }
+}
+
 void MFadc::ElecNoise() {
   //
@@ -282,6 +357,9 @@
     if ( used[ip] == kTRUE ) { 
       i=0;
-      for ( Int_t is=iFirstSlice ; is < (iFirstSlice+FADC_SLICES); is++ ) {
-	output[ip][i++]=(UChar_t) sig[ip][is];
+      for ( Int_t is=iFirstSlice ; is < (iFirstSlice+FADC_SLICES) ; is++ ) {
+	if (is< SLICES_MFADC)
+	  output[ip][i++]=(UChar_t) sig[ip][is];
+	else 
+	  output[ip][i++]= 0;
       }
 
