From 86fbb4a47e6d0d1f0d94f3d61712e6772f9112bb Mon Sep 17 00:00:00 2001
From: rquaglia <rquaglia@cern.ch>
Date: Fri, 19 Jan 2018 11:23:41 +0100
Subject: [PATCH] update memory allocations in hit manager

---
 Pr/PrPixel/src/PrPixelHitManager.cpp          | 28 ++++++++++---------
 Pr/PrPixel/src/PrPixelTracking.cpp            |  4 ++-
 Pr/PrPixel/src/PrPixelTracking.h              |  4 +--
 .../python/TrackSys/RecoUpgradeTracking.py    | 27 ++++++++++--------
 4 files changed, 34 insertions(+), 29 deletions(-)

diff --git a/Pr/PrPixel/src/PrPixelHitManager.cpp b/Pr/PrPixel/src/PrPixelHitManager.cpp
index 03ba3cfe268..0af46d34672 100644
--- a/Pr/PrPixel/src/PrPixelHitManager.cpp
+++ b/Pr/PrPixel/src/PrPixelHitManager.cpp
@@ -56,8 +56,6 @@ StatusCode PrPixelHitManager::initialize() {
   // create pattern buffer for isolated SPs
   cacheSPPatterns();
   
-
-
   return StatusCode::SUCCESS;
   
   
@@ -380,8 +378,10 @@ bool PrPixelHitManager::buildHitsFromRawBank( const LHCb::RawEvent& rawEvent,
           hitsZVec.emplace_back(ltg[6] * local_x + ltg[7] * local_y + ltg[11]);
 
           hitsIDVec.emplace_back(cid);
-          xFractions.push_back(fx);
-          yFractions.push_back(fy);
+	  if( storecluster){
+	    xFractions.push_back(fx);
+	    yFractions.push_back(fy);
+	  }
         }
 
         // if there is a second cluster for this pattern
@@ -407,8 +407,10 @@ bool PrPixelHitManager::buildHitsFromRawBank( const LHCb::RawEvent& rawEvent,
           hitsZVec.emplace_back(ltg[6] * local_x + ltg[7] * local_y + ltg[11]);
 
           hitsIDVec.emplace_back(cid);
-          xFractions.push_back(fx);
-          yFractions.push_back(fy);
+	  if( storecluster){
+	    xFractions.push_back(fx);
+	    yFractions.push_back(fy);
+	  }
         }
         continue;  // move on to next super pixel
       }
@@ -552,7 +554,7 @@ bool PrPixelHitManager::buildHitsFromRawBank( const LHCb::RawEvent& rawEvent,
           }
         }
       }  // while the stack is not empty
