diff --git a/CALIBRATION/shms_dc_calib/scripts/alignDC.py b/CALIBRATION/shms_dc_calib/scripts/alignDC.py
new file mode 100644
index 0000000000000000000000000000000000000000..b13083346b30db7e2339a3acedf1b54d61eecb85
--- /dev/null
+++ b/CALIBRATION/shms_dc_calib/scripts/alignDC.py
@@ -0,0 +1,102 @@
+#!/usr/bin/env python
+import sys
+import os
+import subprocess
+import ROOT
+from ROOT import gROOT
+########################################################################################################
+# This script is used to loop through tweaks to surveyed drift chambers to improve alignment. 
+# Here we only tweak x and y positions. 
+# You need to:
+#      -make an output folder at: CALIBRATION/shms_dc_calib/output_align
+#      -modify the run number (rNUM) and number of events (evNUM) as desired
+#      -modify the step sizes as desired
+#      -modify the start and max values as desired
+#
+# This should be run from the hallc_replay directory. Check path to hcana. 
+# Make directories: raw, ROOTfiles, CALIBRATION/shms_dc_calib/output_align,
+# REPORT_OUTPUT/SHMS/PRODUCTION
+# raw should contain the .dat input file
+#
+# Author: Holly Szumila, hszumila@jlab.org
+# Date: 27 September 2017
+########################################################################################################
+#######################################
+# Enter run number and number of events
+#######################################
+rNUM = 488
+evNUM = 10
+
+############################################
+# loop plane number, x position, y position
+############################################
+# define the step size:
+xposStep = 0.001
+yposStep = 0.001
+
+# define the starting values:
+xposInit = -0.05
+yposInit = -0.05
+
+# define the maximum values:
+xposMax = 0.05
+yposMax = 0.05
+
+# define the start values:
+xposSV = [-0.036,0.008]
+yposSV = [0.019,0.013] 
+
+# fill the start values by plane
+xGlobal = [xposSV[0], xposSV[0], xposSV[0], xposSV[0], xposSV[0], xposSV[0], xposSV[1], xposSV[1], xposSV[1], xposSV[1], xposSV[1], xposSV[1]]
+yGlobal = [yposSV[0], yposSV[0], yposSV[0], yposSV[0], yposSV[0], yposSV[0], yposSV[1], yposSV[1], yposSV[1], yposSV[1], yposSV[1], yposSV[1]]
+
+# loop plane 
+for plane in range (0,12):
+
+    # define the starting values for iteration
+    xpos = xposInit
+    ypos = yposInit
+
+    #  loop tweaks in x
+    while xpos < xposMax:
+        xShift = [0,0,0,0,0,0,0,0,0,0,0,0]
+        xShift[plane] = xpos
+        # generate the modified parameters
+        text_file = open("PARAM/dcalign.param","w")
+        text_file.write("; x and y position of each chamber, tweaking x.\n")
+        for iplane in range (0,12):
+            if (iplane == 0):
+                text_file.write("pdc_xpos = %f\n" %(xGlobal[iplane]+xShift[iplane]) )
+            else :
+                text_file.write("           %f\n" %(xGlobal[iplane]+xShift[iplane]) )
+        text_file.close()
+            
+        # open root in hcana, run the file, and exit
+        subprocess.call("./hcana -b -q 'CALIBRATION/shms_dc_calib/scripts/replay_aligndc_shms.C (%d,%d)'" % (rNUM, evNUM),shell=True)
+            
+        # move the output file and rename
+        os.rename("ROOTfiles/shms_replay_production_%d_%d.root" % (rNUM,evNUM), "CALIBRATION/shms_dc_calib/output_align/shms_replay_%d_xpos_%.3f.root" %(plane, xpos))
+        #os.rename("REPORT_OUTPUT/SHMS/PRODUCTION/replay_shms_production_%d_%d.report" % (rNUM,evNUM), "CALIBRATION/shms_dc_calib/output_align/replay_shms_production_%d_xpos_%.3f.report" %(plane, xpos))
+        #os.rename("PARAM/dcalign.param","CALIBRATION/shms_dc_calib/output_align/param_%d_xpos_%.3f.param" %(plane,xpos))
+        xpos += xposStep
+            
+    # loop tweaks in y
+    while ypos < yposMax:
+        yShift = [0,0,0,0,0,0,0,0,0,0,0,0]
+        yShift[plane] = ypos
+        # generate the modified parameters
+        text_file = open("PARAM/dcalign.param","w")
+        text_file.write("; x and y position of each chamber, tweaking y.\n")
+        for iplane in range (0,12):
+            if (iplane == 0):
+                text_file.write("pdc_ypos = %f\n" %(yGlobal[iplane]+yShift[iplane]) )
+            else :
+                text_file.write("           %f\n" %(yGlobal[iplane]+yShift[iplane]) )
+        text_file.close()
+    
+        # open root in hcana, run the file, and exit
+        subprocess.call("./hcana -b -q 'CALIBRATION/shms_dc_calib/scripts/replay_aligndc_shms.C (%d,%d)'" % (rNUM, evNUM),shell=True)
+            
+        # move the output file and rename
+        os.rename("ROOTfiles/shms_replay_production_%d_%d.root" % (rNUM,evNUM), "CALIBRATION/shms_dc_calib/output_align/shms_replay_%d_ypos_%.3f.root" %(plane, ypos))
+        ypos += yposStep
diff --git a/CALIBRATION/shms_dc_calib/scripts/makeAlignmentPlots.C b/CALIBRATION/shms_dc_calib/scripts/makeAlignmentPlots.C
new file mode 100644
index 0000000000000000000000000000000000000000..068352de2483bd756589acb14613e5218a18aca9
--- /dev/null
+++ b/CALIBRATION/shms_dc_calib/scripts/makeAlignmentPlots.C
@@ -0,0 +1,235 @@
+/**********************************************************************
+ * This is a root macro that can be run in root as:
+ *             .x makeAlignmentPlots.C
+ *
+ * This will output the plots that are needed to check 
+ * the alignment of the drift chambers. The global parameters 
+ * must be the same as those used in the script alignDC.py. 
+ * The input files are in the output_align folder and the path here 
+ * should be modified to get to them. This outputs a file, 
+ * offsets.txt which must be used for the next iteration to align 
+ * the drift chambers. (Take a total of about 2-4 iterations.)
+ *
+ *
+ * Author: Holly Szumila, hszumila@jlab.org
+ * Date: 27 September 2017
+ *
+ *********************************************************************/
+
+
+//define some globals:
+float xposStep = 0.001;
+float yposStep = 0.001;
+float xposInit = -0.05;
+float yposInit = -0.05;
+float xposMax = 0.05;
+float yposMax = 0.05;
+
+
+void makeAlignmentPlots(){
+ 
+  std::string pdf_file_name_A = "output_alignment_plots.pdf";
+  std::string pdf_file_name_R = "output_residual_plots.pdf";
+  gStyle->SetOptStat(0);
+
+  const int npoints = 1000;
+  const int nplanes = 12;
+  gROOT->SetBatch(kTRUE);
+
+  //plots by plane and by shift
+  TCanvas *cx[nplanes][npoints];
+  TCanvas *cy[nplanes][npoints];
+  
+  //store the minimum shift value for x,y
+  double shiftValue[nplanes][2];
+
+  //loop plane interested in
+  for (int npl=0; npl<nplanes; npl++){
+    double xdelta[npoints];
+    double ydelta[npoints];
+    double xmean[npoints];
+    double ymean[npoints];
+    int nx=0;
+    //loop x position
+    for (int xposShort=-50; xposShort<50; xposShort+=1){
+      float xpos = (float)xposShort/1000;
+      //for (float xpos=xposInit; xpos<xposMax; xpos+=xposStep){ 
+      //open the file
+      //if (xpos == -0.0){xpos = abs(xpos);}
+      cout<<"xpos:\t"<<xpos<<endl;
+      TFile *f = new TFile(Form("hallc_replay/CALIBRATION/shms_dc_calib/output_align/shms_replay_%d_xpos_%.3f.root",npl,xpos));
+      double sumMean = 0.0;
+      xdelta[nx] = xpos;
+      TF1 *fgaus[nplanes];
+
+      //load the histograms
+      TH1F *h_res[nplanes];
+      h_res[0] = (TH1F*)f->Get("pdc1u1_residuals");
+      h_res[1] = (TH1F*)f->Get("pdc1u2_residuals");
+      h_res[2] = (TH1F*)f->Get("pdc1x1_residuals");
+      h_res[3] = (TH1F*)f->Get("pdc1x2_residuals");  
+      h_res[4] = (TH1F*)f->Get("pdc1v1_residuals"); 
+      h_res[5] = (TH1F*)f->Get("pdc1v2_residuals");
+      h_res[6] = (TH1F*)f->Get("pdc2u1_residuals"); 
+      h_res[7] = (TH1F*)f->Get("pdc2u2_residuals");
+      h_res[8] = (TH1F*)f->Get("pdc2x1_residuals");
+      h_res[9] = (TH1F*)f->Get("pdc2x2_residuals");
+      h_res[10] = (TH1F*)f->Get("pdc2v1_residuals");
+      h_res[11] = (TH1F*)f->Get("pdc2v2_residuals");
+      
+      cx[npl][nx] = new TCanvas(Form("cx_%d_%d",npl,nx),Form("cx_%d_%d",npl,nx),800,800);
+      cx[npl][nx]->Divide(4,3);
+      //get the histogram of the relevant plane and fit
+      for (int ii=0; ii<nplanes; ii++){
+	cx[npl][nx]->cd(ii+1);
+	h_res[ii]->Draw();
+	fgaus[ii] = new TF1(Form("fg_%d",ii), "gaus",h_res[ii]->GetMean()-0.1,h_res[ii]->GetMean()+0.1);
+	h_res[ii]->Fit(Form("fg_%d",ii),"RQ");
+	gStyle->SetOptFit(111);
+	if (ii==0){
+	  TPad *newpad=new TPad("newpad","a transparent pad",0,0,1,1);
+	  newpad->SetFillStyle(4000);
+	  newpad->Draw();
+	  newpad->cd();
+	  TPaveLabel *title = new TPaveLabel(0.1,0.88,0.9,0.92,Form("Plane_%d, x-shift_%.3f",npl, xpos));
+	  title->SetFillColor(16);
+	  title->SetTextFont(52);
+	  title->Draw();
+	}
+	sumMean += abs(fgaus[ii]->GetParameter(1));
+      }
+      
+      cx[npl][nx]->Update();
+      cx[npl][nx]->Print((pdf_file_name_R+"(").c_str());
+      cx[npl][nx]->Close();
+      xmean[nx] = sumMean;
+      nx++;
+      f->Close();
+    } //end xpos loop
+    
+    int ny=0;
+    //loop the y position
+    for (int yposShort=-50; yposShort<50; yposShort+=1){
+      float ypos = (float)yposShort/1000;
+    //for (float ypos=yposInit; ypos<yposMax; ypos+=yposStep){ 
+      //if (ypos == -0.0){ypos = abs(ypos);}
+      //open the file
+      TFile *f = new TFile(Form("hallc_replay/CALIBRATION/shms_dc_calib/output_align/shms_replay_%d_ypos_%.3f.root",npl,ypos));
+      double sumMean = 0.0;
+      ydelta[ny] = ypos;
+      TF1 *fgaus[nplanes]; 
+      
+      //load the histograms
+      TH1F *h_res[nplanes];
+      h_res[0] = (TH1F*)f->Get("pdc1u1_residuals");
+      h_res[1] = (TH1F*)f->Get("pdc1u2_residuals");
+      h_res[2] = (TH1F*)f->Get("pdc1x1_residuals");
+      h_res[3] = (TH1F*)f->Get("pdc1x2_residuals");  
+      h_res[4] = (TH1F*)f->Get("pdc1v1_residuals"); 
+      h_res[5] = (TH1F*)f->Get("pdc1v2_residuals");
+      h_res[6] = (TH1F*)f->Get("pdc2u1_residuals"); 
+      h_res[7] = (TH1F*)f->Get("pdc2u2_residuals");
+      h_res[8] = (TH1F*)f->Get("pdc2x1_residuals");
+      h_res[9] = (TH1F*)f->Get("pdc2x2_residuals");
+      h_res[10] = (TH1F*)f->Get("pdc2v1_residuals");
+      h_res[11] = (TH1F*)f->Get("pdc2v2_residuals");
+      
+      cy[npl][ny] = new TCanvas(Form("cy_%d_%d",npl,ny),Form("cy_%d_%d",npl,ny),800,800);
+      cy[npl][ny]->Divide(4,3);
+      //get the histogram of the relevant plane and fit
+      for (int ii=0; ii<nplanes; ii++){
+	cy[npl][ny]->cd(ii+1);
+	h_res[ii]->Draw();
+	fgaus[ii] = new TF1(Form("fg_%d",ii), "gaus",h_res[ii]->GetMean()-0.1,h_res[ii]->GetMean()+0.1);
+	h_res[ii]->Fit(Form("fg_%d",ii),"RQ");
+	gStyle->SetOptFit(111);
+	if (ii==0){
+	  TPad *newpad=new TPad("newpad","a transparent pad",0,0,1,1);
+	  newpad->SetFillStyle(4000);
+	  newpad->Draw();
+	  newpad->cd();
+	  TPaveLabel *title = new TPaveLabel(0.1,0.88,0.9,0.92,Form("Plane_%d, y-shift_%.3f",npl, ypos));
+	  title->SetFillColor(16);
+	  title->SetTextFont(52);
+	  title->Draw();
+	}
+	sumMean += abs(fgaus[ii]->GetParameter(1));
+      }    
+      cy[npl][ny]->Update();
+      cy[npl][ny]->Print((pdf_file_name_R+"(").c_str());
+      cy[npl][ny]->Close();
+      ymean[ny] = sumMean;
+      ny++;
+      f->Close();
+    }//end ypos loop
+    
+    
+    //cut down arrays to correct size:
+    double xdeltaCut[nx];
+    double xmeanCut[nx];
+    int filledx = 0;
+    for (int jj=0; jj<nx; jj++){
+      xdeltaCut[jj] = xdelta[jj];
+      xmeanCut[jj] = xmean[jj];
+      if (jj!=0){
+	if (xmeanCut[jj]>xmeanCut[jj-1] && filledx==0){
+	  shiftValue[npl][0] = xdeltaCut[jj-1];
+	  filledx++;
+	}
+      }
+    }
+    
+    //plot the x position vs the reference
+    TCanvas *cc = new TCanvas("cc","",800,400);
+    cc->Divide(2,1);
+    cc->cd(1);
+
+    TGraph *gx = new TGraph(nx,xdeltaCut,xmeanCut);
+    gx->SetMarkerStyle(20);
+    gx->SetMarkerColor(kRed);
+    gx->SetTitle(Form("Tweak x position, plane %d",npl+1));
+    gx->GetYaxis()->SetTitle("Sum of | residual means | [cm]");
+    gx->GetYaxis()->SetTitleOffset(1.2);
+    gx->GetXaxis()->SetTitle("x position tweak [cm]");
+    gx->Draw("ap");
+    
+    //cut down arrays to correct size:
+    double ydeltaCut[nx];
+    double ymeanCut[nx];
+    int filledy = 0;
+    for (int jj=0; jj<ny; jj++){
+      ydeltaCut[jj] = ydelta[jj];
+      ymeanCut[jj] = ymean[jj];
+      if (jj!=0){
+	if (ymeanCut[jj]>ymeanCut[jj-1] && filledy==0){
+	  shiftValue[npl][1] = ydeltaCut[jj-1];
+	  filledy++;
+	}
+      }
+    }
+    
+    //plot the y position vs the reference
+    cc->cd(2);
+    TGraph *gy = new TGraph(ny,ydeltaCut,ymeanCut);
+    gy->SetTitle(Form("Tweak y position, plane %d",npl+1));
+    gy->GetYaxis()->SetTitle("Sum of | residual means | [cm]");
+    gy->GetYaxis()->SetTitleOffset(1.2);
+    gy->GetXaxis()->SetTitle("y position tweak [cm]");
+    gy->SetMarkerStyle(20);
+    gy->SetMarkerColor(kBlue);
+    gy->Draw("ap");
+    cc->Update();
+    cc->Print((pdf_file_name_A+"(").c_str());
+    cc->Close();
+  }//end loop through planes
+
+  FILE *foffsets = fopen("offsets.txt","w");
+  fprintf(foffsets,"plane\t x-shift[cm]\t y-shift[cm]\n");
+  for (int kk=0;kk<nplanes; kk++){
+    fprintf(foffsets,Form("%d\t %.4f\t %.4f\n",kk+1,shiftValue[kk][0],shiftValue[kk][1]));
+  }
+  
+  TCanvas *cexit = new TCanvas("cexit","",1);
+  cexit->Print((pdf_file_name_A+")").c_str());
+  cexit->Print((pdf_file_name_R+")").c_str());
+}
diff --git a/CALIBRATION/shms_dc_calib/scripts/replay_aligndc_shms.C b/CALIBRATION/shms_dc_calib/scripts/replay_aligndc_shms.C
new file mode 100644
index 0000000000000000000000000000000000000000..69e5453c8ad04f90913c084dc50143f06031f688
--- /dev/null
+++ b/CALIBRATION/shms_dc_calib/scripts/replay_aligndc_shms.C
@@ -0,0 +1,145 @@
+void replay_aligndc_shms (Int_t RunNumber = 0, Int_t MaxEvent = 0) {
+
+  // Get RunNumber and MaxEvent if not provided.
+  if(RunNumber == 0) {
+    cout << "Enter a Run Number (-1 to exit): ";
+    cin >> RunNumber;
+    if( RunNumber<=0 ) return;
+  }
+  if(MaxEvent == 0) {
+    cout << "\nNumber of Events to analyze: ";
+    cin >> MaxEvent;
+    if(MaxEvent == 0) {
+      cerr << "...Invalid entry\n";
+      exit;
+    }
+  }
+
+  // Create file name patterns.
+  const char* RunFileNamePattern = "raw/shms_all_%05d.dat";
+  const char* ROOTFileNamePattern = "ROOTfiles/shms_replay_production_%d_%d.root";
+  
+  // Load global parameters
+  // Add variables to global list.
+  gHcParms->Define("gen_run_number", "Run Number", RunNumber);
+  gHcParms->AddString("g_ctp_database_filename", "DBASE/SHMS/STD/standard.database");
+  // Load varibles from files to global list.
+  gHcParms->Load(gHcParms->GetString("g_ctp_database_filename"), RunNumber);
+  // g_ctp_parm_filename and g_decode_map_filename should now be defined.
+  gHcParms->Load(gHcParms->GetString("g_ctp_kinematics_filename"), RunNumber);
+  gHcParms->Load(gHcParms->GetString("g_ctp_parm_filename"));
+  gHcParms->Load(gHcParms->GetString("g_ctp_calib_filename"));
+  // Load params for SHMS trigger configuration
+  gHcParms->Load("PARAM/TRIG/tshms.param");
+  //Change the position of each plane layer
+  gHcParms->Load("PARAM/dcalign.param");
+
+  // Load the Hall C detector map
+  gHcDetectorMap = new THcDetectorMap();
+  gHcDetectorMap->Load("MAPS/SHMS/DETEC/STACK/shms_stack.map");
+
+  // Add trigger apparatus
+  THaApparatus* TRG = new THcTrigApp("T", "TRG");
+  gHaApps->Add(TRG);
+  // Add trigger detector to trigger apparatus
+  THcTrigDet* shms = new THcTrigDet("shms", "SHMS Trigger Information");
+  TRG->AddDetector(shms);
+
+  // Set up the equipment to be analyzed.
+  THaApparatus* SHMS = new THcHallCSpectrometer("P", "SHMS");
+  gHaApps->Add(SHMS);
+  // Add Noble Gas Cherenkov to SHMS apparatus
+  THcCherenkov* ngcer = new THcCherenkov("ngcer", "Noble Gas Cherenkov");
+  SHMS->AddDetector(ngcer);
+  // Add drift chambers to SHMS apparatus
+  THcDC* dc = new THcDC("dc", "Drift Chambers");
+  SHMS->AddDetector(dc);
+  // Add hodoscope to SHMS apparatus
+  THcHodoscope* hod = new THcHodoscope("hod", "Hodoscope");
+  SHMS->AddDetector(hod);
+  // Add Heavy Gas Cherenkov to SHMS apparatus
+  THcCherenkov* hgcer = new THcCherenkov("hgcer", "Heavy Gas Cherenkov");
+  SHMS->AddDetector(hgcer);
+  // Add Aerogel Cherenkov to SHMS apparatus
+  THcAerogel* aero = new THcAerogel("aero", "Aerogel");
+  SHMS->AddDetector(aero);
+  // Add calorimeter to SHMS apparatus
+  THcShower* cal = new THcShower("cal", "Calorimeter");
+  SHMS->AddDetector(cal);
+
+  // Include golden track information
+  THaGoldenTrack* gtr = new THaGoldenTrack("P.gtr", "SHMS Golden Track", "P");
+  gHaPhysics->Add(gtr);
+  // Add Ideal Beam Apparatus
+  THaApparatus* beam = new THaIdealBeam("IB", "Ideal Beamline");
+  gHaApps->Add(beam);
+  // Add Physics Module to calculate primary (scattered beam - usually electrons) kinematics
+  THcPrimaryKine* kin = new THcPrimaryKine("P.kin", "SHMS Single Arm Kinematics", "P", "IB");
+  gHaPhysics->Add(kin);
+
+  // Add event handler for prestart event 125.
+  THcConfigEvtHandler* ev125 = new THcConfigEvtHandler("HC", "Config Event type 125");
+  gHaEvtHandlers->Add(ev125);
+  // Add event handler for EPICS events
+  THaEpicsEvtHandler* hcepics = new THaEpicsEvtHandler("epics", "HC EPICS event type 180");
+  gHaEvtHandlers->Add(hcepics);
+  // Add event handler for scaler events
+  THcScalerEvtHandler* pscaler = new THcScalerEvtHandler("P", "Hall C scaler event type 1");
+  pscaler->AddEvtType(1);
+  pscaler->SetUseFirstEvent(kTRUE);
+  gHaEvtHandlers->Add(pscaler);
+
+  // Set up the analyzer - we use the standard one,
+  // but this could be an experiment-specific one as well.
+  // The Analyzer controls the reading of the data, executes
+  // tests/cuts, loops over Acpparatus's and PhysicsModules,
+  // and executes the output routines.
+  THcAnalyzer* analyzer = new THcAnalyzer;
+
+  // A simple event class to be output to the resulting tree.
+  // Creating your own descendant of THaEvent is one way of
+  // defining and controlling the output.
+  THaEvent* event = new THaEvent;
+
+  // Define the run(s) that we want to analyze.
+  // We just set up one, but this could be many.
+  char RunFileName[100];
+  sprintf(RunFileName, RunFileNamePattern, RunNumber);
+  THaRun* run = new THaRun(RunFileName);
+
+  // Set to read in Hall C run database parameters
+  run->SetRunParamClass("THcRunParameters");
+  
+  // Eventually need to learn to skip over, or properly analyze
+  // the pedestal events
+  run->SetEventRange(1, MaxEvent);    // Physics Event number, does not
+                                      // include scaler or control events.
+  run->SetNscan(1);
+  run->SetDataRequired(0x7);
+  run->Print();
+
+  // Define the analysis parameters
+  TString ROOTFileName = Form(ROOTFileNamePattern, RunNumber, MaxEvent);
+  analyzer->SetCountMode(2);    // 0 = counter is # of physics triggers
+                                // 1 = counter is # of all decode reads
+                                // 2 = counter is event number
+  analyzer->SetEvent(event);
+  // Set EPICS event type
+  analyzer->SetEpicsEvtType(180);
+  // Define crate map
+  analyzer->SetCrateMapFileName("MAPS/db_cratemap.dat");
+  // Define output ROOT file
+  analyzer->SetOutFile(ROOTFileName.Data());
+  // Define DEF-file
+//  analyzer->SetOdefFile("DEF-files/SHMS/PRODUCTION/pstackana_production.def");
+  analyzer->SetOdefFile("DEF-files/SHMS/PRODUCTION/DC/pdc_histos.def");
+  analyzer->SetCutFile("DEF-files/SHMS/PRODUCTION/pstackana_production_cuts.def");  // optional
+  // File to record accounting information for cuts
+  analyzer->SetSummaryFile(Form("REPORT_OUTPUT/SHMS/PRODUCTION/summary_production_%d_%d.report", RunNumber, MaxEvent));  // optional
+  // Start the actual analysis.
+  analyzer->Process(run);
+  // Create report file from template
+  analyzer->PrintReport("TEMPLATES/SHMS/PRODUCTION/pstackana_production.template",
+  			Form("REPORT_OUTPUT/SHMS/PRODUCTION/replay_shms_production_%d_%d.report", RunNumber, MaxEvent));  // optional
+
+}
diff --git a/DEF-files/SHMS/PRODUCTION/pstackana_gem.def b/DEF-files/SHMS/PRODUCTION/pstackana_gem.def
new file mode 100644
index 0000000000000000000000000000000000000000..dd2585209db272bb8b704007686b35f8ed1c2038
--- /dev/null
+++ b/DEF-files/SHMS/PRODUCTION/pstackana_gem.def
@@ -0,0 +1,2 @@
+block P.gem.*
+#include "DEF-files/SHMS/PRODUCTION/pstackana_production.def"
diff --git a/MAPS/HMS/DETEC/AERO/haero_htrig.map b/MAPS/HMS/DETEC/AERO/haero_htrig.map
index 1fcbbf6f896f570f809ce86f28815700dbc122f3..6dfd846ac2bf8ff85c555ff0fe03157f6e1edc24 100644
--- a/MAPS/HMS/DETEC/AERO/haero_htrig.map
+++ b/MAPS/HMS/DETEC/AERO/haero_htrig.map
@@ -25,6 +25,7 @@ REFINDEX=0
    4,   2,   5,   1  ! h1T
    5,   2,   6,   1  ! h2T
    6,1000,   0,   0  ! hTref
