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
4 changes: 2 additions & 2 deletions DQM/SiPixelHeterogeneous/plugins/SiPixelCompareRecHits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ void SiPixelCompareRecHits::analyzeSeparate(U tokenRef, V tokenTar, const edm::E
const auto& rhsoaRef = *rhsoaHandleRef;
const auto& rhsoaTar = *rhsoaHandleTar;

auto const& soa2dRef = rhsoaRef.const_view();
auto const& soa2dTar = rhsoaTar.const_view();
auto const& soa2dRef = rhsoaRef.const_view().trackingHits();
auto const& soa2dTar = rhsoaTar.const_view().trackingHits();

uint32_t nHitsRef = soa2dRef.metadata().size();
uint32_t nHitsTar = soa2dTar.metadata().size();
Expand Down
70 changes: 36 additions & 34 deletions DQM/SiPixelHeterogeneous/plugins/SiPixelCompareTracks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,14 @@ void SiPixelCompareTracks::analyzeSeparate(U tokenRef, V tokenTar, const edm::Ev
auto const& tsoaRef = *tsoaHandleRef;
auto const& tsoaTar = *tsoaHandleTar;

auto maxTracksRef = tsoaRef.view().metadata().size(); //this should be same for both?
auto maxTracksTar = tsoaTar.view().metadata().size(); //this should be same for both?
auto refTracks = tsoaRef.view().tracks();
auto tarTracks = tsoaTar.view().tracks();

auto const qualityRef = tsoaRef.view().quality();
auto const qualityTar = tsoaTar.view().quality();
auto maxTracksRef = refTracks.metadata().size(); //this should be same for both?
auto maxTracksTar = tarTracks.metadata().size(); //this should be same for both?

auto const qualityRef = refTracks.quality();
auto const qualityTar = tarTracks.quality();

int32_t nTracksRef = 0;
int32_t nTracksTar = 0;
Expand All @@ -178,9 +181,9 @@ void SiPixelCompareTracks::analyzeSeparate(U tokenRef, V tokenTar, const edm::Ev
//Loop over Tar tracks and store the indices of the loose tracks. Whats happens if useQualityCut_ is false?
std::vector<int32_t> looseTrkidxTar;
for (int32_t jt = 0; jt < maxTracksTar; ++jt) {
if (reco::nHits(tsoaTar.view(), jt) == 0)
if (reco::nHits(tarTracks, jt) == 0)
break; // this is a guard
if (!(tsoaTar.view()[jt].pt() > 0.))
if (!(tarTracks[jt].pt() > 0.))
continue;
nTracksTar++;
if (useQualityCut_ && qualityTar[jt] < minQuality_)
Expand All @@ -191,17 +194,17 @@ void SiPixelCompareTracks::analyzeSeparate(U tokenRef, V tokenTar, const edm::Ev

//Now loop over Ref tracks//nested loop for loose gPU tracks
for (int32_t it = 0; it < maxTracksRef; ++it) {
int nHitsRef = reco::nHits(tsoaRef.view(), it);
int nHitsRef = reco::nHits(refTracks, it);

if (nHitsRef == 0)
break; // this is a guard

float ptRef = tsoaRef.view()[it].pt();
float etaRef = tsoaRef.view()[it].eta();
float phiRef = reco::phi(tsoaRef.view(), it);
float zipRef = reco::zip(tsoaRef.view(), it);
float tipRef = reco::tip(tsoaRef.view(), it);
auto qRef = reco::charge(tsoaRef.view(), it);
float ptRef = refTracks[it].pt();
float etaRef = refTracks[it].eta();
float phiRef = reco::phi(refTracks, it);
float zipRef = reco::zip(refTracks, it);
float tipRef = reco::tip(refTracks, it);
auto qRef = reco::charge(refTracks, it);

if (!(ptRef > 0.))
continue;
Expand All @@ -215,8 +218,8 @@ void SiPixelCompareTracks::analyzeSeparate(U tokenRef, V tokenTar, const edm::Ev
float mindr2 = dr2cut_;

for (auto gid : looseTrkidxTar) {
float etaTar = tsoaTar.view()[gid].eta();
float phiTar = reco::phi(tsoaTar.view(), gid);
float etaTar = tarTracks[gid].eta();
float phiTar = reco::phi(tarTracks, gid);
float dr2 = reco::deltaR2(etaRef, phiRef, etaTar, phiTar);
if (dr2 > dr2cut_)
continue; // this is arbitrary
Expand All @@ -232,25 +235,24 @@ void SiPixelCompareTracks::analyzeSeparate(U tokenRef, V tokenTar, const edm::Ev
continue;
nLooseAndAboveTracksRef_matchedTar++;

hchi2_->Fill(tsoaRef.view()[it].chi2(), tsoaTar.view()[closestTkidx].chi2());
hCharge_->Fill(qRef, reco::charge(tsoaTar.view(), closestTkidx));
hnHits_->Fill(reco::nHits(tsoaRef.view(), it), reco::nHits(tsoaTar.view(), closestTkidx));
hnLayers_->Fill(tsoaRef.view()[it].nLayers(), tsoaTar.view()[closestTkidx].nLayers());
hpt_->Fill(ptRef, tsoaTar.view()[closestTkidx].pt());
hCurvature_->Fill(qRef / ptRef, reco::charge(tsoaTar.view(), closestTkidx) / tsoaTar.view()[closestTkidx].pt());
hptLogLog_->Fill(ptRef, tsoaTar.view()[closestTkidx].pt());
heta_->Fill(etaRef, tsoaTar.view()[closestTkidx].eta());
hphi_->Fill(phiRef, reco::phi(tsoaTar.view(), closestTkidx));
hz_->Fill(zipRef, reco::zip(tsoaTar.view(), closestTkidx));
htip_->Fill(tipRef, reco::tip(tsoaTar.view(), closestTkidx));
hptdiffMatched_->Fill(ptRef - tsoaTar.view()[closestTkidx].pt());
hCurvdiffMatched_->Fill(qRef / ptRef -
(reco::charge(tsoaTar.view(), closestTkidx) / tsoaTar.view()[closestTkidx].pt()));
hetadiffMatched_->Fill(etaRef - tsoaTar.view()[closestTkidx].eta());
hphidiffMatched_->Fill(reco::deltaPhi(phiRef, reco::phi(tsoaTar.view(), closestTkidx)));
hzdiffMatched_->Fill(zipRef - reco::zip(tsoaTar.view(), closestTkidx));
htipdiffMatched_->Fill(tipRef - reco::tip(tsoaTar.view(), closestTkidx));
hpt_eta_tkAllRefMatched_->Fill(etaRef, tsoaRef.view()[it].pt()); //matched to gpu
hchi2_->Fill(refTracks[it].chi2(), tarTracks[closestTkidx].chi2());
hCharge_->Fill(qRef, reco::charge(tarTracks, closestTkidx));
hnHits_->Fill(reco::nHits(refTracks, it), reco::nHits(tarTracks, closestTkidx));
hnLayers_->Fill(refTracks[it].nLayers(), tarTracks[closestTkidx].nLayers());
hpt_->Fill(ptRef, tarTracks[closestTkidx].pt());
hCurvature_->Fill(qRef / ptRef, reco::charge(tarTracks, closestTkidx) / tarTracks[closestTkidx].pt());
hptLogLog_->Fill(ptRef, tarTracks[closestTkidx].pt());
heta_->Fill(etaRef, tarTracks[closestTkidx].eta());
hphi_->Fill(phiRef, reco::phi(tarTracks, closestTkidx));
hz_->Fill(zipRef, reco::zip(tarTracks, closestTkidx));
htip_->Fill(tipRef, reco::tip(tarTracks, closestTkidx));
hptdiffMatched_->Fill(ptRef - tarTracks[closestTkidx].pt());
hCurvdiffMatched_->Fill(qRef / ptRef - (reco::charge(tarTracks, closestTkidx) / tarTracks[closestTkidx].pt()));
hetadiffMatched_->Fill(etaRef - tarTracks[closestTkidx].eta());
hphidiffMatched_->Fill(reco::deltaPhi(phiRef, reco::phi(tarTracks, closestTkidx)));
hzdiffMatched_->Fill(zipRef - reco::zip(tarTracks, closestTkidx));
htipdiffMatched_->Fill(tipRef - reco::tip(tarTracks, closestTkidx));
hpt_eta_tkAllRefMatched_->Fill(etaRef, refTracks[it].pt()); //matched to gpu
hphi_z_tkAllRefMatched_->Fill(etaRef, zipRef);
}

Expand Down
33 changes: 17 additions & 16 deletions DQM/SiPixelHeterogeneous/plugins/SiPixelCompareVertices.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class SiPixelCompareVertices : public DQMEDAnalyzer {

private:
// these two are both on Host but originally they have been produced on Host or on Device
const edm::EDGetTokenT<ZVertexHost> tokenSoAVertexReferenceSoA_;
const edm::EDGetTokenT<ZVertexHost> tokenSoAVertexTargetSoA_;
const edm::EDGetTokenT<reco::ZVertexHost> tokenSoAVertexReferenceSoA_;
const edm::EDGetTokenT<reco::ZVertexHost> tokenSoAVertexTargetSoA_;
const edm::EDGetTokenT<reco::BeamSpot> tokenBeamSpot_;
const std::string topFolderName_;
const float dzCut_;
Expand All @@ -63,8 +63,9 @@ class SiPixelCompareVertices : public DQMEDAnalyzer {

SiPixelCompareVertices::SiPixelCompareVertices(const edm::ParameterSet& iConfig)
: tokenSoAVertexReferenceSoA_(
consumes<ZVertexHost>(iConfig.getParameter<edm::InputTag>("pixelVertexReferenceSoA"))),
tokenSoAVertexTargetSoA_(consumes<ZVertexHost>(iConfig.getParameter<edm::InputTag>("pixelVertexTargetSoA"))),
consumes<reco::ZVertexHost>(iConfig.getParameter<edm::InputTag>("pixelVertexReferenceSoA"))),
tokenSoAVertexTargetSoA_(
consumes<reco::ZVertexHost>(iConfig.getParameter<edm::InputTag>("pixelVertexTargetSoA"))),
tokenBeamSpot_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpotSrc"))),
topFolderName_(iConfig.getParameter<std::string>("topFolderName")),
dzCut_(iConfig.getParameter<double>("dzCut")) {}
Expand All @@ -87,9 +88,9 @@ void SiPixelCompareVertices::analyzeSeparate(U tokenRef, V tokenTar, const edm::
}

auto const& vsoaRef = *vsoaHandleRef;
int nVerticesRef = vsoaRef.view().nvFinal();
int nVerticesRef = vsoaRef.view().zvertex().nvFinal();
auto const& vsoaTar = *vsoaHandleTar;
int nVerticesTar = vsoaTar.view().nvFinal();
int nVerticesTar = vsoaTar.view().zvertex().nvFinal();

auto bsHandle = iEvent.getHandle(tokenBeamSpot_);
float x0 = 0., y0 = 0., z0 = 0., dxdz = 0., dydz = 0.;
Expand All @@ -105,22 +106,22 @@ void SiPixelCompareVertices::analyzeSeparate(U tokenRef, V tokenTar, const edm::
}

for (int ivc = 0; ivc < nVerticesRef; ivc++) {
auto sic = vsoaRef.view()[ivc].sortInd();
auto zc = vsoaRef.view()[sic].zv();
auto sic = vsoaRef.view().zvertex()[ivc].sortInd();
auto zc = vsoaRef.view().zvertex()[sic].zv();
auto xc = x0 + dxdz * zc;
auto yc = y0 + dydz * zc;
zc += z0;

auto ndofRef = vsoaRef.template view<reco::ZVertexTracksSoA>()[sic].ndof();
auto chi2Ref = vsoaRef.view()[sic].chi2();
auto ndofRef = vsoaRef.view().zvertexTracks()[sic].ndof();
auto chi2Ref = vsoaRef.view().zvertex()[sic].chi2();

const int32_t notFound = -1;
int32_t closestVtxidx = notFound;
float mindz = dzCut_;

for (int ivg = 0; ivg < nVerticesTar; ivg++) {
auto sig = vsoaTar.view()[ivg].sortInd();
auto zgc = vsoaTar.view()[sig].zv() + z0;
auto sig = vsoaTar.view().zvertex()[ivg].sortInd();
auto zgc = vsoaTar.view().zvertex()[sig].zv() + z0;
auto zDist = std::abs(zc - zgc);
//insert some matching condition
if (zDist > dzCut_)
Expand All @@ -133,12 +134,12 @@ void SiPixelCompareVertices::analyzeSeparate(U tokenRef, V tokenTar, const edm::
if (closestVtxidx == notFound)
continue;

auto zg = vsoaTar.view()[closestVtxidx].zv();
auto zg = vsoaTar.view().zvertex()[closestVtxidx].zv();
auto xg = x0 + dxdz * zg;
auto yg = y0 + dydz * zg;
zg += z0;
auto ndofTar = vsoaTar.template view<reco::ZVertexTracksSoA>()[closestVtxidx].ndof();
auto chi2Tar = vsoaTar.view()[closestVtxidx].chi2();
auto ndofTar = vsoaTar.view().zvertexTracks()[closestVtxidx].ndof();
auto chi2Tar = vsoaTar.view().zvertex()[closestVtxidx].chi2();

hx_->Fill(xc - x0, xg - x0);
hy_->Fill(yc - y0, yg - y0);
Expand All @@ -148,7 +149,7 @@ void SiPixelCompareVertices::analyzeSeparate(U tokenRef, V tokenTar, const edm::
hzdiff_->Fill(zc - zg);
hchi2_->Fill(chi2Ref, chi2Tar);
hchi2oNdof_->Fill(chi2Ref / ndofRef, chi2Tar / ndofTar);
hptv2_->Fill(vsoaRef.view()[sic].ptv2(), vsoaTar.view()[closestVtxidx].ptv2());
hptv2_->Fill(vsoaRef.view().zvertex()[sic].ptv2(), vsoaTar.view().zvertex()[closestVtxidx].ptv2());
hntrks_->Fill(ndofRef + 1, ndofTar + 1);
}
hnVertex_->Fill(nVerticesRef, nVerticesTar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void SiPixelMonitorRecHitsSoAAlpaka::analyze(const edm::Event& iEvent, const edm
return;
}
auto const& rhsoa = *rhsoaHandle;
auto const& soa2d = rhsoa.const_view();
auto const& soa2d = rhsoa.const_view().trackingHits();

uint32_t nHits_ = soa2d.metadata().size();
hnHits->Fill(nHits_);
Expand Down
24 changes: 12 additions & 12 deletions DQM/SiPixelHeterogeneous/plugins/SiPixelMonitorTrackSoAAlpaka.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ void SiPixelMonitorTrackSoAAlpaka::analyze(const edm::Event& iEvent, const edm::
}

auto const& tsoa = *tsoaHandle.product();
auto maxTracks = tsoa.view().metadata().size();
auto const quality = tsoa.view().quality();
auto maxTracks = tsoa.view().tracks().metadata().size();
auto const quality = tsoa.view().tracks().quality();
int32_t nTracks = 0;
int32_t nLooseAndAboveTracks = 0;

for (int32_t it = 0; it < maxTracks; ++it) {
auto nHits = reco::nHits(tsoa.const_view(), it);
auto nLayers = tsoa.view()[it].nLayers();
auto nHits = reco::nHits(tsoa.const_view().tracks(), it);
auto nLayers = tsoa.view().tracks()[it].nLayers();
if (nHits == 0)
break; // this is a guard
float pt = tsoa.view()[it].pt();
float pt = tsoa.view().tracks()[it].pt();
if (!(pt > 0.))
continue;

Expand All @@ -106,13 +106,13 @@ void SiPixelMonitorTrackSoAAlpaka::analyze(const edm::Event& iEvent, const edm::
continue;

// fill parameters only for quality >= loose

float chi2 = tsoa.view()[it].chi2();
float phi = tsoa.view()[it].state()(0); //TODO: put these numbers in enum
float zip = tsoa.view()[it].state()(4);
float eta = tsoa.view()[it].eta();
float tip = tsoa.view()[it].state()(1);
auto charge = reco::charge(tsoa.view(), it);
auto track = tsoa.view().tracks()[it];
float chi2 = track.chi2();
float phi = track.state()(0); //TODO: put these numbers in enum
float zip = track.state()(4);
float eta = track.eta();
float tip = track.state()(1);
auto charge = reco::charge(tsoa.view().tracks(), it);

hchi2->Fill(chi2);
hChi2VsPhi->Fill(phi, chi2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SiPixelMonitorVertexSoAAlpaka : public DQMEDAnalyzer {
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
const edm::EDGetTokenT<ZVertexHost> tokenSoAVertex_;
const edm::EDGetTokenT<reco::ZVertexHost> tokenSoAVertex_;
const edm::EDGetTokenT<reco::BeamSpot> tokenBeamSpot_;
std::string topFolderName_;
MonitorElement* hnVertex;
Expand All @@ -52,7 +52,7 @@ class SiPixelMonitorVertexSoAAlpaka : public DQMEDAnalyzer {
//

SiPixelMonitorVertexSoAAlpaka::SiPixelMonitorVertexSoAAlpaka(const edm::ParameterSet& iConfig)
: tokenSoAVertex_(consumes<ZVertexHost>(iConfig.getParameter<edm::InputTag>("pixelVertexSrc"))),
: tokenSoAVertex_(consumes<reco::ZVertexHost>(iConfig.getParameter<edm::InputTag>("pixelVertexSrc"))),
tokenBeamSpot_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpotSrc"))),
topFolderName_(iConfig.getParameter<std::string>("topFolderName")) {}

Expand All @@ -67,8 +67,8 @@ void SiPixelMonitorVertexSoAAlpaka::analyze(const edm::Event& iEvent, const edm:
}

auto const& vsoa = *vsoaHandle;
auto vtx_view = vsoa.view<reco::ZVertexSoA>();
auto trk_view = vsoa.view<reco::ZVertexTracksSoA>();
auto vtx_view = vsoa.view().zvertex();
auto trk_view = vsoa.view().zvertexTracks();
int nVertices = vtx_view.nvFinal();
auto bsHandle = iEvent.getHandle(tokenBeamSpot_);
float x0 = 0., y0 = 0., z0 = 0., dxdz = 0., dydz = 0.;
Expand Down
4 changes: 0 additions & 4 deletions DataFormats/HGCalDigi/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@
<class name="hgcaldigi::HGCalDigiSoALayout<128,false>"/>
<class name="edm::Wrapper<PortableHostCollection<hgcaldigi::HGCalDigiSoALayout<128,false> > >" splitLevel="0"/>

<!-- Recursive templates implementing the association of indices and layouts, and containing the data -->
<class name="portablecollection::CollectionLeaf<0, hgcaldigi::HGCalDigiSoALayout<128, false>>"/>

<class name="hgcaldigi::HGCalECONDPacketInfoHost" rntupleStreamerMode="true"/>
<!-- ::Layout alias must be listed before the aliased-to type -->
<class name="hgcaldigi::HGCalECONDPacketInfoHost::Layout"/>
Expand All @@ -74,6 +71,5 @@
<class name="hgcaldigi::HGCalDigiTriggerSoA::View"/>
<class name="hgcaldigi::HGCalDigiTriggerSoALayout<128,false>"/>
<class name="edm::Wrapper<PortableHostCollection<hgcaldigi::HGCalDigiTriggerSoALayout<128,false> > >" splitLevel="0"/>
<class name="portablecollection::CollectionLeaf<0, hgcaldigi::HGCalDigiTriggerSoALayout<128, false>>"/>

</lcgdict>
28 changes: 14 additions & 14 deletions DataFormats/Portable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,13 @@ Modules that implement portable interfaces (_e.g._ producers) should use the gen

## Multi layout collections

Some use cases require multiple sets of columns of different sizes. This is can be achieved in a single
`PortableCollection` using `PortableCollection2<T1, T2>`, `PortableCollection3<T1, T2, T3>` and so on up to
`PortableCollection5<...>`. The numbered, fixed size wrappers are needed in order to be added to the ROOT dictionary.
Behind the scenes recursive `PortableHostMultiCollection<T0, ...>` and
`ALPAKA_ACCELERATOR_NAMESPACE::PortableDeviceMultiCollection<TDev, T0, ...>` (note the reversed parameter order) provide
the actual class definitions.
Multiple SoA layouts can be concatenated using the `GENERATE_SOA_BLOCKS` macro (see `DataFormats/SoATemplate` for details).
This macro generates a new composite layout that contains other layouts as members
and manages a single contiguous memory buffer large enough to hold all of them.

A `PortableCollection` can then be templated on this `SoABlocks` layout.
In this case, the `view` and `const_view` methods return composite views that themselves contain views of each sublayout.


## ROOT dictionary declaration helper scripts

Expand All @@ -161,17 +162,16 @@ as instructed in `<module>/src/classes_dev.xml` and `<module>/src/alpaka/classes
`<module>/src/alpaka/classes_rocm_def.xml`. Two scripts generate the code to be added to the xml files.
Both scripts expect the collections to be aliased as in:
```
using TestDeviceMultiCollection3 = PortableCollection3<TestSoA, TestSoA2, TestSoA3>;
using TestDeviceCollection3 = PortableCollection<TestSoABlocks3>;
```
and assume the `TestDeviceMultiCollection3` is used in the `SET_PORTABLEHOSTMULTICOLLECTION_READ_RULES()` macro.

For the host xml, SoA layouts have to be listed and duplicates should be removed manually is multiple
collections share a same layout. The scripts are called as follows:
In the example here the `TestSoABlocks3` template is an SoABlocks layout composed of three layouts.
For the host xml, all SoA layouts have to be listed. The scripts are called as follows:
```
./DataFormats/Portable/scripts/portableHostCollectionHints portabletest::TestHostMultiCollection3 \
portabletest::TestSoALayout portabletest::TestSoALayout2 portabletest::TestSoALayout3
./DataFormats/Portable/scripts/portableHostCollectionHints portabletest::TestHostCollection3 \
portabletest::TestSoALayout portabletest::TestSoALayout2 portabletest::TestSoALayout3 portabletest::SoABlocks3

./DataFormats/Portable/scripts/portableDeviceCollectionHints portabletest::TestHostMultiCollection3
```
The layouts should not be added as parameters for the device collection. Those script can be use equally with the
single layout collections or multi layout collections.
The layouts should not be added as parameters for the device collection. Those script can be used equally with the
single layout collections or multi layout collections.
Loading