From 2ab14e51abe4096861a433c5e109d89de3f62ede Mon Sep 17 00:00:00 2001
From: Vardan Tadevosyan <tadevosn@jlab.org>
Date: Fri, 23 Aug 2013 17:23:10 -0400
Subject: [PATCH] Shower counter code change that improve agreement with
 ENGINE.

---
 examples/DBASE/test.database  |  3 ++
 examples/PARAM/hcal.param     | 80 ++++++-----------------------------
 examples/compedeps.C          | 10 ++---
 examples/comprawhits.C        | 21 ++++++++-
 examples/hodtest_cuts_mkj.def |  3 +-
 src/THcShower.cxx             | 20 ++++-----
 src/THcShower.h               | 24 +++++------
 src/THcShowerCluster.h        | 20 ++++-----
 src/THcShowerHit.h            | 14 +++---
 src/THcShowerPlane.cxx        | 38 ++++++++---------
 src/THcShowerPlane.h          | 55 +++++++++++++-----------
 11 files changed, 132 insertions(+), 156 deletions(-)

diff --git a/examples/DBASE/test.database b/examples/DBASE/test.database
index ff37f93..451a266 100644
--- a/examples/DBASE/test.database
+++ b/examples/DBASE/test.database
@@ -2,6 +2,9 @@
 50017
 g_ctp_parm_filename="PARAM/general.param"
 g_decode_map_filename="MAPS/jun04.map"
+52949
+g_ctp_parm_filename="PARAM/52949/general.param"
+g_decode_map_filename="MAPS/july04.map"
 47000-48000
 g_ctp_parm_filename="PARAM/general.param"
 g_decode_map_filename="MAPS/jan03.map"
diff --git a/examples/PARAM/hcal.param b/examples/PARAM/hcal.param
index 614215e..dc33822 100644
--- a/examples/PARAM/hcal.param
+++ b/examples/PARAM/hcal.param
@@ -7,13 +7,13 @@ hcal_slop = 7.5
 
 hcal_fv_test = 0
 
-hcal_pos_cal_const =0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005
-                    0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005
+hcal_pos_cal_const =0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001
+                    0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001
                     0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001
                     0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001
 
-hcal_neg_cal_const =0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005
-                    0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005,0.0005
+hcal_neg_cal_const =0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001
+                    0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001
                     0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001
                     0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001
 
@@ -51,69 +51,17 @@ hcal_neg_ped_limit =1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,
 
 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
