1#include "Tracking/Reco/TrigScintMeasurementProducer.h"
6#include <nlohmann/json.hpp>
10#include "Tracking/Event/Measurement.h"
11#include "TrigScint/Event/TrigScintCluster.h"
13namespace tracking::reco {
22 gSystem->Load(
"libTrigScint_Event");
25 parameters.getParameter<std::vector<std::string>>(
"input_collections");
26 input_pass_ = parameters.getParameter<std::string>(
"input_pass",
"");
28 "out_collection",
"TrigScintMeasurements");
36 daq_map_file_ = parameters.getParameter<std::string>(
"daq_map_file",
"");
41 EXCEPTION_RAISE(
"TrigScintDaqMap",
46 for (
const auto& m : doc.at(
"modules")) {
47 const int geo_module = m.at(
"geo_module").get<
int>();
48 if (geo_module < 0)
continue;
49 daq_modules_.emplace_back(m.at(
"collection").get<std::string>(),
61 const int n_bars = geom.getNumBars();
63 std::vector<ldmx::Measurement> measurements;
67 std::vector<std::pair<std::string, int>> to_process =
daq_modules_;
68 if (to_process.empty()) {
73 for (
const auto& [collection, geo_module] : to_process) {
77 const auto& clusters =
80 for (
const auto& cluster : clusters) {
81 if (cluster.getNHits() <= 0)
continue;
82 if (cluster.getPE() <
min_pe_)
continue;
85 const double centroid = cluster.getCentroid();
86 if (centroid < 0.)
continue;
93 int b0 =
static_cast<int>(std::floor(centroid));
95 if (b0 > n_bars - 1) b0 = n_bars - 1;
96 int b1 = std::min(b0 + 1, n_bars - 1);
97 double f = centroid - b0;
101 const auto p0 = geom.getBarPosition(geo_module, b0);
102 const auto p1 = geom.getBarPosition(geo_module, b1);
103 const float x = (1. - f) * p0.X() + f * p1.X();
104 const float y = (1. - f) * p0.Y() + f * p1.Y();
105 const float z = (1. - f) * p0.Z() + f * p1.Z();
113 static_cast<int>(std::lround(centroid)));
114 meas.
setTime(cluster.getTime());
117 measurements.push_back(meas);
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class that translates a trigger-scintillator (module, bar) into a global bar-center position.
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.
Implements an event buffer system for storing event data.
bool exists(const std::string &name, const std::string &passName, bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.
Class encapsulating parameters for configuring a processor.
void setNStrips(int n)
Set the number of strips that formed this cluster (-1 if not a cluster).
void setLocalPosition(const float &meas_u, const float &meas_v)
Set the local position i.e.
void setLayerID(const int &layer_id)
Set the layer ID of the sensor where this measurement took place.
void setGlobalPosition(const float &meas_x, const float &meas_y, const float &meas_z)
Set the global position i.e.
void setLocalCovariance(const float &cov_uu, const float &cov_vv)
Set cov(U,U) and cov(V, V).
void setClusterAmplitude(float amp)
Set the total cluster amplitude [ADC counts].
void setTime(const float &meas_t)
Set the measurement time in ns.
Stores cluster information from the trigger scintillator pads.
static constexpr const char * CONDITIONS_OBJECT_NAME
Name this conditions object is registered under (must match the python provider field name).
Turns reconstructed trigger-scintillator bar clusters into geometry-aware ldmx::Measurement objects.
void configure(framework::config::Parameters ¶meters) override
Callback for the EventProcessor to configure itself from the given set of parameters.
std::string out_collection_
output ldmx::Measurement collection name
std::string input_pass_
pass name of the input collections ("" = any)
std::vector< std::pair< std::string, int > > daq_modules_
parsed DAQ map: (decoded collection name, geometry module index)
std::vector< std::string > input_collections_
input cluster collections, one per module (index = module number)
void produce(framework::Event &event) override
Process the event and put new data products into it.
std::string daq_map_file_
optional TS DAQ-map JSON (decode collection -> geometry module).
double sigma_y_
assumed y measurement resolution [mm] (local covariance)
double min_pe_
optional cluster selection: cluster PE must exceed this (0 = keep all; the clustering seed/threshold ...