From 38871d9bc76a44bd562647d54ba1fbbf5daa5f8d Mon Sep 17 00:00:00 2001
From: Nikola Dikic <nikola.dikic@cern.ch>
Date: Fri, 1 May 2020 14:35:54 +0200
Subject: [PATCH] Fixing a wrong formula in AFPFastReco

---
 .../python/Run3AFPExampleMonitorAlgorithm.py  | 26 +++++++++++--------
 .../AFP/Run3AFPMonitoring/src/AFPFastReco.cxx |  2 +-
 .../src/AFPSiLayerAlgorithm.cxx               |  9 +++++--
 3 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/python/Run3AFPExampleMonitorAlgorithm.py b/ForwardDetectors/AFP/Run3AFPMonitoring/python/Run3AFPExampleMonitorAlgorithm.py
index 393eaaf95b4d..268db3b67334 100644
--- a/ForwardDetectors/AFP/Run3AFPMonitoring/python/Run3AFPExampleMonitorAlgorithm.py
+++ b/ForwardDetectors/AFP/Run3AFPMonitoring/python/Run3AFPExampleMonitorAlgorithm.py
@@ -14,11 +14,15 @@ def Run3AFPExampleMonitoringConfig(inputFlags):
 
     from AthenaMonitoring import AthMonitorCfgHelper
     helper = AthMonitorCfgHelper(inputFlags,'Run3AFPMonitorCfg')
+    
+    from AthenaConfiguration.ComponentFactory import CompFactory
 
-    from Run3AFPMonitoring.Run3AFPMonitoringConf import AFPSiLayerAlgorithm
+    #from Run3AFPMonitoring.Run3AFPMonitoringConf import AFPSiLayerAlgorithm
+    afpSiLayerAlgorithm = CompFactory.AFPSiLayerAlgorithm
     afpSiLayerAlgorithm = helper.addAlgorithm(AFPSiLayerAlgorithm,'AFPSiLayerAlg')
 
-    from Run3AFPMonitoring.Run3AFPMonitoringConf import AFPToFAlgorithm
+    #from Run3AFPMonitoring.Run3AFPMonitoringConf import AFPToFAlgorithm
+    afpToFAlgorithm = CompFactory.AFPToFAlgorithm
     afpToFAlgorithm = helper.addAlgorithm(AFPToFAlgorithm,'AFPToFAlg')
 
     # Add a generic monitoring tool (a "group" in old language). The returned 
@@ -39,15 +43,15 @@ def Run3AFPExampleMonitoringConfig(inputFlags):
     combinedList = ['farAside', 'nearAside', 'nearCside', 'farCside']
 
     array = helper.addArray([combinedList,layerList], afpSiLayerAlgorithm, 'AFPSiLayerTool', topPath = 'AFP/SiT/')