+   6,   2,   7,   1  ! hT1
    7,   2,   8,   1  ! hASUM
    8,   2,   9,   1  ! hBSUM
    9,   2,  10,   1  ! hCSUM
diff --git a/MAPS/HMS/DETEC/CAL/hcal_htrig.map b/MAPS/HMS/DETEC/CAL/hcal_htrig.map
index 7d42faa27de0159d8d1fe18004671673fe5f065a..3285b65e814aaa7c3accd4e064bbf3e36dcc1a11 100644
--- a/MAPS/HMS/DETEC/CAL/hcal_htrig.map
+++ b/MAPS/HMS/DETEC/CAL/hcal_htrig.map
@@ -25,6 +25,7 @@ REFINDEX=0
    4,   2,   5,   1  ! h1T
    5,   2,   6,   1  ! h2T
    6,1000,   0,   0  ! hTref
+   6,   2,   7,   1  ! hT1
    7,   2,   8,   1  ! hASUM
    8,   2,   9,   1  ! hBSUM
    9,   2,  10,   1  ! hCSUM
diff --git a/MAPS/HMS/DETEC/CER/hcer_htrig.map b/MAPS/HMS/DETEC/CER/hcer_htrig.map
index f1282cf3c8efffd21aa62a7cd952530a67d4d9f5..efe69dc5bb0155bce4cf2a6f08f6fd764f13b9cc 100644
--- a/MAPS/HMS/DETEC/CER/hcer_htrig.map
+++ b/MAPS/HMS/DETEC/CER/hcer_htrig.map
@@ -25,6 +25,7 @@ REFINDEX=0
    4,   2,   5,   1  ! h1T
    5,   2,   6,   1  ! h2T
    6,1000,   0,   0  ! hTref
