diff --git a/Makefile b/Makefile
index b863154d236e2db26cce043cd237aa926a3554ac..ddae59d2923feeb337cb9d0b6e2b33c45561846a 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@ SRC  =  src/THcInterface.cxx src/THcParmList.cxx src/THcAnalyzer.cxx \
 	src/THcDCLookupTTDConv.cxx src/THcDCTimeToDistConv.cxx \
 	src/THcSpacePoint.cxx src/THcDCTrack.cxx \
 	src/THcShower.cxx src/THcShowerPlane.cxx \
-	src/THcShowerHit.cxx \
+	src/THcRawShowerHit.cxx \
 	src/THcAerogel.cxx src/THcAerogelHit.cxx
 
 # Name of your package. 
diff --git a/examples/DBASE/test.database b/examples/DBASE/test.database
index 59790ba98ea08703314c7abaf958b99877f5e8fe..742f7073ae21178f571c6130a81b700d1d5f1dcf 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/jan03.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/MAPS/july04.map b/examples/MAPS/july04.map
index 1b963b508e1ccb69ce88e7e687958fbbb25bcc96..7551ce6553363614d187bee04425a57a7c93713c 100644
--- a/examples/MAPS/july04.map
+++ b/examples/MAPS/july04.map
@@ -1308,7 +1308,7 @@ Slot= 22
   50, 2, 5, 3 !TDC ROC#1 Sl#23 Ch#50 HSCIN pl#2 [Y1] id#5 sig#3 [TDC-] (50 Y1N-05)
   51, 2, 7, 3 !TDC ROC#1 Sl#23 Ch#51 HSCIN pl#2 [Y1] id#7 sig#3 [TDC-] (51 Y1N-07)
   52, 2, 9, 3 !TDC ROC#1 Sl#23 Ch#52 HSCIN pl#2 [Y1] id#9 sig#3 [TDC-] (52 Y1N-09)
-  53, 2, 10, 3 !TDC ROC#1 Sl#23 Ch#53 Y1N-10 As Of 12 Apr 07
+!  53 !TDC ROC#1 Sl#23 Ch#53 unused
 !  54 !TDC ROC#1 Sl#23 Ch#54 unused
 !  55 !TDC ROC#1 Sl#23 Ch#55 unused
   56, 2, 2, 3 !TDC ROC#1 Sl#23 Ch#56 HSCIN pl#2 [Y1] id#2 sig#3 [TDC-] (56 Y1N-02)
@@ -1316,10 +1316,9 @@ Slot= 22
   58, 2, 6, 3 !TDC ROC#1 Sl#23 Ch#58 HSCIN pl#2 [Y1] id#6 sig#3 [TDC-] (58 Y1N-06)
   59, 2, 8, 3 !TDC ROC#1 Sl#23 Ch#59 HSCIN pl#2 [Y1] id#8 sig#3 [TDC-] (59 Y1N-08)
 !  60, 2, 10, 3 !TDC ROC#1 Sl#23 Ch#60 HSCIN pl#2 [Y1] id#10 sig#3 [TDC-] (60 Y1N-10)
-!  61, 2, 10, 3 !TDC ROC#1 Sl#23 Ch#61 swap location for h1y10-
+  61 , 2, 10, 3 !TDC ROC#1 Sl#23 Ch#61 swap location for h1y10-
 !  62 !TDC ROC#1 Sl#23 Ch#62 unused
 !  63 !TDC ROC#1 Sl#23 Ch#63 unused
-!  Channels 60-63 possibly bad 12 Apr 07 - moved Y1N-10 to 53
 !
  Slot= 21 ! TDC  
 ! 
@@ -1620,8 +1619,7 @@ Slot= 22
   41, 2, 4, 0 !ADC ROC#1 Sl#9 Ch#41 HSCIN pl#2 [Y1] id#4 sig#0 [ADC+] (41 Y1P-04)
   42, 2, 6, 0 !ADC ROC#1 Sl#9 Ch#42 HSCIN pl#2 [Y1] id#6 sig#0 [ADC+] (42 Y1P-06)
   43, 2, 8, 0 !ADC ROC#1 Sl#9 Ch#43 HSCIN pl#2 [Y1] id#8 sig#0 [ADC+] (43 Y1P-08)
-  44, 2, 10, 0 !ADC ROC#1 Sl#9 Ch#44 HSCIN pl#2 [Y1] id#10 sig#0 [ADC+] (44 Y1P-10) as of 19 Apr 07 (PS)
-!  37, 2, 10, 0 !ADC ROC#1 Sl#9 Ch#44 HSCIN pl#2 [Y1] id#10 sig#0 [ADC+] (44 Y1P-10)
+  44, 2, 10, 0 !ADC ROC#1 Sl#9 Ch#44 HSCIN pl#2 [Y1] id#10 sig#0 [ADC+] (44 Y1P-10)
 !  45 !ADC ROC#1 Sl#9 Ch#45 unused
 !  46 !ADC ROC#1 Sl#9 Ch#46 unused
 !  47 !ADC ROC#1 Sl#9 Ch#47 unused
@@ -1715,22 +1713,22 @@ Slot= 22
     detector= 4 !HCAL
 !
  Slot= 1 ! ADC  
-   0, 1, 1  !Adc Roc#1 Sl#1 Ch#0 Hcal Col#1 Row#1 (0 A-01)
-   1, 1, 2  !Adc Roc#1 Sl#1 Ch#1 Hcal Col#1 Row#2 (1 A-02)
-   2, 1, 3  !Adc Roc#1 Sl#1 Ch#2 Hcal Col#1 Row#3 (2 A-03)
-   3, 1, 4  !Adc Roc#1 Sl#1 Ch#3 Hcal Col#1 Row#4 (3 A-04)
-   4, 1, 5  !Adc Roc#1 Sl#1 Ch#4 Hcal Col#1 Row#5 (4 A-05)
-   5, 1, 6  !Adc Roc#1 Sl#1 Ch#5 Hcal Col#1 Row#6 (5 A-06)
-   6, 1, 7  !Adc Roc#1 Sl#1 Ch#6 Hcal Col#1 Row#7 (6 A-07)
-   7, 1, 8  !Adc Roc#1 Sl#1 Ch#7 Hcal Col#1 Row#8 (7 A-08)
-   8, 1, 9  !Adc Roc#1 Sl#1 Ch#8 Hcal Col#1 Row#9 (8 A-09)
-   9, 1, 10 !Adc Roc#1 Sl#1 Ch#9 Hcal Col#1 Row#10 (9 A-10)
-  10, 1, 11 !Adc Roc#1 Sl#1 Ch#10 Hcal Col#1 Row#11 (10 A-11)
-  11, 1, 12 !Adc Roc#1 Sl#1 Ch#11 Hcal Col#1 Row#12 (11 A-12)
-  12, 1, 13 !Adc Roc#1 Sl#1 Ch#12 Hcal Col#1 Row#13 (12 A-13)
-!   13 !Adc Roc#1 Sl#1 Ch#13 Unused
-!   14 !Adc Roc#1 Sl#1 Ch#14 Unused
-!   15 !Adc Roc#1 Sl#1 Ch#15 Unused
+   0, 1, 1  !ADC ROC#1 Sl#1 Ch#0 HCAL col#1 row#1 (0 A-01)
+   1, 1, 2  !ADC ROC#1 Sl#1 Ch#1 HCAL col#1 row#2 (1 A-02)
+   2, 1, 3  !ADC ROC#1 Sl#1 Ch#2 HCAL col#1 row#3 (2 A-03)
+   3, 1, 4  !ADC ROC#1 Sl#1 Ch#3 HCAL col#1 row#4 (3 A-04)
+   4, 1, 5  !ADC ROC#1 Sl#1 Ch#4 HCAL col#1 row#5 (4 A-05)
+   5, 1, 6  !ADC ROC#1 Sl#1 Ch#5 HCAL col#1 row#6 (5 A-06)
+   6, 1, 7  !ADC ROC#1 Sl#1 Ch#6 HCAL col#1 row#7 (6 A-07)
+   7, 1, 8  !ADC ROC#1 Sl#1 Ch#7 HCAL col#1 row#8 (7 A-08)
+   8, 1, 9  !ADC ROC#1 Sl#1 Ch#8 HCAL col#1 row#9 (8 A-09)
+   9, 1, 10 !ADC ROC#1 Sl#1 Ch#9 HCAL col#1 row#10 (9 A-10)
+  10, 1, 11 !ADC ROC#1 Sl#1 Ch#10 HCAL col#1 row#11 (10 A-11)
+  11, 1, 12 !ADC ROC#1 Sl#1 Ch#11 HCAL col#1 row#12 (11 A-12)
+  12, 1, 13 !ADC ROC#1 Sl#1 Ch#12 HCAL col#1 row#13 (12 A-13)
+!   13 !ADC ROC#1 Sl#1 Ch#13 unused
+!   14 !ADC ROC#1 Sl#1 Ch#14 unused
+!   15 !ADC ROC#1 Sl#1 Ch#15 unused
   16, 2, 1  !ADC ROC#1 Sl#1 Ch#16 HCAL col#2 row#1 (16 B-01)
   17, 2, 2  !ADC ROC#1 Sl#1 Ch#17 HCAL col#2 row#2 (17 B-02)
   18, 2, 3  !ADC ROC#1 Sl#1 Ch#18 HCAL col#2 row#3 (18 B-03)
@@ -1772,16 +1770,16 @@ Slot= 22
   54, 4, 7  !ADC ROC#1 Sl#1 Ch#54 HCAL col#4 row#7 (54 D-07)
   55, 4, 8  !ADC ROC#1 Sl#1 Ch#55 HCAL col#4 row#8 (55 D-08)
   56, 4, 9  !ADC ROC#1 Sl#1 Ch#56 HCAL col#4 row#9 (56 D-09)
-  63, 4, 10 !ADC ROC#1 Sl#1 Ch#57 HCAL col#4 row#10 (57 D-10)
-!  57, 4, 10 !ADC ROC#1 Sl#1 Ch#57 HCAL col#4 row#10 (57 D-10) (05/09/07, Patricia, flaky ribbon channel)
+  57, 4, 10 !ADC ROC#1 Sl#1 Ch#57 HCAL col#4 row#10 (57 D-10)
   58, 4, 11 !ADC ROC#1 Sl#1 Ch#58 HCAL col#4 row#11 (58 D-11)
   59, 4, 12 !ADC ROC#1 Sl#1 Ch#59 HCAL col#4 row#12 (59 D-12)
   60, 4, 13 !ADC ROC#1 Sl#1 Ch#60 HCAL col#4 row#13 (60 D-13)
+!
 !  61 !ADC ROC#1 Sl#1 Ch#61 unused
 
     detector= 5    !HMISC - scintillator (ADCs) - behind calorimeter
   62, 2, 1, 0 !2,1,0 stands for: 2=adc,channel#1,0=dummy(pos vs. neg).
-!  63, 2, 2, 0 !
+  63, 2, 2, 0 !
 !
 detector= 4 !HCAL
 Slot= 5 ! ADC  Second set of tubes on first two layers
@@ -1796,7 +1794,7 @@ Slot= 5 ! ADC  Second set of tubes on first two layers
   8, 1, 9, 1 !ADC ROC#1 Sl#5 Ch#8 HCAL col#1 row#9 (8 An-09)
   9, 1, 10, 1 !ADC ROC#1 Sl#5 Ch#9 HCAL col#1 row#10 (9 An-10)
   10, 1, 11, 1 !ADC ROC#1 Sl#5 Ch#10 HCAL col#1 row#11 (10 An-11)
-  11, 1, 12, 1 !ADC ROC#1 Sl#5 Ch#11 HCAL col#1 row#12 (11 An-12)
+  11, 1, 12, 1 !ADC ROC#1 Sl#5 Ch#11 HCAL col#1 row#12 (11 An-112)
   12, 1, 13, 1 !ADC ROC#1 Sl#5 Ch#12 HCAL col#1 row#13 (12 An-13)
 !  13 !ADC ROC#1 Sl#5 Ch#13 unused
 !  14 !ADC ROC#1 Sl#5 Ch#14 unused
@@ -1813,8 +1811,7 @@ Slot= 5 ! ADC  Second set of tubes on first two layers
   25, 2, 10, 1 !ADC ROC#1 Sl#5 Ch#25 HCAL col#2 row#10 (25 Bn-10)
   26, 2, 11, 1 !ADC ROC#1 Sl#5 Ch#26 HCAL col#2 row#11 (26 Bn-11)
   27, 2, 12, 1 !ADC ROC#1 Sl#5 Ch#27 HCAL col#2 row#12 (27 Bn-12)
-  30, 2, 13, 1 !ADC ROC#1 Sl#5 Ch#30 HCAL col#2 row#13 (30 Bn-13)
-!  28, 2, 13, 1 !ADC ROC#1 Sl#5 Ch#28 HCAL col#2 row#13 (28 Bn-13) (05/09/07, bad ADC channel, put it at 30)
+  28, 2, 13, 1 !ADC ROC#1 Sl#5 Ch#28 HCAL col#2 row#13 (28 Bn-13)
 !  29 !ADC ROC#1 Sl#1 Ch#29 unused
 !  30 !ADC ROC#1 Sl#1 Ch#30 unused
 !  31 !ADC ROC#1 Sl#1 Ch#31 unused
@@ -1891,9 +1888,6 @@ Slot= 5 ! ADC  Second set of tubes on first two layers
 !   13 !ADC ROC#1 Sl#3 Ch#13 unused
 !   14 !ADC ROC#1 Sl#3 Ch#14 unused
 !   15 !ADC ROC#1 Sl#3 Ch#15 unused
-!   13 !ADC ROC#1 Sl#1 Ch#13 unused
-!   14 !ADC ROC#1 Sl#1 Ch#14 unused
-!   15 !ADC ROC#1 Sl#1 Ch#15 unused
 !   16 !ADC ROC#1 Sl#3 Ch#16 unused
 !   17 !ADC ROC#1 Sl#3 Ch#17 unused
 !   18 !ADC ROC#1 Sl#3 Ch#18 unused
@@ -1958,10 +1952,10 @@ Slot= 5 ! ADC  Second set of tubes on first two layers
 !
   Slot= 13
 !