-
+      
       // we are done with this cluster, calculate
       // centroid pixel coordinate and fractions.
       if (n <= m_maxClusterSize) {
@@ -561,10 +563,10 @@ bool PrPixelHitManager::buildHitsFromRawBank( const LHCb::RawEvent& rawEvent,
         const unsigned int cy = y / n;
         const float fx = x / static_cast<float>(n) - cx;
         const float fy = y / static_cast<float>(n) - cy;
-
-        xFractions.push_back(fx);
-        yFractions.push_back(fy);
-
+	if( storecluster){
+	  xFractions.push_back(fx);
+	  yFractions.push_back(fy);
+	}
         // store target (3D point for tracking)
         const uint32_t chip = cx / CHIP_COLUMNS;
         LHCb::VPChannelID cid(sensor, chip, cx % CHIP_COLUMNS, cy);
@@ -648,7 +650,7 @@ void PrPixelHitManager::storeOfflineClusters( PrPixelModuleHits& mhits, std::vec
 void PrPixelHitManager::storeTriggerClusters( PrPixelModuleHits& mhits, std::vector<float>& xFractions,
                                               std::vector<float>& yFractions, LHCb::VPLightClusters& clusters ) const
 {
-
+  // std::cout<<"storing trigger clusters"<<std::endl;
   // In trigger configuration, only  clusters for 3D points are created
   // that were handed to the pixel tracking. The list of contributing channel
   // IDs for each cluster is not available in this scenario. We will make one
@@ -659,7 +661,7 @@ void PrPixelHitManager::storeTriggerClusters( PrPixelModuleHits& mhits, std::vec
   auto& hitsYVec = mhits.getYVec();
   auto& hitsZVec = mhits.getZVec();
   auto& hitsIDVec = mhits.getIDVec();
-
+  
   const int offset = hitsXVec.size() - xFractions.size();
   unsigned channel;
   for ( size_t i = 0; i < xFractions.size(); ++i ) {
diff --git a/Pr/PrPixel/src/PrPixelTracking.cpp b/Pr/PrPixel/src/PrPixelTracking.cpp
index c86714aab7e..1d5b8a213dd 100644
--- a/Pr/PrPixel/src/PrPixelTracking.cpp
+++ b/Pr/PrPixel/src/PrPixelTracking.cpp
@@ -99,6 +99,7 @@ std::tuple<std::vector<LHCb::Track>, LHCb::VPLightClusters> PrPixelTracking::ope
   LHCb::VPLightClusters clusters;
   clusters.reserve(7500);
   StatusCode sc = m_hitManager->process(rawEvent, modulehits, clusters, m_storecluster);
+  
   if (UNLIKELY(sc.isFailure())) {
     throw GaudiException("Failure in getting hits!", "PrPixelTracking" , sc);
   }
@@ -277,7 +278,6 @@ void PrPixelTracking::extendTrack( std::vector<PrPixelModuleHits>& modulehits, s
   
   //info() << "starting 3 hit loop " << ThreeHitVec.size()/6 << endmsg;
   for(size_t i = 0; i < ThreeHitVec.size(); i+=6){
-    // std::cout<<"Never happen"<<std::endl;
     const size_t i0 = ThreeHitVec[i];
     const size_t i1 = ThreeHitVec[i + 2];
     const size_t i2 = ThreeHitVec[i + 4];
@@ -737,6 +737,8 @@ StatusCode PrPixelTracking::monitor(std::vector<PrPixelModuleHits>& modulehits,
                                     const std::vector<LHCb::Track>& tracks,
                                     const LHCb::VPClusters& clusters) const {
   const unsigned int firstModule = m_hitManager->firstModule();
+  // if( firstModule < m_minModule) std::cout<<"Problems minmodule"<<std::endl;
+  // if( lastModule > m_maxModule) std::cout<<"Problems maxmodule"<<std::endl;
   const unsigned int lastModule = m_hitManager->lastModule();
   for (unsigned int i = firstModule; i < lastModule; ++i) {
     for (const auto& hit : modulehits[i].hits()) {
diff --git a/Pr/PrPixel/src/PrPixelTracking.h b/Pr/PrPixel/src/PrPixelTracking.h
index aa3833bd3ca..30b9aa9cd1e 100644
--- a/Pr/PrPixel/src/PrPixelTracking.h
+++ b/Pr/PrPixel/src/PrPixelTracking.h
@@ -132,10 +132,8 @@ namespace VPConf{
    Gaudi::Property< unsigned int> m_minModule{ this, "MinModule", 0, "Min Module to digitise and use to do tracking, value included"};
 
    Gaudi::Property< unsigned int> m_maxModule{ this, "MaxModule", 51, "Max Module to digitise and use to do tracking, value included"};
-
-   Gaudi::Property<bool> m_skiploopsens{ this, "SkipLoopSens", false, "Skip 1 station in pair creation"};
-   
    
+   Gaudi::Property<bool> m_skiploopsens{ this, "SkipLoopSens", false, "Skip 1 station in pair creation"};
 
  };
 #endif  // PRPIXELTRACKING_H
diff --git a/Tf/TrackSys/python/TrackSys/RecoUpgradeTracking.py b/Tf/TrackSys/python/TrackSys/RecoUpgradeTracking.py
index d92e087a293..a27ed2e8f08 100755
--- a/Tf/TrackSys/python/TrackSys/RecoUpgradeTracking.py
+++ b/Tf/TrackSys/python/TrackSys/RecoUpgradeTracking.py
@@ -106,13 +106,16 @@ def RecoVeloPr(seqType = "Fast", fit = True, output_tracks="Rec/Track/Velo", out
     #Those are the configurations for running with a reduced amount of modules
     prPixelTracking.AlgoConfig = "ForwardThenBackward"
     #ForwardThenBackward"
-    prPixelTracking.RemoveModules = True
-    prPixelTracking.MinModule     = 27
-    prPixelTracking.MaxModule     = 51
-    prPixelTracking.HardFlagging  = True
-    prPixelTracking.MaxMissed     = 0
-    prPixelTracking.Trigger       = True
-    #prPixelTracking.StoreClusters         =   False
+    prPixelTracking.RemoveModules  = False
+    prPixelTracking.MinModule      = 0
+    prPixelTracking.MaxModule      = 51
+    prPixelTracking.HardFlagging   = True
+    prPixelTracking.MaxMissed      = 0
+    prPixelTracking.Trigger        = True
+    prPixelTracking.StoreClusters  = False
+    prPixelTracking.MaxClusterSize = 4
+    prPixelTracking.SkipLoopSens   = True
+    #prPixelTracking.MaxClusterSize = 4
     #prPixelTracking.EndVeloStateKalmanFit = True
     #prPixelTracking.AddFirstLastMeasurementStatesKalmanFit = True
     GaudiSequencer("RecoTr"+seqType+"Seq").Members += [ prPixelTracking ]
@@ -159,8 +162,8 @@ def RecoUpstream(seqType = "Fast", min_pt=0, input_tracks = "Rec/Track/Velo", ou
     prVeloUT.InputTracksName = input_tracks
     prVeloUT.OutputTracksName = output_tracks
     prVeloUT.addTool(PrVeloUTTool, "PrVeloUTTool")
-    prVeloUT.PrVeloUTTool.minPT = min_pt*GeV
-    prVeloUT.doIPCut = False
+    prVeloUT.PrVeloUTTool.minPT = 0.6*GeV
+    prVeloUT.doIPCut = True
     prVeloUT.minIP = 0.1*mm
     prVeloUT.InputVerticesName = "Rec/Vertex/Primary"
     from Configurables import TrackMasterFitter
@@ -187,12 +190,12 @@ def RecoForward(seqType = "Fast",
     prFwdTracking.InputName = input_tracks
     prFwdTracking.OutputName = output_tracks
     prFwdTracking.addTool(PrForwardTool, "PrForwardTool")
-    prFwdTracking.PrForwardTool.MinPT = min_pt
+    prFwdTracking.PrForwardTool.MinPT = 0.8*GeV
     if seqType == "Fast":
         if tuning == 0:
           prFwdTracking.PrForwardTool.UseMomentumEstimate = True
           prFwdTracking.PrForwardTool.Preselection = True
-          prFwdTracking.PrForwardTool.PreselectionPT = 300.
+          prFwdTracking.PrForwardTool.PreselectionPT = 800.
           prFwdTracking.PrForwardTool.TolYTriangleSearch = 20.
           prFwdTracking.PrForwardTool.TolYCollectX = 3.5
           prFwdTracking.PrForwardTool.TolYSlopeCollectX = 0.001
@@ -208,7 +211,7 @@ def RecoForward(seqType = "Fast",
         if tuning == 1:
           prFwdTracking.PrForwardTool.UseMomentumEstimate = True
           prFwdTracking.PrForwardTool.Preselection = True
-          prFwdTracking.PrForwardTool.PreselectionPT = 300.
+          prFwdTracking.PrForwardTool.PreselectionPT = 800.
           prFwdTracking.PrForwardTool.TolYTriangleSearch = 20.
           prFwdTracking.PrForwardTool.TolYCollectX = 2.7
           prFwdTracking.PrForwardTool.TolYSlopeCollectX = 0.0007
-- 
GitLab