+   6,   2,   7,   1  ! hT1
    7,   2,   8,   1  ! hASUM
    8,   2,   9,   1  ! hBSUM
    9,   2,  10,   1  ! hCSUM
diff --git a/MAPS/HMS/DETEC/DC/hdc_6gev_htrig.map b/MAPS/HMS/DETEC/DC/hdc_6gev_htrig.map
index 262db594c1275ea961c158fefb282fdf01912d4c..30f4fb7eb63a559b63c10c2c8ea41c7bb4078f47 100644
--- a/MAPS/HMS/DETEC/DC/hdc_6gev_htrig.map
+++ b/MAPS/HMS/DETEC/DC/hdc_6gev_htrig.map
@@ -25,6 +25,7 @@ REFINDEX=0
    4,   2,   5,   1  ! h1T
    5,   2,   6,   1  ! h2T
    6,1000,   0,   0  ! hTref
+   6,   2,   7,   1  ! hT1
    7,   2,   8,   1  ! hASUM
    8,   2,   9,   1  ! hBSUM
    9,   2,  10,   1  ! hCSUM
diff --git a/MAPS/HMS/DETEC/HODO/hhodo_htrig.map b/MAPS/HMS/DETEC/HODO/hhodo_htrig.map
index 4c89e16d911c6e0f22f8d27337f2274b5b55c303..8a58ec0a966846667fb6c6df143ccc48334bc1d8 100644
--- a/MAPS/HMS/DETEC/HODO/hhodo_htrig.map
+++ b/MAPS/HMS/DETEC/HODO/hhodo_htrig.map
@@ -25,6 +25,7 @@ REFINDEX=0
    4,   2,   5,   1  ! h1T
    5,   2,   6,   1  ! h2T
    6,1000,   0,   0  ! hTref
+   6,   2,   7,   1  ! hT1
    7,   2,   8,   1  ! hASUM
    8,   2,   9,   1  ! hBSUM
    9,   2,  10,   1  ! hCSUM
diff --git a/MAPS/HMS/DETEC/STACK/hms_stack.map b/MAPS/HMS/DETEC/STACK/hms_stack.map
index 7931481834d23cc26fe4dad82645b5121957d6b2..5d0de882c0e13fbf6b64b9d308d607902431bcb0 100644
--- a/MAPS/HMS/DETEC/STACK/hms_stack.map
+++ b/MAPS/HMS/DETEC/STACK/hms_stack.map
@@ -30,6 +30,7 @@ REFINDEX=0
    4,   2,   5,   1  ! h1T
    5,   2,   6,   1  ! h2T
    6,1000,   0,   0  ! hTref
+   6,   2,   7,   1  ! hT1
    7,   2,   8,   1  ! hASUM
    8,   2,   9,   1  ! hBSUM
    9,   2,  10,   1  ! hCSUM
diff --git a/MAPS/HMS/DETEC/TRIG/htrig.map b/MAPS/HMS/DETEC/TRIG/htrig.map
index 1bdacb08469c6cb2df9a77deb725f4899b39931b..e1c98e2bfebb367f94b7ec307278931402e69e98 100644
--- a/MAPS/HMS/DETEC/TRIG/htrig.map
+++ b/MAPS/HMS/DETEC/TRIG/htrig.map
@@ -32,6 +32,7 @@ REFINDEX=0
      4,       2,      5,     1!  h1T
      5,       2,      6,     1!  h2T
      6,    1000,      0,     0!  hTref
+     6,       2,      7,     1!  hT1
      7,       2,      8,     1!  hASUM
      8,       2,      9,     1!  hBSUM
      9,       2,     10,     1!  hCSUM
diff --git a/MAPS/SHMS/DETEC/AERO/paero_ptrig.map b/MAPS/SHMS/DETEC/AERO/paero_ptrig.map
index f9d29dc2f74d6213026ed172edf20c47a57aba4f..7cb7ff6788911184a59f952549f0db125ebc3946 100644
--- a/MAPS/SHMS/DETEC/AERO/paero_ptrig.map
+++ b/MAPS/SHMS/DETEC/AERO/paero_ptrig.map
@@ -18,61 +18,62 @@ SLOT=20
 SLOT=19
 REFINDEX=0
   31,1000,   0,   0  ! pTRef
