10 #include "Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.hpp"
11 #include "Acts/Definitions/Units.hpp"
12 #include "Acts/EventData/VectorMultiTrajectory.hpp"
13 #include "Acts/EventData/VectorTrackContainer.hpp"
14 #include "Acts/Utilities/HashedString.hpp"
15 #include "Acts/Utilities/Logger.hpp"
25 #include "GaudiKernel/ServiceHandle.h"
26 #include "GaudiKernel/ToolHandle.h"
28 unsigned int remapLayer(
unsigned int iVolume,
unsigned int iLayer) {
31 if ((iVolume == 9) || (iVolume == 16)) {
32 return iVolume * 100 + iLayer;
35 unsigned int outerEndsCapVolumes[6] = {13, 14, 15, 18, 19, 20};
39 iVolume) !=
std::end(outerEndsCapVolumes)) {
43 unsigned int innerEndsCapVolumes[2] = {8, 10};
46 unsigned int layerIDBins[4] = {0, 30, 40, 60};
51 iVolume) !=
std::end(innerEndsCapVolumes)) {
62 return iVolume * 100 + (
std::size(layerIDBins) - 1);
67 return iVolume * 100 + layerIDBin;
74 namespace ScoreBasedSolverCutsImpl {
83 updatedTracks.addColumn<
unsigned int>(
"nInnermostPixelLayerHits");
84 updatedTracks.addColumn<
unsigned int>(
"nSCTDoubleHoles");
85 updatedTracks.addColumn<
unsigned int>(
"nContribPixelLayers");
88 auto iTrack = track.index();
89 auto destProxy = updatedTracks.getTrack(updatedTracks.addTrack());
93 std::vector<unsigned int> pixelBarrelLayerIDs = {9, 16};
95 unsigned int innermostPixelVolumeID = 9;
96 unsigned int innermostPixelLayerID = 2;
98 for (
auto track : updatedTracks) {
99 bool doubleFlag =
false;
100 int nDoubleHoles = 0;
101 int nInnermostPixelLayerHits = 0;
102 int nContribPixelLayers = 0;
104 std::vector<unsigned int> contribPixelLayers = {};
106 for (
const auto ts : track.trackStatesReversed()) {
107 if (!
ts.hasReferenceSurface()) {
111 if (
ts.typeFlags().test(Acts::TrackStateFlag::MeasurementFlag)) {
115 auto iVolume =
ts.referenceSurface().geometryId().volume();
116 auto iLayer =
ts.referenceSurface().geometryId().layer();
118 if (iVolume == innermostPixelVolumeID) {
119 if (iLayer == innermostPixelLayerID) {
120 nInnermostPixelLayerHits++;
124 unsigned int remappedLayer =
remapLayer(iVolume, iLayer);
125 if (remappedLayer != 0) {
126 contribPixelLayers.push_back(remappedLayer);
130 std::set<unsigned int> uniqueSet(contribPixelLayers.begin(),
131 contribPixelLayers.end());
132 nContribPixelLayers = uniqueSet.size();
135 auto iTypeFlags =
ts.typeFlags();
136 if (!iTypeFlags.test(Acts::TrackStateFlag::HoleFlag)) {
139 if (iTypeFlags.test(Acts::TrackStateFlag::HoleFlag)) {
149 track.template component<unsigned int>(Acts::hashString(
150 "nInnermostPixelLayerHits")) = nInnermostPixelLayerHits;
151 track.template component<unsigned int>(
152 Acts::hashString(
"nSCTDoubleHoles")) = nDoubleHoles;
153 track.template component<unsigned int>(
154 Acts::hashString(
"nContribPixelLayers")) = nContribPixelLayers;
157 return updatedTracks;
164 std::vector<double> factorDblHoles;
166 const int maxDblHoles = 3;
167 const double goodDblHoles[maxDblHoles + 1] = {1., 0.03, 0.007, 0.0003};
168 const double fakeDblHoles[maxDblHoles + 1] = {1., 0.09, 0.09, 0.008};
170 for (
int i = 0;
i <= maxDblHoles; ++
i) {
171 factorDblHoles.push_back(goodDblHoles[
i] / fakeDblHoles[
i]);
174 Acts::HashedString hash_nMeasSubDet = Acts::hashString(
"nSCTDoubleHoles");
175 if (track.container().hasColumn(hash_nMeasSubDet)) {
176 iDblHoles = track.component<
unsigned int>(hash_nMeasSubDet);
178 if (iDblHoles > -1 && maxDblHoles > 0) {
179 if (iDblHoles > maxDblHoles) {
180 score /= (iDblHoles - maxDblHoles + 1);
181 iDblHoles = maxDblHoles;
183 score *= factorDblHoles[iDblHoles];
192 const int maxB_LayerHitsITk = 8;
193 auto maxB_LayerHits = maxB_LayerHitsITk;
194 const double blayModi[maxB_LayerHitsITk + 1] = {0.25, 4.0, 4.5, 5.0, 5.5,
197 std::vector<double> factorB_LayerHits;
199 for (
int i = 0;
i <= maxB_LayerHits; ++
i)
200 factorB_LayerHits.push_back(blayModi[
i]);
201 Acts::HashedString hash_nMeasSubDet =
202 Acts::hashString(
"nInnermostPixelLayerHits");
203 if (track.container().hasColumn(hash_nMeasSubDet)) {
204 bLayerHits = track.component<
unsigned int>(hash_nMeasSubDet);
209 if (bLayerHits > -1 && maxB_LayerHits > 0) {
210 if (bLayerHits > maxB_LayerHits) {
211 score *= (bLayerHits - maxB_LayerHits + 1);
212 bLayerHits = maxB_LayerHits;
214 score *= factorB_LayerHits[bLayerHits];
222 const int maxPixLay = 16;
223 double maxScore = 30.0;
224 double minScore = 5.00;
229 std::vector<double> factorPixLay;
231 double step[2] = {(maxScore - minScore) / (maxBarrel - minBarrel),
232 (maxScore - minScore) / (maxPixLay - minEnd)};
234 for (
int i = 0;
i <= maxPixLay;
i++) {
236 factorPixLay.push_back(0.01 + (
i * 0.33));
238 factorPixLay.push_back(minScore + ((
i - minEnd) *
step[1]));
243 Acts::HashedString hash_nMeasSubDet = Acts::hashString(
"nContribPixelLayers");
244 if (track.container().hasColumn(hash_nMeasSubDet)) {
245 iPixLay = track.component<
unsigned int>(hash_nMeasSubDet);
250 if (iPixLay > -1 && maxPixLay > 0) {
251 if (iPixLay > maxPixLay) {
252 score *= (iPixLay - maxPixLay + 1);
255 score *= factorPixLay[iPixLay];
263 const int maxHits = 26;
264 double maxScore = 40.0;
265 double minScore = 5.00;
270 int iHits = track.nMeasurements();
272 std::vector<double> factorHits;
274 double step[2] = {(maxScore - minScore) / (maxBarrel - minBarrel),
275 (maxScore - minScore) / (maxHits - minEnd)};
277 for (
int i = 0;
i <= maxHits;
i++) {
279 factorHits.push_back(0.01 + (
i * 1.0 / minEnd));
281 factorHits.push_back(minScore + ((
i - minEnd) *
step[1]));
283 if (iHits > -1 && maxHits > 0) {
284 if (iHits > maxHits) {
285 score *= (iHits - maxHits + 1);
288 score *= factorHits[iHits];
295 auto parm = track.parameters();
297 std::vector<double>
etaBins = {-4.0, -2.6, -2.0, 0.0, 2.0, 2.6, 4.0};
298 std::vector<double> maxD0 = {10.0, 2.0, 2.0, 2.0, 2.0, 10.0};
299 std::vector<double> maxZ0 = {200, 200, 200, 200, 200, 200};
300 std::vector<unsigned int> maxDoubleHoles = {2, 2, 2, 2, 2, 2};
301 std::vector<unsigned int> minSiClusters = {9, 8, 4, 4, 8, 9};
311 if (std::abs(eta) >
maxEta) {
315 if (std::abs(parm[Acts::BoundIndices::eBoundLoc1]) > maxZ0[
etaBin]) {
319 if (std::abs(parm[Acts::BoundIndices::eBoundLoc0]) > maxD0[
etaBin]) {
323 unsigned int numSiClusters = track.nMeasurements();
325 if (numSiClusters < minSiClusters[
etaBin]) {
329 unsigned int numSCTDoubleHoles = 0;
330 Acts::HashedString hash_nMeasSubDet = Acts::hashString(
"nSCTDoubleHoles");
331 if (track.container().hasColumn(hash_nMeasSubDet)) {
332 numSCTDoubleHoles = track.component<
unsigned int>(hash_nMeasSubDet);
335 if (numSCTDoubleHoles > maxDoubleHoles[
etaBin]) {