Index: /fact/tools/rootmacros/FCalibrateEvent.c
===================================================================
--- /fact/tools/rootmacros/FCalibrateEvent.c	(revision 12362)
+++ /fact/tools/rootmacros/FCalibrateEvent.c	(revision 12362)
@@ -0,0 +1,22 @@
+#include <cstdio>
+int FCalibrateEvent(vector<int16_t> &data, vector<int16_t> &data_offset, vector<float> &drs_basemean, vector<float> &drs_gainmean, vector<float> &drs_triggeroffsetmean, vector<float> &calevent, UInt_t data_px, UInt_t data_roi)
+{
+//-------------------------------------------
+//Iterate over the pixels
+//-------------------------------------------
+	for (int j=0; j<data_px; j++)
+	{
+//-------------------------------------------
+//Iterate over the slices
+//-------------------------------------------
+		for (UInt_t k=0; k<data_roi; k++)
+		{
+			UInt_t drs_calib_offset = (k+data_offset[j])%data_roi;
+			float sample = (data[j*data_roi+k]*2000/4096.-drs_basemean[j*data_roi+drs_calib_offset]-drs_triggeroffsetmean[j*data_roi+k])/drs_gainmean[j*data_roi+drs_calib_offset]*1907.35;
+//			float usample = data[j*data_roi+k]; //Uncalibrated sample value
+			calevent[j*data_roi+k]=sample;
+		}
+//	cout << "Plotting successful..." << endl;
+	}
+	return 0;
+}
Index: /fact/tools/rootmacros/calscope.C
===================================================================
--- /fact/tools/rootmacros/calscope.C	(revision 12361)
+++ /fact/tools/rootmacros/calscope.C	(revision 12362)
@@ -8,9 +8,9 @@
 #define HAVE_ZLIB
 #include "fits.h"
-#include "TPKplotevent.c"
 #include "FOpenDataFile.c"
 #include "FOpenCalibFile.c"
+#include "FCalibrateEvent.c"
 
-int calscope(const char *name = "../raw/20110916_025.fits", const char *drsname = "../raw/20110916_024.drs.fits", size_t eventnr = 0, size_t pixelnr = 0)
+int calscope(const char *name, const char *drsname, size_t eventnr, size_t pixelnr)
 {
 //******************************************************************************
@@ -20,5 +20,5 @@
 //Example call in ROOT:
 //root [74] .x calscope.C++("20110804_024.fits","20110804_023.drs.fits",10,1348)
-//T. Krähenbühl, August 2011, tpk@phys.ethz.ch
+//T. Kr�henb�hl, August 2011, tpk@phys.ethz.ch
 //******************************************************************************
 
@@ -64,5 +64,4 @@
 	}
 	
-	
 //-------------------------------------------
 //Create the title
@@ -72,14 +71,29 @@
 	
 //-------------------------------------------
-//Get the event
+//Get the calibrated event
 //-------------------------------------------
+	vector<float> calevent(data_px*data_roi); //Vector for the calibrated event
+
 	cout << "--------------------- Data --------------------" << endl;
 	datafile.GetRow(eventnr);
 	cout << "Event number: " << data_num << endl;
-		
+	
+	FCalibrateEvent(data, data_offset, drs_basemean, drs_gainmean, drs_triggeroffsetmean, calevent, data_px, data_roi);
+	
 //-------------------------------------------
 //Draw the data
 //-------------------------------------------
-	TPKplotevent(title, data, data_offset, drs_basemean, drs_gainmean, drs_triggeroffsetmean, data_roi, pixelnr);
+	TCanvas *canv = new TCanvas( "canv", "Mean values of the first event", 100, 10, 700, 500 );
+	TProfile *pix = new TProfile("pix", title, 1024, -0.5, 1023.5);
+	
+	for (UInt_t k=0; k<data_roi; k++)
+	{
+		pix->Fill(k,calevent[pixelnr*data_roi+k]);
+	}
+	
+	pix->Draw();
+	canv->Modified();
+	canv->Update();
+	
 	return 0;
 }