-    array.defineHistogram('pixelColIDChip', title='1D hitmap for {0} Layer {1}', path='PixelColIDChip', xbins=80, xmin=0.5, xmax=80.5)
-    array.defineHistogram('pixelRowIDChip', title='1D hitmap for {0} Layer {1}', path='PixelRowIDChip', xbins=336, xmin=0.5, xmax=336.5)
-    array.defineHistogram('pixelColIDChip,pixelRowIDChip', title='hitmap for {0} Layer {1}', type='TH2F', path='pixelColRow2D', xbins=80, xmin=0.5, xmax=80.5, ybins=336, ymin=0.5, ymax=336.5)
-    array.defineHistogram('timeOverThreshold', title='1D Time over threshold for {0} Layer {1}', path='SiTimeOverThreshold', xbins=60, xmin=0, xmax=20)
-    array.defineHistogram('clusterX,clusterY', title='Cluster position in station {0} Layer {1}', type='TH2F', path='Cluster', xbins=80, xmin=0.5, xmax=80.5, ybins=336, ymin=0.5, ymax=336.5)
-
-    #tofStations = [ 'Aside', 'Cside' ]
-    arrayToF = helper.addArray([combinedList], afpToFAlgorithm, 'AFPToFTool', topPath='AFP/ToF/')
-    arrayToF.defineHistogram('trainID,barInTrainID', title='ToF hit bar vs train {0};trainID;barInTrainID', type='TH2F', path='HitBarvsTrain/',xbins=4,xmin=-0.5,xmax=3.5,ybins=4,ymin=-0.5,ymax=3.5)
+    array.defineHistogram('pixelColIDChip', title='1D hitmap for {0} Layer {1};pixelColIDChip', path='PixelColIDChip', xbins=80, xmin=0.5, xmax=80.5)
+    array.defineHistogram('pixelRowIDChip', title='1D hitmap for {0} Layer {1};pixelRowIDChip', path='PixelRowIDChip', xbins=336, xmin=0.5, xmax=336.5)
+    array.defineHistogram('pixelColIDChip,pixelRowIDChip', title='hitmap for {0} Layer {1};pixelColIDChip;pixelRowIDChip', type='TH2F', path='pixelColRow2D', xbins=80, xmin=0.5, xmax=80.5, ybins=336, ymin=0.5, ymax=336.5)
+    array.defineHistogram('timeOverThreshold', type='TH1F', title='1D Time over threshold for {0} Layer {1};timeOverThreshold', path='SiTimeOverThreshold', xbins=60, xmin=0, xmax=20)
+    array.defineHistogram('clusterX,clusterY', title='Cluster position in station {0} Layer {1};clusterX;clusterY', type='TH2F', path='Cluster', xbins=80, xmin=0.5, xmax=80.5, ybins=336, ymin=0.5, ymax=336.5)
+
+    arrayOneList = helper.addArray([combinedList], afpToFAlgorithm, 'AFPToFTool', topPath='AFP/ToF/')
+    arrayOneList.defineHistogram('trainID,barInTrainID', title='ToF hit bar vs train {0};trainID;barInTrainID', type='TH2F', path='HitBarvsTrain/',xbins=4,xmin=-0.5,xmax=3.5,ybins=4,ymin=-0.5,ymax=3.5)
+    array.defineHistogram('trackX,trackY', title='Track posistion position in station {0}trackX;trackY', type='TH2F', path='Track', xbins=80, xmin=0.5, xmax=80.5, ybins=336, ymin=0.5, ymax=336.5)   
 
     #array.defineHistogram('pixelColIDChip,pixelColIDChip', title='Correlation Row {0} Row {1}', type='TH2F', path='Correlation', xbins=80, xmin=0.5, xmax=80.5, ybins=80, ymin=0.5, ymax=80.5)
     #array.defineHistogram('pixelRowIDChip,pixelRowIDChip', title='Correlation Col {0} Col {1}', type='TH2F', path='Correlation', xbins=80, xmin=0.5, xmax=80.5, ybins=336, ymin=0.5, ymax=336.5)
diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPFastReco.cxx b/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPFastReco.cxx
index 83ba56c43358..217c1dc607fb 100644
--- a/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPFastReco.cxx
+++ b/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPFastReco.cxx
@@ -49,7 +49,7 @@ namespace AFPMon {
 
       const float x = xPlane;
       const float y = yPlane * cos(tilt);
-      const float z = yPlane * sin(tilt) * dz * layerID;
+      const float z = yPlane * sin(tilt) + dz * layerID;
 
       m_clusters.emplace_back(x, y, z, stationID, layerID);
     }
diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPSiLayerAlgorithm.cxx b/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPSiLayerAlgorithm.cxx
index 5cf0a6f3a9b5..80d88e8b8cfd 100644
--- a/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPSiLayerAlgorithm.cxx
+++ b/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPSiLayerAlgorithm.cxx
@@ -49,7 +49,9 @@ StatusCode AFPSiLayerAlgorithm::fillHistograms( const EventContext& ctx ) const
     auto pixelColIDChip = Monitored::Scalar<int>("pixelColIDChip", 0); 
     auto timeOverThreshold = Monitored::Scalar<float>("timeOverThreshold", 0.0);
     auto clusterX = Monitored::Scalar<float>("clusterX", 0.0);
-    auto clusterY = Monitored::Scalar<float>("clusterY", 0.0);
+    auto clusterY = Monitored::Scalar<float>("clusterY", 0.0); 
+    auto trackX = Monitored::Scalar<float>("trackX", 0.0);
+    auto trackY = Monitored::Scalar<float>("trackY", 0.0);
     
     lb = GetEventInfo(ctx)->lumiBlock();
  
@@ -70,6 +72,7 @@ StatusCode AFPSiLayerAlgorithm::fillHistograms( const EventContext& ctx ) const
       pixelRowIDChip = hitsItr->pixelRowIDChip();
       pixelColIDChip = hitsItr->pixelColIDChip();
       timeOverThreshold = hitsItr->timeOverThreshold();
+      std::cout << "\tTime Over Threshold: " << timeOverThreshold << "\n";
 	
       if (hitsItr->stationID()<4 && hitsItr->stationID()>=0 && hitsItr->pixelLayerID()<4 && hitsItr->pixelLayerID()>=0) 
       {
@@ -94,7 +97,9 @@ StatusCode AFPSiLayerAlgorithm::fillHistograms( const EventContext& ctx ) const
 
     for (const auto& track : fast.tracks()) {
       //ATH_MSG_INFO("t: " << track.x << " " << track.y);
-      
+      trackX = track.x;
+      trackY = track.y;
+      //fill(m_tools[m_HitmapGroups.at(m_stationnames.at(track.station))], trackX, trackY);
     }
  
 
-- 
GitLab