From cf4b23b25035b7863716364e4026156ad75c7d20 Mon Sep 17 00:00:00 2001
From: Zafar <ahmed24z@uregina.ca>
Date: Thu, 21 Aug 2014 13:02:54 -0600
Subject: [PATCH] Golden track:

Goldent track is moved to THcHallCSpectrometer::TrackCalc()
  if  fSelUsingScin == 0 then golden track is calculated just
  like podd. i.e. it is the first track with minimum chi2/ndf
  with sorting ON

  if fSelUsingScin == 1 then golden track is calculetd just like
  engine/HTRACKING/h_select_best_track_using_scin.h. This method
  gives the best track with minimum value of chi2/ndf but with
  additional cuts on the tracks. These cuts are on dedx, beta
  and on energy.

  This commit also corrects and modifies the beta code written
  in the THcHodoscope::FineProcess

  At this point we have godlend track and in additoion to
  previous vlues the following values are set to a track:
  Energy, beta, chi2 of beta and dedx[track][first hit].

NOTE: For some tracks we have large differences in value of chi
      square between ENGINE and hcana and this is already
      discussed in the last group meeting. Following emails are
      exchanged regarding this difference of chisquare.

email to Mark:

Hi Mark,
I tried to trace the origin of difference of the chi square value between
ENGINE and hcana. Please see the attached file, it has long table which I
cannot present in this email. Or you can see the file at the following
link, thanks.

https://userweb.jlab.org/~zahmed/chi2diff.txt

Ahmed

Mark's reply:
Ahmed,
        Thanks. I agree with what you see, but there is also another reason
for the difference. For the space point in ch2 the engine and hcana
choose different left/right combinations. That is why you see the large
jump in the summed chi2 from planes 9 and 10. The two codes pick
different left/right because there is a cut on the difference between the
measured stub xp and an expected xp = sp->GetX()/875  and one code has a combination
slightly below the cut value and the other slightly above. I do not see a way
to make the codes agree more exactly since the stub fitting involves a matrix
inversion.

                Cheers,
                       Mark
---
 src/THcHallCSpectrometer.cxx | 6 +++---
 src/THcHodoscope.cxx         | 1 -
 src/THcScintillatorPlane.cxx | 9 ---------
 src/THcScintillatorPlane.h   | 4 ----
 src/THcShower.cxx            | 7 +++++++
 src/THcShower.h              | 2 ++
 6 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/src/THcHallCSpectrometer.cxx b/src/THcHallCSpectrometer.cxx
index b70fbb2..48023af 100644
--- a/src/THcHallCSpectrometer.cxx
+++ b/src/THcHallCSpectrometer.cxx
@@ -435,8 +435,8 @@ Int_t THcHallCSpectrometer::TrackCalc()
       for ( itrack = 0; itrack < fNtracks; itrack++ ){
 	
 	THaTrack* goodTrack = static_cast<THaTrack*>( fTracks->At(itrack) );      
-        if (!goodTrack) return -1;
-	
+        if (!goodTrack) return -1;	
+
 	if ( goodTrack->GetNDoF() > fSelNDegreesMin ){
 	  fChi2PerDeg =  goodTrack->GetChi2() / goodTrack->GetNDoF();
 	  
@@ -591,7 +591,7 @@ Int_t THcHallCSpectrometer::TrackCalc()
     
   }
 
-  //  if ( fHodo->GetEvent() == 11351 ){
+  //  if ( fHodo->GetEvent() == 17465 ){
     cout << "hcana_event   " << fHodo->GetEvent()
 	 << "     golden_track   " << fGoodTrack + 1
 	 << "     chimin   " << fChi2Min
diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx
index 2802d1e..e0e3933 100644
--- a/src/THcHodoscope.cxx
+++ b/src/THcHodoscope.cxx
@@ -1065,7 +1065,6 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks )
 	  fPaddle = ((THcSignalHit*)scinPosTDC->At(ihit))->GetPaddleNumber()-1;
 	  fHitPaddle[fGoodTimeIndex] = fPaddle;
 
-	  //	  fGoodRawPad[fRawIndex] = fPlanes[ip]->GetGoodRawPadNum(ihit);
 	  fGoodRawPad[fRawIndex] = fPaddle;
 	  
 	  fXcoord = theTrack->GetX() + theTrack->GetTheta() *
diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx
index a107ba0..e6a8073 100644
--- a/src/THcScintillatorPlane.cxx
+++ b/src/THcScintillatorPlane.cxx
@@ -46,8 +46,6 @@ THcScintillatorPlane::THcScintillatorPlane( const char* name,
   //
   fMaxHits=53;
 
-  fGoodRawPadNum = new Int_t [fMaxHits]; // Ahmed
-
   fpTimes = new Double_t [fMaxHits];
   fScinTime = new Double_t [fMaxHits];
   fScinSigma = new Double_t [fMaxHits];
@@ -76,8 +74,6 @@ THcScintillatorPlane::THcScintillatorPlane( const char* name,
   //
   fMaxHits=53;
 
-  fGoodRawPadNum = new Int_t [fMaxHits];
-
   fpTimes = new Double_t [fMaxHits];
   fScinTime = new Double_t [fMaxHits];
   fScinSigma = new Double_t [fMaxHits];
@@ -101,9 +97,6 @@ THcScintillatorPlane::~THcScintillatorPlane()
   delete fScinSigma;
   delete fScinZpos;
 
-  delete fGoodRawPadNum;
-
-
 }
 
 //______________________________________________________________________________
@@ -336,8 +329,6 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit)
     if (((hit->fTDC_pos >= mintdc) && (hit->fTDC_pos <= maxtdc)) ||
 	((hit->fTDC_neg >= mintdc) && (hit->fTDC_neg <= maxtdc))) {
 
-      fGoodRawPadNum[fNScinHits] = hit->fCounter;
-      
       //TDC positive hit
       THcSignalHit *sighit = (THcSignalHit*) fPosTDCHits->ConstructedAt(nPosTDCHits++);
       sighit->Set(padnum, hit->fTDC_pos);
diff --git a/src/THcScintillatorPlane.h b/src/THcScintillatorPlane.h
index 2ecae14..fce7cd3 100644
--- a/src/THcScintillatorPlane.h
+++ b/src/THcScintillatorPlane.h
@@ -68,12 +68,8 @@ class THcScintillatorPlane : public THaSubDetector {
   TClonesArray* GetPosTDC() { return fPosTDCHits;};  // Ahmed
   TClonesArray* GetNegTDC() { return fNegTDCHits;};  // Ahmed
 
-  Int_t GetGoodRawPadNum(Int_t index) {return fGoodRawPadNum[index];};
-
  protected:
 
-  Int_t *fGoodRawPadNum; // array
-
   TClonesArray* frPosTDCHits;
   TClonesArray* frNegTDCHits;
   TClonesArray* frPosADCHits;
diff --git a/src/THcShower.cxx b/src/THcShower.cxx
index 060d120..b2f328b 100644
--- a/src/THcShower.cxx
+++ b/src/THcShower.cxx
@@ -522,6 +522,8 @@ Int_t THcShower::Decode( const THaEvData& evdata )
   // Get the Hall C style hitlist (fRawHitList) for this event
   Int_t nhits = DecodeToHitList(evdata);
 
+  fEvent = evdata.GetEvNum();
+
   if(gHaCuts->Result("Pedestal_event")) {
     Int_t nexthit = 0;
     for(Int_t ip=0;ip<fNLayers;ip++) {
@@ -1014,6 +1016,11 @@ Int_t THcShower::FineProcess( TClonesArray& tracks )
     Float_t energy = GetShEnergy(theTrack);
     theTrack->SetEnergy(energy);
 
+    // if ( fEvent == 13252 )
+    //   cout << "THcShower: track = " << itrk + 1 
+    // 	   << "   energy = " << energy << endl;
+
+
     if (fdbg_tracks_cal) {
       cout << "THcShower::FineProcess, Track " << itrk << ": "
 	   << "  X = " << theTrack->GetX()
diff --git a/src/THcShower.h b/src/THcShower.h
index 04d351d..01de29c 100644
--- a/src/THcShower.h
+++ b/src/THcShower.h
@@ -118,6 +118,8 @@ public:
 
 protected:
 
+  Int_t fEvent;
+
   Int_t fAnalyzePedestals;   // Flag for pedestal analysis.
 
   Int_t* fShPosPedLimit;     // [fNtotBlocks] ADC limits for pedestal calc.-s.
-- 
GitLab