diff --git a/CMakeLists.txt b/CMakeLists.txt index bb0b06d..cf343a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,27 @@ INCLUDE( ilcsoft_default_settings ) INCLUDE_DIRECTORIES( ./include ) INSTALL_DIRECTORY( ./include DESTINATION . FILES_MATCHING PATTERN "*.h" ) -AUX_SOURCE_DIRECTORY( ./src/ DDMarlinPandora_SRCS ) +SET( DDMarlinPandora_SRCS src/DDBFieldPlugin.cc + src/DDCaloDigi_BIB.cc + src/DDCaloDigi.cc + src/DDCaloHitCreator.cc + src/DDExternalClusteringAlgorithm.cc + src/DDGeometryCreator.cc + src/DDMCParticleCreator.cc + src/DDPandoraPFANewProcessor.cc + src/DDPfoCreator.cc + src/DDScintillatorPpdDigi.cc + src/DDSimpleMuonDigi.cc + src/DDTrackCreatorBase.cc + src/DDTrackCreatorCLIC.cc + src/DDTrackCreatorILD.cc) + +OPTION( ENABLE_MT_PLUGINS "Build parallelized plugins" OFF ) + +IF( ENABLE_MT_PLUGINS ) + SET( DDMarlinPandora_SRCS ${DDMarlinPandora_SRCS} + src/ParConeClusteringAlgorithm.cc) +ENDIF() ### DEPENDENCIES ############################################################ @@ -60,8 +80,8 @@ IF( PANDORA_MONITORING ) ENDIF() ENDIF() -OPTION( TBB_ENABLED "Use Intel TBB for internal parallelization" OFF ) -IF( TBB_ENABLED ) + +IF( ENABLE_MT_PLUGINS ) FIND_PACKAGE( TBB REQUIRED ) IF( TBB_FOUND ) MESSAGE( STATUS "Found TBB library") @@ -85,7 +105,7 @@ ENDIF() # add library ADD_SHARED_LIBRARY( DDMarlinPandora ${DDMarlinPandora_SRCS} ) -IF( TBB_ENABLED AND TBB_FOUND ) +IF( ENABLE_MT_PLUGINS AND TBB_FOUND ) TARGET_LINK_LIBRARIES(DDMarlinPandora TBB::tbb) ADD_COMPILE_DEFINITIONS( "TBB_ENABLED" ) ENDIF() diff --git a/include/ParConeClusteringAlgorithm.h b/include/ParConeClusteringAlgorithm.h index 01c2c9f..8974c62 100644 --- a/include/ParConeClusteringAlgorithm.h +++ b/include/ParConeClusteringAlgorithm.h @@ -9,7 +9,8 @@ #define PAR_CONE_CLUSTERING_ALGORITHM_H 1 #include "Pandora/Algorithm.h" - +#include "Pandora/AlgorithmHeaders.h" +#include "Pandora/StatusCodes.h" #include "Helpers/ClusterFitHelper.h" #include "Objects/CaloHit.h" @@ -22,11 +23,7 @@ using lc_content::KDTreeLinkerAlgo; using lc_content::KDTreeNodeInfoT; -#ifdef TBB_ENABLED #include "tbb/tbb.h" -#include "Pandora/AlgorithmHeaders.h" -#include "Pandora/StatusCodes.h" -#endif /** * @brief ConeClusteringAlgorithm class @@ -243,8 +240,6 @@ class ParConeClusteringAlgorithm : public pandora::Algorithm unsigned int m_firstLayer; ///< cache the pseudo layer at IP -#ifdef TBB_ENABLED - mutable tbb::queuing_mutex p_mutex; class CurrentClusterFit @@ -261,6 +256,7 @@ class ParConeClusteringAlgorithm : public pandora::Algorithm virtual ~CurrentClusterFit() {} void operator()(const tbb::blocked_range& crange) const; + inline pandora::StatusCode getStatus() { return p_result; } private: const ParConeClusteringAlgorithm& coneAlgorithm; @@ -268,9 +264,6 @@ class ParConeClusteringAlgorithm : public pandora::Algorithm ClusterFitResultMap& clusterFitResultMap; mutable pandora::StatusCode p_result; }; - -#endif - }; class ParConeClusteringAlgorithmFactory : public pandora::AlgorithmFactory diff --git a/src/ParConeClusteringAlgorithm.cc b/src/ParConeClusteringAlgorithm.cc index 0e8cf53..da7522f 100644 --- a/src/ParConeClusteringAlgorithm.cc +++ b/src/ParConeClusteringAlgorithm.cc @@ -6,9 +6,6 @@ * $Log: $ */ -#include "Pandora/AlgorithmHeaders.h" -#include "Pandora/StatusCodes.h" - #include "ParConeClusteringAlgorithm.h" #include "LCHelpers/SortingHelper.h" @@ -198,57 +195,10 @@ StatusCode ParConeClusteringAlgorithm::GetCurrentClusterFitResults(const Cluster { if (!clusterFitResultMap.empty()) return STATUS_CODE_INVALID_PARAMETER; -#ifdef TBB_ENABLED - tbb::parallel_for(tbb::blocked_range(0, clusterVector.size()), - CurrentClusterFit(*this, clusterVector, clusterFitResultMap)); -#else - for (ClusterVector::const_iterator iter = clusterVector.begin(); iter != clusterVector.end(); ++iter) - { - const Cluster *const pCluster = *iter; - ClusterFitResult clusterFitResult; - - if (pCluster->GetNCaloHits() > 1) - { - const unsigned int innerLayer(pCluster->GetInnerPseudoLayer()); - const unsigned int outerLayer(pCluster->GetOuterPseudoLayer()); - const unsigned int nLayersSpanned(outerLayer - innerLayer); - - if (nLayersSpanned > m_nLayersSpannedForFit) - { - unsigned int nLayersToFit(m_nLayersToFit); - - if (pCluster->GetMipFraction() - m_nLayersToFitLowMipCut < std::numeric_limits::epsilon()) - nLayersToFit *= m_nLayersToFitLowMipMultiplier; - - const unsigned int startLayer( (nLayersSpanned > nLayersToFit) ? (outerLayer - nLayersToFit) : innerLayer); - (void) ClusterFitHelper::FitLayerCentroids(pCluster, startLayer, outerLayer, clusterFitResult); - - if (clusterFitResult.IsFitSuccessful()) - { - const float dotProduct(clusterFitResult.GetDirection().GetDotProduct(pCluster->GetInitialDirection())); - const float chi2(clusterFitResult.GetChi2()); - if (((dotProduct < m_fitSuccessDotProductCut1) && (chi2 > m_fitSuccessChi2Cut1)) || - ((dotProduct < m_fitSuccessDotProductCut2) && (chi2 > m_fitSuccessChi2Cut2)) ) - { - clusterFitResult.SetSuccessFlag(false); - } - } - } - else if (nLayersSpanned > m_nLayersSpannedForApproxFit) - { - const CartesianVector centroidChange(pCluster->GetCentroid(outerLayer) - pCluster->GetCentroid(innerLayer)); - clusterFitResult.Reset(); - clusterFitResult.SetDirection(centroidChange.GetUnitVector()); - clusterFitResult.SetSuccessFlag(true); - } - } - - if (!clusterFitResultMap.insert(ClusterFitResultMap::value_type(pCluster, clusterFitResult)).second) - return STATUS_CODE_FAILURE; - } -#endif - return STATUS_CODE_SUCCESS; + auto clusterFit = CurrentClusterFit(*this, clusterVector, clusterFitResultMap); + tbb::parallel_for(tbb::blocked_range(0, clusterVector.size()), clusterFit); + return clusterFit.getStatus(); } //------------------------------------------------------------------------------------------------------------------------------------------ @@ -951,10 +901,6 @@ StatusCode ParConeClusteringAlgorithm::ReadSettings(const TiXmlHandle xmlHandle) return STATUS_CODE_SUCCESS; } - - - -#ifdef TBB_ENABLED void ParConeClusteringAlgorithm::CurrentClusterFit::operator()(const tbb::blocked_range& crange) const { for (std::size_t idx = crange.begin(); idx != crange.end(); ++idx) @@ -1004,8 +950,7 @@ void ParConeClusteringAlgorithm::CurrentClusterFit::operator()(const tbb::blocke { tbb::queuing_mutex::scoped_lock lock(coneAlgorithm.p_mutex); if (!clusterFitResultMap.insert(ClusterFitResultMap::value_type(pCluster, clusterFitResult)).second) - p_result = STATUS_CODE_FAILURE; + p_result = STATUS_CODE_FAILURE; } } } -#endif