From a669fa1e44c5ac5ec6c4f02cd693dd2e012ec5b6 Mon Sep 17 00:00:00 2001
From: Zhang Yao <zhangyao@ihep.ac.cn>
Date: Mon, 4 Jan 2021 18:35:59 +0800
Subject: [PATCH] Add a number of DC digi cut in TruthTrackerAlg

---
 .../Tracking/src/TruthTracker/TruthTrackerAlg.cpp     | 11 +++++++----
 .../Tracking/src/TruthTracker/TruthTrackerAlg.h       |  3 ++-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/Reconstruction/Tracking/src/TruthTracker/TruthTrackerAlg.cpp b/Reconstruction/Tracking/src/TruthTracker/TruthTrackerAlg.cpp
index 612fae8e..6a9842e0 100644
--- a/Reconstruction/Tracking/src/TruthTracker/TruthTrackerAlg.cpp
+++ b/Reconstruction/Tracking/src/TruthTracker/TruthTrackerAlg.cpp
@@ -22,7 +22,8 @@
 DECLARE_COMPONENT(TruthTrackerAlg)
 
 TruthTrackerAlg::TruthTrackerAlg(const std::string& name, ISvcLocator* svcLoc)
-: GaudiAlgorithm(name, svcLoc), m_dd4hep(nullptr), m_gridDriftChamber(nullptr),m_decoder(nullptr)
+: GaudiAlgorithm(name,svcLoc),m_dd4hep(nullptr),m_gridDriftChamber(nullptr),
+    m_decoder(nullptr)
 {
     declareProperty("MCParticle", m_mcParticleCol,
             "Handle of the input MCParticle collection");
@@ -34,7 +35,8 @@ TruthTrackerAlg::TruthTrackerAlg(const std::string& name, ISvcLocator* svcLoc)
         "Handle of association collection");
     declareProperty("DCRecParticleCollection", m_dcRecParticleCol,
             "Handle of drift chamber reconstructed particle collection");
-    declareProperty("DCRecParticleAssociationCollection", m_dcRecParticleAssociationCol,
+    declareProperty("DCRecParticleAssociationCollection",
+            m_dcRecParticleAssociationCol,
             "Handle of drift chamber reconstructed particle collection");
     declareProperty("debug", m_debug=false);
 }
@@ -90,6 +92,7 @@ StatusCode TruthTrackerAlg::execute()
         debug()<<"TrackerHitCollection not found"<<endmsg;
         //return StatusCode::SUCCESS;
     }
+    if((int) digiDCHitsCol->size()>m_maxDCDigiCut) return StatusCode::SUCCESS;
 
     ///Output Track collection
     edm4hep::TrackCollection* dcTrackCol=m_dcTrackCol.createAndPut();
@@ -112,7 +115,7 @@ StatusCode TruthTrackerAlg::execute()
         //if(fabs(mcParticle.getCharge()<1e-6) continue;//Skip neutral particles
         edm4hep::Vector3d posV= mcParticle.getVertex();
         edm4hep::Vector3f momV= mcParticle.getMomentum();//GeV
-        float pos[3]={posV.x, posV.y, posV.z};
+        float pos[3]={(float) posV.x, (float) posV.y, (float) posV.z};
         float mom[3]={momV.x, momV.y, momV.z};
         //FIXME
         //pivotToFirstLayer(mcPocaPos,mcPocaMom,firstLayerPos,firstLayerMom);
@@ -155,7 +158,7 @@ StatusCode TruthTrackerAlg::execute()
             track.setNdf(digiDCHitsCol->size()-5);
             //track.setDEdx();//TODO
             //track.setRadiusOfInnermostHit();//TODO
-            for(int i=0; i<digiDCHitsCol->size(); i++ ){
+            for(unsigned int i=0; i<digiDCHitsCol->size(); i++ ){
                 edm4hep::TrackerHit digiDC=digiDCHitsCol->at(i);
                 //if(Sim->MCParti!=current) continue;//TODO
                 track.addToTrackerHits(digiDC);
diff --git a/Reconstruction/Tracking/src/TruthTracker/TruthTrackerAlg.h b/Reconstruction/Tracking/src/TruthTracker/TruthTrackerAlg.h
index 23e581e1..36a87d65 100644
--- a/Reconstruction/Tracking/src/TruthTracker/TruthTrackerAlg.h
+++ b/Reconstruction/Tracking/src/TruthTracker/TruthTrackerAlg.h
@@ -59,7 +59,8 @@ class TruthTrackerAlg: public GaudiAlgorithm
         Gaudi::Property<std::string> m_readout_name{this, "readout",
             "DriftChamberHitsCollection"};
 
-        Gaudi::Property<int>  m_debug{ this, "debug", false};
+        Gaudi::Property<int> m_debug{this, "debug", false};
+        Gaudi::Property<int> m_maxDCDigiCut{this, "maxDCDigiCut",150};
 };
 
 #endif
-- 
GitLab