From eec53d9e7fb4873c36dbffc453edfe373f5173e8 Mon Sep 17 00:00:00 2001
From: Vardan Tadevosyan <tadevosn@jlab.org>
Date: Fri, 1 Jan 2016 09:44:01 +0400
Subject: [PATCH] Add adjustment of fiducial volume limits of Shower counter to
 the fly's eye part.

---
 src/THcShower.cxx      | 13 +++++++++++++
 src/THcShower.h        |  8 ++++----
 src/THcShowerArray.cxx | 31 +++++++++++++++++++++++++++++++
 src/THcShowerArray.h   |  5 +++++
 4 files changed, 53 insertions(+), 4 deletions(-)

diff --git a/src/THcShower.cxx b/src/THcShower.cxx
index 9cfe345..394955a 100644
--- a/src/THcShower.cxx
+++ b/src/THcShower.cxx
@@ -163,6 +163,19 @@ THaAnalysisObject::EStatus THcShower::Init( const TDatime& date )
       return kInitError;
   }
 
+  if(fHasArray) {
+    cout << "THcShower::Init: adjustment of fiducial volume limits to the fly's eye part." << endl;
+    cout << "  Old limits:" << endl;
+    cout << "    Xmin = " << fvXmin << "  Xmax = " << fvXmax << endl;
+    cout << "    Ymin = " << fvYmin << "  Ymax = " << fvYmax << endl;
+    fvXmin = TMath::Max(fvXmin, fArray->fvXmin());
+    fvXmax = TMath::Min(fvXmax, fArray->fvXmax());
+    fvYmin = TMath::Max(fvYmin, fArray->fvYmin());
+    fvYmax = TMath::Min(fvYmax, fArray->fvYmax());
+    cout << "  New limits:" << endl;
+    cout << "    Xmin = " << fvXmin << "  Xmax = " << fvXmax << endl;
+    cout << "    Ymin = " << fvYmin << "  Ymax = " << fvYmax << endl;
+  }
 
   cout << "---------------------------------------------------------------\n";
   cout << "From THcShower::Init: initialized " << GetApparatus()->GetName()
diff --git a/src/THcShower.h b/src/THcShower.h
index a90b3dd..df673cc 100644
--- a/src/THcShower.h
+++ b/src/THcShower.h
@@ -154,8 +154,8 @@ public:
   
   Int_t GetNBlocks(Int_t NLayer) const { return fNBlocks[NLayer];}
 
-  Double_t GetXPos(Int_t NLayer, Int_t NRaw) const {
-    return fXPos[NLayer][NRaw];
+  Double_t GetXPos(Int_t NLayer, Int_t NRow) const {
+    return fXPos[NLayer][NRow];
   }
 
   Double_t GetYPos(Int_t NLayer, Int_t Side) const {
@@ -247,8 +247,8 @@ protected:
   Int_t fNclust;             // Number of clusters
   Int_t fNtracks;            // Number of shower tracks, i.e. number of
                              // cluster-to-track association
-  Double_t fEtot;             // Total energy 
-  Double_t fEtotNorm;             // Total energy divided by spec central momentum 
+  Double_t fEtot;            // Total energy 
+  Double_t fEtotNorm;        // Total energy divided by spec central momentum 
 
   THcShowerClusterList* fClusterList;   // List of hit clusters
 
diff --git a/src/THcShowerArray.cxx b/src/THcShowerArray.cxx
index c64bbd9..0fce28e 100644
--- a/src/THcShowerArray.cxx
+++ b/src/THcShowerArray.cxx
@@ -85,6 +85,9 @@ Int_t THcShowerArray::ReadDatabase( const TDatime& date )
   prefix[1]='\0';
 
   cout << "Parent name: " << GetParent()->GetPrefix() << endl;
+  fNRows=fNColumns=0;
+  fXFront=fYFront=fZFront=0.;
+  fXStep=fYStep=0.;
   fUsingFADC=0;
   fPedSampLow=0;
   fPedSampHigh=9;
@@ -628,3 +631,31 @@ void THcShowerArray::InitializePedestals( )
     fPedCount[i] = 0;
   }
 } 
+
+//------------------------------------------------------------------------------
+
+// Fiducial volume limits.
+
+Double_t THcShowerArray::fvXmin() {
+  THcShower* fParent;
+  fParent = (THcShower*) GetParent();
+  return fXPos[0][0] - fXStep/2 + fParent->fvDelta;
+}
+
+Double_t THcShowerArray::fvYmax() {
+  THcShower* fParent;
+  fParent = (THcShower*) GetParent();
+  return fYPos[0][0] + fYStep/2 - fParent->fvDelta;
+}
+
+Double_t THcShowerArray::fvXmax() {
+  THcShower* fParent;
+  fParent = (THcShower*) GetParent();
+  return fXPos[fNRows-1][fNColumns-1] + fXStep/2 - fParent->fvDelta;
+}
+
+Double_t THcShowerArray::fvYmin() {
+  THcShower* fParent;
+  fParent = (THcShower*) GetParent();
+  return fYPos[fNRows-1][fNColumns-1] - fYStep/2 + fParent->fvDelta;
+}
diff --git a/src/THcShowerArray.h b/src/THcShowerArray.h
index d4eb98a..b6f88f3 100644
--- a/src/THcShowerArray.h
+++ b/src/THcShowerArray.h
@@ -56,6 +56,11 @@ public:
     return 0.0;
   };
 
+  // Fiducial volume limits.
+  Double_t fvXmin(); 
+  Double_t fvYmax();
+  Double_t fvXmax();
+  Double_t fvYmin();
 
 protected:
 
-- 
GitLab