From 85db47e967d9632f3550fb7d53eeac831d7c339a Mon Sep 17 00:00:00 2001
From: wenxingfang <1473717798@qq.com>
Date: Sat, 7 Nov 2020 16:50:50 +0800
Subject: [PATCH] create a namespace for Utility

---
 .../PFA/Pandora/GaudiPandora/CMakeLists.txt   |  1 +
 .../GaudiPandora/include/PandoraPFAlg.h       |  2 +-
 .../Pandora/GaudiPandora/include/Utility.h    | 22 ++++++++++---------
 .../GaudiPandora/src/CaloHitCreator.cpp       |  6 ++---
 .../GaudiPandora/src/GeometryCreator.cpp      |  4 ++--
 .../Pandora/GaudiPandora/src/TrackCreator.cpp |  4 ++--
 .../PFA/Pandora/GaudiPandora/src/Utility.cpp  | 16 +++++++-------
 7 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/CMakeLists.txt b/Reconstruction/PFA/Pandora/GaudiPandora/CMakeLists.txt
index 3842a7aa..c01c5ecf 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/CMakeLists.txt
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/CMakeLists.txt
@@ -3,6 +3,7 @@ gaudi_subdir(GaudiPandora v0r0)
 find_package(LCIO REQUIRED ) 
 find_package(DD4hep COMPONENTS DDG4 REQUIRED)
 find_package(GEAR REQUIRED)
+find_package(CLHEP REQUIRED;CONFIG)
 message("ENV GEAR: $ENV{GEAR}")
 
 find_package(EDM4HEP REQUIRED )
diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/include/PandoraPFAlg.h b/Reconstruction/PFA/Pandora/GaudiPandora/include/PandoraPFAlg.h
index c3c2599e..3f029fe3 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/include/PandoraPFAlg.h
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/include/PandoraPFAlg.h
@@ -276,7 +276,7 @@ protected:
   Gaudi::Property<bool> m_use_dd4hep_geo{this, "use_dd4hep_geo", false,"choose if use geo info from dd4hep"};
   Gaudi::Property<bool> m_use_dd4hep_decoder {this, "use_dd4hep_decoder", true,"if use decoder from dd4hep"};
   Gaudi::Property<bool> m_use_preshower {this, "use_preshower", false,"if use preshower layer for calorimeter"};
-  Gaudi::Property< std::string >              m_AnaOutput{ this, "AnaOutput", "/junofs/users/wxfang/MyGit/CEPCSW/Reconstruction/PFA/Pandora/GaudiPandora/Ana.root" };
+  Gaudi::Property< std::string >              m_AnaOutput{ this, "AnaOutput", "Pan_Ana.root" };
   //######################
   std::map< std::string, std::string > m_collections;
   Gaudi::Property<std::vector<std::string>> m_readCols{this, "collections", {}, "Places of collections to read"};
diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/include/Utility.h b/Reconstruction/PFA/Pandora/GaudiPandora/include/Utility.h
index 07ae4809..b29092bf 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/include/Utility.h
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/include/Utility.h
@@ -1,5 +1,5 @@
-#ifndef MYUTILITY
-#define MYUTILITY 1
+#ifndef PanUTIL
+#define PanUTIL 1
 
 #include <sstream>
 #include "DD4hep/Detector.h"
@@ -7,12 +7,14 @@
 #include "DD4hep/DetType.h"
 #include "DDRec/DetectorData.h"
 #include "DD4hep/DetectorSelector.h"
-std::string Convert (float number);
-dd4hep::rec::LayeredCalorimeterData * getExtension(unsigned int includeFlag, unsigned int excludeFlag) ;
-void line_a_b(float x1, float y1, float x2, float y2, float& a, float& b);
-float getPhi(float x, float y);
-int partition(float x, float y);
-int getLayer(float x, float y, float z, std::vector<float>& layers);
-int getLayer_v1(float x, float y, float z, std::vector<float>& layers);
-int getStave(float x, float y);
+namespace PanUtil{
+    std::string Convert (float number);
+    dd4hep::rec::LayeredCalorimeterData * getExtension(unsigned int includeFlag, unsigned int excludeFlag) ;
+    void line_a_b(float x1, float y1, float x2, float y2, float& a, float& b);
+    float getPhi(float x, float y);
+    int partition(float x, float y);
+    int getLayer(float x, float y, float z, std::vector<float>& layers);
+    int getLayer_v1(float x, float y, float z, std::vector<float>& layers);
+    int getStave(float x, float y);
+}
 #endif
diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp
index 02009a5b..818f78bf 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp
@@ -52,7 +52,7 @@ CaloHitCreator::CaloHitCreator(const Settings &settings, const pandora::Pandora
     if(m_settings.m_use_dd4hep_geo){
         sc = svcloc->service("GeomSvc", m_geosvc, false);
         if (!sc) throw "Failed to find GeomSvc.";
-        const dd4hep::rec::LayeredCalorimeterData * eCalBarrelExtension= getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::BARREL),
+        const dd4hep::rec::LayeredCalorimeterData * eCalBarrelExtension= PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::BARREL),
 										     ( dd4hep::DetType::AUXILIARY  |  dd4hep::DetType::FORWARD ) );
         m_eCalBarrelOuterZ        = eCalBarrelExtension->extent[3]/dd4hep::mm;
         m_eCalBarrelInnerPhi0     = eCalBarrelExtension->inner_phi0/dd4hep::rad;
@@ -211,7 +211,7 @@ pandora::StatusCode CaloHitCreator::CreateECalCaloHits(const CollectionMaps& col
                     if (std::fabs(pCaloHit->getPosition()[2]) < m_eCalBarrelOuterZ)
                     {
                         if(m_settings.m_use_dd4hep_geo){
-                            const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer>& barrelLayers= getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::BARREL), ( dd4hep::DetType::AUXILIARY  |  dd4hep::DetType::FORWARD ) )->layers;
+                            const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer>& barrelLayers= PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::BARREL), ( dd4hep::DetType::AUXILIARY  |  dd4hep::DetType::FORWARD ) )->layers;
                             this->GetBarrelCaloHitProperties(pCaloHit, barrelLayers, m_eCalBarrelInnerSymmetry, m_eCalBarrelInnerPhi0,
                             Stave, caloHitParameters, absorberCorrection);
                         }
@@ -225,7 +225,7 @@ pandora::StatusCode CaloHitCreator::CreateECalCaloHits(const CollectionMaps& col
                     else
                     {
                         if(m_settings.m_use_dd4hep_geo){
-                            const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer>& endcapLayers= getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::ENDCAP), ( dd4hep::DetType::AUXILIARY  |  dd4hep::DetType::FORWARD ) )->layers;
+                            const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer>& endcapLayers= PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::ENDCAP), ( dd4hep::DetType::AUXILIARY  |  dd4hep::DetType::FORWARD ) )->layers;
                             this->GetEndCapCaloHitProperties(pCaloHit, endcapLayers, caloHitParameters, absorberCorrection);
                         }
                         else{
diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/GeometryCreator.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/GeometryCreator.cpp
index 4c3bcb36..890c0f8b 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/src/GeometryCreator.cpp
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/GeometryCreator.cpp
@@ -76,8 +76,8 @@ void GeometryCreator::SetMandatorySubDetectorParameters(SubDetectorTypeMap &subD
         muonBarrelParameters, muonEndCapParameters;
     if(m_settings.m_use_dd4hep_geo){
         std::cout << "Use dd4hep geo info for ECAL" << std::endl;
-        this->SetDefaultSubDetectorParameters(*const_cast<dd4hep::rec::LayeredCalorimeterData*>(getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::BARREL), ( dd4hep::DetType::AUXILIARY  |  dd4hep::DetType::FORWARD ) )), "ECalBarrel", pandora::ECAL_BARREL, eCalBarrelParameters);
-        this->SetDefaultSubDetectorParameters(*const_cast<dd4hep::rec::LayeredCalorimeterData*>(getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::ENDCAP), ( dd4hep::DetType::AUXILIARY  |  dd4hep::DetType::FORWARD ) )), "ECalEndCap", pandora::ECAL_ENDCAP, eCalEndCapParameters);
+        this->SetDefaultSubDetectorParameters(*const_cast<dd4hep::rec::LayeredCalorimeterData*>(PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::BARREL), ( dd4hep::DetType::AUXILIARY  |  dd4hep::DetType::FORWARD ) )), "ECalBarrel", pandora::ECAL_BARREL, eCalBarrelParameters);
+        this->SetDefaultSubDetectorParameters(*const_cast<dd4hep::rec::LayeredCalorimeterData*>(PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::ENDCAP), ( dd4hep::DetType::AUXILIARY  |  dd4hep::DetType::FORWARD ) )), "ECalEndCap", pandora::ECAL_ENDCAP, eCalEndCapParameters);
     }
     else{
         this->SetDefaultSubDetectorParameters(_GEAR->getEcalBarrelParameters(), "ECalBarrel", pandora::ECAL_BARREL, eCalBarrelParameters);
diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/TrackCreator.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/TrackCreator.cpp
index c2c0757f..6bf803ec 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/src/TrackCreator.cpp
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/TrackCreator.cpp
@@ -57,9 +57,9 @@ TrackCreator::TrackCreator(const Settings &settings, const pandora::Pandora *con
     m_tpcZmax                 = (_GEAR->getTPCParameters().getMaxDriftLength());
     // fg: FTD description in GEAR has changed ...
     if(m_settings.m_use_dd4hep_geo){
-        const dd4hep::rec::LayeredCalorimeterData * eCalBarrelExtension= getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::BARREL),
+        const dd4hep::rec::LayeredCalorimeterData * eCalBarrelExtension= PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::BARREL),
             									     ( dd4hep::DetType::AUXILIARY  |  dd4hep::DetType::FORWARD ) );
