|
ATLAS Offline Software
|
Go to the documentation of this file.
21 #include "Gaudi/Property.h"
22 #include "GaudiKernel/ThreadLocalContext.h"
34 const std::string&
name,
35 ISvcLocator* pSvcLocator):
48 ATH_MSG_FATAL(
"No inner detector track selection strings provided!");
49 return StatusCode::FAILURE;
70 ATH_MSG_DEBUG(
"Initializing measurement ThinningHandleKeys.");
82 return StatusCode::SUCCESS;
90 ATH_MSG_INFO(
"Pixel state objects thinning, Total / Passed (Efficiency): "
97 ATH_MSG_INFO(
"SCT state objects thinning, Total / Passed (Efficiency): "
104 ATH_MSG_INFO(
"TRT state objects thinning, Total / Passed (Efficiency): "
113 return StatusCode::SUCCESS;
122 ATH_CHECK( importedTrackParticles.isValid() );
128 unsigned int size_measurements = importedMeasurements->
size();
134 unsigned int size_measurements = importedMeasurements->
size();
140 unsigned int size_measurements = importedMeasurements->
size();
146 unsigned int nTracks = importedTrackParticles->size();
147 if (nTracks==0)
return StatusCode::SUCCESS;
150 std::vector<bool>
mask;
151 mask.assign(nTracks,
false);
160 ATH_MSG_ERROR(
"Sizes incompatible! Are you sure your selection string used ID TrackParticles?");
161 return StatusCode::FAILURE;
164 for (
unsigned int i=0;
i<nTracks; ++
i) {
175 *importedTrackParticles,
186 *importedTrackParticles,
197 *importedTrackParticles,
206 return StatusCode::SUCCESS;
212 const std::vector<bool>& inputMask,
215 unsigned int& ntot_states,
216 unsigned int& npass_states,
217 unsigned int& npass_measurements)
const
219 std::vector<bool> maskStates;
220 std::vector<bool> maskMeasurements;
223 maskStates, maskMeasurements);
225 auto count = [] (
const std::vector<bool>&
m)
227 npass_states +=
count (maskStates);
228 npass_measurements +=
count (maskMeasurements);
230 if (!statesKey.
empty()) {
233 unsigned int size_states = importedStates->size();
234 if (size_states == 0) {
238 ntot_states += size_states;
239 if (maskStates.size() > size_states) {
240 ATH_MSG_ERROR(
"States mask size mismatch: mask size (" << maskStates.size() <<
") > number of states (" << size_states <<
").");
241 return StatusCode::FAILURE;
243 maskStates.resize (size_states);
244 importedStates.
keep (maskStates);
248 if (!measurementsKey.
empty()) {
250 ATH_CHECK( importedMeasurements.isValid() );
251 unsigned int size_measurements = importedMeasurements->size();
252 if (size_measurements == 0) {
256 if (maskMeasurements.size() > size_measurements) {
257 ATH_MSG_ERROR(
"Measurements mask size mismatch: mask size (" << maskMeasurements.size() <<
") > number of measurements (" << size_measurements <<
").");
258 return StatusCode::FAILURE;
260 maskMeasurements.resize (size_measurements);
261 importedMeasurements.
keep (maskMeasurements);
265 return StatusCode::SUCCESS;
269 const std::vector<bool>& inputMask,
271 std::vector<bool>& outputStatesMask, std::vector<bool>& outputMeasurementsMask)
const
273 using StatesOnTrack = std::vector<ElementLink<xAOD::TrackStateValidationContainer>>;
280 if (not inputMask[trkIndex])
continue;
285 ATH_MSG_INFO(
"Cannot find TrackState link from xAOD::TrackParticle. Skipping track.");
288 const StatesOnTrack& measurementsOnTrack = trackStateAcc(*trkIt);
291 if (not trkState_el.isValid()) {
292 ATH_MSG_INFO(
"Cannot find a valid link to TrackStateValidation object for track index: " << trkIndex);
295 if ((*trkState_el)->detType() != detTypeToSelect) {
296 ATH_MSG_VERBOSE(
"Discarding TrackState as not of correct type " << detTypeToSelect);
299 if (trkState_el.index() >= outputStatesMask.size()) {
300 outputStatesMask.resize (trkState_el.index()+1);
302 outputStatesMask[trkState_el.index()] =
true;
306 if (not trkMeasurement_el.
isValid()) {
307 ATH_MSG_VERBOSE(
"Cannot find a valid link to TrackMeasurementValidation object from track state for track index: " << trkIndex
308 <<
", trackState index: " << trkState_el.index());
311 if (*trkMeasurement_el ==
nullptr) {
312 ATH_MSG_VERBOSE(
"Invalid pointer to TrackMeasurementValidation object from track state for track index: " << trkIndex
313 <<
", trackState index: " << trkState_el.index());
316 if (trkMeasurement_el.
index() >= outputMeasurementsMask.size()) {
317 outputMeasurementsMask.resize (trkMeasurement_el.
index()+1);
319 outputMeasurementsMask[trkMeasurement_el.
index()] =
true;
SG::ThinningHandleKey< xAOD::TrackStateValidationContainer > m_statesSctSGKey
unsigned int m_ntot_pix_measurements
StatusCode finalizeParser()
HandleKey object for adding thinning to an object.
Handle for requesting thinning for a data object.
StringProperty m_selectionString
Expressions for object thinning selections Default InDetTrackParticles (also accomplished through fla...
std::conditional< NUM_PARSER==1, std::unique_ptr< ExpressionParsing::ExpressionParser >, std::array< std::unique_ptr< ExpressionParsing::ExpressionParser >, NUM_PARSER > >::type m_parser
unsigned int m_npass_sct_states
MeasurementType
Track state types Subset of enum MeasurementType from Athena: Tracking/TrkEvent/TrkEventPrimitives/Tr...
BooleanProperty m_thinTRTHitsOnTrack
Helper class to provide constant type-safe access to aux data.
#define ATH_MSG_VERBOSE(x)
const std::string & key() const
Return the StoreGate ID for the referenced object.
unsigned int m_ntot_pix_states
Counters and keys for xAOD::TrackStateValidation and xAOD::TrackMeasurementValidation containers.
virtual StatusCode execute() override
Athena algorithm's execute hook.
bool empty() const
Test if the key is blank.
void selectTrackHits(const xAOD::TrackParticleContainer &inputTrackParticles, const std::vector< bool > &inputMask, MeasurementType detTypeToSelect, std::vector< bool > &outputStatesMask, std::vector< bool > &outputMeasurementsMask) const
Select TrackStateValidation and TrackMeasurementValidation objects that are used in the (thinned) tra...
virtual StatusCode finalize() override
Athena algorithm's finalize hook.
bool isValid() const
Test to see if the link can be dereferenced.
unsigned int m_ntot
Counters and keys for xAOD::TrackParticle container.
unsigned int m_ntot_trt_states
Handle for requesting thinning for a data object.
unsigned int m_npass_trt_states
SG::ThinningHandleKey< xAOD::TrackStateValidationContainer > m_statesPixSGKey
virtual StatusCode initialize() override
Athena algorithm's initalize hook.
void keep(size_t ndx)
Mark that index ndx in the container should be kept (not thinned away).
unsigned int m_npass_pix_states
ThinInDetClustersAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
unsigned int m_ntot_sct_states
::StatusCode StatusCode
StatusCode definition for legacy code.
SG::ThinningHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurementsPixSGKey
BooleanProperty m_thinSCTHitsOnTrack
StatusCode filterTrackHits(MeasurementType detTypeToSelect, const xAOD::TrackParticleContainer &inputTrackParticles, const std::vector< bool > &inputMask, const SG::ThinningHandleKey< xAOD::TrackStateValidationContainer > &statesKey, const SG::ThinningHandleKey< xAOD::TrackMeasurementValidationContainer > &measurementsKey, unsigned int &ntot_states, unsigned int &npass_states, unsigned int &npass_measurements) const
unsigned int m_ntot_sct_measurements
StringProperty m_streamName
Stream for object thinning selections.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode initializeParser(const ExpressionParsing::SelectionArg< 1 > &selection_string)
ElementLink implementation for ROOT usage.
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetSGKey
SGKey for TrackParticleContainer.
SG::ThinningHandleKey< xAOD::TrackStateValidationContainer > m_statesTrtSGKey
unsigned int m_npass_sct_measurements
SG::ThinningHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurementsTrtSGKey
StatusCode initialize(bool used=true)
#define ATH_MSG_WARNING(x)
unsigned int m_ntot_trt_measurements
index_type index() const
Get the index of the element inside of its container.
unsigned int m_npass_trt_measurements
BooleanProperty m_thinPixelHitsOnTrack
Thinning logic.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
For P->T converter of SCT_Clusters.
Class describing a TrackParticle.
SG::ThinningHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurementsSctSGKey
size_type size() const noexcept
Returns the number of elements in the collection.
unsigned int m_npass_pix_measurements