Index: fact/tools/rootmacros/fpeak_cfd.C
===================================================================
--- fact/tools/rootmacros/fpeak_cfd.C	(revision 12519)
+++ fact/tools/rootmacros/fpeak_cfd.C	(revision 12521)
@@ -23,5 +23,7 @@
 #define HAVE_ZLIB
 #include "fits.h"
-#include "FOpenCalibFile.c"
+
+#include "openFits.h"
+#include "openFits.c"
 
 #include "discriminator.h"
@@ -50,8 +52,6 @@
 UInt_t NumberOfPixels;
 
-size_t drs_n;
-vector<float> drs_basemean;
-vector<float> drs_gainmean;
-vector<float> drs_triggeroffsetmean;
+size_t TriggerOffsetROI, RC;
+vector<float> Offset, Gain, TriggerOffset;
 
 vector<float> Ameas(FAD_MAX_SAMPLES);  // copy of the data (measured amplitude
@@ -102,4 +102,5 @@
 	int avg1		= 8,
 	int avg2 		= 8,
+	float threshold = 5.0,
 	int verbosityLevel = 1, // different verbosity levels can be implemented here
 	bool ProduceGraphic = true
@@ -115,9 +116,11 @@
 histogramtitle += " ";
 
-			histogramtitle += avg1;
- 			histogramtitle += " "; 
-			histogramtitle +=  avg2;
-//			histogramtitle +=  " 3.0 100";
-			cout << histogramtitle.Data() << endl;
+histogramtitle += avg1;
+histogramtitle += " ";
+histogramtitle +=  avg2;
+histogramtitle += " ";
+histogramtitle +=  threshold ;
+histogramtitle +=  " 100";
+cout << histogramtitle.Data() << endl;
 
 
@@ -141,5 +144,5 @@
 	// Parameters to the data file. So they are filled with
 	// raw data as soon as datafile->GetRow(int) is called.
-	NEvents = OpenDataFile( datafilename, &datafile,
+	NEvents = openDataFits( datafilename, &datafile,
 		AllPixelDataVector, StartCellVector, CurrentEventID,
 		RegionOfInterest, NumberOfPixels, PXLxROI, verbosityLevel);
@@ -162,12 +165,10 @@
 		cout <<"of, which "<< npixel << "will be processed"<< endl;
 
-
-
-	//Get the DRS calibration
-	FOpenCalibFile(	drsfilename,
-					drs_basemean,
-					drs_gainmean,
-					drs_triggeroffsetmean,
-					drs_n);
+	RC = openCalibFits( drsfilename, Offset, Gain, TriggerOffset, TriggerOffsetROI);
+	if (RC == 0){
+		cout << "return code of openCalibFits:" << drsfilename << endl;
+		cout << "is zero -> aborting." << endl;
+		return 1;
+	}
 
 	BookHistos( histogramtitle  );
@@ -187,5 +188,5 @@
 
 			applyDrsCalibration( Ameas,pix,12,12,
-				drs_basemean, drs_gainmean, drs_triggeroffsetmean,
+				Offset, Gain, TriggerOffset,
 				RegionOfInterest, AllPixelDataVector, StartCellVector);
 
@@ -210,8 +211,7 @@
 			EnlargeRegion( *zXings, 10, 10);
 			findAbsMaxInRegions( *zXings, Vslide);
-	//		removeMaximaBelow( *zXings, 3.0, 0);
-	//		removeRegionWithMaxOnEdge( *zXings, 2);
-	//		removeRegionOnFallingEdge( *zXings, 100);
-
+			removeMaximaBelow( *zXings, threshold, 0);
+			removeRegionWithMaxOnEdge( *zXings, 2);
+			removeRegionOnFallingEdge( *zXings, 100);
 			
 			// fill maxima in Histogram
