7#include "Packing/Utility/Mask.h"
8#include "Packing/Utility/Reader.h"
18double to_double_ft(uint64_t i) {
19 static const unsigned int bits = 32;
20 static const unsigned int expbits = 8;
24 unsigned significandbits = bits - expbits - 1;
26 if (i == 0)
return 0.0;
29 result = (i & ((1LL << significandbits) - 1));
30 result /= (1LL << significandbits);
34 bias = (1 << (expbits - 1)) - 1;
35 shift = ((i >> significandbits) & ((1LL << expbits) - 1)) - bias;
46 result *= (i >> (bits - 1)) & 1 ? -1.0 : 1.0;
55 uint32_t field_header_;
56 std::vector<uint32_t> field_value_;
65 r >> len >> field_header_;
66 r.
read(field_value_, len - 1);
67 if (i_field != field_header_) {
68 EXCEPTION_RAISE(
"BadForm",
"Field " + std::to_string(i_field) +
69 " has a mismatched header " +
70 std::to_string(field_header_));
77 int to_int(
const std::size_t i = 0)
const {
return field_value_.at(i); }
84 str.resize(field_value_.size());
85 for (
int i{0}; i < str.size(); i++) {
86 str[i] = (char)field_value_[i];
96 long int to_long(
const std::size_t i = 0)
const {
97 return ((uint64_t)field_value_.at(i + 1) << 32) |
98 (uint64_t)field_value_.at(i);
105 return to_double_ft(this->
to_long(i));
111 const std::vector<uint32_t>&
value()
const {
return field_value_; }
136 int trigger_timestamp_lsb, trigger_timestamp_msb, event_timestamp_lsb,
138 std::vector<uint32_t> channel_hits;
143 std::size_t i_word) {
144 trigger_timestamp_lsb = spill_data.at(i_word);
145 trigger_timestamp_msb = spill_data.at(i_word + 1);
146 event_timestamp_lsb = spill_data.at(i_word + 2);
147 event_timestamp_msb = spill_data.at(i_word + 3);
148 channel_hits.clear();
149 channel_hits.reserve(6);
150 for (std::size_t i{i_word + 4}; i < i_word + 10 and i < spill_data.size();
152 channel_hits.push_back(spill_data.at(i));
164 std::string coincidenceInUse;
166 long int countsRecords;
167 long int countsRecordsWithZeroEvents;
168 long int countsTrigs;
169 std::string cycleName;
171 std::string equipmentName;
172 int eventSelectionAcq;
182 std::vector<double> profile;
183 std::vector<double> profileStandAlone;
184 std::string timeFirstEvent;
185 std::string timeFirstTrigger;
186 std::string timeLastEvent;
187 std::string timeLastTrigger;
189 int triggerOffsetAcq;
190 int triggerSelectionAcq;
208 std::cout << i_field <<
" "
209 <<
"acqMode = " << acqMode << std::endl;
213 std::cout << i_field <<
" "
214 <<
"acqStamp = " << acqStamp << std::endl;
218 std::cout << i_field <<
" "
219 <<
"acqType = " << acqType << std::endl;
223 std::cout << i_field <<
" "
224 <<
"acqTypeAllowed = " << acqTypeAllowed << std::endl;
228 std::cout << i_field <<
" "
229 <<
"coincidenceInUse = " << coincidenceInUse << std::endl;
233 std::cout << i_field <<
" "
234 <<
"counts = " << counts << std::endl;
238 std::cout << i_field <<
" "
239 <<
"countsRecords = " << countsRecords << std::endl;
243 std::cout << i_field <<
" "
244 <<
"countsRecordsWithZeroEvents = " << countsRecordsWithZeroEvents
249 std::cout << i_field <<
" "
250 <<
"countsTrigs = " << countsTrigs << std::endl;
254 std::cout << i_field <<
" "
255 <<
"cycleName = " << cycleName << std::endl;
259 std::cout << i_field <<
" "
260 <<
"cycleStamp = " << cycleStamp << std::endl;
264 std::cout << i_field <<
" "
265 <<
"equipmentName = " << equipmentName << std::endl;
269 std::cout << i_field <<
" "
270 <<
"eventSelectionAcq = " << eventSelectionAcq << std::endl;
276 for (std::size_t i_word{0}; i_word < events_data_field.
value().size();
281 std::cout << i_field <<
" "
282 <<
"eventsData (size = " <<
eventsData.size() <<
")" << std::endl;
286 std::cout << i_field <<
" "
287 <<
"meanSNew = " << meanSNew << std::endl;
291 std::cout << i_field <<
" "
292 <<
"message = " << message << std::endl;
296 profile.reserve(profile_field.
value().size() / 2);
297 for (std::size_t i_word{0}; i_word < profile_field.
value().size();
299 profile.push_back(profile_field.
to_double(i_word));
302 std::cout << i_field <<
" "
303 <<
"profile size " << profile.size() << std::endl;
308 profileStandAlone.clear();
309 profileStandAlone.reserve(profileStandAlone_field.
value().size() / 2);
310 for (std::size_t i_word{0}; i_word < profileStandAlone_field.
value().size();
312 profileStandAlone.push_back(profileStandAlone_field.
to_double(i_word));
315 std::cout << i_field <<
" "
316 <<
"profileStandAlone size " << profileStandAlone.size()
321 std::cout << i_field <<
" "
322 <<
"timeFirstEvent = " << timeFirstEvent << std::endl;
326 std::cout << i_field <<
" "
327 <<
"timeFirstTrigger = " << timeFirstTrigger << std::endl;
331 std::cout << i_field <<
" "
332 <<
"timeLastEvent = " << timeLastEvent << std::endl;
336 std::cout << i_field <<
" "
337 <<
"timeLastTrigger = " << timeLastTrigger << std::endl;
341 std::cout << i_field <<
" "
342 <<
"trigger = " << trigger << std::endl;
346 std::cout << i_field <<
" "
347 <<
"triggerOffsetAcq = " << triggerOffsetAcq << std::endl;
351 std::cout << i_field <<
" "
352 <<
"triggerSelectionAcq = " << triggerSelectionAcq << std::endl;
358std::ostream& operator<<(std::ostream& os,
const FiberTrackerBinaryPacket& p) {
359 return (os <<
"FiberTracker Packet {" << p.acqStamp <<
"}");
404 tree_ =
new TTree(
"raw",
"Flattened and decoded raw FiberTracker data");
411 spill_tree_ =
new TTree(
"spill",
"Spill Meta-Data from FiberTrackerDAQ");
415 spill_tree_->Branch(
"acqTypeAllowed", &
spill_packet_.acqTypeAllowed);
417 spill_tree_->Branch(
"countsRecords", &
spill_packet_.countsRecords);
418 spill_tree_->Branch(
"countsRecordsWithZeroEvents",
420 spill_tree_->Branch(
"countsTrigs", &
spill_packet_.countsTrigs);
421 spill_tree_->Branch(
"cycleStamp", &
spill_packet_.cycleStamp);
422 spill_tree_->Branch(
"eventSelectionAcq", &
spill_packet_.eventSelectionAcq);
425 spill_tree_->Branch(
"profileStandAlone", &
spill_packet_.profileStandAlone);
427 spill_tree_->Branch(
"triggerOffsetAcq", &
spill_packet_.triggerOffsetAcq);
428 spill_tree_->Branch(
"triggerSelectionAcq",
443 std::cout <<
"no more events" << std::endl;
Base classes for all user event processing components to extend.
#define DECLARE_PRODUCER_NS(NS, CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
TDirectory * getHistoDirectory()
Access/create a directory in the histogram file for this event processor to create histograms and ana...
Implements an event buffer system for storing event data.
Class which represents the process under execution.
Base class for a module which produces a data product.
Class encapsulating parameters for configuring a processor.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Each "field" of data in a FiberTracker packet.
double to_double(const std::size_t i=0) const
convert two ints into a double
const std::vector< uint32_t > & value() const
Get the field value.
int to_int(const std::size_t i=0) const
conversion to a single int
std::string to_string() const
conversion from series of ints to string specific to FiberTrackerDAQ
long int to_long(const std::size_t i=0) const
long split across two ints
FiberTrackerField(utility::Reader &r, int i_field)
r - reader i_field - field we are supposed to be reading from
std::string output_name_
output object to put onto event bus
virtual void produce(framework::Event &event) final override
Process the event and put new data products into it.
virtual void configure(framework::config::Parameters &) final override
Callback for the EventProcessor to configure itself from the given set of parameters.
FiberTrackerEvent ft_event_
Current Event.
FiberTrackerBinaryPacket spill_packet_
packet being used for decoding
virtual void onProcessStart() final override
Callback for the EventProcessor to take any necessary action when the processing of events starts,...
packing::utility::Reader file_reader_
the file reader (if we are doing that)
bool ntuplize_
should we ntuplize?
std::string input_file_
input file
void open(const std::string &file_name)
Open a file with this reader.
Reader & read(WordType *w, std::size_t count)
Read the next 'count' words into the input handle.
Each one of these packets represents an entire spill of data.
std::vector< FiberTrackerEvent > eventsData
This is the actual event data in which we are interested.
utility::Reader & read(utility::Reader &r)
27 fields in order, all are present
int i_event
index of event we are on (for next)
A spill of events from a FiberTracker station.