-  0, 2, 17, 0 !ADC ROC#1 Sl#15 Ch#0 H00C X+
-  1, 2, 18, 0 !ADC ROC#1 Sl#15 Ch#1 H00C X-
-  2, 2, 19, 0 !ADC ROC#1 Sl#15 Ch#2 H00C Y+
-  3, 2, 20, 0 !ADC ROC#1 Sl#15 Ch#3 H00C Y-
+!  0, 2, 1, 0 !ADC ROC#1 Sl#15 Ch#0
+!  1, 2, 2, 0 !ADC ROC#1 Sl#15 Ch#1
+!  2, 2, 3, 0 !ADC ROC#1 Sl#15 Ch#2
+!  3, 2, 4, 0 !ADC ROC#1 Sl#15 Ch#3
   4, 2, 5, 0 !ADC ROC#1 Sl#15 Ch#4 H00A X+
   5, 2, 6, 0 !ADC ROC#1 Sl#15 Ch#5 H00A X-
   6, 2, 7, 0 !ADC ROC#1 Sl#15 Ch#6 H00A Y+
@@ -1979,10 +1973,10 @@ Slot= 5 ! ADC  Second set of tubes on first two layers
   15, 2, 14, 0 !ADC ROC#1 Sl#15 Ch#15 Fast Raster X-signal
   12, 2, 15, 0 !ADC ROC#1 Sl#15 Ch#12 Fast Raster Y-sync
   13, 2, 16, 0 !ADC ROC#1 Sl#15 Ch#13 Fast Raster Y-signal
-!  16, 2, 17, 0  !ADC ROC#1 Sl#15 Ch#16 H00C X+
-!  17, 2, 18, 0  !ADC ROC#1 Sl#15 Ch#17 H00C X-
-!  18, 2, 19, 0  !ADC ROC#1 Sl#15 Ch#18 H00C Y+
-!  19, 2, 20, 0  !ADC ROC#1 Sl#15 Ch#19 H00C Y-
+  16, 2, 17, 0  !ADC ROC#1 Sl#15 Ch#16 H00C X+
+  17, 2, 18, 0  !ADC ROC#1 Sl#15 Ch#17 H00C X-
+  18, 2, 19, 0  !ADC ROC#1 Sl#15 Ch#18 H00C Y+
+  19, 2, 20, 0  !ADC ROC#1 Sl#15 Ch#19 H00C Y-
 !   20 !ADC ROC#1 Sl#15 Ch#20 unused
 !   21 !ADC ROC#1 Sl#15 Ch#21 unused
   22, 2, 23, 0  !ADC ROC#1 Sl#15 Ch#22 Raster gate
@@ -2730,42 +2724,6 @@ Slot= 5 ! ADC  Second set of tubes on first two layers
  62, 10, 63
  63, 10, 64
 !
-! Use for runs before July 3rd 8:00am
-!    detector= 15 !SMISC for tracker
-!95, 1, 81, 0  ! 0 !TDC ROC#4 Sl#12 track 3
-!83, 1, 82, 0  ! 0 !TDC ROC#4 Sl#12 track 4
-!82, 1, 83, 0  ! 0 !TDC ROC#4 Sl#12 track 5
-!81, 1, 84, 0  ! 0 !TDC ROC#4 Sl#12 track 6   
-!84, 1, 85, 0  ! 0 !TDC ROC#4 Sl#12 track 7   
-!85, 1, 86, 0  ! 0 !TDC ROC#4 Sl#12 track 8   
-!86, 1, 87, 0  ! 0 !TDC ROC#4 Sl#12 track 9   
-!87, 1, 88, 0  ! 0 !TDC ROC#4 Sl#12 track 10 
-! before run 63466 track 11 in chan 88 and fiber 1 in chan 90 
-! after run 63466 track 11 in chan 90 and fiber 1 in chan 88 
-!90, 1, 89, 0  ! 0 !TDC ROC#4 Sl#12 track 11  
-!89, 1, 90, 0  ! 0 !TDC ROC#4 Sl#12 track 12 
-!88, 1, 91, 0  ! 0 !TDC ROC#4 Sl#12 fiber 1    
-!91, 1, 92, 0  ! 0 !TDC ROC#4 Sl#12 bad    
-!92, 1, 93, 0  ! 0 !TDC ROC#4 Sl#12 fiber 2    
-!93, 1, 94, 0  ! 0 !TDC ROC#4 Sl#12 fiber 3
-!94, 1, 95, 0  ! 0 !TDC ROC#4 Sl#12 fiber 4  
-!
-! Use for runs after July 3rd 8:00am ( CAMAC slot 19 mod 3412 8mV disc)
- 82, 1, 81, 0  ! 0 !TDC ROC#4 Sl#12 track 3   
- 83, 1, 82, 0  ! 0 !TDC ROC#4 Sl#12 track 4   
- 84, 1, 83, 0  ! 0 !TDC ROC#4 Sl#12 track 5   
- 85, 1, 84, 0  ! 0 !TDC ROC#4 Sl#12 track 6   
- 86, 1, 85, 0  ! 0 !TDC ROC#4 Sl#12 track 7   
- 87, 1, 86, 0  ! 0 !TDC ROC#4 Sl#12 track 8   
- 88, 1, 87, 0  ! 0 !TDC ROC#4 Sl#12 track 9   
- 89, 1, 88, 0  ! 0 !TDC ROC#4 Sl#12 track 10  
- 90, 1, 89, 0  ! 0 !TDC ROC#4 Sl#12 track 11  
- 91, 1, 90, 0  ! 0 !TDC ROC#4 Sl#12 track 12 
- 92, 1, 91, 0  ! 0 !TDC ROC#4 Sl#12 fiber 1    
- 93, 1, 93, 0  ! 0 !TDC ROC#4 Sl#12 fiber 2    
- 94, 1, 94, 0  ! 0 !TDC ROC#4 Sl#12 fiber 3
- 95, 1, 95, 0  ! 0 !TDC ROC#4 Sl#12 fiber 4  
-
 !   SOS upstairs (SSCIN+SCAL+SCER) map    K.B.Beard 13-Jun-1994
 !
     ROC= 3               !upstairs SOS crate (fbch2)
@@ -2998,8 +2956,6 @@ Slot= 5 ! ADC  Second set of tubes on first two layers
 !  44 !ADC ROC#3 Sl#9 Ch#44 unused
 !  45 !ADC ROC#3 Sl#9 Ch#45 unused
 !  46 !ADC ROC#3 Sl#9 Ch#46 unused
-  45, 3, 16, 0 !ADC ROC#3 Sl#7 Ch#15 SSCIN pl#3 [X2] id sig#16 [ADC+]
-  47, 3, 16, 1 !ADC ROC#3 Sl#7 Ch#31 SSCIN pl#3 [X2] id sig#16 [ADC-]
 !  47 !ADC ROC#3 Sl#9 Ch#47 unused
   48, 2, 1, 1 !ADC ROC#3 Sl#9 Ch#48 SSCIN pl#2 [Y1] id sig#1 [ADC-]
   49, 2, 3, 1 !ADC ROC#3 Sl#9 Ch#49 SSCIN pl#2 [Y1] id sig#3 [ADC-]
@@ -3034,7 +2990,7 @@ Slot= 5 ! ADC  Second set of tubes on first two layers
   12, 3, 10, 0 !ADC ROC#3 Sl#7 Ch#12 SSCIN pl#3 [X2] id sig#10 [ADC+]
   13, 3, 12, 0 !ADC ROC#3 Sl#7 Ch#13 SSCIN pl#3 [X2] id sig#12 [ADC+]
   14, 3, 14, 0 !ADC ROC#3 Sl#7 Ch#14 SSCIN pl#3 [X2] id sig#14 [ADC+]
-!  15, 3, 16, 0 !ADC ROC#3 Sl#7 Ch#15 SSCIN pl#3 [X2] id sig#16 [ADC+]
+  15, 3, 16, 0 !ADC ROC#3 Sl#7 Ch#15 SSCIN pl#3 [X2] id sig#16 [ADC+]
   16, 3, 1, 1 !ADC ROC#3 Sl#7 Ch#16 SSCIN pl#3 [X2] id sig#1 [ADC-]
   17, 3, 3, 1 !ADC ROC#3 Sl#7 Ch#17 SSCIN pl#3 [X2] id sig#3 [ADC-]
   18, 3, 5, 1 !ADC ROC#3 Sl#7 Ch#18 SSCIN pl#3 [X2] id sig#5 [ADC-]
@@ -3050,7 +3006,7 @@ Slot= 5 ! ADC  Second set of tubes on first two layers
   28, 3, 10, 1 !ADC ROC#3 Sl#7 Ch#28 SSCIN pl#3 [X2] id sig#10 [ADC-]
   29, 3, 12, 1 !ADC ROC#3 Sl#7 Ch#29 SSCIN pl#3 [X2] id sig#12 [ADC-]
   30, 3, 14, 1 !ADC ROC#3 Sl#7 Ch#30 SSCIN pl#3 [X2] id sig#14 [ADC-]
-!  31, 3, 16, 1 !ADC ROC#3 Sl#7 Ch#31 SSCIN pl#3 [X2] id sig#16 [ADC-]
+  31, 3, 16, 1 !ADC ROC#3 Sl#7 Ch#31 SSCIN pl#3 [X2] id sig#16 [ADC-]
   32, 4, 1, 0 !ADC ROC#3 Sl#7 Ch#32 SSCIN pl#4 [Y2] id sig#1 [ADC+]
   33, 4, 3, 0 !ADC ROC#3 Sl#7 Ch#33 SSCIN pl#4 [Y2] id sig#3 [ADC+]
   34, 4, 5, 0 !ADC ROC#3 Sl#7 Ch#34 SSCIN pl#4 [Y2] id sig#5 [ADC+]
@@ -3088,7 +3044,7 @@ Slot= 5 ! ADC  Second set of tubes on first two layers
 !
  Slot= 1 ! ADC  
   0, 1, 1 !ADC ROC#3 Sl#1 Ch#0 SCAL column#1 row#1
-! 1  !ADC ROC#3 Sl#1 Ch#2 unused
+  1, 1, 2 !ADC ROC#3 Sl#1 Ch#1 SCAL column#1 row#2
   2, 1, 3 !ADC ROC#3 Sl#1 Ch#2 SCAL column#1 row#3
   3, 1, 4 !ADC ROC#3 Sl#1 Ch#3 SCAL column#1 row#4
   4, 1, 5 !ADC ROC#3 Sl#1 Ch#4 SCAL column#1 row#5
@@ -3096,12 +3052,12 @@ Slot= 5 ! ADC  Second set of tubes on first two layers
   6, 1, 7 !ADC ROC#3 Sl#1 Ch#6 SCAL column#1 row#7
   7, 1, 8 !ADC ROC#3 Sl#1 Ch#7 SCAL column#1 row#8
   8, 1, 9 !ADC ROC#3 Sl#1 Ch#8 SCAL column#1 row#9
-! 9  !ADC ROC#3 Sl#1 Ch#9 unused
-! 10 !ADC ROC#3 Sl#1 Ch#10 unused
-  11, 1, 2 !ADC ROC#3 Sl#1 Ch#1 SCAL column#1 row#2
-  12, 1, 11 !ADC ROC#3 Sl#1 Ch#10 SCAL column#1 row#11
-  13, 1, 10 !ADC ROC#3 Sl#1 Ch#9 SCAL column#1 row#10
-! 14  !ADC ROC#3 Sl#1 Ch#14 unused
+  9, 1, 10 !ADC ROC#3 Sl#1 Ch#9 SCAL column#1 row#10
+  10, 1, 11 !ADC ROC#3 Sl#1 Ch#10 SCAL column#1 row#11
+!  11 !ADC ROC#3 Sl#1 Ch#11 unused
+!  12 !ADC ROC#3 Sl#1 Ch#12 unused
+!  13 !ADC ROC#3 Sl#1 Ch#13 unused
+!  14 !ADC ROC#3 Sl#1 Ch#14 unused
 !  15 !ADC ROC#3 Sl#1 Ch#15 unused
   16, 2, 1 !ADC ROC#3 Sl#1 Ch#16 SCAL column#2 row#1
   17, 2, 2 !ADC ROC#3 Sl#1 Ch#17 SCAL column#2 row#2
@@ -3119,19 +3075,20 @@ Slot= 5 ! ADC  Second set of tubes on first two layers
 !  29 !ADC ROC#3 Sl#1 Ch#29 unused
 !  30 !ADC ROC#3 Sl#1 Ch#30 unused
 !  31 !ADC ROC#3 Sl#1 Ch#31 unused
-  32, 3, 1 !ADC ROC#3 Sl#1 Ch#32 SCAL column#3 row#1
+!  32, 3, 1 !ADC ROC#3 Sl#1 Ch#32 SCAL column#3 row#1  
+  44, 3, 1 !ADC ROC#3 Sl#1 Ch#32 SCAL column#3 row#1
   33, 3, 2 !ADC ROC#3 Sl#1 Ch#33 SCAL column#3 row#2
   34, 3, 3 !ADC ROC#3 Sl#1 Ch#34 SCAL column#3 row#3
   35, 3, 4 !ADC ROC#3 Sl#1 Ch#35 SCAL column#3 row#4
   36, 3, 5 !ADC ROC#3 Sl#1 Ch#36 SCAL column#3 row#5
-! 37 !ADC ROC#3 Sl#1 Ch#37 unused
+  37, 3, 6 !ADC ROC#3 Sl#1 Ch#37 SCAL column#3 row#6
   38, 3, 7 !ADC ROC#3 Sl#1 Ch#38 SCAL column#3 row#7
   39, 3, 8 !ADC ROC#3 Sl#1 Ch#39 SCAL column#3 row#8
   40, 3, 9 !ADC ROC#3 Sl#1 Ch#40 SCAL column#3 row#9
   41, 3, 10 !ADC ROC#3 Sl#1 Ch#41 SCAL column#3 row#10
   42, 3, 11 !ADC ROC#3 Sl#1 Ch#42 SCAL column#3 row#11
-  43, 3, 6 !ADC ROC#3 Sl#1 Ch#43 SCAL column#3 row#6
-!  44 !ADC ROC#3 Sl#1 Ch#43 unused
+!  43 !ADC ROC#3 Sl#1 Ch#43 unused
+!  44 !ADC ROC#3 Sl#1 Ch#44 unused
 !  45 !ADC ROC#3 Sl#1 Ch#45 unused
 !  46 !ADC ROC#3 Sl#1 Ch#46 unused
 !  47 !ADC ROC#3 Sl#1 Ch#47 unused
@@ -3152,6 +3109,7 @@ Slot= 5 ! ADC  Second set of tubes on first two layers
 !  59 !ADC ROC#3 Sl#1 Ch#59 unused
 !  60 !ADC ROC#3 Sl#1 Ch#60 unused
 !  61 !ADC ROC#3 Sl#1 Ch#61 unused
+!  62 !ADC ROC#3 Sl#1 Ch#62 unused
   62, 4, 1 !ADC ROC#3 Sl#1 Ch#48 SCAL column#4 row#1
 !  63 !ADC ROC#3 Sl#1 Ch#63 unused
  detector= 15   !smisc  -  photodiode for laser gain calibration system.
diff --git a/examples/PARAM/general.param b/examples/PARAM/general.param
index c327a187a2e884bbfcd49a59f72417225575957f..91b4ebd055535831a3c5bf08c2404f27c5be4d60 100644
--- a/examples/PARAM/general.param
+++ b/examples/PARAM/general.param
@@ -26,3 +26,5 @@ raddeg=3.14159265/180
 #include "PARAM/haero.param"
 #include "PARAM/hdc.param"
 #include "PARAM/hdriftmap.param"
+#include "PARAM/hcal.param"
+
diff --git a/examples/calhit.C b/examples/calhit.C
deleted file mode 100644
index 5a61005f38667d59c32d209ca626069673531e84..0000000000000000000000000000000000000000
--- a/examples/calhit.C
+++ /dev/null
@@ -1,43 +0,0 @@
-{
-  TFile* f = new TFile("hodtest.root");
- 
-  TCanvas *c1 = new TCanvas("c1", "Shower Hit Maps", 800, 800); 
-  c1->Divide(1, 4);
-
-  TH1F* h[6];
-
-  h[0] = chposadc1;
-  h[1] = chnegadc1;
-  h[2] = chposadc2;
-  h[3] = chnegadc2;
-  h[4] = chposadc3;
-  h[5] = chposadc4;
-
-  
-    c1->cd(1);
-    h[0]->SetFillColor(kGreen);
-    h[0]->SetFillStyle(3345);
-    h[0]->Draw();
-    h[1]->SetFillColor(kBlue);
-    h[1]->SetFillStyle(3354);
-    h[1]->Draw("same");
-  
-    c1->cd(2);
-    h[2]->SetFillColor(kGreen);
-    h[2]->SetFillStyle(3345);
-    h[2]->Draw();
-    h[3]->SetFillColor(kBlue);
-    h[3]->SetFillStyle(3354);
-    h[3]->Draw("same");
-
-    c1->cd(3);
-    h[4]->SetFillColor(kGreen);
-    h[4]->SetFillStyle(3345);
-    h[4]->Draw();
-
-    c1->cd(4);
-    h[5]->SetFillColor(kGreen);
-    h[5]->SetFillStyle(3345);
-    h[5]->Draw();
-}
- 
diff --git a/examples/compare.C b/examples/compare.C
deleted file mode 100644
index 1664415a39d83b728b5c1188c153bc160c29ea1c..0000000000000000000000000000000000000000
--- a/examples/compare.C
+++ /dev/null
@@ -1,147 +0,0 @@
-{
-  TFile* f = new TFile("hodtest.root");
-  
-  TCanvas *c1 = new TCanvas("c1", "Shower Hit Maps", 1000, 1200); 
-  c1->Divide(2, 3);
-  
-  TH1F *h1[6];
-  TH1F* h[6];
-  
-  for(int l = 0; l < 6; l++){
-    h1[l] = new TH1F("","",13,0.4,13.4);
-  }
-  Double_t mean = 0.;
-  Double_t hits;
-  Double_t raw[13] = {1, 2,  3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
-  Double_t ratio[77];
-  Double_t err[77];
-
-
-//with peds and scalers
-//   double v[6][13] = { 
-//     {679, 2016, 2439, 2446, 2369, 2179, 2045, 1953, 1723, 1618, 1465, 1241, 1061},  //hcalapos
-//     {0,   2125, 2521, 2420, 2364, 2006, 1935, 1911, 1769, 1536, 1450, 1242, 1090},  //hcalaneg
-//     {803, 2069, 2446, 2422, 2188, 1986, 2043, 1881, 1736, 1630, 1455, 1130, 1086},  //hcalbpos
-//     {788, 2034, 2372, 2217, 2141, 2002, 1956, 1938, 1700, 1605, 1442, 1219,  952},  //hcalbneg
-//     {915, 1964, 2276, 2066, 2122, 1880, 1969, 1854, 1576, 1500, 1403, 1189,  875},  //hcalcpos
-//     {7187, 1748, 1890, 1852, 1786, 1573, 1525, 1510, 1376, 1432, 1191, 1033, 809}   //hcaldpos
-//   };
-
-  double v[6][13] = { 
-    {747, 2212, 2688, 2698, 2602, 2400, 2228, 2131, 1910, 1763, 1605, 1382, 1179},  //hcalapos
-    {0,   2334, 2784, 2673, 2599, 2215, 2107, 2079, 1958, 1672, 1584, 1384, 1211},  //hcalaneg
-    {882, 2285, 2709, 2650, 2405, 2184, 2230, 2062, 1921, 1789, 1589, 1252, 1204},  //hcalbpos
-    {866, 2244, 2632, 2430, 2354, 2207, 2127, 2127, 1888, 1757, 1578, 1345, 1054},  //hcalbneg
-    {1006, 2171, 2529, 2262, 2302, 2070, 2149, 2024, 1732, 1634, 1543, 1323, 957},  //hcalcpos
-    {7913, 1918, 2084, 2027, 1947, 1739, 1668, 1646, 1521, 1572, 1302, 1136, 887}   //hcaldpos
-  };
-
-
-  // //Without thresholds
-  //	double v[6][13] = {
-  // 	{679, 2296, 2439, 2446, 2369, 2179, 2045, 1953, 1723, 1618, 1465, 1241, 1061};
-  //      {0, 2125, 2521, 2420, 2364, 2006, 1935, 1911, 1769, 1536, 1450, 1242, 1090};
-  // 	{803, 2069, 2446, 2422, 2188, 1986, 2043, 1881, 1736, 1630, 1455, 1130, 1086};
-  //      {788, 2034, 2372, 2217, 2141, 2002, 1956, 1938, 1700, 1605, 1442, 1219, 952};
-  //      {915, 1964, 2276, 2066, 2122, 1880, 1969, 1854, 1576, 1500, 1403, 1189, 875};
-  // 	{12633, 1748, 1890, 1852, 1786, 1573, 1525, 1510, 1376, 1432, 1191, 1033, 809};
-  
-  h[0] = chposadc1;
-  h[1] = chnegadc1;
-  h[2] = chposadc2;
-  h[3] = chnegadc2;
-  h[4] = chposadc3;
-  h[5] = chposadc4;
-
-
-  for (int j = 0; j < 6; j++){
-    c1->cd(j+1);
-    h[j]->SetFillColor(kGreen);
-    h[j]->SetFillStyle(3345);
-    h[j]->Draw();
-    
-    for(int k = 0; k < 13; k++){
-      for(int i = 0; i < v[j][k]; i++){
-	hits = raw[k]-0.1;
-	h1[j]->Fill(hits);
-      }
-    }
-    h1[j]->SetFillColor(kBlue);
-    h1[j]->SetFillStyle(3354);
-    h1[j]->Draw("same");
-  }
-
-for (int i = 1; i < 14; i++){
-cout << "hitsC = " << h[0].GetBinContent(i) << endl;
-}
-
-
-/*
-int n = 0;
-Double_t errC;
-Double_t errE;
-Double_t hitsC;
-Double_t hitsE;
-Double_t hitsCmean = 1876.81;
-Double_t hitsEmean = 1783.7;
-Double_t sum1 = 0.; //chislitel
-Double_t sum2 = 0.; 
-Double_t sum3 = 0.; 
-Double_t chan[77];
-Double_t r;
-
-  for (Int_t l = 0; l < 6; l++){ 
-//    cout << "ADC" << l+1 << ": " << endl;
-    for (Int_t i = 1; i < h[l].GetNbinsX() +1; i++){
-	hitsC = h[l].GetBinContent(i);
-	hitsE = h1[l].GetBinContent(i);
-      if (hitsC > 0 && hitsE > 0){
-	errC = 1./sqrt(hitsC);
-        errE = 1./sqrt(hitsE);
-	ratio[n] = hitsC/hitsE;
-//cout << "errC = " << errC << ", errE = " << errE << "corr = " <<  errC*errE << endl;
-	err[n] = sqrt((errC**2 + errE**2 - 2*errC*errE))*ratio[n];
-	mean = mean + ratio[n];
-
-
-
-
-sum1 = sum1 + (hitsC - hitsCmean)*(hitsE - hitsEmean);
-sum2 = sum2 + (hitsC - hitsCmean)**2;
-sum3 = sum3 + (hitsE - hitsEmean)**2;
-//	hitsCmean = hitsCmean + hitsC;
-//	hitsEmean = hitsEmean + hitsE;
-	chan[n] = n*1.;
-	n++;
-	}
-	//cout << "Hits ratio C++/ENGINE = " << err[l][i] << endl;
-    }
-  }
-mean = mean/n;
-//hitsCmean = hitsCmean/n;
-//hitsEmean = hitsEmean/n;
-r = sum1/sqrt(sum2*sum3);
-cout << "r = " << r << endl;
-
-c1->Update();
-TCanvas *c2 = new TCanvas("c2", "RATIO", 1200, 800); 
-c2->cd();
-// create the TGraphErrors and draw it
-gr = new TGraphErrors(n,chan,ratio,0,err);
-//gr->SetLineColor(8);
-gr->SetMarkerStyle(20);
- TAxis *xaxis = gr->GetXaxis();
- TAxis *yaxis = gr->GetYaxis();
- //xaxis->SetLimits(10, 60);
- xaxis->SetTitle("Channel");
- yaxis->SetTitle("Hits ratio (C++/Engine)");
-yaxis->SetTitleOffset(1.2);
-
-gr->Draw("AP");
-
-  TF1 *f1 = new TF1("f1","1.0527",0.,77.);
-   f1->Draw("same");
-
-c2->Update();
-*/
-} 
diff --git a/examples/compclustedep.C b/examples/compclustedep.C
new file mode 100644
index 0000000000000000000000000000000000000000..c251ae614d23f1440cbde67db14b2fb3e9192027
--- /dev/null
+++ b/examples/compclustedep.C
@@ -0,0 +1,57 @@
+void compclustedep(Int_t run)
+{
+  TFile* f = new TFile(Form("hodtest_%d.root",run));
+  cout << "hcana root file " << Form("hodtest_%d.root",run) << endl;
+  TH1F* h = emax;
+
+  TFile* f1 = new TFile(Form("%d_hbk.root",run));
+  cout << "Engine root file " << Form("%d_hbk.root",run) << endl;
+  TH1F* h1;
+  switch (run) {
+  case 50017 :
+  //    h1 = h212;   //A+
+    break;
+  default :
+    h1 = h414;   //edep
+  }
+
+  TCanvas *c1 = new TCanvas("c1", "Shower Largest cluster Edep", 1000, 667); 
+
+  gPad->SetLogy();
+
+  h1->SetFillColor(kGreen);
+  h1->SetLineColor(kGreen);
+  h1->Draw();
+
+  h->SetLineColor(kBlue);
+  h->SetFillStyle(0);
+  h->SetLineWidth(2);
+  h->Draw("same");
+
+  TLatex l;
+  l.SetTextSize(0.04);
+  Float_t maxy = h1->GetBinContent(h1->GetMaximumBin());
+  Float_t xmin = h1->GetXaxis()->GetXmin();
+  Float_t xmax = h1->GetXaxis()->GetXmax();
+  Float_t xt = xmin + 0.67*(xmax-xmin);
+
+  l.SetTextColor(kGreen);
+  l.DrawLatex(xt,0.095*maxy,"Engine");
+  l.SetTextColor(kBlue);
+  l.DrawLatex(xt,0.045*maxy,"hcana");
+    
+  // Difference between the histograms.
+
+  TCanvas *c2 = new TCanvas("c2", "Edep differences", 1000, 667); 
+
+  TH1F* dif = h->Clone();
+
+  dif->Add(h,h1,1.,-1.);
+
+  dif->SetTitle("Edep Difference");
+  dif->SetFillColor(kRed);
+  dif->SetLineColor(kRed);
+  dif->SetLineWidth(1);
+  dif->SetFillStyle(1111);
+  dif->Draw();
+} 
diff --git a/examples/compclustepr.C b/examples/compclustepr.C
new file mode 100644
index 0000000000000000000000000000000000000000..97bc64a8c0a3eb80930398aaa5d8904b206b031e
--- /dev/null
+++ b/examples/compclustepr.C
@@ -0,0 +1,57 @@
+void compclustepr(Int_t run)
+{
+  TFile* f = new TFile(Form("hodtest_%d.root",run));
+  cout << "hcana root file " << Form("hodtest_%d.root",run) << endl;
+  TH1F* h = eprmax;
+
+  TFile* f1 = new TFile(Form("%d_hbk.root",run));
+  cout << "Engine root file " << Form("%d_hbk.root",run) << endl;
+  TH1F* h1;
+  switch (run) {
+  case 50017 :
+  //    h1 = h212;   //A+
+    break;
+  default :
+    h1 = h415;   //edep
+  }
+
+  TCanvas *c1 = new TCanvas("c1", "Shower Largest cluster Eprsh", 1000, 667); 
+
+  gPad->SetLogy();
+
+  h1->SetFillColor(kGreen);
+  h1->SetLineColor(kGreen);
+  h1->Draw();
+
+  h->SetLineColor(kBlue);
+  h->SetFillStyle(0);
+  h->SetLineWidth(2);
+  h->Draw("same");
+
+  TLatex l;
+  l.SetTextSize(0.04);
+  Float_t maxy = h1->GetBinContent(h1->GetMaximumBin());
+  Float_t xmin = h1->GetXaxis()->GetXmin();
+  Float_t xmax = h1->GetXaxis()->GetXmax();
+  Float_t xt = xmin + 0.67*(xmax-xmin);
+
+  l.SetTextColor(kGreen);
+  l.DrawLatex(xt,0.095*maxy,"Engine");
+  l.SetTextColor(kBlue);
+  l.DrawLatex(xt,0.045*maxy,"hcana");
+    
+  // Difference between the histograms.
+
+  TCanvas *c2 = new TCanvas("c2", "Eprsh differences", 1000, 667); 
+
+  TH1F* dif = h->Clone();
+
+  dif->Add(h,h1,1.,-1.);
+
+  dif->SetTitle("Eprsh Difference");
+  dif->SetFillColor(kRed);
+  dif->SetLineColor(kRed);
+  dif->SetLineWidth(1);
+  dif->SetFillStyle(1111);
+  dif->Draw();
+} 
diff --git a/examples/compclustsize.C b/examples/compclustsize.C
new file mode 100644
index 0000000000000000000000000000000000000000..4707a0d3a2d17a11a1b71a184628f541d35187e0
--- /dev/null
+++ b/examples/compclustsize.C
@@ -0,0 +1,57 @@
+void compclustsize(Int_t run)
+{
+  TFile* f = new TFile(Form("hodtest_%d.root",run));
+  cout << "hcana root file " << Form("hodtest_%d.root",run) << endl;
+  TH1F* h = mult;
+
+  TFile* f1 = new TFile(Form("%d_hbk.root",run));
+  cout << "Engine root file " << Form("%d_hbk.root",run) << endl;
+  TH1F* h1;
+  switch (run) {
+  case 50017 :
+  //    h1 = h212;   //A+
+    break;
+  default :
+    h1 = h413;   //mult
+  }
+
+  TCanvas *c1 = new TCanvas("c1", "Shower Largest cluster size", 1000, 667); 
+
+  gPad->SetLogy();
+
+  h1->SetFillColor(kGreen);
+  h1->SetLineColor(kGreen);
+  h1->Draw();
+
+  h->SetLineColor(kBlue);
+  h->SetFillStyle(0);
+  h->SetLineWidth(2);
+  h->Draw("same");
+
+  TLatex l;
+  l.SetTextSize(0.04);
+  Float_t maxy = h1->GetBinContent(h1->GetMaximumBin());
+  Float_t xmin = h1->GetXaxis()->GetXmin();
+  Float_t xmax = h1->GetXaxis()->GetXmax();
+  Float_t xt = xmin + 0.67*(xmax-xmin);
+
+  l.SetTextColor(kGreen);
+  l.DrawLatex(xt,0.095*maxy,"Engine");
+  l.SetTextColor(kBlue);
+  l.DrawLatex(xt,0.045*maxy,"hcana");
+    
+  // Difference between the histograms.
+
+  TCanvas *c2 = new TCanvas("c2", "Size differences", 1000, 667); 
+
+  TH1F* dif = h->Clone();
+
+  dif->Add(h,h1,1.,-1.);
+
+  dif->SetTitle("Size Difference");
+  dif->SetFillColor(kRed);
+  dif->SetLineColor(kRed);
+  dif->SetLineWidth(1);
+  dif->SetFillStyle(1111);
+  dif->Draw();
+} 
diff --git a/examples/compclustx.C b/examples/compclustx.C
new file mode 100644
index 0000000000000000000000000000000000000000..1fe40d6aaf11421876cbb3b812ac10afe26638ad
--- /dev/null
+++ b/examples/compclustx.C
@@ -0,0 +1,57 @@
+void compclustx(Int_t run)
+{
+  TFile* f = new TFile(Form("hodtest_%d.root",run));
+  cout << "hcana root file " << Form("hodtest_%d.root",run) << endl;
+  TH1F* h = xmax;
+
+  TFile* f1 = new TFile(Form("%d_hbk.root",run));
+  cout << "Engine root file " << Form("%d_hbk.root",run) << endl;
+  TH1F* h1;
+  switch (run) {
+  case 50017 :
+  //    h1 = h212;   //A+
+    break;
+  default :
+    h1 = h416;   //X
+  }
+
+  TCanvas *c1 = new TCanvas("c1", "Shower Largest cluster X", 1000, 667); 
+
+  gPad->SetLogy();
+
+  h1->SetFillColor(kGreen);
+  h1->SetLineColor(kGreen);
+  h1->Draw();
+
+  h->SetLineColor(kBlue);
+  h->SetFillStyle(0);
+  h->SetLineWidth(2);
+  h->Draw("same");
+
+  TLatex l;
+  l.SetTextSize(0.04);
+  Float_t maxy = h1->GetBinContent(h1->GetMaximumBin());
+  Float_t xmin = h1->GetXaxis()->GetXmin();
+  Float_t xmax = h1->GetXaxis()->GetXmax();
+  Float_t xt = xmin + 0.67*(xmax-xmin);
+
+  l.SetTextColor(kGreen);
+  l.DrawLatex(xt,0.095*maxy,"Engine");
+  l.SetTextColor(kBlue);
+  l.DrawLatex(xt,0.045*maxy,"hcana");
+    
+  // Difference between the histograms.
+
+  TCanvas *c2 = new TCanvas("c2", "X differences", 1000, 667); 
+
+  TH1F* dif = h->Clone();
+
+  dif->Add(h,h1,1.,-1.);
+
+  dif->SetTitle("X Difference");
+  dif->SetFillColor(kRed);
+  dif->SetLineColor(kRed);
+  dif->SetLineWidth(1);
+  dif->SetFillStyle(1111);
+  dif->Draw();
+} 
diff --git a/examples/compedeps.C b/examples/compedeps.C
new file mode 100644
index 0000000000000000000000000000000000000000..dcb8f0b3d7beeda77dd232f0917a4e8b51808221
--- /dev/null
+++ b/examples/compedeps.C
@@ -0,0 +1,70 @@
+void compedeps(Int_t run)
+{
+
+  // Compare deposited energies in 4 planes from ENGINE with hcana.
+
+  TFile* f = new TFile(Form("hodtest_%d.root",run));
+  TH1F* h[4];
+  h[0] = edep1;
+  h[1] = edep2;
+  h[2] = edep3;
+  h[3] = edep4;
+
+  TFile* f1 = new TFile(Form("%d_hbk.root",run));
+  TH1F* h1[4];
+  switch (run) {
+  case 50017 :
+    h1[0] = h683;   //A
+    h1[1] = h684;   //B
+    h1[2] = h685;   //C
+    h1[3] = h686;   //C
+    break;
+  default :
+    h1[0] = h628;   //A
+    h1[1] = h629;   //B
+    h1[2] = h630;   //C
+    h1[3] = h631;   //C
+  }
+
+  TCanvas *c1 = new TCanvas("c1", "Shower raw Edeps", 1000, 667); 
+  c1->Divide(2, 2);
+
+  for (int j = 0; j < 4; j++){
+
+    c1->cd(j+1);
+
+    h1[j]->SetFillColor(kBlue);
+    h1[j]->SetFillStyle(3354);
+    h1[j]->Draw();
+
+    h[j]->SetFillColor(kGreen);
+    h[j]->SetFillStyle(3345);
+    h[j]->Draw("same");
+
+    //    gPad->SetLogy();
+  }
+
+  //
+  // Difference between the histograms.
+  //
+
+  TCanvas *c2 = new TCanvas("c2", "Edep histogram differences", 1000, 667); 
+  c2->Divide(2, 2);
+
+  TH1F* d[4] = {h[0]->Clone(),h[0]->Clone(),h[0]->Clone(),h[0]->Clone()};
+
+  for (Int_t j = 0; j < 4; j++){
+
+    //    d[j]->Divide(h[j],h1[j]);
+    d[j]->Add(h[j],h1[j],1.,-1.);
+
+    c2->cd(j+1);
+
+    d[j]->SetFillColor(kRed);
+    d[j]->SetFillStyle(1111);
+    d[j]->Draw();
+
+    //    gPad->SetLogy();
+  }
+
+} 
diff --git a/examples/compnclusts.C b/examples/compnclusts.C
new file mode 100644
index 0000000000000000000000000000000000000000..2f16142e2e3bf1d91cc3f007933a70a104bebe60
--- /dev/null
+++ b/examples/compnclusts.C
@@ -0,0 +1,59 @@
+void compnclusts(Int_t run)
+{
+  TFile* f = new TFile(Form("hodtest_%d.root",run));
+  cout << "hcana root file " << Form("hodtest_%d.root",run) << endl;
+  TH1F* h = nclust;
+
+  TFile* f1 = new TFile(Form("%d_hbk.root",run));
+  cout << "Engine root file " << Form("%d_hbk.root",run) << endl;
+  TH1F* h1;
+  switch (run) {
+  case 50017 :
+  //    h1 = h212;   //A+
+    break;
+  default :
+    h1 = h412;   //hnclusters
+  }
+
+  TCanvas *c1 = new TCanvas("c1", "Shower Cluster Map", 1000, 667); 
+
+  gPad->SetLogy();
+
+  h1->SetFillColor(kGreen);
+  h1->SetLineColor(kGreen);
+  h1->SetFillStyle(1111);
+  h1->Draw();
+
+  h->SetFillColor(kBlue);
+  h->SetLineWidth(2);
+  h->SetFillStyle(0);
+  h->Draw("same");
+
+  TLatex l;
+  l.SetTextSize(0.04);
+  Float_t maxy = h1->GetBinContent(h1->GetMaximumBin());
+  Float_t xmin = h1->GetXaxis()->GetXmin();
+  Float_t xmax = h1->GetXaxis()->GetXmax();
+  Float_t xt = xmin + 0.67*(xmax-xmin);
+
+  l.SetTextColor(kGreen);
+  l.DrawLatex(xt,0.095*maxy,"Engine");
+  l.SetTextColor(kBlue);
+  l.DrawLatex(xt,0.045*maxy,"hcana");
+    
+  // Difference between the histograms.
+
+  TCanvas *c2 = new TCanvas("c2", "Cluster differences", 1000, 667); 
+
+  TH1F* dif = h->Clone();
+
+  dif->Add(h,h1,1.,-1.);
+
+  dif->SetTitle("Difference");
+  dif->SetFillColor(kRed);
+  dif->SetLineColor(kRed);
+  dif->SetLineWidth(1);
+  dif->SetFillStyle(1111);
+  dif->Draw();
+
+} 
diff --git a/examples/compnhits.C b/examples/compnhits.C
new file mode 100644
index 0000000000000000000000000000000000000000..b30f829f4da4d6d4e7a68b1914e5463e0f755543
--- /dev/null
+++ b/examples/compnhits.C
@@ -0,0 +1,57 @@
+void compnhits(Int_t run)
+{
+  TFile* f = new TFile(Form("hodtest_%d.root",run));
+  cout << "hcana root file " << Form("hodtest_%d.root",run) << endl;
+  TH1F* h = nhits;
+
+  TFile* f1 = new TFile(Form("%d_hbk.root",run));
+  cout << "Engine root file " << Form("%d_hbk.root",run) << endl;
+  TH1F* h1;
+  switch (run) {
+  case 50017 :
+  //    h1 = h212;   //A+
+    break;
+  default :
+    h1 = h411;   //hnhits
+  }
+
+  TCanvas *c1 = new TCanvas("c1", "Shower Sparsified Hit Map", 1000, 667); 
+
+  gPad->SetLogy();
+
+  h1->SetFillColor(kGreen);
+  h1->SetLineColor(kGreen);
+  h1->Draw();
+
+  h->SetLineColor(kBlue);
+  h->SetFillStyle(0);
+  h->SetLineWidth(2);
+  h->Draw("same");
+
+  TLatex l;
+  l.SetTextSize(0.04);
+  Float_t maxy = h1->GetBinContent(h1->GetMaximumBin());
+  Float_t xmin = h1->GetXaxis()->GetXmin();
+  Float_t xmax = h1->GetXaxis()->GetXmax();
+  Float_t xt = xmin + 0.67*(xmax-xmin);
+
+  l.SetTextColor(kGreen);
+  l.DrawLatex(xt,0.095*maxy,"Engine");
+  l.SetTextColor(kBlue);
+  l.DrawLatex(xt,0.045*maxy,"hcana");
+    
+  // Difference between the histograms.
+
+  TCanvas *c2 = new TCanvas("c2", "Hit differences", 1000, 667); 
+
+  TH1F* dif = h->Clone();
+
+  dif->Add(h,h1,1.,-1.);
+
+  dif->SetTitle("Difference");
+  dif->SetFillColor(kRed);
+  dif->SetLineColor(kRed);
+  dif->SetLineWidth(1);
+  dif->SetFillStyle(1111);
+  dif->Draw();
+} 
diff --git a/examples/comprawhits.C b/examples/comprawhits.C
new file mode 100644
index 0000000000000000000000000000000000000000..6b8890f10760a786c6e8f6abaec06c8f4ef97037
--- /dev/null
+++ b/examples/comprawhits.C
@@ -0,0 +1,49 @@
+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];
+  h[0] = chposadc1;
+  h[1] = chnegadc1;
+  h[2] = chposadc2;
+  h[3] = chnegadc2;
+  h[4] = chposadc3;
+  h[5] = chposadc4;
+
+  TFile* f1 = new TFile(Form("%d_hbk.root",run));
+  cout << "Engine root file " << Form("%d_hbk.root",run) << endl;
+  TH1F* h1[6];
+  switch (run) {
+  case 50017 :
+    h1[0] = h212;   //A+
+    h1[1] = h213;   //A-
+    h1[2] = h214;   //B+
+    h1[3] = h215;   //B-
+    h1[4] = h216;   //C+
+    h1[5] = h217;   //D+
+    break;
+  default :
+    h1[0] = h213;   //A+
+    h1[1] = h217;   //A-
+    h1[2] = h214;   //B+
+    h1[3] = h218;   //B-
+    h1[4] = h215;   //C+
+    h1[5] = h216;   //D+
+  }
+
+  TCanvas *c1 = new TCanvas("c1", "Shower Hit Maps", 1000, 667); 
+  c1->Divide(2, 3);
+
+  for (int j = 0; j < 6; j++){
+    c1->cd(j+1);
+    h[j]->SetFillColor(kGreen);
+    h[j]->SetFillStyle(3345);
+    h[j]->Draw();
+    
+    h1[j]->SetFillColor(kBlue);
+    h1[j]->SetFillStyle(3354);
+    h1[j]->Draw("same");
+  }
+
+} 
diff --git a/examples/hitmaps.C b/examples/hitmaps.C
deleted file mode 100644
index 0874bc38ec8b21fcb094fde17b4fdebe3eee160d..0000000000000000000000000000000000000000
--- a/examples/hitmaps.C
+++ /dev/null
@@ -1,39 +0,0 @@
-{
-  TFile* f = new TFile("hodtest.root");
- 
-  TCanvas *c1 = new TCanvas("c1", "Scintillator Hit Maps", 800, 800); 
-  c1->Divide(2, 4);
-
-  TH1F* h[16];
-
-  h[0] = hpostdc1;
-  h[1] = hnegtdc1;
-  h[4] = hpostdc2;
-  h[5] = hnegtdc2;
-  h[8] = hpostdc3;
-  h[9] = hnegtdc3;
-  h[12] = hpostdc4;
-  h[13] = hnegtdc4;
-
-  h[2] = hposadc1;
-  h[3] = hnegadc1;
-  h[6] = hposadc2;
-  h[7] = hnegadc2;
-  h[10] = hposadc3;
-  h[11] = hnegadc3;
-  h[14] = hposadc4;
-  h[15] = hnegadc4;
-  
-  for(Int_t ipad=1;ipad<=8;ipad++) {
-    TPad *pt = c1->cd(ipad);
-    Int_t ihp = 2*(ipad-1);
-    Int_t ihn = ihp+1;
-    h[ihp]->SetFillColor(kGreen);
-    h[ihp]->SetFillStyle(3345);
-    h[ihp]->Draw();
-    h[ihn]->SetFillColor(kBlue);
-    h[ihn]->SetFillStyle(3354);
-    h[ihn]->Draw("same");
-  }
-
-}
diff --git a/examples/hodtest_cuts.def b/examples/hodtest_cuts.def
deleted file mode 100644
index f6003c2200a18b2f4d7156e51c0250c8b5ce2b06..0000000000000000000000000000000000000000
--- a/examples/hodtest_cuts.def
+++ /dev/null
@@ -1,17 +0,0 @@
-# Demo cuts for hodtest
-#
-
-Block: RawDecode
-
-Pedestal_event    g.evtyp==4
-RawDecode_master  1
-
-Block: Decode
-Decode_master     !Pedestal_event
-
-Block: CoarseTracking
-CoarseTracking_master !Pedestal_event
-
-Block: CoarseReconstruct
-RawCoarseReconstruct !Pedestal_event
-
diff --git a/setup.csh b/setup.csh
index d85dc0c84258aa4d1701582211ba660815733e9b..d7df18c89cf06ac4bea58b32ff02b2cd2fbf27d2 100644
--- a/setup.csh
+++ b/setup.csh
@@ -16,6 +16,3 @@ if ( ! ($?LD_LIBRARY_PATH) ) then
    setenv LD_LIBRARY_PATH ""
 endif
 setenv LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:${ANALYZER}:${HCANALYZER}"
-
-
-
diff --git a/src/HallC_LinkDef.h b/src/HallC_LinkDef.h
index 408c60043915204efe8809826e84cee590311b0a..53a5b40a5c2f265f7b3f326ea2590a8b1c8ad329 100644
--- a/src/HallC_LinkDef.h
+++ b/src/HallC_LinkDef.h
@@ -30,7 +30,7 @@
 #pragma link C++ class THcDCTrack+;
 #pragma link C++ class THcShower+;
 #pragma link C++ class THcShowerPlane+;
-#pragma link C++ class THcShowerHit+;
+#pragma link C++ class THcRawShowerHit+;
 #pragma link C++ class THcAerogel+;
 #pragma link C++ class THcAerogelHit+;
 
diff --git a/src/THcShowerHit.cxx b/src/THcRawShowerHit.cxx
similarity index 78%
rename from src/THcShowerHit.cxx
rename to src/THcRawShowerHit.cxx
index c27357235534b2b8c67d13cdbcba0984c6fb8b09..75c3a322642ddda42996eced2697a45ed91a6b34 100644
--- a/src/THcShowerHit.cxx
+++ b/src/THcRawShowerHit.cxx
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
-// THcShowerHit                                                           //
+// THcRawShowerHit                                                           //
 //                                                                           //
 // Class representing a single raw hit for a hodoscope paddle                //
 //                                                                           //
@@ -8,12 +8,12 @@
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#include "THcShowerHit.h"
+#include "THcRawShowerHit.h"
 
 using namespace std;
 
 
