Skip to content
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 @@ -13,13 +13,17 @@
#include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
#include "DataFormats/SiPixelDigiSoA/interface/alpaka/SiPixelDigiErrorsSoACollection.h"
#include "DataFormats/SiPixelDigiSoA/interface/alpaka/SiPixelDigisSoACollection.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "Geometry/CommonTopologies/interface/GeomDetEnumerators.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/EDPutToken.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/Event.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/stream/SynchronizingEDProducer.h"
Expand All @@ -41,8 +45,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
private:
void acquire(device::Event const& iEvent, device::EventSetup const& iSetup) override;
void produce(device::Event& iEvent, device::EventSetup const& iSetup) override;
void beginRun(edm::Run const&, edm::EventSetup const& iSetup) override;

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomTokenBeginRun_; // For BeginRun
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> topoToken_;

const edm::EDGetTokenT<edm::DetSetVector<PixelDigi>> pixelDigiToken_;
const device::EDPutToken<SiPixelDigisSoACollection> digiPutToken_;
const device::EDPutToken<SiPixelClustersSoACollection> clusterPutToken_;
Expand All @@ -51,11 +59,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
Algo algo_;
uint32_t nDigis_ = 0;
std::optional<SiPixelDigisSoACollection> digis_d_;
mutable uint32_t offsetBPIX2_ = pixelTopology::Phase2::layerStart[1];
};

SiPixelPhase2DigiToCluster::SiPixelPhase2DigiToCluster(const edm::ParameterSet& iConfig)
: SynchronizingEDProducer(iConfig),
geomToken_(esConsumes()),
geomTokenBeginRun_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord, edm::Transition::BeginRun>()),
topoToken_(esConsumes<TrackerTopology, TrackerTopologyRcd, edm::Transition::BeginRun>()),
pixelDigiToken_(consumes<edm::DetSetVector<PixelDigi>>(iConfig.getParameter<edm::InputTag>("InputDigis"))),
digiPutToken_(produces()),
clusterPutToken_(produces()),
Expand All @@ -80,6 +91,44 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
desc.add<edm::InputTag>("InputDigis", edm::InputTag("simSiPixelDigis:Pixel"));
descriptions.addWithDefaultLabel(desc);
}
void SiPixelPhase2DigiToCluster::beginRun(edm::Run const&, edm::EventSetup const& iSetup) {
using namespace pixelTopology;

auto const& trackerGeometry = iSetup.getData(geomTokenBeginRun_);
auto const& trackerTopology = iSetup.getData(topoToken_);

auto const& dets = trackerGeometry.detUnits();

uint32_t n_modules = 0;
uint32_t oldLayer = std::numeric_limits<uint32_t>::max();
uint32_t layerCount = 0;
uint32_t bpix2Start = 0;

// Loop over detector modules to find where BPIX2 starts
for (auto& det : dets) {
if (!GeomDetEnumerators::isInnerTracker(det->subDetector()))
continue;

DetId detId = det->geographicalId();
auto layer = trackerTopology.layer(detId);

if (layer != oldLayer) {
if (layerCount == 1) {
// layer 1 is BPIX2
bpix2Start = n_modules;
}
layerCount++;
oldLayer = layer;
}
n_modules++;
}

offsetBPIX2_ = bpix2Start;

LogDebug("SiPixelPhase2DigiToCluster")
<< "beginRun: BPIX2 module start = " << offsetBPIX2_ << " (total pixel modules: " << n_modules
<< "). Offset from simplePixelTopology = " << pixelTopology::Phase2::layerStart[1] << '\n';
}

void SiPixelPhase2DigiToCluster::acquire(device::Event const& iEvent, device::EventSetup const& iSetup) {
auto const& input = iEvent.get(pixelDigiToken_);
Expand Down Expand Up @@ -117,7 +166,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
assert(nDigis == nDigis_);

alpaka::memcpy(iEvent.queue(), digis_d_->buffer(), digis_h.buffer());
algo_.makePhase2ClustersAsync(iEvent.queue(), clusterThresholds_, digis_d_->view(), nDigis_);
algo_.makePhase2ClustersAsync(iEvent.queue(), clusterThresholds_, digis_d_->view(), nDigis_, offsetBPIX2_);
}

void SiPixelPhase2DigiToCluster::produce(device::Event& iEvent, device::EventSetup const& iSetup) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
Queue &queue,
const SiPixelClusterThresholds clusterThresholds,
SiPixelDigisSoAView &digis_view,
const uint32_t numDigis) {
const uint32_t numDigis,
const uint32_t offsetBPIX2) {
using namespace pixelClustering;
using pixelTopology::Phase2;
nDigis = numDigis;
Expand Down Expand Up @@ -744,7 +745,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
// last element holds the number of all clusters
const auto clusModuleStartLastElement = cms::alpakatools::make_device_view(
queue, clusters_d->const_view().clusModuleStart().data() + numberOfModules, 1u);
constexpr int startBPIX2 = pixelTopology::Phase2::layerStart[1];
const int startBPIX2 = offsetBPIX2;
// element startBPIX2 hold the number of clusters until BPIX2
const auto bpix2ClusterStart =
cms::alpakatools::make_device_view(queue, clusters_d->const_view().clusModuleStart().data() + startBPIX2, 1u);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
void makePhase2ClustersAsync(Queue& queue,
const SiPixelClusterThresholds clusterThresholds,
SiPixelDigisSoAView& digis_view,
const uint32_t numDigis);
const uint32_t numDigis,
const uint32_t offsetBPIX2);

SiPixelDigisSoACollection getDigis() {
digis_d->setNModules(nModules_Clusters_h[0]);
Expand Down