From 4eb6c8ce49e23203630295201e7f999af666997e Mon Sep 17 00:00:00 2001
From: Vardan Tadevosyan <tadevosn@jlab.org>
Date: Thu, 18 Sep 2014 11:46:31 -0400
Subject: [PATCH] Add access to the golden track proper in THaGolden Track
 class. Access the energy of the golden track from THaGoldenTrack.

    Include THaTrack.h in THaGoldenTrack.h.
    Add GetEnergy method in THaGoldenTrack.h.
    Define variable name "e" for the energy of golden track in THaGoldenTrack.C.
---
 examples/compgoldenenorm.C | 65 ++++++++++++++++++++++++++++++++++++++
 examples/hodtest_mkj.C     |  3 ++
 examples/output_52949.def  | 13 +++++---
 src/SConscript.py          |  2 +-
 4 files changed, 78 insertions(+), 5 deletions(-)
 create mode 100644 examples/compgoldenenorm.C

diff --git a/examples/compgoldenenorm.C b/examples/compgoldenenorm.C
new file mode 100644
index 0000000..5cc16b6
--- /dev/null
+++ b/examples/compgoldenenorm.C
@@ -0,0 +1,65 @@
+void compgoldenenorm(Int_t run=52949)
+{
+
+  //Comapare hsshtrk from Engine with gold.enorm from hcana.
+
+  TFile* f = new TFile(Form("hodtest_%d.root",run));
+  cout << "hcana root file " << Form("hodtest_%d.root",run) << endl;
+  TH1F* h = golden_enorm;
+
+  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 = h438;   //hsshtrk, engine/replay/paw
+    h1 = h426;   //hsshtrk, engine/replay_mkj/paw
+  }
+
+  TCanvas *c1 = new TCanvas("c1", "Golden track E/P", 800, 1000);
+
+  c1->Divide(1,2);
+
+  //  gPad->SetLogy();
+
+  c1->cd(1);
+
+  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.75*(xmax-xmin);
+
+  l.SetTextColor(kGreen);
+  l.DrawLatex(xt,0.65*maxy,"Engine");
+  l.SetTextColor(kBlue);
+  l.DrawLatex(xt,0.75*maxy,"hcana");
+    
+  // Difference between the histograms.
+
+  c1->cd(2);
+
+  TH1F* dif = h->Clone();
+
+  dif->Add(h,h1,1.,-1.);
+
+  dif->SetTitle("Enorm Difference");
+  dif->SetFillColor(kRed);
+  dif->SetLineColor(kRed);
+  dif->SetLineWidth(1);
+  dif->SetFillStyle(1111);
+  dif->Draw();
+} 
diff --git a/examples/hodtest_mkj.C b/examples/hodtest_mkj.C
index f091dbf..eac9af9 100644
--- a/examples/hodtest_mkj.C
+++ b/examples/hodtest_mkj.C
@@ -45,6 +45,9 @@ void hodtest_mkj(Int_t RunNumber=50017, Int_t MaxEventToReplay=5000) {
   THcAerogel* aerogel = new THcAerogel("aero", "Aerogel Cerenkov" );
   HMS->AddDetector( aerogel );
 
+  // Add Golden Track
+  gHaPhysics->Add( new THaGoldenTrack( "H.gold", "HMS Golden Track", "H" ));
+
   // 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
diff --git a/examples/output_52949.def b/examples/output_52949.def
index d4c4a66..c58c9a6 100644
--- a/examples/output_52949.def
+++ b/examples/output_52949.def
@@ -1,10 +1,11 @@
 # See $ANALYZER/examples/output_example.def for examples
 #
-block H.dc.*
-block H.hod.*
+#block H.dc.*
+#block H.hod.*
 block H.cal.*
-block H.aero.*
+#block H.aero.*
 block H.tr.*
+block H.gold.*
 block g.evtyp
 
 # TDC spectra
@@ -211,4 +212,8 @@ TH1F dtime_hdc2u1 'HDC 2U1 Drift Time' H.dc.2u1.time 200 -100 300
 TH1F dtime_hdc2v1 'HDC 2V1 Drift Time' H.dc.2v1.time 200 -100 300
 TH1F dtime_hdc2y2 'HDC 2Y2 Drift Time' H.dc.2y2.time 200 -100 300
 TH1F dtime_hdc2x2 'HDC 2X2 Drift Time' H.dc.2x2.time 200 -100 300
-
+#
+# Golden Track momentum
+TH1F golden_p 'HMS Golden P' H.gold.p 100 0.011 1.8 H.dc.ntrack!=0
+TH1F golden_e 'HMS Golden E' H.gold.e 100 0.011 1.8 H.dc.ntrack!=0
+TH1F golden_enorm 'HMS Golden E/P' H.gold.e/H.gold.p 100 0.01 1.8 H.gold.index>=0
diff --git a/src/SConscript.py b/src/SConscript.py
index cbd967e..8792ee3 100644
--- a/src/SConscript.py
+++ b/src/SConscript.py
@@ -13,7 +13,7 @@ THcDetectorMap.cxx \
 THcRawHit.cxx THcHitList.cxx \
 THcSignalHit.cxx \
 THcHodoscope.cxx THcScintillatorPlane.cxx \
-THcHodoscopeHit.cxx \
+THcRawHodoHit.cxx \
 THcDC.cxx THcDriftChamberPlane.cxx \
 THcDriftChamber.cxx \
 THcRawDCHit.cxx THcDCHit.cxx \
-- 
GitLab