From 7ccc7b8a4987ea9bcd8bc5fbb1b96fd5ea77c17c Mon Sep 17 00:00:00 2001
From: adrien-matta <a.matta@surrey.ac.uk>
Date: Fri, 13 Nov 2020 08:57:17 +0100
Subject: [PATCH] * adding Power threshold to FDC2

---
 NPLib/Detectors/Samurai/TSamuraiFDC2Physics.cxx | 13 +++++++++----
 NPLib/Detectors/Samurai/TSamuraiFDC2Physics.h   |  2 +-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/NPLib/Detectors/Samurai/TSamuraiFDC2Physics.cxx b/NPLib/Detectors/Samurai/TSamuraiFDC2Physics.cxx
index 74bbd25a6..312f203a7 100644
--- a/NPLib/Detectors/Samurai/TSamuraiFDC2Physics.cxx
+++ b/NPLib/Detectors/Samurai/TSamuraiFDC2Physics.cxx
@@ -48,6 +48,7 @@ ClassImp(TSamuraiFDC2Physics)
     ToTThreshold = 180;
     DriftLowThreshold=0.2;
     DriftUpThreshold=9.4;
+    PowerThreshold=14;
   }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -88,9 +89,13 @@ void TSamuraiFDC2Physics::BuildPhysicalEvent(){
   VX0.clear();VX100.clear(),D.clear();
   for(auto it = X.begin();it!=X.end();++it){
     D[it->first]=m_reconstruction.BuildTrack2D(X[it->first],Z[it->first],R[it->first],X0,X100,a,b); 
- /*  std::ofstream f("distance.txt", std::ios::app);
+
+  /* // for Debug, write a file of 
+   { std::ofstream f("distance.txt", std::ios::app);
    f<< D[it->first] << endl;
-   f.close();*/
+   f.close();
+   }
+   */
     // very large a means track perpendicular to the chamber, what happen when there is pile up
     if(abs(a)>1000)
       PileUp++;
@@ -118,7 +123,7 @@ void TSamuraiFDC2Physics::BuildPhysicalEvent(){
       if(it1!=it2 && it1->first.first==it2->first.first){// different plane, same detector
         m_reconstruction.ResolvePlane(it1->second,it1->first.second,it2->second,it2->first.second,P);
         
-        if(P.X()!=-10000 && D[it1->first]<200 && D[it2->first]<200){
+        if(P.X()!=-10000 && D[it1->first]<PowerThreshold&& D[it2->first]<PowerThreshold){
           C[it1->first.first].push_back(P);
           // Mean pos are weighted based on the the sum of distance from track
           // to hit obtained during the minimisation
@@ -136,7 +141,7 @@ void TSamuraiFDC2Physics::BuildPhysicalEvent(){
       if(it1!=it2 && it1->first.first==it2->first.first){// different plane, same detector
         m_reconstruction.ResolvePlane(it1->second,it1->first.second,it2->second,it2->first.second,P);
 
-        if(P.X()!=-10000&& D[it1->first]<200 && D[it2->first]<200)
+        if(P.X()!=-10000&& D[it1->first]<PowerThreshold && D[it2->first]<PowerThreshold)
           C100[it1->first.first].push_back(P);
       }
     }
diff --git a/NPLib/Detectors/Samurai/TSamuraiFDC2Physics.h b/NPLib/Detectors/Samurai/TSamuraiFDC2Physics.h
index 9259270c8..8549b92d2 100644
--- a/NPLib/Detectors/Samurai/TSamuraiFDC2Physics.h
+++ b/NPLib/Detectors/Samurai/TSamuraiFDC2Physics.h
@@ -120,7 +120,7 @@ class TSamuraiFDC2Physics : public TObject, public NPL::VDetector{
     // since the calibration is a sigmoid there quite a few event at the edge 
     double DriftLowThreshold;//! Minimum Drift length to keep the hit 
     double DriftUpThreshold;//! Maximum Drift length to keep the hit
-  
+    double PowerThreshold;//! Maximum P2 minimisation value to keep the track   
     void RemoveNoise();
     // Construct the 2D track and ref position at Z=0 and Z=100 based on X,Z and Radius provided
 
-- 
GitLab