LDMX Software
tracking::reco::RawTrackerDecoder Class Reference

Decodes raw Rogue frame data from SingleSubsystemUnpacker into a collection of RawSiStripHit objects on the event bus. More...

#include <RawTrackerDecoder.h>

Public Member Functions

 RawTrackerDecoder (const std::string &name, framework::Process &process)
 
void configure (framework::config::Parameters &ps) 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::string input_collection_ {"TrackerRawData"}
 Raw byte buffer collection name from SingleSubsystemUnpacker.
 
std::string input_pass_name_ {""}
 Pass name of the upstream producer.
 
std::string output_collection_ {"RawSiStripHits"}
 Name for the output RawSiStripHit collection.
 
int n_samples_ {3}
 ADC samples per hit (always 3 for APV25).
 

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
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger the_log_
 The logger for this EventProcessor.
 

Detailed Description

Decodes raw Rogue frame data from SingleSubsystemUnpacker into a collection of RawSiStripHit objects on the event bus.

Definition at line 15 of file RawTrackerDecoder.h.

Constructor & Destructor Documentation

◆ RawTrackerDecoder()

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

Definition at line 17 of file RawTrackerDecoder.h.

18 : Producer(name, process) {}
Producer(const std::string &name, Process &process)
Class constructor.
virtual void process(Event &event) final
Processing an event for a Producer is calling produce.

Member Function Documentation

◆ configure()

void tracking::reco::RawTrackerDecoder::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 10 of file RawTrackerDecoder.cxx.

10 {
12 ps.get<std::string>("input_collection", input_collection_);
13 input_pass_name_ = ps.get<std::string>("input_pass_name", input_pass_name_);
15 ps.get<std::string>("output_collection", output_collection_);
16 n_samples_ = ps.get<int>("n_samples", n_samples_);
17}
int n_samples_
ADC samples per hit (always 3 for APV25).
std::string input_collection_
Raw byte buffer collection name from SingleSubsystemUnpacker.
std::string output_collection_
Name for the output RawSiStripHit collection.
std::string input_pass_name_
Pass name of the upstream producer.

References framework::config::Parameters::get(), input_collection_, input_pass_name_, n_samples_, and output_collection_.

◆ produce()

void tracking::reco::RawTrackerDecoder::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 19 of file RawTrackerDecoder.cxx.

19 {
20 const auto& raw =
21 event.getCollection<uint8_t>(input_collection_, input_pass_name_);
22
23 std::vector<ldmx::RawSiStripHit> hits;
24
25 // Need at least the 10-byte header (4B event_count + 6B padding).
26 if (raw.size() < 10) {
27 event.add(output_collection_, hits);
28 return;
29 }
30
31 uint32_t event_count{0};
32 std::memcpy(&event_count, raw.data(), sizeof(event_count));
33
34 const std::size_t payload_start = 10;
35 const std::size_t n_multisamples = (raw.size() - payload_start) / 10;
36
37 if (n_multisamples == 0) {
38 event.add(output_collection_, hits);
39 return;
40 }
41
42 const auto& hdr = event.getEventHeader();
43 uint64_t ror_ts = 0;
44 if (hdr.hasIntParameter("RoR Timestamp LSB") &&
45 hdr.hasIntParameter("RoR Timestamp MSB")) {
46 ror_ts = (static_cast<uint64_t>(static_cast<uint32_t>(
47 hdr.getIntParameter("RoR Timestamp MSB")))
48 << 32) |
49 static_cast<uint32_t>(hdr.getIntParameter("RoR Timestamp LSB"));
50 }
51 auto timestamp = static_cast<long>(ror_ts);
52
53 hits.reserve(n_multisamples - 1);
54
55 // Skip the last multisample (replicates FrameParser behaviour).
56 for (std::size_t i = 0; i < n_multisamples - 1; ++i) {
57 const uint8_t* ms = raw.data() + payload_start + i * 10;
58
59 uint16_t s0{0}, s1{0}, s2{0};
60 std::memcpy(&s0, ms + 0, 2);
61 std::memcpy(&s1, ms + 2, 2);
62 std::memcpy(&s2, ms + 4, 2);
63
64 uint8_t channel = ms[6];
65 uint8_t apv_id = ms[7] & 0x07;
66 uint8_t hybrid_id = (ms[7] >> 4) & 0x07;
67 uint8_t feb_id = ms[8] & 0x0F;
68
69 // Bytes 8–9 as little-endian uint16_t; shift right 4, mask 6 bits.
70 uint16_t trig_word{0};
71 std::memcpy(&trig_word, ms + 8, 2);
72 uint16_t apv_trigger = (trig_word >> 4) & 0x3F;
73
74 uint8_t flags = ms[9];
75 uint8_t read_error = (flags >> 2) & 1;
76 uint8_t tail = (flags >> 3) & 1;
77 uint8_t head = (flags >> 4) & 1;
78 uint8_t filter = (flags >> 5) & 1;
79
81 channel,
82 std::vector<short>{static_cast<short>(s0), static_cast<short>(s1),
83 static_cast<short>(s2)},
84 timestamp);
85 hit.setApvId(apv_id);
86 hit.setHybridId(hybrid_id);
87 hit.setFebId(feb_id);
88 hit.setApvTrigger(apv_trigger);
89 hit.setReadError(read_error);
90 hit.setHead(head);
91 hit.setTail(tail);
92 hit.setFilter(filter);
93 hits.push_back(std::move(hit));
94 }
95
96 event.add(output_collection_, hits);
97}
Implementation of a raw digitized hit from a silicon strip detector.

References input_collection_, input_pass_name_, and output_collection_.

Member Data Documentation

◆ input_collection_

std::string tracking::reco::RawTrackerDecoder::input_collection_ {"TrackerRawData"}
private

Raw byte buffer collection name from SingleSubsystemUnpacker.

Definition at line 28 of file RawTrackerDecoder.h.

28{"TrackerRawData"};

Referenced by configure(), and produce().

◆ input_pass_name_

std::string tracking::reco::RawTrackerDecoder::input_pass_name_ {""}
private

Pass name of the upstream producer.

Definition at line 30 of file RawTrackerDecoder.h.

30{""};

Referenced by configure(), and produce().

◆ n_samples_

int tracking::reco::RawTrackerDecoder::n_samples_ {3}
private

ADC samples per hit (always 3 for APV25).

Definition at line 34 of file RawTrackerDecoder.h.

34{3};

Referenced by configure().

◆ output_collection_

std::string tracking::reco::RawTrackerDecoder::output_collection_ {"RawSiStripHits"}
private

Name for the output RawSiStripHit collection.

Definition at line 32 of file RawTrackerDecoder.h.

32{"RawSiStripHits"};

Referenced by configure(), and produce().


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