From 63190e9adea8531ecbb10c36f5b1f36492f8f0c7 Mon Sep 17 00:00:00 2001 From: "fangwx@ihep.ac.cn" <fangwx@ihep.ac.cn> Date: Thu, 9 May 2024 01:33:33 +0000 Subject: [PATCH] move hard-coded codes to functions --- .../PFA/Pandora/GaudiPandora/CMakeLists.txt | 1 + .../GaudiPandora/src/CaloHitCreator.cpp | 11 +++--- Utilities/CMakeLists.txt | 1 + Utilities/DecoderHelper/CMakeLists.txt | 10 ++++++ .../include/DecoderHelper/DD4hep2Lcio.h | 14 ++++++++ Utilities/DecoderHelper/src/DD4hep2Lcio.cc | 36 +++++++++++++++++++ 6 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 Utilities/DecoderHelper/CMakeLists.txt create mode 100644 Utilities/DecoderHelper/include/DecoderHelper/DD4hep2Lcio.h create mode 100644 Utilities/DecoderHelper/src/DD4hep2Lcio.cc diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/CMakeLists.txt b/Reconstruction/PFA/Pandora/GaudiPandora/CMakeLists.txt index 01a0267f..dade7622 100644 --- a/Reconstruction/PFA/Pandora/GaudiPandora/CMakeLists.txt +++ b/Reconstruction/PFA/Pandora/GaudiPandora/CMakeLists.txt @@ -11,6 +11,7 @@ gaudi_add_module(GaudiPandora LINK EventSeeder GearSvc DataHelperLib + DecoderHelperLib DetInterface Gaudi::GaudiKernel k4FWCore::k4FWCore diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp index 29b9adcb..bb63363f 100644 --- a/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp +++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp @@ -21,7 +21,7 @@ #include "PandoraPFAlg.h" #include "CaloHitCreator.h" - +#include "DecoderHelper/DD4hep2Lcio.h" #include <algorithm> #include <cmath> #include <limits> @@ -322,7 +322,8 @@ pandora::StatusCode CaloHitCreator::CreateECalCaloHits(const CollectionMaps& col } else{ Stave = m_decoder->get(pCaloHit->getCellID(), "stave"); - Stave = Stave <=2 ? Stave+5 : Stave-3 ;//change to correct style + Stave = DD4hep2Lcio::CEPCv4::getEcalStave(Stave); + //Stave = Stave <=2 ? Stave+5 : Stave-3 ;//change to correct style } //std::cout<<"0Stave="<<Stave<<",0layer="<<caloHitParameters.m_layer.Get()<<std::endl; if (Stave<0) throw "wrong Stave"; @@ -449,7 +450,8 @@ pandora::StatusCode CaloHitCreator::CreateHCalCaloHits(const CollectionMaps& col } else{ Stave = m_decoder->get(pCaloHit->getCellID(), "stave"); - Stave = Stave ==0 ? Stave+7 : Stave-1 ;//correct, same with LCIO + Stave = DD4hep2Lcio::CEPCv4::getHcalStave(Stave); + //Stave = Stave ==0 ? Stave+7 : Stave-1 ;//correct, same with LCIO /* 1 0 **** **** @@ -583,7 +585,8 @@ pandora::StatusCode CaloHitCreator::CreateMuonCaloHits(const CollectionMaps& col } else{ Stave = m_decoder->get(pCaloHit->getCellID(), "stave"); - Stave = 12 - Stave ;//correct to be same with LCIO + Stave = DD4hep2Lcio::CEPCv4::getMuonStave(Stave); + //Stave = 12 - Stave ;//correct to be same with LCIO if(Stave<0) throw("throw wrong stave number?"); } diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt index 7558d9c2..fd5eb932 100644 --- a/Utilities/CMakeLists.txt +++ b/Utilities/CMakeLists.txt @@ -2,4 +2,5 @@ add_subdirectory(DataHelper) add_subdirectory(KalTest) add_subdirectory(KalDet) add_subdirectory(KiTrack) +add_subdirectory(DecoderHelper) diff --git a/Utilities/DecoderHelper/CMakeLists.txt b/Utilities/DecoderHelper/CMakeLists.txt new file mode 100644 index 00000000..3c3f4ca9 --- /dev/null +++ b/Utilities/DecoderHelper/CMakeLists.txt @@ -0,0 +1,10 @@ + +gaudi_add_library(DecoderHelperLib + SOURCES src/DD4hep2Lcio.cc +) + +install(TARGETS DecoderHelperLib + EXPORT CEPCSWTargets + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib + COMPONENT dev) diff --git a/Utilities/DecoderHelper/include/DecoderHelper/DD4hep2Lcio.h b/Utilities/DecoderHelper/include/DecoderHelper/DD4hep2Lcio.h new file mode 100644 index 00000000..a5a2210d --- /dev/null +++ b/Utilities/DecoderHelper/include/DecoderHelper/DD4hep2Lcio.h @@ -0,0 +1,14 @@ +#ifndef DD4HEP2LCIO_H +#define DD4HEP2LCIO_H + +namespace DD4hep2Lcio { + namespace CEPCv4 { + int getEcalLayer(int dd4hep_layer); + int getEcalStave(int dd4hep_stave); + int getHcalLayer(int dd4hep_layer); + int getHcalStave(int dd4hep_stave); + int getMuonLayer(int dd4hep_layer); + int getMuonStave(int dd4hep_stave); + } +} +#endif diff --git a/Utilities/DecoderHelper/src/DD4hep2Lcio.cc b/Utilities/DecoderHelper/src/DD4hep2Lcio.cc new file mode 100644 index 00000000..30dba288 --- /dev/null +++ b/Utilities/DecoderHelper/src/DD4hep2Lcio.cc @@ -0,0 +1,36 @@ +#include "DecoderHelper/DD4hep2Lcio.h" + +int DD4hep2Lcio::CEPCv4::getEcalLayer(int dd4hep_layer){ + return dd4hep_layer - 1 ; +} +int DD4hep2Lcio::CEPCv4::getEcalStave(int dd4hep_stave){ + int lcio_stave = dd4hep_stave <=2 ? dd4hep_stave+5 : dd4hep_stave-3 ; + return lcio_stave ; +} +int DD4hep2Lcio::CEPCv4::getHcalLayer(int dd4hep_layer){ + return dd4hep_layer - 1 ; +} +int DD4hep2Lcio::CEPCv4::getHcalStave(int dd4hep_stave){ + + int lcio_stave = dd4hep_stave ==0 ? dd4hep_stave+7 : dd4hep_stave-1 ; + /* + 1 0 + **** **** + 2 * * 0 1 * * 7 + * * * * + 3* * 7 ---> 2* * 6 + * * * * + 4 * * 6 3 * * 5 + **** **** + 5 4 + + + */ + return lcio_stave ; +} +int DD4hep2Lcio::CEPCv4::getMuonLayer(int dd4hep_layer){ + return dd4hep_layer - 1 ; +} +int DD4hep2Lcio::CEPCv4::getMuonStave(int dd4hep_stave){ + return 12 - dd4hep_stave ; +} -- GitLab