Skip to content

Commit

Permalink
code-format
Browse files Browse the repository at this point in the history
  • Loading branch information
czangela committed Apr 6, 2021
1 parent fff0dc9 commit 566baed
Show file tree
Hide file tree
Showing 18 changed files with 1,727 additions and 1,991 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,26 @@
#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h"

class Phase2TrackerRecHits : public edm::global::EDProducer<> {
public:
public:
explicit Phase2TrackerRecHits(const edm::ParameterSet& conf);
~Phase2TrackerRecHits() override{};
void produce(edm::StreamID sid, edm::Event& event,
const edm::EventSetup& eventSetup) const final;
void produce(edm::StreamID sid, edm::Event& event, const edm::EventSetup& eventSetup) const final;

private:
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> const
tTrackerGeom_;
edm::ESGetToken<ClusterParameterEstimator<Phase2TrackerCluster1D>,
TkPhase2OTCPERecord> const tCPE_;
private:
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> const tTrackerGeom_;
edm::ESGetToken<ClusterParameterEstimator<Phase2TrackerCluster1D>, TkPhase2OTCPERecord> const tCPE_;

edm::EDGetTokenT<Phase2TrackerCluster1DCollectionNew> token_;
};

Phase2TrackerRecHits::Phase2TrackerRecHits(edm::ParameterSet const& conf)
: tTrackerGeom_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>()),
tCPE_(esConsumes(conf.getParameter<edm::ESInputTag>("Phase2StripCPE"))),
token_(consumes<Phase2TrackerCluster1DCollectionNew>(
conf.getParameter<edm::InputTag>("src"))) {
token_(consumes<Phase2TrackerCluster1DCollectionNew>(conf.getParameter<edm::InputTag>("src"))) {
produces<Phase2TrackerRecHit1DCollectionNew>();
}

void Phase2TrackerRecHits::produce(edm::StreamID sid, edm::Event& event,
const edm::EventSetup& eventSetup) const {
void Phase2TrackerRecHits::produce(edm::StreamID sid, edm::Event& event, const edm::EventSetup& eventSetup) const {
// Get the Clusters
edm::Handle<Phase2TrackerCluster1DCollectionNew> clusters;
event.getByToken(token_, clusters);
Expand All @@ -70,16 +65,15 @@ void Phase2TrackerRecHits::produce(edm::StreamID sid, edm::Event& event,
const GeomDetUnit* geomDetUnit(tkGeom->idToDetUnit(detId));

// Container for the clusters that will be produced for this modules
Phase2TrackerRecHit1DCollectionNew::FastFiller rechits(
*outputRecHits, clusterDetSet.detId());
Phase2TrackerRecHit1DCollectionNew::FastFiller rechits(*outputRecHits, clusterDetSet.detId());

for (const auto& clusterRef : clusterDetSet) {
ClusterParameterEstimator<Phase2TrackerCluster1D>::LocalValues lv =
cpe->localParameters(clusterRef, *geomDetUnit);

// Create a persistent edm::Ref to the cluster
edm::Ref<Phase2TrackerCluster1DCollectionNew, Phase2TrackerCluster1D>
cluster = edmNew::makeRefTo(clusters, &clusterRef);
edm::Ref<Phase2TrackerCluster1DCollectionNew, Phase2TrackerCluster1D> cluster =
edmNew::makeRefTo(clusters, &clusterRef);

// Make a RecHit and add it to the DetSet
Phase2TrackerRecHit1D hit(lv.first, lv.second, *geomDetUnit, cluster);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
#define RecoLocalTracker_SiPixelClusterizer_plugins_SiPixelClusterThresholds_h

struct SiPixelClusterThresholds {
inline constexpr int32_t getThresholdForLayerOnCondition(
bool isLayer1) const noexcept {
inline constexpr int32_t getThresholdForLayerOnCondition(bool isLayer1) const noexcept {
return isLayer1 ? layer1 : otherLayers;
}
const int32_t layer1;
const int32_t otherLayers;
};

constexpr SiPixelClusterThresholds kSiPixelClusterThresholdsDefaultPhase1{
.layer1 = 2000, .otherLayers = 4000};
constexpr SiPixelClusterThresholds kSiPixelClusterThresholdsDefaultPhase1{.layer1 = 2000, .otherLayers = 4000};

#endif // RecoLocalTracker_SiPixelClusterizer_plugins_SiPixelClusterThresholds_h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
#include "SiPixelClusterThresholds.h"

class SiPixelDigisClustersFromSoA : public edm::global::EDProducer<> {
public:
public:
explicit SiPixelDigisClustersFromSoA(const edm::ParameterSet& iConfig);
~SiPixelDigisClustersFromSoA() override = default;

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
void produce(edm::StreamID, edm::Event& iEvent,
const edm::EventSetup& iSetup) const override;
private:
void produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> topoToken_;

Expand All @@ -38,34 +37,26 @@ class SiPixelDigisClustersFromSoA : public edm::global::EDProducer<> {
edm::EDPutTokenT<edm::DetSetVector<PixelDigi>> digiPutToken_;
edm::EDPutTokenT<SiPixelClusterCollectionNew> clusterPutToken_;

const SiPixelClusterThresholds
clusterThresholds_; // Cluster threshold in electrons
const SiPixelClusterThresholds clusterThresholds_; // Cluster threshold in electrons
};

SiPixelDigisClustersFromSoA::SiPixelDigisClustersFromSoA(
const edm::ParameterSet& iConfig)
SiPixelDigisClustersFromSoA::SiPixelDigisClustersFromSoA(const edm::ParameterSet& iConfig)
: topoToken_(esConsumes()),
digiGetToken_(consumes<SiPixelDigisSoA>(
iConfig.getParameter<edm::InputTag>("src"))),
digiGetToken_(consumes<SiPixelDigisSoA>(iConfig.getParameter<edm::InputTag>("src"))),
digiPutToken_(produces<edm::DetSetVector<PixelDigi>>()),
clusterPutToken_(produces<SiPixelClusterCollectionNew>()),
clusterThresholds_{
iConfig.getParameter<int>("clusterThreshold_layer1"),
iConfig.getParameter<int>("clusterThreshold_otherLayers")} {}
clusterThresholds_{iConfig.getParameter<int>("clusterThreshold_layer1"),
iConfig.getParameter<int>("clusterThreshold_otherLayers")} {}

void SiPixelDigisClustersFromSoA::fillDescriptions(
edm::ConfigurationDescriptions& descriptions) {
void SiPixelDigisClustersFromSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("src", edm::InputTag("siPixelDigisSoA"));
desc.add<int>("clusterThreshold_layer1",
kSiPixelClusterThresholdsDefaultPhase1.layer1);
desc.add<int>("clusterThreshold_otherLayers",
kSiPixelClusterThresholdsDefaultPhase1.otherLayers);
desc.add<int>("clusterThreshold_layer1", kSiPixelClusterThresholdsDefaultPhase1.layer1);
desc.add<int>("clusterThreshold_otherLayers", kSiPixelClusterThresholdsDefaultPhase1.otherLayers);
descriptions.addWithDefaultLabel(desc);
}

void SiPixelDigisClustersFromSoA::produce(edm::StreamID, edm::Event& iEvent,
const edm::EventSetup& iSetup) const {
void SiPixelDigisClustersFromSoA::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
const auto& digis = iEvent.get(digiGetToken_);
const uint32_t nDigis = digis.size();
const auto& ttopo = iSetup.getData(topoToken_);
Expand All @@ -76,62 +67,59 @@ void SiPixelDigisClustersFromSoA::produce(edm::StreamID, edm::Event& iEvent,

edm::DetSet<PixelDigi>* detDigis = nullptr;
for (uint32_t i = 0; i < nDigis; i++) {
if (digis.pdigi(i) == 0) continue;
if (digis.pdigi(i) == 0)
continue;
detDigis = &collection->find_or_insert(digis.rawIdArr(i));
if ((*detDigis).empty())
(*detDigis).data.reserve(64); // avoid the first relocations
break;
}

int32_t nclus = -1;
std::vector<PixelClusterizerBase::AccretionCluster> aclusters(
gpuClustering::maxNumClustersPerModules);
std::vector<PixelClusterizerBase::AccretionCluster> aclusters(gpuClustering::maxNumClustersPerModules);
#ifdef EDM_ML_DEBUG
auto totClustersFilled = 0;
#endif

auto fillClusters = [&](uint32_t detId) {
if (nclus < 0) return; // this in reality should never happen
edmNew::DetSetVector<SiPixelCluster>::FastFiller spc(*outputClusters,
detId);
if (nclus < 0)
return; // this in reality should never happen
edmNew::DetSetVector<SiPixelCluster>::FastFiller spc(*outputClusters, detId);
auto layer = (DetId(detId).subdetId() == 1) ? ttopo.pxbLayer(detId) : 0;
auto clusterThreshold =
clusterThresholds_.getThresholdForLayerOnCondition(layer == 1);
auto clusterThreshold = clusterThresholds_.getThresholdForLayerOnCondition(layer == 1);
for (int32_t ic = 0; ic < nclus + 1; ++ic) {
auto const& acluster = aclusters[ic];
// in any case we cannot go out of sync with gpu...
if (acluster.charge < clusterThreshold)
edm::LogWarning("SiPixelDigisClustersFromSoA")
<< "cluster below charge Threshold "
<< "Layer/DetId/clusId " << layer << '/' << detId << '/' << ic
<< " size/charge " << acluster.isize << '/' << acluster.charge;
SiPixelCluster cluster(acluster.isize, acluster.adc, acluster.x,
acluster.y, acluster.xmin, acluster.ymin, ic);
edm::LogWarning("SiPixelDigisClustersFromSoA") << "cluster below charge Threshold "
<< "Layer/DetId/clusId " << layer << '/' << detId << '/' << ic
<< " size/charge " << acluster.isize << '/' << acluster.charge;
SiPixelCluster cluster(acluster.isize, acluster.adc, acluster.x, acluster.y, acluster.xmin, acluster.ymin, ic);
#ifdef EDM_ML_DEBUG
++totClustersFilled;
#endif
LogDebug("SiPixelDigisClustersFromSoA")
<< "putting in this cluster " << ic << " " << cluster.charge() << " "
<< cluster.pixelADC().size();
<< "putting in this cluster " << ic << " " << cluster.charge() << " " << cluster.pixelADC().size();
// sort by row (x)
spc.push_back(std::move(cluster));
std::push_heap(spc.begin(), spc.end(),
[](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
return cl1.minPixelRow() < cl2.minPixelRow();
});
std::push_heap(spc.begin(), spc.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
return cl1.minPixelRow() < cl2.minPixelRow();
});
}
for (int32_t ic = 0; ic < nclus + 1; ++ic) aclusters[ic].clear();
for (int32_t ic = 0; ic < nclus + 1; ++ic)
aclusters[ic].clear();
nclus = -1;
// sort by row (x)
std::sort_heap(spc.begin(), spc.end(),
[](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
return cl1.minPixelRow() < cl2.minPixelRow();
});
if (spc.empty()) spc.abort();
std::sort_heap(spc.begin(), spc.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
return cl1.minPixelRow() < cl2.minPixelRow();
});
if (spc.empty())
spc.abort();
};

for (uint32_t i = 0; i < nDigis; i++) {
if (digis.pdigi(i) == 0) continue;
if (digis.pdigi(i) == 0)
continue;
if (digis.clus(i) > 9000)
continue; // not in cluster; TODO add an assert for the size
assert(digis.rawIdArr(i) > 109999);
Expand All @@ -142,8 +130,7 @@ void SiPixelDigisClustersFromSoA::produce(edm::StreamID, edm::Event& iEvent,
if ((*detDigis).empty())
(*detDigis).data.reserve(64); // avoid the first relocations
else {
edm::LogWarning("SiPixelDigisClustersFromSoA")
<< "Problem det present twice in input! " << (*detDigis).detId();
edm::LogWarning("SiPixelDigisClustersFromSoA") << "Problem det present twice in input! " << (*detDigis).detId();
}
}
(*detDigis).data.emplace_back(digis.pdigi(i));
Expand All @@ -159,10 +146,10 @@ void SiPixelDigisClustersFromSoA::produce(edm::StreamID, edm::Event& iEvent,
}

// fill final clusters
if (detDigis) fillClusters((*detDigis).detId());
if (detDigis)
fillClusters((*detDigis).detId());
#ifdef EDM_ML_DEBUG
LogDebug("SiPixelDigisClustersFromSoA")
<< "filled " << totClustersFilled << " clusters";
LogDebug("SiPixelDigisClustersFromSoA") << "filled " << totClustersFilled << " clusters";
#endif

iEvent.put(digiPutToken_, std::move(collection));
Expand Down
Loading

0 comments on commit 566baed

Please sign in to comment.