-  32,   2,   2,   1  ! p1X
-  33,   2,   3,   1  ! p1Y
-  34,   2,   4,   1  ! p2X
-  35,   2,   5,   1  ! p2Y
-  36,   2,   6,   1  ! p1T
-  37,   2,   7,   1  ! p2T
-  38,   2,   8,   1  ! pT2
-  39,   2,   9,   1  ! pAERSUM
-  40,   2,  10,   1  ! pHGCERSUM
-  41,   2,  11,   1  ! pNGCERSUM
-  42,   2,  22,   1  ! pHODO_EDTM
-  48,   2,  23,   1  ! pTRIG1
-  49,   2,  24,   1  ! pTRIG2
-  50,   2,  25,   1  ! pTRIG3
-  51,   2,  26,   1  ! pTRIG4
-  52,   2,  27,   1  ! pTRIG5
-  53,   2,  28,   1  ! pTRIG6
-  58,   2,  29,   1  ! hTRIG1
-  59,   2,  30,   1  ! hTRIG2
-  60,   2,  31,   1  ! hTRIG3
-  61,   2,  32,   1  ! hTRIG4
-  62,   2,  33,   1  ! hTRIG5
-  63,   2,  34,   1  ! hTRIG6
+  31,   2,   2,   1  ! pT2
+  32,   2,   3,   1  ! p1X
+  33,   2,   4,   1  ! p1Y
+  34,   2,   5,   1  ! p2X
+  35,   2,   6,   1  ! p2Y
+  36,   2,   7,   1  ! p1T
+  37,   2,   8,   1  ! p2T
+  38,   2,   9,   1  ! pT3
+  39,   2,  10,   1  ! pAERSUM
+  40,   2,  11,   1  ! pHGCERSUM
+  41,   2,  12,   1  ! pNGCERSUM
+  42,   2,  23,   1  ! pHODO_EDTM
+  48,   2,  24,   1  ! pTRIG1
+  49,   2,  25,   1  ! pTRIG2
+  50,   2,  26,   1  ! pTRIG3
+  51,   2,  27,   1  ! pTRIG4
+  52,   2,  28,   1  ! pTRIG5
+  53,   2,  29,   1  ! pTRIG6
+  58,   2,  30,   1  ! hTRIG1
+  59,   2,  31,   1  ! hTRIG2
+  60,   2,  32,   1  ! hTRIG3
+  61,   2,  33,   1  ! hTRIG4
+  62,   2,  34,   1  ! hTRIG5
+  63,   2,  35,   1  ! hTRIG6
 
 ROC=6
 
 SLOT=6
-  79,   2,  12,   1  ! pDCREF1
+  79,   2,  13,   1  ! pDCREF1
 
 SLOT=7
-  79,   2,  13,   1  ! pDCREF2
+  79,   2,  14,   1  ! pDCREF2
 
 SLOT=8
-  79,   2,  14,   1  ! pDCREF3
+  79,   2,  15,   1  ! pDCREF3
 
 SLOT=9
-  79,   2,  15,   1  ! pDCREF4
+  79,   2,  16,   1  ! pDCREF4
 
 SLOT=10
-  79,   2,  16,   1  ! pDCREF5
+  79,   2,  17,   1  ! pDCREF5
 
 SLOT=11
-  47,   2,  17,   1  ! pDCREF6
+  47,   2,  18,   1  ! pDCREF6
 
 SLOT=12
-  47,   2,  18,   1  ! pDCREF7
+  47,   2,  19,   1  ! pDCREF7
 
 SLOT=13
-  47,   2,  19,   1  ! pDCREF8
+  47,   2,  20,   1  ! pDCREF8
 
 SLOT=14
-  15,   2,  20,   1  ! pDCREF9
+  15,   2,  21,   1  ! pDCREF9
 
 SLOT=15
-  47,   2,  21,   1  ! pDCREF10
+  47,   2,  22,   1  ! pDCREF10
 
 
 DETECTOR=25
diff --git a/MAPS/SHMS/DETEC/CAL/pcal_ptrig.map b/MAPS/SHMS/DETEC/CAL/pcal_ptrig.map
index cd37e77d0b0f1277ae4e0c347786f6d056b0b19f..fda6ef50b83f52fc4b0ea4bba196d60ef204a74e 100644
--- a/MAPS/SHMS/DETEC/CAL/pcal_ptrig.map
+++ b/MAPS/SHMS/DETEC/CAL/pcal_ptrig.map
@@ -18,61 +18,62 @@ SLOT=20
 SLOT=19
 REFINDEX=0
   31,1000,   0,   0  ! pTRef
-  32,   2,   2,   1  ! p1X
-  33,   2,   3,   1  ! p1Y
-  34,   2,   4,   1  ! p2X
-  35,   2,   5,   1  ! p2Y
-  36,   2,   6,   1  ! p1T
-  37,   2,   7,   1  ! p2T
-  38,   2,   8,   1  ! pT2
-  39,   2,   9,   1  ! pAERSUM
-  40,   2,  10,   1  ! pHGCERSUM
-  41,   2,  11,   1  ! pNGCERSUM
-  42,   2,  22,   1  ! pHODO_EDTM
-  48,   2,  23,   1  ! pTRIG1
-  49,   2,  24,   1  ! pTRIG2
-  50,   2,  25,   1  ! pTRIG3
-  51,   2,  26,   1  ! pTRIG4
-  52,   2,  27,   1  ! pTRIG5
-  53,   2,  28,   1  ! pTRIG6
-  58,   2,  29,   1  ! hTRIG1
-  59,   2,  30,   1  ! hTRIG2
-  60,   2,  31,   1  ! hTRIG3
-  61,   2,  32,   1  ! hTRIG4
-  62,   2,  33,   1  ! hTRIG5
-  63,   2,  34,   1  ! hTRIG6
+  31,   2,   2,   1  ! pT2
+  32,   2,   3,   1  ! p1X
+  33,   2,   4,   1  ! p1Y
+  34,   2,   5,   1  ! p2X
+  35,   2,   6,   1  ! p2Y
+  36,   2,   7,   1  ! p1T
+  37,   2,   8,   1  ! p2T
+  38,   2,   9,   1  ! pT3
+  39,   2,  10,   1  ! pAERSUM
+  40,   2,  11,   1  ! pHGCERSUM
+  41,   2,  12,   1  ! pNGCERSUM
+  42,   2,  23,   1  ! pHODO_EDTM
+  48,   2,  24,   1  ! pTRIG1
+  49,   2,  25,   1  ! pTRIG2
+  50,   2,  26,   1  ! pTRIG3
+  51,   2,  27,   1  ! pTRIG4
+  52,   2,  28,   1  ! pTRIG5
+  53,   2,  29,   1  ! pTRIG6
+  58,   2,  30,   1  ! hTRIG1
+  59,   2,  31,   1  ! hTRIG2
+  60,   2,  32,   1  ! hTRIG3
+  61,   2,  33,   1  ! hTRIG4
+  62,   2,  34,   1  ! hTRIG5
+  63,   2,  35,   1  ! hTRIG6
 
 ROC=6
 
 SLOT=6
-  79,   2,  12,   1  ! pDCREF1
+  79,   2,  13,   1  ! pDCREF1
 
 SLOT=7
-  79,   2,  13,   1  ! pDCREF2
+  79,   2,  14,   1  ! pDCREF2
 
 SLOT=8
-  79,   2,  14,   1  ! pDCREF3
+  79,   2,  15,   1  ! pDCREF3
 
 SLOT=9
-  79,   2,  15,   1  ! pDCREF4
+  79,   2,  16,   1  ! pDCREF4
 
 SLOT=10
-  79,   2,  16,   1  ! pDCREF5
+  79,   2,  17,   1  ! pDCREF5
 
 SLOT=11
-  47,   2,  17,   1  ! pDCREF6
+  47,   2,  18,   1  ! pDCREF6
 
 SLOT=12
-  47,   2,  18,   1  ! pDCREF7
+  47,   2,  19,   1  ! pDCREF7
 
 SLOT=13
-  47,   2,  19,   1  ! pDCREF8
+  47,   2,  20,   1  ! pDCREF8
 
 SLOT=14
-  15,   2,  20,   1  ! pDCREF9
+  15,   2,  21,   1  ! pDCREF9
 
 SLOT=15
-  47,   2,  21,   1  ! pDCREF10
+  47,   2,  22,   1  ! pDCREF10
 
 
 DETECTOR=26
diff --git a/MAPS/SHMS/DETEC/DC/pdc_ptrig.map b/MAPS/SHMS/DETEC/DC/pdc_ptrig.map
index 8a3bc626d0b01ac24482207d091f74c55f5429aa..7df55695119806368c90cd62255ecdd258b9eb50 100644
--- a/MAPS/SHMS/DETEC/DC/pdc_ptrig.map
+++ b/MAPS/SHMS/DETEC/DC/pdc_ptrig.map
@@ -18,61 +18,62 @@ SLOT=20
 SLOT=19
 REFINDEX=0
   31,1000,   0,   0  ! pTRef
-  32,   2,   2,   1  ! p1X
-  33,   2,   3,   1  ! p1Y
-  34,   2,   4,   1  ! p2X
-  35,   2,   5,   1  ! p2Y
-  36,   2,   6,   1  ! p1T
-  37,   2,   7,   1  ! p2T
-  38,   2,   8,   1  ! pT2
-  39,   2,   9,   1  ! pAERSUM
-  40,   2,  10,   1  ! pHGCERSUM
-  41,   2,  11,   1  ! pNGCERSUM
-  42,   2,  22,   1  ! pHODO_EDTM
-  48,   2,  23,   1  ! pTRIG1
-  49,   2,  24,   1  ! pTRIG2
-  50,   2,  25,   1  ! pTRIG3
-  51,   2,  26,   1  ! pTRIG4
-  52,   2,  27,   1  ! pTRIG5
-  53,   2,  28,   1  ! pTRIG6
-  58,   2,  29,   1  ! hTRIG1
-  59,   2,  30,   1  ! hTRIG2
-  60,   2,  31,   1  ! hTRIG3
-  61,   2,  32,   1  ! hTRIG4
-  62,   2,  33,   1  ! hTRIG5
-  63,   2,  34,   1  ! hTRIG6
+  31,   2,   2,   1  ! pT2
+  32,   2,   3,   1  ! p1X
+  33,   2,   4,   1  ! p1Y
+  34,   2,   5,   1  ! p2X
+  35,   2,   6,   1  ! p2Y
+  36,   2,   7,   1  ! p1T
+  37,   2,   8,   1  ! p2T
+  38,   2,   9,   1  ! pT3
+  39,   2,  10,   1  ! pAERSUM
+  40,   2,  11,   1  ! pHGCERSUM
+  41,   2,  12,   1  ! pNGCERSUM
+  42,   2,  23,   1  ! pHODO_EDTM
+  48,   2,  24,   1  ! pTRIG1
+  49,   2,  25,   1  ! pTRIG2
+  50,   2,  26,   1  ! pTRIG3
+  51,   2,  27,   1  ! pTRIG4
+  52,   2,  28,   1  ! pTRIG5
+  53,   2,  29,   1  ! pTRIG6
+  58,   2,  30,   1  ! hTRIG1
+  59,   2,  31,   1  ! hTRIG2
+  60,   2,  32,   1  ! hTRIG3
+  61,   2,  33,   1  ! hTRIG4
+  62,   2,  34,   1  ! hTRIG5
+  63,   2,  35,   1  ! hTRIG6
 
 ROC=6
 
 SLOT=6
-  79,   2,  12,   1  ! pDCREF1
+  79,   2,  13,   1  ! pDCREF1
 
 SLOT=7
-  79,   2,  13,   1  ! pDCREF2
+  79,   2,  14,   1  ! pDCREF2
 
 SLOT=8
-  79,   2,  14,   1  ! pDCREF3
+  79,   2,  15,   1  ! pDCREF3
 
 SLOT=9
-  79,   2,  15,   1  ! pDCREF4
+  79,   2,  16,   1  ! pDCREF4
 
 SLOT=10
-  79,   2,  16,   1  ! pDCREF5
+  79,   2,  17,   1  ! pDCREF5
 
 SLOT=11
-  47,   2,  17,   1  ! pDCREF6
+  47,   2,  18,   1  ! pDCREF6
 
 SLOT=12
-  47,   2,  18,   1  ! pDCREF7
+  47,   2,  19,   1  ! pDCREF7
 
 SLOT=13
-  47,   2,  19,   1  ! pDCREF8
+  47,   2,  20,   1  ! pDCREF8
 
 SLOT=14
-  15,   2,  20,   1  ! pDCREF9
+  15,   2,  21,   1  ! pDCREF9
 
 SLOT=15
-  47,   2,  21,   1  ! pDCREF10
+  47,   2,  22,   1  ! pDCREF10
 
 
 DETECTOR=22  ! SHMS chambers
diff --git a/MAPS/SHMS/DETEC/HGCER/phgcer_ptrig.map b/MAPS/SHMS/DETEC/HGCER/phgcer_ptrig.map
index 64b2ce54c5f0c8a2f395723567a660c36bb1b5b9..5657fdea6df151d5122a5b961e698244bfb58077 100644
--- a/MAPS/SHMS/DETEC/HGCER/phgcer_ptrig.map
+++ b/MAPS/SHMS/DETEC/HGCER/phgcer_ptrig.map
@@ -18,61 +18,62 @@ SLOT=20
 SLOT=19
 REFINDEX=0
   31,1000,   0,   0  ! pTRef
-  32,   2,   2,   1  ! p1X
-  33,   2,   3,   1  ! p1Y
-  34,   2,   4,   1  ! p2X
-  35,   2,   5,   1  ! p2Y
-  36,   2,   6,   1  ! p1T
-  37,   2,   7,   1  ! p2T
-  38,   2,   8,   1  ! pT2
-  39,   2,   9,   1  ! pAERSUM
-  40,   2,  10,   1  ! pHGCERSUM
-  41,   2,  11,   1  ! pNGCERSUM
-  42,   2,  22,   1  ! pHODO_EDTM
-  48,   2,  23,   1  ! pTRIG1
-  49,   2,  24,   1  ! pTRIG2
-  50,   2,  25,   1  ! pTRIG3
-  51,   2,  26,   1  ! pTRIG4
-  52,   2,  27,   1  ! pTRIG5
-  53,   2,  28,   1  ! pTRIG6
-  58,   2,  29,   1  ! hTRIG1
-  59,   2,  30,   1  ! hTRIG2
-  60,   2,  31,   1  ! hTRIG3
-  61,   2,  32,   1  ! hTRIG4
-  62,   2,  33,   1  ! hTRIG5
-  63,   2,  34,   1  ! hTRIG6
+  31,   2,   2,   1  ! pT2
+  32,   2,   3,   1  ! p1X
+  33,   2,   4,   1  ! p1Y
+  34,   2,   5,   1  ! p2X
+  35,   2,   6,   1  ! p2Y
+  36,   2,   7,   1  ! p1T
+  37,   2,   8,   1  ! p2T
+  38,   2,   9,   1  ! pT3
+  39,   2,  10,   1  ! pAERSUM
+  40,   2,  11,   1  ! pHGCERSUM
+  41,   2,  12,   1  ! pNGCERSUM
+  42,   2,  23,   1  ! pHODO_EDTM
+  48,   2,  24,   1  ! pTRIG1
+  49,   2,  25,   1  ! pTRIG2
+  50,   2,  26,   1  ! pTRIG3
+  51,   2,  27,   1  ! pTRIG4
+  52,   2,  28,   1  ! pTRIG5
+  53,   2,  29,   1  ! pTRIG6
+  58,   2,  30,   1  ! hTRIG1
+  59,   2,  31,   1  ! hTRIG2
+  60,   2,  32,   1  ! hTRIG3
+  61,   2,  33,   1  ! hTRIG4
+  62,   2,  34,   1  ! hTRIG5
+  63,   2,  35,   1  ! hTRIG6
 
 ROC=6
 
 SLOT=6
-  79,   2,  12,   1  ! pDCREF1
+  79,   2,  13,   1  ! pDCREF1
 
 SLOT=7
-  79,   2,  13,   1  ! pDCREF2
+  79,   2,  14,   1  ! pDCREF2
 
 SLOT=8
-  79,   2,  14,   1  ! pDCREF3
+  79,   2,  15,   1  ! pDCREF3
 
 SLOT=9
-  79,   2,  15,   1  ! pDCREF4
+  79,   2,  16,   1  ! pDCREF4
 
 SLOT=10
-  79,   2,  16,   1  ! pDCREF5
+  79,   2,  17,   1  ! pDCREF5
 
 SLOT=11
-  47,   2,  17,   1  ! pDCREF6
+  47,   2,  18,   1  ! pDCREF6
 
 SLOT=12
-  47,   2,  18,   1  ! pDCREF7
+  47,   2,  19,   1  ! pDCREF7
 
 SLOT=13
-  47,   2,  19,   1  ! pDCREF8
+  47,   2,  20,   1  ! pDCREF8
 
 SLOT=14
-  15,   2,  20,   1  ! pDCREF9
+  15,   2,  21,   1  ! pDCREF9
 
 SLOT=15
-  47,   2,  21,   1  ! pDCREF10
+  47,   2,  22,   1  ! pDCREF10
 
 
 DETECTOR=24
diff --git a/MAPS/SHMS/DETEC/HODO/phodo_ptrig.map b/MAPS/SHMS/DETEC/HODO/phodo_ptrig.map
index 641a408db53e8d0af152bdade3cab878a738419b..1a07fec9b967a5fcd784ef09d44a01a64df4af82 100644
--- a/MAPS/SHMS/DETEC/HODO/phodo_ptrig.map
+++ b/MAPS/SHMS/DETEC/HODO/phodo_ptrig.map
@@ -18,61 +18,62 @@ SLOT=20
 SLOT=19
 REFINDEX=0
   31,1000,   0,   0  ! pTRef
-  32,   2,   2,   1  ! p1X
-  33,   2,   3,   1  ! p1Y
-  34,   2,   4,   1  ! p2X
-  35,   2,   5,   1  ! p2Y
-  36,   2,   6,   1  ! p1T
-  37,   2,   7,   1  ! p2T
-  38,   2,   8,   1  ! pT2
-  39,   2,   9,   1  ! pAERSUM
-  40,   2,  10,   1  ! pHGCERSUM
-  41,   2,  11,   1  ! pNGCERSUM
-  42,   2,  22,   1  ! pHODO_EDTM
-  48,   2,  23,   1  ! pTRIG1
-  49,   2,  24,   1  ! pTRIG2
-  50,   2,  25,   1  ! pTRIG3
-  51,   2,  26,   1  ! pTRIG4
-  52,   2,  27,   1  ! pTRIG5
-  53,   2,  28,   1  ! pTRIG6
-  58,   2,  29,   1  ! hTRIG1
-  59,   2,  30,   1  ! hTRIG2
-  60,   2,  31,   1  ! hTRIG3
-  61,   2,  32,   1  ! hTRIG4
-  62,   2,  33,   1  ! hTRIG5
-  63,   2,  34,   1  ! hTRIG6
+  31,   2,   2,   1  ! pT2
+  32,   2,   3,   1  ! p1X
+  33,   2,   4,   1  ! p1Y
+  34,   2,   5,   1  ! p2X
+  35,   2,   6,   1  ! p2Y
+  36,   2,   7,   1  ! p1T
+  37,   2,   8,   1  ! p2T
+  38,   2,   9,   1  ! pT3
+  39,   2,  10,   1  ! pAERSUM
+  40,   2,  11,   1  ! pHGCERSUM
+  41,   2,  12,   1  ! pNGCERSUM
+  42,   2,  23,   1  ! pHODO_EDTM
+  48,   2,  24,   1  ! pTRIG1
+  49,   2,  25,   1  ! pTRIG2
+  50,   2,  26,   1  ! pTRIG3
+  51,   2,  27,   1  ! pTRIG4
+  52,   2,  28,   1  ! pTRIG5
+  53,   2,  29,   1  ! pTRIG6
+  58,   2,  30,   1  ! hTRIG1
+  59,   2,  31,   1  ! hTRIG2
+  60,   2,  32,   1  ! hTRIG3
+  61,   2,  33,   1  ! hTRIG4
+  62,   2,  34,   1  ! hTRIG5
+  63,   2,  35,   1  ! hTRIG6
 
 ROC=6
 
 SLOT=6
-  79,   2,  12,   1  ! pDCREF1
+  79,   2,  13,   1  ! pDCREF1
 
 SLOT=7
-  79,   2,  13,   1  ! pDCREF2
+  79,   2,  14,   1  ! pDCREF2
 
 SLOT=8
-  79,   2,  14,   1  ! pDCREF3
+  79,   2,  15,   1  ! pDCREF3
 
 SLOT=9
-  79,   2,  15,   1  ! pDCREF4
+  79,   2,  16,   1  ! pDCREF4
 
 SLOT=10
-  79,   2,  16,   1  ! pDCREF5
+  79,   2,  17,   1  ! pDCREF5
 
 SLOT=11
-  47,   2,  17,   1  ! pDCREF6
+  47,   2,  18,   1  ! pDCREF6
 
 SLOT=12
-  47,   2,  18,   1  ! pDCREF7
+  47,   2,  19,   1  ! pDCREF7
 
 SLOT=13
-  47,   2,  19,   1  ! pDCREF8
+  47,   2,  20,   1  ! pDCREF8
 
 SLOT=14
-  15,   2,  20,   1  ! pDCREF9
+  15,   2,  21,   1  ! pDCREF9
 
 SLOT=15
-  47,   2,  21,   1  ! pDCREF10
+  47,   2,  22,   1  ! pDCREF10
 
 
 DETECTOR=23
diff --git a/MAPS/SHMS/DETEC/NGCER/pngcer_ptrig.map b/MAPS/SHMS/DETEC/NGCER/pngcer_ptrig.map
index 6500875ecedc0af71b8bf5287ccdd5d8b82757e9..8d7b3fbdf7a083e4c5796e349c5cfa0808e730d3 100644
--- a/MAPS/SHMS/DETEC/NGCER/pngcer_ptrig.map
+++ b/MAPS/SHMS/DETEC/NGCER/pngcer_ptrig.map
@@ -18,61 +18,62 @@ SLOT=20
 SLOT=19
 REFINDEX=0
   31,1000,   0,   0  ! pTRef
