-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
Examples/Algorithms/Utilities/include/ActsExamples/Utilities/HitSelector.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2019-2023 CERN for the benefit of the Acts project | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#pragma once | ||
|
||
#include "Acts/TrackFinding/TrackSelector.hpp" | ||
#include "Acts/Utilities/Logger.hpp" | ||
#include "ActsExamples/EventData/SimHit.hpp" | ||
#include "ActsExamples/Framework/DataHandle.hpp" | ||
#include "ActsExamples/Framework/IAlgorithm.hpp" | ||
|
||
#include <cstddef> | ||
#include <limits> | ||
#include <string> | ||
|
||
namespace ActsExamples { | ||
|
||
/// Select tracks by applying some selection cuts. | ||
class HitSelector final : public IAlgorithm { | ||
public: | ||
struct Config { | ||
/// Input track collection. | ||
std::string inputHits; | ||
/// Output track collection | ||
std::string outputHits; | ||
|
||
/// Time cut | ||
double maxTime = std::numeric_limits<double>::max(); | ||
}; | ||
|
||
HitSelector(const Config& config, Acts::Logging::Level level); | ||
|
||
ProcessCode execute(const AlgorithmContext& ctx) const final; | ||
|
||
/// Get readonly access to the config parameters | ||
const Config& config() const { return m_cfg; } | ||
|
||
private: | ||
Config m_cfg; | ||
|
||
ReadDataHandle<SimHitContainer> m_inputHits{this, "InputHits"}; | ||
WriteDataHandle<SimHitContainer> m_outputHits{this, "OutputHits"}; | ||
}; | ||
|
||
} // namespace ActsExamples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2019-2023 CERN for the benefit of the Acts project | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#include "ActsExamples/Utilities/HitSelector.hpp" | ||
|
||
ActsExamples::HitSelector::HitSelector(const Config& config, | ||
Acts::Logging::Level level) | ||
: IAlgorithm("HitSelector", level), m_cfg(config) { | ||
m_inputHits.initialize(m_cfg.inputHits); | ||
m_outputHits.initialize(m_cfg.outputHits); | ||
} | ||
|
||
ActsExamples::ProcessCode ActsExamples::HitSelector::execute( | ||
const ActsExamples::AlgorithmContext& ctx) const { | ||
const auto& hits = m_inputHits(ctx); | ||
SimHitContainer selectedHits; | ||
|
||
std::copy_if(hits.begin(), hits.end(), | ||
std::inserter(selectedHits, selectedHits.begin()), | ||
[&](const auto& hit) { return hit.time() < m_cfg.maxTime; }); | ||
|
||
ACTS_DEBUG("selected " << selectedHits.size() << " from " << hits.size() | ||
<< " hits"); | ||
|
||
m_outputHits(ctx, std::move(selectedHits)); | ||
|
||
return {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters