diff --git a/CALIBRATION/hms_cal_calib/THcShowerCalib.h b/CALIBRATION/hms_cal_calib/THcShowerCalib.h
index 51f105121192ee90d2b68514504bebabec4db114..2dd996bf3bc1e8d000518fbdd59f5700e8edf85a 100644
--- a/CALIBRATION/hms_cal_calib/THcShowerCalib.h
+++ b/CALIBRATION/hms_cal_calib/THcShowerCalib.h
@@ -62,6 +62,9 @@ class THcShowerCalib {
   Double_t fBetaMin, fBetaMax;     // Beta range
   Double_t fCerMin;                // Threshold Cerenkov signal, p.e.
   UInt_t fMinHitCount;             // Min. number of hits/chan. for calibration
+  Double_t fEuncLoLo, fEuncHiHi;   // Range of uncalibrated Edep histogram
+  UInt_t fEuncNBin;                // Binning of uncalibrated Edep histogram
+  Double_t fEuncGFitLo,fEuncGFitHi;// Gaussian fit range of uncalib. Edep histo.
 
   Double_t fLoThr;     // Low and high thresholds on the normalized uncalibrated
   Double_t fHiThr;     // energy deposition.
@@ -221,6 +224,12 @@ void THcShowerCalib::ReadThresholds() {
   iss >> fCerMin;
   getline(fin, line);  iss.str(line);
   iss >> fMinHitCount;
+  getline(fin, line);  iss.str(line);
+  iss >> fEuncLoLo >> fEuncHiHi;
+  getline(fin, line);  iss.str(line);
+  iss >> fEuncNBin;
+  getline(fin, line);  iss.str(line);
+  iss >> fEuncGFitLo >> fEuncGFitHi;
 
   getline(fin, line);
   getline(fin, line);
@@ -257,6 +266,10 @@ void THcShowerCalib::ReadThresholds() {
   cout << "  Beta min, max    = " << fBetaMin << "  " << fBetaMax << endl;
   cout << "  Gas Cerenkov min = " << fCerMin << endl;
   cout << "  Min. hit count   = " << fMinHitCount << endl;
+  cout << "  Uncalibrated histo. range and binning: " << fEuncLoLo << "  "
+       << fEuncHiHi << "  " << fEuncNBin << endl;
+  cout << "  Uncalibrated histo. fit range: " << fEuncGFitLo << "  "
+       << fEuncGFitHi << endl;
   cout << endl;
 
   cout << "Initial gain constants:\n";
@@ -346,7 +359,7 @@ void THcShowerCalib::Init() {
 
   // Histogram declarations.
 
-  hEunc = new TH1F("hEunc", "Edep/P uncalibrated", 500, 0., 2.);
+  hEunc = new TH1F("hEunc","Edep/P uncalibrated",fEuncNBin,fEuncLoLo,fEuncHiHi);
   hEcal = new TH1F("hEcal", "Edep/P calibrated", 200, 0., 2.);
   hDPvsEcal = new TH2F("hDPvsEcal", "#DeltaP versus Edep/P ",
 		       150,0.,1.5, 250,-12.5,12.5);
@@ -410,7 +423,11 @@ void THcShowerCalib::CalcThresholds() {
     if (nev > 200000) break;
   };
 
-  hEunc->Fit("gaus","0","",0.5, 1.5);
+  //  hEunc->Fit("gaus","0","",0.5, 1.5);
+  hEunc->Fit("gaus","","",fEuncGFitLo, fEuncGFitHi);
+  hEunc->GetFunction("gaus")->SetLineColor(2);
+  hEunc->GetFunction("gaus")->SetLineWidth(1);
+  hEunc->GetFunction("gaus")->SetLineStyle(1);
   TF1 *fit = hEunc->GetFunction("gaus");
   Double_t gmean  = fit->GetParameter(1);
   Double_t gsigma = fit->GetParameter(2);
diff --git a/CALIBRATION/hms_cal_calib/howto.txt b/CALIBRATION/hms_cal_calib/howto.txt
index 11d1016fd90349939537961c58307d4d94798df9..67722b92eada3ee66a8d32abab11e7c835e8d093 100644
--- a/CALIBRATION/hms_cal_calib/howto.txt
+++ b/CALIBRATION/hms_cal_calib/howto.txt
@@ -14,16 +14,18 @@ full HMS analysis. The root files are assumed to be in a linked
 ROOTfiles directory.
 
 Th input file contains thresholds on the quantities used in the
-calibration, such as HMS delta range, the hodoscope beta range,
+calibration, such as HMS: delta range, the hodoscope beta range,
 threshold on the gas Cherenkov signals, required minimum number of
-hits in the calorimeter channels in order to be calibrated, and
-initial gain constants. The gas Cherenkov signals and beta are used to
-select good electron events for calibration. The initial gain
-constants are used for additional clean up of the electron samples
-from hadron contamination (if any) left after PID with gas Cherenkov
-and beta. The code does not iterate the gain constants.  The user is
-free to modify cuts in the input file as needed. Caution must be
-exercised not to alter the format of the file.
+hits in the calorimeter channels in order to be calibrated, initial
+gain constants, and parameters for an auxiliary histogram of energy
+deposition calculated with initial gain constants. The gas Cherenkov
+signals and beta are used to select good electron events for
+calibration.  Additional clean up of the electron sample from hadron
+contamination (if any) left after PID with gas Cherenkov and beta is
+done by a rough localization of the electron peak in the auxiliary
+histogram. Note that code does not iterate the gain constants. The
+user is free to modify cuts in the input file as needed. Caution must
+be exercised not to alter the format of the file.
 
 The steering script hcal_calib.cpp takes 3 parameters: prefix of the
 root file to be calibrated, last (-1 by default) and the first (0 by
diff --git a/CALIBRATION/hms_cal_calib/input.dat b/CALIBRATION/hms_cal_calib/input.dat
index f3eafd4a990a010275df4bd9d0816fa63888f848..b4b3eceacaa01d453615b692ae890349f77d7627 100644
--- a/CALIBRATION/hms_cal_calib/input.dat
+++ b/CALIBRATION/hms_cal_calib/input.dat
@@ -2,6 +2,9 @@
 0.5 1.5	Beta range
 4.  	Gas Cherenkov, threshold on signals in p.e.
 20	Minimum number of hits per channel required to be calibrated
+0. 2.	Range of uncalibrated energy deposition histogram
+500	Binning of uncalibrated energy deposition histogram
+0.5 1.5	Gaussian fit range around e- peak in the uncalibrated Edep histogram
 
 ; Initial calibration constants.
 
diff --git a/CALIBRATION/shms_cal_calib/THcPShowerCalib.h b/CALIBRATION/shms_cal_calib/THcPShowerCalib.h
index 3823673c9c1e6ce19a59cfaa5592cd52ea9fd86a..f895ad0af333dcc70d32f8e335c15b80e58581a2 100644
--- a/CALIBRATION/shms_cal_calib/THcPShowerCalib.h
+++ b/CALIBRATION/shms_cal_calib/THcPShowerCalib.h
@@ -85,6 +85,9 @@ class THcPShowerCalib {
   Double_t fHGCerMin;              // Threshold heavy gas Cerenkov signal, p.e.
   Double_t fNGCerMin;              // Threshold noble gas Cerenkov signal, p.e.
   UInt_t fMinHitCount;             // Min. number of hits/chan. for calibration
+  Double_t fEuncLoLo, fEuncHiHi;   // Range of uncalibrated Edep histogram
+  UInt_t fEuncNBin;                // Binning of uncalibrated Edep histogram
+  Double_t fEuncGFitLo,fEuncGFitHi;// Gaussian fit range of uncalib. Edep histo.
 
   TTree* fTree;
   UInt_t fNentries;
@@ -238,6 +241,12 @@ void THcPShowerCalib::ReadThresholds() {
   iss >> fNGCerMin;
   getline(fin, line);  iss.str(line);
   iss >> fMinHitCount;
+  getline(fin, line);  iss.str(line);
+  iss >> fEuncLoLo >> fEuncHiHi;
+  getline(fin, line);  iss.str(line);
+  iss >> fEuncNBin;
+  getline(fin, line);  iss.str(line);
+  iss >> fEuncGFitLo >> fEuncGFitHi;
 
   getline(fin, line);
   getline(fin, line);
@@ -294,6 +303,10 @@ void THcPShowerCalib::ReadThresholds() {
   cout << "  Heavy Gas Cerenkov min = " << fHGCerMin << endl;
   cout << "  Noble Gas Cerenkov min = " << fNGCerMin << endl;
   cout << "  Min. hit count   = " << fMinHitCount << endl;
+  cout << "  Uncalibrated histo. range and binning: " << fEuncLoLo << "  "
+       << fEuncHiHi << "  " << fEuncNBin << endl;
+  cout << "  Uncalibrated histo. fit range: " << fEuncGFitLo << "  "
+       << fEuncGFitHi << endl;
   cout << endl;
 
   cout << "Initial gain constants:\n";
@@ -373,7 +386,7 @@ void THcPShowerCalib::Init() {
 
   // Histogram declarations.
 
-  hEunc = new TH1F("hEunc", "Edep/P uncalibrated", 500, 0., 2.);
+  hEunc = new TH1F("hEunc","Edep/P uncalibrated",fEuncNBin,fEuncLoLo,fEuncHiHi);
   hEcal = new TH1F("hEcal", "Edep/P calibrated", 200, 0., 2.);
   hDPvsEcal = new TH2F("hDPvsEcal", "#DeltaP versus Edep/P ",
 		       400,0.,2., 440,fDeltaMin-1.,fDeltaMax+1.);
@@ -455,7 +468,11 @@ void THcPShowerCalib::CalcThresholds() {
     if (nev > 200000) break;
   };
 
-  hEunc->Fit("gaus","0","",0.5, 1.5);       //do not plot
+  //  hEunc->Fit("gaus","0","",fEuncGFitLo, fEuncGFitHi);    //fit, do not plot
+  hEunc->Fit("gaus","","",fEuncGFitLo, fEuncGFitHi);
+  hEunc->GetFunction("gaus")->SetLineColor(2);
+  hEunc->GetFunction("gaus")->SetLineWidth(1);
+  hEunc->GetFunction("gaus")->SetLineStyle(1);
   TF1 *fit = hEunc->GetFunction("gaus");
   Double_t gmean  = fit->GetParameter(1);
   Double_t gsigma = fit->GetParameter(2);
diff --git a/CALIBRATION/shms_cal_calib/howto.txt b/CALIBRATION/shms_cal_calib/howto.txt
index 80c8220ed5385278fd59bc75d1a87889f10e4839..5cc565168fe55bb9b22c3e960d137d3110209c47 100644
--- a/CALIBRATION/shms_cal_calib/howto.txt
+++ b/CALIBRATION/shms_cal_calib/howto.txt
@@ -14,16 +14,18 @@ full SHMS analysis. The root files are assumed to be in a linked
 ROOTfiles directory.
 
 Th input file contains thresholds on the quantities used in the
-calibration, such as SHMS delta range, the hodoscope beta range,
+calibration, such as: SHMS delta range, the hodoscope beta range,
 thresholds on heavy and noble gas Cherenkov signals, required minimum
 number of hits in the calorimeter channels in order to be calibrated,
-and initial gain constants. The gas Cherenkov signals and beta are
-used to select good electron events for calibration. The initial gain
-constants are used for additional clean up of the electron samples
-from hadron contamination (if any) left after PID with gas Cherenkovs
-and beta. The code does not iterate the gain constants.  The user is
-free to modify cuts in the input file as needed. Caution must be
-exercised not to alter the format of the file.
+initial gain constants, and parameters for an auxiliary histogram of
+energy deposition calculated with initial gain constants. The gas
+Cherenkov signals and beta are used to select good electron events for
+calibration. Additional clean up of the electron sample from hadron
+contamination (if any) left after PID with gas Cherenkov-s and beta is
+done by a rough localization of the electron peak in the auxiliary
+histogram. Note that code does not iterate the gain constants.  The
+user is free to modify cuts in the input file as needed. Caution must
+be exercised not to alter the format of the file.
 
 The steering script pcal_calib.cpp takes 3 parameters: prefix of the
 root file to be calibrated, last (-1 by default) and the first (0 by
diff --git a/CALIBRATION/shms_cal_calib/input.dat b/CALIBRATION/shms_cal_calib/input.dat
new file mode 100644
index 0000000000000000000000000000000000000000..2d61d39a850a7756edf9be155a2f934580ce3df8
--- /dev/null
+++ b/CALIBRATION/shms_cal_calib/input.dat
@@ -0,0 +1,27 @@
+-10 22	Delta range, %
+0.5 1.5	Beta range
+2.  	Heavy Gas Cherenkov, threshold on signals in p.e.
+0.  	Noble Gas Cherenkov, threshold on signals in p.e.
+5	Minimum number of hits per channel required to be calibrated
+0. 3.	Range of uncalibrated energy deposition histogram
+500	Binning of uncalibrated energy deposition histogram
+0.5 2.	Gaussian fit range around e- peak in the uncalibrated Edep histogram
+
+; Calibration constants for run 1791_300000, 38067 events processed (dec. 17 defocused run)
+
+pcal_neg_gain_cor = 31.20, 28.28, 28.19, 29.18, 31.57, 27.67, 30.21, 32.54, 31.59, 28.61, 30.12, 28.67, 35.35,  0.00,
+pcal_pos_gain_cor = 29.91, 27.86, 27.42, 28.18, 31.90, 34.08, 29.00, 24.00, 27.65, 27.75, 31.99, 26.58, 23.02,  0.00,
+pcal_arr_gain_cor =  0.00,  0.00,  0.00, 37.46, 24.21, 25.41, 14.60, 32.73, 40.66,  9.56, 19.92,  0.00,  0.00,  0.00,  0.00,  0.00,
+                   49.52, 28.39, 57.17, 43.51, 44.38, 36.14, 42.24, 25.59, 22.50, 37.73, 72.10, 45.51,  0.00,  0.00,  0.00,  0.00,
+                   54.73, 39.81, 37.85, 33.96, 58.96, 62.49, 41.46, 60.29, 32.42, 50.27, 39.06, 73.12, 27.12,  0.00,  0.00,  0.00,
+                   57.37, 46.09, 36.74, 46.87, 41.02, 31.42, 80.19, 63.10, 55.60, 56.74, 60.95, 21.81,195.67, 28.97,  0.00,  0.00,
+                   41.31, 34.24, 30.86, 29.89, 65.71, 58.52, 47.87, 32.37, 34.76, 47.78, 41.52, 40.51, 41.17, 64.87, 33.22,  0.00,
+                   34.42, 43.16, 32.57, 73.08, 19.86, 43.48, 46.40, 59.08, 73.81, 37.54, 49.58, 53.58, 74.19, 19.06, 28.13,  0.00,
+                   66.71, 34.52, 55.89, 48.36, 27.14, 45.48, 58.28, 45.87, 40.69, 40.06, 34.77, 23.31, 41.80, 38.69, 32.65,  0.00,
+                   36.26, 12.98, 17.62, 15.39, 19.40, 13.89, 19.27, 22.97, 12.63, 18.96, 27.19, 21.72, 29.04, 17.72,  8.71,  0.00,
+                   57.97, 40.42, 34.70, 35.82, 54.46, 46.75, 26.81, 47.02, 62.38, 72.22, 29.95, 64.76, 28.95, 27.52, 52.12,  0.00,
+                   80.23, 62.50, 22.76, 46.45, 28.61, 63.85, 49.35, 58.90, 34.68, 43.16, 42.49, 40.35, 57.38, 35.70, 20.09,  0.00,
+                  103.60, 47.55, 76.32, 47.25, 37.86, 46.79, 23.73, 42.14, 58.53, 60.64, 39.26, 46.68, 40.73, 25.56,  0.00,  0.00,
+                   39.82, 56.21, 39.53, 37.01, 42.92, 41.25, 22.11, 27.69, 45.91, 32.81, 28.12, 45.18, 59.98,  0.00,  0.00,  0.00,
+                    0.00, 42.99, 25.68, 60.17, 67.59, 52.29, 28.33, 42.01, 68.30, 42.20, 39.85,  0.00,  0.00,  0.00,  0.00,  0.00,
+                    0.00,  0.00,  0.00, 15.01,  0.00,  0.00,  0.00,  0.00,  0.00,  0.00,  0.00,  0.00,  0.00,  0.00,  0.00,  0.00,