-        const dd4hep::rec::LayeredCalorimeterData * eCalEndcapExtension= getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::ENDCAP),
+        const dd4hep::rec::LayeredCalorimeterData * eCalEndcapExtension= PanUtil::getExtension( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::ENDCAP),
             									     ( dd4hep::DetType::AUXILIARY |  dd4hep::DetType::FORWARD  ) );
         m_eCalBarrelInnerPhi0     = eCalBarrelExtension->inner_phi0/dd4hep::rad;
         m_eCalBarrelInnerSymmetry = eCalBarrelExtension->inner_symmetry;
diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/Utility.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/Utility.cpp
index 697681ff..179cd6e6 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/src/Utility.cpp
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/Utility.cpp
@@ -1,11 +1,11 @@
 #include "Utility.h"
 
-std::string Convert (float number){
+std::string PanUtil::Convert (float number){
     std::ostringstream buff;
     buff<<number;
     return buff.str();   
 }
-dd4hep::rec::LayeredCalorimeterData * getExtension(unsigned int includeFlag, unsigned int excludeFlag=0) {
+dd4hep::rec::LayeredCalorimeterData * PanUtil::getExtension(unsigned int includeFlag, unsigned int excludeFlag=0) {
   
   
   dd4hep::rec::LayeredCalorimeterData * theExtension = 0;
@@ -34,7 +34,7 @@ dd4hep::rec::LayeredCalorimeterData * getExtension(unsigned int includeFlag, uns
 }
 
 
-int partition(float x, float y)
+int PanUtil::partition(float x, float y)
 {
     float a1, b1, a2, b2 ;
     if (x>1850 && x < 2020){
@@ -80,13 +80,13 @@ int partition(float x, float y)
     return -1;
 }
 
-void line_a_b(float x1, float y1, float x2, float y2, float& a, float& b)
+void PanUtil::line_a_b(float x1, float y1, float x2, float y2, float& a, float& b)
 {
     a = (y2-y1)/(x1*y2-x2*y1);
     b = (x1-x2)/(x1*y2-x2*y1);
 }
 
-float getPhi(float x, float y)
+float PanUtil::getPhi(float x, float y)
 {
     if     (x==0 && y>0) return 90;
     else if(x==0 && y<0) return 270;
@@ -97,14 +97,14 @@ float getPhi(float x, float y)
     return phi;
 }
 
-int getStave(float x, float y){
+int PanUtil::getStave(float x, float y){
 
 int part = partition(x, y);
 int Stave = part>=3 ? (part-2) : (part+6);// correct S is from 1 to 8, S-1 is from 0-7 
 return Stave-1;
 }
 
-int getLayer(float x, float y, float z, std::vector<float>& layers){
+int PanUtil::getLayer(float x, float y, float z, std::vector<float>& layers){
 if(abs(z) < 2400){
     float phi = getPhi(x, y);
     int part = partition(x, y);
@@ -130,7 +130,7 @@ else{
 return -1;
 }
 
-int getLayer_v1(float x, float y, float z, std::vector<float>& layers){
+int PanUtil::getLayer_v1(float x, float y, float z, std::vector<float>& layers){
 if(abs(z) < 2400){
     float phi = getPhi(x, y);
     int part = partition(x, y);
-- 
GitLab