-  32,   2,   2,   1  ! p1X
-  33,   2,   3,   1  ! p1Y
-  34,   2,   4,   1  ! p2X
-  35,   2,   5,   1  ! p2Y
-  36,   2,   6,   1  ! p1T
-  37,   2,   7,   1  ! p2T
-  38,   2,   8,   1  ! pT2
-  39,   2,   9,   1  ! pAERSUM
-  40,   2,  10,   1  ! pHGCERSUM
-  41,   2,  11,   1  ! pNGCERSUM
-  42,   2,  22,   1  ! pHODO_EDTM
-  48,   2,  23,   1  ! pTRIG1
-  49,   2,  24,   1  ! pTRIG2
-  50,   2,  25,   1  ! pTRIG3
-  51,   2,  26,   1  ! pTRIG4
-  52,   2,  27,   1  ! pTRIG5
-  53,   2,  28,   1  ! pTRIG6
-  58,   2,  29,   1  ! hTRIG1
-  59,   2,  30,   1  ! hTRIG2
-  60,   2,  31,   1  ! hTRIG3
-  61,   2,  32,   1  ! hTRIG4
-  62,   2,  33,   1  ! hTRIG5
-  63,   2,  34,   1  ! hTRIG6
+  31,   2,   2,   1  ! pT2
+  32,   2,   3,   1  ! p1X
+  33,   2,   4,   1  ! p1Y
+  34,   2,   5,   1  ! p2X
+  35,   2,   6,   1  ! p2Y
+  36,   2,   7,   1  ! p1T
+  37,   2,   8,   1  ! p2T
+  38,   2,   9,   1  ! pT3
+  39,   2,  10,   1  ! pAERSUM
+  40,   2,  11,   1  ! pHGCERSUM
+  41,   2,  12,   1  ! pNGCERSUM
+  42,   2,  23,   1  ! pHODO_EDTM
+  48,   2,  24,   1  ! pTRIG1
+  49,   2,  25,   1  ! pTRIG2
+  50,   2,  26,   1  ! pTRIG3
+  51,   2,  27,   1  ! pTRIG4
+  52,   2,  28,   1  ! pTRIG5
+  53,   2,  29,   1  ! pTRIG6
+  58,   2,  30,   1  ! hTRIG1
+  59,   2,  31,   1  ! hTRIG2
+  60,   2,  32,   1  ! hTRIG3
+  61,   2,  33,   1  ! hTRIG4
+  62,   2,  34,   1  ! hTRIG5
+  63,   2,  35,   1  ! hTRIG6
 
 ROC=6
 
 SLOT=6
-  79,   2,  12,   1  ! pDCREF1
+  79,   2,  13,   1  ! pDCREF1
 
 SLOT=7
-  79,   2,  13,   1  ! pDCREF2
+  79,   2,  14,   1  ! pDCREF2
 
 SLOT=8
-  79,   2,  14,   1  ! pDCREF3
+  79,   2,  15,   1  ! pDCREF3
 
 SLOT=9
-  79,   2,  15,   1  ! pDCREF4
+  79,   2,  16,   1  ! pDCREF4
 
 SLOT=10
-  79,   2,  16,   1  ! pDCREF5
+  79,   2,  17,   1  ! pDCREF5
 
 SLOT=11
-  47,   2,  17,   1  ! pDCREF6
+  47,   2,  18,   1  ! pDCREF6
 
 SLOT=12
-  47,   2,  18,   1  ! pDCREF7
+  47,   2,  19,   1  ! pDCREF7
 
 SLOT=13
-  47,   2,  19,   1  ! pDCREF8
+  47,   2,  20,   1  ! pDCREF8
 
 SLOT=14
-  15,   2,  20,   1  ! pDCREF9
+  15,   2,  21,   1  ! pDCREF9
 
 SLOT=15
-  47,   2,  21,   1  ! pDCREF10
+  47,   2,  22,   1  ! pDCREF10
 
 
 DETECTOR=21
diff --git a/MAPS/SHMS/DETEC/STACK/shms_stack.map b/MAPS/SHMS/DETEC/STACK/shms_stack.map
index 7ce4b4ac29c1d916448cbfb904bd920e38c189cf..ca4fe0472d795f28880d3e80856ecceb6a6b0cbf 100644
--- a/MAPS/SHMS/DETEC/STACK/shms_stack.map
+++ b/MAPS/SHMS/DETEC/STACK/shms_stack.map
@@ -24,61 +24,62 @@ SLOT=20
 SLOT=19
 REFINDEX=0
   31,1000,   0,   0  ! pTRef
-  32,   2,   2,   1  ! p1X
-  33,   2,   3,   1  ! p1Y
-  34,   2,   4,   1  ! p2X
-  35,   2,   5,   1  ! p2Y
-  36,   2,   6,   1  ! p1T
-  37,   2,   7,   1  ! p2T
-  38,   2,   8,   1  ! pT2
-  39,   2,   9,   1  ! pAERSUM
-  40,   2,  10,   1  ! pHGCERSUM
-  41,   2,  11,   1  ! pNGCERSUM
-  42,   2,  22,   1  ! pHODO_EDTM
-  48,   2,  23,   1  ! pTRIG1
-  49,   2,  24,   1  ! pTRIG2
-  50,   2,  25,   1  ! pTRIG3
-  51,   2,  26,   1  ! pTRIG4
-  52,   2,  27,   1  ! pTRIG5
-  53,   2,  28,   1  ! pTRIG6
-  58,   2,  29,   1  ! hTRIG1
-  59,   2,  30,   1  ! hTRIG2
-  60,   2,  31,   1  ! hTRIG3
-  61,   2,  32,   1  ! hTRIG4
-  62,   2,  33,   1  ! hTRIG5
-  63,   2,  34,   1  ! hTRIG6
+  31,   2,   2,   1  ! pT2
+  32,   2,   3,   1  ! p1X
+  33,   2,   4,   1  ! p1Y
+  34,   2,   5,   1  ! p2X
+  35,   2,   6,   1  ! p2Y
+  36,   2,   7,   1  ! p1T
+  37,   2,   8,   1  ! p2T
+  38,   2,   9,   1  ! pT3
+  39,   2,  10,   1  ! pAERSUM
+  40,   2,  11,   1  ! pHGCERSUM
+  41,   2,  12,   1  ! pNGCERSUM
+  42,   2,  23,   1  ! pHODO_EDTM
+  48,   2,  24,   1  ! pTRIG1
+  49,   2,  25,   1  ! pTRIG2
+  50,   2,  26,   1  ! pTRIG3
+  51,   2,  27,   1  ! pTRIG4
+  52,   2,  28,   1  ! pTRIG5
+  53,   2,  29,   1  ! pTRIG6
+  58,   2,  30,   1  ! hTRIG1
+  59,   2,  31,   1  ! hTRIG2
+  60,   2,  32,   1  ! hTRIG3
+  61,   2,  33,   1  ! hTRIG4
+  62,   2,  34,   1  ! hTRIG5
+  63,   2,  35,   1  ! hTRIG6
 
 ROC=6
 
 SLOT=6
-  79,   2,  12,   1  ! pDCREF1
+  79,   2,  13,   1  ! pDCREF1
 
 SLOT=7
-  79,   2,  13,   1  ! pDCREF2
+  79,   2,  14,   1  ! pDCREF2
 
 SLOT=8
-  79,   2,  14,   1  ! pDCREF3
+  79,   2,  15,   1  ! pDCREF3
 
 SLOT=9
-  79,   2,  15,   1  ! pDCREF4
+  79,   2,  16,   1  ! pDCREF4
 
 SLOT=10
-  79,   2,  16,   1  ! pDCREF5
+  79,   2,  17,   1  ! pDCREF5
 
 SLOT=11
-  47,   2,  17,   1  ! pDCREF6
+  47,   2,  18,   1  ! pDCREF6
 
 SLOT=12
-  47,   2,  18,   1  ! pDCREF7
+  47,   2,  19,   1  ! pDCREF7
 
 SLOT=13
-  47,   2,  19,   1  ! pDCREF8
+  47,   2,  20,   1  ! pDCREF8
 
 SLOT=14
-  15,   2,  20,   1  ! pDCREF9
+  15,   2,  21,   1  ! pDCREF9
 
 SLOT=15
-  47,   2,  21,   1  ! pDCREF10
+  47,   2,  22,   1  ! pDCREF10
 
 
 DETECTOR=21
diff --git a/MAPS/SHMS/DETEC/TRIG/ptrig.map b/MAPS/SHMS/DETEC/TRIG/ptrig.map
index 35ccb62c0c967b9968985b32f644c3132fbff0d3..b09ebb52ff79be94c823f6f05dc851e21821de3a 100644
--- a/MAPS/SHMS/DETEC/TRIG/ptrig.map
+++ b/MAPS/SHMS/DETEC/TRIG/ptrig.map
@@ -17,58 +17,59 @@ SLOT=20
 SLOT=19
 REFINDEX=0
   31,   1000,      0,   0  ! pTRef
-  32,      2,  	   2,   1  ! p1X
-  33,      2,      3,   1  ! p1Y
-  34,      2,      4,   1  ! p2X
-  35,      2,      5,   1  ! p2Y
-  36,      2,      6,   1  ! p1T
-  37,      2,      7,   1  ! p2T
-  38,      2,      8,   1  ! pT2
-  39,      2,      9,   1  ! pAERSUM
-  40,      2,     10,   1  ! pHGCERSUM
-  41,      2,     11,   1  ! pNGCERSUM
-  42,      2,     22,   1  ! pHODO_EDTM
-  48,      2,     23,   1  ! pTRIG1
-  49,      2,     24,   1  ! pTRIG2
-  50,      2,     25,   1  ! pTRIG3
-  51,      2,     26,   1  ! pTRIG4
-  52,      2,     27,   1  ! pTRIG5
-  53,      2,     28,   1  ! pTRIG6
-  58,      2,     29,   1  ! hTRIG1
-  59,      2,     30,   1  ! hTRIG2
-  60,      2,     31,   1  ! hTRIG3
-  61,      2,     32,   1  ! hTRIG4
-  62,      2,     33,   1  ! hTRIG5
-  63,      2,     34,   1  ! hTRIG6
+  31,      2,      2,   1  ! pT2
+  32,      2,  	   3,   1  ! p1X
+  33,      2,      4,   1  ! p1Y
+  34,      2,      5,   1  ! p2X
+  35,      2,      6,   1  ! p2Y
+  36,      2,      7,   1  ! p1T
+  37,      2,      8,   1  ! p2T
+  38,      2,      9,   1  ! pT3
+  39,      2,     10,   1  ! pAERSUM
+  40,      2,     11,   1  ! pHGCERSUM
+  41,      2,     12,   1  ! pNGCERSUM
+  42,      2,     23,   1  ! pHODO_EDTM
+  48,      2,     24,   1  ! pTRIG1
+  49,      2,     25,   1  ! pTRIG2
+  50,      2,     26,   1  ! pTRIG3
+  51,      2,     27,   1  ! pTRIG4
+  52,      2,     28,   1  ! pTRIG5
+  53,      2,     29,   1  ! pTRIG6
+  58,      2,     30,   1  ! hTRIG1
+  59,      2,     31,   1  ! hTRIG2
+  60,      2,     32,   1  ! hTRIG3
+  61,      2,     33,   1  ! hTRIG4
+  62,      2,     34,   1  ! hTRIG5
+  63,      2,     35,   1  ! hTRIG6
 
 ROC=6
 
 SLOT=6
-  79,      2,     12,   1  ! pDCREF1
+  79,      2,     13,   1  ! pDCREF1
 
 SLOT=7
