Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Start to migrate the R4-MS segment fit #4108

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions Core/include/Acts/EventData/StationSpacePoint.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// This file is part of the ACTS project.
//
// Copyright (C) 2025 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 https://mozilla.org/MPL/2.0/.
#pragma once

#include "Acts/Definitions/Algebra.hpp"

#include <type_traits>


namespace Acts{
/** @brief Concept definition of the station space points. They're primarly used in composite detectors,
* like the Muon chambers in side the ATLAS experiment. The chambers usually consist of few layers
* of drift tubes which maybe sandwiched by other strip detector layers to measure the local coordinates
* on the reference plane the particle's passage.
*
* To describe the
*/
template <typename SpacePointType>
concept StationSpacePoint = requires(SpacePointType sp) {
/** @brief Local position of the space point measurement. It'either
* the position of the wire or the position of the fired strip in the chamber */
{ sp.localPosition() } -> std::same_as<const Acts::Vector3&>;
/** @brief Orientation of the sensor, which is either the wire orientation or
* the strip orientation. Travelling along the direction does not alter the residual */
{ sp.sensorDirection()} -> std::same_as<const Acts::Vector3&>;
/** @brief Normal vector on the strip-plane. */
{ sp.stripPlaneNormal()} -> std::same_as<const Acts::Vector3&>;
/** @brief Radius of the tube drift-measurement. The returned value is zero for strip measurements */
{ sp.driftRadius() } -> std::same_as<double>;
/** @brief Time when the measurement was taken */
{ sp.time()} -> std::same_as<double>;
};

}
34 changes: 34 additions & 0 deletions Core/include/Acts/Seeding/StrawChamberLineSeeder.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This file is part of the ACTS project.
//
// Copyright (C) 2025 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 https://mozilla.org/MPL/2.0/.
#pragma once

#include "Acts/EventData/StationSpacePoint.hpp"

namespace Acts{

/** @brief Define the concept of the space point measurement sorter. The sorter shall take a collection
* of station space points and sort them first into straw and strip hits. Then each category
* needs to be sorted by the logical measurement layers. */
template <typename MeasurementSorterType,typename spType>
//

concept MeasurementSorter = std::constructible_from<MeasurementSorterType, const std::vector<const spType*>&> &&
requires(MeasurementSorterType sorter, spType SP){
{ sorter.strawHits()} -> std::same_as<const std::vector<std::vector<const spType*>>& >;
{ sorter.stripHits()} -> std::same_as<const std::vector<std::vector<const spType*>>& >;
};
/** @brief Define the */
template <StationSpacePoint s, MeasurementSorter<s> m>
class StrawChamberLineSeeder{
public:


};

}
#include "Acts/Seeding/StrawChamberLineSeeder.ipp"
10 changes: 10 additions & 0 deletions Core/include/Acts/Seeding/StrawChamberLineSeeder.ipp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This file is part of the ACTS project.
//
// Copyright (C) 2025 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 https://mozilla.org/MPL/2.0/.
namespace Acts{

}
1 change: 1 addition & 0 deletions Examples/Algorithms/TrackFinding/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ add_library(
src/HoughTransformSeeder.cpp
src/TrackParamsEstimationAlgorithm.cpp
src/MuonHoughSeeder.cpp
src/MuonSegmentFinder.cpp
src/GbtsSeedingAlgorithm.cpp
src/TrackParamsLookupEstimation.cpp
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// This file is part of the ACTS project.
//
// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/.

#pragma once

#include "ActsExamples/Framework/DataHandle.hpp"
#include "ActsExamples/Framework/IAlgorithm.hpp"
#include "ActsExamples/Framework/ProcessCode.hpp"

#include <algorithm>
#include <memory>
#include <string>
#include <utility>
#include <vector>

namespace ActsExamples{
/// @brief Example implementation of a muon hough transform seeder
/// Uses the hough tools from the ACTS Core repo
/// Reads CSV files with muon sim hits (= true trajectories)
/// and drift circles (= measurements), performs
/// a hough transform to the drift circles in each station,
/// and compares to the true parameters of the sim hit in the
/// given station.
class MuonSegmentFinder final : public IAlgorithm {
public:
/// config
struct Config {
std::string inHoughSeeds{};
std::string outSegments{};
};

MuonSegmentFinder(Config cfg, Acts::Logging::Level lvl);

/// Run the seeding algorithm.
///
/// @param ctx is the algorithm context with event information
/// @return a process code indication success or failure
ProcessCode execute(const AlgorithmContext& ctx) const final;
ProcessCode initialize() final;
ProcessCode finalize() final;

/// Const access to the config
const Config& config() const { return m_cfg; }

private:
Config m_cfg;
std::unique_ptr<const Acts::Logger> m_logger;
const Acts::Logger& logger() const { return *m_logger; }

/// ReadDataHandle<SimHitContainer> m_inputSimHits{this, "InputSimHits"};
/// ReadDataHandle<DriftCircleContainer> m_inputDriftCircles{this,
/// "InputDriftCircles"};
};
}
1 change: 1 addition & 0 deletions Examples/Algorithms/TrackFinding/src/MuonHoughSeeder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "ActsExamples/TrackFinding/MuonHoughSeeder.hpp"

#include "ActsExamples/EventData/MuonSimHit.hpp"
#include "ActsExamples/EventData/MuonSpacePoint.hpp"

#include <algorithm>
#include <cmath>
Expand Down
40 changes: 40 additions & 0 deletions Examples/Algorithms/TrackFinding/src/MuonSegmentFinder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@


#include "Acts/Seeding/StrawChamberLineSeeder.hpp"

#include "ActsExamples/TrackFinding/MuonSegmentFinder.hpp"
#include "ActsExamples/EventData/MuonSpacePoint.hpp"


namespace ActsExamples{



MuonSegmentFinder::MuonSegmentFinder(Config cfg, Acts::Logging::Level lvl)
: IAlgorithm("MuonSegmentFinder", lvl),
m_cfg(std::move(cfg)),
m_logger(Acts::getDefaultLogger("MuonSegmentFinder", lvl)) {
// if (m_cfg.inDriftCircles.empty()) {
// throw std::invalid_argument(
// "MuonSegmentFinder: Missing drift circle collection");
// }
// if (m_cfg.inSimHits.empty()) {
// throw std::invalid_argument("MuonSegmentFinder: Missing sim hit collection");
// }

// m_inputDriftCircles.initialize(m_cfg.inDriftCircles);
// m_inputSimHits.initialize(m_cfg.inSimHits);
}

ProcessCode MuonSegmentFinder::execute( const AlgorithmContext& ctx) const {
Acts::StrawChamberLineSeeder<MuonSpacePoint, MuonSpacePointSorter> seeder{};
return ProcessCode::SUCCESS;
}

ProcessCode MuonSegmentFinder::initialize() {
return ProcessCode::SUCCESS;
}
ProcessCode MuonSegmentFinder::finalize() {
return ProcessCode::SUCCESS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "ActsExamples/EventData/IndexSourceLink.hpp"
#include "ActsExamples/EventData/SimHit.hpp"

#include "ActsExamples/EventData/MuonSpacePoint.hpp"
#include <cmath>
#include <vector>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

#pragma once

#include "Acts/EventData/StationSpacePoint.hpp"

namespace ActsExamples{
class MuonSpacePoint {
public:
/** @brief Return the local meaurement position */
const Acts::Vector3& localPosition() const{
return m_pos;
}
/** @brief Return the local sensor direction */
const Acts::Vector3& sensorDirection() const{
return m_dir;
}
/** @brief Return the normal vector to the plane */
const Acts::Vector3& stripPlaneNormal() const {
return m_pos;
}
/** @brief Return the drift radius */
double driftRadius() const{
return m_radius;
}
/** @brief Return the measurement time */
double time() const {
return m_time;
}
/** @brief Define the space point coordinates.
* @param pos: Space point position
* @param sensorDir: Direction of the sensor */
void defineCoordinates(Acts::Vector3&& pos,
Acts::Vector3&& sensorDir){
m_pos = std::move(pos);
m_dir = std::move(sensorDir);
}
/** @brief Define the space point normal*/
void defineNormal(Acts::Vector3&& norm) {
m_norm = std::move(norm);
}
/** @brief Define the space point radius */
void setRadius(const double r) {
m_radius = r;
}
/** @brief Define the time of the space point measurement */
void setTime(const double t){
m_time = t;
}
private:
Acts::Vector3 m_pos{Acts::Vector3::Zero()};
Acts::Vector3 m_dir{Acts::Vector3::Zero()};
Acts::Vector3 m_norm{Acts::Vector3::Zero()};
double m_radius{0.};
double m_time{0.};

};
using SpacePointContainer = std::vector<std::vector<MuonSpacePoint>>;

class MuonSpacePointSorter{
public:
MuonSpacePointSorter(const std::vector<const MuonSpacePoint*>& spacePoins);

const std::vector<std::vector<const MuonSpacePoint*>>& strawHits() const;

const std::vector<std::vector<const MuonSpacePoint*>>& stripHits() const;
};
}
1 change: 1 addition & 0 deletions Examples/Io/Csv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ add_library(
src/CsvSeedWriter.cpp
src/CsvTrackWriter.cpp
src/CsvDriftCircleReader.cpp
src/CsvMuonSpacePointReader.cpp
src/CsvMuonSimHitReader.cpp
src/CsvProtoTrackWriter.cpp
src/CsvSpacePointWriter.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// This file is part of the ACTS project.
//
// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/.

#pragma once
#include "ActsExamples/Framework/DataHandle.hpp"
#include "ActsExamples/Framework/IReader.hpp"
#include "ActsExamples/Framework/ProcessCode.hpp"

#include "ActsExamples/EventData/MuonSpacePoint.hpp"

namespace ActsExamples {
struct AlgorithmContext;

// Read in a simhit collection in comma-separated-value format.
///
/// This reads one files per event in the configured input directory. By default
/// it reads files in the current working directory. Files are assumed to be
/// named using the following schema
///
/// event000000001-<stem>.csv
/// event000000002-<stem>.csv
///
/// and each line in the file corresponds to one simhit.
class CsvMuonSpacePointReader final : public IReader {
public:
struct Config {
/// Where to read input files from.
std::string inputDir{};
/// Input filename stem.
std::string inputStem{};
/// Output simulated (truth) hits collection.
std::string outputSpacePoints{};
};

/// Construct the simhit reader.
///
/// @param config is the configuration object
/// @param level is the logging level
CsvMuonSpacePointReader(const Config& config, Acts::Logging::Level level);

std::string name() const override;

/// Return the available events range.
std::pair<std::size_t, std::size_t> availableEvents() const override;

/// Read out data from the input stream.
ProcessCode read(const ActsExamples::AlgorithmContext& ctx) override;

/// Readonly access to the config
const Config& config() const { return m_cfg; }

private:
Config m_cfg{};
std::pair<std::size_t, std::size_t> m_eventsRange{};
std::unique_ptr<const Acts::Logger> m_logger{};

WriteDataHandle<SpacePointContainer> m_outputSpacePoints{this, "OutputMuonSpacePoints"};

const Acts::Logger& logger() const { return *m_logger; }
};

} // namespace ActsExamples

Loading
Loading