LDMX Software
tracking::reco::TrigScintMeasurementProducer Class Reference

Turns reconstructed trigger-scintillator bar clusters into geometry-aware ldmx::Measurement objects. More...

#include <TrigScintMeasurementProducer.h>

Public Member Functions

 TrigScintMeasurementProducer (const std::string &name, framework::Process &process)
 
void configure (framework::config::Parameters &parameters) override
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
void produce (framework::Event &event) override
 Process the event and put new data products into it.
 
- Public Member Functions inherited from framework::Producer
 Producer (const std::string &name, Process &process)
 Class constructor.
 
virtual void process (Event &event) final
 Processing an event for a Producer is calling produce.
 
- Public Member Functions inherited from framework::EventProcessor
 DECLARE_FACTORY (EventProcessor, EventProcessor *, const std::string &, Process &)
 declare that we have a factory for this class
 
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()=default
 Class destructor.
 
virtual void beforeNewRun (ldmx::RunHeader &run_header)
 Callback for Producers to add parameters to the run header before conditions are initialized.
 
virtual void onNewRun (const ldmx::RunHeader &run_header)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed.
 
virtual void onProcessStart ()
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
virtual void onProcessEnd ()
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
template<class T >
const T & getCondition (const std::string &condition_name)
 Access a conditions object for the current event.
 
TDirectory * getHistoDirectory ()
 Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples.
 
void setStorageHint (framework::StorageControl::Hint hint)
 Mark the current event as having the given storage control hint from this module_.
 
void setStorageHint (framework::StorageControl::Hint hint, const std::string &purposeString)
 Mark the current event as having the given storage control hint from this module and the given purpose string.
 
int getLogFrequency () const
 Get the current logging frequency from the process.
 
int getRunNumber () const
 Get the run number from the process.
 
std::string getName () const
 Get the processor name.
 
void createHistograms (const std::vector< framework::config::Parameters > &histos)
 Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create.
 

Private Attributes

std::vector< std::string > input_collections_
 input cluster collections, one per module (index = module number)
 
std::string input_pass_
 pass name of the input collections ("" = any)
 
std::string out_collection_
 output ldmx::Measurement collection name
 
std::string daq_map_file_
 optional TS DAQ-map JSON (decode collection -> geometry module).
 
std::vector< std::pair< std::string, int > > daq_modules_
 parsed DAQ map: (decoded collection name, geometry module index)
 
double min_pe_ {0.}
 optional cluster selection: cluster PE must exceed this (0 = keep all; the clustering seed/threshold cuts already define the clusters)
 
double sigma_y_ {0.9}
 assumed y measurement resolution [mm] (local covariance)
 

Additional Inherited Members

- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramPool histograms_
 helper object for making and filling histograms
 
NtupleManager & ntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger the_log_
 The logger for this EventProcessor.
 

Detailed Description

Turns reconstructed trigger-scintillator bar clusters into geometry-aware ldmx::Measurement objects.

The TS bars measure the y coordinate. This producer reads one or more ldmx::TrigScintCluster collections (the output of the calibrated EventReadout -> TestBeamHit -> TestBeamCluster chain), each addressed to a geometry module, and converts each cluster's PE-weighted fractional bar centroid (TrigScintCluster::getCentroid) into a global (x, y, z) position by interpolating the bar geometry between the two adjacent bars – so the output measurements live in the same ldmx::Measurement frame the tracker uses and can be correlated with tracker measurements.

Consuming clusters (rather than the raw decoded ZCCM digis) means the input is pedestal-subtracted, gain-calibrated (PE) and cluster-position-refined, giving a sub-bar centroid instead of a single fired channel.

This is the first, parameterized increment (geometry via python params, tuned against the tracker beam). The follow-up promotes the bar geometry to a proper DetDescr ConditionsObject provider (Ecal/Hcal-style), read from the detector.

Input : one collection of ldmx::TrigScintCluster per module Output : collection of ldmx::Measurement

Definition at line 37 of file TrigScintMeasurementProducer.h.

Constructor & Destructor Documentation

◆ TrigScintMeasurementProducer()

tracking::reco::TrigScintMeasurementProducer::TrigScintMeasurementProducer ( const std::string & name,
framework::Process & process )
inline

Definition at line 39 of file TrigScintMeasurementProducer.h.

Base class for a module which produces a data product.
virtual void process(Event &event) final
Processing an event for a Producer is calling produce.

Member Function Documentation

◆ configure()

void tracking::reco::TrigScintMeasurementProducer::configure ( framework::config::Parameters & parameters)
overridevirtual

Callback for the EventProcessor to configure itself from the given set of parameters.

The parameters a processor has access to are the member variables of the python class in the sequence that has class_name equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 15 of file TrigScintMeasurementProducer.cxx.

16 {
17 // Load the TrigScint_Event ROOT dictionary so the digi collection reads as
18 // the compiled type. The accessors are inline (linker drops
19 // libTrigScint_Event) and there is no rootmap for autoload, so ROOT would
20 // otherwise fall back to an emulated streamer that crashes when cast to the
21 // compiled class.
22 gSystem->Load("libTrigScint_Event");
23
25 parameters.getParameter<std::vector<std::string>>("input_collections");
26 input_pass_ = parameters.getParameter<std::string>("input_pass", "");
27 out_collection_ = parameters.getParameter<std::string>(
28 "out_collection", "TrigScintMeasurements");
29 min_pe_ = parameters.getParameter<double>("min_pe", min_pe_);
30 sigma_y_ = parameters.getParameter<double>("sigma_y", sigma_y_);
31
32 // Optional TS DAQ map: fixes the decode-collection -> geometry-module
33 // (cabling) correspondence, analogous to the tracker's daq_map_file. Entries
34 // with geo_module < 0 (e.g. the LYSO pad, not yet in the geometry) are
35 // skipped.
36 daq_map_file_ = parameters.getParameter<std::string>("daq_map_file", "");
37 daq_modules_.clear();
38 if (!daq_map_file_.empty()) {
39 std::ifstream in(daq_map_file_);
40 if (!in) {
41 EXCEPTION_RAISE("TrigScintDaqMap",
42 "Could not open TS DAQ map '" + daq_map_file_ + "'.");
43 }
44 nlohmann::json doc;
45 in >> doc;
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; // not mapped to geometry (e.g. LYSO)
49 daq_modules_.emplace_back(m.at("collection").get<std::string>(),
50 geo_module);
51 }
52 ldmx_log(info) << "TS DAQ map '" << daq_map_file_ << "' -> "
53 << daq_modules_.size() << " mapped modules.";
54 }
55}
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)
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 ...

References daq_map_file_, daq_modules_, input_collections_, input_pass_, min_pe_, out_collection_, and sigma_y_.

◆ produce()

void tracking::reco::TrigScintMeasurementProducer::produce ( framework::Event & event)
overridevirtual

Process the event and put new data products into it.

Parameters
eventThe Event to process.

Implements framework::Producer.

Definition at line 57 of file TrigScintMeasurementProducer.cxx.