-  79,      2,     13,   1  ! pDCREF2
+  79,      2,     14,   1  ! pDCREF2
 
 SLOT=8
-  79,      2,     14,   1  ! pDCREF3
+  79,      2,     15,   1  ! pDCREF3
 
 SLOT=9
-  79,      2,     15,   1  ! pDCREF4
+  79,      2,     16,   1  ! pDCREF4
 
 SLOT=10
-  79,      2,     16,   1  ! pDCREF5
+  79,      2,     17,   1  ! pDCREF5
 
 SLOT=11
-  47,      2,     17,   1  ! pDCREF6
+  47,      2,     18,   1  ! pDCREF6
 
 SLOT=12
-  47,      2,     18,   1  ! pDCREF7
+  47,      2,     19,   1  ! pDCREF7
 
 SLOT=13
-  47,      2,     19,   1  ! pDCREF8
+  47,      2,     20,   1  ! pDCREF8
 
 SLOT=14
-  15,      2,     20,   1  ! pDCREF9
+  15,      2,     21,   1  ! pDCREF9
 
 SLOT=15
-  47,      2,     21,   1  ! pDCREF10
+  47,      2,     22,   1  ! pDCREF10
diff --git a/PARAM/SHMS/DC/GEOM/pdc_geom.param b/PARAM/SHMS/DC/GEOM/pdc_geom.param
index 77f96caffab40610cec3e082ec6c46cb37f07285..b76ef2992a609814e75d337571d384210ba3b879 100644
--- a/PARAM/SHMS/DC/GEOM/pdc_geom.param
+++ b/PARAM/SHMS/DC/GEOM/pdc_geom.param
@@ -10,7 +10,7 @@ pdc_num_chambers = 2
 pdc_num_planes = 12
 
 ; Names of planes.
-pdc_plane_names = "1u1 1u2 1x1 1x2 1v1 1v2 2v2 2v1 2x2 2x1 2u2 2u1"  ; TODO
+pdc_plane_names = "1u1 1u2 1x1 1x2 1v1 1v2 2v2 2v1 2x2 2x1 2u2 2u1";
 
 ; Chamber index for each plane.
 pdc_chamber_planes = 1, 1, 1, 1, 1, 1
@@ -26,29 +26,33 @@ pdc_sigma = 0.02, 0.02, 0.02, 0.02, 0.02, 0.02  ; TODO - SOS values for now
             0.02, 0.02, 0.02, 0.02, 0.02, 0.02
 
 ; Wire velocity corrections.
-pdc_wire_velocity  = 13.0  ; TODO
+pdc_wire_velocity  = 12.0;
 pdc_central_time   = 0, 0, 0, 0, 0, 0  ; TODO - no correction for now
                      0, 0, 0, 0, 0, 0
 pdc_drifttime_sign = 0, 0, 0, 0, 0, 0  ; TODO - no correction for now
                      0, 0, 0, 0, 0, 0
+;pdc_readoutLR = -1.0, 1.0, -1.0, -1.0, 1.0, -1.0
+;                 1.0, -1.0, 1.0, 1.0, -1.0, 1.0
+;pdc_readoutTB = 1.0, -1.0, 1.0, -1.0, 1.0, -1.0
+;                -1.0, 1.0, -1.0, 1.0, -1.0, 1.0             
 
 ; CHAMBER POSITION PARAMETERS
 
 ; x, y and z position of center for each wire chamber in cm.
 ; From survey C1771.
-pdc_xcenter = -0.036, 0.008  ; TODO - final survey
-pdc_ycenter =  0.019, 0.013  ; TODO - final survey
-pdc_1_zpos = -40 - 0.656  ; TODO - final survey
-pdc_2_zpos =  40 - 0.668  ; TODO - final survey
+pdc_xcenter = -0.036, 0.008 ;
+pdc_ycenter =  0.019, 0.013 ;
+pdc_1_zpos = -40 - 0.656 ;
+pdc_2_zpos =  40 - 0.668 ;
 
 ; Roll, pitch and yaw for each wire chamber in degrees.
 ; From survey C1771.
-pdc_1_roll = 180.0  ; TODO - survey
-pdc_2_roll = 180.0  ; TODO - survey
-pdc_1_pitch = -0.006  ; TODO - final survey
-pdc_2_pitch =  0.001  ; TODO - final survey
-pdc_1_yaw = -0.006  ; TODO - final survey
-pdc_2_yaw = -0.035  ; TODO - final survey
+pdc_1_roll = 180.0 ;
+pdc_2_roll = 180.0 ; 
+pdc_1_pitch = -0.006 ; 
+pdc_2_pitch =  0.001 ; 
+pdc_1_yaw = -0.006 ; 
+pdc_2_yaw = -0.035 ; 
 
 
 ; PLANE POSITION PARAMETERS
@@ -67,6 +71,35 @@ pdc_pitch = 1.0, 1.0, 1.0, 1.0, 1.0, 1.0
 pdc_wire_counting = 0, 0, 0, 0, 0, 0
                     0, 0, 0, 0, 0, 0
 
+; x position in cm defaults to global
+pdc_xpos = pdc_xcenter[0]-0.0045
+           pdc_xcenter[0]-0.028
+           pdc_xcenter[0]+0.0105
+           pdc_xcenter[0]+0.0085
+           pdc_xcenter[0]-0.007
+           pdc_xcenter[0]-0.035
+           pdc_xcenter[1]-0.036
+           pdc_xcenter[1]+0.036
+           pdc_xcenter[1]+0.0015
+           pdc_xcenter[1]-0.0025
+           pdc_xcenter[1]-0.0045
+           pdc_xcenter[1]+0.012
+           
+; y position in cm defaults to global
+pdc_ypos = pdc_ycenter[0]-0.007
+           pdc_ycenter[0]-0.0205
+           pdc_ycenter[0]
+           pdc_ycenter[0]
+           pdc_ycenter[0]+0.0045
+           pdc_ycenter[0]+0.022
+           pdc_ycenter[1]-0.019
+           pdc_ycenter[1]+0.0245
+           pdc_ycenter[1]
+           pdc_ycenter[1]
+           pdc_ycenter[1]+0.0035
+           pdc_ycenter[1]-0.006
+
+
 ; z position in cm of each plane measured from focal plane.
 ; From technical drawings.
 pdc_zpos = pdc_1_zpos - 0.68701*cminch
diff --git a/PARAM/TRIG/thms.param b/PARAM/TRIG/thms.param
index 8cd13ea246603cd7c1c254e8e7b13279a707a785..3d986888b84959e1049ab822e3b2654a76b695ee 100644
--- a/PARAM/TRIG/thms.param
+++ b/PARAM/TRIG/thms.param
@@ -1,10 +1,10 @@
-t_hms_numAdc = 12
+t_hms_numAdc = 8
 t_hms_numTdc = 33
 t_hms_tdcoffset=-300.
 t_hms_tdcchanperns=0.1
 
-; bar num:        1     2     3     4     5      6     7       8       9     10    11    12
-t_hms_adcNames = "hASUM hBSUM hCSUM hDSUM hPSHWR hSHWR hAERSUM hCERSUM hFRXA hFRYA hFRXB hFRYB"
+; bar num:          1     2     3     4     5      6      7       8
+t_hms_adcNames = "hASUM hBSUM hCSUM hDSUM hPSHWR hSHWR hAERSUM hCERSUM"
 
 ; bar num:         1   2   3   4   5   6   7    8     9     10    11     12       13      14      15       16    17    18      19      20      21      22     23     24     25     26     27     28     29     30     31     32     33
 t_hms_tdcNames = "h1X h1Y h2X h2Y h1T h2T hT1 hASUM hBSUM hCSUM hDSUM hPSHWRLO hPSHWRHI hSHWR hHODO_EDTM hCERSUM hT2 hDCREF1 hDCREF2 hDCREF3 hDCREF4 hTRIG1 hTRIG2 hTRIG3 hTRIG4 hTRIG5 hTRIG6 pTRIG1 pTRIG2 pTRIG3 pTRIG4 pTRIG5 pTRIG6"
\ No newline at end of file
diff --git a/PARAM/TRIG/tshms.param b/PARAM/TRIG/tshms.param
index ac7c688a524c2c48e7473260d6245d875d8954b1..8a3b1f66a4eebf77a439eb73916acfd75d148810 100644
--- a/PARAM/TRIG/tshms.param
+++ b/PARAM/TRIG/tshms.param
@@ -1,5 +1,5 @@
 t_shms_numAdc = 4
-t_shms_numTdc = 34
+t_shms_numTdc = 35
 
 t_shms_tdcoffset = -300.
 t_shms_tdcchanperns = 0.1
@@ -7,5 +7,5 @@ t_shms_tdcchanperns = 0.1
 ; bar num:            1       2       3           4
 t_shms_adcNames = "pAERSUM pHGCSUM pNGCSUM pFADC_TREF_ROC2"
 
