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
1 change: 1 addition & 0 deletions DataFormats/Common/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
<class name="edm::StdArray<short, 4>"/>
<class name="edm::StdArray<unsigned short, 11>"/>
<class name="edm::StdArray<unsigned int, 4>"/>
<class name="edm::StdArray<unsigned int, 14>"/>

<class name="edm::PathStateToken" ClassVersion="3">
<version ClassVersion="3" checksum="2219165191"/>
Expand Down
40 changes: 0 additions & 40 deletions RecoTracker/LST/interface/LSTOutput.h

This file was deleted.

1 change: 0 additions & 1 deletion RecoTracker/LST/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@
<flags ALPAKA_BACKENDS="1"/>
<flags EDM_PLUGIN="1"/>
</library>

94 changes: 55 additions & 39 deletions RecoTracker/LST/plugins/LSTOutputConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "RecoTracker/LSTCore/interface/LSTInputHostCollection.h"
#include "RecoTracker/LST/interface/LSTOutput.h"
#include "RecoTracker/LSTCore/interface/TrackCandidatesHostCollection.h"
#include "RecoTracker/TkSeedingLayers/interface/SeedingHitSet.h"

#include "RecoTracker/TkSeedGenerator/interface/SeedCreator.h"
Expand All @@ -35,7 +35,7 @@ class LSTOutputConverter : public edm::stream::EDProducer<> {
private:
void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;

const edm::EDGetTokenT<LSTOutput> lstOutputToken_;
const edm::EDGetTokenT<lst::TrackCandidatesBaseHostCollection> lstOutputToken_;
const edm::EDGetTokenT<lst::LSTInputHostCollection> lstInputToken_;
const edm::EDGetTokenT<TrajectorySeedCollection> lstPixelSeedToken_;
const bool includeT5s_;
Expand Down Expand Up @@ -120,41 +120,55 @@ void LSTOutputConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSet
auto const& propOppo = iSetup.getData(propagatorOppositeToken_);
auto const& tracker = iSetup.getData(tGeomToken_);

// Vector definitions
std::vector<std::vector<unsigned int>> const& lstTC_hitIdx = lstOutput.hitIdx();
std::vector<unsigned int> const& lstTC_len = lstOutput.len();
std::vector<int> const& lstTC_seedIdx = lstOutput.seedIdx();
std::vector<short> const& lstTC_trackCandidateType = lstOutput.trackCandidateType();
auto lstOutput_view = lstOutput.const_view();
unsigned int nTrackCandidates = lstOutput_view.nTrackCandidates();

TrajectorySeedCollection outputTS, outputpLSTS;
outputTS.reserve(lstTC_len.size());
outputpLSTS.reserve(lstTC_len.size());
outputTS.reserve(nTrackCandidates);
outputpLSTS.reserve(nTrackCandidates);
TrackCandidateCollection outputTC, outputpTC, outputT5TC, outputNopLSTC, outputpTTC, outputpLSTC;
outputTC.reserve(lstTC_len.size());
outputpTC.reserve(lstTC_len.size());
outputT5TC.reserve(lstTC_len.size());
outputNopLSTC.reserve(lstTC_len.size());
outputpTTC.reserve(lstTC_len.size());
outputpLSTC.reserve(lstTC_len.size());
outputTC.reserve(nTrackCandidates);
outputpTC.reserve(nTrackCandidates);
outputT5TC.reserve(nTrackCandidates);
outputNopLSTC.reserve(nTrackCandidates);
outputpTTC.reserve(nTrackCandidates);
outputpLSTC.reserve(nTrackCandidates);

auto OTHits = lstInputHC.const_view<lst::HitsBaseSoA>().hits();

LogDebug("LSTOutputConverter") << "lstTC size " << lstTC_len.size();
for (unsigned int i = 0; i < lstTC_len.size(); i++) {
LogDebug("LSTOutputConverter") << " cand " << i << " " << lstTC_len[i] << " " << lstTC_seedIdx[i];
LogDebug("LSTOutputConverter") << "nTrackCandidates " << nTrackCandidates;
for (unsigned int i = 0; i < nTrackCandidates; i++) {
LogDebug("LSTOutputConverter") << " cand " << i << " " << lstOutput_view.trackCandidateType()[i] << " "
<< lstOutput_view.pixelSeedIndex()[i];
TrajectorySeed seed;
if (lstTC_trackCandidateType[i] != LSTOutput::LSTTCType::T5)
seed = pixelSeeds[lstTC_seedIdx[i]];
if (lstOutput_view.trackCandidateType()[i] != lst::LSTObjType::T5)
seed = pixelSeeds[lstOutput_view.pixelSeedIndex()[i]];

edm::OwnVector<TrackingRecHit> recHits;
if (lstTC_trackCandidateType[i] != LSTOutput::LSTTCType::T5) {
if (lstOutput_view.trackCandidateType()[i] != lst::LSTObjType::T5) {
for (auto const& hit : seed.recHits())
recHits.push_back(hit.clone());
}

unsigned int const nPixelHits = lstTC_trackCandidateType[i] == LSTOutput::LSTTCType::T5 ? 0 : recHits.size();
for (unsigned int j = nPixelHits; j < lstTC_hitIdx[i].size(); j++)
recHits.push_back(OTHits[lstTC_hitIdx[i][j]]->clone());
// pixel-seeded TCs from LST always have 4 pixel hits
unsigned int const nPixelHits = lstOutput_view.trackCandidateType()[i] == lst::LSTObjType::T5 ? 0 : 4;
unsigned int nHits = 0;
switch (lstOutput_view.trackCandidateType()[i]) {
case lst::LSTObjType::T5:
nHits = lst::Params_T5::kHits;
break;
case lst::LSTObjType::pT3:
nHits = lst::Params_pT3::kHits;
break;
case lst::LSTObjType::pT5:
nHits = lst::Params_pT5::kHits;
break;
case lst::LSTObjType::pLS:
nHits = lst::Params_pLS::kHits;
break;
}
for (unsigned int j = nPixelHits; j < nHits; j++)
recHits.push_back(OTHits[lstOutput_view.hitIndices()[i][j]]->clone());

recHits.sort([](const auto& a, const auto& b) {
const auto asub = a.det()->subDetector();
Expand All @@ -177,33 +191,34 @@ void LSTOutputConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSet
});

TrajectorySeedCollection seeds;
if (lstTC_trackCandidateType[i] != LSTOutput::LSTTCType::pLS) {
if (lstOutput_view.trackCandidateType()[i] != lst::LSTObjType::pLS) {
// Construct a full-length TrajectorySeed always for T5s,
// only when required by a flag for other pT objects.
if (includeNonpLSTSs_ || lstTC_trackCandidateType[i] == LSTOutput::LSTTCType::T5) {
if (includeNonpLSTSs_ || lstOutput_view.trackCandidateType()[i] == lst::LSTObjType::T5) {
using Hit = SeedingHitSet::ConstRecHitPointer;
std::vector<Hit> hitsForSeed;
hitsForSeed.reserve(lstTC_len[i]);
int nHits = 0;
hitsForSeed.reserve(nHits);
int n = 0;
for (auto const& hit : recHits) {
if (lstTC_trackCandidateType[i] == LSTOutput::LSTTCType::T5) {
if (lstOutput_view.trackCandidateType()[i] == lst::LSTObjType::T5) {
auto hType = tracker.getDetectorType(hit.geographicalId());
if (hType != TrackerGeometry::ModuleType::Ph2PSP && nHits < 2)
if (hType != TrackerGeometry::ModuleType::Ph2PSP && n < 2)
continue; // the first two should be P
}
hitsForSeed.emplace_back(dynamic_cast<Hit>(&hit));
nHits++;
n++;
}
GlobalTrackingRegion region;
seedCreator_->init(region, iSetup, nullptr);
seedCreator_->makeSeed(seeds, hitsForSeed);
if (seeds.empty()) {
edm::LogInfo("LSTOutputConverter")
<< "failed to convert a LST object to a seed" << i << " " << lstTC_len[i] << " " << lstTC_seedIdx[i];
if (lstTC_trackCandidateType[i] == LSTOutput::LSTTCType::T5)
<< "failed to convert a LST object to a seed" << i << " " << lstOutput_view.trackCandidateType()[i] << " "
<< lstOutput_view.pixelSeedIndex()[i];
if (lstOutput_view.trackCandidateType()[i] == lst::LSTObjType::T5)
continue;
}
if (lstTC_trackCandidateType[i] == LSTOutput::LSTTCType::T5)
if (lstOutput_view.trackCandidateType()[i] == lst::LSTObjType::T5)
seed = seeds[0];

auto trajectorySeed = (seeds.empty() ? seed : seeds[0]);
Expand All @@ -229,7 +244,7 @@ void LSTOutputConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSet
PTrajectoryStateOnDet st =
trajectoryStateTransform::persistentState(tsosPair.first, recHits[0].det()->geographicalId().rawId());

if (lstTC_trackCandidateType[i] == LSTOutput::LSTTCType::T5) {
if (lstOutput_view.trackCandidateType()[i] == lst::LSTObjType::T5) {
if (!includeT5s_) {
continue;
} else {
Expand All @@ -242,7 +257,7 @@ void LSTOutputConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSet
auto tc = TrackCandidate(recHits, seed, st);
outputTC.emplace_back(tc);
outputpTC.emplace_back(tc);
if (lstTC_trackCandidateType[i] != LSTOutput::LSTTCType::pLS) {
if (lstOutput_view.trackCandidateType()[i] != lst::LSTObjType::pLS) {
outputNopLSTC.emplace_back(tc);
outputpTTC.emplace_back(tc);
} else {
Expand All @@ -251,8 +266,9 @@ void LSTOutputConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSet
}
} else {
edm::LogInfo("LSTOutputConverter") << "Failed to make a candidate initial state. Seed state is " << tsos
<< " TC cand " << i << " " << lstTC_len[i] << " " << lstTC_seedIdx[i]
<< " first hit " << recHits.front().globalPosition() << " last hit "
<< " TC cand " << i << " " << lstOutput_view.pixelSeedIndex()[i] << " "
<< lstOutput_view.pixelSeedIndex()[i] << " first hit "
<< recHits.front().globalPosition() << " last hit "
<< recHits.back().globalPosition();
}
}
Expand All @@ -271,4 +287,4 @@ void LSTOutputConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSet
iEvent.emplace(seedStopInfoPutToken_, std::move(outputSeedStopInfo)); //dummy stop info
}

DEFINE_FWK_MODULE(LSTOutputConverter);
DEFINE_FWK_MODULE(LSTOutputConverter);
44 changes: 20 additions & 24 deletions RecoTracker/LST/plugins/alpaka/LSTProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/EDPutToken.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/Event.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/EventSetup.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/stream/SynchronizingEDProducer.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/global/EDProducer.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"

#include "RecoTracker/LST/interface/LSTOutput.h"
#include "RecoTracker/LSTCore/interface/alpaka/TrackCandidatesDeviceCollection.h"

#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE {

class LSTProducer : public stream::SynchronizingEDProducer<> {
class LSTProducer : public global::EDProducer<> {
public:
LSTProducer(edm::ParameterSet const& config)
: SynchronizingEDProducer(config),
: EDProducer(config),
lstInputToken_{consumes(config.getParameter<edm::InputTag>("lstInput"))},
lstESToken_{esConsumes(edm::ESInputTag("", config.getParameter<std::string>("ptCutLabel")))},
verbose_(config.getParameter<bool>("verbose")),
Expand All @@ -33,25 +33,23 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
tcpLSTriplets_(config.getParameter<bool>("tcpLSTriplets")),
lstOutputToken_{produces()} {}

void acquire(device::Event const& event, device::EventSetup const& setup) override {
void produce(edm::StreamID sid, device::Event& iEvent, const device::EventSetup& iSetup) const override {
lst::LST lst;
// Inputs
auto const& lstInputDC = event.get(lstInputToken_);
auto const& lstInputDC = iEvent.get(lstInputToken_);
auto const& lstESDeviceData = iSetup.getData(lstESToken_);

auto const& lstESDeviceData = setup.getData(lstESToken_);
lst.run(iEvent.queue(),
verbose_,
static_cast<float>(ptCut_),
&lstESDeviceData,
&lstInputDC,
nopLSDupClean_,
tcpLSTriplets_);

lst_.run(event.queue(),
verbose_,
static_cast<float>(ptCut_),
&lstESDeviceData,
&lstInputDC,
nopLSDupClean_,
tcpLSTriplets_);
}

void produce(device::Event& event, device::EventSetup const&) override {
// Output
LSTOutput lstOutput(lst_.hits(), lst_.len(), lst_.seedIdx(), lst_.trackCandidateType());
event.emplace(lstOutputToken_, std::move(lstOutput));
auto lstTrackCandidates = lst.getTrackCandidates();
iEvent.emplace(lstOutputToken_, std::move(*lstTrackCandidates.release()));
}

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
Expand All @@ -66,15 +64,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
}

private:
device::EDGetToken<lst::LSTInputDeviceCollection> lstInputToken_;
device::ESGetToken<lst::LSTESData<Device>, TrackerRecoGeometryRecord> lstESToken_;
const device::EDGetToken<lst::LSTInputDeviceCollection> lstInputToken_;
const device::ESGetToken<lst::LSTESData<Device>, TrackerRecoGeometryRecord> lstESToken_;
const bool verbose_;
const double ptCut_;
const bool nopLSDupClean_;
const bool tcpLSTriplets_;
edm::EDPutTokenT<LSTOutput> lstOutputToken_;

lst::LST lst_;
const device::EDPutToken<lst::TrackCandidatesBaseDeviceCollection> lstOutputToken_;
};

} // namespace ALPAKA_ACCELERATOR_NAMESPACE
Expand Down
7 changes: 0 additions & 7 deletions RecoTracker/LST/src/classes.h

This file was deleted.

4 changes: 0 additions & 4 deletions RecoTracker/LST/src/classes_def.xml

This file was deleted.

8 changes: 7 additions & 1 deletion RecoTracker/LSTCore/interface/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace lst {
enum PixelType : int8_t { kInvalid = -1, kHighPt = 0, kLowPtPosCurv = 1, kLowPtNegCurv = 2 };

// Named types for LST objects
enum LSTObjType { T5 = 4, pT3 = 5, pT5 = 7, pLS = 8 };
enum LSTObjType : int8_t { T5 = 4, pT3 = 5, pT5 = 7, pLS = 8 };

constexpr unsigned int max_blocks = 80;
constexpr unsigned int max_connected_modules = 40;
Expand Down Expand Up @@ -87,6 +87,12 @@ namespace lst {
using ArrayU16xLayers = edm::StdArray<uint16_t, kLayers>;
using ArrayUxHits = edm::StdArray<unsigned int, kHits>;
};
struct Params_TC {
static constexpr int kLayers = 7, kHits = 14;
using ArrayU8xLayers = edm::StdArray<uint8_t, kLayers>;
using ArrayU16xLayers = edm::StdArray<uint16_t, kLayers>;
using ArrayUxHits = edm::StdArray<unsigned int, kHits>;
};

using ArrayIx2 = edm::StdArray<int, 2>;
using ArrayUx2 = edm::StdArray<unsigned int, 2>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "DataFormats/Portable/interface/PortableHostCollection.h"

namespace lst {
using TrackCandidatesHostCollection = PortableHostCollection<TrackCandidatesSoA>;
using TrackCandidatesBaseHostCollection = PortableHostCollection<TrackCandidatesBaseSoA>;
using TrackCandidatesExtendedHostCollection = PortableHostCollection<TrackCandidatesExtendedSoA>;
} // namespace lst
#endif
Loading