-; Calibration constants for run   48816,  35730 events processed
-;
-;hcal_pos_gain_cor= 0.454, 0.272, 0.377, 0.437, 0.367, 0.471, 0.371, 0.480, 0.382, 0.453, 0.306, 0.337, 0.300,
-;                   0.264, 0.451, 0.324, 0.300, 0.356, 0.358, 0.331, 0.391, 0.319, 0.309, 0.401, 0.450, 0.263,
-;                   0.746, 0.743, 0.703, 0.881, 0.760, 0.720, 0.636, 0.671, 1.003, 0.791, 0.607, 0.696, 0.817,
-;                   1.147, 0.920, 0.753, 0.829, 0.869, 0.876, 0.915, 0.899, 0.983, 0.763, 0.806, 0.915, 0.663,
-;hcal_neg_gain_cor= 0.413, 0.827, 0.455, 0.366, 0.368, 0.403, 0.463, 0.402, 0.364, 0.371, 0.352, 0.534, 0.372,
-;                   0.475, 0.365, 0.446, 0.552, 0.454, 0.445, 0.418, 0.427, 0.457, 0.365, 0.377, 0.395, 0.416,
-;                   0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
-;                   0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
-
-; Calibration constants for run   49064,  28202 events processed
-
-;hcal_pos_gain_cor= 0.374, 0.368, 0.364, 0.336, 0.298, 0.424, 0.395, 0.452, 0.415, 0.000, 0.000, 0.000, 0.000,
-;                   0.311, 0.275, 0.234, 0.263, 0.312, 0.316, 0.264, 0.292, 0.624, 0.000, 0.000, 0.000, 0.000,
-;                   0.938, 0.668, 0.617, 0.785, 0.634, 0.624, 0.501, 0.568, 1.060, 0.000, 0.000, 0.000, 0.000,
-;                   0.047, 0.759, 0.725, 0.785, 0.833, 0.881, 0.938, 0.920, 1.856, 0.000, 0.000, 0.000, 0.000,
-;hcal_neg_gain_cor= 0.391, 0.328, 0.357, 0.367, 0.314, 0.243, 0.353, 0.328, 0.241, 0.000, 0.000, 0.000, 0.000,
-;                   0.364, 0.450, 0.484, 0.563, 0.436, 0.442, 0.402, 0.453, 0.104, 0.000, 0.000, 0.000, 0.000,
-;                   0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
-;                   0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
-
-; Calibration constants for run   49098,  23159 events processed
-
-;hcal_pos_gain_cor= 0.344, 0.427, 0.342, 0.355, 0.291, 0.568, 0.536, 0.387, 0.000, 0.000, 0.000, 0.000, 0.000,
-;                   0.292, 0.319, 0.228, 0.295, 0.372, 0.436, 0.220, 0.392, 0.586, 0.000, 0.000, 0.000, 0.000,
-;                   0.938, 0.648, 0.625, 0.808, 0.636, 0.659, 0.544, 0.533, 1.229, 0.000, 0.000, 0.000, 0.000,
-;                   0.033, 0.769, 0.720, 0.886, 0.823, 0.925, 0.880, 1.089, 0.000, 0.000, 0.000, 0.000, 0.000,
-;hcal_neg_gain_cor= 0.454, 0.301, 0.380, 0.370, 0.341, 0.099, 0.246, 0.474, 0.000, 0.000, 0.000, 0.000, 0.000,
-;                   0.412, 0.430, 0.542, 0.606, 0.400, 0.355, 0.515, 0.378, 0.804, 0.000, 0.000, 0.000, 0.000,
-;                   0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
-;                   0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
-
 
 ; the following lines are from calibration file
 ; written by the perlscript mkcalpar.prl
 