57 {
58 // Bar positions come from the geometry conditions object (not hard-coded).
61 const int n_bars = geom.getNumBars();
62
63 std::vector<ldmx::Measurement> measurements;
64
65 // (decoded collection, geometry module) pairs to process: from the DAQ map
66 // if provided, else the input_collections order (index = geometry module).
67 std::vector<std::pair<std::string, int>> to_process = daq_modules_;
68 if (to_process.empty()) {
69 for (std::size_t i = 0; i < input_collections_.size(); ++i)
70 to_process.emplace_back(input_collections_[i], static_cast<int>(i));
71 }
72
73 for (const auto& [collection, geo_module] : to_process) {
74 // TestBeamClusterProducer only writes the collection for events with >=1
75 // cluster, so it is legitimately absent in empty events -- skip those.
76 if (!event.exists(collection, input_pass_, false)) continue;
77 const auto& clusters =
78 event.getCollection<ldmx::TrigScintCluster>(collection, input_pass_);
79
80 for (const auto& cluster : clusters) {
81 if (cluster.getNHits() <= 0) continue;
82 if (cluster.getPE() < min_pe_) continue;
83
84 // PE-weighted fractional bar centroid (0-based); < 0 means uninitialized.
85 const double centroid = cluster.getCentroid();
86 if (centroid < 0.) continue;
87
88 // Interpolate the global position between the two bracketing bars. The
89 // bars alternate between two staggered layers (bar%2), so the geometry is
90 // piecewise in bar parity -- evaluating both integer endpoints and
91 // interpolating gives the correct y AND the correct in-between z, and
92 // reduces to the exact bar position for an integer centroid.
93 int b0 = static_cast<int>(std::floor(centroid));
94 if (b0 < 0) b0 = 0;
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;
98 if (f < 0.) f = 0.;
99 if (f > 1.) f = 1.;
100
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();
106
108 meas.setGlobalPosition(x, y, z);
109 meas.setLocalPosition(y, 0.f);
110 meas.setLocalCovariance(static_cast<float>(sigma_y_ * sigma_y_), 0.f);
111 // encode geometry module + nearest bar so downstream can trace it
112 meas.setLayerID(geo_module * 100 +
113 static_cast<int>(std::lround(centroid)));
114 meas.setTime(cluster.getTime());
115 meas.setClusterAmplitude(static_cast<float>(cluster.getPE()));
116 meas.setNStrips(cluster.getNHits());
117 measurements.push_back(meas);
118 }
119 }
120
121 event.add(out_collection_, measurements);
122}
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.
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.
Definition Event.cxx:107
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.
Definition Measurement.h:61
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.
Definition Measurement.h:42
void setLocalCovariance(const float &cov_uu, const float &cov_vv)
Set cov(U,U) and cov(V, V).
Definition Measurement.h:77
void setClusterAmplitude(float amp)
Set the total cluster amplitude [ADC counts].
void setTime(const float &meas_t)
Set the measurement time in ns.
Definition Measurement.h:93
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).

References ldmx::TrigScintGeometry::CONDITIONS_OBJECT_NAME, daq_modules_, framework::Event::exists(), framework::EventProcessor::getCondition(), input_collections_, input_pass_, min_pe_, out_collection_, ldmx::Measurement::setClusterAmplitude(), ldmx::Measurement::setGlobalPosition(), ldmx::Measurement::setLayerID(), ldmx::Measurement::setLocalCovariance(), ldmx::Measurement::setLocalPosition(), ldmx::Measurement::setNStrips(), ldmx::Measurement::setTime(), and sigma_y_.

Member Data Documentation

◆ daq_map_file_

std::string tracking::reco::TrigScintMeasurementProducer::daq_map_file_
private

optional TS DAQ-map JSON (decode collection -> geometry module).

If unset, the input_collections index is used as the geometry module.

Definition at line 59 of file TrigScintMeasurementProducer.h.

Referenced by configure().

◆ daq_modules_

std::vector<std::pair<std::string, int> > tracking::reco::TrigScintMeasurementProducer::daq_modules_
private

parsed DAQ map: (decoded collection name, geometry module index)

Definition at line 61 of file TrigScintMeasurementProducer.h.

Referenced by configure(), and produce().

◆ input_collections_

std::vector<std::string> tracking::reco::TrigScintMeasurementProducer::input_collections_
private

input cluster collections, one per module (index = module number)

Definition at line 48 of file TrigScintMeasurementProducer.h.

Referenced by configure(), and produce().

◆ input_pass_

std::string tracking::reco::TrigScintMeasurementProducer::input_pass_
private

pass name of the input collections ("" = any)

Definition at line 50 of file TrigScintMeasurementProducer.h.

Referenced by configure(), and produce().

◆ min_pe_

double tracking::reco::TrigScintMeasurementProducer::min_pe_ {0.}
private

optional cluster selection: cluster PE must exceed this (0 = keep all; the clustering seed/threshold cuts already define the clusters)

Definition at line 65 of file TrigScintMeasurementProducer.h.

65{0.};

Referenced by configure(), and produce().

◆ out_collection_

std::string tracking::reco::TrigScintMeasurementProducer::out_collection_
private

output ldmx::Measurement collection name

Definition at line 52 of file TrigScintMeasurementProducer.h.

Referenced by configure(), and produce().

◆ sigma_y_

double tracking::reco::TrigScintMeasurementProducer::sigma_y_ {0.9}
private

assumed y measurement resolution [mm] (local covariance)

Definition at line 67 of file TrigScintMeasurementProducer.h.

67{0.9};

Referenced by configure(), and produce().


The documentation for this class was generated from the following files: