Skip to content

Commit 691c5b0

Browse files
authored
Merge pull request #47461 from SegmentLinking/ariostas/fix_bugs
Minor fixes to LST standalone code
2 parents 059eb10 + 1564fd7 commit 691c5b0

File tree

5 files changed

+24
-30
lines changed

5 files changed

+24
-30
lines changed

RecoTracker/LSTCore/src/alpaka/Hit.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,16 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
6262
alpaka::math::acosh(
6363
acc, alpaka::math::sqrt(acc, ihit_x * ihit_x + ihit_y * ihit_y + ihit_z * ihit_z) / hits.rts()[ihit]);
6464
auto found_pointer = alpaka_std::lower_bound(modules.mapdetId(), modules.mapdetId() + nModules, iDetId);
65+
ALPAKA_ASSERT_ACC(found_pointer != modules.mapdetId() + nModules);
6566
int found_index = std::distance(modules.mapdetId(), found_pointer);
66-
if (found_pointer == modules.mapdetId() + nModules)
67-
found_index = -1;
6867
uint16_t lastModuleIndex = modules.mapIdx()[found_index];
6968

7069
hits.moduleIndices()[ihit] = lastModuleIndex;
7170

7271
if (modules.subdets()[lastModuleIndex] == Endcap && modules.moduleType()[lastModuleIndex] == TwoS) {
7372
found_pointer = alpaka_std::lower_bound(geoMapDetId, geoMapDetId + nEndCapMap, iDetId);
73+
ALPAKA_ASSERT_ACC(found_pointer != geoMapDetId + nEndCapMap);
7474
found_index = std::distance(geoMapDetId, found_pointer);
75-
if (found_pointer == geoMapDetId + nEndCapMap)
76-
found_index = -1;
7775
float phi = geoMapPhi[found_index];
7876
float cos_phi = alpaka::math::cos(acc, phi);
7977
hits.highEdgeXs()[ihit] = ihit_x + 2.5f * cos_phi;

RecoTracker/LSTCore/src/alpaka/LSTEvent.dev.cc

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,21 +1047,14 @@ void LSTEvent::addMiniDoubletsToEventExplicit() {
10471047
cms::alpakatools::make_device_view(queue_, modules.layers(), nLowerModules_); // only lower modules
10481048
alpaka::memcpy(queue_, module_layers_buf, module_layers_view, nLowerModules_);
10491049

1050-
auto module_hitRanges_buf = cms::alpakatools::make_host_buffer<ArrayIx2[]>(queue_, nLowerModules_);
1051-
auto hits = hitsDC_->view<HitsRangesSoA>();
1052-
auto hitRanges_view =
1053-
cms::alpakatools::make_device_view(queue_, hits.hitRanges(), nLowerModules_); // only lower modules
1054-
alpaka::memcpy(queue_, module_hitRanges_buf, hitRanges_view, nLowerModules_);
1055-
10561050
alpaka::wait(queue_); // wait for inputs before using them
10571051

10581052
auto const* nMDsCPU = nMDsCPU_buf.data();
10591053
auto const* module_subdets = module_subdets_buf.data();
10601054
auto const* module_layers = module_layers_buf.data();
1061-
auto const* module_hitRanges = module_hitRanges_buf.data();
10621055

10631056
for (unsigned int i = 0; i < nLowerModules_; i++) {
1064-
if (!(nMDsCPU[i] == 0 or module_hitRanges[i][0] == -1)) {
1057+
if (nMDsCPU[i] != 0) {
10651058
if (module_subdets[i] == Barrel) {
10661059
n_minidoublets_by_layer_barrel_[module_layers[i] - 1] += nMDsCPU[i];
10671060
} else {

RecoTracker/LSTCore/standalone/code/core/lst_math.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace lst_math {
7474
center_.push_back(center_vec_z);
7575

7676
// Lambda
77-
lam_ = copysign(M_PI / 2. - 2. * atan(exp(-abs(eta))), eta);
77+
lam_ = copysign(M_PI / 2. - 2. * atan(exp(-std::abs(eta))), eta);
7878
}
7979

8080
const std::vector<float> center() { return center_; }

RecoTracker/LSTCore/standalone/code/core/trkCore.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ int getDenomSimTrkType(int isimtrk) {
475475
return 1; // sim
476476
const float &pt = trk.sim_pt()[isimtrk];
477477
const float &eta = trk.sim_eta()[isimtrk];
478-
if (pt < 1 or abs(eta) > 2.4)
478+
if (pt < 1 or std::abs(eta) > 2.4)
479479
return 2; // sim and charged
480480
const int &bunch = trk.sim_bunchCrossing()[isimtrk];
481481
const int &event = trk.sim_event()[isimtrk];
@@ -486,7 +486,7 @@ int getDenomSimTrkType(int isimtrk) {
486486
const float &vtx_perp = sqrt(vtx_x * vtx_x + vtx_y * vtx_y);
487487
if (vtx_perp > 2.5)
488488
return 3; // pt > 1 and abs(eta) < 2.4
489-
if (abs(vtx_z) > 30)
489+
if (std::abs(vtx_z) > 30)
490490
return 4; // pt > 1 and abs(eta) < 2.4 and vtx < 2.5
491491
if (bunch != 0)
492492
return 5; // pt > 1 and abs(eta) < 2.4 and vtx < 2.5 and vtx < 300
@@ -546,7 +546,7 @@ float drfracSimHitConsistentWithHelix(lst_math::Helix &helix, int isimhitidx) {
546546
auto [x, y, z, r] = helix.get_helix_point(t);
547547

548548
// ( expected_r - simhit_r ) / expected_r
549-
float drfrac = abs(helix.compare_radius(point)) / r;
549+
float drfrac = std::abs(helix.compare_radius(point)) / r;
550550

551551
return drfrac;
552552
}

RecoTracker/LSTCore/standalone/efficiency/src/performance.cc

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ int main(int argc, char** argv) {
2525
};
2626
std::vector<std::function<bool(unsigned int)>> sels = {
2727
[&](unsigned int isim) { return 1.; },
28-
[&](unsigned int isim) { return abs(lstEff.sim_eta().at(isim)) < 2.4; },
29-
[&](unsigned int isim) { return abs(lstEff.sim_eta().at(isim)) > 1.1 and abs(lstEff.sim_eta().at(isim)) < 1.7; },
28+
[&](unsigned int isim) { return std::abs(lstEff.sim_eta().at(isim)) < 2.4; },
3029
[&](unsigned int isim) {
31-
return (abs(lstEff.sim_eta().at(isim)) < 1.1 or abs(lstEff.sim_eta().at(isim)) > 1.7) and
32-
abs(lstEff.sim_eta().at(isim)) < 2.4;
30+
return std::abs(lstEff.sim_eta().at(isim)) > 1.1 and std::abs(lstEff.sim_eta().at(isim)) < 1.7;
31+
},
32+
[&](unsigned int isim) {
33+
return (std::abs(lstEff.sim_eta().at(isim)) < 1.1 or std::abs(lstEff.sim_eta().at(isim)) > 1.7) and
34+
std::abs(lstEff.sim_eta().at(isim)) < 2.4;
3335
}};
3436
pdgids.insert(pdgids.end(), ana.pdgids.begin(), ana.pdgids.end());
3537

@@ -584,7 +586,7 @@ void fillEfficiencySet(int isimtrk, SimTrackSetDefinition& effset) {
584586
bool sel = effset.sel(isimtrk);
585587

586588
if (effset.pdgid != 0) {
587-
if (abs(pdgidtrk) != abs(effset.pdgid))
589+
if (std::abs(pdgidtrk) != std::abs(effset.pdgid))
588590
return;
589591
}
590592

@@ -607,7 +609,7 @@ void fillEfficiencySet(int isimtrk, SimTrackSetDefinition& effset) {
607609
const float vtx_perp_thresh = 2.5;
608610

609611
// N minus eta cut
610-
if (pt > ana.pt_cut and abs(vtx_z) < vtx_z_thresh and abs(vtx_perp) < vtx_perp_thresh) {
612+
if (pt > ana.pt_cut and std::abs(vtx_z) < vtx_z_thresh and std::abs(vtx_perp) < vtx_perp_thresh) {
611613
// vs. eta plot
612614
ana.tx.pushbackToBranch<float>(category_name + "_ef_denom_eta", eta);
613615
if (pass)
@@ -617,7 +619,7 @@ void fillEfficiencySet(int isimtrk, SimTrackSetDefinition& effset) {
617619
}
618620

619621
// N minus pt cut
620-
if (abs(eta) < ana.eta_cut and abs(vtx_z) < vtx_z_thresh and abs(vtx_perp) < vtx_perp_thresh) {
622+
if (std::abs(eta) < ana.eta_cut and std::abs(vtx_z) < vtx_z_thresh and std::abs(vtx_perp) < vtx_perp_thresh) {
621623
// vs. pt plot
622624
ana.tx.pushbackToBranch<float>(category_name + "_ef_denom_pt", pt);
623625
if (pass)
@@ -627,7 +629,7 @@ void fillEfficiencySet(int isimtrk, SimTrackSetDefinition& effset) {
627629
}
628630

629631
// N minus dxy cut
630-
if (abs(eta) < ana.eta_cut and pt > ana.pt_cut and abs(vtx_z) < vtx_z_thresh) {
632+
if (std::abs(eta) < ana.eta_cut and pt > ana.pt_cut and std::abs(vtx_z) < vtx_z_thresh) {
631633
// vs. dxy plot
632634
ana.tx.pushbackToBranch<float>(category_name + "_ef_denom_dxy", dxy);
633635
ana.tx.pushbackToBranch<float>(category_name + "_ef_denom_vxy", vtx_perp);
@@ -641,7 +643,7 @@ void fillEfficiencySet(int isimtrk, SimTrackSetDefinition& effset) {
641643
}
642644

643645
// N minus dz cut
644-
if (abs(eta) < ana.eta_cut and pt > ana.pt_cut and abs(vtx_perp) < vtx_perp_thresh) {
646+
if (std::abs(eta) < ana.eta_cut and pt > ana.pt_cut and std::abs(vtx_perp) < vtx_perp_thresh) {
645647
// vs. dz plot
646648
ana.tx.pushbackToBranch<float>(category_name + "_ef_denom_dz", dz);
647649
if (pass)
@@ -651,7 +653,8 @@ void fillEfficiencySet(int isimtrk, SimTrackSetDefinition& effset) {
651653
}
652654

653655
// All phase-space cuts
654-
if (abs(eta) < ana.eta_cut and pt > ana.pt_cut and abs(vtx_z) < vtx_z_thresh and abs(vtx_perp) < vtx_perp_thresh) {
656+
if (std::abs(eta) < ana.eta_cut and pt > ana.pt_cut and std::abs(vtx_z) < vtx_z_thresh and
657+
std::abs(vtx_perp) < vtx_perp_thresh) {
655658
// vs. Phi plot
656659
ana.tx.pushbackToBranch<float>(category_name + "_ef_denom_phi", phi);
657660
if (pass)
@@ -687,12 +690,12 @@ void fillFakeRateSet(int itc, RecoTrackSetDefinition& FRset) {
687690
if (pass)
688691
ana.tx.pushbackToBranch<float>(category_name + "_fr_numer_eta", eta);
689692
}
690-
if (abs(eta) < ana.eta_cut) {
693+
if (std::abs(eta) < ana.eta_cut) {
691694
ana.tx.pushbackToBranch<float>(category_name + "_fr_denom_pt", pt);
692695
if (pass)
693696
ana.tx.pushbackToBranch<float>(category_name + "_fr_numer_pt", pt);
694697
}
695-
if (abs(eta) < ana.eta_cut and pt > ana.pt_cut) {
698+
if (std::abs(eta) < ana.eta_cut and pt > ana.pt_cut) {
696699
ana.tx.pushbackToBranch<float>(category_name + "_fr_denom_phi", phi);
697700
if (pass)
698701
ana.tx.pushbackToBranch<float>(category_name + "_fr_numer_phi", phi);
@@ -725,12 +728,12 @@ void fillDuplicateRateSet(int itc, RecoTrackSetDefinition& DRset) {
725728
if (pass)
726729
ana.tx.pushbackToBranch<float>(category_name + "_dr_numer_eta", eta);
727730
}
728-
if (abs(eta) < ana.eta_cut) {
731+
if (std::abs(eta) < ana.eta_cut) {
729732
ana.tx.pushbackToBranch<float>(category_name + "_dr_denom_pt", pt);
730733
if (pass)
731734
ana.tx.pushbackToBranch<float>(category_name + "_dr_numer_pt", pt);
732735
}
733-
if (abs(eta) < ana.eta_cut and pt > ana.pt_cut) {
736+
if (std::abs(eta) < ana.eta_cut and pt > ana.pt_cut) {
734737
ana.tx.pushbackToBranch<float>(category_name + "_dr_denom_phi", phi);
735738
if (pass)
736739
ana.tx.pushbackToBranch<float>(category_name + "_dr_numer_phi", phi);

0 commit comments

Comments
 (0)