-;hcal_pos_gain_cor= 0.000, 0.328, 0.240, 0.482, 0.202, 0.397, 0.279, 0.327, 0.270, 0.299, 0.297, 0.309, 0.000,
-;                   0.000, 0.375, 0.317, 0.389, 0.390, 0.171, 0.274, 0.383, 0.310, 0.323, 0.297, 0.606, 1.168,
-;                   0.000, 0.744, 0.618, 0.853, 0.732, 0.674, 0.532, 0.646, 0.710, 0.714, 0.484, 0.773, 0.000,
-;                   0.000, 0.000, 0.684, 0.596, 0.716, 0.692, 0.694, 0.595, 0.806, 0.640, 0.841, 0.000, 0.000,
-;hcal_neg_gain_cor= 0.000, 0.167, 0.372, 0.317, 0.255, 0.279, 0.376, 0.338, 0.336, 0.315, 0.295, 0.277, 0.000,
-;                   0.000, 0.246, 0.366, 0.471, 0.359, 0.549, 0.435, 0.427, 0.399, 0.298, 0.313, 0.342, 0.000,
-;                   0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
-;                   0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
-
-
-hcal_pos_gain_cor= 0.973,0.775,0.814,0.839,0.638,0.72,0.699,0.74,0.794,0.805,0.658,0.694,0.604
-                  0.794,0.756,0.688,0.719,0.791,0.795,0.715,0.879,0.744,0.725,0.8,1.129,0.424
-                  0.716,0.66,0.623,0.899,0.682,0.764,0.609,0.641,0.924,0.835,0.55,0.671,0.888
-                  1.468,0.754,0.789,1.015,0.869,1.083,1.148,0.962,1.236,0.745,0.949,1.004,0.892
-hcal_neg_gain_cor= 0.864,0.672,0.749,0.755,0.657,0.600,1.056,0.996,0.693,0.876,0.717,0.726,0.662
-                  0.694,0.826,0.818,1.009,0.829,0.781,0.848,0.796,0.779,0.668,0.762,0.742,0.842
-                  0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000
-                  0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000
-;
-; Calibration constants for run   63504,  51956 events processed
-
-;hcal_pos_gain_cor= 0.335, 0.316, 0.367, 0.498, 0.366, 0.363, 0.408, 0.451, 0.380, 0.473, 0.369, 0.416, 0.287,
-;                   0.417, 0.388, 0.361, 0.363, 0.314, 0.384, 0.349, 0.411, 0.356, 0.339, 0.412, 0.591, 0.286,
-;                   0.677, 0.707, 0.675, 0.986, 0.793, 0.760, 0.649, 0.725, 0.748, 0.876, 0.611, 0.706, 0.989,
-;                   1.011, 0.648, 0.685, 0.871, 0.791, 0.939, 1.035, 0.865, 0.967, 0.758, 0.866, 0.856, 0.504,
-;hcal_neg_gain_cor= 0.490, 0.429, 0.436, 0.402, 0.349, 0.249, 0.435, 0.455, 0.378, 0.408, 0.332, 0.299, 0.394,
-;                   0.415, 0.480, 0.446, 0.630, 0.555, 0.460, 0.497, 0.514, 0.487, 0.449, 0.408, 0.486, 0.348,
-;                   0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
-;                   0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
+hcal_pos_gain_cor= 0.000, 0.328, 0.240, 0.482, 0.202, 0.397, 0.279, 0.327, 0.270, 0.299, 0.297, 0.309, 0.000,
+                   0.000, 0.375, 0.317, 0.389, 0.390, 0.171, 0.274, 0.383, 0.310, 0.323, 0.297, 0.606, 1.168,
+                   0.000, 0.744, 0.618, 0.853, 0.732, 0.674, 0.532, 0.646, 0.710, 0.714, 0.484, 0.773, 0.000,
+                   0.000, 0.000, 0.684, 0.596, 0.716, 0.692, 0.694, 0.595, 0.806, 0.640, 0.841, 0.000, 0.000,
+hcal_neg_gain_cor= 0.000, 0.167, 0.372, 0.317, 0.255, 0.279, 0.376, 0.338, 0.336, 0.315, 0.295, 0.277, 0.000,
+                   0.000, 0.246, 0.366, 0.471, 0.359, 0.549, 0.435, 0.427, 0.399, 0.298, 0.313, 0.342, 0.000,
+                   0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
+                   0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
+
+
diff --git a/examples/compedeps.C b/examples/compedeps.C
index dcb8f0b..737957a 100644
--- a/examples/compedeps.C
+++ b/examples/compedeps.C
@@ -17,13 +17,13 @@ void compedeps(Int_t run)
     h1[0] = h683;   //A
     h1[1] = h684;   //B
     h1[2] = h685;   //C
-    h1[3] = h686;   //C
+    h1[3] = h686;   //D
     break;
   default :
-    h1[0] = h628;   //A
-    h1[1] = h629;   //B
-    h1[2] = h630;   //C
-    h1[3] = h631;   //C
+    h1[0] = h632;   //A
+    h1[1] = h633;   //B
+    h1[2] = h634;   //C
+    h1[3] = h635;   //D
   }
 
   TCanvas *c1 = new TCanvas("c1", "Shower raw Edeps", 1000, 667); 
