Commit 22a15378 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

DUTAssociation: make DUT_MODULE

parent c57259ff
# Define module and return the generated name as MODULE_NAME
CORRYVRECKAN_GLOBAL_MODULE(MODULE_NAME)
CORRYVRECKAN_DUT_MODULE(MODULE_NAME)
# Add source files to library
CORRYVRECKAN_MODULE_SOURCES(${MODULE_NAME}
......
......@@ -3,12 +3,11 @@
using namespace corryvreckan;
using namespace std;
DUTAssociation::DUTAssociation(Configuration config, std::vector<std::shared_ptr<Detector>> detectors)
: Module(std::move(config), std::move(detectors)) {
DUTAssociation::DUTAssociation(Configuration config, std::shared_ptr<Detector> detector)
: Module(std::move(config), detector), m_detector(detector) {
auto det = get_dut();
timingCut = m_config.get<double>("timingCut", static_cast<double>(Units::convert(200, "ns")));
spatialCut = m_config.get<XYVector>("spatialCut", 2 * det->pitch());
spatialCut = m_config.get<XYVector>("spatialCut", 2 * m_detector->pitch());
}
StatusCode DUTAssociation::run(Clipboard* clipboard) {
......@@ -20,11 +19,8 @@ StatusCode DUTAssociation::run(Clipboard* clipboard) {
return Success;
}
// Get the DUT:
auto dut = get_dut();
// Get the DUT clusters from the clipboard
Clusters* clusters = reinterpret_cast<Clusters*>(clipboard->get(dut->name(), "clusters"));
Clusters* clusters = reinterpret_cast<Clusters*>(clipboard->get(m_detector->name(), "clusters"));
if(clusters == nullptr) {
LOG(DEBUG) << "No DUT clusters on the clipboard";
return Success;
......
#include "DUTAssociation.h"
using namespace corryvreckan;
using namespace std;
DUTAssociation::DUTAssociation(Configuration config, std::vector<std::shared_ptr<Detector>> detectors)
: Module(std::move(config), std::move(detectors)) {
auto det = get_dut();
<<<<<<< HEAD
timingCut = m_config.get<double>("timingCut", static_cast<double>(Units::convert(200, "ns")));
=======
timingCut = m_config.get<double>("timingCut", Units::convert(200, "ns"));
>>>>>>> master
spatialCut = m_config.get<XYVector>("spatialCut", 2 * det->pitch());
}
StatusCode DUTAssociation::run(Clipboard* clipboard) {
// Get the tracks from the clipboard
Tracks* tracks = reinterpret_cast<Tracks*>(clipboard->get("tracks"));
if(tracks == nullptr) {
LOG(DEBUG) << "No tracks on the clipboard";
return Success;
}
// Get the DUT:
auto dut = get_dut();
// Get the DUT clusters from the clipboard
Clusters* clusters = reinterpret_cast<Clusters*>(clipboard->get(dut->name(), "clusters"));
if(clusters == nullptr) {
LOG(DEBUG) << "No DUT clusters on the clipboard";
return Success;
}
// Loop over all tracks
for(auto& track : (*tracks)) {
// Loop over all DUT clusters
for(auto& cluster : (*clusters)) {
// Check distance between track and cluster
ROOT::Math::XYZPoint intercept = track->intercept(cluster->globalZ());
double xdistance = intercept.X() - cluster->globalX();
double ydistance = intercept.Y() - cluster->globalY();
if(abs(xdistance) > spatialCut.x() || abs(ydistance) > spatialCut.y()) {
LOG(DEBUG) << "Discarding DUT cluster with distance (" << abs(xdistance) << "," << abs(ydistance) << ")";
continue;
}
// Check if the cluster is close in time
if(std::abs(cluster->timestamp() - track->timestamp()) > timingCut) {
continue;
}
LOG(DEBUG) << "Found associated cluster with distance (" << abs(xdistance) << "," << abs(ydistance) << ")";
track->addAssociatedCluster(cluster);
}
}
// Return value telling analysis to keep running
return Success;
}
......@@ -17,14 +17,14 @@ namespace corryvreckan {
public:
// Constructors and destructors
DUTAssociation(Configuration config, std::vector<std::shared_ptr<Detector>> detectors);
DUTAssociation(Configuration config, std::shared_ptr<Detector> detector);
~DUTAssociation() = default;
// Functions
StatusCode run(Clipboard* clipboard);
private:
std::string m_DUT;
std::shared_ptr<Detector> m_detector;
double timingCut;
ROOT::Math::XYVector spatialCut;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment