ATLAS Offline Software
ScoreBasedSolverCutsImpl.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 
9 // ACTS
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"
18 #include "ActsInterop/Logger.h"
19 
20 // Athena
23 
24 // Gaudi
25 #include "GaudiKernel/ServiceHandle.h"
26 #include "GaudiKernel/ToolHandle.h"
27 namespace ActsTrk {
28 
29 namespace ScoreBasedSolverCutsImpl {
30 // Add the summary information to the track container for OptionalCuts, This likely needs to be moved outside ambiguity resolution
32  ActsTrk::TrackContainer trackContainer) {
33 
34  ActsTrk::MutableTrackContainer updatedTracks;
35  updatedTracks.ensureDynamicColumns(trackContainer);
36 
37  updatedTracks.addColumn<unsigned int>("nInnermostPixelLayerHits");
38  updatedTracks.addColumn<unsigned int>("nSCTDoubleHoles");
39  updatedTracks.addColumn<unsigned int>("nContribPixelLayers");
40 
41  for (auto track : trackContainer) {
42  auto iTrack = track.index();
43  auto destProxy = updatedTracks.getTrack(updatedTracks.addTrack());
44  destProxy.copyFrom(trackContainer.getTrack(iTrack));
45  }
46 
47  unsigned int pixelVoulmeIds[] = {8, 9, 10, 13, 14, 15, 16, 17, 18, 19, 20};
48 
49  for (auto track : updatedTracks) {
50  bool doubleFlag = false;
51  int nDoubleHoles = 0;
52  int nInnermostPixelLayerHits = 0;
53  int nContribPixelLayers = 0;
54  for (const auto &ts : track.trackStatesReversed()) {
55  if (!ts.hasReferenceSurface()) {
56  continue;
57  }
58  // Check if the volume is the innermost pixel layer
59  // Compute the number of hits in the innermost pixel layer
60  auto iVolume = ts.referenceSurface().geometryId().volume();
61  if (iVolume == 8) {
62  nInnermostPixelLayerHits++;
63  }
64  if (std::find(std::begin(pixelVoulmeIds), std::end(pixelVoulmeIds),
65  iVolume) != std::end(pixelVoulmeIds)) {
66  nContribPixelLayers++;
67  }
68 
69  // Check if the track state has a hole flag
70  // Compute the number of double holes
71  auto iTypeFlags = ts.typeFlags();
72  if (!iTypeFlags.test(Acts::TrackStateFlag::HoleFlag)) {
73  doubleFlag = false;
74  }
75  if (iTypeFlags.test(Acts::TrackStateFlag::HoleFlag)) {
76  if (doubleFlag) {
77  nDoubleHoles++;
78  doubleFlag = false;
79  } else {
80  doubleFlag = true;
81  }
82  }
83  }
84  track.template component<unsigned int>(Acts::hashString(
85  "nInnermostPixelLayerHits")) = nInnermostPixelLayerHits;
86  track.template component<unsigned int>(
87  Acts::hashString("nSCTDoubleHoles")) = nDoubleHoles;
88  track.template component<unsigned int>(
89  Acts::hashString("nContribPixelLayers")) = nContribPixelLayers;
90  }
91 
92  return updatedTracks;
93 }
94 
95 // This optionalCut removes tracks that have a number of SCT double holes greater than 2
97 
98  int n_doubleHoles = 0;
99  int max_doubleHoles = 2;
100  Acts::HashedString hash_nMeasSubDet =
101  Acts::hashString("nSCTDoubleHoles");
102  if (track.container().hasColumn(hash_nMeasSubDet)) {
103  n_doubleHoles = track.component<unsigned int>(hash_nMeasSubDet);
104  } else {
105  return false;
106  }
107  if (n_doubleHoles > max_doubleHoles) {
108  return true;
109  }
110  return false;
111 }
112 
113 // This optional score modifies the score based on the number of hits in the innermost pixel layer
115  int bLayerHits = 0;
116  const int maxB_LayerHitsITk = 8;
117  auto maxB_LayerHits = maxB_LayerHitsITk;
118  const double blayModi[maxB_LayerHitsITk + 1] = {0.25, 4.0, 4.5, 5.0, 5.5,
119  6.0, 6.5, 7.0, 7.5};
120 
121  std::vector<double> factorB_LayerHits;
122 
123  for (int i = 0; i <= maxB_LayerHits; ++i)
124  factorB_LayerHits.push_back(blayModi[i]);
125  Acts::HashedString hash_nMeasSubDet =
126  Acts::hashString("nInnermostPixelLayerHits");
127  if (track.container().hasColumn(hash_nMeasSubDet)) {
128  bLayerHits = track.component<unsigned int>(hash_nMeasSubDet);
129  } else {
130  return;
131  }
132 
133  if (bLayerHits > -1 && maxB_LayerHits > 0) {
134  if (bLayerHits > maxB_LayerHits) {
135  score *= (bLayerHits - maxB_LayerHits + 1); // hits are good !
136  bLayerHits = maxB_LayerHits;
137  }
138  score *= factorB_LayerHits[bLayerHits];
139  }
140 }
141 
142 // This optional score modifies the score based on the number of contributing pixel layers
144 
145  const int maxPixelLayITk = 16;
146  auto maxPixLay = maxPixelLayITk;
147  double maxScore = 30.0;
148  double minScore = 5.00;
149  int maxBarrel = 10;
150  int minBarrel = 3;
151  int minEnd = 5;
152 
153  double step[2] = {(maxScore - minScore) / (maxBarrel - minBarrel),
154  (maxScore - minScore) / (maxPixelLayITk - minEnd)};
155 
156  std::vector<double> factorPixLay;
157  for (int i = 0; i <= maxPixelLayITk; i++) {
158  if (i < minEnd)
159  factorPixLay.push_back(0.01 + (i * 0.33));
160  else
161  factorPixLay.push_back(minScore + ((i - minEnd) * step[1]));
162  }
163 
164  int iPixLay = 0;
165  Acts::HashedString hash_nMeasSubDet =
166  Acts::hashString("nContribPixelLayers");
167  if (track.container().hasColumn(hash_nMeasSubDet)) {
168  iPixLay = track.component<unsigned int>(hash_nMeasSubDet);
169  } else {
170  return;
171  }
172 
173  if (iPixLay > -1 && maxPixLay > 0) {
174  if (iPixLay > maxPixLay) {
175  score *= (iPixLay - maxPixLay + 1); // layers are good !
176  iPixLay = maxPixLay;
177  }
178  score *= factorPixLay[iPixLay];
179  }
180 }
181 
182 // This optional cut removes tracks based on the eta dependent cuts
183 // The eta dependent cuts are defined in the InDet::InDetEtaDependentCutsSvc
185  auto trackEta = Acts::VectorHelpers::eta(track.momentum());
186  auto parm = track.parameters();
187 
188  double maxEta = etaDependentCutsSvc->getMaxEta();
189  if (std::abs(trackEta) > maxEta) {
190  return true;
191  }
192 
193  double maxZ0 = etaDependentCutsSvc->getMaxZImpactAtEta(trackEta);
194  if (std::abs(parm[Acts::BoundIndices::eBoundLoc1]) > maxZ0) {
195  return true;
196  }
197 
198  double maxD0 = etaDependentCutsSvc->getMaxPrimaryImpactAtEta(trackEta);
199 
200  if (std::abs(parm[Acts::BoundIndices::eBoundLoc0]) > maxD0) {
201  return true;
202  }
203 
204  return false;
205 }
206 
207 // This optional cut removes hits from the track based on the pattern track hits
208 // NOTE: this operation will not be used until the pattern track hits are implemented in ActsTrk
210  const trackProxy_t &track, const trackProxy_t::ConstTrackStateProxy &ts,
211  Acts::ScoreBasedAmbiguityResolution::TrackStateTypes &trackStateType) {
212  bool ispatternTrack = false;
213  Acts::HashedString hash_nMeasSubDet = Acts::hashString("ispatternTrack");
214  if (track.container().hasColumn(hash_nMeasSubDet)) {
215  ispatternTrack = track.component<unsigned int>(hash_nMeasSubDet);
216  }
217  if (ts.typeFlags().test(Acts::TrackStateFlag::OutlierFlag) &&
218  ispatternTrack) {
219  trackStateType =
220  Acts::ScoreBasedAmbiguityResolution::TrackStateTypes::RejectedHit;
221  } else if (ts.typeFlags().test(Acts::TrackStateFlag::OutlierFlag) &&
222  !ispatternTrack) {
223  // Copy the hit to the track
224  trackStateType =
225  Acts::ScoreBasedAmbiguityResolution::TrackStateTypes::Outlier;
226  }
227 }
228 
229 } // namespace ScoreBasedSolverCutsImpl
230 
231 } // namespace ActsTrk
TrackSummaryContainer.h
ActsTrk::TrackContainer
Definition: TrackContainer.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
ActsTrk::ScoreBasedSolverCutsImpl::innermostPixelLayerHitsScore
void innermostPixelLayerHitsScore(const trackProxy_t &track, double &score)
Score modifier for tracks based on innermost pixel layer hits.
Definition: ScoreBasedSolverCutsImpl.cxx:114
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
PUfitVar::maxEta
constexpr float maxEta
Definition: GepMETPufitAlg.cxx:13
ActsTrk::ScoreBasedSolverCutsImpl::doubleHolesFilter
bool doubleHolesFilter(const trackProxy_t &track)
Filter for tracks based on double holes.
Definition: ScoreBasedSolverCutsImpl.cxx:96
ScoreBasedSolverCutsImpl.h
GenericMonitoringTool.h
ActsTrk::ScoreBasedSolverCutsImpl::trackProxy_t
ActsTrk::MutableTrackContainer::ConstTrackProxy trackProxy_t
Definition: ScoreBasedSolverCutsImpl.h:27
lumiFormat.i
int i
Definition: lumiFormat.py:85
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
ActsTrk::ScoreBasedSolverCutsImpl::etaDependentCuts
bool etaDependentCuts(const trackProxy_t &track, ServiceHandle< InDet::IInDetEtaDependentCutsSvc > etaDependentCutsSvc)
Filter for tracks based on eta dependent cuts.
Definition: ScoreBasedSolverCutsImpl.cxx:184
xAOD::score
@ score
Definition: TrackingPrimitives.h:513
ActsTrk::ScoreBasedSolverCutsImpl::addSummaryInformation
ActsTrk::MutableTrackContainer addSummaryInformation(ActsTrk::TrackContainer trackContainer)
Adds summary information to the track container.
Definition: ScoreBasedSolverCutsImpl.cxx:31
ScoreBasedAmbiguityResolutionAlg.h
LArCellBinning.step
step
Definition: LArCellBinning.py:158
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:54
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
Logger.h
python.CaloScaleNoiseConfig.ts
ts
Definition: CaloScaleNoiseConfig.py:86
ActsTrk::MutableTrackContainer
Definition: TrackContainer.h:122
TrackContainer.h
ActsTrk::ScoreBasedSolverCutsImpl::ContribPixelLayersScore
void ContribPixelLayersScore(const trackProxy_t &track, double &score)
Score modifier for tracks based on contributing pixel layers.
Definition: ScoreBasedSolverCutsImpl.cxx:143
ActsTrk::ScoreBasedSolverCutsImpl::patternTrackHitSelection
void patternTrackHitSelection(const trackProxy_t &track, const trackProxy_t::ConstTrackStateProxy &ts, Acts::ScoreBasedAmbiguityResolution::TrackStateTypes &trackStateType)
Hit selection for tracks based on pattern track hits.
Definition: ScoreBasedSolverCutsImpl.cxx:209
TauGNNUtils::Variables::Track::trackEta
bool trackEta(const xAOD::TauJet &, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:477
ServiceHandle< InDet::IInDetEtaDependentCutsSvc >