diff --git a/examples/comprawhits.C b/examples/comprawhits.C
index 6b8890f..a88b4b1 100644
--- a/examples/comprawhits.C
+++ b/examples/comprawhits.C
@@ -1,6 +1,5 @@
 void comprawhits(Int_t run)
 {
-  //  TFile* f = new TFile("hodtest.root");
   TFile* f = new TFile(Form("hodtest_%d.root",run));
   cout << "hcana root file " << Form("hodtest_%d.root",run) << endl;
   TH1F* h[6];
@@ -46,4 +45,24 @@ void comprawhits(Int_t run)
     h1[j]->Draw("same");
   }
 
+  //Differences
+
+  TCanvas *c2 = new TCanvas("c2", "Shower Hit Map Differences", 1000, 667);
+  c2->Divide(2, 3);
+
+  for (int j = 0; j < 6; j++){
+
+    c2->cd(j+1);
+
+    TH1F* dif = h[j]->Clone();
+    dif->Add(h[j],h1[j],1.,-1.);
+
+    dif->SetTitle(Form("Difference %d",j+1));
+    dif->SetFillColor(kRed);
+    dif->SetLineColor(kRed);
+    dif->SetLineWidth(1);
+    dif->SetFillStyle(1111);
+    dif->Draw();
+  }
+
 } 
diff --git a/examples/hodtest_cuts_mkj.def b/examples/hodtest_cuts_mkj.def
index 8a9260d..19317cd 100644
--- a/examples/hodtest_cuts_mkj.def
+++ b/examples/hodtest_cuts_mkj.def
@@ -9,10 +9,11 @@ HMS_event         g.evtyp==1
 SOS_event         g.evtyp==2
 coin_event         g.evtyp==3
 misc_event         g.evtyp>=5
+hms_and_coin	HMS_event||coin_event
 RawDecode_master  1
 
 Block: Decode
-Decode_master     HMS_event
+Decode_master     hms_and_coin
 
 Block: CoarseTracking
 CoarseTracking_master !Pedestal_event
diff --git a/src/THcShower.cxx b/src/THcShower.cxx
index 009cc20..8d580a1 100644
--- a/src/THcShower.cxx
+++ b/src/THcShower.cxx
@@ -542,10 +542,10 @@ Int_t THcShower::CoarseProcess( TClonesArray&  ) //tracks
 
       //May be should be done this way.
       //
-      //      Float_t Edep = fPlanes[j]->GetEmean(i);
+      //      Double_t Edep = fPlanes[j]->GetEmean(i);
       //      if (Edep > 0.) {                                    //hit
-      //	Float_t x = YPos[j][i] + BlockThick[j]/2.;        //top + thick/2
-      //	Float_t z = fNLayerZPos[j] + BlockThick[j]/2.;    //front + thick/2
+      //	Double_t x = YPos[j][i] + BlockThick[j]/2.;        //top + thick/2
+      //	Double_t z = fNLayerZPos[j] + BlockThick[j]/2.;    //front + thick/2
       //      	THcShowerHit* hit = new THcShowerHit(i,j,x,z,Edep);
 
       //ENGINE way.
@@ -556,9 +556,9 @@ Int_t THcShower::CoarseProcess( TClonesArray&  ) //tracks
 	  fPlanes[j]->GetPosThr(i) - fPlanes[j]->GetPosPed(i) ||
 	  fPlanes[j]->GetAneg(i) - fPlanes[j]->GetNegPed(i) >
 	  fPlanes[j]->GetNegThr(i) - fPlanes[j]->GetNegPed(i)) {    //hit
-	Float_t Edep = fPlanes[j]->GetEmean(i);
-      	Float_t x = XPos[j][i] + BlockThick[j]/2.;        //top + thick/2
-      	Float_t z = fNLayerZPos[j] + BlockThick[j]/2.;    //front + thick/2
+	Double_t Edep = fPlanes[j]->GetEmean(i);
+	Double_t x = XPos[j][i] + BlockThick[j]/2.;        //top + thick/2
+	Double_t z = fNLayerZPos[j] + BlockThick[j]/2.;    //front + thick/2
 	THcShowerHit* hit = new THcShowerHit(i,j,x,z,Edep);
 
 	HitList.push_back(hit);
@@ -618,15 +618,15 @@ Int_t THcShower::CoarseProcess( TClonesArray&  ) //tracks
 
       THcShowerCluster* cluster = (*ClusterList).ListedCluster(i);
 
-      Int_t size = (*cluster).clSize();
+      Double_t E = (*cluster).clE();
 
-      if (fMult < size) {
-	fMult = size;
+      if (fE < E) {
+	fE = E;
 	MaxCluster = cluster;
       }
     }
 
-    fE = (*MaxCluster).clE();
+    fMult = (*MaxCluster).clSize();
     fEpr = (*MaxCluster).clEpr();
     fX = (*MaxCluster).clX();
   }
