Index: fact/tools/rootmacros/gainfit.C
===================================================================
--- fact/tools/rootmacros/gainfit.C	(revision 12467)
+++ fact/tools/rootmacros/gainfit.C	(revision 12486)
@@ -67,5 +67,5 @@
 
 	cGainFit->cd(1);
-	p1->GetXaxis()->SetRangeUser( 2.5, 25);
+	p1->GetXaxis()->SetRangeUser( 5, 25);
 	p1->Draw();
 
@@ -114,15 +114,32 @@
 
 //tf->Close();	
+string filename =  InputRootFileName;
+size_t lastslash = filename.find_last_of('/');
+filename = filename.substr(lastslash+1);
+size_t firstdot = filename.find_first_of('.');
+filename = filename.substr(0, firstdot);
+
+string::iterator it;
+for (it=filename.begin(); it < filename.end(); ){
+
+	if (!isdigit(*it)){
+		it=filename.erase(it);
+	}
+	else
+		++it;
+}
+cout << filename << endl;
+
 
 ofstream out;
 out.open( OutTextFileName );
+out << "pixelID/I:gain/F:fitgain:filename/l" << endl;
+out << "# ---- the 1st line helps to use TTree::ReadFile, for reading again this txt file with root. " << endl;
 out << "#" << InputRootFileName << endl;
 out << "# PixelID : simple_gain : gain " << endl;
 out << "# simple_gain is just the distance of the local maxima in the amplitude spektra " << endl;
 out << "# gain is derived from a fit of two gaussians " << endl;
-out << "# ---- the following line helps to use TTree::ReadFile, for reading again this txt file with root. " << endl;
-out << "pixelID/I:simpleGain/F:Gain" << endl;
 for (int i=0; i<1440; i++){
-	out << pixelvec[i] << "\t" << simple_gain[i] << "\t" << gain[i] << endl;
+	out << pixelvec[i] << "\t" << simple_gain[i] << "\t" << gain[i] << "\t" << filename << endl;
 
 } 