-void THcShowerHit::SetData(Int_t signal, Int_t data) {
+void THcRawShowerHit::SetData(Int_t signal, Int_t data) {
   if(signal==0) {
     fADC_pos = data;
   } else if (signal==1) {
@@ -21,7 +21,7 @@ void THcShowerHit::SetData(Int_t signal, Int_t data) {
   } 
 }
 
-Int_t THcShowerHit::GetData(Int_t signal) {
+Int_t THcRawShowerHit::GetData(Int_t signal) {
   if(signal==0) {
     return(fADC_pos);
   } else if (signal==1) {
@@ -32,11 +32,11 @@ Int_t THcShowerHit::GetData(Int_t signal) {
 }
 
 #if 0
-Int_t THcShowerHit::Compare(const TObject* obj) const
+Int_t THcRawShowerHit::Compare(const TObject* obj) const
 {
   // Compare to sort by plane and counter
 
-  const THcShowerHit* hit = dynamic_cast<const THcShowerHit*>(obj);
+  const THcRawShowerHit* hit = dynamic_cast<const THcRawShowerHit*>(obj);
 
   if(!hit) return -1;
   Int_t p1 = fPlane;
@@ -53,7 +53,7 @@ Int_t THcShowerHit::Compare(const TObject* obj) const
 }
 #endif
 //_____________________________________________________________________________
-THcShowerHit& THcShowerHit::operator=( const THcShowerHit& rhs )
+THcRawShowerHit& THcRawShowerHit::operator=( const THcRawShowerHit& rhs )
 {
   // Assignment operator.
 
@@ -70,6 +70,6 @@ THcShowerHit& THcShowerHit::operator=( const THcShowerHit& rhs )
 
 
 //////////////////////////////////////////////////////////////////////////
-ClassImp(THcShowerHit)
+ClassImp(THcRawShowerHit)
 
  
diff --git a/src/THcRawShowerHit.h b/src/THcRawShowerHit.h
new file mode 100644
index 0000000000000000000000000000000000000000..1671ddcbfcc7645315c2e99e7440c1b40927d067
--- /dev/null
+++ b/src/THcRawShowerHit.h
@@ -0,0 +1,36 @@
+#ifndef ROOT_THcRawShowerHit
+#define ROOT_THcRawShowerHit
+
+#include "THcRawHit.h"
+
+class THcRawShowerHit : public THcRawHit {
+
+ public:
+
+ THcRawShowerHit(Int_t plane=0, Int_t counter=0) : THcRawHit(plane, counter), 
+    fADC_pos(-1), fADC_neg(-1){
+  }
+  THcRawShowerHit& operator=( const THcRawShowerHit& );
+  virtual ~THcRawShowerHit() {}
+
+  virtual void Clear( Option_t* opt="" )
+    { fADC_pos = -1; fADC_neg = -1; }
+
+  void SetData(Int_t signal, Int_t data);
+  Int_t GetData(Int_t signal);
+
+  //  virtual Bool_t  IsSortable () const {return kTRUE; }
+  //  virtual Int_t   Compare(const TObject* obj) const;
+
+  Int_t fADC_pos;
+  Int_t fADC_neg;
+
+ protected:
+
+ private:
+
+  ClassDef(THcRawShowerHit, 0);	// Shower hit class
+};  
+
+#endif
+ 
diff --git a/src/THcShower.cxx b/src/THcShower.cxx
index 7bce97a42e3717e09cb68d56e4030563eb3c371c..009cc20d88299619cf50145674a0dddf97c1e56e 100644
--- a/src/THcShower.cxx
+++ b/src/THcShower.cxx
@@ -10,6 +10,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 #include "THcShower.h"
+#include "THcShowerCluster.h"
 #include "THaEvData.h"
 #include "THaDetMap.h"
 #include "THcDetectorMap.h"
@@ -105,7 +106,7 @@ THaAnalysisObject::EStatus THcShower::Init( const TDatime& date )
   // Should probably put this in ReadDatabase as we will know the
   // maximum number of hits after setting up the detector map
 
-  THcHitList::InitHitList(fDetMap, "THcShowerHit", 100);
+  THcHitList::InitHitList(fDetMap, "THcRawShowerHit", 100);
 
   EStatus status;
   if( (status = THaNonTrackingDetector::Init( date )) )
@@ -155,44 +156,214 @@ Int_t THcShower::ReadDatabase( const TDatime& date )
   prefix[0]=tolower(GetApparatus()->GetName()[0]);
   prefix[1]='\0';
 
+  {
+    DBRequest list[]={
+      {"cal_num_neg_columns", &fNegCols, kInt},
+      {"cal_slop", &fSlop, kDouble},
+      {"cal_fv_test", &fvTest, kDouble},
+      {0}
+    };
+    gHcParms->LoadParmValues((DBRequest*)&list, prefix);
+  }
+
+  cout << "Number of neg. columns   = " << fNegCols << endl;
+  cout << "Slop parameter           = " << fSlop << endl;
+  cout << "Fiducial volum test flag = " << fvTest << endl;
+
   BlockThick = new Double_t [fNLayers];
   fNBlocks = new Int_t [fNLayers];
   fNLayerZPos = new Double_t [fNLayers];
-  XPos = new Double_t [2*fNLayers];
+  YPos = new Double_t [2*fNLayers];
 
   for(Int_t i=0;i<fNLayers;i++) {
     DBRequest list[]={
       {Form("cal_%s_thick",fLayerNames[i]), &BlockThick[i], kDouble},
       {Form("cal_%s_nr",fLayerNames[i]), &fNBlocks[i], kInt},
       {Form("cal_%s_zpos",fLayerNames[i]), &fNLayerZPos[i], kDouble},
-      {Form("cal_%s_left",fLayerNames[i]), &XPos[2*i], kDouble},
-      {Form("cal_%s_right",fLayerNames[i]), &XPos[2*i+1], kDouble},
+      {Form("cal_%s_right",fLayerNames[i]), &YPos[2*i], kDouble},
+      {Form("cal_%s_left",fLayerNames[i]), &YPos[2*i+1], kDouble},
       {0}
     };
     gHcParms->LoadParmValues((DBRequest*)&list, prefix);
   }
-  YPos = new Double_t* [fNLayers];
+
+  //Caution! Z positions (fronts) are off in hcal.param! Correct later on.
+
+  XPos = new Double_t* [fNLayers];
   for(Int_t i=0;i<fNLayers;i++) {
-    YPos[i] = new Double_t [fNBlocks[i]];
+    XPos[i] = new Double_t [fNBlocks[i]];
     DBRequest list[]={
-      {Form("cal_%s_top",fLayerNames[i]),YPos[i], kDouble, fNBlocks[i]},
+      {Form("cal_%s_top",fLayerNames[i]),XPos[i], kDouble, fNBlocks[i]},
       {0}
     };
     gHcParms->LoadParmValues((DBRequest*)&list, prefix);
   }
+
   for(Int_t i=0;i<fNLayers;i++) {
     cout << "Plane " << fLayerNames[i] << ":" << endl;
     cout << "    Block thickness: " << BlockThick[i] << endl;
     cout << "    NBlocks        : " << fNBlocks[i] << endl;
     cout << "    Z Position     : " << fNLayerZPos[i] << endl;
-    cout << "    X Positions    : " << XPos[2*i] << ", " << XPos[2*i+1] << endl;
-    cout << "    Y Positions    :";
+    cout << "    Y Positions    : " << YPos[2*i] << ", " << YPos[2*i+1] <<endl;
+    cout << "    X Positions    :";
     for(Int_t j=0; j<fNBlocks[i]; j++) {
-      cout << " " << YPos[i][j];
+      cout << " " << XPos[i][j];
     }
     cout << endl;
+
   }
 
+  //Calibration related parameters (from hcal.param).
+
+  fNtotBlocks=0;              //total number of blocks
+  for (Int_t i=0; i<fNLayers; i++) fNtotBlocks += fNBlocks[i];
+
+  cout << "Total number of blocks in the calorimeter: " << fNtotBlocks << endl;
+
+  //Pedestal limits from hcal.param.
+  fShPosPedLimit = new Int_t [fNtotBlocks];
+  fShNegPedLimit = new Int_t [fNtotBlocks];
+
+  //Calibration constants
+  fPosGain = new Double_t [fNtotBlocks];
+  fNegGain = new Double_t [fNtotBlocks];
+
+  //Read in parameters from hcal.param
+  Double_t hcal_pos_cal_const[fNtotBlocks];
+  //  Double_t hcal_pos_gain_ini[fNtotBlocks];
+  //  Double_t hcal_pos_gain_cur[fNtotBlocks];
+  //  Int_t    hcal_pos_ped_limit[fNtotBlocks];
+  Double_t hcal_pos_gain_cor[fNtotBlocks];
+
+  Double_t hcal_neg_cal_const[fNtotBlocks];
+  //  Double_t hcal_neg_gain_ini[fNtotBlocks];
+  //  Double_t hcal_neg_gain_cur[fNtotBlocks];
+  //  Int_t    hcal_neg_ped_limit[fNtotBlocks];
+  Double_t hcal_neg_gain_cor[fNtotBlocks];
+
+  DBRequest list[]={
+    {"cal_pos_cal_const", hcal_pos_cal_const, kDouble, fNtotBlocks},
+    //    {"cal_pos_gain_ini",  hcal_pos_gain_ini,  kDouble, fNtotBlocks},
+    //    {"cal_pos_gain_cur",  hcal_pos_gain_cur,  kDouble, fNtotBlocks},
+    {"cal_pos_ped_limit", fShPosPedLimit, kInt,    fNtotBlocks},
+    {"cal_pos_gain_cor",  hcal_pos_gain_cor,  kDouble, fNtotBlocks},
+    {"cal_neg_cal_const", hcal_neg_cal_const, kDouble, fNtotBlocks},
+    //    {"cal_neg_gain_ini",  hcal_neg_gain_ini,  kDouble, fNtotBlocks},
+    //    {"cal_neg_gain_cur",  hcal_neg_gain_cur,  kDouble, fNtotBlocks},
+    {"cal_neg_ped_limit", fShNegPedLimit, kInt,    fNtotBlocks},
+    {"cal_neg_gain_cor",  hcal_neg_gain_cor,  kDouble, fNtotBlocks},
+    {"cal_min_peds", &fShMinPeds, kInt},
+    {0}
+  };
+  gHcParms->LoadParmValues((DBRequest*)&list, prefix);
+
+  //+++
+
+  cout << "hcal_pos_cal_const:" << endl;
+  for (Int_t j=0; j<fNLayers; j++) {
+    for (Int_t i=0; i<fNBlocks[j]; i++) {
+      cout << hcal_pos_cal_const[j*fNBlocks[j]+i] << " ";
+    };
+    cout <<  endl;
+  };
+
+  //  cout << "hcal_pos_gain_ini:" << endl;
+  //  for (Int_t j=0; j<fNLayers; j++) {
+  //    for (Int_t i=0; i<fNBlocks[j]; i++) {
+  //      cout << hcal_pos_gain_ini[j*fNBlocks[j]+i] << " ";
+  //    };
+  //    cout <<  endl;
+  //  };
+
+  //  cout << "hcal_pos_gain_cur:" << endl;
+  //  for (Int_t j=0; j<fNLayers; j++) {
+  //    for (Int_t i=0; i<fNBlocks[j]; i++) {
+  //      cout << hcal_pos_gain_cur[j*fNBlocks[j]+i] << " ";
+  //    };
+  //    cout <<  endl;
+  //  };
+
+  cout << "fShPosPedLimit:" << endl;
+  for (Int_t j=0; j<fNLayers; j++) {
+    for (Int_t i=0; i<fNBlocks[j]; i++) {
+      cout << fShPosPedLimit[j*fNBlocks[j]+i] << " ";
+    };
+    cout <<  endl;
+  };
+
+  cout << "hcal_pos_gain_cor:" << endl;
+  for (Int_t j=0; j<fNLayers; j++) {
+    for (Int_t i=0; i<fNBlocks[j]; i++) {
+      cout << hcal_pos_gain_cor[j*fNBlocks[j]+i] << " ";
+    };
+    cout <<  endl;
+  };
+
+  //---
+
+  cout << "hcal_neg_cal_const:" << endl;
+  for (Int_t j=0; j<fNLayers; j++) {
+    for (Int_t i=0; i<fNBlocks[j]; i++) {
+      cout << hcal_neg_cal_const[j*fNBlocks[j]+i] << " ";
+    };
+    cout <<  endl;
+  };
+
+  //  cout << "hcal_neg_gain_ini:" << endl;
+  //  for (Int_t j=0; j<fNLayers; j++) {
+  //    for (Int_t i=0; i<fNBlocks[j]; i++) {
+  //      cout << hcal_neg_gain_ini[j*fNBlocks[j]+i] << " ";
+  //    };
+  //  //    cout <<  endl;
+  //  };
+
+  //  cout << "hcal_neg_gain_cur:" << endl;
+  //  for (Int_t j=0; j<fNLayers; j++) {
+  //    for (Int_t i=0; i<fNBlocks[j]; i++) {
+  //      cout << hcal_neg_gain_cur[j*fNBlocks[j]+i] << " ";
+  //    };
+  //    cout <<  endl;
+  //  };
+
+  cout << "fShNegPedLimit:" << endl;
+  for (Int_t j=0; j<fNLayers; j++) {
+    for (Int_t i=0; i<fNBlocks[j]; i++) {
+      cout << fShNegPedLimit[j*fNBlocks[j]+i] << " ";
+    };
+    cout <<  endl;
+  };
+
+  cout << "hcal_neg_gain_cor:" << endl;
+  for (Int_t j=0; j<fNLayers; j++) {
+    for (Int_t i=0; i<fNBlocks[j]; i++) {
+      cout << hcal_neg_gain_cor[j*fNBlocks[j]+i] << " ";
+    };
+    cout <<  endl;
+  };
+
+  //Calibration constants in GeV per ADC channel.
+
+  for (Int_t i=0; i<fNtotBlocks; i++) {
+    fPosGain[i] = hcal_pos_cal_const[i] *  hcal_pos_gain_cor[i];
+    fNegGain[i] = hcal_neg_cal_const[i] *  hcal_neg_gain_cor[i];
+  }
+
+  cout << "fPosGain:" << endl;
+  for (Int_t j=0; j<fNLayers; j++) {
+    for (Int_t i=0; i<fNBlocks[j]; i++) {
+      cout << fPosGain[j*fNBlocks[j]+i] << " ";
+    };
+    cout <<  endl;
+  };
+
+  cout << "fNegGain:" << endl;
+  for (Int_t j=0; j<fNLayers; j++) {
+    for (Int_t i=0; i<fNBlocks[j]; i++) {
+      cout << fNegGain[j*fNBlocks[j]+i] << " ";
+    };
+    cout <<  endl;
+  };
+
   fIsInit = true;
 
   return kOK;
@@ -212,25 +383,27 @@ Int_t THcShower::DefineVariables( EMode mode )
 
   // Register variables in global list
 
- //  RVarDef vars[] = {
- //   { "nhit",   "Number of hits",                     "fNhits" },
+  RVarDef vars[] = {
+    { "nhits",  "Number of hits",                     "fNhits" },
  //   { "a",      "Raw ADC amplitudes",                 "fA" },
  //   { "a_p",    "Ped-subtracted ADC amplitudes",      "fA_p" },
  //   { "a_c",    "Calibrated ADC amplitudes",          "fA_c" },
  //   { "asum_p", "Sum of ped-subtracted ADCs",         "fAsum_p" },
  //   { "asum_c", "Sum of calibrated ADCs",             "fAsum_c" },
- //   { "nclust", "Number of clusters",                 "fNclust" },
- //   { "e",      "Energy (MeV) of largest cluster",    "fE" },
- //   { "x",      "x-position (cm) of largest cluster", "fX" },
- //   { "y",      "y-position (cm) of largest cluster", "fY" },
- //   { "mult",   "Multiplicity of largest cluster",    "fMult" },
+    { "nclust", "Number of clusters",                 "fNclust" },
+    { "emax",   "Energy (MeV) of largest cluster",    "fE" },
+    { "eprmax",   "Preshower Energy (MeV) of largest cluster",    "fEpr" },
+    { "xmax",      "x-position (cm) of largest cluster", "fX" },
+ //   { "z",      "z-position (cm) of largest cluster", "fZ" },
+    { "mult",   "Multiplicity of largest cluster",    "fMult" },
  //   { "nblk",   "Numbers of blocks in main cluster",  "fNblk" },
  //   { "eblk",   "Energies of blocks in main cluster", "fEblk" },
  //   { "trx",    "track x-position in det plane",      "fTRX" },
  //   { "try",    "track y-position in det plane",      "fTRY" },
- //   { 0 }
- // };
- //  return DefineVarsFromList( vars, mode );
+    { 0 }
+  };
+  return DefineVarsFromList( vars, mode );
+
   return kOK;
 }
 
@@ -258,7 +431,7 @@ void THcShower::DeleteArrays()
   delete [] fNBlocks;  fNBlocks = NULL;
   delete [] fNLayerZPos;  fNLayerZPos = NULL;
   delete [] XPos;  XPos = NULL;
-  delete [] YPos;  YPos = NULL;
+  delete [] ZPos;  ZPos = NULL;
   //delete [] fSpacing;  fSpacing = NULL;
   //delete [] fCenter;   fCenter = NULL; // This 2D. What is correct way to delete?
 }
@@ -267,51 +440,63 @@ void THcShower::DeleteArrays()
 inline 
 void THcShower::Clear(Option_t* opt)
 {
+
 //   Reset per-event data.
+
   for(Int_t ip=0;ip<fNLayers;ip++) {
     fPlanes[ip]->Clear(opt);
   }
+
  // fTrackProj->Clear();
+
+  fNhits = 0;
+  fNclust = 0;
+  fMult = 0;
+  fE = 0.;
+  fEpr = 0.;
+  fX = -75.;   //out of acceptance
 }
 
 //_____________________________________________________________________________
 Int_t THcShower::Decode( const THaEvData& evdata )
 {
+
+  Clear();
+
   // Get the Hall C style hitlist (fRawHitList) for this event
   Int_t nhits = THcHitList::DecodeToHitList(evdata);
 
-if(gHaCuts->Result("Pedestal_event")) {
+  if(gHaCuts->Result("Pedestal_event")) {
     Int_t nexthit = 0;
     for(Int_t ip=0;ip<fNLayers;ip++) {
       nexthit = fPlanes[ip]->AccumulatePedestals(fRawHitList, nexthit);
-//cout << "nexthit = " << nexthit << endl;
+      //cout << "nexthit = " << nexthit << endl;
     }
     fAnalyzePedestals = 1;	// Analyze pedestals first normal events
     return(0);
   }
 
-   if(fAnalyzePedestals) {
-     for(Int_t ip=0;ip<fNLayers;ip++) {
-       fPlanes[ip]->CalculatePedestals();
-     }
-     fAnalyzePedestals = 0;	// Don't analyze pedestals next event
-   }
-
-
+  if(fAnalyzePedestals) {
+    for(Int_t ip=0;ip<fNLayers;ip++) {
+      fPlanes[ip]->CalculatePedestals();
+    }
+    fAnalyzePedestals = 0;	// Don't analyze pedestals next event
+  }
 
   Int_t nexthit = 0;
   for(Int_t ip=0;ip<fNLayers;ip++) {
     nexthit = fPlanes[ip]->ProcessHits(fRawHitList, nexthit);
   }
-/*
-//   fRawHitList is TClones array of THcShowerHit objects
-  for(Int_t ihit = 0; ihit < fNRawHits ; ihit++) {
-    THcShowerHit* hit = (THcShowerHit *) fRawHitList->At(ihit);
-    cout << ihit << " : " << hit->fPlane << ":" << hit->fCounter << " : "
-	 << hit->fADC_pos << " " << hit->fADC_neg << " "  << endl;
-  }
-  cout << endl;
-*/
+
+  //   fRawHitList is TClones array of THcRawShowerHit objects
+  //  cout << "THcShower::Decode: Shower raw hit list:" << endl;
+  //  for(Int_t ihit = 0; ihit < fNRawHits ; ihit++) {
+  //    THcRawShowerHit* hit = (THcRawShowerHit *) fRawHitList->At(ihit);
+  //    cout << ihit << " : " << hit->fPlane << ":" << hit->fCounter << " : "
+  //	 << hit->fADC_pos << " " << hit->fADC_neg << " "  << endl;
+  //  }
+  //  cout << endl;
+
   return nhits;
 }
 
@@ -322,11 +507,11 @@ Int_t THcShower::ApplyCorrections( void )
 }
 
 //_____________________________________________________________________________
-Double_t THcShower::TimeWalkCorrection(const Int_t& paddle,
-					     const ESide side)
-{
-  return(0.0);
-}
+//Double_t THcShower::TimeWalkCorrection(const Int_t& paddle,
+//					     const ESide side)
+//{
+//  return(0.0);
+//}
 
 //_____________________________________________________________________________
 Int_t THcShower::CoarseProcess( TClonesArray&  ) //tracks
@@ -339,8 +524,126 @@ Int_t THcShower::CoarseProcess( TClonesArray&  ) //tracks
   //
   //  static const Double_t sqrt2 = TMath::Sqrt(2.);
   
-  ApplyCorrections();
+  cout << "THcShower::CoarseProcess called ---------------------------" <<endl;
+
+  //  ApplyCorrections();
+
+  //
+  // Clustering of hits.
+  //
+
+  THcShowerHitList HitList;                    //list of unclusterd hits
+
+  for(Int_t j=0; j < fNLayers; j++) {
+
+   //cout << "Plane " << j << "  Eplane = " << fPlanes[j]->GetEplane() << endl;
+
+    for (Int_t i=0; i<fNBlocks[j]; i++) {
+
+      //May be should be done this way.
+      //
+      //      Float_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
+      //      	THcShowerHit* hit = new THcShowerHit(i,j,x,z,Edep);
+
+      //ENGINE way.
+      //
+      //      if (fPlanes[j]->GetApos(i)> fPlanes[j]->GetPosThr(i) ||
+      //	  fPlanes[j]->GetAneg(i)> fPlanes[j]->GetNegThr(i)) {    //hit
+      if (fPlanes[j]->GetApos(i) - fPlanes[j]->GetPosPed(i) >
+	  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
+	THcShowerHit* hit = new THcShowerHit(i,j,x,z,Edep);
+
+	HitList.push_back(hit);
+
+	//cout << "Hit: Edep = " << Edep << " X = " << x << " Z = " << z <<
+	//	  " Block " << i << " Layer " << j << endl;
+      };
+
+    }
+  }
+
+  //Print out hits before clustering.
+  //
+  fNhits = HitList.size();
+  cout << "Total hits:     " << fNhits << endl;
+  for (UInt_t i=0; i!=fNhits; i++) {
+    cout << "unclustered hit " << i << ": ";
+    (*(HitList.begin()+i))->show();
+  }
+
+  THcShowerClusterList* ClusterList = new THcShowerClusterList;
+  ClusterList->ClusterHits(HitList);
+
+  //Print out the cluster list.
+  //
+  fNclust = (*ClusterList).NbClusters();
+  cout << "Cluster_list size: " << fNclust << endl;
+
+  for (UInt_t i=0; i!=fNclust; i++) {
+
+    THcShowerCluster* cluster = (*ClusterList).ListedCluster(i);
+
+    cout << "Cluster #" << i 
+         <<":  E=" << (*cluster).clE() 
+         << "  Epr=" << (*cluster).clEpr()
+         << "  X=" << (*cluster).clX()
+         << "  Z=" << (*cluster).clZ()
+         << "  size=" << (*cluster).clSize()
+         << endl;
+
+    for (UInt_t j=0; j!=(*cluster).clSize(); j++) {
+      THcShowerHit* hit = (*cluster).ClusteredHit(j);
+      cout << "  hit #" << j << ":  "; (*hit).show();
+    }
+
+  }
+
+  
+  //The largest cluster.
+  //
+
+  if (fNclust != 0) {
+
+    THcShowerCluster* MaxCluster;
+
+    for (UInt_t i=0; i!=fNclust; i++) {
+
+      THcShowerCluster* cluster = (*ClusterList).ListedCluster(i);
+
+      Int_t size = (*cluster).clSize();
+
+      if (fMult < size) {
+	fMult = size;
+	MaxCluster = cluster;
+      }
+    }
+
+    fE = (*MaxCluster).clE();
+    fEpr = (*MaxCluster).clEpr();
+    fX = (*MaxCluster).clX();
+  }
 
+  cout << fEpr << " " << fE << " " << fX << " PrSh" << endl;
+
+  /*
+    cout << "Cluster #" << i 
+         <<":  E=" << (*cluster).clE() 
+         << "  Epr=" << (*cluster).clEpr()
+         << "  X=" << (*cluster).clX()
+         << "  Z=" << (*cluster).clZ()
+         << "  size=" << (*cluster).clSize()
+         << endl;
+  */
+   
+  cout << "THcShower::CoarseProcess return ---------------------------" <<endl;
   return 0;
 }
 
diff --git a/src/THcShower.h b/src/THcShower.h
index 27a91daec374055484aa08ea4bb2276eb601fb15..f6ebd34cd8400a59d0ca02a774aeb164bd150e00 100644
--- a/src/THcShower.h
+++ b/src/THcShower.h
@@ -10,7 +10,6 @@
 #include "TClonesArray.h"
 #include "THaNonTrackingDetector.h"
 #include "THcHitList.h"
-#include "THcShowerHit.h"
 #include "THcShowerPlane.h"
 
 class THaScCalib;
@@ -34,31 +33,96 @@ public:
   Int_t GetNTracks() const { return fTrackProj->GetLast()+1; }
   const TClonesArray* GetTrackHits() const { return fTrackProj; }
 
-  Int_t GetNBlocks(Int_t plane) const { return fNBlocks[plane-1];}
-  friend class THaScCalib;
+  Int_t GetNBlocks(Int_t NLayer) const { return fNBlocks[NLayer];}
+
+  //  friend class THaScCalib; not needed?
+
+  Int_t GetPedLimit(Int_t NBlock, Int_t NLayer, Int_t Side) {
+    if (Side!=0&&Side!=1) {
+      cout << "*** Wrong Side in GetPedLimit:" << Side << " ***" << endl;
+      return -1;
+    }
+    Int_t nelem = 0;
+    for (Int_t i=0; i<NLayer; i++) nelem += fNBlocks[i];
+    nelem += NBlock;
+    return ( Side == 0 ? fShPosPedLimit[nelem] : fShNegPedLimit[nelem]);
+  }
+
+  Double_t GetGain(Int_t NBlock, Int_t NLayer, Int_t Side) {
+    if (Side!=0&&Side!=1) {
+      cout << "*** Wrong Side in GetGain:" << Side << " ***" << endl;
+      return -1;
+    }
+    Int_t nelem = 0;
+    for (Int_t i=0; i<NLayer; i++) nelem += fNBlocks[i];
+    nelem += NBlock;
+    return ( Side == 0 ? fPosGain[nelem] : fNegGain[nelem]);
+  }
+
+  Int_t GetMinPeds() {
+    return fShMinPeds;
+  }
+
+  Int_t GetMult() {
+    return fMult;
+  }
 
   THcShower();  // for ROOT I/O
+
 protected:
+
   Int_t fAnalyzePedestals;
-  // Calibration
+
+  // ADC signal limits for pedestal calculations.
+  Int_t* fShPosPedLimit;
+  Int_t* fShNegPedLimit;
+
+  Int_t fShMinPeds;   //Min.number of events to analize/update pedestals.
+
+  // Calibration constants
+  Double_t* fPosGain;
+  Double_t* fNegGain;
 
   // 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
+  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
+  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",      
 
   // Potential Hall C parameters.  Mostly here for demonstration
+
   char** fLayerNames;
   Int_t fNLayers;
-  Int_t fNRows;
-  Double_t* fNLayerZPos;		// Z position of front of shower counter layers
+  //  Int_t fNRows;             fNBlocks is used instead
+  Double_t* fNLayerZPos;	// Z position of front of shower counter layers
   Double_t* BlockThick;		// Thickness of shower counter blocks, blocks
-  Int_t* fNBlocks;           // Number of shower counter blocks per layer
-  Double_t** YPos;		//X,Y positions of shower counter blocks
-  Double_t* XPos;
+  Int_t* fNBlocks;              // Number of shower counter blocks per layer
+  Int_t fNtotBlocks;            // Total number of shower counter blocks
+  Double_t** XPos;		//X,Y,Z positions of shower counter blocks
+  Double_t* YPos;
+  Double_t* ZPos;
+  Int_t fNegCols; //number of columns with PMTTs on the negative side only.
+  Double_t fSlop;               //Track to cluster vertical slop distance.
+  Int_t fvTest;                 //fiducial volume test flag
 
   THcShowerPlane** fPlanes; // List of plane objects
 
   TClonesArray*  fTrackProj;  // projection of track onto scintillator plane
                               // and estimated match to TOF paddle
+
   // Useful derived quantities
   // double tan_angle, sin_angle, cos_angle;
   
@@ -81,12 +145,12 @@ protected:
   virtual Int_t  ReadDatabase( const TDatime& date );
   virtual Int_t  DefineVariables( EMode mode = kDefine );
 
-  enum ESide { kLeft = 0, kRight = 1 };
+  //  enum ESide { kLeft = 0, kRight = 1 };
   
-  virtual  Double_t TimeWalkCorrection(const Int_t& paddle,
-					   const ESide side);
+  //  virtual  Double_t TimeWalkCorrection(const Int_t& paddle,
+  //				       const ESide side);
 
-void Setup(const char* name, const char* description);
+  void Setup(const char* name, const char* description);
 
   ClassDef(THcShower,0)   // Generic hodoscope class
 };
diff --git a/src/THcShowerCluster.h b/src/THcShowerCluster.h
new file mode 100644
index 0000000000000000000000000000000000000000..d330810de469495f0c0f9775ef3268994ee2ad7c
--- /dev/null
+++ b/src/THcShowerCluster.h
@@ -0,0 +1,200 @@
+#ifndef ROOT_THcShowerCluster
+#define ROOT_THcShowerCluster
+
+//HMS calorimeter hit cluster, version 3.
+
+#include "THcShowerHit.h"
+
+//HMS calorimeter hit cluster
+//
+class THcShowerCluster : THcShowerHitList {
+
+ public:
+
+  THcShowerCluster() {
+    //    cout << "Dummy THcShowerCluster object created" << endl;
+  }
+
+  ~THcShowerCluster() {
+    for (THcShowerHitIt i = THcShowerHitList::begin();
+    	 i != THcShowerHitList::end(); i++) {
+      delete *i;
+      *i = 0;
+    }
+    //    purge(THcShowerHitList::);
+    //    THcShowerHitList::clear();
+    //    cout << "THcShowerCluster object destructed" << endl;
+  }
+
+  // Add a hit to the cluster hit list
+  //
+  void grow(THcShowerHit* hit) {
+    THcShowerHitList::push_back(hit);
+  }
+
+  //Pointer to the hit #i in the cluster hit list
+  //
+  THcShowerHit* ClusteredHit(UInt_t i) {
+    return * (THcShowerHitList::begin()+i);
+  }
+
+  //Print out a hit in the cluster
+  //
+  void showHit(UInt_t num) {
+    (*(THcShowerHitList::begin()+num))->show();
+  }
+
+  //X coordinate of cluster's center of gravity.
+  //
+  float clX() {
+    float x_sum=0.;
+    float Etot=0.;
+    for (THcShowerHitIt it=THcShowerHitList::begin();
+	 it!=THcShowerHitList::end(); it++) {
+      x_sum += (*it)->hitX() * (*it)->hitE();
+      Etot += (*it)->hitE();
+    }
+    //    cout << "x_sum=" << x_sum << "  Etot=" << Etot << endl;
+    return (Etot != 0. ? x_sum/Etot : -75.);
+  }
+
+  //Z coordinate for a cluster, calculated as a weighted by energy average.
+  //
+  float clZ() {
+    float z_sum=0.;
+    float Etot=0.;
+    for (THcShowerHitIt it=THcShowerHitList::begin();
+	 it!=THcShowerHitList::end(); it++) {
+      z_sum += (*it)->hitZ() * (*it)->hitE();
+      Etot += (*it)->hitE();
+    }
+    //    cout << "z_sum=" << z_sum << "  Etot=" << Etot << endl;
+    return z_sum/Etot;
+  }
+
+  //Energy depostion in a cluster
+  //
+  float clE() {
+    //    cout << "In ECl:" << endl;
+    float Etot=0.;
+    for (THcShowerHitIt it=THcShowerHitList::begin();
+	 it!=THcShowerHitList::end(); it++) {
+      Etot += (*it)->hitE();
+    }
+    return Etot;
+  }
+
+  //Energy deposition in the Preshower (1st layer) for a cluster
+  //
+  float clEpr() {
+    float Epr=0.;
+    for (THcShowerHitIt it=THcShowerHitList::begin();
+	 it!=THcShowerHitList::end(); it++) {
+      if ((*it)->hitColumn() == 0) Epr += (*it)->hitE();
+    }
+    return Epr;
+  }
+
+  //Cluster size.
+  //
+  UInt_t clSize() {
+    return THcShowerHitList::size();
+  }
+
+};
+
+//-----------------------------------------------------------------------------
+
+//Alias for cluster container and for its iterator
+//
+typedef vector<THcShowerCluster*> THcShClusterList;
+typedef THcShClusterList::iterator THcShClusterIt;
+
+//List of clusters
+
+class THcShowerClusterList : private THcShClusterList {
+
+ public:
+
+  THcShowerClusterList() {
+    //    cout << "Dummy THcShowerClusterList object created" << endl;
+  }
+
+  ~THcShowerClusterList() {
+    for (THcShClusterIt i = THcShClusterList::begin();
+    	 i != THcShClusterList::end(); i++) {
+      delete *i;
+      *i = 0;
+    }
+    //    purge(THcShClusterList);
+    //    THcShClusterList::clear();
+    //    cout << "THcShowerClusterList object destroyed" << endl;
+  }
+
+  //Put a cluster in the cluster list
+  //
+  void grow(THcShowerCluster* cluster) {
+    THcShClusterList::push_back(cluster);
+  }
+
+  //Pointer to the cluster #i in the cluster list
+  //
+  THcShowerCluster* ListedCluster(UInt_t i) {
+    return *(THcShClusterList::begin()+i);
+  }
+
+  //Cluster list size.
+  //
+  UInt_t NbClusters() {
+    return THcShClusterList::size();
+  }
+
+//_____________________________________________________________________________
+
+void ClusterHits(THcShowerHitList HitList) {
+
+//Cluster hits from the HitList. The resultant hit clusters are saved
+//in the ClusterList.
+
+  while (HitList.size() != 0) {
+
+    THcShowerCluster* cluster = new THcShowerCluster;
+
+    (*cluster).grow(*(HitList.end()-1)); //move the last hit from the hit list
+    HitList.erase(HitList.end()-1);      //into the 1st cluster
+    bool clustered = true;
+
+    while (clustered) {                   //while a hit is clustered
+
+      clustered = false;
+
+      for (THcShowerHitIt i=HitList.begin(); i!=HitList.end(); i++) {
+
+	for (UInt_t k=0; k!=(*cluster).clSize(); k++) {
+
+	  if ((**i).isNeighbour((*cluster).ClusteredHit(k))) {
+
+	    (*cluster).grow(*i);          //If hit i is neighbouring a hit
+	    HitList.erase(i);             //in the cluster, then move it
+	                                  //into cluster.
+	    clustered = true;
+	  }
+
+	  if (clustered) break;
+	}                                 //k
+
+	if (clustered) break;
+      }                                   //i
+
+    }                                     //while clustered
+
+    //    (*ClusterList).grow(cluster);  //Put the cluster in the cluster list
+    grow(cluster);        //Put the cluster in the cluster list
+
+  }                                       //while hit_list not exhausted
+
+}
+
+};
+
+#endif
diff --git a/src/THcShowerHit.h b/src/THcShowerHit.h
index 7d1a5f08ee650cf8eb3a96dd82ce4a9ff414171f..fc6b15472f116ead77b531de6237ce480ee57d7e 100644
--- a/src/THcShowerHit.h
+++ b/src/THcShowerHit.h
@@ -1,36 +1,89 @@
 #ifndef ROOT_THcShowerHit
 #define ROOT_THcShowerHit
 
-#include "THcRawHit.h"
+// HMS calorimeter hit, version 2
 
-class THcShowerHit : public THcRawHit {
+#include <vector>
+#include <iterator>
+#include <iostream>
+
+using namespace std;
+
+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
 
  public:
 
- THcShowerHit(Int_t plane=0, Int_t counter=0) : THcRawHit(plane, counter), 
-    fADC_pos(-1), fADC_neg(-1){
+  THcShowerHit() {             //default constructor
+  fCol=fRow=0;
+  fX=fZ=0.;
+  fE=0.;
   }
-  THcShowerHit& operator=( const THcShowerHit& );
-  virtual ~THcShowerHit() {}
 
-  virtual void Clear( Option_t* opt="" )
-    { fADC_pos = -1; fADC_neg = -1; }
+  THcShowerHit(UInt_t hRow, UInt_t hCol, float hX, float hZ,
+	       float hE) {
+    fRow=hRow;
+    fCol=hCol;
+    fX=hX;
+    fZ=hZ;
+    fE=hE;
+  }
 
-  void SetData(Int_t signal, Int_t data);
-  Int_t GetData(Int_t signal);
+  ~THcShowerHit() {
+    //    cout << " hit destructed" << endl;
+  }
 
-  //  virtual Bool_t  IsSortable () const {return kTRUE; }
-  //  virtual Int_t   Compare(const TObject* obj) const;
+  UInt_t hitColumn() {
+    return fCol;
+  }
 
-  Int_t fADC_pos;
-  Int_t fADC_neg;
+  UInt_t hitRow() {
+    return fRow;
+  }
 
- protected:
+  float hitX() {
+    return fX;
+  }
 
- private:
+  float hitZ() {
+    return fZ;
+  }
 
-  ClassDef(THcShowerHit, 0);	// Shower hit class
-};  
+  float hitE() {
+    return fE;
+  }
+
+  bool isNeighbour(THcShowerHit* hit1) {      //Is hit1 neighbouring this hit?
+    Int_t dRow = fRow-(*hit1).fRow;
+    Int_t dCol = fCol-(*hit1).fCol;
+    return TMath::Abs(dRow)<2 && TMath::Abs(dCol)<2;
+  }
+
+  //Print out hit information
+  //
+  void show() {
+    cout << "row=" << fRow << "  column=" << fCol << 
+      "  x=" << fX << "  z=" << fZ << "  E=" << fE << endl;
+  }
+
+};
+
+
+typedef vector<THcShowerHit*> THcShowerHitList;      //alias for hit container
+typedef THcShowerHitList::iterator THcShowerHitIt;   //and for its iterator
+
+//Purge sequence container of pointers. Found in Echel, v.2, p.253.
+//
+template<class Seq> void purge(Seq& c) {
+  typename Seq::iterator i;
+  for(i = c.begin(); i != c.end(); i++) {
+    delete *i;
+    *i = 0;
+  }
+}
 
 #endif
- 
diff --git a/src/THcShowerPlane.cxx b/src/THcShowerPlane.cxx
index 0afc59cec68f15deb07e4ddc1359d7e1e94b2dc5..aeb85b29572b7a0ee400c228cd12f2cfc388a660 100644
--- a/src/THcShowerPlane.cxx
+++ b/src/THcShowerPlane.cxx
@@ -13,6 +13,7 @@
 #include "THcParmList.h"
 #include "THcHitList.h"
 #include "THcShower.h"
+#include "THcRawShowerHit.h"
 #include "TClass.h"
 #include "math.h"
 
@@ -57,7 +58,11 @@ THcShowerPlane::~THcShowerPlane()
   delete [] fA_Pos_p;
   delete [] fA_Neg_p;
 
+  delete [] fEpos;
+  delete [] fEneg;
+  delete [] fEmean;
 }
+
 THaAnalysisObject::EStatus THcShowerPlane::Init( const TDatime& date )
 {
   // Extra initialization for shower layer: set up DataDest map
@@ -105,13 +110,20 @@ Int_t THcShowerPlane::ReadDatabase( const TDatime& date )
 
   fParent = (THcShower*) GetParent();
 
-  fNelem = fParent->GetNBlocks(fLayerNum);
+  fNelem = fParent->GetNBlocks(fLayerNum-1);
+
+  //  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];
 
+  fEpos = new Float_t[fNelem];
+  fEneg = new Float_t[fNelem];
+  fEmean= new Float_t[fNelem];
+
  //  fNelem = *(Int_t *)gHcParms->Find(parname)->GetValuePointer();
 // 
 //   parname[plen]='\0';
@@ -127,9 +139,29 @@ Int_t THcShowerPlane::ReadDatabase( const TDatime& date )
   
   // Create arrays to hold results here
 
- InitializePedestals();
+  fPosPedLimit = new Int_t [fNelem];
+  fNegPedLimit = new Int_t [fNelem];
+
+  for(Int_t i=0;i<fNelem;i++) {
+    fPosPedLimit[i] = fParent->GetPedLimit(i,fLayerNum-1,0);
+    fNegPedLimit[i] = fParent->GetPedLimit(i,fLayerNum-1,1);
+  }
+
+  cout << "   fPosPedLimit:";
+  for(Int_t i=0;i<fNelem;i++) cout << " " << fPosPedLimit[i];
+  cout << endl;
+  cout << "   fNegPedLimit:";
+  for(Int_t i=0;i<fNelem;i++) cout << " " << fNegPedLimit[i];
+  cout << endl;
+
+  fMinPeds = fParent->GetMinPeds();
+  cout << "   fMinPeds = " << fMinPeds << endl;
+
+  InitializePedestals();
+
   return kOK;
 }
+
 //_____________________________________________________________________________
 Int_t THcShowerPlane::DefineVariables( EMode mode )
 {
@@ -148,6 +180,10 @@ Int_t THcShowerPlane::DefineVariables( EMode mode )
     {"aneg",   "Raw Negative ADC Amplitudes",            "fA_Neg"},
     {"apos_p", "Ped-subtracted Positive ADC Amplitudes", "fA_Pos_p"},
     {"aneg_p", "Ped-subtracted Negative ADC Amplitudes", "fA_Neg_p"},
+    {"epos",   "Energy Depositions from Positive Side PMTs", "fEpos"},
+    {"eneg",   "Energy Depositions from Negative Side PMTs", "fEneg"},
+    {"emean",  "Mean Energy Depositions",                    "fEMean"},
+    {"eplane", "Energy Deposition per plane",                "fEplane"},
     { 0 }
   };
 
@@ -171,12 +207,15 @@ Int_t THcShowerPlane::Decode( const THaEvData& evdata )
 
   return 0;
 }
