Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moved PixelThresholdClusterizer::clusterizeDetUnitT template function in separate header #42314

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,80 +120,8 @@ bool PixelThresholdClusterizer::setup(const PixelGeomDetUnit* pixDet) {

return true;
}
//----------------------------------------------------------------------------
//! \brief Cluster pixels.
//! This method operates on a matrix of pixels
//! and finds the largest contiguous cluster around
//! each seed pixel.
//! Input and output data stored in DetSet
//----------------------------------------------------------------------------
template <typename T>
void PixelThresholdClusterizer::clusterizeDetUnitT(const T& input,
const PixelGeomDetUnit* pixDet,
const TrackerTopology* tTopo,
const std::vector<short>& badChannels,
edmNew::DetSetVector<SiPixelCluster>::FastFiller& output) {
typename T::const_iterator begin = input.begin();
typename T::const_iterator end = input.end();

// this should never happen and the raw2digi does not create empty detsets
if (begin == end) {
edm::LogError("PixelThresholdClusterizer") << "@SUB=PixelThresholdClusterizer::clusterizeDetUnitT()"
<< " No digis to clusterize";
}

// Set up the clusterization on this DetId.
if (!setup(pixDet))
return;

theDetid = input.detId();

// Set separate cluster threshold for L1 (needed for phase1)
auto clusterThreshold = theClusterThreshold;
theLayer = (DetId(theDetid).subdetId() == 1) ? tTopo->pxbLayer(theDetid) : 0;
if (theLayer == 1)
clusterThreshold = theClusterThreshold_L1;

// Copy PixelDigis to the buffer array; select the seed pixels
// on the way, and store them in theSeeds.
if (end > begin)
copy_to_buffer(begin, end);

assert(output.empty());
// Loop over all seeds. TO DO: wouldn't using iterators be faster?
for (unsigned int i = 0; i < theSeeds.size(); i++) {
// Gavril : The charge of seeds that were already inlcuded in clusters is set to 1 electron
// so we don't want to call "make_cluster" for these cases
if (theBuffer(theSeeds[i]) >= theSeedThreshold) { // Is this seed still valid?
// Make a cluster around this seed
SiPixelCluster&& cluster = make_cluster(theSeeds[i], output);

// Check if the cluster is above threshold
// (TO DO: one is signed, other unsigned, gcc warns...)
if (cluster.charge() >= clusterThreshold) {
// sort by row (x)
output.push_back(std::move(cluster));
std::push_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
return cl1.minPixelRow() < cl2.minPixelRow();
});
}
}
}
// sort by row (x) maybe sorting the seed would suffice....
std::sort_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
return cl1.minPixelRow() < cl2.minPixelRow();
});

// Erase the seeds.
theSeeds.clear();

// Need to clean unused pixels from the buffer array.
clear_buffer(begin, end);

theFakePixels.clear();

thePixelOccurrence.clear();
}
#include "PixelThresholdClusterizer.icc"

//----------------------------------------------------------------------------
//! \brief Clear the internal buffer array.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//----------------------------------------------------------------------------
//! \brief Cluster pixels.
//! This method operates on a matrix of pixels
//! and finds the largest contiguous cluster around
//! each seed pixel.
//! Input and output data stored in DetSet
//----------------------------------------------------------------------------
template <typename T>
void PixelThresholdClusterizer::clusterizeDetUnitT(const T& input,
const PixelGeomDetUnit* pixDet,
const TrackerTopology* tTopo,
const std::vector<short>& badChannels,
edmNew::DetSetVector<SiPixelCluster>::FastFiller& output) {
typename T::const_iterator begin = input.begin();
typename T::const_iterator end = input.end();

// this should never happen and the raw2digi does not create empty detsets
if (begin == end) {
edm::LogError("PixelThresholdClusterizer") << "@SUB=PixelThresholdClusterizer::clusterizeDetUnitT()"
<< " No digis to clusterize";
}

// Set up the clusterization on this DetId.
if (!setup(pixDet))
return;

theDetid = input.detId();

// Set separate cluster threshold for L1 (needed for phase1)
auto clusterThreshold = theClusterThreshold;
theLayer = (DetId(theDetid).subdetId() == 1) ? tTopo->pxbLayer(theDetid) : 0;
if (theLayer == 1)
clusterThreshold = theClusterThreshold_L1;

// Copy PixelDigis to the buffer array; select the seed pixels
// on the way, and store them in theSeeds.
if (end > begin)
copy_to_buffer(begin, end);

assert(output.empty());
// Loop over all seeds. TO DO: wouldn't using iterators be faster?
for (unsigned int i = 0; i < theSeeds.size(); i++) {
// Gavril : The charge of seeds that were already inlcuded in clusters is set to 1 electron
// so we don't want to call "make_cluster" for these cases
if (theBuffer(theSeeds[i]) >= theSeedThreshold) { // Is this seed still valid?
// Make a cluster around this seed
SiPixelCluster&& cluster = make_cluster(theSeeds[i], output);

// Check if the cluster is above threshold
// (TO DO: one is signed, other unsigned, gcc warns...)
if (cluster.charge() >= clusterThreshold) {
// sort by row (x)
output.push_back(std::move(cluster));
std::push_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
return cl1.minPixelRow() < cl2.minPixelRow();
});
}
}
}
// sort by row (x) maybe sorting the seed would suffice....
std::sort_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
return cl1.minPixelRow() < cl2.minPixelRow();
});

// Erase the seeds.
theSeeds.clear();

// Need to clean unused pixels from the buffer array.
clear_buffer(begin, end);

theFakePixels.clear();

thePixelOccurrence.clear();
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ void SiPixelClusterProducer::run(const T& input,
} // end of DetUnit loop
}

#include "PixelThresholdClusterizer.icc"
#include "FWCore/PluginManager/interface/ModuleDef.h"
#include "FWCore/Framework/interface/MakerMacros.h"

Expand Down