diff --git a/src/THcShower.h b/src/THcShower.h
index f6ebd34..5094d06 100644
--- a/src/THcShower.h
+++ b/src/THcShower.h
@@ -86,21 +86,21 @@ protected:
   // Per-event data
 
   Int_t fNhits;    // Number of hits
-  Float_t** fA;    // Raw ADC amplitudes
-  Float_t** fA_p;  // Ped-subtracted ADC amplitudes
-  Float_t** fA_c;  // Calibrated ADC amplitudes
-  Float_t fAsum_p; // Sum of ped-subtracted ADCs
-  Float_t fAsum_c; // Sum of calibrated ADCs
+  Double_t** fA;    // Raw ADC amplitudes
+  Double_t** fA_p;  // Ped-subtracted ADC amplitudes
+  Double_t** fA_c;  // Calibrated ADC amplitudes
+  Double_t fAsum_p; // Sum of ped-subtracted ADCs
+  Double_t fAsum_c; // Sum of calibrated ADCs
   Int_t fNclust;   // Number of clusters
-  Float_t fE;      // Energy (MeV) of largest cluster
-  Float_t fEpr;    // Preshower Energy (MeV) of largest cluster
-  Float_t fX;      // x-position (cm) of largest cluster
-  Float_t fZ;      // z-position (cm) of largest cluster
+  Double_t fE;      // Energy (MeV) of largest cluster
+  Double_t fEpr;    // Preshower Energy (MeV) of largest cluster
+  Double_t fX;      // x-position (cm) of largest cluster
+  Double_t fZ;      // z-position (cm) of largest cluster
   Int_t fMult;     // Multiplicity of largest cluster
   Int_t fNblk;     // Number of blocks in main cluster
-  Float_t* fEblk;  // Energies of blocks in main cluster
-  Float_t fTRX;    // track x-position in det plane"
-  Float_t fTRY;    // track y-position in det plane",      
+  Double_t* fEblk;  // Energies of blocks in main cluster
+  Double_t fTRX;    // track x-position in det plane"
+  Double_t fTRY;    // track y-position in det plane",
 
   // Potential Hall C parameters.  Mostly here for demonstration
 