+
 //_____________________________________________________________________________
 Int_t THcShowerPlane::CoarseProcess( TClonesArray& tracks )
 {
  
   //  HitCount();
 
+  cout << "THcShowerPlane::CoarseProcess called ---------------------" << endl;
+
  return 0;
 }
 
@@ -185,6 +224,7 @@ Int_t THcShowerPlane::FineProcess( TClonesArray& tracks )
 {
   return 0;
 }
+
 Int_t THcShowerPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit)
 {
   // Extract the data for this layer from hit list
@@ -201,15 +241,20 @@ Int_t THcShowerPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit)
     fA_Neg[i] = 0;
     fA_Pos_p[i] = 0;
     fA_Neg_p[i] = 0;
+    fEpos[i] = 0;
+    fEneg[i] = 0;
+    fEmean[i] = 0;
   }
 
+  fEplane = 0;
+
   Int_t nrawhits = rawhits->GetLast()+1;
 
   Int_t ihit = nexthit;
   //cout << "nrawhits =  " << nrawhits << endl;
   //cout << "nexthit =  " << nexthit << endl;
   while(ihit < nrawhits) {
-    THcShowerHit* hit = (THcShowerHit *) rawhits->At(ihit);
+    THcRawShowerHit* hit = (THcRawShowerHit *) rawhits->At(ihit);
 
     //cout << "fplane =  " << hit->fPlane << " Num = " << fLayerNum << endl;
     if(hit->fPlane > fLayerNum) {
@@ -223,23 +268,37 @@ Int_t THcShowerPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit)
     fA_Pos_p[hit->fCounter-1] = hit->fADC_pos - fPosPed[hit->fCounter -1];
     fA_Neg_p[hit->fCounter-1] = hit->fADC_neg - fNegPed[hit->fCounter -1];
 
-    double thresh_pos = fPosThresh[hit->fCounter -1];
+    THcShower* fParent;
+    fParent = (THcShower*) GetParent();
+
+    Double_t thresh_pos = fPosThresh[hit->fCounter -1];
     if(hit->fADC_pos >  thresh_pos) {
-      THcSignalHit *sighit = (THcSignalHit*) fPosADCHits->ConstructedAt(nPosADCHits++);
 
+      THcSignalHit *sighit = (THcSignalHit*) fPosADCHits->ConstructedAt(nPosADCHits++);
       sighit->Set(hit->fCounter, hit->fADC_pos);
+
+      fEpos[hit->fCounter-1] += fA_Pos_p[hit->fCounter-1]*
+	fParent->GetGain(hit->fCounter-1,fLayerNum-1,0);
     }
 
-    double thresh_neg = fNegThresh[hit->fCounter -1];
+    Double_t thresh_neg = fNegThresh[hit->fCounter -1];
     if(hit->fADC_neg >  thresh_neg) {
+
       THcSignalHit *sighit = (THcSignalHit*) fNegADCHits->ConstructedAt(nNegADCHits++);
       sighit->Set(hit->fCounter, hit->fADC_neg);
+
+      fEneg[hit->fCounter-1] += fA_Neg_p[hit->fCounter-1]*
+	fParent->GetGain(hit->fCounter-1,fLayerNum-1,1);
     }
 
+    fEmean[hit->fCounter-1] += (fEpos[hit->fCounter-1] + fEneg[hit->fCounter-1]);
+    fEplane += fEmean[hit->fCounter-1];
+
     ihit++;
   }
   return(ihit);
 }
+
 //_____________________________________________________________________________
 Int_t THcShowerPlane::AccumulatePedestals(TClonesArray* rawhits, Int_t nexthit)
 {
@@ -250,7 +309,7 @@ Int_t THcShowerPlane::AccumulatePedestals(TClonesArray* rawhits, Int_t nexthit)
   //  cout << "THcScintillatorPlane::AcculatePedestals " << fLayerNum << " " << nexthit << "/" << nrawhits << endl;
   Int_t ihit = nexthit;
   while(ihit < nrawhits) {
-    THcShowerHit* hit = (THcShowerHit *) rawhits->At(ihit);
+    THcRawShowerHit* hit = (THcRawShowerHit *) rawhits->At(ihit);
     //cout << "fPlane =  " << hit->fPlane << " Limit = " << fPlaneNum << endl;
     if(hit->fPlane > fLayerNum) {
       break;
@@ -282,9 +341,8 @@ Int_t THcShowerPlane::AccumulatePedestals(TClonesArray* rawhits, Int_t nexthit)
 
   return(ihit);
 }
-
     
- //_____________________________________________________________________________
+//_____________________________________________________________________________
 void THcShowerPlane::CalculatePedestals( )
 {
   // Use the accumulated pedestal data to calculate pedestals
@@ -304,7 +362,8 @@ void THcShowerPlane::CalculatePedestals( )
     //  fNegThresh[i] = fNegPed[i] + 15;
     fNegThresh[i] = fNegPed[i] + TMath::Min(50., TMath::Max(10., 3.*fNegSig[i]));
 
-    //    cout << i+1 << " " << 3.*fPosSig[i] << " " << 3.*fNegSig[i] << endl;
+    cout << "Ped&Thr: " << fPosPed[i] << " " << fPosThresh[i] << " " <<
+      fNegPed[i] << " " << fNegThresh[i] << " " << i+1 << endl;
   }
   //  cout << " " << endl;
   
@@ -314,14 +373,11 @@ void THcShowerPlane::CalculatePedestals( )
 void THcShowerPlane::InitializePedestals( )
 {
   fNPedestalEvents = 0;
-  fMinPeds = 500; 		// In engine, this is set in parameter file
   fPosPedSum = new Int_t [fNelem];
   fPosPedSum2 = new Int_t [fNelem];
-  fPosPedLimit = new Int_t [fNelem];
   fPosPedCount = new Int_t [fNelem];
   fNegPedSum = new Int_t [fNelem];
   fNegPedSum2 = new Int_t [fNelem];
-  fNegPedLimit = new Int_t [fNelem];
   fNegPedCount = new Int_t [fNelem];
 
   fPosSig = new Double_t [fNelem];
@@ -333,13 +389,9 @@ void THcShowerPlane::InitializePedestals( )
   for(Int_t i=0;i<fNelem;i++) {
     fPosPedSum[i] = 0;
     fPosPedSum2[i] = 0;
-    fPosPedLimit[i] = 1000;	// In engine, this are set in parameter file
     fPosPedCount[i] = 0;
     fNegPedSum[i] = 0;
     fNegPedSum2[i] = 0;
-    fNegPedLimit[i] = 1000;	// In engine, this are set in parameter file
     fNegPedCount[i] = 0;
   }
 } 
-  
-
diff --git a/src/THcShowerPlane.h b/src/THcShowerPlane.h
index 7e4c196c66d37010b0929e29a3081ea66721b53e..c38218b475cb98421605fcb60948d385bef25bda 100644
--- a/src/THcShowerPlane.h
+++ b/src/THcShowerPlane.h
@@ -35,7 +35,7 @@ class THcShowerPlane : public THaSubDetector {
 
   virtual Int_t CoarseProcess( TClonesArray& tracks );
   virtual Int_t FineProcess( TClonesArray& tracks );
-          Bool_t   IsTracking() { return kFALSE; }
+  Bool_t   IsTracking() { return kFALSE; }
   virtual Bool_t   IsPid()      { return kFALSE; }
 
   virtual Int_t ProcessHits(TClonesArray* rawhits, Int_t nexthit);
@@ -46,6 +46,46 @@ class THcShowerPlane : public THaSubDetector {
 
   TClonesArray* fParentHitList;
 
+  Float_t GetEplane() {
+    return fEplane;
+  };
+
+  Float_t GetEmean(Int_t i) {
+    return fEmean[i];
+  };
+
+  Float_t GetAposP(Int_t i) {
+    return fA_Pos_p[i];
+  };
+
+  Float_t GetAnegP(Int_t i) {
+    return fA_Neg_p[i];
+  };
+
+  Float_t GetApos(Int_t i) {
+    return fA_Pos[i];
+  };
+
+  Float_t GetAneg(Int_t i) {
+    return fA_Neg[i];
+  };
+
+  Float_t GetPosThr(Int_t i) {
+    return fPosThresh[i];
+  };
+
+  Float_t GetNegThr(Int_t i) {
+    return fNegThresh[i];
+  };
+
+  Float_t GetPosPed(Int_t i) {
+    return fPosPed[i];
+  };
+
+  Float_t GetNegPed(Int_t i) {
+    return fNegPed[i];
+  };
+
  protected:
 
   Float_t*   fA_Pos;         // [fNelem] Array of ADC amplitudes of blocks
@@ -53,6 +93,11 @@ class THcShowerPlane : public THaSubDetector {
   Float_t*   fA_Pos_p;	     // [fNelem] Array of pedestal subtracted ADC amplitudes
   Float_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
+
   TClonesArray* fPosADCHits;
   TClonesArray* fNegADCHits;
 
@@ -84,6 +129,3 @@ class THcShowerPlane : public THaSubDetector {
   ClassDef(THcShowerPlane,0)
 };
 #endif
-
-
-