Skip to content

Commit

Permalink
Changed conditional build
Browse files Browse the repository at this point in the history
  • Loading branch information
pandreetto committed Oct 25, 2024
1 parent 64560fb commit 75effc3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 73 deletions.
28 changes: 24 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ############################################################

Expand Down Expand Up @@ -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")
Expand All @@ -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()
Expand Down
13 changes: 3 additions & 10 deletions include/ParConeClusteringAlgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -261,16 +256,14 @@ class ParConeClusteringAlgorithm : public pandora::Algorithm
virtual ~CurrentClusterFit() {}

void operator()(const tbb::blocked_range<std::size_t>& crange) const;
inline pandora::StatusCode getStatus() { return p_result; }

private:
const ParConeClusteringAlgorithm& coneAlgorithm;
const ClusterVector& clusterVector;
ClusterFitResultMap& clusterFitResultMap;
mutable pandora::StatusCode p_result;
};

#endif

};

class ParConeClusteringAlgorithmFactory : public pandora::AlgorithmFactory
Expand Down
63 changes: 4 additions & 59 deletions src/ParConeClusteringAlgorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
* $Log: $
*/

#include "Pandora/AlgorithmHeaders.h"
#include "Pandora/StatusCodes.h"

#include "ParConeClusteringAlgorithm.h"

#include "LCHelpers/SortingHelper.h"
Expand Down Expand Up @@ -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<std::size_t>(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<float>::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<std::size_t>(0, clusterVector.size()), clusterFit);
return clusterFit.getStatus();
}

//------------------------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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<std::size_t>& crange) const
{
for (std::size_t idx = crange.begin(); idx != crange.end(); ++idx)
Expand Down Expand Up @@ -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

0 comments on commit 75effc3

Please sign in to comment.