diff --git a/src/THcShowerCluster.h b/src/THcShowerCluster.h
index d330810..f6804b4 100644
--- a/src/THcShowerCluster.h
+++ b/src/THcShowerCluster.h
@@ -46,9 +46,9 @@ class THcShowerCluster : THcShowerHitList {
 
   //X coordinate of cluster's center of gravity.
   //
-  float clX() {
-    float x_sum=0.;
-    float Etot=0.;
+  Double_t clX() {
+    Double_t x_sum=0.;
+    Double_t Etot=0.;
     for (THcShowerHitIt it=THcShowerHitList::begin();
 	 it!=THcShowerHitList::end(); it++) {
       x_sum += (*it)->hitX() * (*it)->hitE();
@@ -60,9 +60,9 @@ class THcShowerCluster : THcShowerHitList {
 
   //Z coordinate for a cluster, calculated as a weighted by energy average.
   //
-  float clZ() {
-    float z_sum=0.;
-    float Etot=0.;
+  Double_t clZ() {
+    Double_t z_sum=0.;
+    Double_t Etot=0.;
     for (THcShowerHitIt it=THcShowerHitList::begin();
 	 it!=THcShowerHitList::end(); it++) {
       z_sum += (*it)->hitZ() * (*it)->hitE();
@@ -74,9 +74,9 @@ class THcShowerCluster : THcShowerHitList {
 
   //Energy depostion in a cluster
   //
-  float clE() {
+  Double_t clE() {
     //    cout << "In ECl:" << endl;
-    float Etot=0.;
+    Double_t Etot=0.;
     for (THcShowerHitIt it=THcShowerHitList::begin();
 	 it!=THcShowerHitList::end(); it++) {
       Etot += (*it)->hitE();
@@ -86,8 +86,8 @@ class THcShowerCluster : THcShowerHitList {
 
   //Energy deposition in the Preshower (1st layer) for a cluster
   //
-  float clEpr() {
-    float Epr=0.;
+  Double_t clEpr() {
+    Double_t Epr=0.;
     for (THcShowerHitIt it=THcShowerHitList::begin();
 	 it!=THcShowerHitList::end(); it++) {
       if ((*it)->hitColumn() == 0) Epr += (*it)->hitE();
diff --git a/src/THcShowerHit.h b/src/THcShowerHit.h
index fc6b154..edf8ac0 100644
--- a/src/THcShowerHit.h
+++ b/src/THcShowerHit.h
@@ -13,8 +13,8 @@ class THcShowerHit {           //HMS calorimeter hit class
 
  private:
   UInt_t fCol, fRow; //hit colomn and row
-  float fX, fZ;            //hit X (vert.) and Z (along spect.axis) coordinates
-  float fE;                 //hit energy deposition
+  Double_t fX, fZ;            //hit X (vert.) and Z (along spect.axis) coordinates
+  Double_t fE;                 //hit energy deposition
 
  public:
 
@@ -24,8 +24,8 @@ class THcShowerHit {           //HMS calorimeter hit class
   fE=0.;
   }
 
-  THcShowerHit(UInt_t hRow, UInt_t hCol, float hX, float hZ,
-	       float hE) {
+  THcShowerHit(UInt_t hRow, UInt_t hCol, Double_t hX, Double_t hZ,
+	       Double_t hE) {
     fRow=hRow;
     fCol=hCol;
     fX=hX;
@@ -45,15 +45,15 @@ class THcShowerHit {           //HMS calorimeter hit class
     return fRow;
   }
 
-  float hitX() {
+  Double_t hitX() {
     return fX;
   }
 
-  float hitZ() {
+  Double_t hitZ() {
     return fZ;
   }
 
-  float hitE() {
+  Double_t hitE() {
     return fE;
   }
 
diff --git a/src/THcShowerPlane.cxx b/src/THcShowerPlane.cxx
index aeb85b2..b9ffc2b 100644
--- a/src/THcShowerPlane.cxx
+++ b/src/THcShowerPlane.cxx
@@ -115,14 +115,14 @@ Int_t THcShowerPlane::ReadDatabase( const TDatime& date )
   //  cout << "THcShowerPlane::ReadDatabase: fLayerNum=" << fLayerNum 
   //       << "  fNelem=" << fNelem << endl;
 
-  fA_Pos = new Float_t[fNelem];
-  fA_Neg = new Float_t[fNelem];
-  fA_Pos_p = new Float_t[fNelem];
-  fA_Neg_p = new Float_t[fNelem];
+  fA_Pos = new Double_t[fNelem];
+  fA_Neg = new Double_t[fNelem];
+  fA_Pos_p = new Double_t[fNelem];
+  fA_Neg_p = new Double_t[fNelem];
 
-  fEpos = new Float_t[fNelem];
-  fEneg = new Float_t[fNelem];
-  fEmean= new Float_t[fNelem];
+  fEpos = new Double_t[fNelem];
+  fEneg = new Double_t[fNelem];
+  fEmean= new Double_t[fNelem];
 
  //  fNelem = *(Int_t *)gHcParms->Find(parname)->GetValuePointer();
 // 
@@ -351,15 +351,15 @@ void THcShowerPlane::CalculatePedestals( )
   for(Int_t i=0; i<fNelem;i++) {
     
     // Positive tubes
-    fPosPed[i] = ((Double_t) fPosPedSum[i]) / TMath::Max(1, fPosPedCount[i]);
-    fPosSig[i] = sqrt((fPosPedSum2[i] - 2.*fPosPed[i]*fPosPedSum[i])/TMath::Max(1, fPosPedCount[i]) + fPosPed[i]*fPosPed[i]);
-    //  fPosThresh[i] = fPosPed[i] + 15;
+    fPosPed[i] = ((Float_t) fPosPedSum[i]) / TMath::Max(1, fPosPedCount[i]);
+    fPosSig[i] = sqrt(((Float_t)fPosPedSum2[i])/TMath::Max(1, fPosPedCount[i])
+		      - fPosPed[i]*fPosPed[i]);
     fPosThresh[i] = fPosPed[i] + TMath::Min(50., TMath::Max(10., 3.*fPosSig[i]));
 
     // Negative tubes
-    fNegPed[i] = ((Double_t) fNegPedSum[i]) / TMath::Max(1, fNegPedCount[i]);
-    fNegSig[i] = sqrt((fNegPedSum2[i] - 2.*fNegPed[i]*fNegPedSum[i])/TMath::Max(1, fNegPedCount[i]) + fNegPed[i]*fNegPed[i]);
-    //  fNegThresh[i] = fNegPed[i] + 15;
+    fNegPed[i] = ((Float_t) fNegPedSum[i]) / TMath::Max(1, fNegPedCount[i]);
+    fNegSig[i] = sqrt(((Float_t)fNegPedSum2[i])/TMath::Max(1, fNegPedCount[i])
+		      - fNegPed[i]*fNegPed[i]);
     fNegThresh[i] = fNegPed[i] + TMath::Min(50., TMath::Max(10., 3.*fNegSig[i]));
 
     cout << "Ped&Thr: " << fPosPed[i] << " " << fPosThresh[i] << " " <<
@@ -380,12 +380,12 @@ void THcShowerPlane::InitializePedestals( )
   fNegPedSum2 = new Int_t [fNelem];
   fNegPedCount = new Int_t [fNelem];
 
-  fPosSig = new Double_t [fNelem];
-  fNegSig = new Double_t [fNelem];
-  fPosPed = new Double_t [fNelem];
-  fNegPed = new Double_t [fNelem];
-  fPosThresh = new Double_t [fNelem];
-  fNegThresh = new Double_t [fNelem];
+  fPosSig = new Float_t [fNelem];
+  fNegSig = new Float_t [fNelem];
+  fPosPed = new Float_t [fNelem];
+  fNegPed = new Float_t [fNelem];
+  fPosThresh = new Float_t [fNelem];
+  fNegThresh = new Float_t [fNelem];
   for(Int_t i=0;i<fNelem;i++) {
     fPosPedSum[i] = 0;
     fPosPedSum2[i] = 0;
diff --git a/src/THcShowerPlane.h b/src/THcShowerPlane.h
index c38218b..ce4f256 100644
--- a/src/THcShowerPlane.h
+++ b/src/THcShowerPlane.h
@@ -46,57 +46,57 @@ class THcShowerPlane : public THaSubDetector {
 
   TClonesArray* fParentHitList;
 
-  Float_t GetEplane() {
+  Double_t GetEplane() {
     return fEplane;
   };
 
-  Float_t GetEmean(Int_t i) {
+  Double_t GetEmean(Int_t i) {
     return fEmean[i];
   };
 
-  Float_t GetAposP(Int_t i) {
+  Double_t GetAposP(Int_t i) {
     return fA_Pos_p[i];
   };
 
-  Float_t GetAnegP(Int_t i) {
+  Double_t GetAnegP(Int_t i) {
     return fA_Neg_p[i];
   };
 
-  Float_t GetApos(Int_t i) {
+  Double_t GetApos(Int_t i) {
     return fA_Pos[i];
   };
 
-  Float_t GetAneg(Int_t i) {
+  Double_t GetAneg(Int_t i) {
     return fA_Neg[i];
   };
 
-  Float_t GetPosThr(Int_t i) {
+  Double_t GetPosThr(Int_t i) {
     return fPosThresh[i];
   };
 
-  Float_t GetNegThr(Int_t i) {
+  Double_t GetNegThr(Int_t i) {
     return fNegThresh[i];
   };
 
-  Float_t GetPosPed(Int_t i) {
+  Double_t GetPosPed(Int_t i) {
     return fPosPed[i];
   };
 
-  Float_t GetNegPed(Int_t i) {
+  Double_t GetNegPed(Int_t i) {
     return fNegPed[i];
   };
 
  protected:
 
-  Float_t*   fA_Pos;         // [fNelem] Array of ADC amplitudes of blocks
-  Float_t*   fA_Neg;         // [fNelem] Array of ADC amplitudes of blocks
-  Float_t*   fA_Pos_p;	     // [fNelem] Array of pedestal subtracted ADC amplitudes
-  Float_t*   fA_Neg_p;	     // [fNelem] Array of pedestal subtracted ADC amplitudes
+  Double_t*   fA_Pos;         // [fNelem] Array of ADC amplitudes of blocks
+  Double_t*   fA_Neg;         // [fNelem] Array of ADC amplitudes of blocks
+  Double_t*   fA_Pos_p;	     // [fNelem] Array of pedestal subtracted ADC amplitudes
+  Double_t*   fA_Neg_p;	     // [fNelem] Array of pedestal subtracted ADC amplitudes
 
-  Float_t* fEpos;     // [fNelem] Array of energy depositions seen by positive PMTs
-  Float_t* fEneg;     // [fNelem] Array of energy depositions seen by negative PMTs
-  Float_t* fEmean;    // [fNelem] Array of mean energy depositions (pos + neg)
-  Float_t  fEplane;   // Energy deposition per plane
+  Double_t* fEpos;     // [fNelem] Array of energy depositions seen by positive PMTs
+  Double_t* fEneg;     // [fNelem] Array of energy depositions seen by negative PMTs
+  Double_t* fEmean;    // [fNelem] Array of mean energy depositions (pos + neg)
+  Double_t  fEplane;   // Energy deposition per plane
 
   TClonesArray* fPosADCHits;
   TClonesArray* fNegADCHits;
@@ -115,13 +115,18 @@ class THcShowerPlane : public THaSubDetector {
   Int_t *fNegPedLimit;
   Int_t *fNegPedCount;
 
-  Double_t *fPosPed;
-  Double_t *fPosSig;
-  Double_t *fPosThresh;
-  Double_t *fNegPed;
-  Double_t *fNegSig;
-  Double_t *fNegThresh;
-
+  //  Double_t *fPosPed;
+  //  Double_t *fPosSig;
+  //  Double_t *fPosThresh;
+  //  Double_t *fNegPed;
+  //  Double_t *fNegSig;
+  //  Double_t *fNegThresh;
+  Float_t *fPosPed;      //To be consistent with Engine
+  Float_t *fPosSig;
+  Float_t *fPosThresh;
+  Float_t *fNegPed;
+  Float_t *fNegSig;
+  Float_t *fNegThresh;
 
   virtual Int_t  ReadDatabase( const TDatime& date );
   virtual Int_t  DefineVariables( EMode mode = kDefine );
-- 
GitLab