-; BAR NUM:          1   2   3   4   5   6   7   8     9     10      11      12      13     14      15      16      17      18      19      20      21       22        23       24     25     26     27     28     29     30     31     32     33     34
-t_shms_tdcNames = "pT1 p1X p1Y p2X p2Y p1T p2T pT2 pAERSUM pHGCSUM pNGCSUM pDCREF1 pDCREF2 pDCREF3 pDCREF4 pDCREF5 pDCREF6 pDCREF7 pDCREF8 pDCREF9 pDCREF10 pHODO_EDTM pTRIG1 pTRIG2 pTRIG3 pTRIG4 pTRIG5 pTRIG6 hTRIG1 hTRIG2 hTRIG3 hTRIG4 hTRIG5 hTRIG6"
+; BAR NUM:          1   2   3   4   5   6   7   8   9     10      11      12      13     14      15      16      17      18      19      20      21       22        23       24     25     26     27     28     29     30     31     32     33     34     35
+t_shms_tdcNames = "pT1 pT2 p1X p1Y p2X p2Y p1T p2T pT3 pAERSUM pHGCSUM pNGCSUM pDCREF1 pDCREF2 pDCREF3 pDCREF4 pDCREF5 pDCREF6 pDCREF7 pDCREF8 pDCREF9 pDCREF10 pHODO_EDTM pTRIG1 pTRIG2 pTRIG3 pTRIG4 pTRIG5 pTRIG6 hTRIG1 hTRIG2 hTRIG3 hTRIG4 hTRIG5 hTRIG6"
diff --git a/SCRIPTS/SHMS/GEM/gem_hcana.cfg b/SCRIPTS/SHMS/GEM/gem_hcana.cfg
new file mode 100644
index 0000000000000000000000000000000000000000..439addad68411cfc1cca72caf8f9e888ccb98b96
--- /dev/null
+++ b/SCRIPTS/SHMS/GEM/gem_hcana.cfg
@@ -0,0 +1,97 @@
+#GEM analysis configure file
+
+#===============================================================
+# DAQ setting
+#===============================================================
+TIMESAMPLE: 21
+
+
+#===============================================================
+# runType
+#===============================================================
+RUNTYPE: PHYSICS
+#RUNTYPE: PEDESTAL
+#RUNTYPE: RAWDATA
+
+
+#===============================================================
+# path to the mapping file to be loaded
+#===============================================================
+MAPPING: ../hcana_gem/config/mapping.cfg
+
+
+#===============================================================
+# path to save pedestal root file
+#===============================================================
+SAVEPED: ../hcana_gem/pedestal/pedestal.root
+
+
+#===============================================================
+# path to load pedestal root file
+#===============================================================
+LOADPED: ../hcana_gem/pedestal/pedestal.root
+#LOADPED: ./pedestal/pedestal_20160617_owl_run1401.root
+
+
+#===============================================================
+# number of events to be analyzed, 
+# affect both pedestal run and physics run
+#===============================================================
+NEVENTPED: -1
+
+
+#===============================================================
+# Physics cut
+#===============================================================
+#---------------------------
+#scintillator timing cut
+UseScinTDC: 1
+UseHyCalPosMatch: 0
+UseHycalTimingCut: 1
+#TDCChannel: S1
+#TDCChannel: S2
+#TDCChannel: S1andS2
+TDCChannel: S1orS2
+TDCValueStart: 7700
+TDCValueEnd: 7800
+//2
+#TDCValueStart: 7600
+#TDCValueEnd: 7800
+//1
+#TDCValueStart: 7000
+#TDCValueEnd: 8000
+
+#----------------------------
+#HyCal Cut
+#Energy Cut
+HycalEnergy: 200
+
+#HyCalTDCGroupQuantity: 1
+#HyCalTDCGroup: W25
+HyCalTDCGroupQuantity: 4
+HyCalTDCGroup: W33, W34, W27, W28
+#HyCalTDCGroup: W35, W25, W22, G11 # format: use comma
+#timing , need to have TDC group channels,
+UseHycalTimingCut: 1
+#HyCalTimingCutStart: 7200
+#HyCalTimingCutEnd: 7500
+
+#W302 TDC Group W12
+HyCalTimingCutStart: 7000
+HyCalTimingCutEnd: 7500
+
+# results directory
+PHYSRESULTS: root_file/result.root
+
+
+#===============================================================
+# Input File
+#===============================================================
+NFILE: 1
+# this line for multiple files
+#INPUTFILE: /home/xbai/w/R/hallcgem/test_135_xin_comsmic.evio, 1, 1
+
+# this line fine single file
+#INPUTFILE: /home/daq/data/test_135_xin_comsmic.dat
+# INPUTFILE: /home/saw/ROOT/data/GEM/shms_all_00899.dat
+INPUTFILE: /home/siplu/GIT/JLAB/HcAna/hallc_replay/raw/shms_all_00899.dat
diff --git a/SCRIPTS/SHMS/GEM/replay_gem_shms.C b/SCRIPTS/SHMS/GEM/replay_gem_shms.C
new file mode 100644
index 0000000000000000000000000000000000000000..4fff3d22efb445c764b626a5df71f483f8fe6349
--- /dev/null
+++ b/SCRIPTS/SHMS/GEM/replay_gem_shms.C
@@ -0,0 +1,162 @@
+R__LOAD_LIBRARY(libGEM.so);
+
+void replay_gem_shms (Int_t RunNumber = 0, Int_t MaxEvent = 0) {
+
+  // Get RunNumber and MaxEvent if not provided.
+  if(RunNumber == 0) {
+    cout << "Enter a Run Number (-1 to exit): ";
+    cin >> RunNumber;
+    if( RunNumber<=0 ) return;
+  }
+  if(MaxEvent == 0) {
+    cout << "\nNumber of Events to analyze: ";
+    cin >> MaxEvent;
+    if(MaxEvent == 0) {
+      cerr << "...Invalid entry\n";
+      exit;
+    }
+  }
+
+  // Create file name patterns.
+  const char* RunFileNamePattern = "shms_all_%05d.dat";
+  vector<TString> pathList;
+    pathList.push_back(".");
+    pathList.push_back("./raw");
+    pathList.push_back("./cache");
+
+  const char* ROOTFileNamePattern = "ROOTfiles/shms_replay_gem_%d_%d.root";
+  
+  // Load global parameters
+  // Add variables to global list.
+  gHcParms->Define("gen_run_number", "Run Number", RunNumber);
+  gHcParms->AddString("g_ctp_database_filename", "DBASE/SHMS/STD/standard.database");
+  // Load varibles from files to global list.
+  gHcParms->Load(gHcParms->GetString("g_ctp_database_filename"), RunNumber);
+  // g_ctp_parm_filename and g_decode_map_filename should now be defined.
+  gHcParms->Load(gHcParms->GetString("g_ctp_kinematics_filename"), RunNumber);
+  gHcParms->Load(gHcParms->GetString("g_ctp_parm_filename"));
+  gHcParms->Load(gHcParms->GetString("g_ctp_calib_filename"));
+  // Load params for SHMS trigger configuration
+  gHcParms->Load("PARAM/TRIG/tshms.param");
+
+  // Load the Hall C detector map
+  gHcDetectorMap = new THcDetectorMap();
+  gHcDetectorMap->Load("MAPS/SHMS/DETEC/STACK/shms_stack.map");
+
+  // Add trigger apparatus
+  THaApparatus* TRG = new THcTrigApp("T", "TRG");
+  gHaApps->Add(TRG);
+
+  
+  // Add trigger detector to trigger apparatus
+  THcTrigDet* shms = new THcTrigDet("shms", "SHMS Trigger Information");
+  TRG->AddDetector(shms);
+
+  // Set up the equipment to be analyzed.
+  THaApparatus* SHMS = new THcHallCSpectrometer("P", "SHMS");
+  gHaApps->Add(SHMS);
+  // Add Noble Gas Cherenkov to SHMS apparatus
+  THcCherenkov* ngcer = new THcCherenkov("ngcer", "Noble Gas Cherenkov");
+  SHMS->AddDetector(ngcer);
+  // Add drift chambers to SHMS apparatus
+  THcDC* dc = new THcDC("dc", "Drift Chambers");
+  SHMS->AddDetector(dc);
+  // Add hodoscope to SHMS apparatus
+  THcHodoscope* hod = new THcHodoscope("hod", "Hodoscope");
+  SHMS->AddDetector(hod);
+  // Add Heavy Gas Cherenkov to SHMS apparatus
+  THcCherenkov* hgcer = new THcCherenkov("hgcer", "Heavy Gas Cherenkov");
+  SHMS->AddDetector(hgcer);
+
+  // Add Aerogel Cherenkov to SHMS apparatus
+  THcAerogel* aero = new THcAerogel("aero", "Aerogel");
+  SHMS->AddDetector(aero);
+  // Add calorimeter to SHMS apparatus
+  THcShower* cal = new THcShower("cal", "Calorimeter");
+  SHMS->AddDetector(cal);
+  // Add GEM to SHMS apparatus
+  // Add handler for GEM data
+  THcGEM* gem = new THcGEM("gem","GEM data");
+  //  gem->SetEvtType(1);
+  gem->SetConfigFile("SCRIPTS/SHMS/GEM/gem_hcana.cfg");
+  SHMS->AddDetector(gem);
+
+
+  // Include golden track information
+  THaGoldenTrack* gtr = new THaGoldenTrack("P.gtr", "SHMS Golden Track", "P");
+  gHaPhysics->Add(gtr);
+  // Add Rastered Beam Apparatus
+  THaApparatus* beam = new THcRasteredBeam("P.rb", "Rastered Beamline");
+  gHaApps->Add(beam);
+  // Add Physics Module to calculate primary (scattered beam - usually electrons) kinematics
+  THcPrimaryKine* kin = new THcPrimaryKine("P.kin", "SHMS Single Arm Kinematics", "P", "P.rb");
+  gHaPhysics->Add(kin);
+
+   
+
+  // Add event handler for prestart event 125.
+  THcConfigEvtHandler* ev125 = new THcConfigEvtHandler("HC", "Config Event type 125");
+  gHaEvtHandlers->Add(ev125);
+  // Add event handler for EPICS events
+  THaEpicsEvtHandler* hcepics = new THaEpicsEvtHandler("epics", "HC EPICS event type 180");
+  gHaEvtHandlers->Add(hcepics);
+  // Add event handler for scaler events
+  THcScalerEvtHandler* pscaler = new THcScalerEvtHandler("P", "Hall C scaler event type 1");
+  pscaler->AddEvtType(1);
+  pscaler->SetUseFirstEvent(kTRUE);
+  gHaEvtHandlers->Add(pscaler);
+
+  // Set up the analyzer - we use the standard one,
+  // but this could be an experiment-specific one as well.
+  // The Analyzer controls the reading of the data, executes
+  // tests/cuts, loops over Acpparatus's and PhysicsModules,
+  // and executes the output routines.
+  THcAnalyzer* analyzer = new THcAnalyzer;
+
+  // A simple event class to be output to the resulting tree.
+  // Creating your own descendant of THaEvent is one way of
+  // defining and controlling the output.
+  THaEvent* event = new THaEvent;
+
+  // Define the run(s) that we want to analyze.
+  // We just set up one, but this could be many.
+  char RunFileName[100];
+  sprintf(RunFileName, RunFileNamePattern, RunNumber);
+  THaRun* run = new THaRun( pathList, Form(RunFileNamePattern, RunNumber) );
+
+  // Set to read in Hall C run database parameters
+  run->SetRunParamClass("THcRunParameters");
+  
+  // Eventually need to learn to skip over, or properly analyze
+  // the pedestal events
+  run->SetEventRange(1, MaxEvent);    // Physics Event number, does not
+                                      // include scaler or control events.
+  run->SetNscan(1);
+  run->SetDataRequired(0x7);
+  run->Print();
+
+  // Define the analysis parameters
+  TString ROOTFileName = Form(ROOTFileNamePattern, RunNumber, MaxEvent);
+  analyzer->SetCountMode(2);    // 0 = counter is # of physics triggers
+                                // 1 = counter is # of all decode reads
+                                // 2 = counter is event number
+  analyzer->SetEvent(event);
+  // Set EPICS event type
+  analyzer->SetEpicsEvtType(180);
+  // Define crate map
+  analyzer->SetCrateMapFileName("MAPS/db_cratemap.dat");
+  // Define output ROOT file
+  analyzer->SetOutFile(ROOTFileName.Data());
+  // Define DEF-file
+  analyzer->SetOdefFile("DEF-files/SHMS/PRODUCTION/pstackana_gem.def");
+  // Define cuts file
+  analyzer->SetCutFile("DEF-files/SHMS/PRODUCTION/pstackana_production_cuts.def");  // optional
+  // File to record accounting information for cuts
+  analyzer->SetSummaryFile(Form("REPORT_OUTPUT/SHMS/GEM/summary_gem_%d_%d.report", RunNumber, MaxEvent));  // optional
+  // Start the actual analysis.
+  analyzer->Process(run);
+  // Create report file from template
+  analyzer->PrintReport("TEMPLATES/SHMS/PRODUCTION/pstackana_production.template",
+  			Form("REPORT_OUTPUT/SHMS/GEM/replay_shms_gem_%d_%d.report", RunNumber, MaxEvent));  // optional
+
+}